Improve Parser::braceSubstitution() coverage
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
1 # MediaWiki Parser test cases
2 # Some taken from https://meta.wikimedia.org/wiki/Parser_testing
3 # All (C) their respective authors and released under the GPL
4 #
5 # The syntax should be fairly self-explanatory.
6 #
7 # Currently supported test options:
8 # One of the following three:
9 #
10 # (default) generate HTML output
11 # pst apply pre-save transform
12 # msg apply message transform
13 #
14 # Plus any combination of these:
15 #
16 # cat add category links
17 # (ignored by Parsoid, since it emits <link>s)
18 # ill add inter-language links
19 # (ignored by Parsoid, since it emits <link>s)
20 # subpage enable subpages (disabled by default)
21 # title=[[XXX]] run test using article title XXX
22 # language=XXX set content language to XXX for this test
23 # variant=XXX set the variant of language for this test (eg zh-tw)
24 # disabled do not run test
25 # parsoid parsoid-specific options (not run by PHP parser unless
26 # the test includes an html/php section)
27 # php php-only test (not run by the parsoid parser unless
28 # the test includes an html/parsoid section)
29 # showtitle make the first line the title
30 # showindicators make the first lines the page status indicators
31 # comment run through Linker::formatComment() instead of main parser
32 # local format section links in edit comment text as local links
33 # notoc disable table of contents
34 # thumbsize=NNN set the default thumb size to NNNpx for this test
35 # wrap include the normal wrapper <div class="mw-parser-output"> (since 1.30)
36 #
37 # You can also set the following parser properties via test options:
38 # wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
39 # wgLinkHolderBatchSize, wgRawHtml, wgInterwikiMagic,
40 # wgEnableMagicLinks
41 #
42 # For testing purposes, temporary articles can created:
43 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
44 # where '/' denotes a newline.
45
46 # This is the standard article assumed to exist.
47 !! article
48 Main Page
49 !! text
50 blah blah
51 !! endarticle
52
53 !!article
54 Foo
55 !!text
56 FOO
57 !!endarticle
58
59 !!article
60 Template:Foo
61 !!text
62 FOO
63 !!endarticle
64
65 !! article
66 Template:Blank
67 !! text
68 !! endarticle
69
70 !! article
71 Template:pipe
72 !! text
73 |
74 !! endarticle
75
76 !! article
77 Template:=
78 !! text
79 <nowiki>=</nowiki>
80 !! endarticle
81
82 !!article
83 MediaWiki:bad image list
84 !!text
85 * [[File:Bad.jpg]] except [[Nasty page]]
86 !!endarticle
87
88 !! article
89 Template:inner list
90 !! text
91 * item 1
92 !! endarticle
93
94 !! article
95 Template:tbl-start
96 !! text
97 {|
98 !! endarticle
99
100 !! article
101 Template:tbl-end
102 !! text
103 |}
104 !! endarticle
105
106 !! article
107 Template:echo
108 !! text
109 {{{1}}}
110 !! endarticle
111
112 !! article
113 Template:echo3
114 !! text
115 {{{1}}}
116 {{{1}}}
117 {{{1}}}
118 !! endarticle
119
120 // For Serbian; localize Template namespace
121 !! article
122 Шаблон:Echo
123 !! text
124 {{{1}}}
125 !! endarticle
126
127 !! article
128 Template:echo_with_span
129 !! text
130 <span>{{{1}}}</span>
131 !! endarticle
132
133 !! article
134 Template:echo_with_div
135 !! text
136 <div>{{{1}}}</div>
137 !! endarticle
138
139 !! article
140 Template:echo with depth
141 !! text
142 {{echo|{{{1}}}}}
143 !! endarticle
144
145 !! article
146 Template:blank_param
147 !! text
148 {{{1}}}
149 {{{}}}
150 !! endarticle
151
152 !! article
153 Template:table_attribs
154 !! text
155 <noinclude>
156 |</noinclude>style="color:red;"|Foo
157 !! endarticle
158
159 !! article
160 Template:table_attribs_2
161 !! text
162 <noinclude>
163 |</noinclude>style="color:red;"|Foo
164 |Bar||Baz
165 !! endarticle
166
167 !! article
168 Template:table_attribs_3
169 !! text
170 <noinclude>
171 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo
172 !! endarticle
173
174 !! article
175 Template:table_attribs_4
176 !! text
177 | style="background-color:#DC241f;" width="10px" |
178 !! endarticle
179
180 !! article
181 Template:table_attribs_5
182 !! text
183 <noinclude>
184 |</noinclude>style="color:red;"||Bar
185 !! endarticle
186
187 !! article
188 Template:table_attribs_6
189 !! text
190 style="background: <nowiki>
191
192
193 red;</nowiki>" |
194 !! endarticle
195
196 !! article
197 Template:table_attribs_7
198 !! text
199 <noinclude>
200 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
201 !! endarticle
202
203 !! article
204 Template:table_header_cells
205 !! text
206 {{table_attribs}}!!style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
207 !! endarticle
208
209 !! article
210 Template:table_cells
211 !! text
212 {{table_attribs}}||style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
213 !! endarticle
214
215 !! article
216 Template:PartialTable
217 !! text
218 {|
219 |-
220 !! endarticle
221
222 !! article
223 Template:image_attribs
224 !! text
225 <noinclude>
226 [[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
227 !! endarticle
228
229 ## See T48811 for details
230 !! article
231 Template:mixed_attr_content_template
232 !! text
233 style="color:red;" title="T48811"
234 |-
235 |foo
236 !! endarticle
237
238 !! article
239 Template:definition_list
240 !! text
241 one
242 ::two
243 !! endarticle
244
245 !! article
246 A?b
247 !! text
248 Weirdo titles!
249 !! endarticle
250
251 !!article
252 Template:Bullet
253 !!text
254 * Bar
255 !!endarticle
256
257 !!article
258 Template:OpenTable
259 !!text
260 {|
261 !!endarticle
262
263 !!article
264 Template:EmptyLITest
265 !!text
266 *a
267 *
268 *
269 *b
270 !!endarticle
271
272 !!article
273 Template:EmptyTRTest
274 !!text
275 {|
276 |-
277 |-
278 |foo
279 |-
280 |-
281 |bar
282 |}
283 !!endarticle
284
285 !!article
286 Template:EmptyTRWithHTMLAttrTest
287 !!text
288 <table>
289 <tr align="center"></tr>
290 <tr><td>foo</td></tr>
291 <tr align="center"></tr>
292 <tr><td>bar</td></tr>
293 </table>
294 !!endarticle
295
296 !! article
297 Template:With: Colon
298 !! text
299 Template with colon
300 !! endarticle
301
302 ###
303 ### Basic tests
304 ###
305
306 !! test
307 Blank input
308 !! wikitext
309 !! html
310 !! end
311
312 !! test
313 Simple paragraph
314 !! wikitext
315 This is a simple paragraph.
316 !! html
317 <p>This is a simple paragraph.
318 </p>
319 !! end
320
321 !! test
322 Paragraphs with extra newline spacing
323 !! wikitext
324 foo
325
326 bar
327
328
329 baz
330
331
332
333 booz
334 !! html
335 <p>foo
336 </p><p>bar
337 </p><p><br />
338 baz
339 </p><p><br />
340 </p><p>booz
341 </p>
342 !! end
343
344 !! test
345 Paragraphs with newline spacing with comment lines in between
346 !! wikitext
347 ----
348 a
349 <!--foo-->
350 b
351 ----
352 a
353 <!--foo--><!--More than 1 comment, still stripped-->
354 b
355 ----
356 a
357 <!--foo--> <!----> <!-- bar -->
358 b
359 ----
360 a
361 <!--foo-->
362
363 b
364 ----
365 a
366
367 <!--foo-->
368 b
369 ----
370 a
371 <!--foo-->
372
373
374 b
375 ----
376 a
377
378
379 <!--foo-->
380 b
381 ----
382 !! html
383 <hr />
384 <p>a
385 b
386 </p>
387 <hr />
388 <p>a
389 b
390 </p>
391 <hr />
392 <p>a
393 b
394 </p>
395 <hr />
396 <p>a
397 </p><p>b
398 </p>
399 <hr />
400 <p>a
401 </p><p>b
402 </p>
403 <hr />
404 <p>a
405 </p><p><br />
406 b
407 </p>
408 <hr />
409 <p>a
410 </p><p><br />
411 b
412 </p>
413 <hr />
414
415 !! end
416
417 !! test
418 Paragraphs with newline spacing with non-empty white-space lines in between
419 !! wikitext
420 ----
421 a
422
423 b
424 ----
425 a
426
427
428 b
429 ----
430 !! html
431 <hr />
432 <p>a
433 </p><p>b
434 </p>
435 <hr />
436 <p>a
437 </p><p><br />
438 b
439 </p>
440 <hr />
441
442 !! end
443
444 !! test
445 Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
446 !! wikitext
447 ----
448 a
449 <!--foo-->
450 b
451 ----
452 a
453 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
454 b
455 ----
456 a
457
458 <!--foo-->
459 <!--bar-->
460 b
461 ----
462 a
463
464 <!--foo-->
465 <!--bar-->
466
467 b
468 ----
469 !! html
470 <hr />
471 <p>a
472 b
473 </p>
474 <hr />
475 <p>a
476 b
477 </p>
478 <hr />
479 <p>a
480 </p><p>b
481 </p>
482 <hr />
483 <p>a
484 </p><p><br />
485 b
486 </p>
487 <hr />
488
489 !! end
490
491 !! test
492 Extra newlines: More paragraphs with indented comment
493 !! wikitext
494 a
495
496 <!--boo-->
497
498 b
499 !! html
500 <p>a
501 </p><p><br />
502 b
503 </p>
504 !!end
505
506 !! test
507 Extra newlines followed by heading
508 !! wikitext
509 a
510
511
512
513 =b=
514 [[a]]
515
516
517 =b=
518 !! html
519 <p>a
520 </p><p><br />
521 </p>
522 <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>
523 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
524 </p><p><br />
525 </p>
526 <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>
527
528 !! end
529
530 !! test
531 Extra newlines between heading and content are swallowed
532 !! wikitext
533 =b=
534
535
536
537 [[a]]
538 !! html
539 <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>
540 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
541 </p>
542 !! end
543
544 !! test
545 Heading with line break in nowiki
546 !! options
547 parsoid=wt2html
548 !! config
549 wgFragmentMode=[ 'html5', 'legacy' ]
550 !! wikitext
551 ==A <nowiki>B
552 C</nowiki>==
553 !! html/php
554 <h2><span id="A_B.0AC"></span><span class="mw-headline" id="A_B
555 C">A B
556 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>
557
558 !! html/parsoid
559 <h2 id="A_B
560 C"><span id="A_B.0AC" typeof="mw:FallbackId"></span>A <span typeof="mw:Nowiki">B
561 C</span></h2>
562 !! end
563
564 !! test
565 Parsing an URL
566 !! wikitext
567 http://fr.wikipedia.org/wiki/🍺
568 <!-- EasterEgg we love beer, better be able be able to link to it -->
569 !! html
570 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
571 </p>
572 !! end
573
574 !! test
575 Simple list
576 !! wikitext
577 *Item 1
578 *Item 2
579 !! html
580 <ul><li>Item 1</li>
581 <li>Item 2</li></ul>
582
583 !! end
584
585 !! test
586 Italics and bold
587 !! wikitext
588 *plain
589 *plain''italic''plain
590 *plain''italic''plain''italic''plain
591 *plain'''bold'''plain
592 *plain'''bold'''plain'''bold'''plain
593 *plain''italic''plain'''bold'''plain
594 *plain'''bold'''plain''italic''plain
595 *plain''italic'''bold-italic'''italic''plain
596 *plain'''bold''bold-italic''bold'''plain
597 *plain'''''bold-italic'''italic''plain
598 *plain'''''bold-italic''bold'''plain
599 *plain''italic'''bold-italic'''''plain
600 *plain'''bold''bold-italic'''''plain
601 *plain l'''italic''plain
602 *plain l''''bold''' plain
603 !! html
604 <ul><li>plain</li>
605 <li>plain<i>italic</i>plain</li>
606 <li>plain<i>italic</i>plain<i>italic</i>plain</li>
607 <li>plain<b>bold</b>plain</li>
608 <li>plain<b>bold</b>plain<b>bold</b>plain</li>
609 <li>plain<i>italic</i>plain<b>bold</b>plain</li>
610 <li>plain<b>bold</b>plain<i>italic</i>plain</li>
611 <li>plain<i>italic<b>bold-italic</b>italic</i>plain</li>
612 <li>plain<b>bold<i>bold-italic</i>bold</b>plain</li>
613 <li>plain<i><b>bold-italic</b>italic</i>plain</li>
614 <li>plain<b><i>bold-italic</i>bold</b>plain</li>
615 <li>plain<i>italic<b>bold-italic</b></i>plain</li>
616 <li>plain<b>bold<i>bold-italic</i></b>plain</li>
617 <li>plain l'<i>italic</i>plain</li>
618 <li>plain l'<b>bold</b> plain</li></ul>
619
620 !! end
621
622 # this example taken from the [[simple:Moon]] article (T49326)
623 !! test
624 Italics and possessives (1)
625 !! wikitext
626 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
627 !! html
628 <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
629 </p>
630 !! end
631
632 # this example taken from [[en:Flaming Pie]] (T51926)
633 !! test
634 Italics and possessives (2)
635 !! wikitext
636 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
637 !! html
638 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
639 </p>
640 !! end
641
642 # this example taken from [[en:Dictionary]] (T51926)
643 !! test
644 Italics and possessives (3)
645 !! wikitext
646 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''.
647 !! html
648 <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>.
649 </p>
650 !! end
651
652
653 ###
654 ### 2-quote opening sequence tests
655 ###
656 !! test
657 Italics and bold: 2-quote opening sequence: (2,2)
658 !! wikitext
659 ''foo''
660 !! html
661 <p><i>foo</i>
662 </p>
663 !!end
664
665 !! test
666 Italics and bold: 2-quote opening sequence: (2,3)
667 !! wikitext
668 ''foo'''
669 !! html/*
670 <p><i>foo'</i>
671 </p>
672 !!end
673
674 !! test
675 Italics and bold: 2-quote opening sequence: (2,4)
676 !! options
677 parsoid=wt2html
678 !! wikitext
679 ''foo''''
680 !! html/*
681 <p><i>foo''</i>
682 </p>
683 !!end
684
685 # same html as previous, but wikitext adjusted to match parsoid html2wt
686 !! test
687 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
688 !! wikitext
689 ''foo<nowiki>''</nowiki>''
690 !! html
691 <p><i>foo''</i>
692 </p>
693 !! end
694
695 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
696 !! test
697 Italics and bold: 2-quote opening sequence: (2,5)
698 !! options
699 parsoid=wt2html
700 !! wikitext
701 ''foo'''''
702 !! html/php
703 <p><i>foo</i>
704 </p>
705 !! html/parsoid
706 <p><i>foo</i><b></b>
707 </p>
708 !!end
709
710 # same html as previous, but wikitext adjusted to match parsoid html2wt
711 !! test
712 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
713 !! wikitext
714 ''foo'''''<nowiki/>'''
715 !! html/php
716 <p><i>foo</i>
717 </p>
718 !! html/parsoid
719 <p><i>foo</i><b></b>
720 </p>
721 !! end
722
723
724 ###
725 ### 3-quote opening sequence tests
726 ###
727
728 !! test
729 Italics and bold: 3-quote opening sequence: (3,2)
730 !! wikitext
731 '''foo''
732 !! html/*
733 <p>'<i>foo</i>
734 </p>
735 !!end
736
737 !! test
738 Italics and bold: 3-quote opening sequence: (3,3)
739 !! wikitext
740 '''foo'''
741 !! html
742 <p><b>foo</b>
743 </p>
744 !!end
745
746 !! test
747 Italics and bold: 3-quote opening sequence: (3,4)
748 !! wikitext
749 '''foo''''
750 !! html/*
751 <p><b>foo'</b>
752 </p>
753 !!end
754
755 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
756 !! test
757 Italics and bold: 3-quote opening sequence: (3,5)
758 !! options
759 parsoid=wt2html
760 !! wikitext
761 '''foo'''''
762 !! html/php
763 <p><b>foo</b>
764 </p>
765 !! html/parsoid
766 <p><b>foo</b><i></i>
767 </p>
768 !!end
769
770 # same html as previous, but wikitext adjusted to match parsoid html2wt
771 !! test
772 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
773 !! wikitext
774 '''foo'''''<nowiki/>''
775 !! html/php
776 <p><b>foo</b>
777 </p>
778 !! html/parsoid
779 <p><b>foo</b><i></i>
780 </p>
781 !! end
782
783
784 ###
785 ### 4-quote opening sequence tests
786 ###
787
788 !! test
789 Italics and bold: 4-quote opening sequence: (4,2)
790 !! options
791 parsoid=wt2html
792 !! wikitext
793 ''''foo''
794 !! html/*
795 <p>''<i>foo</i>
796 </p>
797 !!end
798
799 # same html as previous, but wikitext adjusted to match parsoid html2wt
800 !! test
801 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
802 !! wikitext
803 <nowiki>''</nowiki>''foo''
804 !! html
805 <p>''<i>foo</i>
806 </p>
807 !! end
808
809 !! test
810 Italics and bold: 4-quote opening sequence: (4,3)
811 !! wikitext
812 ''''foo'''
813 !! html/*
814 <p>'<b>foo</b>
815 </p>
816 !!end
817
818 !! test
819 Italics and bold: 4-quote opening sequence: (4,4)
820 !! options
821 parsoid=wt2html
822 !! wikitext
823 ''''foo''''
824 !! html/*
825 <p>'<b>foo'</b>
826 </p>
827 !!end
828
829 # same html as previous, but wikitext adjusted to match parsoid html2wt
830 !! test
831 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
832 !! wikitext
833 '<nowiki/>'''foo''''
834 !! html
835 <p>'<b>foo'</b>
836 </p>
837 !! end
838
839 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
840 !! test
841 Italics and bold: 4-quote opening sequence: (4,5)
842 !! options
843 parsoid=wt2html
844 !! wikitext
845 ''''foo'''''
846 !! html/php
847 <p>'<b>foo</b>
848 </p>
849 !! html/parsoid
850 <p>'<b>foo</b><i></i>
851 </p>
852 !!end
853
854 # same html as previous, but wikitext adjusted to match parsoid html2wt
855 !! test
856 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
857 !! wikitext
858 '<nowiki/>'''foo'''''<nowiki/>''
859 !! html/php
860 <p>'<b>foo</b>
861 </p>
862 !! html/parsoid
863 <p>'<b>foo</b><i></i>
864 </p>
865 !! end
866
867
868 ###
869 ### 5-quote opening sequence tests
870 ###
871
872 !! test
873 Italics and bold: 5-quote opening sequence: (5,2)
874 !! options
875 parsoid=wt2html
876 !! wikitext
877 '''''foo''
878 !! html/*
879 <p><b><i>foo</i></b>
880 </p>
881 !!end
882
883 # same html as previous, but wikitext adjusted to match parsoid html2wt
884 !! test
885 Italics and bold: 5-quote opening sequence: (5,2+3)
886 !! wikitext
887 '''''foo'''''
888 !! html/*
889 <p><i><b>foo</b></i>
890 </p>
891 !! end
892
893 !! test
894 Italics and bold: 5-quote opening sequence: (5,3)
895 !! options
896 parsoid=wt2html
897 !! wikitext
898 '''''foo'''
899 !! html/*
900 <p><i><b>foo</b></i>
901 </p>
902 !!end
903
904 # same html as previous, but wikitext adjusted to match parsoid html2wt
905 !! test
906 Italics and bold: 5-quote opening sequence: (5,3+2)
907 !! wikitext
908 '''''foo'''''
909 !! html
910 <p><i><b>foo</b></i>
911 </p>
912 !! end
913
914 !! test
915 Italics and bold: 5-quote opening sequence: (5,4)
916 !! options
917 parsoid=wt2html
918 !! wikitext
919 '''''foo''''
920 !! html/*
921 <p><i><b>foo'</b></i>
922 </p>
923 !!end
924
925 !! test
926 Italics and bold: 5-quote opening sequence: (5,5)
927 !! wikitext
928 '''''foo'''''
929 !! html
930 <p><i><b>foo</b></i>
931 </p>
932 !!end
933
934 !! test
935 Italics and bold: 5-quote opening sequence: (5,6)
936 !! wikitext
937 '''''foo''''''
938 !! html/*
939 <p><i><b>foo'</b></i>
940 </p>
941 !! end
942
943 ###
944 ### multiple quote sequences in a line
945 ###
946
947 !! test
948 Italics and bold: multiple quote sequences: (2,4,2)
949 !! options
950 parsoid=wt2html
951 !! wikitext
952 ''foo''''bar''
953 !! html/*
954 <p><i>foo'<b>bar</b></i>
955 </p>
956 !! end
957
958 # same html as previous, but wikitext adjusted to match parsoid html2wt
959 !! test
960 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
961 !! wikitext
962 ''foo'<nowiki/>'''bar'''''
963 !! html
964 <p><i>foo'<b>bar</b></i>
965 </p>
966 !! end
967
968 !! test
969 Italics and bold: multiple quote sequences: (2,4,3)
970 !! options
971 parsoid=wt2html
972 !! wikitext
973 ''foo''''bar'''
974 !! html/*
975 <p><i>foo'<b>bar</b></i>
976 </p>
977 !! end
978
979 # same html as previous, but wikitext adjusted to match parsoid html2wt
980 !! test
981 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
982 !! wikitext
983 ''foo'<nowiki/>'''bar'''''
984 !! html
985 <p><i>foo'<b>bar</b></i>
986 </p>
987 !! end
988
989 !! test
990 Italics and bold: multiple quote sequences: (2,4,4)
991 !! options
992 parsoid=wt2html
993 !! wikitext
994 ''foo''''bar''''
995 !! html/*
996 <p><i>foo'<b>bar'</b></i>
997 </p>
998 !! end
999
1000 # same html as previous, but wikitext adjusted to match parsoid html2wt
1001 !! test
1002 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
1003 !! wikitext
1004 ''foo'<nowiki/>'''bar'<nowiki/>'''''
1005 !! html
1006 <p><i>foo'<b>bar'</b></i>
1007 </p>
1008 !! end
1009
1010 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1011 !! test
1012 Italics and bold: multiple quote sequences: (3,4,2)
1013 !! options
1014 parsoid=wt2html
1015 !! wikitext
1016 '''foo''''bar''
1017 !! html/php
1018 <p><b>foo'</b>bar
1019 </p>
1020 !! html/parsoid
1021 <p><b>foo'</b>bar<i></i>
1022 </p>
1023 !! end
1024
1025 # same html as previous, but wikitext adjusted to match parsoid html2wt
1026 !! test
1027 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1028 !! wikitext
1029 '''foo''''bar''<nowiki/>''
1030 !! html/php
1031 <p><b>foo'</b>bar
1032 </p>
1033 !! html/parsoid
1034 <p><b>foo'</b>bar<i></i>
1035 </p>
1036 !! end
1037
1038 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1039 !! test
1040 Italics and bold: multiple quote sequences: (3,4,3)
1041 !! options
1042 parsoid=wt2html
1043 !! wikitext
1044 '''foo''''bar'''
1045 !! html/php
1046 <p><b>foo'</b>bar
1047 </p>
1048 !! html/parsoid
1049 <p><b>foo'</b>bar<b></b>
1050 </p>
1051 !! end
1052
1053 # same html as previous, but wikitext adjusted to match parsoid html2wt
1054 !! test
1055 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1056 !! wikitext
1057 '''foo''''bar'''<nowiki/>'''
1058 !! html/php
1059 <p><b>foo'</b>bar
1060 </p>
1061 !! html/parsoid
1062 <p><b>foo'</b>bar<b></b>
1063 </p>
1064 !! end
1065
1066 ###
1067 ### other quote tests
1068 ###
1069 !! test
1070 Italics and bold: other quote tests: (2,3,5)
1071 !! wikitext
1072 ''this is about '''foo's family'''''
1073 !! html
1074 <p><i>this is about <b>foo's family</b></i>
1075 </p>
1076 !!end
1077
1078
1079 !! test
1080 Italics and bold: other quote tests: (2,(3,3),2)
1081 !! wikitext
1082 ''this is about '''foo's''' family''
1083 !! html
1084 <p><i>this is about <b>foo's</b> family</i>
1085 </p>
1086 !!end
1087
1088
1089 !! test
1090 Italics and bold: other quote tests: (3,2,3,2)
1091 !! options
1092 parsoid=wt2html
1093 !! wikitext
1094 '''this is about ''foo'''s family''
1095 !! html/*
1096 <p><b>this is about <i>foo</i></b><i>s family</i>
1097 </p>
1098 !!end
1099
1100
1101 # same html as previous, but wikitext adjusted to match parsoid html2wt
1102 !! test
1103 Italics and bold: other quote tests: (3,2,3+2+2,2)
1104 !! wikitext
1105 '''this is about ''foo'''''<nowiki/>''s family''
1106 !! html
1107 <p><b>this is about <i>foo</i></b><i>s family</i>
1108 </p>
1109 !! end
1110
1111
1112 !! test
1113 Italics and bold: other quote tests: (3,2,3,3)
1114 !! wikitext
1115 '''this is about ''foo'''s family'''
1116 !! html/*
1117 <p>'<i>this is about </i>foo<b>s family</b>
1118 </p>
1119 !!end
1120
1121
1122 !! test
1123 Italics and bold: other quote tests: (3,(2,2),3)
1124 !! wikitext
1125 '''this is about ''foo's'' family'''
1126 !! html
1127 <p><b>this is about <i>foo's</i> family</b>
1128 </p>
1129 !!end
1130
1131
1132 !! test
1133 Italicized possessive
1134 !! wikitext
1135 The ''[[Main Page]]'''s talk page.
1136 !! html/php
1137 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1138 </p>
1139 !! html/parsoid
1140 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1141 !! end
1142
1143 !! test
1144 Quote balancing context should be restricted to td/th cells on the same wikitext line
1145 !! options
1146 parsoid=wt2html,wt2wt
1147 !! wikitext
1148 {|
1149 !''a!!''b
1150 |''a||''b
1151 |}
1152 !! html+tidy
1153 <table>
1154 <tbody><tr>
1155 <th><i>a</i></th>
1156 <th><i>b</i>
1157 </th>
1158 <td><i>a</i></td>
1159 <td><i>b</i>
1160 </td></tr></tbody></table>
1161 !! end
1162
1163 ###
1164 ### Non-html5 tags
1165 ###
1166
1167 !! test
1168 Non-html5 tags should be accepted
1169 !! wikitext
1170 <center>''foo''</center>
1171 <big>''foo''</big>
1172 <font>''foo''</font>
1173 <strike>''foo''</strike>
1174 <tt>''foo''</tt>
1175 !! html
1176 <center><i>foo</i></center>
1177 <p><big><i>foo</i></big>
1178 <font><i>foo</i></font>
1179 <strike><i>foo</i></strike>
1180 <tt><i>foo</i></tt>
1181 </p>
1182 !! end
1183
1184 !! test
1185 <wbr> is valid wikitext (T54468)
1186 !! wikitext
1187 <wbr>
1188 !! html
1189 <p><wbr />
1190 </p>
1191 !! end
1192
1193 # <strike> is HTML4, <s> is HTML4/5.
1194 !! test
1195 <s> or <strike> for strikethrough
1196 !! wikitext
1197 <strike>strike</strike>
1198
1199 <s>s</s>
1200 !! html
1201 <p><strike>strike</strike>
1202 </p><p><s>s</s>
1203 </p>
1204 !! end
1205
1206 ## a not permitted
1207 ## i,b,br omitted
1208 !! test
1209 Text-level semantic html elements in wikitext
1210 !! wikitext
1211 <em>text</em>
1212 <strong>text</strong>
1213 <small>text</small>
1214 <s>text</s>
1215 <cite>text</cite>
1216 <q>text</q>
1217 <dfn>text</dfn>
1218 <abbr>text</abbr>
1219 <data>text</data>
1220 <time>text</time>
1221 <code>text</code>
1222 <var>text</var>
1223 <samp>text</samp>
1224 <kbd>text</kbd>
1225 <sub>text</sub>
1226 <u>text</u>
1227 <mark>text</mark>
1228 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1229 <bdi>text</bdi>
1230 <bdo>text</bdo>
1231 <span>text</span>
1232 <wbr />
1233 !! html
1234 <p><em>text</em>
1235 <strong>text</strong>
1236 <small>text</small>
1237 <s>text</s>
1238 <cite>text</cite>
1239 <q>text</q>
1240 <dfn>text</dfn>
1241 <abbr>text</abbr>
1242 <data>text</data>
1243 <time>text</time>
1244 <code>text</code>
1245 <var>text</var>
1246 <samp>text</samp>
1247 <kbd>text</kbd>
1248 <sub>text</sub>
1249 <u>text</u>
1250 <mark>text</mark>
1251 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1252 <bdi>text</bdi>
1253 <bdo>text</bdo>
1254 <span>text</span>
1255 <wbr />
1256 </p>
1257 !! end
1258
1259 # test cases taken from
1260 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1261 !! test
1262 Ruby markup (W3C-style)
1263 !! wikitext
1264 ;Mono-ruby for individual base characters
1265 :<ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1266 ;Group ruby
1267 :<ruby>今日<rt>きょう</rt></ruby>
1268 ;Jukugo ruby
1269 :<ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1270 ;Inline ruby
1271 :<ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1272 ;Double-sided ruby
1273 :<ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1274
1275 <ruby>
1276 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1277 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1278 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1279 </ruby>
1280 !! html
1281 <dl><dt>Mono-ruby for individual base characters</dt>
1282 <dd><ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1283 <dt>Group ruby</dt>
1284 <dd><ruby>今日<rt>きょう</rt></ruby></dd>
1285 <dt>Jukugo ruby</dt>
1286 <dd><ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1287 <dt>Inline ruby</dt>
1288 <dd><ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1289 <dt>Double-sided ruby</dt>
1290 <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>
1291 <p><ruby>
1292 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1293 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1294 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1295 </ruby>
1296 </p>
1297 !! end
1298
1299 # The next two test different paths in the sanitizer.
1300 !! test
1301 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1302 !! wikitext
1303 <blockquote|>a</blockquote>
1304
1305 <b→> doesn't terminate </b→>
1306
1307 <bä> doesn't terminate </bä>
1308
1309 <boo> doesn't terminate </boo>
1310
1311 <s.foo> doesn't terminate </s.foo>
1312
1313 <sub-ID#1>
1314 !! html
1315 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1316 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1317 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1318 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1319 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1320 </p><p>&lt;sub-ID#1&gt;
1321 </p>
1322 !! end
1323
1324 !! test
1325 Non-word characters don't terminate tag names
1326 !! wikitext
1327 <blockquote|>a</blockquote>
1328
1329 <b→> doesn't terminate </b→>
1330
1331 <bä> doesn't terminate </bä>
1332
1333 <boo> doesn't terminate </boo>
1334
1335 <s.foo> doesn't terminate </s.foo>
1336
1337 <sub-ID#1>
1338 !! html+tidy
1339 <p>&lt;blockquote|&gt;a
1340 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1341 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1342 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1343 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1344 </p><p>&lt;sub-ID#1&gt;
1345 </p>
1346 !! end
1347
1348 ###
1349 ### See tests/parser/parserTestsParserHook.php for the <tåg> extension)
1350 ### This checks that HTML5 tags (with non-word characters in the tag
1351 ### name) make it safely through the parser -- the Sanitizer will
1352 ### munge them later, as it should.
1353 ###
1354 !! test
1355 Non-word characters are valid in extension tags (T19663)
1356 !! wikitext
1357 <tåg>tåg</tåg>
1358 !! html/php
1359 <pre>
1360 'tåg'
1361 array (
1362 )
1363 </pre>
1364
1365 !! html/parsoid
1366 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1367 !! end
1368
1369 !! test
1370 Isolated close tags should be treated as literal text (T54760)
1371 !! options
1372 parsoid=wt2html
1373 !! wikitext
1374 </b>
1375
1376 <s.foo>s</s>
1377 !! html/php+tidy
1378 <p class="mw-empty-elt">
1379 </p><p>&lt;s.foo&gt;s
1380 </p>
1381 !! html/parsoid
1382 <p>&lt;s.foo&gt;s</p>
1383 !! end
1384
1385 ###
1386 ### Special characters
1387 ###
1388
1389 !! test
1390 Bare pipe character (T54363)
1391 !! wikitext
1392 |
1393 !! html
1394 <p>|
1395 </p>
1396 !! end
1397
1398 !! test
1399 Bare pipe character from a template (T54363)
1400 !! wikitext
1401 {{pipe}}
1402 !! html
1403 <p>|
1404 </p>
1405 !! end
1406
1407 ###
1408 ### <nowiki> test cases
1409 ###
1410
1411 !! test
1412 <nowiki> unordered list
1413 !! wikitext
1414 <nowiki>* This is not an unordered list item.</nowiki>
1415 !! html/php
1416 <p>* This is not an unordered list item.
1417 </p>
1418 !! html/parsoid
1419 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1420 !! end
1421
1422 !! test
1423 <nowiki> spacing
1424 !! wikitext
1425 <nowiki>Lorem ipsum dolor
1426
1427 sed abit.
1428 sed nullum.
1429
1430 :and a colon
1431 </nowiki>
1432 !! html/php
1433 <p>Lorem ipsum dolor
1434
1435 sed abit.
1436 sed nullum.
1437
1438 :and a colon
1439
1440 </p>
1441 !! html/parsoid
1442 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1443
1444 sed abit.
1445 sed nullum.
1446
1447 :and a colon
1448 </span></p>
1449 !! end
1450
1451 !! test
1452 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1453 !! wikitext
1454 <nowiki><span class="error"></nowiki>
1455 !! html/php
1456 <p>&lt;span class="error"&gt;
1457 </p>
1458 !! html/parsoid
1459 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1460 !! end
1461
1462 !! test
1463 nowiki 3
1464 !! wikitext
1465 :There is not nowiki.
1466 :There is <nowiki>nowiki</nowiki>.
1467
1468 #There is not nowiki.
1469 #There is <nowiki>nowiki</nowiki>.
1470
1471 *There is not nowiki.
1472 *There is <nowiki>nowiki</nowiki>.
1473 !! html/php
1474 <dl><dd>There is not nowiki.</dd>
1475 <dd>There is nowiki.</dd></dl>
1476 <ol><li>There is not nowiki.</li>
1477 <li>There is nowiki.</li></ol>
1478 <ul><li>There is not nowiki.</li>
1479 <li>There is nowiki.</li></ul>
1480
1481 !! html/parsoid
1482 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1483 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1484
1485 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1486 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1487
1488 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1489 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1490 !! end
1491
1492 !! test
1493 Entities inside <nowiki>
1494 !! wikitext
1495 <nowiki>&lt;</nowiki>
1496 !! html/php
1497 <p>&lt;
1498 </p>
1499 !! html/parsoid
1500 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1501 !! end
1502
1503 !! test
1504 Entities inside template parameters
1505 !! wikitext
1506 {{echo|&ndash;}}
1507 !! html/php+tidy
1508 <p>&#8211;
1509 </p>
1510 !! html/parsoid
1511 <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>
1512 !! end
1513
1514 !! test
1515 Properly escape nowiki when combined with other wiki markup
1516 !! options
1517 parsoid=html2wt
1518 !! html/parsoid
1519 <p>* &lt;/nowiki&gt; tag</p>
1520 !! wikitext
1521 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1522 !! end
1523
1524 !! test
1525 T93824: Put escaped HTML tags inside nowiki
1526 !! options
1527 parsoid=html2wt
1528 !! html/parsoid
1529 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1530 !! wikitext
1531 <nowiki><h2>foo</h2></nowiki>
1532 !! end
1533
1534 !! test
1535 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1536 !! options
1537 parsoid=html2wt
1538 !! html/parsoid
1539 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1540 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1541 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1542 !! wikitext
1543 This text: L'[[Foo]]
1544 This text: L<nowiki>''</nowiki>[[Foo]]
1545 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1546 !! end
1547
1548 # This test fails because wikitext whitespace is not normalized before comparing.
1549 !! test
1550 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1551 !! options
1552 parsoid=html2wt
1553 !! html/parsoid
1554 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1555 </p>
1556 !! wikitext
1557 This text : L<nowiki>''</nowiki>[[Foo]]
1558 !! end
1559
1560 # This test and the next one are html2wt only as they test that incorrect wikitext
1561 # passed in template arguments gets escaped or wrapped in nowikis where required.
1562 !! test
1563 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1564 !! options
1565 parsoid=html2wt
1566 !! html/parsoid
1567 <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>
1568 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo|bar |[[&quot;}},&quot;i&quot;:0}}]}" about="#mwt2"></p>
1569 !! wikitext
1570 {{echo|foo{{!}}bar}}
1571 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1572 !! end
1573
1574 !! test
1575 T53961: Output correct nowikis in template arguments
1576 !! options
1577 parsoid=html2wt
1578 !! html/parsoid
1579 <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>
1580 <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>
1581 <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>
1582 <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>
1583 <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>
1584 !! wikitext
1585 {{echo|a [ b}}
1586 {{echo|<nowiki>a }} b</nowiki>}}
1587 {{echo|<nowiki>a [[ b</nowiki>}}
1588 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1589 {{echo|a <nowiki>}</nowiki>}}
1590 !! end
1591
1592 !! test
1593 Cases where "!!" needs nowiki protection
1594 !! options
1595 parsoid=html2wt
1596 !! html/parsoid
1597 <table>
1598 <tr><th>this needs protection !! here</th></tr>
1599 </table>
1600
1601 <table>
1602 <tr><th>this does not need
1603 protection !! here</th></tr>
1604 </table>
1605 !! wikitext
1606 {|
1607 !<nowiki>this needs protection !! here</nowiki>
1608 |}
1609
1610 {|
1611 !this does not need
1612 protection !! here
1613 |}
1614 !! end
1615
1616 ###
1617 ### Comments
1618 ###
1619 !! test
1620 Comments and Indent-Pre
1621 !! wikitext
1622 <!-- comment 1 --> asdf
1623
1624 <!-- comment 1 --> asdf
1625 <!-- comment 2 -->
1626
1627 <!-- comment 1 --> asdf
1628 <!-- comment 2 -->xyz
1629
1630 <!-- comment 1 --> asdf
1631 <!-- comment 2 --> xyz
1632 !! html
1633 <pre>asdf
1634 </pre>
1635 <pre>asdf
1636 </pre>
1637 <pre>asdf
1638 </pre>
1639 <p>xyz
1640 </p>
1641 <pre>asdf
1642 xyz
1643 </pre>
1644 !! end
1645
1646 !! test
1647 Comment test 2a
1648 !! wikitext
1649 asdf
1650 <!-- comment 1 -->
1651 jkl
1652 !! html
1653 <p>asdf
1654 jkl
1655 </p>
1656 !! end
1657
1658 !! test
1659 Comment test 2b
1660 !! wikitext
1661 asdf
1662 <!-- comment 1 -->
1663
1664 jkl
1665 !! html
1666 <p>asdf
1667 </p><p>jkl
1668 </p>
1669 !! end
1670
1671 !! test
1672 Comment test 3
1673 !! wikitext
1674 asdf
1675 <!-- comment 1 -->
1676 <!-- comment 2 -->
1677 jkl
1678 !! html
1679 <p>asdf
1680 jkl
1681 </p>
1682 !! end
1683
1684 !! test
1685 Comment test 4
1686 !! wikitext
1687 asdf<!-- comment 1 -->jkl
1688 !! html
1689 <p>asdfjkl
1690 </p>
1691 !! end
1692
1693 !! test
1694 Comment spacing
1695 !! wikitext
1696 a
1697 <!-- foo --> b <!-- bar -->
1698 c
1699 !! html
1700 <p>a
1701 </p>
1702 <pre> b
1703 </pre>
1704 <p>c
1705 </p>
1706 !! end
1707
1708 !! test
1709 Comment whitespace
1710 !! wikitext
1711 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1712 !! html
1713
1714 !! end
1715
1716 !! test
1717 Comment semantics and delimiters
1718 !! wikitext
1719 <!-- --><!----><!-----><!------>
1720 !! html/php
1721
1722 !! html/parsoid
1723 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1724 !! end
1725
1726 !! test
1727 Comment semantics and delimiters, redux
1728 !! wikitext
1729 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1730 -- foo -- funky huh? ... -->
1731 !! html/php
1732
1733 !! html/parsoid
1734 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1735 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1736 !! end
1737
1738 !! test
1739 Comment semantics and delimiters: directors cut
1740 !! wikitext
1741 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1742 everything starting with < followed by !-- until the first -- and > we see,
1743 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1744 -->-->
1745 !! html/php
1746 <p>--&gt;
1747 </p>
1748 !! html/parsoid
1749 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1750 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1751 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1752 --><p>--></p>
1753 !! end
1754
1755 !! test
1756 Comment semantics: nesting
1757 !! wikitext
1758 <!--<!-- no, we're not going to do anything fancy here -->-->
1759 !! html/php
1760 <p>--&gt;
1761 </p>
1762 !! html/parsoid
1763 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1764 !! end
1765
1766 # Parsoid closes the unclosed comment, even if it means a slight
1767 # round-trip diff.
1768 !! test
1769 Comment semantics: unclosed comment at end
1770 !! options
1771 parsoid=wt2html,html2html
1772 !! wikitext
1773 <!--This comment will run out to the end of the document
1774 !! html/php
1775
1776 !! html/parsoid
1777 <!--This comment will run out to the end of the document-->
1778 !! end
1779
1780 !! test
1781 Comment semantics: normalize comments to play nice with XML and browsers
1782 !! wikitext
1783 <!-- Browsers --!> think this is closed -->
1784 <!--> This would normally be text -->
1785 <!---> As would this -->
1786 <!-- XML doesn't like trailing dashes -------->
1787 <!-- Nor doubled hyphens -- anywhere in the data -->
1788 But this is not a comment.
1789 !! html/php
1790 <p>But this is not a comment.
1791 </p>
1792 !! html/parsoid
1793 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1794 <!--&#x3E; This would normally be text -->
1795 <!--&#x2D;&#x3E; As would this -->
1796 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1797 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1798 <p>But this is not a comment.</p>
1799 !! end
1800
1801 !! test
1802 Comment semantics: round-trip even text which contains encoded -->
1803 !! wikitext
1804 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1805 !! html/parsoid
1806 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1807 !! end
1808
1809 !! test
1810 Comment in template title
1811 !! wikitext
1812 {{f<!---->oo}}
1813 !! html
1814 <p>FOO
1815 </p>
1816 !! end
1817
1818 !! test
1819 Comment on its own line post-expand
1820 !! wikitext
1821 a
1822 {{blank}}<!---->
1823 b
1824 !! html
1825 <p>a
1826 </p><p>b
1827 </p>
1828 !! end
1829
1830 !! test
1831 Comment on its own line post-expand with non-significant whitespace
1832 !! wikitext
1833 a
1834 {{blank}} <!---->
1835 b
1836 !! html
1837 <p>a
1838 </p><p>b
1839 </p>
1840 !! end
1841
1842 !! test
1843 post-expand include size being exceeded
1844 !! options
1845 maxincludesize=20
1846 !! wikitext
1847 {{echo3|1234567890}}
1848 !! html
1849 <p><a href="/wiki/Template:Echo3" title="Template:Echo3">Template:Echo3</a><!-- WARNING: template omitted, post-expand include size too large -->
1850 </p>
1851 !! end
1852
1853 !! test
1854 max template depth being reached
1855 !! options
1856 maxtemplatedepth=1
1857 !! wikitext
1858 {{echo with depth|too deep!}}
1859 !! html
1860 <p><span class="error">Template recursion depth limit exceeded (1)</span>
1861 </p>
1862 !! end
1863
1864 !! test
1865 Multiple comments should still parse as SOL-transparent
1866 !! options
1867 parsoid=wt2html,wt2wt
1868 !! wikitext
1869 <!--c1-->*a
1870 <!--c2--><!--c3--><!--c4-->*b
1871 !! html/php
1872 <ul><li>a</li>
1873 <li>b</li></ul>
1874
1875 !! html/parsoid
1876 <!--c1--><ul>
1877 <li>a
1878 </li>
1879 <!--c2--><!--c3--><!--c4-->
1880 <li>b
1881 </li>
1882 </ul>
1883 !! end
1884
1885 ## Make sure ">" gets escaped in comments to avoid XSS
1886 !! test
1887 IE conditional comments
1888 !! wikitext
1889 <!--[if lt IE 9]>
1890 <script>alert('hi');</script>
1891 <![endif]-->
1892 !! html/parsoid
1893 <!--[if lt IE 9]&#x3E;
1894 <script&#x3E;alert('hi');</script&#x3E;
1895 <![endif]-->
1896 !! end
1897
1898 ###
1899 ### paragraph wrapping tests
1900 ###
1901
1902 !! test
1903 No block tags
1904 !! wikitext
1905 a
1906
1907 b
1908 !! html
1909 <p>a
1910 </p><p>b
1911 </p>
1912 !! end
1913
1914 !! test
1915 Block tag on one line (<div>)
1916 !! wikitext
1917 a <div>foo</div>
1918
1919 b
1920 !! html
1921 a <div>foo</div>
1922 <p>b
1923 </p>
1924 !! html+tidy
1925 <p>a </p><div>foo</div>
1926 <p>b
1927 </p>
1928 !! end
1929
1930 # Remex wraps empty tag runs with p-tags.
1931 # Parsoid strips them out during p-wrapping.
1932 !! test
1933 No p-wrappable content
1934 !! wikitext
1935 <span><div>x</div></span>
1936 <span><s><div>x</div></s></span>
1937 <small><em></em></small><span><s><div>x</div></s></span>
1938 !! html/php+tidy
1939 <span><div>x</div></span>
1940 <span><s><div>x</div></s></span>
1941 <p><small><em></em></small></p><span><s><div>x</div></s></span>
1942 !! html/parsoid
1943 <span><div>x</div></span>
1944 <span><s><div>x</div></s></span>
1945 <small><em></em></small><span><s><div>x</div></s></span>
1946 !! end
1947
1948 # T177612: Parsoid-only test
1949 !! test
1950 Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
1951 !! wikitext
1952 {{echo|<span><div>x</div></span>}}
1953 x
1954 !! html/parsoid
1955 <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>
1956 <p>x</p>
1957 !! end
1958
1959 !! test
1960 Block tag on one line (<blockquote>)
1961 !! wikitext
1962 a <blockquote>foo</blockquote>
1963
1964 b
1965 !! html
1966 a <blockquote>foo</blockquote>
1967 <p>b
1968 </p>
1969 !! html+tidy
1970 <p>a </p><blockquote><p>foo</p></blockquote>
1971 <p>b
1972 </p>
1973 !! end
1974
1975 !! test
1976 Block tag on both lines (<div>)
1977 !! wikitext
1978 a <div>foo</div>
1979
1980 b <div>foo</div>
1981 !! html
1982 a <div>foo</div>
1983 b <div>foo</div>
1984
1985 !! html+tidy
1986 <p>a </p><div>foo</div><p>
1987 b </p><div>foo</div>
1988 !! end
1989
1990 !! test
1991 Block tag on both lines (<blockquote>)
1992 !! wikitext
1993 a <blockquote>foo</blockquote>
1994
1995 b <blockquote>foo</blockquote>
1996 !! html
1997 a <blockquote>foo</blockquote>
1998 b <blockquote>foo</blockquote>
1999
2000 !! html+tidy
2001 <p>a </p><blockquote><p>foo</p></blockquote><p>
2002 b </p><blockquote><p>foo</p></blockquote>
2003 !! end
2004
2005 !! test
2006 Multiple lines without block tags
2007 !! wikitext
2008 <div>foo</div> a
2009 b
2010 c
2011 d<!--foo--> e
2012 x <div>foo</div> z
2013 !! html
2014 <div>foo</div> a
2015 <p>b
2016 c
2017 d e
2018 </p>
2019 x <div>foo</div> z
2020
2021 !! html+tidy
2022 <div>foo</div><p> a
2023 </p><p>b
2024 c
2025 d e
2026 </p><p>
2027 x </p><div>foo</div><p> z
2028 </p>
2029 !! end
2030
2031 # The difference between Parsoid & Remex here
2032 # is because of Parsoid's Tidy-emulation code
2033 # for p-wrapping. We'll start work to remove this
2034 # emulation code in Parsoid sooner than later.
2035 # Remex wraps empty tag runs with p-tags.
2036 # Parsoid strips them out in a separate pass.
2037 !! test
2038 Empty lines between lines with block tags
2039 !! wikitext
2040 <div></div>
2041
2042
2043 <div></div>a
2044
2045 b
2046 <div>a</div>b
2047
2048 <div>b</div>d
2049
2050
2051 <div>e</div>
2052 !! html
2053 <div></div>
2054 <p><br />
2055 </p>
2056 <div></div>a
2057 <p>b
2058 </p>
2059 <div>a</div>b
2060 <div>b</div>d
2061 <p><br />
2062 </p>
2063 <div>e</div>
2064
2065 !! html+tidy
2066 <div></div>
2067 <p><br />
2068 </p>
2069 <div></div><p>a
2070 </p><p>b
2071 </p>
2072 <div>a</div><p>b
2073 </p><div>b</div><p>d
2074 </p><p><br />
2075 </p>
2076 <div>e</div>
2077 !! html/parsoid
2078 <div data-parsoid='{"stx":"html"}'></div>
2079
2080 <p><br /></p>
2081 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2082
2083 <p>b</p>
2084 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2085
2086 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2087
2088 <p><br /></p>
2089 <div data-parsoid='{"stx":"html"}'>e</div>
2090 !! end
2091
2092 !! test
2093 Unclosed HTML p-tags should be handled properly
2094 !! wikitext
2095 <div><p>foo</div>
2096 a
2097
2098 b
2099 !! html/php+tidy
2100 <div><p>foo</p></div>
2101 <p>a
2102 </p><p>b
2103 </p>
2104 !! html/parsoid
2105 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2106 <p>a</p>
2107 <p>b</p>
2108 !! end
2109
2110 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2111 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2112 ## them for now.
2113 !! test
2114 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2115 !! options
2116 parsoid=wt2html
2117 !! wikitext
2118 a [[Category:A1]] [[Category:A2]]
2119 [[Category:A3]]
2120 [[Category:A4]]
2121 !! html/parsoid
2122 <p>a</p>
2123 <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"/>
2124 !! end
2125
2126 !! test
2127 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2128 !! options
2129 parsoid=wt2html
2130 !! wikitext
2131 [[Category:A1]]a
2132 !! html/parsoid
2133 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2134 !! end
2135
2136 !! test
2137 No paragraph necessary for SOL transparent template
2138 !! wikitext
2139 <span><div>foo</div></span>
2140 [[Category:Foo]]
2141
2142 <span><div>foo</div></span>
2143 {{echo|[[Category:Foo]]}}
2144 !! html/php
2145 <span><div>foo</div></span>
2146 <span><div>foo</div></span>
2147
2148 !! html/parsoid
2149 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2150 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
2151
2152 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2153 <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}}]}'/>
2154 !! end
2155
2156 !! test
2157 Avoid expanding multiline sol transparent template ranges unnecessarily
2158 !! wikitext
2159 hi
2160
2161
2162 {{echo|<br/>
2163 }}
2164
2165 [[Category:Ho]]
2166 !! html/php
2167 <p>hi
2168 </p><p><br />
2169 <br />
2170 </p>
2171 !! html/parsoid
2172 <p>hi</p>
2173
2174 <p><br />
2175 <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">
2176 </span></p>
2177
2178 <link rel="mw:PageProp/Category" href="./Category:Ho" />
2179 !! end
2180
2181 ###
2182 ### Preformatted text
2183 ###
2184
2185 !! test
2186 Preformatted text
2187 !! wikitext
2188 This is some
2189 Preformatted text
2190 With ''italic''
2191 And '''bold'''
2192 And a [[Main Page|link]]
2193 !! html
2194 <pre>This is some
2195 Preformatted text
2196 With <i>italic</i>
2197 And <b>bold</b>
2198 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2199 </pre>
2200 !! end
2201
2202 !! test
2203 Tabs don't trigger preformatted text
2204 !! wikitext
2205 This is not
2206 preformatted text.
2207 This is preformatted text.
2208 So is this.
2209 !! html/php
2210 <p> This is not
2211 preformatted text.
2212 </p>
2213 <pre>This is preformatted text.
2214 So is this.
2215 </pre>
2216 !! html/parsoid
2217 <p> This is not
2218 preformatted text.</p>
2219 <pre>This is preformatted text.
2220 So is this.</pre>
2221 !! end
2222
2223 !! test
2224 Space before tab needs nowiki pre protection
2225 !! options
2226 parsoid=html2wt
2227 !! html/parsoid
2228 <p> a</p>
2229 !! wikitext
2230 <nowiki> </nowiki> a
2231 !! end
2232
2233 !! test
2234 Ident preformatting with inline content
2235 !! wikitext
2236 a
2237 ''b''
2238 !! html
2239 <pre>a
2240 <i>b</i>
2241 </pre>
2242 !! end
2243
2244 !! test
2245 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2246 !! wikitext
2247 <pre><nowiki>
2248 <b>
2249 <cite>
2250 <em>
2251 </nowiki></pre>
2252 !! html
2253 <pre>
2254 &lt;b&gt;
2255 &lt;cite&gt;
2256 &lt;em&gt;
2257 </pre>
2258
2259 !! end
2260
2261 !! test
2262 Regression with preformatted in <center>
2263 !! wikitext
2264 <center>
2265 Blah
2266 </center>
2267 !! html
2268 <center>
2269 <pre>Blah
2270 </pre>
2271 </center>
2272
2273 !! end
2274
2275 !! test
2276 T54763: Preformatted in <blockquote>
2277 !! wikitext
2278 <blockquote>
2279 Blah
2280 {|
2281 |
2282 indented cell (no pre-wrapping!)
2283 |}
2284 </blockquote>
2285 !! html
2286 <blockquote>
2287 <p> Blah
2288 </p>
2289 <table>
2290 <tr>
2291 <td>
2292 <p> indented cell (no pre-wrapping!)
2293 </p>
2294 </td></tr></table>
2295 </blockquote>
2296
2297 !! end
2298
2299 !! test
2300 T53086: Double newlines in blockquotes should be turned into paragraphs
2301 !! wikitext
2302 <blockquote>
2303 Foo
2304
2305 Bar
2306 </blockquote>
2307 !! html
2308 <blockquote>
2309 <p>Foo
2310 </p><p>Bar
2311 </p>
2312 </blockquote>
2313
2314 !! end
2315
2316 !! test
2317 T17491: <ins>/<del> in blockquote
2318 !! wikitext
2319 <blockquote>
2320 Foo <del>bar</del> <ins>baz</ins> quux
2321 </blockquote>
2322 !! html
2323 <blockquote>
2324 <p>Foo <del>bar</del> <ins>baz</ins> quux
2325 </p>
2326 </blockquote>
2327
2328 !! end
2329
2330 !! test
2331 T17491: <ins>/<del> in blockquote (2)
2332 !! wikitext
2333 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2334 </blockquote>
2335 !! html
2336 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2337 </blockquote>
2338
2339 !! html+tidy
2340 <blockquote><p>Foo </p><del>bar</del> <ins>baz</ins><p> quux
2341 </p></blockquote>
2342 !! end
2343
2344 !! test
2345 <pre> with attributes (T5202)
2346 !! wikitext
2347 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2348 !! html
2349 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2350
2351 !! end
2352
2353 !! test
2354 <pre> with width attribute (T5202)
2355 !! wikitext
2356 <pre width="8">Narrow screen goodies</pre>
2357 !! html
2358 <pre width="8">Narrow screen goodies</pre>
2359
2360 !! end
2361
2362 !! test
2363 <pre> with forbidden attribute (T5202)
2364 !! wikitext
2365 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2366 !! html
2367 <pre width="8">Narrow screen goodies</pre>
2368
2369 !! end
2370
2371 !! test
2372 Entities inside <pre>
2373 !! wikitext
2374 <pre>&lt;</pre>
2375 !! html
2376 <pre>&lt;</pre>
2377
2378 !! end
2379
2380 !! test
2381 <pre> with forbidden attribute values (T5202)
2382 !! wikitext
2383 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2384 !! html
2385 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2386
2387 !! end
2388
2389 !! test
2390 <nowiki> inside <pre> (T15238)
2391 !! wikitext
2392 <pre>
2393 <nowiki>
2394 </pre>
2395 <pre>
2396 <nowiki></nowiki>
2397 </pre>
2398 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2399 !! html
2400 <pre>
2401 &lt;nowiki&gt;
2402 </pre>
2403 <pre>
2404
2405 </pre>
2406 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2407
2408 !! end
2409
2410 !! test
2411 <nowiki> inside of #tag:pre
2412 !! wikitext
2413 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2414 !! html/php
2415 <pre>Foo &#8594;bar</pre>
2416
2417 !! html/parsoid
2418 <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>
2419 !! end
2420
2421 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2422 ## aren't enclosed in nowikis.
2423 !! test
2424 <nowiki> and <pre> preference (first one wins)
2425 !! options
2426 parsoid=wt2html
2427 !! wikitext
2428 <pre>
2429 <nowiki>
2430 </pre>
2431 </nowiki>
2432 </pre>
2433
2434 <nowiki>
2435 <pre>
2436 <nowiki>
2437 </pre>
2438 </nowiki>
2439 </pre>
2440
2441 !! html/php
2442 <pre>
2443 &lt;nowiki&gt;
2444 </pre>
2445 <p>&lt;/nowiki&gt;
2446 &lt;/pre&gt;
2447 </p><p>
2448 &lt;pre&gt;
2449 &lt;nowiki&gt;
2450 &lt;/pre&gt;
2451
2452 &lt;/pre&gt;
2453 </p>
2454 !! html/parsoid
2455 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2456 </pre>
2457 <p>&lt;/nowiki></p>
2458
2459
2460 <p><span typeof="mw:Nowiki">
2461 &lt;pre>
2462 &lt;nowiki>
2463 &lt;/pre>
2464 </span></p>
2465 !! end
2466
2467 !! test
2468 </pre> inside nowiki
2469 !! wikitext
2470 <nowiki></pre></nowiki>
2471 !! html
2472 <p>&lt;/pre&gt;
2473 </p>
2474 !! end
2475
2476 !! test
2477 Empty pre; pre inside other HTML tags (T56946)
2478 !! wikitext
2479 a
2480
2481 <div><pre>
2482 foo
2483 </pre></div>
2484 <pre></pre>
2485 !! html/php+tidy
2486 <p>a
2487 </p>
2488 <div><pre>foo
2489 </pre></div>
2490 <pre></pre>
2491 !! html/parsoid
2492 <p>a</p>
2493
2494 <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
2495 </pre></div>
2496 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2497 !! end
2498
2499 !! test
2500 HTML pre followed by indent-pre
2501 !! wikitext
2502 <pre>foo</pre>
2503 bar
2504 !! html
2505 <pre>foo</pre>
2506 <pre>bar
2507 </pre>
2508 !! end
2509
2510 !! test
2511 Block tag pre
2512 !! wikitext
2513 <p><pre>foo</pre></p>
2514 !! html/php+tidy
2515 <p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p>
2516 !! html/parsoid
2517 <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>
2518 !! end
2519
2520 !!test
2521 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2522 !! wikitext
2523 {{echo|}}
2524 !! html
2525
2526 !!end
2527
2528 !!test
2529 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2530 !! wikitext
2531 {{echo|
2532 foo}}
2533 !! html
2534 <p>foo
2535 </p>
2536 !!end
2537
2538 !! test
2539 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2540 !! wikitext
2541 {{echo|a
2542 b}}
2543 !! html
2544 <pre>a
2545 </pre>
2546 <p>b
2547 </p>
2548 !!end
2549
2550 !! test
2551 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2552 !! wikitext
2553 {{echo|a
2554 b
2555 c
2556 d
2557 e
2558 }}
2559 !! html
2560 <pre>a
2561 </pre>
2562 <p>b
2563 c
2564 </p>
2565 <pre>d
2566 </pre>
2567 <p>e
2568 </p>
2569 !!end
2570
2571 !!test
2572 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2573 !! wikitext
2574 {{echo| foo}}
2575
2576 {{echo| foo}}{{echo| bar}}
2577
2578 {{echo| foo}}
2579 {{echo| bar}}
2580
2581 {{echo|<!--cmt--> foo}}
2582
2583 <!--cmt-->{{echo| foo}}
2584
2585 {{echo|{{echo| }}bar}}
2586 !! html
2587 <pre>foo
2588 </pre>
2589 <pre>foo bar
2590 </pre>
2591 <pre>foo
2592 bar
2593 </pre>
2594 <pre>foo
2595 </pre>
2596 <pre>foo
2597 </pre>
2598 <pre>bar
2599 </pre>
2600 !!end
2601
2602 !! test
2603 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2604 !! wikitext
2605 {{echo| }}a
2606
2607 {{echo|
2608 }}a
2609
2610 {{echo|
2611 b}}
2612
2613 {{echo|a
2614 }}b
2615
2616 {{echo|a
2617 }} b
2618 !! html
2619 <pre>a
2620 </pre>
2621 <p><br />
2622 </p>
2623 <pre>a
2624 </pre>
2625 <p><br />
2626 </p>
2627 <pre>b
2628 </pre>
2629 <p>a
2630 </p>
2631 <pre>b
2632 </pre>
2633 <p>a
2634 </p>
2635 <pre>b
2636 </pre>
2637 !!end
2638
2639 ## Hmm, should Parsoid rt this?
2640 !! test
2641 Pres with newline attributes
2642 !! options
2643 parsoid=wt2html,html2html
2644 !! wikitext
2645 <pre class="one
2646 two">hi</pre>
2647 !! html/php
2648 <pre class="one two">hi</pre>
2649
2650 !! html/parsoid
2651 <pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2652 !! end
2653
2654 !! test
2655 Things that look like <pre> tags aren't treated as such
2656 !! wikitext
2657 Barack Obama <President> of the United States
2658 <President></President>
2659 !! html
2660 <p>Barack Obama &lt;President&gt; of the United States
2661 &lt;President&gt;&lt;/President&gt;
2662 </p>
2663 !! end
2664
2665 !! test
2666 Handle broken pre-like tags (T66025)
2667 !! options
2668 parsoid=wt2html
2669 !! wikitext
2670 {{echo|<pre <pre>x</pre>}}
2671
2672 <table><pre </table>
2673 !! html/php
2674 <pre>x</pre>
2675 <table>&lt;pre </table>
2676
2677 !! html/php+tidy
2678 <pre>x</pre>
2679 &lt;pre <table></table>
2680 !! html/parsoid
2681 <pre about="#mwt1" typeof="mw:Transclusion mw:Extension/pre" data-parsoid='{"a":{"&lt;pre":null},"sa":{"&lt;pre":""},"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre &lt;pre>x&lt;/pre>"}},"i":0}}]}'>x</pre>
2682
2683
2684 <p>&lt;pre </p>
2685
2686 <table></table>
2687 !! end
2688
2689 !! test
2690 Parsoid: handle pre with space after attribute
2691 !! options
2692 parsoid=wt2html
2693 !! wikitext
2694 <pre style="width:50%;" >{{echo|foo}}</pre>
2695 !! html/php
2696 <pre style="width:50%;">{{echo|foo}}</pre>
2697
2698 !! html/parsoid
2699 <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>
2700 !! end
2701
2702 # TODO / maybe: fix wt2wt for this
2703 !! test
2704 Parsoid: Don't paragraph-wrap fosterable content
2705 !! options
2706 parsoid=wt2html
2707 !! wikitext
2708 {|
2709 <td></td>
2710 <td></td>
2711
2712
2713
2714 |}
2715 !! html
2716 <table>
2717
2718 <tbody>
2719 <tr>
2720 <td></td>
2721
2722 <td></td></tr>
2723
2724
2725
2726 </tbody></table>
2727 !! end
2728
2729 !! test
2730 Self-closed pre
2731 !! wikitext
2732 <pre />
2733 !! html/php
2734 <pre></pre>
2735
2736 !! html/parsoid
2737 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":null}'></pre>
2738 !! end
2739
2740 !! test
2741 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2742 !! options
2743 parsoid=wt2html
2744 !! wikitext
2745 {|
2746 <td>
2747 <td>
2748 </td>
2749
2750
2751
2752 |}
2753 !! html
2754 <table>
2755
2756 <tbody>
2757 <tr>
2758 <td></td>
2759
2760 <td>
2761 </td></tr>
2762
2763
2764
2765 </tbody></table>
2766 !! end
2767
2768
2769 #--------------------------------------------------------------------
2770 # Transclusion parameter whitespace stripping tests
2771 # Behavior is different for positional and named parameters
2772 #--------------------------------------------------------------------
2773 !! test
2774 Templates: Strip leading and trailing whitespace from named-param values
2775 !! wikitext
2776 {{echo|1= a }}
2777
2778 {{echo|1= {{echo|b}} }}
2779
2780 {{echo| 1 =
2781 c }}
2782
2783 {{echo| 1 =
2784 * d
2785 }}
2786 !! html
2787 <p>a
2788 </p><p>b
2789 </p><p>c
2790 </p>
2791 <ul><li>d</li></ul>
2792
2793 !! end
2794
2795 !! test
2796 Templates: Don't strip whitespace from positional-param values
2797 !! wikitext
2798 {{echo|a }}
2799
2800 {{echo|{{echo|b}} }}
2801
2802 {{echo| c
2803 }}
2804
2805 {{echo| {{echo|d}}
2806 }}
2807
2808 {{echo|
2809 e}}
2810
2811 {{echo|
2812 *f}}
2813
2814 {{echo|
2815 }}g
2816 !! html
2817 <p>a
2818 </p><p>b
2819 </p>
2820 <pre>c
2821 </pre>
2822 <p><br />
2823 </p>
2824 <pre>d
2825 </pre>
2826 <p><br />
2827 </p>
2828 <pre>e
2829 </pre>
2830 <p><br />
2831 </p>
2832 <ul><li>f</li></ul>
2833 <p><br />
2834 </p>
2835 <pre>g
2836 </pre>
2837 !! end
2838
2839 !! test
2840 Templates: Don't recognize targets split by newlines
2841 !! options
2842 parsoid=wt2html
2843 !! wikitext
2844 {{ech
2845 o|foo}}
2846 !! html/php
2847 <p>{{ech
2848 o|foo}}
2849 </p>
2850 !! html/parsoid
2851 <p>{{ech
2852 o|foo}}</p>
2853 !! end
2854
2855 !! test
2856 Templates: Recognize targets when newlines and comments don't split the target
2857 !! options
2858 parsoid=wt2html
2859 !! wikitext
2860 {{
2861 <!--X--> ech<!--X-->o<!--X-->
2862 <!--X--> <!--X-->
2863
2864 |foo}}
2865 !! html/php
2866 <p>foo
2867 </p>
2868 !! html/parsoid
2869 <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>
2870 !! end
2871
2872 !! test
2873 Templates: Handle empty comment-and-ws-only lines correctly
2874 !! wikitext
2875 {{echo|foo
2876 <!--should be ignored-->
2877 <!--should be ignored as well-->
2878 bar}}
2879 !! html/php
2880 <p>foo
2881 bar
2882 </p>
2883 !! html/parsoid
2884 <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>
2885 !! end
2886
2887 !! test
2888 Templates: Handle comments in the target
2889 !! wikitext
2890 {{echo
2891 <!-- should be ignored -->
2892 |foo}}
2893
2894 {{echo
2895 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
2896 |foo}}
2897
2898 {{echo<!-- should be ignored -->
2899 |foo}}
2900
2901 {{echo<!-- should be ignored -->|foo}}
2902
2903 {{<!-- should be ignored -->echo|foo}}
2904 !! html/php
2905 <p>foo
2906 </p><p>foo
2907 </p><p>foo
2908 </p><p>foo
2909 </p><p>foo
2910 </p>
2911 !! html/parsoid
2912 <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>
2913
2914 <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>
2915
2916 <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>
2917
2918 <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>
2919
2920 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
2921 !! end
2922
2923 !! test
2924 Templates: Handle comments in parameter names (T69657)
2925 !! wikitext
2926 {{echo|1
2927 <!-- should be ignored -->
2928 =foo}}
2929
2930 {{echo|
2931 <!-- should be ignored -->
2932 1 = foo}}
2933
2934 {{echo|1<!-- should be ignored -->=foo}}
2935
2936 {{echo|<!-- should be ignored -->1=foo}}
2937 !! html/php
2938 <p>foo
2939 </p><p>foo
2940 </p><p>foo
2941 </p><p>foo
2942 </p>
2943 !! html/parsoid
2944 <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>
2945
2946 <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>
2947
2948 <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>
2949
2950 <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>
2951 !! end
2952
2953 !! test
2954 Templates: Other wikitext in parameter names (T69657)
2955 !! wikitext
2956 {{echo|''1''=foo}}
2957 !! html/php
2958 <p>{{{1}}}
2959 </p>
2960 !! html/parsoid
2961 <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>
2962 !! end
2963
2964 !! test
2965 Templates: With colons
2966 !! wikitext
2967 {{With: Colon}}
2968 !! html/php
2969 <p>Template with colon
2970 </p>
2971 !! html/parsoid
2972 <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>
2973 !! end
2974
2975 #--------------------------------------------------------------------
2976 # Transclusion parameter escaping tests
2977 #--------------------------------------------------------------------
2978
2979 !! test
2980 Templates: Parsoid parameter escaping test 1
2981 !! wikitext
2982 {{echo|[foo]|{{echo|[bar]}}}}
2983 !! html/php+tidy
2984 <p>[foo]
2985 </p>
2986 !! html/parsoid
2987 <p about="#mwt1" typeof="mw:Transclusion"
2988 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
2989 !! end
2990
2991 !! test
2992 Parsoid: Pipes in external links in template parameter
2993 !! wikitext
2994 {{echo|[{{echo|http://example.com}} link]}}
2995 !! html/php+tidy
2996 <p><a rel="nofollow" class="external text" href="http://example.com">link</a>
2997 </p>
2998 !! html/parsoid
2999 <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>
3000 !! end
3001
3002 !! test
3003 Parsoid: pipe in transclusion parameter
3004 !! wikitext
3005 {{echo|http://foo.com/a&#124;b}}
3006 !! html/php+tidy
3007 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a>
3008 </p>
3009 !! html/parsoid
3010 <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>
3011 !! end
3012
3013 !! test
3014 Parsoid: Pipe in external link target and content in template parameter
3015 !! options
3016 parsoid=html2wt,wt2wt
3017 !! wikitext
3018 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
3019 !! html/php+tidy
3020 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a&#124;b</a>
3021 </p>
3022 !! html/parsoid
3023 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
3024 typeof="mw:Transclusion"
3025 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
3026 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
3027 !! end
3028
3029 !! test
3030 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
3031 !! options
3032 parsoid
3033 !! wikitext
3034 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
3035 !! html
3036 <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>
3037 !! end
3038
3039 !! test
3040 Templates: Don't escape already nowiki-escaped text in template parameters
3041 !! options
3042 parsoid=html2wt,wt2wt
3043 !! wikitext
3044 {{echo|foo<nowiki>|</nowiki>bar}}
3045 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
3046 {{echo|<nowiki></nowiki>}}
3047 !! html/php+tidy
3048 <p>foo|bar
3049 &lt;div&gt;
3050
3051 </p>
3052 !! html/parsoid
3053 <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>
3054 <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>
3055 <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>
3056 </p>
3057 !! end
3058
3059 ## T54824
3060 !! test
3061 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
3062 !! options
3063 parsoid=html2wt,wt2wt
3064 !! wikitext
3065 {{echo|{{echo|1=bar}}}}
3066 !! html/php+tidy
3067 <p>bar
3068 </p>
3069 !! html/parsoid
3070 <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>
3071 !! end
3072
3073 ## T58733
3074 !! test
3075 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
3076 !! wikitext
3077 {{echo|a : b}}
3078 !! html/php+tidy
3079 <p>a&#160;: b
3080 </p>
3081 !! html/parsoid
3082 <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>
3083 !! end
3084
3085 ## T73412
3086 !! test
3087 Templates: Preserve blank parameter names
3088 !! wikitext
3089 {{echo|=foo}}
3090 !! html/php+tidy
3091 <p>{{{1}}}
3092 </p>
3093 !! html/parsoid
3094 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3095 !! end
3096
3097 !! test
3098 Templates: Preserve blank parameter names in other positions
3099 !! wikitext
3100 {{blank_param|bar|=foo}}
3101 !! html/php+tidy
3102 <p>bar
3103 foo
3104 </p>
3105 !! html/parsoid
3106 <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
3107 foo</p>
3108 !! end
3109
3110 ###
3111 ### Parsoid-centric tests for testing RT edge cases for pre
3112 ###
3113
3114 !!test
3115 1a. Indent-Pre and Comments
3116 !! wikitext
3117 a
3118 <!--a-->
3119 c
3120 !! html
3121 <pre>a
3122 </pre>
3123 <p>c
3124 </p>
3125 !!end
3126
3127 !!test
3128 1b. Indent-Pre and Comments
3129 !! wikitext
3130 a
3131 <!--a-->
3132 c
3133 !! html
3134 <pre>a
3135 </pre>
3136 <p>c
3137 </p>
3138 !!end
3139
3140 !!test
3141 1c. Indent-Pre and Comments
3142 !! wikitext
3143 <!--a--> a
3144
3145 <!--a--> a
3146 !! html
3147 <pre> a
3148 </pre>
3149 <pre> a
3150 </pre>
3151 !!end
3152
3153 !!test
3154 1d. Indent-Pre and Comments
3155 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3156 !! wikitext
3157 <!--a--> a
3158
3159 <!--b-->b
3160 !! html
3161 <pre>a
3162 </pre>
3163 <pre>b
3164 </pre>
3165 !!end
3166
3167 !!test
3168 2a. Indent-Pre and tables
3169 !! wikitext
3170 {|
3171 |-
3172 !h1!!h2
3173 |foo||bar
3174 |}
3175 !! html
3176 <table>
3177
3178 <tr>
3179 <th>h1</th>
3180 <th>h2
3181 </th>
3182 <td>foo</td>
3183 <td>bar
3184 </td></tr></table>
3185
3186 !!end
3187
3188 !!test
3189 2b. Indent-Pre and tables
3190 !! wikitext
3191 {|
3192 |-
3193 |foo
3194 |}
3195 !! html
3196 <table>
3197
3198 <tr>
3199 <td>foo
3200 </td></tr></table>
3201
3202 !!end
3203
3204 !!test
3205 2c. Indent-Pre and tables (T44252)
3206 !! wikitext
3207 {|
3208 |+foo
3209 ! |bar
3210 |}
3211 !! html
3212 <table>
3213 <caption>foo
3214 </caption>
3215 <tr>
3216 <th>bar
3217 </th></tr></table>
3218
3219 !!end
3220
3221 !!test
3222 2d. Indent-Pre and tables
3223 !! wikitext
3224 a
3225 {|
3226 |b
3227 |}
3228 !! html/php
3229 <pre>a
3230 </pre>
3231 <table>
3232 <tr>
3233 <td>b
3234 </td></tr></table>
3235
3236 !! html/parsoid
3237 <pre>a</pre>
3238 <table>
3239 <tbody><tr><td> b</td></tr>
3240 </tbody></table>
3241 !!end
3242
3243 !!test
3244 2e. Indent-Pre and table-line syntax
3245 !! wikitext
3246 a
3247 | b
3248 | c
3249 !! html/php
3250 <pre>a
3251 | b
3252 | c
3253 </pre>
3254 !!end
3255
3256 !!test
3257 2f. Indent-pre started by table-line syntax
3258 !! wikitext
3259 a
3260 | b
3261 | c
3262 !! html/php
3263 <p>a
3264 </p>
3265 <pre>| b
3266 | c
3267 </pre>
3268 !! html/parsoid
3269 <p>a</p>
3270 <pre>
3271 | b
3272 | c</pre>
3273 !!end
3274
3275 !! test
3276 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3277 !! wikitext
3278 <table>
3279 <tr>
3280 <td>
3281 Text that should be rendered preformatted
3282 </td>
3283 </tr>
3284 </table>
3285 !! html
3286 <table>
3287 <tr>
3288 <td>
3289 <pre>Text that should be rendered preformatted
3290 </pre>
3291 </td>
3292 </tr>
3293 </table>
3294
3295 !! end
3296
3297 !!test
3298 3a. Indent-Pre and block tags (single-line html)
3299 !! wikitext
3300 a <p> foo </p>
3301 b <div> foo </div>
3302 c <blockquote> foo </blockquote>
3303 <span> foo </span>
3304 !! html
3305 a <p> foo </p>
3306 b <div> foo </div>
3307 c <blockquote> foo </blockquote>
3308 <pre><span> foo </span>
3309 </pre>
3310 !! html/parsoid
3311 <p>a </p><p data-parsoid='{"stx":"html"}'> foo </p>
3312 <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3313 <p>c </p><blockquote data-parsoid='{"stx":"html"}'> foo </blockquote>
3314 <pre><span> foo </span>
3315 </pre>
3316 !! html/php+tidy
3317 <p> a </p><p> foo </p><p>
3318 b </p><div> foo </div><p>
3319 c </p><blockquote><p> foo </p></blockquote>
3320 <pre><span> foo </span>
3321 </pre>
3322 !! end
3323
3324 !!test
3325 3b. Indent-Pre and block tags (multi-line html)
3326 !! wikitext
3327 a <span>foo</span>
3328 b <div> foo </div>
3329 !! html
3330 <pre>a <span>foo</span>
3331 </pre>
3332 b <div> foo </div>
3333
3334 !! html/parsoid
3335 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3336 b <div data-parsoid='{"stx":"html"}'> foo </div>
3337 !! html/php+tidy
3338 <pre>a <span>foo</span>
3339 </pre><p>
3340 b </p><div> foo </div>
3341 !!end
3342
3343 !!test
3344 3c. Indent-Pre and block tags (pre-content on separate line)
3345 !! wikitext
3346 <p>
3347 foo
3348 </p>
3349
3350 <div>
3351 foo
3352 </div>
3353
3354 <center>
3355 foo
3356 </center>
3357
3358 <blockquote>
3359 foo
3360 </blockquote>
3361
3362 <blockquote>
3363 <pre>
3364 foo
3365 </pre>
3366 </blockquote>
3367
3368 <table><tr><td>
3369 foo
3370 </td></tr></table>
3371
3372 <ul><li>
3373 foo
3374 </li></ul>
3375
3376 !! html
3377 <p>
3378 foo
3379 </p>
3380 <div>
3381 <pre>foo
3382 </pre>
3383 </div>
3384 <center>
3385 <pre>foo
3386 </pre>
3387 </center>
3388 <blockquote>
3389 <p> foo
3390 </p>
3391 </blockquote>
3392 <blockquote>
3393 <pre>
3394 foo
3395 </pre>
3396 </blockquote>
3397 <table><tr><td>
3398 <pre>foo
3399 </pre>
3400 </td></tr></table>
3401 <ul><li>
3402 foo
3403 </li></ul>
3404
3405 !!end
3406
3407 !! test
3408 4. Indent-Pre and extension tags
3409 !! wikitext
3410 a <tag />
3411 !! html/php
3412 a <pre>
3413 NULL
3414 array (
3415 )
3416 </pre>
3417
3418 !! html/parsoid
3419 a <pre typeof="mw:Extension/tag" about="#mwt2" data-parsoid='{}' data-mw='{"name":"tag","attrs":{},"body":null}'></pre>
3420 !! end
3421
3422 !! test
3423 5. Indent-Pre and html pre
3424 !! wikitext
3425 <pre class="123">hi</pre>
3426 !! html/php
3427 <pre class="123">hi</pre>
3428
3429 !! html/parsoid
3430 <pre typeof="mw:Extension/pre" about="#mwt2" class="123" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3431 !! end
3432
3433 !!test
3434 Render paragraphs when indent-pre is suppressed in blocklevels
3435 !! wikitext
3436 <blockquote>
3437 foo
3438
3439 bar
3440 </blockquote>
3441 !! html
3442 <blockquote>
3443 <p> foo
3444 </p><p> bar
3445 </p>
3446 </blockquote>
3447
3448 !!end
3449
3450 !!test
3451 4. Multiple spaces at start-of-line
3452 !! wikitext
3453 <p> foo </p>
3454 foo
3455 {|
3456 |foo
3457 |}
3458 !! html
3459 <p> foo </p>
3460 <pre> foo
3461 </pre>
3462 <table>
3463 <tr>
3464 <td>foo
3465 </td></tr></table>
3466
3467 !!end
3468
3469 ## NOTE: the leading white-space chars on empty line are significant
3470 !! test
3471 5a. White-space in indent-pre
3472 !! wikitext
3473 a<br />
3474
3475 b
3476 !! html
3477 <pre>a<br />
3478
3479 b
3480 </pre>
3481 !! end
3482
3483 ## NOTE: the leading white-space chars on empty line are significant
3484 !! test
3485 5b. White-space in indent-pre
3486 !! wikitext
3487 a
3488
3489 b
3490
3491
3492 c
3493 !! html
3494 <pre>a
3495
3496 b
3497
3498
3499 c
3500 </pre>
3501 !! end
3502
3503 !! test
3504 5c. White-space in indent-pre
3505 !! wikitext
3506 ''a''
3507 ''b''
3508 ''c''
3509 !! html
3510 <pre><i>a</i>
3511 <i>b</i>
3512 <i>c</i>
3513 </pre>
3514 !! end
3515
3516 !! test
3517 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3518 !! wikitext
3519 a
3520
3521 <!-- continue -->
3522 b
3523
3524 c
3525
3526 d
3527 !! html
3528 <pre>a
3529
3530 b
3531 </pre>
3532 <pre>c
3533
3534 </pre>
3535 <p>d
3536 </p>
3537 !! end
3538
3539 !! test
3540 7a. Indent-pre and category links
3541 !! options
3542 parsoid=wt2html,wt2wt
3543 !! wikitext
3544 [[Category:foo]] <!-- No pre-wrapping -->
3545 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3546 !! html/php+tidy
3547 !! html/parsoid
3548 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3549 <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 -->
3550 !! end
3551
3552 ## We used to, but no longer wt2wt this test since the default serializer
3553 ## will normalize all categories to serialize on their own line.
3554 ## This wikitext usage is going to be fairly uncommon in production and
3555 ## selser will take care of preserving formatting in those scenarios.
3556 !! test
3557 7b. Indent-pre and category links
3558 !! options
3559 parsoid=wt2html
3560 !! wikitext
3561 [[Category:foo]] a
3562 [[Category:foo]] {{echo|b}}
3563 !! html/parsoid
3564 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3565 <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>
3566 !! end
3567
3568 !! test
3569 Indent-Pre: Newlines in comments shouldn't affect sol state
3570 !! wikitext
3571 a <!--
3572 foo
3573 --> b
3574 !! html/php+tidy
3575 <p>a b
3576 </p>
3577 !! html/parsoid
3578 <p>a <!--
3579 foo
3580 --> b</p>
3581 !! end
3582
3583 ###
3584 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3585 ###
3586
3587 !!test
3588 HTML-pre: 1. embedded newlines
3589 !! wikitext
3590 <pre>foo</pre>
3591
3592 <pre>
3593 foo
3594 </pre>
3595
3596 <pre>
3597
3598 foo
3599 </pre>
3600
3601 <pre>
3602
3603
3604 foo
3605 </pre>
3606 !! html/php+tidy
3607 <pre>foo</pre>
3608 <pre>foo
3609 </pre>
3610 <pre>
3611
3612 foo
3613 </pre>
3614 <pre>
3615
3616
3617 foo
3618 </pre>
3619 !! html/parsoid
3620 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3621
3622 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3623 </pre>
3624
3625 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3626
3627 foo
3628 </pre>
3629
3630 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3631
3632
3633 foo
3634 </pre>
3635 !!end
3636
3637 !! test
3638 HTML-pre: big spaces
3639 !! wikitext
3640 <pre>
3641
3642
3643
3644
3645 haha
3646
3647
3648
3649
3650 haha
3651
3652
3653
3654
3655 </pre>
3656 !! html/php+tidy
3657 <pre>
3658
3659
3660
3661
3662 haha
3663
3664
3665
3666
3667 haha
3668
3669
3670
3671
3672 </pre>
3673 !! html/parsoid
3674 <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"}}'>
3675
3676
3677
3678
3679 haha
3680
3681
3682
3683
3684 haha
3685
3686
3687
3688
3689 </pre>
3690 !! end
3691
3692 !!test
3693 HTML-pre: 2: indented text
3694 !! wikitext
3695 <pre>
3696 foo
3697 </pre>
3698 !! html
3699 <pre>
3700 foo
3701 </pre>
3702
3703 !!end
3704
3705 !!test
3706 HTML-pre: 3: other wikitext
3707 !! wikitext
3708 <pre>
3709 * foo
3710 # bar
3711 = no-h =
3712 '' no-italic ''
3713 [[ NoLink ]]
3714 </pre>
3715 !! html/php
3716 <pre>
3717 * foo
3718 # bar
3719 = no-h =
3720 '' no-italic ''
3721 [[ NoLink ]]
3722 </pre>
3723
3724 !! html/parsoid
3725 <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
3726 # bar
3727 = no-h =
3728 '' no-italic ''
3729 [[ NoLink ]]
3730 </pre>
3731 !!end
3732
3733 ###
3734 ### Definition lists
3735 ###
3736 !! test
3737 Simple definition
3738 !! wikitext
3739 ;name :Definition
3740 !! html
3741 <dl><dt>name&#160;</dt>
3742 <dd>Definition</dd></dl>
3743
3744 !! end
3745
3746 !! test
3747 Definition list for indentation only
3748 !! wikitext
3749 :Indented text
3750 !! html
3751 <dl><dd>Indented text</dd></dl>
3752
3753 !! end
3754
3755 !! test
3756 Definition list with no space
3757 !! wikitext
3758 ;name:Definition
3759 !! html
3760 <dl><dt>name</dt>
3761 <dd>Definition</dd></dl>
3762
3763 !!end
3764
3765 !! test
3766 Definition list with URL link
3767 !! wikitext
3768 ;http://example.com/ :definition
3769 !! html
3770 <dl><dt><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&#160;</dt>
3771 <dd>definition</dd></dl>
3772
3773 !! end
3774
3775 !! test
3776 Definition list with bracketed URL link
3777 !! wikitext
3778 ;[http://www.example.com/ Example]:Something about it
3779 !! html
3780 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
3781 <dd>Something about it</dd></dl>
3782
3783 !! end
3784
3785 !! test
3786 Definition list with wikilink containing colon
3787 !! wikitext
3788 ; [[Help:FAQ]]:The least-read page on Wikipedia
3789 !! html
3790 <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>
3791 <dd>The least-read page on Wikipedia</dd></dl>
3792
3793 !! end
3794
3795 # At Brion's and JeLuF's insistence... :)
3796 !! test
3797 Definition list with news link containing colon
3798 !! wikitext
3799 ;news:alt.wikipedia.rox: This isn't even a real newsgroup!
3800 !! html/php
3801 <dl><dt><a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
3802 <dd>This isn't even a real newsgroup!</dd></dl>
3803
3804 !! html/parsoid
3805 <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>
3806 !! end
3807
3808 !! test
3809 Malformed definition list with colon
3810 !! wikitext
3811 ; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
3812 !! html
3813 <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>
3814
3815 !! end
3816
3817 !! test
3818 Definition lists: colon in external link text
3819 !! wikitext
3820 ;[http://www.wikipedia2.org/ Wikipedia :The Next Generation] :OK, I made that up
3821 !! html
3822 <dl><dt><a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia&#160;:The Next Generation</a>&#160;</dt>
3823 <dd>OK, I made that up</dd></dl>
3824
3825 !! end
3826
3827 !! test
3828 Definition lists: colon in HTML attribute
3829 !! wikitext
3830 ;<b style="display: inline">bold</b>
3831 !! html
3832 <dl><dt><b style="display: inline">bold</b></dt></dl>
3833
3834 !! end
3835
3836 !! test
3837 Definition lists: self-closed tag
3838 !! wikitext
3839 ;one<br/>two :two-line fun
3840 !! html
3841 <dl><dt>one<br />two&#160;</dt>
3842 <dd>two-line fun</dd></dl>
3843
3844 !! end
3845
3846 !! test
3847 Definition lists: ignore colons inside tags
3848 !! wikitext
3849 ;one <b>two : tag <i>fun:</i>:</b>:def
3850 !! html
3851 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
3852 <dd>def</dd></dl>
3853
3854 !! end
3855
3856 !! test
3857 Definition lists: excess closed tags
3858 !! wikitext
3859 ;one</b>two :bad tag fun
3860 !! html/php+tidy
3861 <dl><dt>onetwo&#160;</dt>
3862 <dd>bad tag fun</dd></dl>
3863 !! html/parsoid
3864 <dl>
3865 <dt>onetwo</dt>
3866 <dd>bad tag fun</dd>
3867 </dl>
3868 !! end
3869
3870 !! test
3871 T13748: Literal closing tags
3872 !! wikitext
3873 <dl>
3874 <dt>test 1</dt>
3875 <dd>test test test test test</dd>
3876 <dt>test 2</dt>
3877 <dd>test test test test test</dd>
3878 </dl>
3879 !! html
3880 <dl>
3881 <dt>test 1</dt>
3882 <dd>test test test test test</dd>
3883 <dt>test 2</dt>
3884 <dd>test test test test test</dd>
3885 </dl>
3886
3887 !! end
3888
3889 !! test
3890 Definition and unordered list using wiki syntax nested in unordered list using html tags.
3891 !! wikitext
3892 <ul><li>
3893 ;term :description
3894 *unordered
3895 </li></ul>
3896 !! html
3897 <ul><li>
3898 <dl><dt>term&#160;</dt>
3899 <dd>description</dd></dl>
3900 <ul><li>unordered</li></ul>
3901 </li></ul>
3902
3903 !! end
3904
3905 !! test
3906 Definition list with empty definition and following paragraph
3907 !! wikitext
3908 ;term:
3909
3910 Paragraph text
3911 !! html
3912 <dl><dt>term</dt>
3913 <dd></dd></dl>
3914 <p>Paragraph text
3915 </p>
3916 !! end
3917
3918 !! test
3919 Nested definition lists using html syntax
3920 !! wikitext
3921 <dl><dt>x</dt>
3922 <dd>a</dd>
3923 <dd>b</dd></dl>
3924 !! html
3925 <dl><dt>x</dt>
3926 <dd>a</dd>
3927 <dd>b</dd></dl>
3928
3929 !! end
3930
3931 !! test
3932 Definition Lists: No nesting: Multiple dd's
3933 !! wikitext
3934 ;x
3935 :a
3936 :b
3937 !! html
3938 <dl><dt>x</dt>
3939 <dd>a</dd>
3940 <dd>b</dd></dl>
3941
3942 !! end
3943
3944 !! test
3945 Definition Lists: Indentation: Regular
3946 !! wikitext
3947 :i1
3948 ::i2
3949 :::i3
3950 !! html
3951 <dl><dd>i1
3952 <dl><dd>i2
3953 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3954
3955 !! end
3956
3957 !! test
3958 Definition Lists: Indentation: Missing 1st level
3959 !! wikitext
3960 ::i2
3961 :::i3
3962 !! html
3963 <dl><dd><dl><dd>i2
3964 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3965
3966 !! end
3967
3968 !! test
3969 Definition Lists: Indentation: Multi-level indent
3970 !! wikitext
3971 :::i3
3972 !! html
3973 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
3974
3975 !! end
3976
3977 !! test
3978 Definition Lists: Hacky use to indent tables
3979 !! wikitext
3980 ::{|
3981 |foo
3982 |bar
3983 |}
3984 this text
3985 should be left alone
3986 !! html
3987 <dl><dd><dl><dd><table>
3988 <tr>
3989 <td>foo
3990 </td>
3991 <td>bar
3992 </td></tr></table></dd></dl></dd></dl>
3993 <p>this text
3994 should be left alone
3995 </p>
3996 !! end
3997
3998 !! test
3999 Definition Lists: Hacky use to indent tables (with content following table)
4000 !! wikitext
4001 :{|
4002 |foo
4003 |bar
4004 |} <!--c1--> this text should be part of the dl
4005 !! html/php+tidy
4006 <dl><dd><table>
4007 <tbody><tr>
4008 <td>foo
4009 </td>
4010 <td>bar
4011 </td></tr></tbody></table> this text should be part of the dl</dd></dl>
4012 !! html/parsoid
4013 <dl><dd><table>
4014 <tbody><tr>
4015 <td>foo
4016 </td>
4017 <td>bar
4018 </td></tr></tbody></table> <!--c1--> this text should be part of the dl</dd></dl>
4019 !! end
4020
4021 !! test
4022 Definition Lists: Hacky use to indent tables, with comments (T65979)
4023 !! wikitext
4024 <!-- foo -->
4025 ::{|
4026 |foo
4027 |bar
4028 |}<!-- bar -->
4029 this text
4030 should be left alone
4031 !! html/parsoid
4032 <!-- foo -->
4033 <dl><dd><dl><dd><table><tr>
4034 <td>foo</td>
4035 <td>bar</td>
4036 </tr></table><!-- bar --></dd></dl></dd></dl>
4037 <p>this text
4038 should be left alone</p>
4039 !! end
4040
4041 !! test
4042 Definition Lists: Hacky use to indent tables, with comment before table
4043 !! wikitext
4044 ::<!-- foo -->{|
4045 |foo
4046 |}
4047 !! html/parsoid
4048 <dl><dd><dl><dd><!-- foo --><table><tr>
4049 <td>foo</td>
4050 </tr></table></dd></dl></dd></dl>
4051 !! end
4052
4053 # The trailing whitespace in this test is to catch a regression in
4054 # Parsoid after T54473.
4055 !! test
4056 Definition Lists: Hacky use to indent tables (WS-insensitive)
4057 !! wikitext
4058 : {|
4059 |a
4060 |}
4061 !! html/php
4062 <dl><dd><table>
4063 <tr>
4064 <td>a
4065 </td></tr></table></dd></dl>
4066
4067 !! html/parsoid
4068 <dl><dd> <table>
4069 <tbody><tr><td>a</td></tr>
4070 </tbody></table> </dd></dl>
4071 !! end
4072
4073 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
4074 ## as an empty dt item. It also ignores all but the last ";" when followed
4075 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
4076 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
4077 ## ";"s.
4078 ##
4079 ## Ex: ";;t2 ::d2" is transformed into:
4080 ##
4081 ## <dl>
4082 ## <dt>t2 </dt>
4083 ## <dd>
4084 ## <dl>
4085 ## <dt></dt>
4086 ## <dd>d2</dd>
4087 ## </dl>
4088 ## </dd>
4089 ## </dl>
4090 ##
4091 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
4092 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
4093 ##
4094 ## <dl>
4095 ## <dt>
4096 ## <dl>
4097 ## <dt>t2 </dt>
4098 ## <dd>:d2</dd>
4099 ## </dl>
4100 ## </dt>
4101 ## </dl>
4102 ##
4103 ## All Parsoid only definition list tests have this difference.
4104 ##
4105 ## See also: https://phabricator.wikimedia.org/T8569
4106 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4107
4108 !! test
4109 Table / list interaction: indented table with lists in table contents
4110 !! wikitext
4111 :{|
4112 |-
4113 |a
4114
4115 *b
4116 |-
4117 |c
4118
4119 *d
4120 |}
4121 !! html
4122 <dl><dd><table>
4123
4124 <tr>
4125 <td>a
4126 <ul><li>b</li></ul>
4127 </td></tr>
4128 <tr>
4129 <td>c
4130 <ul><li>d</li></ul>
4131 </td></tr></table></dd></dl>
4132
4133 !! end
4134
4135 !!test
4136 Table / list interaction: lists nested in tables nested in indented lists
4137 !! wikitext
4138 :{|
4139 |
4140 :a
4141 :b
4142 |
4143 *c
4144 *d
4145 |}
4146
4147 *e
4148 *f
4149 !! html
4150 <dl><dd><table>
4151 <tr>
4152 <td>
4153 <dl><dd>a</dd>
4154 <dd>b</dd></dl>
4155 </td>
4156 <td>
4157 <ul><li>c</li>
4158 <li>d</li></ul>
4159 </td></tr></table></dd></dl>
4160 <ul><li>e</li>
4161 <li>f</li></ul>
4162
4163 !!end
4164
4165 !! test
4166 Definition Lists: Nesting: Multi-level (Parsoid only)
4167 !! wikitext
4168 ;t1 :d1
4169 ;;t2 ::d2
4170 ;;;t3 :::d3
4171 !! html/parsoid
4172 <dl>
4173 <dt>t1 </dt>
4174 <dd>d1</dd>
4175 <dt>
4176 <dl>
4177 <dt>t2 </dt>
4178 <dd>:d2</dd>
4179 <dt>
4180 <dl>
4181 <dt>t3 </dt>
4182 <dd>::d3</dd>
4183 </dl>
4184 </dt>
4185 </dl>
4186 </dt>
4187 </dl>
4188
4189
4190 !! end
4191
4192
4193 !! test
4194 Definition Lists: Nesting: Test 2
4195 !! wikitext
4196 ;t1
4197 ::d2
4198 !! html+tidy
4199 <dl><dt>t1</dt>
4200 <dd>
4201 <dl><dd>d2</dd></dl></dd></dl>
4202 !! end
4203
4204
4205 !! test
4206 Definition Lists: Nesting: Test 3
4207 !! wikitext
4208 :;t1
4209 ::::d2
4210 !! html+tidy
4211 <dl><dd><dl><dt>t1</dt>
4212 <dd>
4213 <dl><dd><dl><dd>d2</dd></dl></dd></dl></dd></dl></dd></dl>
4214 !! end
4215
4216
4217 !! test
4218 Definition Lists: Nesting: Test 4
4219 !! wikitext
4220 ::;t3
4221 :::d3
4222 !! html
4223 <dl><dd><dl><dd><dl><dt>t3</dt>
4224 <dd>d3</dd></dl></dd></dl></dd></dl>
4225
4226 !! end
4227
4228
4229 ## The Parsoid team believes the following three test exposes a
4230 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4231 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4232 ## It also exposes a "misfeature" in tidy, which doesn't like
4233 ## <dl> tags with a single <dt> child; it converts the <dt> into
4234 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4235 !! test
4236 Definition Lists: Mixed Lists: Test 1
4237 !! wikitext
4238 :;*foo
4239 ::*bar
4240 :;baz
4241 !! html/php
4242 <dl><dd><dl><dt><ul><li>foo</li>
4243 <li>bar</li></ul></dt></dl>
4244 <dl><dt>baz</dt></dl></dd></dl>
4245
4246 !! html/php+tidy
4247 <dl><dd><dl><dt><ul><li>foo</li>
4248 <li>bar</li></ul></dt></dl>
4249 <dl><dt>baz</dt></dl></dd></dl>
4250 !! html/parsoid
4251 <dl>
4252 <dd><dl>
4253 <dt><ul>
4254 <li>foo
4255 </li>
4256 </ul></dt>
4257 <dd><ul>
4258 <li>bar
4259 </li>
4260 </ul></dd>
4261 <dt>baz</dt>
4262 </dl></dd>
4263 </dl>
4264 !! end
4265
4266 !! test
4267 Definition Lists: Mixed Lists: Test 2
4268 !! wikitext
4269 *:d1
4270 *:d2
4271 !! html
4272 <ul><li><dl><dd>d1</dd>
4273 <dd>d2</dd></dl></li></ul>
4274
4275 !! end
4276
4277
4278 !! test
4279 Definition Lists: Mixed Lists: Test 3
4280 !! wikitext
4281 *:::d1
4282 *:::d2
4283 !! html
4284 <ul><li><dl><dd><dl><dd><dl><dd>d1</dd>
4285 <dd>d2</dd></dl></dd></dl></dd></dl></li></ul>
4286
4287 !! end
4288
4289
4290 !! test
4291 Definition Lists: Mixed Lists: Test 4
4292 !! wikitext
4293 *;d1 :d2
4294 *;d3 :d4
4295 !! html
4296 <ul><li><dl><dt>d1&#160;</dt>
4297 <dd>d2</dd>
4298 <dt>d3&#160;</dt>
4299 <dd>d4</dd></dl></li></ul>
4300
4301 !! end
4302
4303
4304 !! test
4305 Definition Lists: Mixed Lists: Test 5
4306 !! wikitext
4307 *:d1
4308 *::d2
4309 !! html
4310 <ul><li><dl><dd>d1
4311 <dl><dd>d2</dd></dl></dd></dl></li></ul>
4312
4313 !! end
4314
4315
4316 !! test
4317 Definition Lists: Mixed Lists: Test 6
4318 !! wikitext
4319 #*:d1
4320 #*:::d3
4321 !! html
4322 <ol><li><ul><li><dl><dd>d1
4323 <dl><dd><dl><dd>d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4324
4325 !! end
4326
4327
4328 !! test
4329 Definition Lists: Mixed Lists: Test 7
4330 !! wikitext
4331 :*d1
4332 :*d2
4333 !! html
4334 <dl><dd><ul><li>d1</li>
4335 <li>d2</li></ul></dd></dl>
4336
4337 !! end
4338
4339
4340 !! test
4341 Definition Lists: Mixed Lists: Test 8
4342 !! wikitext
4343 :*d1
4344 ::*d2
4345 !! html
4346 <dl><dd><ul><li>d1</li></ul>
4347 <dl><dd><ul><li>d2</li></ul></dd></dl></dd></dl>
4348
4349 !! end
4350
4351
4352 !! test
4353 Definition Lists: Mixed Lists: Test 9
4354 !! wikitext
4355 *;foo :bar
4356 !! html
4357 <ul><li><dl><dt>foo&#160;</dt>
4358 <dd>bar</dd></dl></li></ul>
4359
4360 !! end
4361
4362
4363 !! test
4364 Definition Lists: Mixed Lists: Test 10
4365 !! wikitext
4366 *#;foo :bar
4367 !! html
4368 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4369 <dd>bar</dd></dl></li></ol></li></ul>
4370
4371 !! end
4372
4373 # The Parsoid team disagrees with the PHP parser's seemingly-random
4374 # rules regarding dd/dt on the next few tests. Parsoid is more
4375 # consistent, and recognizes the shared nesting and keeps the
4376 # still-open tags around until the nesting is complete.
4377
4378 # This is a regression test for T175099
4379 !! test
4380 Definition Lists: Mixed Lists: Test 11
4381 !! wikitext
4382 ;a
4383 :*b
4384 !! html/php
4385 <dl><dt>a</dt>
4386 <dd>
4387 <ul><li>b</li></ul></dd></dl>
4388
4389 !! html/parsoid
4390 <dl><dt>a
4391 <dd><ul><li>b</li></ul></dd></dl>
4392 !! end
4393
4394 # FIXME: Maybe get rid of this test?
4395 !! test
4396 Definition Lists: Mixed Lists: Test 12
4397 !! wikitext
4398 *#*#;*;;foo :bar
4399 *#*#;boo :baz
4400 !! html/php
4401 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4402 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4403 <dl><dt>boo&#160;</dt>
4404 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4405
4406 !! html/php+tidy
4407 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4408 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4409 <dl><dt>boo&#160;</dt>
4410 <dd>baz</dd></dl></li></ol></li></ul>
4411 !! html/parsoid
4412 <ul>
4413 <li>
4414 <ol>
4415 <li>
4416 <ul>
4417 <li>
4418 <ol>
4419 <li>
4420 <dl>
4421 <dt>
4422 <ul>
4423 <li>
4424 <dl>
4425 <dt>
4426 <dl>
4427 <dt>foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4428 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4429 </dl></dt>
4430 </dl></li>
4431 </ul></dt>
4432 <dt>boo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4433 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4434 </dl></li>
4435 </ol></li>
4436 </ul></li>
4437 </ol></li>
4438 </ul>
4439 !! end
4440
4441 # FIXME: Maybe get rid of this test?
4442 # From whitelist:
4443 # * The test is wrong, there are two colons where there should be :;
4444 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4445 !! test
4446 Definition Lists: Weird Ones: Test 1
4447 !! wikitext
4448 *#;*::;;foo :bar (who uses this?)
4449 !! html/php+tidy
4450 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4451 <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>
4452 !! html/parsoid
4453 <ul>
4454 <li>
4455 <ol>
4456 <li>
4457 <dl>
4458 <dt>
4459 <ul>
4460 <li>
4461 <dl>
4462 <dd>
4463 <dl>
4464 <dd>
4465 <dl>
4466 <dt>
4467 <dl>
4468 <dt>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span></dt>
4469 <dd data-parsoid='{"stx":"row"}'>bar (who uses this?)</dd>
4470 </dl></dt>
4471 </dl></dd>
4472 </dl></dd>
4473 </dl></li>
4474 </ul></dt>
4475 </dl></li>
4476 </ol></li>
4477 </ul>
4478 !! end
4479
4480 !! test
4481 Definition Lists: colons occurring in tags
4482 !! wikitext
4483 ;a:b
4484 ;'''a:b'''
4485 ;<i>a:b</i>
4486 ;<span>a:b</span>
4487 ;<div>a:b</div>
4488 ;<div>a
4489 :b</div>
4490 ;{{echo|a:b}}
4491 ;{{echo|''a:b''}}
4492 ;;;''a:b''
4493 !! html+tidy
4494 <dl><dt>a</dt>
4495 <dd>b</dd>
4496 <dt><b>a:b</b></dt>
4497 <dt><i>a:b</i></dt>
4498 <dt><span>a:b</span></dt>
4499 <dt><div>a:b</div></dt>
4500 <dt><div>a</div></dt>
4501 <dd>b</dd>
4502 <dt>a</dt>
4503 <dd>b</dd>
4504 <dt><i>a:b</i></dt></dl>
4505 <dl><dt><dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4506 !! html/parsoid
4507 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4508 <dt><b>a:b</b></dt>
4509 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4510 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4511 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4512 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4513 <dd>b</dd>
4514 <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>
4515 <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>
4516 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4517 !! end
4518
4519 # Parsoid's output differs here again because it shares
4520 # nesting between the two lists unlike the PHP parser.
4521 # Unsure which is more desirable.
4522 !! test
4523 Definition Lists: colons and tables 1
4524 !! wikitext
4525 :{|
4526 |x
4527 |}
4528 :{|
4529 |y
4530 |}
4531 !! html/php
4532 <dl><dd><table>
4533 <tr>
4534 <td>x
4535 </td></tr></table></dd></dl>
4536 <dl><dd><table>
4537 <tr>
4538 <td>y
4539 </td></tr></table></dd></dl>
4540
4541 !! html/parsoid
4542 <dl><dd><table>
4543 <tr>
4544 <td>x
4545 </td></tr></table></dd>
4546 <dd><table>
4547 <tr>
4548 <td>y
4549 </td></tr></table></dd></dl>
4550 !! end
4551
4552 # FIXME: Does this need a html/php section?
4553 !! test
4554 Definition Lists: template interaction
4555 !! wikitext
4556 ::{{definition_list}}
4557
4558 :one
4559 ::{{definition_list}}
4560 :::two
4561 :::three
4562 ::four
4563 !! html/parsoid
4564 <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">
4565 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4566
4567 <dl><dd data-parsoid='{}'>one
4568 <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">
4569 </span><dd about="#mwt2">two
4570 <dl><dd>two</dd>
4571 <dd>three</dd></dl></dd>
4572 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4573 !! end
4574
4575
4576 ###
4577 ### External links
4578 ###
4579 !! test
4580 External links: non-bracketed
4581 !! wikitext
4582 Non-bracketed: http://example.com
4583 !! html
4584 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4585 </p>
4586 !! end
4587
4588 # parsoid doesn't explicitly mark autonumbered links, see T55505
4589 !! test
4590 External links: numbered
4591 !! wikitext
4592 Numbered: [http://example.com]
4593 Numbered: [http://example.net]
4594 Numbered: [http://example.com]
4595 !! html/php
4596 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4597 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4598 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4599 </p>
4600 !! html/parsoid
4601 <p>Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>
4602 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.net"></a>
4603 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a></p>
4604 !!end
4605
4606 !! test
4607 External links: specified text
4608 !! wikitext
4609 Specified text: [http://example.com link]
4610 !! html
4611 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4612 </p>
4613 !!end
4614
4615 !! test
4616 External links: trail
4617 !! wikitext
4618 Linktrails should not work for external links: [http://example.com link]s
4619 !! html
4620 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4621 </p>
4622 !! end
4623
4624 !! test
4625 External links: dollar sign in URL
4626 !! wikitext
4627 http://example.com/1$2345
4628 !! html
4629 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4630 </p>
4631 !! end
4632
4633 # parsoid doesn't explicitly mark autonumbered links, see T55505
4634 !! test
4635 External links: dollar sign in URL (autonumber)
4636 !! wikitext
4637 [http://example.com/1$2345]
4638 !! html/php
4639 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4640 </p>
4641 !! html/parsoid
4642 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/1$2345"></a></p>
4643 !!end
4644
4645 !! test
4646 External links: open square bracket forbidden in URL (T6377)
4647 !! options
4648 parsoid=wt2html,wt2wt,html2html
4649 !! wikitext
4650 http://example.com/1[2345
4651 !! html/php
4652 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4653 </p>
4654 !! html/parsoid
4655 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/1">http://example.com/1</a>[2345</p>
4656 !! end
4657
4658 !! test
4659 External links: open square bracket forbidden in URL (named) (T6377)
4660 !! options
4661 parsoid=wt2html,html2html
4662 !! wikitext
4663 [http://example.com/1[2345]
4664 !! html/php
4665 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4666 </p>
4667 !! html/parsoid
4668 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/1">[2345</a></p>
4669 !!end
4670
4671 # parsoid adds a space before the link name
4672 !! test
4673 External links: open square bracket forbidden in URL (named) (T6377)
4674 Parsoid variant.
4675 !! wikitext
4676 [http://example.com/1 [2345]
4677 !! html
4678 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4679 </p>
4680 !!end
4681
4682 !! test
4683 External links: nowiki in URL link text (T8230)
4684 !! wikitext
4685 [http://example.com/ <nowiki>''example site''</nowiki>]
4686 !! html
4687 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4688 </p>
4689 !! end
4690
4691 !! test
4692 External links: newline forbidden in text (T8230 regression check)
4693 !! wikitext
4694 [http://example.com/ first
4695 second]
4696 !! html
4697 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4698 second]
4699 </p>
4700 !!end
4701
4702 !! test
4703 External links: Pipe char between url and text
4704 !! wikitext
4705 [http://example.com | link]
4706 !! html
4707 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4708 </p>
4709 !!end
4710
4711 !! test
4712 External links: protocol-relative URL in brackets
4713 !! wikitext
4714 [//example.com/ Test]
4715 !! html
4716 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4717 </p>
4718 !! end
4719
4720 # parsoid doesn't explicitly mark autonumbered links, see T55505
4721 !! test
4722 External links: protocol-relative URL in brackets without text
4723 !! wikitext
4724 [//example.com]
4725 !! html/php
4726 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
4727 </p>
4728 !! html/parsoid
4729 <p><a rel="mw:ExtLink" class="external autonumber" href="//example.com"></a></p>
4730 !! end
4731
4732 !! test
4733 External links: protocol-relative URL in free text is left alone
4734 !! wikitext
4735 //example.com/Foo
4736 !! html
4737 <p>//example.com/Foo
4738 </p>
4739 !!end
4740
4741 !! test
4742 External links: protocol-relative URL in the middle of a word is left alone (T32269)
4743 !! wikitext
4744 foo//example.com/Foo
4745 !! html
4746 <p>foo//example.com/Foo
4747 </p>
4748 !! end
4749
4750 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
4751 !! test
4752 External links: with no contents
4753 !! options
4754 parsoid=wt2html,wt2wt
4755 !! wikitext
4756 [http://en.wikipedia.org/wiki/Foo]
4757
4758 [[wikipedia:Foo|Bar]]
4759
4760 [[wikipedia:Foo|<span>Bar</span>]]
4761 !! html/php
4762 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
4763 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
4764 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
4765 </p>
4766 !! html/parsoid
4767 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo"></a></p>
4768 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
4769 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
4770 !! end
4771
4772 !! test
4773 External links: Free with trailing punctuation
4774 !! wikitext
4775 http://example.com,
4776 http://example.com;
4777 http://example.com\
4778 http://example.com.
4779 http://example.com:
4780 http://example.com!
4781 http://example.com?
4782 http://example.com)
4783 http://example.com/url_with_(brackets)
4784 (http://example.com/url_without_brackets)
4785 http://example.com/url_with_entity&amp;
4786 http://example.com/url_with_entity&#x26;
4787 http://example.com/url_with_entity&#038;
4788 http://example.com/url_with_entity&nbsp;
4789 http://example.com/url_with_entity&#xA0;
4790 http://example.com/url_with_entity&#160;
4791 http://example.com/url_with_entity&lt;
4792 http://example.com/url_with_entity&#x3C;
4793 http://example.com/url_with_entity&#60;
4794 !! html/php
4795 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
4796 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
4797 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
4798 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
4799 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
4800 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
4801 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
4802 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
4803 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4804 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4805 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4806 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4807 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4808 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4809 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
4810 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4811 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
4812 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
4813 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
4814 </p>
4815 !! html/parsoid
4816 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>,
4817 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>;
4818 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>\
4819 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>.
4820 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>:
4821 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>!
4822 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>?
4823 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)
4824 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4825 (<a rel="mw:ExtLink" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4826 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4827 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4828 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4829 <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>
4830 <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>
4831 <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>
4832 <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>
4833 <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>
4834 <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>
4835 !! end
4836
4837 !! test
4838 External links: tricky Parsoid html2html case
4839 !! options
4840 parsoid=wt2html,wt2wt,html2html
4841 !! wikitext
4842 http://example.com/url_with_entity&amp;amp;
4843 !! html/php
4844 <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>;
4845 </p>
4846 !! html/parsoid
4847 <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>
4848 !! end
4849
4850 !! test
4851 External links: Free with trailing quotes (T113666)
4852 !! wikitext
4853 '''News:''' Stuff here
4854
4855 news:'a'b''c''d e
4856 !! html/php
4857 <p><b>News:</b> Stuff here
4858 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
4859 </p>
4860 !! html/parsoid
4861 <p><b>News:</b> Stuff here</p>
4862 <p><a rel="mw:ExtLink" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
4863 !! end
4864
4865 !! test
4866 External links: with entity
4867 !! wikitext
4868 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
4869 !! html/php
4870 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
4871 </p>
4872 !! html/parsoid
4873 <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>
4874 !! end
4875
4876 !! test
4877 External links: Lone protocols are never linked (T105697)
4878 !! wikitext
4879 http://
4880 http://;
4881 (http://)
4882 bitcoin:
4883 bitcoin:;
4884 (bitcoin:)
4885 !! html
4886 <p>http://
4887 http://;
4888 (http://)
4889 bitcoin:
4890 bitcoin:;
4891 (bitcoin:)
4892 </p>
4893 !! end
4894
4895 !! test
4896 External links: No preceding word characters allowed (T67278)
4897 !! wikitext
4898 NOPEhttp://example.com
4899 N0http://example.com
4900 ok:http://example.com
4901 ok-http://example.com
4902 !! html
4903 <p>NOPEhttp://example.com
4904 N0http://example.com
4905 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4906 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4907 </p>
4908 !! end
4909
4910 !! test
4911 External links: nofollow domain exception
4912 !! wikitext
4913 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
4914 !! html
4915 <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>.
4916 </p>
4917 !!end
4918
4919 !! test
4920 External image
4921 !! wikitext
4922 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4923 !! html
4924 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
4925 </p>
4926 !! end
4927
4928 !! test
4929 External image from https
4930 !! wikitext
4931 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4932 !! html
4933 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
4934 </p>
4935 !! end
4936
4937 !! test
4938 External image (when not allowed)
4939 !! options
4940 wgAllowExternalImages=0
4941 !! wikitext
4942 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4943 !! html
4944 <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>
4945 </p>
4946 !! end
4947
4948 !! test
4949 Link to non-http image, no img tag
4950 !! wikitext
4951 Link to non-http image, no img tag: ftp://example.com/test.jpg
4952 !! html
4953 <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>
4954 </p>
4955 !! end
4956
4957 !! test
4958 External links: terminating separator
4959 !! wikitext
4960 Terminating separator: http://example.com/thing,
4961 !! html
4962 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
4963 </p>
4964 !! end
4965
4966 !! test
4967 External links: intervening separator
4968 !! wikitext
4969 Intervening separator: http://example.com/1,2,3
4970 !! html
4971 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
4972 </p>
4973 !! end
4974
4975 !! test
4976 External links: old bug with URL in query
4977 !! wikitext
4978 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
4979 !! html
4980 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
4981 </p>
4982 !! end
4983
4984 !! test
4985 External links: old URL-in-URL bug, mixed protocols
4986 !! wikitext
4987 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
4988 !! html
4989 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
4990 </p>
4991 !!end
4992
4993 # Since Parsoid is starting to emit canonical wikitext for links,
4994 # [http://example.com http://example.com] will not RT back to that
4995 # form anymore.
4996 !! test
4997 External links: URL in text
4998 !! options
4999 parsoid=wt2html
5000 !! wikitext
5001 URL in text: [http://example.com http://example.com]
5002 !! html/php
5003 <p>URL in text: <a rel="nofollow" class="external text" href="http://example.com">http://example.com</a>
5004 </p>
5005 !! html/parsoid
5006 <p>URL in text: <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
5007 !! end
5008
5009 !! test
5010 External links: Clickable images
5011 !! wikitext
5012 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5013 !! html/php
5014 <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>
5015 </p>
5016 !! html/parsoid
5017 <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>
5018 !! end
5019
5020 !! test
5021 External links: raw ampersand
5022 !! wikitext
5023 Old &amp; use: http://x&y
5024 !! html
5025 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5026 </p>
5027 !! end
5028
5029 !! test
5030 External links: encoded ampersand
5031 !! wikitext
5032 Old &amp; use: http://x&amp;y
5033 !! html/php
5034 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5035 </p>
5036 !! html/parsoid
5037 <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>
5038 !! end
5039
5040 !! test
5041 External links: encoded equals (T8102)
5042 !! wikitext
5043 http://example.com/?foo&#61;bar
5044 !! html/php
5045 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5046 </p>
5047 !! html/parsoid
5048 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5049 !! end
5050
5051 ##
5052 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5053 ## does it number them. As discussed in T55505, we can identify
5054 ## autonumbered links via CSS.
5055 ##
5056
5057 !! test
5058 External links: [raw ampersand]
5059 !! wikitext
5060 Old &amp; use: [http://x&y]
5061 !! html/php
5062 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5063 </p>
5064 !! html/parsoid
5065 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5066 !! end
5067
5068 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5069 # mode will return the [raw ampersand] wikitext
5070 !! test
5071 External links: [encoded ampersand]
5072 !! options
5073 parsoid=wt2html,wt2wt,html2html
5074 !! wikitext
5075 Old &amp; use: [http://x&amp;y]
5076 !! html/php
5077 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5078 </p>
5079 !! html/parsoid
5080 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5081 !! end
5082
5083 !! test
5084 External links: [raw equals]
5085 !! wikitext
5086 [http://example.com/?foo=bar]
5087 !! html/php
5088 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5089 </p>
5090 !! html/parsoid
5091 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5092 !! end
5093
5094 # note that parsoid html is identical to [raw equals] case; so html2wt
5095 # mode will return the [raw equals] wikitext
5096 !! test
5097 External links: [encoded equals] (T8102)
5098 !! options
5099 parsoid=wt2html,wt2wt,html2html
5100 !! wikitext
5101 [http://example.com/?foo&#61;bar]
5102 !! html/php
5103 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5104 </p>
5105 !! html/parsoid
5106 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5107 !! end
5108
5109 # xxx parsoid strips the IDN character, so the round-trip tests will
5110 # obviously fail and are disabled. --cscott
5111 !! test
5112 External links: [IDN ignored character reference in hostname; strip it right off]
5113 !! options
5114 parsoid=wt2html,wt2wt,html2html
5115 !! wikitext
5116 [http://e&zwnj;xample.com/]
5117 !! html/php
5118 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5119 </p>
5120 !! html/parsoid
5121 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/"></a></p>
5122 !! end
5123
5124 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5125 # Where an external link could easily circumvent the sanitization of the text of
5126 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5127 # test demands a higher standard. That's a bit strange.
5128 #
5129 # Example:
5130 #
5131 # http://e‌xample.com -> [http://example.com|http://example.com]
5132 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5133 #
5134 # The first example is sanitized, but the second is not. Any security benefits
5135 # from this production are trivial to circumvent. Either remove this test and
5136 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5137 # the test accordingly.
5138 #
5139 # All our love,
5140 # The Parsoid team.
5141 # xxx parsoid strips the IDN character, so the round-trip tests will
5142 # obviously fail and are disabled. --cscott
5143 !! test
5144 External links: IDN ignored character reference in hostname; strip it right off
5145 !! options
5146 parsoid=wt2html,html2html
5147 !! wikitext
5148 http://e&zwnj;xample.com/
5149 !! html/php
5150 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5151 </p>
5152 !! html/parsoid
5153 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/">http://example.com/</a></p>
5154 !! end
5155
5156 !! test
5157 External links: www.jpeg.org (T2554)
5158 !! wikitext
5159 http://www.jpeg.org
5160 !! html
5161 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5162 </p>
5163 !! end
5164
5165 # parsoid doesn't explicitly mark autonumbered links, see T55505
5166 !! test
5167 External links: URL within URL (T2002)
5168 !! wikitext
5169 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5170 !! html/php
5171 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5172 </p>
5173 !! html/parsoid
5174 <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>
5175 !! end
5176
5177 !! test
5178 T2361: URL inside bracketed URL
5179 !! wikitext
5180 [http://www.example.com/foo http://www.example.com/bar]
5181 !! html
5182 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5183 </p>
5184 !! end
5185
5186 !! test
5187 T2361: URL within URL, not bracketed
5188 !! wikitext
5189 http://www.example.com/foo?=http://www.example.com/bar
5190 !! html
5191 <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>
5192 </p>
5193 !! end
5194
5195 !! test
5196 T2289: ">"-token in URL-tail
5197 !! wikitext
5198 http://www.example.com/<hello>
5199 !! html
5200 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5201 </p>
5202 !!end
5203
5204 !! test
5205 T2289: literal ">"-token in URL-tail
5206 !! wikitext
5207 http://www.example.com/<b>html</b>
5208 !! html/php
5209 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5210 </p>
5211 !! html/parsoid
5212 <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>
5213 !! end
5214
5215 !! test
5216 T2289: ">"-token in bracketed URL
5217 !! wikitext
5218 [http://www.example.com/<hello> stuff]
5219 !! html
5220 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5221 </p>
5222 !!end
5223
5224 !! test
5225 T2289: literal ">"-token in bracketed URL
5226 !! wikitext
5227 [http://www.example.com/<b>html</b> stuff]
5228 !! html
5229 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5230 </p>
5231 !!end
5232
5233 !! test
5234 T2289: literal double quote at end of URL
5235 !! wikitext
5236 http://www.example.com/"hello"
5237 !! html
5238 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5239 </p>
5240 !!end
5241
5242 !! test
5243 T2289: literal double quote in bracketed URL
5244 !! wikitext
5245 [http://www.example.com/"hello" stuff]
5246 !! html
5247 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5248 </p>
5249 !!end
5250
5251 !! test
5252 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5253 !! wikitext
5254 [http://www.example.com test]
5255 !! html
5256 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5257 </p>
5258 !! end
5259
5260 !! test
5261 External links: link text with spaces
5262 !! wikitext
5263 [http://www.example.com a b c]
5264 [http://www.example.com ''a'' ''b'']
5265 !! html
5266 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5267 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5268 </p>
5269 !! end
5270
5271 # Note edge case difference between PHP and Parsoid here.
5272 !! test
5273 External links: wiki links within external link (T5695)
5274 !! options
5275 parsoid=wt2html,html2html
5276 !! wikitext
5277 [http://example.com [[wikilink]] embedded in ext link]
5278
5279 [http://example.com test [[wikilink]] embedded in ext link]
5280 !! html/php
5281 <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>
5282 </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>
5283 </p>
5284 !! html/parsoid
5285 <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>
5286 <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>
5287 !! end
5288
5289 !! test
5290 T2787: Links with one slash after the url protocol are invalid
5291 !! wikitext
5292 http:/example.com
5293
5294 [http:/example.com title]
5295 !! html
5296 <p>http:/example.com
5297 </p><p>[http:/example.com title]
5298 </p>
5299 !! end
5300
5301 !! test
5302 Bracketed external links with template-generated invalid target
5303 !! wikitext
5304 [{{echo|http:/example.com}} title]
5305 !! html
5306 <p>[http:/example.com title]
5307 </p>
5308 !! end
5309
5310 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5311 !! test
5312 Broken wikilinks (but not external links) prevent templates from closing
5313 !! options
5314 parsoid=wt2html
5315 !! wikitext
5316 [http://example.com x
5317
5318 {{echo|[http://example.com x}}
5319
5320 [[Foo
5321
5322 {{echo|[[Foo}}
5323 !! html/php
5324 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5325 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5326 </p><p>[[Foo
5327 </p><p>{{echo|[[Foo}}
5328 </p>
5329 !! html/parsoid
5330 <p>[<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> x</p>
5331 <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>
5332 <p>[[Foo</p>
5333 <p>{{echo|[[Foo}}</p>
5334 !! end
5335
5336 !! test
5337 Wikilinks with embedded newlines are not broken
5338 !! wikitext
5339 {{echo|[[ Foo
5340 B
5341 C]]}}
5342 !! html/php
5343 <p>[[ Foo
5344 B
5345 C]]
5346 </p>
5347 !! html/parsoid
5348 <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>
5349 !! end
5350
5351 !! test
5352 Broken templates
5353 !! options
5354 parsoid=wt2html
5355 !! wikitext
5356 {{echo|[[Foo|}}]]
5357
5358 [[Foo|{{echo|]]}}
5359 !! html/php
5360 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5361 </p><p>[[Foo|]]
5362 </p>
5363 !! html/parsoid
5364 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5365 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5366 !! end
5367
5368 !! test
5369 T4702: Mismatched <i>, <b> and <a> tags are invalid
5370 !! wikitext
5371 ''[http://example.com text'']
5372 [http://example.com '''text]'''
5373 ''Something [http://example.com in italic'']
5374 ''Something [http://example.com mixed''''', even bold]'''
5375 '''''Now [http://example.com both''''']
5376 !! html
5377 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5378 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5379 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5380 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5381 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5382 </p>
5383 !! end
5384
5385
5386 !! test
5387 T6781: %26 in URL
5388 !! wikitext
5389 http://www.example.com/?title=AT%26T
5390 !! html/php
5391 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5392 </p>
5393 !! html/parsoid
5394 <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>
5395 !! end
5396
5397 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5398 # % is actually legal in HTML5. Any change in output would need testing though.
5399 !! test
5400 T6781, T7267: %25 in URL
5401 !! wikitext
5402 http://www.example.com/?title=100%25_Bran
5403 !! html/php
5404 <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>
5405 </p>
5406 !! html/parsoid
5407 <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>
5408 !! end
5409
5410 !! test
5411 T6781, T7267: %28, %29 in URL
5412 !! wikitext
5413 http://www.example.com/?title=Ben-Hur_%281959_film%29
5414 !! html/php
5415 <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>
5416 </p>
5417 !! html/parsoid
5418 <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>
5419 !! end
5420
5421
5422 !! test
5423 T6781: %26 in autonumber URL
5424 !! wikitext
5425 [http://www.example.com/?title=AT%26T]
5426 !! html/php
5427 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5428 </p>
5429 !! html/parsoid
5430 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=AT%26T"></a></p>
5431 !! end
5432
5433 !! test
5434 T6781, T7267: %26 in autonumber URL
5435 !! wikitext
5436 [http://www.example.com/?title=100%25_Bran]
5437 !! html/php
5438 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5439 </p>
5440 !! html/parsoid
5441 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=100%25_Bran"></a></p>
5442 !! end
5443
5444 !! test
5445 T6781, T7267: %28, %29 in autonumber URL
5446 !! wikitext
5447 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5448 !! html/php
5449 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5450 </p>
5451 !! html/parsoid
5452 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5453 !! end
5454
5455
5456 !! test
5457 T6781: %26 in bracketed URL
5458 !! wikitext
5459 [http://www.example.com/?title=AT%26T link]
5460 !! html/php
5461 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5462 </p>
5463 !! html/parsoid
5464 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=AT%26T">link</a></p>
5465 !! end
5466
5467 !! test
5468 T6781, T7267: %25 in bracketed URL
5469 !! wikitext
5470 [http://www.example.com/?title=100%25_Bran link]
5471 !! html
5472 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5473 </p>
5474 !! end
5475
5476 !! test
5477 T6781, T7267: %28, %29 in bracketed URL
5478 !! wikitext
5479 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5480 !! html/php
5481 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5482 </p>
5483 !! html/parsoid
5484 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5485 !! end
5486
5487 !! test
5488 External link containing a period in the anchor. (T65947)
5489 !! wikitext
5490 [//foo.org/bar#baz. bang]
5491
5492 [//foo.org/bar. bang]
5493 !! html/php
5494 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5495 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5496 </p>
5497 !! html/parsoid
5498 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar#baz.">bang</a></p>
5499 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar.">bang</a></p>
5500 !! end
5501
5502 !! test
5503 External link containing a single quote. (T65947)
5504 !! wikitext
5505 [//foo.org/bar'baz]
5506
5507 [//foo.org/bar'baz bang]
5508 !! html/php
5509 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
5510 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
5511 </p>
5512 !! html/parsoid
5513 <p><a rel="mw:ExtLink" class="external autonumber" href="//foo.org/bar'baz"></a></p>
5514 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar'baz">bang</a></p>
5515 !! end
5516
5517 !! test
5518 External link containing double-single-quotes in text '' (T6598 sanity check)
5519 !! wikitext
5520 Some [http://example.com/ pretty ''italics'' and stuff]!
5521 !! html
5522 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5523 </p>
5524 !! end
5525
5526 !! test
5527 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5528 !! wikitext
5529 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5530 !! html
5531 <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>
5532 </p>
5533 !! end
5534
5535 # Don't add the html/php section since the output is broken and there isn't any reason to spec it
5536 !! test
5537 External link containing double-single-quotes with no space separating the url from text in italics
5538 !! wikitext
5539 [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]].]
5540 !! html/php+tidy
5541 <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>.
5542 </p>
5543 !! html/parsoid
5544 <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>
5545 !! end
5546
5547 !! test
5548 External link with comments in link text
5549 !! wikitext
5550 [http://www.google.com Google <!-- comment -->]
5551 !! html/php
5552 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5553 </p>
5554 !! html/parsoid
5555 <p><a rel="mw:ExtLink" class="external text" href="http://www.google.com">Google <!-- comment --></a></p>
5556 !! end
5557
5558 !! test
5559 External link to bare IPv4 address
5560 !! wikitext
5561 [http://192.168.0.1 Link]
5562 !! html/php
5563 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5564 </p>
5565 !! html/parsoid
5566 <p><a rel="mw:ExtLink" class="external text" href="http://192.168.0.1">Link</a></p>
5567 !! end
5568
5569 !! test
5570 URL-encoding in URL functions (single parameter)
5571 !! wikitext
5572 {{localurl:Some page|amp=&}}
5573 !! html
5574 <p>/index.php?title=Some_page&amp;amp=&amp;
5575 </p>
5576 !! end
5577
5578 !! test
5579 URL-encoding in URL functions (multiple parameters)
5580 !! wikitext
5581 {{localurl:Some page|q=?&amp=&}}
5582 !! html
5583 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5584 </p>
5585 !! end
5586
5587 !! test
5588 Brackets in urls
5589 !! wikitext
5590 http://example.com/index.php?foozoid%5B%5D=bar
5591
5592 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5593 !! html/php
5594 <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>
5595 </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>
5596 </p>
5597 !! html/parsoid
5598 <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>
5599
5600 <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>
5601 !! end
5602
5603 !! test
5604 IPv6 urls, autolink format (T23261)
5605 !! wikitext
5606 http://[2404:130:0:1000::187:2]/index.php
5607
5608 Examples from RFC 2373, section 2.2:
5609
5610 *http://[1080::8:800:200C:417A]/unicast
5611 *http://[FF01::101]/multicast
5612 *http://[::1]/loopback
5613 *http://[::]/unspecified
5614 *http://[::13.1.68.3]/ipv4compat
5615 *http://[::FFFF:129.144.52.38]/ipv4compat
5616
5617 Examples from RFC 2732, section 2:
5618
5619 *http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5620 *http://[1080:0:0:0:8:800:200C:417A]/index.html
5621 *http://[3ffe:2a00:100:7031::1]
5622 *http://[1080::8:800:200C:417A]/foo
5623 *http://[::192.9.5.5]/ipng
5624 *http://[::FFFF:129.144.52.38]:80/index.html
5625 *http://[2010:836B:4179::836B:4179]
5626 !! html/php
5627 <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>
5628 </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:
5629 </p>
5630 <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>
5631 <li><a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5632 <li><a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5633 <li><a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5634 <li><a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5635 <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>
5636 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5637 </p>
5638 <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>
5639 <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>
5640 <li><a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5641 <li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5642 <li><a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5643 <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>
5644 <li><a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5645
5646 !! html/parsoid
5647 <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>
5648
5649 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink" class="external text">RFC 2373</a>, section 2.2:</p>
5650 <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>
5651 <li><a rel="mw:ExtLink" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5652 <li><a rel="mw:ExtLink" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5653 <li><a rel="mw:ExtLink" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5654 <li><a rel="mw:ExtLink" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5655 <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>
5656
5657 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external text">RFC 2732</a>, section 2:</p>
5658 <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>
5659 <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>
5660 <li><a rel="mw:ExtLink" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5661 <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>
5662 <li><a rel="mw:ExtLink" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5663 <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>
5664 <li><a rel="mw:ExtLink" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5665 !! end
5666
5667 !! test
5668 IPv6 urls, bracketed format (T23261)
5669 !! wikitext
5670 [http://[2404:130:0:1000::187:2]/index.php test]
5671
5672 Examples from RFC 2373, section 2.2:
5673
5674 *[http://[1080::8:800:200C:417A] unicast]
5675 *[http://[FF01::101] multicast]
5676 *[http://[::1]/ loopback]
5677 *[http://[::] unspecified]
5678 *[http://[::13.1.68.3] ipv4compat]
5679 *[http://[::FFFF:129.144.52.38] ipv4compat]
5680
5681 Examples from RFC 2732, section 2:
5682
5683 *[http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5684 *[http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5685 *[http://[3ffe:2a00:100:7031::1] 3]
5686 *[http://[1080::8:800:200C:417A]/foo 4]
5687 *[http://[::192.9.5.5]/ipng 5]
5688 *[http://[::FFFF:129.144.52.38]:80/index.html 6]
5689 *[http://[2010:836B:4179::836B:4179] 7]
5690 !! html/php
5691 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5692 </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:
5693 </p>
5694 <ul><li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5695 <li><a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5696 <li><a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5697 <li><a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5698 <li><a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5699 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5700 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5701 </p>
5702 <ul><li><a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5703 <li><a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5704 <li><a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5705 <li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5706 <li><a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5707 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5708 <li><a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5709
5710 !! html/parsoid
5711 <p><a rel="mw:ExtLink" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5712
5713 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink" class="external text">RFC 2373</a>, section 2.2:</p>
5714 <ul><li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5715 <li><a rel="mw:ExtLink" class="external text" href="http://[FF01::101]">multicast</a></li>
5716 <li><a rel="mw:ExtLink" class="external text" href="http://[::1]/">loopback</a></li>
5717 <li><a rel="mw:ExtLink" class="external text" href="http://[::]">unspecified</a></li>
5718 <li><a rel="mw:ExtLink" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5719 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5720
5721 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external text">RFC 2732</a>, section 2:</p>
5722 <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>
5723 <li><a rel="mw:ExtLink" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5724 <li><a rel="mw:ExtLink" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5725 <li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5726 <li><a rel="mw:ExtLink" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5727 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5728 <li><a rel="mw:ExtLink" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5729 !! end
5730
5731 !! test
5732 Non-extlinks in brackets
5733 !! wikitext
5734 [foo]
5735 [foo bar]
5736 [foo ''bar'']
5737 [fool's] errand
5738 [fool's errand]
5739 [{{echo|foo}}]
5740 [{{echo|foo}} bar]
5741 [{{echo|foo}} ''bar'']
5742 [{{echo|foo}}l's] errand
5743 [{{echo|foo}}l's errand]
5744 [url={{echo|foo}}]
5745 [url=http://example.com]
5746 [http:// bare protocols don't count]
5747 !! html/php
5748 <p>[foo]
5749 [foo bar]
5750 [foo <i>bar</i>]
5751 [fool's] errand
5752 [fool's errand]
5753 [foo]
5754 [foo bar]
5755 [foo <i>bar</i>]
5756 [fool's] errand
5757 [fool's errand]
5758 [url=foo]
5759 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
5760 [http:// bare protocols don't count]
5761 </p>
5762 !! html/parsoid
5763 <p>[foo]
5764 [foo bar]
5765 [foo <i>bar</i>]
5766 [fool's] errand
5767 [fool's errand]
5768 [<span about="#mwt19" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
5769 [<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]
5770 [<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>]
5771 [<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
5772 [<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]
5773 [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>]
5774 [url=<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>]
5775 [http:// bare protocols don't count]</p>
5776 !! end
5777
5778 !! test
5779 Percent encoding in external links
5780 !! wikitext
5781 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
5782 !! html/php
5783 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
5784 </p>
5785 !! html/parsoid
5786 <p><a rel="mw:ExtLink" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
5787 !! end
5788
5789 !! test
5790 Use url link syntax for links where the content is equal the link target
5791 !! wikitext
5792 http://example.com
5793 !! html/php
5794 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5795 </p>
5796 !! html/parsoid
5797 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
5798 !! end
5799
5800 !! test
5801 Parenthesis in external links, especially URL links
5802 !! wikitext
5803 http://example.com)
5804
5805 http://example.com/test)
5806
5807 http://example.com/(test)
5808
5809 http://example.com/((test)
5810
5811 (http://example.com/(test))
5812
5813 (http://example.com/(test)))))
5814
5815 http://example.com/a)b
5816
5817 [http://example.com) foo]
5818 !! html/php
5819 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5820 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
5821 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
5822 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
5823 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
5824 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
5825 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
5826 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
5827 </p>
5828 !! html/parsoid
5829 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)</p>
5830 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/test">http://example.com/test</a>)</p>
5831 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/(test)">http://example.com/(test)</a></p>
5832 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/((test)">http://example.com/((test)</a></p>
5833 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test))">http://example.com/(test))</a></p>
5834 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
5835 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/a)b">http://example.com/a)b</a></p>
5836 <p><a rel="mw:ExtLink" class="external text" href="http://example.com)">foo</a></p>
5837 !! end
5838
5839 !! test
5840 Parenthesis in external links, w/ transclusion or comment
5841 !! wikitext
5842 (http://example.com/{{echo|hi}})
5843
5844 (http://example.com<!-- hi -->)
5845 !! html/php
5846 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
5847 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5848 </p>
5849 !! html/parsoid
5850 <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>
5851
5852 <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>
5853 !! end
5854
5855 !! test
5856 Serialize <a> tags with invalid link targets as plain text
5857 !! options
5858 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
5859 !! html/parsoid
5860 <a rel="mw:WikiLink" href="[[foo]]">text</a>
5861 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
5862 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
5863 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
5864 !! wikitext
5865 text
5866 <nowiki>*</nowiki>text
5867 <nowiki>[[foo]]</nowiki>
5868 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
5869 !! end
5870
5871 !! test
5872 mw:ExtLink -vs- mw:WikiLink (T94723)
5873 !! options
5874 parsoid=html2wt
5875 !! html/parsoid
5876 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
5877 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
5878 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5879 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5880 <p>
5881 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5882 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5883 </p>
5884 !! wikitext
5885 [[Foo|Bar]]
5886 [[Foo|Bar]]
5887 [[:en:Foo|Bar]]
5888 [[:en:Foo|Bar]]
5889
5890 [[:en:European_Robin|European Robin]]
5891 [[:en:European_Robin|European Robin]]
5892 !! end
5893
5894 !! test
5895 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
5896 !! options
5897 parsoid=wt2wt
5898 !! wikitext
5899 [http://en.wikipedia.org/wiki/European_Robin European Robin]
5900 !! html/parsoid
5901 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
5902 !! end
5903
5904
5905 ###
5906 ### Quotes
5907 ###
5908
5909 !! test
5910 Quotes
5911 !! wikitext
5912 Normal text. '''Bold text.''' Normal text. ''Italic text.''
5913
5914 Normal text. '''''Bold italic text.''''' Normal text.
5915 !! html
5916 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
5917 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
5918 </p>
5919 !! end
5920
5921
5922 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
5923 # parser strips. The wikitext contains just the first half of the bold
5924 # quote pair.
5925 !! test
5926 Unclosed and unmatched quotes
5927 !! wikitext
5928 '''''Bold italic text '''with bold deactivated''' in between.'''''
5929
5930 '''''Bold italic text ''with italic deactivated'' in between.'''''
5931
5932 '''Bold text..
5933
5934 ..spanning two paragraphs (should not work).'''
5935
5936 '''Bold tag left open
5937
5938 ''Italic tag left open
5939
5940 Normal text.
5941
5942 <!-- Unmatching number of opening, closing tags: -->
5943 '''This year''''s election ''should'' beat '''last year''''s.
5944
5945 ''Tom'''s car is bigger than ''Susan'''s.
5946
5947 Plain ''italic'''s plain
5948 !! html/php
5949 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
5950 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
5951 </p><p><b>Bold text..</b>
5952 </p><p>..spanning two paragraphs (should not work).
5953 </p><p><b>Bold tag left open</b>
5954 </p><p><i>Italic tag left open</i>
5955 </p><p>Normal text.
5956 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
5957 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
5958 </p><p>Plain <i>italic'</i>s plain
5959 </p>
5960 !! html/parsoid
5961 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
5962 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
5963 </p><p><b>Bold text..</b>
5964 </p><p>..spanning two paragraphs (should not work).<b></b>
5965 </p><p><b>Bold tag left open</b>
5966 </p><p><i>Italic tag left open</i>
5967 </p><p>Normal text.
5968 </p>
5969 <!-- Unmatching number of opening, closing tags: -->
5970 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
5971 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
5972 </p><p>Plain <i>italic'</i>s plain
5973 </p>
5974 !! end
5975
5976 ###
5977 ### Tables
5978 ###
5979 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
5980 ###
5981
5982 # This should not produce <table></table> as <table><tr><td></td></tr></table>
5983 # is the bare minimum required by the spec, see:
5984 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
5985 # Parsoid team replies: empty table tags are legal in HTML5
5986 !! test
5987 A table with no data.
5988 !! options
5989 parsoid=wt2html
5990 !! wikitext
5991 {||}
5992 !! html/php
5993
5994 !! html/parsoid
5995 <table></table>
5996
5997 !! end
5998
5999 !! test
6000 A table with stray table end tags on start tag line (wt2html)
6001 !! options
6002 parsoid=wt2html
6003 !! wikitext
6004 {|style="color: red;"|}
6005
6006 {|style="color: red;" |}
6007 |foo
6008 |}
6009
6010 {|style="color: red;"|} id="foo"
6011 |foo
6012 |}
6013
6014 {|style="color: red;" |} id="foo"
6015 |foo
6016 |}
6017 !! html
6018 <table style="color: red;"></table>
6019
6020 <table style="color: red;">
6021 <tbody><tr>
6022 <td>foo</td>
6023 </tr></tbody>
6024 </table>
6025
6026 <table style="color: red;" id="foo">
6027 <tbody><tr>
6028 <td>foo</td>
6029 </tr></tbody>
6030 </table>
6031
6032 <table style="color: red;" id="foo">
6033 <tbody><tr>
6034 <td>foo</td>
6035 </tr></tbody>
6036 </table>
6037
6038 !! end
6039
6040 !! test
6041 A table with no data (take 2)
6042 !! wikitext
6043 {|
6044 |}
6045 !! html/parsoid
6046 <table></table>
6047 !! end
6048
6049 # A table with nothing but a caption is invalid XHTML, we might want to render
6050 # this as <p>caption</p>
6051 # Parsoid team replies: table with only a caption is legal in HTML5
6052 !! test
6053 A table with nothing but a caption
6054 !! wikitext
6055 {|
6056 |+caption
6057 |}
6058 !! html/php
6059 <table>
6060 <caption>caption
6061 </caption><tr><td></td></tr></table>
6062
6063 !! html/parsoid
6064 <table><caption>caption</caption></table>
6065 !! end
6066
6067 !! test
6068 A table with caption with default-spaced attributes and a table row
6069 !! wikitext
6070 {|
6071 |+ style="color: red;" | caption1
6072 |-
6073 |foo
6074 |}
6075 !! html
6076 <table>
6077 <caption style="color: red;">caption1
6078 </caption>
6079 <tr>
6080 <td>foo
6081 </td></tr></table>
6082
6083 !! end
6084
6085 !! test
6086 A table with captions with non-default spaced attributes and a table row
6087 !! wikitext
6088 {|
6089 |+style="color: red;"|caption2
6090 |+ style="color: red;"|caption3
6091 |-
6092 |foo
6093 |}
6094 !! html
6095 <table>
6096 <caption style="color: red;">caption2
6097 </caption>
6098 <caption style="color: red;">caption3
6099 </caption>
6100 <tr>
6101 <td>foo
6102 </td></tr></table>
6103
6104 !! end
6105
6106 !! test
6107 Table td-cell syntax variations
6108 !! wikitext
6109 {|
6110 |foo bar foo|baz
6111 |foo bar foo||baz
6112 |style='color:red;'|baz
6113 |style='color:red;'||baz
6114 |}
6115 !! html
6116 <table>
6117 <tr>
6118 <td>baz
6119 </td>
6120 <td>foo bar foo</td>
6121 <td>baz
6122 </td>
6123 <td style="color:red;">baz
6124 </td>
6125 <td>style='color:red;'</td>
6126 <td>baz
6127 </td></tr></table>
6128
6129 !! end
6130
6131 !! test
6132 Simple table
6133 !! wikitext
6134 {|
6135 |1||2
6136 |-
6137 |3||4
6138 |}
6139 !! html
6140 <table>
6141 <tr>
6142 <td>1</td>
6143 <td>2
6144 </td></tr>
6145 <tr>
6146 <td>3</td>
6147 <td>4
6148 </td></tr></table>
6149
6150 !! end
6151
6152 !! test
6153 Simple table but with multiple dashes for row wikitext
6154 !! wikitext
6155 {|
6156 |foo
6157 |-----
6158 |bar
6159 |}
6160 !! html
6161 <table>
6162 <tr>
6163 <td>foo
6164 </td></tr>
6165 <tr>
6166 <td>bar
6167 </td></tr></table>
6168
6169 !! end
6170
6171 !! test
6172 Multiplication table
6173 !! wikitext
6174 {| border="1" cellpadding="2"
6175 |+Multiplication table
6176 |-
6177 !&times;!!1!!2!!3
6178 |-
6179 !1
6180 |1||2||3
6181 |-
6182 !2
6183 |2||4||6
6184 |-
6185 !3
6186 |3||6||9
6187 |-
6188 !4
6189 |4||8||12
6190 |-
6191 !5
6192 |5||10||15
6193 |}
6194 !! html
6195 <table border="1" cellpadding="2">
6196 <caption>Multiplication table
6197 </caption>
6198 <tr>
6199 <th>&#215;</th>
6200 <th>1</th>
6201 <th>2</th>
6202 <th>3
6203 </th></tr>
6204 <tr>
6205 <th>1
6206 </th>
6207 <td>1</td>
6208 <td>2</td>
6209 <td>3
6210 </td></tr>
6211 <tr>
6212 <th>2
6213 </th>
6214 <td>2</td>
6215 <td>4</td>
6216 <td>6
6217 </td></tr>
6218 <tr>
6219 <th>3
6220 </th>
6221 <td>3</td>
6222 <td>6</td>
6223 <td>9
6224 </td></tr>
6225 <tr>
6226 <th>4
6227 </th>
6228 <td>4</td>
6229 <td>8</td>
6230 <td>12
6231 </td></tr>
6232 <tr>
6233 <th>5
6234 </th>
6235 <td>5</td>
6236 <td>10</td>
6237 <td>15
6238 </td></tr></table>
6239
6240 !! end
6241
6242 !! test
6243 Accept "||" in table headings
6244 !! wikitext
6245 {|
6246 !h1||h2
6247 |}
6248 !! html
6249 <table>
6250 <tr>
6251 <th>h1</th>
6252 <th>h2
6253 </th></tr></table>
6254
6255 !! end
6256
6257 !! test
6258 Accept "!!" in table data
6259 !! wikitext
6260 {|
6261 |Foo!!||
6262 |}
6263 !! html
6264 <table>
6265 <tr>
6266 <td>Foo!!</td>
6267 <td>
6268 </td></tr></table>
6269
6270 !! html/parsoid
6271 <table>
6272 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
6273 </tbody></table>
6274 !! end
6275
6276 !! test
6277 Accept "||" in indented table headings
6278 !! wikitext
6279 :{|
6280 !h1||h2
6281 |}
6282 !! html
6283 <dl><dd><table>
6284 <tr>
6285 <th>h1</th>
6286 <th>h2
6287 </th></tr></table></dd></dl>
6288
6289 !! end
6290
6291 !! test
6292 Accept "!!" in templates
6293 !! wikitext
6294 {|
6295 !a {{echo|b!!c}}
6296 |}
6297 !! html/php
6298 <table>
6299 <tr>
6300 <th>a b</th>
6301 <th>c
6302 </th></tr></table>
6303
6304 !! html/parsoid
6305 <table>
6306 <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>
6307 !! end
6308
6309 !! test
6310 Accept "!!" in table headings after newline
6311 !! wikitext
6312 {|
6313 !a
6314 b!!c
6315 |}
6316 !! html/php
6317 <table>
6318 <tr>
6319 <th>a
6320 <p>b!!c
6321 </p>
6322 </th></tr></table>
6323
6324 !! html/parsoid
6325 <table>
6326 <tbody><tr><th>a
6327 <p>b!!c</p></th></tr>
6328 </tbody></table>
6329 !! end
6330
6331 !! test
6332 Accept "!!" in table data of mixed wikitext / html syntax
6333 !! wikitext
6334 {|
6335 !a
6336 <tr><td>b!!c</td></tr>
6337 |}
6338 !! html/php+tidy
6339 <table>
6340 <tbody><tr>
6341 <th>a
6342 </th></tr><tr><td>b!!c</td></tr>
6343 </tbody></table>
6344 !! html/parsoid
6345 <table>
6346 <tbody><tr><th>a</th></tr>
6347 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6348 </tbody></table>
6349 !! end
6350
6351 !! test
6352 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6353 !! wikitext
6354 {|
6355 !| h1
6356 || a
6357 |}
6358 !! html
6359 <table>
6360 <tr>
6361 <th>h1
6362 </th>
6363 <td>a
6364 </td></tr></table>
6365
6366 !! end
6367
6368 !!test
6369 Accept "| !" at start of line in tables (ignore !-attribute)
6370 !! wikitext
6371 {|
6372 |-
6373 |!style="color:red"|bar
6374 |}
6375 !! html
6376 <table>
6377
6378 <tr>
6379 <td>bar
6380 </td></tr></table>
6381
6382 !!end
6383
6384 !!test
6385 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 +/-
6386 !! wikitext
6387 {|
6388 |-
6389 |style='color:red;'|+1
6390 |style='color:blue;'|-1
6391 |-
6392 |1||2||3
6393 |1||+2||-3
6394 |-
6395 | +1
6396 | -1
6397 |}
6398 !! html
6399 <table>
6400
6401 <tr>
6402 <td style="color:red;">+1
6403 </td>
6404 <td style="color:blue;">-1
6405 </td></tr>
6406 <tr>
6407 <td>1</td>
6408 <td>2</td>
6409 <td>3
6410 </td>
6411 <td>1</td>
6412 <td>+2</td>
6413 <td>-3
6414 </td></tr>
6415 <tr>
6416 <td>+1
6417 </td>
6418 <td>-1
6419 </td></tr></table>
6420
6421 !!end
6422
6423 !! test
6424 Table rowspan
6425 !! wikitext
6426 {| border=1
6427 |Cell 1, row 1
6428 |rowspan=2|Cell 2, row 1 (and 2)
6429 |Cell 3, row 1
6430 |-
6431 |Cell 1, row 2
6432 |Cell 3, row 2
6433 |}
6434 !! html
6435 <table border="1">
6436 <tr>
6437 <td>Cell 1, row 1
6438 </td>
6439 <td rowspan="2">Cell 2, row 1 (and 2)
6440 </td>
6441 <td>Cell 3, row 1
6442 </td></tr>
6443 <tr>
6444 <td>Cell 1, row 2
6445 </td>
6446 <td>Cell 3, row 2
6447 </td></tr></table>
6448
6449 !! end
6450
6451 !! test
6452 Nested table
6453 !! wikitext
6454 {| border=1
6455 | &alpha;
6456 |
6457 {| bgcolor=#ABCDEF border=2
6458 |nested
6459 |-
6460 |table
6461 |}
6462 |the original table again
6463 |}
6464 !! html
6465 <table border="1">
6466 <tr>
6467 <td>&#945;
6468 </td>
6469 <td>
6470 <table bgcolor="#ABCDEF" border="2">
6471 <tr>
6472 <td>nested
6473 </td></tr>
6474 <tr>
6475 <td>table
6476 </td></tr></table>
6477 </td>
6478 <td>the original table again
6479 </td></tr></table>
6480
6481 !! end
6482
6483 !! test
6484 Invalid attributes in table cell (T3830)
6485 !! wikitext
6486 {|
6487 |Cell:|broken
6488 |}
6489 !! html
6490 <table>
6491 <tr>
6492 <td>broken
6493 </td></tr></table>
6494
6495 !! end
6496
6497 !! test
6498 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6499 !! wikitext
6500 {|
6501 | title="foo" |bar
6502 | title="foo<nowiki>|</nowiki>" |bar
6503 | title="foo<nowiki>|</nowiki>" bar
6504 |}
6505 !! html/php
6506 <table>
6507 <tr>
6508 <td title="foo">bar
6509 </td>
6510 <td title="foo&#124;">bar
6511 </td>
6512 <td>title="foo|" bar
6513 </td></tr></table>
6514
6515 !! html/parsoid
6516 <table>
6517 <tbody><tr><td title="foo">bar</td>
6518 <td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
6519 <td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6520 </tbody></table>
6521 !! end
6522
6523 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6524 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6525 # *2wt modes will fail.
6526 !! test
6527 Table security: embedded pipes
6528 !! options
6529 parsoid=wt2html,html2html
6530 !! wikitext
6531 {|
6532 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6533 !! html/php
6534 <table>
6535 <tr>
6536 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6537 <td>]" onmouseover="alert(document.cookie)"&gt;test
6538 </td>
6539 </tr>
6540 </table>
6541
6542 !! html/parsoid
6543 <table><tbody>
6544 <tr>
6545 <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>
6546 !! end
6547
6548 !! test
6549 Element attributes with double ! should not be broken up by <th>
6550 !! wikitext
6551 {|
6552 !hi <div class="!!">ha</div> ho
6553 |}
6554 !! html/php
6555 <table>
6556 <tr>
6557 <th>hi <div class="!!">ha</div> ho
6558 </th></tr></table>
6559
6560 !! html/parsoid
6561 <table>
6562 <tbody><tr><th>hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6563 </tbody></table>
6564 !! end
6565
6566 !! test
6567 ! and || in element attributes should not be parsed as <th>/<td>
6568 !! wikitext
6569 {|
6570 |<div style="color: red !important;" data-contrived="put this here ||">hi</div>
6571 |}
6572 !! html/php
6573 <table>
6574 <tr>
6575 <td><div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
6576 </td></tr></table>
6577
6578 !! html/parsoid
6579 <table>
6580 <tbody><tr><td><div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6581 </tbody></table>
6582 !! end
6583
6584 # FIXME: The output seems broken. Filed as T110268.
6585 !! test
6586 ! and || in td attributes should not be parsed as <th>/<td>
6587 !! options
6588 parsoid=wt2html
6589 !! wikitext
6590 {|
6591 |style="color: red !important;" data-contrived="put this here ||"|foo
6592 |}
6593 !! html/php
6594 <table>
6595 <tr>
6596 <td>style="color: red !important;" data-contrived="put this here</td>
6597 <td>foo
6598 </td></tr></table>
6599
6600 !! html/parsoid
6601 <table>
6602 <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>
6603 </tbody></table>
6604 !! end
6605
6606 !! test
6607 Break on | in element attribute in template
6608 !! options
6609 parsoid=wt2html,html2html
6610 !! wikitext
6611 {{echo|1=<div class="hi|ho">ha</div>}}
6612 !! html/php
6613 <p>ho"&gt;ha&lt;/div&gt;
6614 </p>
6615 !! html/parsoid
6616 <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>
6617 !! end
6618
6619 !! test
6620 Break on | in element attribute name in template
6621 !! wikitext
6622 {{echo|<div cla|ss="hiho">ha</div>}}
6623 !! html/parsoid
6624 <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>
6625 !! end
6626
6627 !! test
6628 Don't break on | in extension attribute in template
6629 !! wikitext
6630 {{echo|<ref name="hi|ho">ha</ref>}}
6631
6632 <references />
6633 !! html/parsoid
6634 <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>
6635
6636 <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>
6637 !! end
6638
6639 ## We don't support roundtripping of these attributes in Parsoid.
6640 ## Selective serialization takes care of preventing dirty diffs.
6641 ## But, on edits, we dirty-diff the invalid attribute text.
6642 !! test
6643 Invalid text in table attributes should be discarded
6644 !! options
6645 parsoid=wt2html
6646 !! wikitext
6647 {| <span>boo</span> style='border:1px solid black'
6648 | <span>boo</span> style='color:blue' |1
6649 |<span>boo</span> style='color:blue'|2
6650 |}
6651 !! html/php
6652 <table style="border:1px solid black">
6653 <tr>
6654 <td style="color:blue">1
6655 </td>
6656 <td style="color:blue">2
6657 </td></tr></table>
6658
6659 !! html/parsoid
6660 <table style="border:1px solid black">
6661 <tr>
6662 <td style="color:blue">1</td>
6663 <td style="color:blue">2</td>
6664 </tr>
6665 </table>
6666 !! end
6667
6668 !! test
6669 Invalid text in table attributes should be preserved by selective serializer
6670 !! options
6671 parsoid={
6672 "modes": ["selser"],
6673 "changes": [
6674 ["td:first-child", "text", "abc"],
6675 ["td + td", "text", "xyz"]
6676 ]
6677 }
6678 !! wikitext
6679 {| <span>boo</span> style='border:1px solid black'
6680 | <span>boo</span> style='color:blue' | 1
6681 |<span>boo</span> style='color:blue'| 2
6682 |}
6683 !! wikitext/edited
6684 {| <span>boo</span> style='border:1px solid black'
6685 | <span>boo</span> style='color:blue' |abc
6686 |<span>boo</span> style='color:blue'|xyz
6687 |}
6688 !! end
6689
6690 !! test
6691 1. Template-generated table cell attributes and cell content
6692 !! wikitext
6693 {|
6694 |{{table_attribs}}
6695 | {{table_attribs}}
6696 || {{table_attribs_5}}
6697 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
6698 |align=center {{table_attribs}}
6699 | <!--foo--> align=center <!--bar--> {{table_attribs}}
6700 |}
6701 !! html
6702 <table>
6703 <tr>
6704 <td style="color:red;">Foo
6705 </td>
6706 <td style="color:red;">Foo
6707 </td>
6708 <td>style="color:red;"</td>
6709 <td>Bar
6710 </td>
6711 <td style="color:red;">Foo
6712 </td>
6713 <td align="center" style="color:red;">Foo
6714 </td>
6715 <td align="center" style="color:red;">Foo
6716 </td></tr></table>
6717
6718 !! end
6719
6720 !! test
6721 2. Template-generated table cell attributes and cell content
6722 !! wikitext
6723 {|
6724 |{{table_attribs_2}}
6725 |}
6726 !! html/php
6727 <table>
6728 <tr>
6729 <td style="color:red;">Foo
6730 </td>
6731 <td>Bar</td>
6732 <td>Baz
6733 </td></tr></table>
6734
6735 !! html/parsoid
6736 <table>
6737 <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>
6738 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
6739 </tbody></table>
6740 !! end
6741
6742 !! test
6743 3. Template-generated table cell attributes and cell content
6744 !! wikitext
6745 {|
6746 !align=center {{table_header_cells}}
6747 |-
6748 |align=center {{table_cells}}
6749 |}
6750 !! html/php
6751 <table>
6752 <tr>
6753 <th align="center" style="color:red;">Foo</th>
6754 <th style="color:red;"><i>Bar</i></th>
6755 <th style="color:brown;"><i>Foo</i> and Baz
6756 </th></tr>
6757 <tr>
6758 <td align="center" style="color:red;">Foo</td>
6759 <td style="color:red;"><i>Bar</i></td>
6760 <td style="color:brown;"><i>Foo</i> and Baz
6761 </td></tr></table>
6762
6763 !! html/parsoid
6764 <table>
6765 <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>
6766 <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>
6767 </tbody></table>
6768 !! end
6769
6770 !! test
6771 4. Template-generated table cell attributes and cell content inside a templated table
6772 !! wikitext
6773 {{tbl-start}}
6774 !align=center {{table_header_cells}}
6775 |-
6776 |align=center {{table_cells}}
6777 {{tbl-end}}
6778 !! html/php
6779 <table>
6780 <tr>
6781 <th align="center" style="color:red;">Foo</th>
6782 <th style="color:red;"><i>Bar</i></th>
6783 <th style="color:brown;"><i>Foo</i> and Baz
6784 </th></tr>
6785 <tr>
6786 <td align="center" style="color:red;">Foo</td>
6787 <td style="color:red;"><i>Bar</i></td>
6788 <td style="color:brown;"><i>Foo</i> and Baz
6789 </td></tr></table>
6790
6791 !! html/parsoid
6792 <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}}]}'>
6793 <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>
6794 <tr>
6795 <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>
6796 </tbody></table>
6797 !! end
6798
6799 ## Edge case fix to prevent future regressions
6800 !! test
6801 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
6802 !! wikitext
6803 {|
6804 |{{table_attribs_7}}
6805 |}
6806 <references />
6807 !! html/parsoid
6808 <table>
6809 <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>
6810 </tbody></table>
6811 <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>
6812 !! end
6813
6814 !! test
6815 Table with row followed by newlines and table heading
6816 !! options
6817 parsoid=wt2html,html2html
6818 !! wikitext
6819 {|
6820 |-
6821
6822 !foo
6823 |}
6824 !! html/*
6825 <table>
6826
6827
6828 <tr>
6829 <th>foo
6830 </th></tr></table>
6831
6832 !! end
6833
6834 !! test
6835 Table with empty line following the start tag
6836 !! options
6837 parsoid=wt2html,html2html
6838 !! wikitext
6839 {|
6840
6841 |-
6842 |foo
6843 |}
6844 !! html/*
6845 <table>
6846
6847
6848 <tr>
6849 <td>foo
6850 </td></tr></table>
6851
6852 !! end
6853
6854 !! test
6855 Table attributes with empty value
6856 !! options
6857 parsoid=wt2html,html2html
6858 !! wikitext
6859 {|
6860 | style=|hello
6861 |}
6862 !! html/php
6863 <table>
6864 <tr>
6865 <td style="">hello
6866 </td></tr></table>
6867
6868 !! html/parsoid
6869 <table>
6870 <tbody><tr><td style="">hello</td></tr>
6871 </tbody></table>
6872 !! end
6873
6874 !! test
6875 Wikitext table with a lot of comments
6876 !! wikitext
6877 {|
6878 <!-- c0 -->
6879 |foo
6880 <!-- c1 -->
6881 |-<!-- c2 -->
6882 <!-- c3 -->
6883 |<!-- c4 -->
6884 <!-- c5 -->
6885 |}
6886 !! html
6887 <table>
6888 <tr>
6889 <td>foo
6890 </td></tr>
6891 <tr>
6892 <td>
6893 </td></tr></table>
6894
6895 !! end
6896
6897 !! test
6898 Wikitext table comments represented in parsoid dom
6899 !! wikitext
6900 {|<!--c1--><!--c2-->
6901 |-<!--c3-->
6902 |x
6903 |}
6904 !! html/php+tidy
6905 <table>
6906
6907 <tbody><tr>
6908 <td>x
6909 </td></tr></tbody></table>
6910 !! html/parsoid
6911 <table><!--c1--><!--c2-->
6912 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
6913 <td data-parsoid='{"autoInsertedEnd":true}'>x</td></tr>
6914 </tbody></table>
6915 !! end
6916
6917 !! test
6918 Wikitext table with double-line table cell
6919 !! wikitext
6920 {|
6921 |a
6922 b
6923 |}
6924 !! html
6925 <table>
6926 <tr>
6927 <td>a
6928 <p>b
6929 </p>
6930 </td></tr></table>
6931
6932 !! end
6933
6934 !! test
6935 Table cell with a single comment
6936 !! wikitext
6937 {|
6938 | <!-- c1 -->
6939 |a
6940 |}
6941 !! html
6942 <table>
6943 <tr>
6944 <td>
6945 </td>
6946 <td>a
6947 </td></tr></table>
6948
6949 !! end
6950
6951 !! test
6952 Table-cell after a comment-only-empty-line
6953 !! wikitext
6954 {|
6955 |a
6956 <!--c1-->
6957 <!--c2-->|b
6958 |}
6959 !! html
6960 <table>
6961 <tr>
6962 <td>a
6963 </td>
6964 <td>b
6965 </td></tr></table>
6966
6967 !! html/parsoid
6968 <table>
6969 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
6970 <!--c1-->
6971 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'>b</td></tr>
6972 </tbody></table>
6973
6974 !! end
6975
6976 !! test
6977 Build table with {{!}}
6978 !! wikitext
6979 {{{!}} class="wikitable"
6980 !header
6981 !second header
6982 {{!}}- style="color:red;"
6983 {{!}}data{{!}}{{!}} style="color:red;" {{!}}second data
6984 {{!}}}
6985 !! html
6986 <table class="wikitable">
6987 <tr>
6988 <th>header
6989 </th>
6990 <th>second header
6991 </th></tr>
6992 <tr style="color:red;">
6993 <td>data</td>
6994 <td style="color:red;">second data
6995 </td></tr></table>
6996
6997 !! end
6998
6999 !! test
7000 Build table with pipe as data
7001 !! wikitext
7002 {| class="wikitable"
7003 !header
7004 !second header
7005 |- style="color:red;"
7006 |data|| style="color:red;" |second data
7007 |-
7008 | style="color:red;" |data with | || style="color:red;" | second data with |
7009 |-
7010 ||data with | |||second data with |
7011 |}
7012 !! html
7013 <table class="wikitable">
7014 <tr>
7015 <th>header
7016 </th>
7017 <th>second header
7018 </th></tr>
7019 <tr style="color:red;">
7020 <td>data</td>
7021 <td style="color:red;">second data
7022 </td></tr>
7023 <tr>
7024 <td style="color:red;">data with |</td>
7025 <td style="color:red;">second data with |
7026 </td></tr>
7027 <tr>
7028 <td>data with |</td>
7029 <td>second data with |
7030 </td></tr></table>
7031
7032 !! end
7033
7034 !! test
7035 Build table with wikilink
7036 !! wikitext
7037 {| class="wikitable"
7038 !header||second header
7039 |- style="color:red;"
7040 |data [[Main Page|linktext]]||second data [[Main Page|linktext]]
7041 |-
7042 |data||second data [[Main Page|link|text with pipe]]
7043 |}
7044 !! html
7045 <table class="wikitable">
7046 <tr>
7047 <th>header</th>
7048 <th>second header
7049 </th></tr>
7050 <tr style="color:red;">
7051 <td>data <a href="/wiki/Main_Page" title="Main Page">linktext</a></td>
7052 <td>second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
7053 </td></tr>
7054 <tr>
7055 <td>data</td>
7056 <td>second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
7057 </td></tr></table>
7058
7059 !! end
7060
7061 # The expected HTML structure in this test is debatable. The PHP parser does
7062 # not parse this kind of table at all. The main focus for Parsoid is on
7063 # round-tripping, so this output is ok for now. TODO: revisit!
7064 !! test
7065 Wikitext table with html-syntax row
7066 !! wikitext
7067 {|
7068 |-
7069 <td>foo</td>
7070 |}
7071 !! html/parsoid
7072 <table>
7073 <tbody>
7074 <tr>
7075 <td>foo</td></tr></tbody></table>
7076 !! end
7077
7078 !! test
7079 Fostered content in tables: Plain text
7080 !! options
7081 parsoid=wt2html,html2html
7082 !! wikitext
7083 {|
7084 |-
7085 a
7086 |}
7087 !! html/php
7088 <table>
7089
7090 a
7091 </table>
7092
7093 !! html/php+tidy
7094
7095
7096 a
7097 <table></table>
7098 !! html/parsoid
7099 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>a</p><table>
7100 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7101
7102 </tr></tbody></table>
7103 !! end
7104
7105 !! test
7106 Fostered content in tables: Lists
7107 !! options
7108 parsoid=wt2html,html2html
7109 !! wikitext
7110 {|
7111 |-
7112 *a
7113 |}
7114 !! html/php
7115 <table>
7116
7117 <ul><li>a</li></ul>
7118 </table>
7119
7120 !! html/php+tidy
7121 <ul><li>a</li></ul><table>
7122
7123
7124 </table>
7125 !! html/parsoid
7126 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7127 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7128
7129 </tr></tbody></table>
7130 !! end
7131
7132 !! test
7133 Template generated table cell with attributes
7134 !! wikitext
7135 {|
7136 |-
7137 {{table_attribs_4}} ||a||b
7138 |}
7139 !! html/php+tidy
7140 <table>
7141
7142 <tbody><tr>
7143 <td style="background-color:#DC241f;" width="10px"></td>
7144 <td>a</td>
7145 <td>b
7146 </td></tr></tbody></table>
7147 !! html/parsoid
7148 <table>
7149 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7150 <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>
7151 !! end
7152
7153 !! test
7154 Parsoid: Round-trip tables directly followed by content (T53219)
7155 !! options
7156 parsoid=wt2html,wt2wt
7157 !! wikitext
7158 {|
7159 |foo
7160 |} bar
7161
7162 {|
7163 |baz
7164 |}<b>quux</b>
7165 !! html+tidy
7166 <table>
7167 <tbody><tr>
7168 <td>foo
7169 </td></tr></tbody></table><p> bar
7170 </p><table>
7171 <tbody><tr>
7172 <td>baz
7173 </td></tr></tbody></table><p><b>quux</b>
7174 </p>
7175 !! end
7176
7177 !! test
7178 Parsoid: Default to a newline after tables in new content (T53219)
7179 !! options
7180 parsoid=html2wt
7181 !! html/parsoid
7182 <table><tbody>
7183 <tr><td>foo</td></tr></tbody></table> bar
7184 <table><tbody>
7185 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7186 !! wikitext
7187 {|
7188 |foo
7189 |}
7190 <nowiki> </nowiki>bar
7191 {|
7192 |baz
7193 |}
7194 '''quux'''
7195 !! end
7196
7197 !! test
7198 Parsoid: newline inducing block nodes don't suppress <nowiki>
7199 !! options
7200 parsoid=html2wt
7201 !! html/parsoid
7202 a<h1>foo</h1>
7203 !! wikitext
7204 <nowiki> </nowiki>a
7205
7206 = foo =
7207 !! end
7208
7209 !! test
7210 Parsoid: Row-syntax table headings followed by comment & table cells
7211 !! options
7212 parsoid=wt2html,wt2wt
7213 !! wikitext
7214 {|
7215 !foo||bar
7216 <!-- foo --> ||baz||quux
7217 |}
7218 !! html/php
7219 <table>
7220 <tr>
7221 <th>foo</th>
7222 <th>bar
7223 </th>
7224 <td>baz</td>
7225 <td>quux
7226 </td></tr></table>
7227
7228 !! html/parsoid
7229 <table>
7230 <tbody><tr><th> foo </th><th> bar
7231 <!-- foo --> </th><td> baz </td><td> quux</td></tr>
7232 </tbody></table>
7233 !! end
7234
7235 !!test
7236 Parsoid: Recover better from broken table attributes
7237 !!options
7238 parsoid=wt2html
7239 !!wikitext
7240 {| class="foo
7241 | class="bar" |
7242 foo
7243 |}
7244 !!html/php+tidy
7245 <table class="foo">
7246 <tbody><tr>
7247 <td class="bar">
7248 <p>foo
7249 </p>
7250 </td></tr></tbody></table>
7251 !!html/parsoid
7252 <table class="foo">
7253 <tr>
7254 <td class="bar">
7255 <p>foo</p></td></tr>
7256 </tbody></table>
7257 !!end
7258
7259 !! test
7260 Tables: Digest broken attributes on table and tr tag
7261 !! options
7262 parsoid=wt2html
7263 !! wikitext
7264 {| || |} ++
7265 |- || || ++ --
7266 |- > [
7267 |}
7268 !! html
7269 <table>
7270 <tbody>
7271 <tr class='mw-empty-elt'></tr>
7272 <tr class='mw-empty-elt'></tr>
7273 </tbody></table>
7274 !! end
7275
7276 # T137406: Whitespace in the HTML
7277 !! test
7278 1. Generate correct wikitext for tables with thead/tbody/tfoot
7279 !! options
7280 parsoid=html2wt
7281 !! html/parsoid
7282 <table>
7283 <caption>Test</caption>
7284 <thead>
7285 <tr>
7286 <th>Month</th>
7287 <th>Savings</th>
7288 </tr>
7289 </thead>
7290 <tbody>
7291 <tr>
7292 <td>January</td>
7293 <td>$100</td>
7294 </tr>
7295 <tr>
7296 <td>February</td>
7297 <td>$80</td>
7298 </tr>
7299 </tbody>
7300 <tfoot>
7301 <tr>
7302 <td>Sum</td>
7303 <td>$180</td>
7304 </tr>
7305 </tfoot>
7306 </table>
7307 !! wikitext
7308 {|
7309 |+Test
7310 !Month
7311 !Savings
7312 |-
7313 |January
7314 |$100
7315 |-
7316 |February
7317 |$80
7318 |-
7319 |Sum
7320 |$180
7321 |}
7322 !! html/php+tidy
7323 <table>
7324 <caption>Test
7325 </caption>
7326 <tbody><tr>
7327 <th>Month
7328 </th>
7329 <th>Savings
7330 </th></tr>
7331 <tr>
7332 <td>January
7333 </td>
7334 <td>$100
7335 </td></tr>
7336 <tr>
7337 <td>February
7338 </td>
7339 <td>$80
7340 </td></tr>
7341 <tr>
7342 <td>Sum
7343 </td>
7344 <td>$180
7345 </td></tr></tbody></table>
7346 !! end
7347
7348 # T137406: No whitespace in the HTML
7349 !! test
7350 2. Generate correct wikitext for tables with thead/tbody/tfoot
7351 !! options
7352 parsoid=html2wt
7353 !! html/parsoid
7354 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7355 !! wikitext
7356 {|
7357 !heading
7358 |-
7359 |foo
7360 |}
7361 !! end
7362
7363 !! test
7364 Testing serialization after deletion in references
7365 !! options
7366 parsoid={
7367 "modes": ["wt2wt"],
7368 "changes": [
7369 ["#x", "remove"]
7370 ]
7371 }
7372 !! wikitext
7373 hi <ref><div id="x">ho</div></ref>
7374
7375 <references />
7376 !! wikitext/edited
7377 hi <ref></ref>
7378
7379 <references />
7380 !! end
7381
7382 !!test
7383 Testing serialization after deletion of table cells
7384 !!options
7385 parsoid={
7386 "modes": ["wt2wt", "selser"],
7387 "changes": [
7388 ["#x", "remove"]
7389 ]
7390 }
7391 !!wikitext
7392 {|
7393 !h1 !!h2 !!h3
7394 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
7395 |}
7396 !! wikitext/edited
7397 {|
7398 !h1 !!h2 !!h3
7399 |c2 |||c3
7400 |}
7401 !!end
7402
7403 !! test
7404 Testing selser after addition of new row before first row (T125419)
7405 !! options
7406 parsoid={
7407 "modes": ["wt2wt", "selser"],
7408 "changes": [
7409 [ "tr", "before", "<tr><td>X</td></tr>" ]
7410 ]
7411 }
7412 !! wikitext
7413 {|
7414 |a
7415 |}
7416 !! wikitext/edited
7417 {|
7418 |X
7419 |-
7420 |a
7421 |}
7422 !! end
7423
7424 !! test
7425 Serialize new table rows in a HTML table using HTML tags
7426 !! options
7427 parsoid={
7428 "modes": ["wt2wt", "selser"],
7429 "changes": [
7430 [ "tr", "before", "<tr><td>X</td></tr>" ]
7431 ]
7432 }
7433 !! wikitext
7434 <table><tr><td>a</td></tr></table>
7435 !! wikitext/edited
7436 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
7437 !! end
7438
7439 !! test
7440 Serialize new table cells in a HTML row using HTML tags
7441 !! options
7442 parsoid={
7443 "modes": ["wt2wt", "selser"],
7444 "changes": [
7445 [ "td", "before", "<td>X</td>" ]
7446 ]
7447 }
7448 !! wikitext
7449 <table><tr><td>a</td></tr></table>
7450 !! wikitext/edited
7451 <table><tr><td>X</td><td>a</td></tr></table>
7452 !! end
7453
7454 !! test
7455 Wikitext tables can be nested inside HTML tables
7456 !! options
7457 parsoid=html2wt
7458 !! html
7459 <table data-parsoid='{"stx":"html"}'>
7460 <tr><td>
7461 <table>
7462 <tr><td>foo</td></tr>
7463 </table>
7464 </td></tr>
7465 </table>
7466 !! wikitext
7467 <table>
7468 <tr><td>
7469 {|
7470 |foo
7471 |}
7472 </td></tr>
7473 </table>
7474 !! end
7475
7476 !! test
7477 Serialize wikitext list items as HTML list items when embedded in a HTML list
7478 !! options
7479 parsoid=html2wt
7480 !! html
7481 <ul data-parsoid='{"stx": "html"}'>
7482 <li data-parsoid='{}'>a</li>
7483 <li>b</li>
7484 </ul>
7485 !! wikitext
7486 <ul>
7487 <li>a</li>
7488 <li>b</li>
7489 </ul>
7490 !! end
7491
7492 # SSS FIXME: Is this actually a good thing given the
7493 # odd nested list output that is generated by MW?
7494 # <ul><li>foo<ul>..</ul></li></ul> instead of
7495 # <ul><li>foo</li><ul>..</ul></ul>
7496 !! test
7497 Wikitext lists can be nested inside HTML lists
7498 !! options
7499 parsoid=html2wt
7500 !! html
7501 <ul data-parsoid='{"stx": "html"}'>
7502 <li data-parsoid='{"stx": "html"}'>a
7503 <ul><li>b</li></ul>
7504 </li>
7505 </ul>
7506
7507 <ul data-parsoid='{"stx": "html"}'>
7508 <li>x
7509 <ul><li>y</li></ul>
7510 </li>
7511 </ul>
7512 !! wikitext
7513 <ul>
7514 <li>a
7515 * b
7516 </li>
7517 </ul>
7518
7519 <ul>
7520 <li>x
7521 * y
7522 </li>
7523 </ul>
7524 !! end
7525
7526 ###
7527 ### Internal links
7528 ###
7529 !! test
7530 Plain link, capitalized
7531 !! wikitext
7532 [[Main Page]]
7533 !! html
7534 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7535 </p>
7536 !! end
7537
7538 !! test
7539 Plain link, uncapitalized
7540 !! wikitext
7541 [[main Page]]
7542 !! html
7543 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7544 </p>
7545 !! end
7546
7547 !! test
7548 Piped link
7549 !! wikitext
7550 [[Main Page|The Main Page]]
7551 !! html
7552 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7553 </p>
7554 !! end
7555
7556 !! test
7557 Piped link with comment in link text
7558 !! wikitext
7559 [[Main Page|The Main<!--front--> Page]]
7560 !! html
7561 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7562 </p>
7563 !! end
7564
7565 !! test
7566 Piped link with multiple pipe characters in link text
7567 !! wikitext
7568 [[Main Page||The|Main|Page|]]
7569 !! html/php
7570 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7571 </p>
7572 !! html/parsoid
7573 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7574 !! end
7575
7576 !! test
7577 Piped link with no link text
7578 !! wikitext
7579 [[Thomas Bek (bishop of St David's)|]]
7580 !! html/php
7581 <p>[[Thomas Bek (bishop of St David's)|]]
7582 </p>
7583 !! html/parsoid
7584 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7585 !! end
7586
7587 !! test
7588 Piped link with empty link text
7589 !! wikitext
7590 [[Main Page|<nowiki/>]] - empty nowiki
7591 [[Main Page| ]] - empty space
7592 [[Main Page|&nbsp;]] - empty non breaking space
7593 !! html/php
7594 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7595 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7596 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7597 </p>
7598 !! html/parsoid
7599 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7600 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7601 <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>
7602 !! end
7603
7604 !! test
7605 Broken link
7606 !! wikitext
7607 [[Zigzagzogzagzig]]
7608 !! html
7609 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7610 </p>
7611 !! end
7612
7613 !! test
7614 Broken link with fragment
7615 !! wikitext
7616 [[Zigzagzogzagzig#zug]]
7617 !! html
7618 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7619 </p>
7620 !! end
7621
7622 !! test
7623 Special page link with fragment
7624 !! wikitext
7625 [[Special:Version#anchor]]
7626 !! html
7627 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7628 </p>
7629 !! end
7630
7631 !! test
7632 Nonexistent special page link with fragment
7633 !! wikitext
7634 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7635 !! html
7636 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7637 </p>
7638 !! end
7639
7640 !! test
7641 Link with prefix
7642 !! wikitext
7643 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7644 !! html
7645 <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>
7646 </p>
7647 !! end
7648
7649 !! test
7650 Link with suffix
7651 !! wikitext
7652 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7653 !! html
7654 <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>!!!
7655 </p>
7656 !! end
7657
7658 !! article
7659 prefixed article
7660 !! text
7661 Some text
7662 !! endarticle
7663
7664 !! test
7665 T45661: Piped links with identical prefixes
7666 !! wikitext
7667 [[prefixed article|prefixed articles with spaces]]
7668
7669 [[prefixed article|prefixed articlesaoeu]]
7670
7671 [[Main Page|Main Page test]]
7672 !! html
7673 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7674 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7675 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7676 </p>
7677 !! end
7678
7679
7680 !! test
7681 Link with HTML entity in suffix / tail
7682 !! wikitext
7683 [[Main Page]]&quot;, [[Main Page]]&#97;
7684 !! html/php
7685 <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;
7686 </p>
7687 !! html/parsoid
7688 <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>
7689 !! end
7690
7691 !! test
7692 Link with 3 brackets
7693 !! wikitext
7694 [[[Main Page]]]
7695 Foo [[[Main Page]]]
7696 !! html
7697 <p>[[[Main Page]]]
7698 Foo [[[Main Page]]]
7699 </p>
7700 !! end
7701
7702 !! test
7703 Link with 4 brackets
7704 !! wikitext
7705 [[[[Main Page]]]]
7706 !! html
7707 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7708 </p>
7709 !! end
7710
7711 !! test
7712 Piped link with 3 brackets
7713 !! wikitext
7714 [[[main page|the main page]]]
7715 !! html
7716 <p>[[[main page|the main page]]]
7717 </p>
7718 !! end
7719
7720 !! test
7721 Piped link with extlink-like text
7722 !! wikitext
7723 [[Main Page|[bar]]]
7724 [[Main Page|This is a [bar]]]
7725 [[Main Page|[bar]]
7726 !! html/php
7727 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7728 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7729 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7730 </p>
7731 !! html/parsoid
7732 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7733 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7734 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7735 !! end
7736
7737 !! test
7738 Link with multiple pipes
7739 !! wikitext
7740 [[Main Page|The|Main|Page]]
7741 !! html
7742 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7743 </p>
7744 !! end
7745
7746 !! test
7747 Anchor containing a #. (T65430)
7748 !! config
7749 wgFragmentMode=[ 'html5', 'legacy' ]
7750 !! wikitext
7751 [[Main Page#And#Link]]
7752 !! html/php
7753 <p><a href="/wiki/Main_Page#And#Link" title="Main Page">Main Page#And#Link</a>
7754 </p>
7755 !! html/parsoid
7756 <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>
7757 !! end
7758
7759 !! test
7760 Link to namespaces
7761 !! wikitext
7762 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7763 !! html
7764 <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>
7765 </p>
7766 !! end
7767
7768 !! test
7769 Link with space in namespace
7770 !! wikitext
7771 [[User talk:Foo bar]]
7772 !! html
7773 <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>
7774 </p>
7775 !! end
7776
7777 !! article
7778 MemoryAlpha:AlphaTest
7779 !! text
7780 This is an article in the MemoryAlpha namespace
7781 (which shadows the memoryalpha interwiki link).
7782 !! endarticle
7783
7784 !! test
7785 Namespace takes precedence over interwiki link (T53680)
7786 !! wikitext
7787 [[MemoryAlpha:AlphaTest]]
7788 !! html
7789 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7790 </p>
7791 !! end
7792
7793 # The previous test doesn't work correctly in html2*, due to not recognizing the
7794 # link as an internal one. This one checks for the correct behavior.
7795 !! test
7796 Link to namespace preferred over interwiki with correct rel attribute
7797 !! options
7798 parsoid=html2wt,html2html
7799 !! html/parsoid
7800 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7801 !! wikitext
7802 [[MemoryAlpha:AlphaTest]]
7803 !! end
7804
7805 !! test
7806 Piped link to namespace
7807 !! wikitext
7808 [[Meta:Disclaimers|The disclaimers]]
7809 !! html
7810 <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>
7811 </p>
7812 !! end
7813
7814 !! test
7815 Link containing }
7816 !! wikitext
7817 [[Usually caused by a typo (oops}]]
7818 !! html
7819 <p>[[Usually caused by a typo (oops}]]
7820 </p>
7821 !! end
7822
7823 !! article
7824 7% Solution
7825 !! text
7826 Just a test of an article title containing a percent.
7827 !! endarticle
7828
7829 !! test
7830 Link containing % (not as a hex sequence)
7831 !! wikitext
7832 [[7% Solution]]
7833 [[7% Solution|7%25 Solution]]
7834 !! html/php
7835 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7836 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7837 </p>
7838 !! html/parsoid
7839 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7840 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7841 !! end
7842
7843 # note that the parsoid HTML is identical to the previous test output,
7844 # so the previous test ensures that the html2wt mode will generate the
7845 # "not as a hex sequence" wikitext.
7846 !! test
7847 Link containing % as a single hex sequence interpreted to char
7848 !! options
7849 parsoid=wt2wt,wt2html,html2html
7850 !! wikitext
7851 [[7%25 Solution]]
7852 [[7%25 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 !! test
7863 Link containing % as a double hex sequence interpreted to hex sequence
7864 !! wikitext
7865 [[7%2525 Solution]]
7866 !! html
7867 <p>[[7%2525 Solution]]
7868 </p>
7869 !!end
7870
7871 ## Example for such a section: == < ==
7872 !! test
7873 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
7874 !! config
7875 wgFragmentMode=[ 'html5', 'legacy' ]
7876 !! wikitext
7877 [[%23%3c]][[%23%3e]]
7878 !! html/php
7879 <p><a href="#&lt;">#&lt;</a><a href="#&gt;">#&gt;</a>
7880 </p>
7881 !! html/parsoid
7882 <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>
7883 !! end
7884
7885 ## Example for such a section: == < ==
7886 !! test
7887 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy)
7888 !! config
7889 wgFragmentMode=[ 'legacy' ]
7890 !! wikitext
7891 [[%23%3c]][[%23%3e]]
7892 !! html/php
7893 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
7894 </p>
7895 !! end
7896
7897 !! test
7898 Link containing "<#" and ">#" as a hex sequences
7899 !! wikitext
7900 [[%3c%23]][[%3e%23]]
7901 !! html
7902 <p>[[%3c%23]][[%3e%23]]
7903 </p>
7904 !! end
7905
7906 !! test
7907 Link containing an equals sign
7908 !! wikitext
7909 [[Special:BookSources/isbn=4-00-026157-6]]
7910 !! html/php
7911 <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>
7912 </p>
7913 !! html/parsoid
7914 <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>
7915 !! end
7916
7917 !! article
7918 Foo~bar
7919 !! text
7920 Just a test of an article title containing a tilde.
7921 !! endarticle
7922
7923 # note that links containing signatures, like [[Foo~~~~]], are
7924 # massaged by the pre-save transform (PST) and so the tildes are never
7925 # seen by the parser.
7926 !! test
7927 Link containing a tilde
7928 !! wikitext
7929 [[Foo~bar]]
7930 !! html/php
7931 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
7932 </p>
7933 !! html/parsoid
7934 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
7935 !! end
7936
7937 !! test
7938 Link containing double-single-quotes '' (T6598)
7939 !! wikitext
7940 [[Lista d''e paise d''o munno]]
7941 !! html/php
7942 <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>
7943 </p>
7944 !! html/parsoid
7945 <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>
7946 !! end
7947
7948 !! test
7949 Link containing double quotes and spaces
7950 !! wikitext
7951 [[Cool "Gator"]]
7952 !! html/php
7953 <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>
7954 </p>
7955 !! html/parsoid
7956 <p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p>
7957 !! end
7958
7959 !! test
7960 File containing double quotes and spaces
7961 !! wikitext
7962 [[File:Cool "Gator".png]]
7963 !! html/parsoid
7964 <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>
7965 !! end
7966
7967 !! test
7968 Redirect containing double quotes and spaces
7969 !! wikitext
7970 #REDIRECT [[Cool "Gator"]]
7971 !! html/parsoid
7972 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
7973 !! end
7974
7975 !! test
7976 Link containing double-single-quotes '' in text (T6598 sanity check)
7977 !! wikitext
7978 Some [[Link|pretty ''italics'' and stuff]]!
7979 !! html/php
7980 <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>!
7981 </p>
7982 !! html/parsoid
7983 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
7984 !! end
7985
7986 !! test
7987 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
7988 !! wikitext
7989 ''Some [[Link|pretty ''italics'' and stuff]]!''
7990 !! html
7991 <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>
7992 </p>
7993 !! end
7994
7995 !! test
7996 Link with double quotes in title part (literal) and alternate part (interpreted)
7997 !! wikitext
7998 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
7999
8000 [[''Pentecoste'']]
8001
8002 [[''Pentecoste''|Pentecoste]]
8003
8004 [[''Pentecoste''|''Pentecoste'']]
8005 !! html/php
8006 <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>
8007 </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>
8008 </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>
8009 </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>
8010 </p>
8011 !! html/parsoid
8012 <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>
8013 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
8014 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
8015 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
8016 !! end
8017
8018 !! test
8019 Broken image links with HTML captions (T41700)
8020 !! wikitext
8021 [[File:Nonexistent|<script></script>]]
8022 [[File:Nonexistent|100x100px|<script></script>]]
8023 [[File:Nonexistent|&lt;]]
8024 [[File:Nonexistent|a<i>b</i>c]]
8025 !! html/php
8026 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8027 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8028 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8029 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8030 </p>
8031 !! html/parsoid
8032 <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>
8033 <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>
8034 <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>
8035 <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>
8036 !! end
8037
8038 !! test
8039 Plain link to URL
8040 !! wikitext
8041 [[http://www.example.com]]
8042 !! html/php
8043 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8044 </p>
8045 !! html/parsoid
8046 <p>[<a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com"></a>]</p>
8047 !! end
8048
8049 !! test
8050 Plain link to URL with link text
8051 !! wikitext
8052 [[http://www.example.com Link text]]
8053 !! html
8054 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8055 </p>
8056 !! end
8057
8058 !! test
8059 Plain link to protocol-relative URL
8060 !! wikitext
8061 [[//www.example.com]]
8062 !! html/php
8063 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8064 </p>
8065 !! html/parsoid
8066 <p>[<a rel="mw:ExtLink" class="external autonumber" href="//www.example.com"></a>]</p>
8067 !! end
8068
8069 !! test
8070 Plain link to protocol-relative URL with link text
8071 !! wikitext
8072 [[//www.example.com Link text]]
8073 !! html
8074 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8075 </p>
8076 !! end
8077
8078 !! test
8079 Plain link to page with question mark in title
8080 !! wikitext
8081 [[A?b]]
8082
8083 [[A?b|Baz]]
8084 !! html
8085 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8086 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8087 </p>
8088 !! end
8089
8090 # I'm fairly sure the expected result here is wrong.
8091 # We want these to be URL links, not pseudo-pages with URLs for titles....
8092 # However the current output is also pretty screwy.
8093 #
8094 # ----
8095 # I'm changing it to match the current output--it arguably makes more
8096 # sense in the light of the test above. Old expected result was:
8097 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8098 #</p>
8099 # But I think this test is bordering on "garbage in, garbage out" anyway.
8100 # -- wtm
8101 !! test
8102 Piped link to URL
8103 !! wikitext
8104 Piped link to URL: [[http://www.example.com|an example URL]]
8105 !! html/php
8106 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8107 </p>
8108 !! html/parsoid
8109 <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>
8110 !! end
8111
8112 !! test
8113 Plain link in template argument
8114 !! options
8115 parsoid=wt2html
8116 !! wikitext
8117 {{echo|[http://www.example.com |123]}}
8118
8119 {{echo|[[http://www.example.com |123]]}}
8120
8121 {{echo|[[http://www.example.com |123]}}
8122
8123 {{echo|[http://www.example.com |123]]}}
8124 !! html/php
8125 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8126 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8127 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8128 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8129 </p>
8130 !! html/parsoid
8131 <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>
8132
8133 <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>
8134
8135 <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>
8136
8137 <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>
8138 !! end
8139
8140 !! test
8141 T2002: [[page|http://url/]] should link to page, not http://url/
8142 !! wikitext
8143 [[Main Page|http://url/]]
8144 !! html/php
8145 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8146 </p>
8147 !! html/parsoid
8148 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8149 !! end
8150
8151 # Parsoid does not mark self-links, by design.
8152 !! test
8153 T2337: Escaped self-links should be bold
8154 !! options
8155 title=[[Bug462]]
8156 !! wikitext
8157 [[Bu&#103;462]] [[Bug462]]
8158 !! html/php+tidy
8159 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8160 </p>
8161 !! html/parsoid
8162 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8163 !! end
8164
8165 !! test
8166 Self-link to section should not be bold
8167 !! options
8168 title=[[Main Page]]
8169 !! wikitext
8170 [[Main Page#section]]
8171 !! html
8172 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8173 </p>
8174 !! end
8175
8176 !! article
8177 00
8178 !! text
8179 This is 00.
8180 !! endarticle
8181
8182 !!test
8183 Self-link to numeric title
8184 !!options
8185 title=[[0]]
8186 !! wikitext
8187 [[0]]
8188 !! html
8189 <p><a class="mw-selflink selflink">0</a>
8190 </p>
8191 !!end
8192
8193 !!test
8194 Link to numeric-equivalent title
8195 !!options
8196 title=[[0]]
8197 !! wikitext
8198 [[00]]
8199 !! html
8200 <p><a href="/wiki/00" title="00">00</a>
8201 </p>
8202 !!end
8203
8204 !! test
8205 <nowiki> inside a link
8206 !! wikitext
8207 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8208 !! html
8209 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8210 </p>
8211 !! end
8212
8213 !! test
8214 Non-breaking spaces in title
8215 !! wikitext
8216 [[&nbsp; Main &nbsp; Page &nbsp;]]
8217 !! html
8218 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8219 </p>
8220 !!end
8221
8222 # Add new article for the test below so that it doesn't red-link
8223 !! article
8224 Foo bar baz
8225 !! text
8226 boo
8227 !! endarticle
8228
8229 !! test
8230 Multiple spaces in titles should normalize to a single underscore
8231 !! options
8232 parsoid=wt2html,wt2wt
8233 !! wikitext
8234 [[Foo bar baz|x]]
8235 [[Foo bar baz|x]]
8236 [[Foo bar baz|x]]
8237 !! html/php
8238 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8239 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8240 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8241 </p>
8242 !! html/parsoid
8243 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8244 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8245 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8246 </p>
8247 !! end
8248
8249 !! test
8250 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8251 !! options
8252 language=ca
8253 !! wikitext
8254 '''[[Main Page]]'''
8255 !! html
8256 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8257 </p>
8258 !! end
8259
8260 !! test
8261 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8262 !! options
8263 language=ca
8264 !! wikitext
8265 ''[[Main Page]]''
8266 !! html
8267 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8268 </p>
8269 !! end
8270
8271 !! test
8272 Internal link with en linktrail: no apostrophes (T29473)
8273 !! options
8274 language=en
8275 !! wikitext
8276 [[Something]]'nice
8277 !! html
8278 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8279 </p>
8280 !! end
8281
8282 !! test
8283 Internal link with ca linktrail with apostrophes (T29473)
8284 !! options
8285 language=ca
8286 !! wikitext
8287 [[Something]]'nice
8288 !! html
8289 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8290 </p>
8291 !! end
8292
8293 !! test
8294 Internal link with kaa linktrail with apostrophes (T29473)
8295 !! options
8296 language=kaa
8297 !! wikitext
8298 [[Something]]'nice
8299 !! html
8300 <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>
8301 </p>
8302 !! end
8303
8304 !! test
8305 Link with multiple ":" in a subpage-supporting namespace (T65636)
8306 !! wikitext
8307 [[User:Foo/Test/63636:Bar|Test]]
8308 !! html/php
8309 <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>
8310 </p>
8311 !! html/parsoid
8312 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8313 !! end
8314
8315 ## Mainly a sanity check for Parsoid
8316 !! test
8317 Handle title parsing for subpages
8318 !! options
8319 title=[[/123123]]
8320 subpage
8321 !! wikitext
8322 123
8323 !! html/php
8324 <p>123
8325 </p>
8326 !! html/parsoid
8327 <p>123</p>
8328 !! end
8329
8330 !! article
8331 User:Test/123
8332 !! text
8333 test 123
8334 !! endarticle
8335
8336 !! test
8337 Link to a subpage from a namespace other than main
8338 !! options
8339 title=[[User:Test]]
8340 subpage
8341 !! wikitext
8342 [[/123]]
8343 !! html/php
8344 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8345 </p>
8346 !! html/parsoid
8347 <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>
8348 !! end
8349
8350 !! test
8351 Ensure that transclusion titles are not url-decoded
8352 !! options
8353 subpage title=[[Test]]
8354 parsoid=wt2html
8355 !! wikitext
8356 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8357 !! html/php
8358 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8359 </p>
8360 !! html/parsoid
8361 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8362 !! end
8363
8364 !! test
8365 Purely hash wikilink
8366 !! options
8367 title=[[User:Test/123]]
8368 subpage
8369 !! wikitext
8370 [[#a|b]]
8371 !! html/php
8372 <p><a href="#a">b</a>
8373 </p>
8374 !! html/parsoid
8375 <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>
8376 !! end
8377
8378 !! test
8379 Serialization of purely hash wikilink
8380 !! options
8381 title=[[User:Test/123]]
8382 subpage
8383 parsoid=html2wt
8384 !! html/parsoid
8385 <p><a href="#a">[[</a></p>
8386 !! wikitext
8387 [[#a|<nowiki>[[</nowiki>]]
8388 !! html/php
8389 <p><a href="#a">[[</a>
8390 </p>
8391 !! end
8392
8393 !! test
8394 1. Interaction of linktrail and template encapsulation
8395 !! wikitext
8396 {{echo|[[Foo]]}}l
8397 !! html/parsoid
8398 <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>
8399 !! end
8400
8401 !! test
8402 2. Interaction of linktrail and template encapsulation
8403 !! options
8404 parsoid
8405 !! wikitext
8406 {{echo|Some [[Fool]]}}s
8407 !! html
8408 <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>
8409 !! end
8410
8411 !! test
8412 3. Interaction of linktrail and template encapsulation
8413 !! options
8414 parsoid
8415 !! wikitext
8416 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8417 !! html
8418 <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>
8419 !! end
8420
8421 !! article
8422 Söfnuður
8423 !! text
8424 Test.
8425 !! endarticle
8426
8427 !! test
8428 Internal link with is link prefix
8429 !! options
8430 language=is
8431 !! wikitext
8432 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8433 !! html
8434 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8435 </p>
8436 !! end
8437
8438 !! article
8439 Mótmælendatrú
8440 !! text
8441 Test.
8442 !! endarticle
8443
8444 !! test
8445 Internal link with is link trail and link prefix
8446 !! options
8447 language=is
8448 !! wikitext
8449 [[mótmælendatrú|xxx]]ar
8450 [[mótmælendatrú]]ar
8451 mótmælenda[[söfnuður]]
8452 mótmælenda[[söfnuður|söfnuðir]]
8453 mótmælenda[[söfnuður|söfnuðir]]xxx
8454 !! html
8455 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8456 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8457 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8458 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8459 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8460 </p>
8461 !! end
8462
8463 !! test
8464 Parsoid link trail escaping
8465 !! options
8466 parsoid=html2wt,html2html
8467 !! html/parsoid
8468 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8469 !! wikitext
8470 [[apple]]<nowiki/>s
8471 !! end
8472
8473 !! test
8474 Parsoid link prefix escaping
8475 !! options
8476 language=is
8477 parsoid=html2wt,html2html
8478 !! html/parsoid
8479 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8480 !! wikitext
8481 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8482 !! end
8483
8484 !! test
8485 Parsoid link bracket escaping
8486 !! options
8487 parsoid=html2wt,html2html
8488 !! html/parsoid
8489 <p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
8490 <p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
8491 <p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
8492 <p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
8493 <p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
8494 <p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
8495 !! wikitext
8496 [[Test]]
8497
8498 [<nowiki/>[[Test]]]
8499
8500 [[[[Test]]]]
8501
8502 [[[<nowiki/>[[Test]]]]]
8503
8504 [[[[[[Test]]]]]]
8505
8506 [[[[[<nowiki/>[[Test]]]]]]]
8507 !! end
8508
8509 !! test
8510 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8511 !! wikitext
8512 [[Foo| bar]]
8513
8514 [[Foo| ''bar'']]
8515
8516 [http://wp.org foo]
8517
8518 [http://wp.org ''foo'']
8519 !! html
8520 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8521 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8522 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8523 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8524 </p>
8525 !! end
8526
8527 !! test
8528 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8529 !! wikitext
8530 [[Foo|{{echo|a}} b {{echo|c}}]]
8531 !! html/parsoid
8532 <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>
8533 !! end
8534
8535 !! test
8536 Link with angle bracket after anchor
8537 !! config
8538 wgFragmentMode=[ 'html5', 'legacy' ]
8539 !! wikitext
8540 [[Foo#<bar>]]
8541 !! html/php
8542 <p><a href="/wiki/Foo#&lt;bar&gt;" title="Foo">Foo#&lt;bar&gt;</a>
8543 </p>
8544 !! html/parsoid
8545 <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>
8546 !! end
8547
8548 !! test
8549 Link with angle bracket after anchor (legacy)
8550 !! config
8551 wgFragmentMode=[ 'legacy' ]
8552 !! wikitext
8553 [[Foo#<bar>]]
8554 !! html/php
8555 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8556 </p>
8557 !! end
8558
8559 ###
8560 ### Interwiki links (see maintenance/interwiki.sql)
8561 ###
8562
8563 !! test
8564 Inline interwiki link
8565 !! options
8566 parsoid=wt2html,wt2wt,html2html
8567 !! wikitext
8568 [[MeatBall:SoftSecurity]]
8569 !! html/php
8570 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8571 </p>
8572 !! html/parsoid
8573 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8574 !! end
8575
8576 !! test
8577 Inline interwiki link with empty title (T4372)
8578 !! options
8579 parsoid=wt2html,wt2wt,html2html
8580 !! wikitext
8581 [[MeatBall:]]
8582 !! html/php
8583 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8584 </p>
8585 !! html/parsoid
8586 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8587 !! end
8588
8589 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8590 !! test
8591 Interwiki link encoding conversion (T3636)
8592 !! options
8593 parsoid=wt2html,wt2wt
8594 !! wikitext
8595 *[[Wikipedia:ro:Olteni&#0355;a]]
8596 *[[Wikipedia:ro:Olteni&#355;a]]
8597 !! html
8598 <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>
8599 <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>
8600
8601 !! html/php+tidy
8602 <ul>
8603 <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>
8604 <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>
8605 </ul>
8606 !! html/parsoid
8607 <ul>
8608 <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>
8609 <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>
8610 </ul>
8611 !! end
8612
8613 !! test
8614 Interwiki link with fragment (T4130)
8615 !! wikitext
8616 [[MeatBall:SoftSecurity#foo]]
8617 !! html
8618 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8619 </p>
8620 !! end
8621
8622 !! test
8623 Link scenarios with escaped fragments
8624 !! config
8625 wgFragmentMode=[ 'html5', 'legacy' ]
8626 !! wikitext
8627 [[#Is this great?]]
8628 [[Foo#Is this great?]]
8629 [[meatball:Foo#Is this great?]]
8630 !! html/php
8631 <p><a href="#Is_this_great?">#Is this great?</a>
8632 <a href="/wiki/Foo#Is_this_great?" title="Foo">Foo#Is this great?</a>
8633 <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>
8634 </p>
8635 !! html/parsoid
8636 <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>
8637 <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>
8638 <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>
8639 !! end
8640
8641 !! test
8642 Link scenarios with escaped fragments (legacy)
8643 !! config
8644 wgFragmentMode=[ '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.3F">#Is this great?</a>
8651 <a href="/wiki/Foo#Is_this_great.3F" 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 !! end
8655
8656 # Ideally the wikipedia: prefix here should be proto-relative too
8657 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8658 # define the 'en' prefix, and originally the test used 'wikipedia',
8659 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8660 # article.
8661 !! test
8662 Different interwiki prefixes mapping to the same URL
8663 !! wikitext
8664 [[:en:Foo]]
8665
8666 [[:en:Foo|Foo]]
8667
8668 [[wikipedia:Foo]]
8669
8670 [[:wikipedia:Foo|Foo]]
8671
8672 [[wikipedia:en:Foo]]
8673
8674 [[:wikipedia:en:Foo]]
8675
8676 [[ wikiPEdia :Foo]]
8677 !! html/parsoid
8678 <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>
8679
8680 <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>
8681
8682 <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>
8683
8684 <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>
8685
8686 <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>
8687
8688 <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>
8689
8690 <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>
8691 !! end
8692
8693 !! test
8694 Interwiki links that cannot be represented in wiki syntax
8695 !! wikitext
8696 [[meatball:ok]]
8697 [[meatball:ok#foo|ok with fragment]]
8698 [[meatball:ok_as_well?|ok ending with ? mark]]
8699 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8700 [http://de.wikipedia.org/wiki/#foo is just fragment]
8701
8702 !! html/php
8703 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8704 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8705 <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>
8706 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8707 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8708 </p>
8709 !! html/parsoid
8710 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8711 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8712 <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>
8713 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8714 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8715 !! end
8716
8717 !! test
8718 Interwiki links: trail
8719 !! wikitext
8720 [[wikipedia:Foo|Ba]]r
8721 !! html/php
8722 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8723 </p>
8724 !! html/parsoid
8725 <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>
8726 !! end
8727
8728 !! test
8729 Local interwiki link
8730 !! options
8731 parsoid=wt2html,wt2wt,html2html
8732 !! wikitext
8733 [[local:Template:Foo]]
8734 !! html/php
8735 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8736 </p>
8737 !! html/parsoid
8738 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8739 !! end
8740
8741 # Parsoid does not mark self-links, by design.
8742 !! test
8743 Local interwiki link: self-link to current page
8744 !! options
8745 title=[[Main Page]]
8746 parsoid=wt2html,wt2wt,html2html
8747 !! wikitext
8748 [[local:Main Page]]
8749 !! html/php
8750 <p><a class="mw-selflink selflink">local:Main Page</a>
8751 </p>
8752 !! html/parsoid
8753 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8754 !! end
8755
8756 !! test
8757 Local interwiki link: prefix only (T66167)
8758 !! options
8759 parsoid=wt2html,wt2wt,html2html
8760 !! wikitext
8761 [[local:]]
8762 !! html/php
8763 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8764 </p>
8765 !! html/parsoid
8766 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8767 !! end
8768
8769 !! test
8770 Local interwiki link: with additional interwiki prefix (T63357)
8771 !! options
8772 parsoid=wt2html,wt2wt,html2html
8773 !! wikitext
8774 [[local:meatball:Hello]]
8775 !! html/php
8776 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8777 </p>
8778 !! html/parsoid
8779 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8780 !! end
8781
8782 !! test
8783 Multiple local interwiki link prefixes
8784 !! wikitext
8785 [[local:local:local:local:mi:local:Foo]]
8786 !! options
8787 parsoid=wt2html,wt2wt,html2html
8788 !! html/php
8789 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8790 </p>
8791 !! html/parsoid
8792 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8793 !! end
8794
8795 ###
8796 ### Interlanguage links
8797 ### Language links (so that searching for '### language' matches..)
8798 ###
8799
8800 !! test
8801 Interlanguage link
8802 !! wikitext
8803 Blah blah blah
8804 [[zh:Chinese]]
8805 !! html/php
8806 <p>Blah blah blah
8807 </p>
8808 !! html/parsoid
8809 <p>Blah blah blah</p>
8810 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8811 !! end
8812
8813 ## parsoid html2wt will lose the space variations
8814 !! test
8815 Interlanguage link with spacing
8816 !! options
8817 parsoid=wt2html,wt2wt,html2html
8818 !! wikitext
8819 Blah blah blah
8820 [[ zh : Chinese ]]
8821 !! html/php
8822 <p>Blah blah blah
8823 </p>
8824 !! html/parsoid
8825 <p>Blah blah blah</p>
8826 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8827 !! end
8828
8829 !! test
8830 Double interlanguage link
8831 !! wikitext
8832 Blah blah blah
8833 [[es:Spanish]]
8834 [[zh:Chinese]]
8835 !! html/php
8836 <p>Blah blah blah
8837 </p>
8838 !! html/parsoid
8839 <p>Blah blah blah</p>
8840 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8841 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8842 !! end
8843
8844 ## parsoid html2wt will lose the space variations
8845 !! test
8846 Interlanguage link variations
8847 !! options
8848 parsoid=wt2html,wt2wt,html2html
8849 !! wikitext
8850 Blah blah blah
8851 [[ es :Spanish]]
8852 [[ ZH :Chinese]]
8853 [[es:Foo_bar]]
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 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
8862 !! end
8863
8864 !! test
8865 Escaping of interlanguage links (T129218, T156308)
8866 !! wikitext
8867 Blah blah blah
8868 [[:es:Spanish]]
8869 [[ : zh : Chinese ]]
8870 !! html/php
8871 <p>Blah blah blah
8872 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8873 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
8874 </p>
8875 !! html/parsoid
8876 <p>Blah blah blah
8877 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8878 <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
8879 !! end
8880
8881 !! test
8882 Multiple colons escaping interlanguage links
8883 !! options
8884 parsoid=wt2html
8885 !! wikitext
8886 [[:es:Spanish]]
8887 [[::es:Spanish]]
8888 [[:::es:Spanish]]
8889 !! html/php
8890 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8891 [[::es:Spanish]]
8892 [[:::es:Spanish]]
8893 </p>
8894 !! html/parsoid
8895 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8896 [[::es:Spanish]]
8897 [[:::es:Spanish]]</p>
8898 !! end
8899
8900 ## parsoid html2wt will normalize the space to _
8901 !! test
8902 Space and question mark encoding in interlanguage links (T95473)
8903 !! options
8904 parsoid=wt2html,wt2wt,html2html
8905 !! wikitext
8906 Blah blah blah
8907 [[es:Foo bar?]]
8908 !! html/php
8909 <p>Blah blah blah
8910 </p>
8911 !! html/parsoid
8912 <p>Blah blah blah</p>
8913 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
8914 !! end
8915
8916 !! test
8917 Interlanguage link, with prefix links
8918 !! options
8919 language=ln
8920 !! wikitext
8921 Blah blah blah
8922 [[zh:Chinese]]
8923 !! html/php
8924 <p>Blah blah blah
8925 </p>
8926 !! html/parsoid
8927 <p>Blah blah blah</p>
8928 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8929 !! end
8930
8931 !! test
8932 Double interlanguage link, with prefix links (T10897)
8933 !! options
8934 language=ln
8935 !! wikitext
8936 Blah blah blah
8937 [[es:Spanish]]
8938 [[zh:Chinese]]
8939 !! html/php
8940 <p>Blah blah blah
8941 </p>
8942 !! html/parsoid
8943 <p>Blah blah blah</p>
8944 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8945 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8946 !! end
8947
8948 !! test
8949 "Extra" interlanguage links (T34189 / gerrit 111390)
8950 !! wikitext
8951 Blah blah blah
8952 [[mul:Article]]
8953 !! html/php
8954 <p>Blah blah blah
8955 </p>
8956 !! html/parsoid
8957 <p>Blah blah blah</p>
8958 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
8959 !! end
8960
8961 ## PHP parser tests script needs an update
8962 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8963 !! test
8964 Language links render as inline links if $wgInterwikiMagic=false
8965 !! options
8966 wgInterwikiMagic=false
8967 parsoid=wt2html,wt2wt,html2html
8968 !! wikitext
8969 Blah blah blah
8970 [[zh:Chinese]]
8971 !! html/parsoid
8972 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
8973 !! end
8974
8975 ## PHP parser tests script needs an update
8976 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8977 !! test
8978 Language links render as inline links in the Talk namespace
8979 !! options
8980 title=Talk:Foo
8981 parsoid=wt2html,wt2wt,html2html
8982 !! wikitext
8983 Blah blah blah
8984 [[zh:Chinese]]
8985 !! html/parsoid
8986 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
8987 !! end
8988
8989 !! test
8990 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
8991 !! options
8992 language=ln
8993 !! wikitext
8994 [[WW&nbsp;II]]
8995 !! html
8996 <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>
8997 </p>
8998 !! end
8999
9000 !! test
9001 Parsoid T55221: Wikilinks should be properly entity-escaped
9002 !! options
9003 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
9004 !! html/parsoid
9005 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9006 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9007 !! wikitext
9008 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
9009
9010 He&amp;nbsp;llo He&amp;nbsp;llo
9011 !! html/php
9012 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
9013 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
9014 </p>
9015 !! end
9016
9017 # html2wt will fail because of title normalization without data-parsoid
9018 !! test
9019 Parsoid: handle constructor well
9020 !! options
9021 parsoid=wt2html,wt2wt
9022 !! wikitext
9023 [[constructor]]
9024
9025 [[constructor:foo]]
9026 !! html/php
9027 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
9028 </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>
9029 </p>
9030 !! html/parsoid
9031 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
9032
9033 <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>
9034 !! end
9035
9036 !! article
9037 ko:
9038 !! text
9039 Test.
9040 !! endarticle
9041
9042 # Note that `ko` isn't a known interlanguage prefix
9043 !! test
9044 Parsoid: recognize interlanguage links without a target page
9045 !! options
9046 ill
9047 !! wikitext
9048 [[es:]]
9049
9050 [[ko:]]
9051 !! html/php
9052 es:
9053 !! html/parsoid
9054 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
9055
9056 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9057 !! end
9058
9059 # Note that `ko` isn't a known interwiki prefix
9060 !! test
9061 Parsoid: recognize interwiki links without a target page
9062 !! options
9063 parsoid=wt2html,wt2wt,html2html
9064 !! wikitext
9065 [[:es:]]
9066
9067 [[:ko:]]
9068 !! html/php
9069 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9070 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9071 </p>
9072 !! html/parsoid
9073 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9074 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9075 !! end
9076
9077 !! test
9078 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9079 !! wikitext
9080 [[mi:Foo]]
9081 !! html/php
9082 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9083 </p>
9084 !! html/parsoid
9085 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9086 !! end
9087
9088 !! test
9089 Interlanguage link with preceding local interwiki link (T70085)
9090 !! options
9091 parsoid=wt2html,wt2wt,html2html
9092 !! wikitext
9093 Blah blah blah
9094 [[local:es:Spanish]]
9095 !! html/php
9096 <p>Blah blah blah
9097 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9098 </p>
9099 !! html/parsoid
9100 <p>Blah blah blah
9101 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9102 !! end
9103
9104 !! test
9105 Looks like an interlanguage link, but is actually a local interwiki
9106 !! options
9107 parsoid=wt2html,wt2wt,html2html
9108 !! wikitext
9109 Blah blah blah
9110 [[mi:Template:Foo]]
9111 !! html/php
9112 <p>Blah blah blah
9113 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9114 </p>
9115 !! html/parsoid
9116 <p>Blah blah blah
9117 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9118 !! end
9119
9120 ###
9121 ### Redirects, Parsoid-only
9122 ###
9123
9124 !! test
9125 1. Simple redirect to page
9126 !! wikitext
9127 #REDIRECT [[Main Page]]
9128 !! html/parsoid
9129 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9130 !! end
9131
9132 !! test
9133 2. Other redirect variants
9134 !! wikitext
9135 #REDIRECT [[Main_Page]]
9136 !! html/parsoid
9137 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9138 !! end
9139
9140 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9141 # This tests the Parsoid bail-out code.
9142 !! test
9143 3. Other redirect variants
9144 !! options
9145 parsoid=wt2html
9146 !! wikitext
9147 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9148 !! html/parsoid
9149 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
9150 !! end
9151
9152 !! test
9153 4. Redirect to a templated destination
9154 !! wikitext
9155 #REDIRECT [[{{echo|Foo}}bar]]
9156 !! html/parsoid
9157 <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"}]]}'/>
9158 !! end
9159
9160 !! test
9161 Empty redirect
9162 !! options
9163 parsoid=wt2html,wt2wt
9164 !! wikitext
9165 #REDIRECT [[]]
9166 !! html/parsoid
9167 <ol>
9168 <li>REDIRECT [[]]</li></ol>
9169 !! end
9170
9171 !! test
9172 Optional colon in #REDIRECT
9173 !! options
9174 # the colon is archaic syntax. we support it for wt2html, but we
9175 # don't care that it roundtrips back to the modern syntax.
9176 parsoid=wt2html,html2html
9177 !! wikitext
9178 #REDIRECT:[[Main Page]]
9179 !! html/parsoid
9180 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9181 !! end
9182
9183 !! test
9184 Whitespace in #REDIRECT with optional colon
9185 !! options
9186 # the colon and gratuitous whitespace is archaic syntax. we support
9187 # it for wt2html, but we don't care that it roundtrips back to the
9188 # modern syntax (without extra whitespace)
9189 parsoid=wt2html,html2html
9190 !! wikitext
9191
9192 #REDIRECT
9193 :
9194 [[Main Page]]
9195 !! html/parsoid
9196 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9197 !! end
9198
9199 !! test
9200 Piped link in #REDIRECT
9201 !! options
9202 # content after piped link is ignored. we support this syntax,
9203 # but don't care that the piped link is lost when we roundtrip this.
9204 parsoid=wt2html
9205 !! wikitext
9206 #REDIRECT [[Main Page|bar]]
9207 !! html/parsoid
9208 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9209 !! end
9210
9211 !! test
9212 Redirect to category (T104502)
9213 !! options
9214 parsoid=wt2html,wt2wt
9215 !! wikitext
9216 #REDIRECT [[Category:Foo]]
9217 !! html/parsoid
9218 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9219 !! end
9220
9221 !! test
9222 Redirect to category with URL encoding (T104502)
9223 !! options
9224 parsoid=wt2html
9225 !! wikitext
9226 #REDIRECT [[Category%3AFoo]]
9227 !! html/parsoid
9228 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9229 !! end
9230
9231 !! test
9232 Redirect to category page
9233 !! wikitext
9234 #REDIRECT [[:Category:Foo]]
9235 !! html/parsoid
9236 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9237 !! end
9238
9239 !! test
9240 Redirect to image page (1)
9241 !! wikitext
9242 #REDIRECT [[File:Wiki.png]]
9243 !! html/parsoid
9244 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9245 !! end
9246
9247 !! test
9248 Redirect to image page (2)
9249 !! wikitext
9250 #REDIRECT [[Image:Wiki.png]]
9251 !! html/parsoid
9252 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9253 !! end
9254
9255 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9256 # Next test confirms this.
9257 !! test
9258 Redirect to language (1) (T104918)
9259 !! options
9260 parsoid=wt2html,wt2wt,html2html
9261 !! wikitext
9262 #REDIRECT [[en:File:Wiki.png]]
9263 !! html/parsoid
9264 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9265 !! end
9266
9267 !! test
9268 Redirect to language (2) (T104918)
9269 !! wikitext
9270 #REDIRECT [[:en:File:Wiki.png]]
9271 !! html/parsoid
9272 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9273 !! end
9274
9275 !! test
9276 Redirect to interwiki (T104918)
9277 !! wikitext
9278 #REDIRECT [[meatball:File:Wiki.png]]
9279 !! html/parsoid
9280 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9281 !! end
9282
9283 !! test
9284 Non-English #REDIRECT
9285 !! options
9286 language=is
9287 !! wikitext
9288 #TILVÍSUN [[Main Page]]
9289 !! html/parsoid
9290 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9291 !! end
9292
9293 !! test
9294 Redirect syntax under text isn't considered a redirect
9295 !! wikitext
9296 some text
9297
9298 #redirect [[Main Page]]
9299 !! html/parsoid
9300 <p>some text</p>
9301 <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>
9302 !! end
9303
9304 !! test
9305 New redirect
9306 !! options
9307 parsoid=html2wt
9308 !! html/parsoid
9309 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9310 !! wikitext
9311 #REDIRECT [[Foo]]
9312 Foo
9313 !! end
9314
9315 !! test
9316 Redirect followed by block on the same line
9317 !! options
9318 parsoid=wt2html
9319 !! wikitext
9320 #REDIRECT [[Main Page]]<!-- haha -->==hi==
9321 !! html/parsoid
9322 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi">hi</h2>
9323 !! end
9324
9325 !! test
9326 Redirect followed by a newline
9327 !! wikitext
9328 #REDIRECT [[Main Page]]
9329 A newline
9330 !! html/parsoid
9331 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9332 <p>A newline</p>
9333 !! end
9334
9335 !! test
9336 Redirect followed by multiple newlines
9337 !! wikitext
9338 #REDIRECT [[Main Page]]
9339
9340
9341 A newline
9342 !! html/parsoid
9343 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9344
9345 <p><br/>
9346 A newline</p>
9347 !! end
9348
9349 !! test
9350 Drop duplicate redirects
9351 !! options
9352 parsoid=html2wt
9353 !! html/parsoid
9354 <link rel="mw:PageProp/redirect" href="./Foo"/>
9355 <link rel="mw:PageProp/redirect" href="./Bar"/>
9356 <link rel="mw:PageProp/redirect" href="./Baz"/>
9357 !! wikitext
9358 #REDIRECT [[Foo]]
9359 !! end
9360
9361 ##
9362 ## XHTML tidiness
9363 ###
9364
9365 !! test
9366 <br> to <br />
9367 !! wikitext
9368 1<br>2<br />3
9369 !! html
9370 <p>1<br />2<br />3
9371 </p>
9372 !! end
9373
9374 !! test
9375 Broken br tag sanitization
9376 !! wikitext
9377 </br>
9378 !! html/php
9379 <p>&lt;/br&gt;
9380 </p>
9381 !! end
9382
9383 # TODO: Fix html2html mode (T53055)!
9384 !! test
9385 Parsoid: Broken br tag recognition
9386 !! options
9387 parsoid=wt2html
9388 !! wikitext
9389 </br>
9390
9391 <br/ >
9392 !! html+tidy
9393 <p><br />
9394 </p><p><br />
9395 </p>
9396 !! end
9397
9398 !! test
9399 Incorrecly removing closing slashes from correctly formed XHTML
9400 !! wikitext
9401 <br style="clear:both;" />
9402 !! html
9403 <p><br style="clear:both;" />
9404 </p>
9405 !! end
9406
9407 !! test
9408 Failing to transform badly formed HTML into correct XHTML
9409 !! wikitext
9410 <br style="clear: left;">
9411 <br style="clear: right;">
9412 <br style="clear: both;">
9413 !! html
9414 <p><br style="clear: left;" />
9415 <br style="clear: right;" />
9416 <br style="clear: both;" />
9417 </p>
9418 !!end
9419
9420 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9421 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9422 !! test
9423 Handling html with a div self-closing tag
9424 !! wikitext
9425 <div title />
9426 <div title/>
9427 <div title/ >
9428 <div title=bar />
9429 <div title=bar/>
9430 <div title=bar/ >
9431 !! html/php
9432 <p>&lt;div title /&gt;
9433 &lt;div title/&gt;
9434 </p>
9435 <div>
9436 <p>&lt;div title=bar /&gt;
9437 &lt;div title=bar/&gt;
9438 </p>
9439 <div title="bar/"></div>
9440 </div>
9441
9442 !! html/parsoid
9443 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9444 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9445 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9446 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9447 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9448 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>
9449 !! end
9450
9451 !! test
9452 Handling html with a br self-closing tag
9453 !! wikitext
9454 <br title />
9455 <br title/>
9456 <br title/ >
9457 <br title=bar />
9458 <br title=bar/>
9459 <br title=bar/ >
9460 !! html/php
9461 <p><br title="" />
9462 <br title="" />
9463 <br />
9464 <br title="bar" />
9465 <br title="bar" />
9466 <br title="bar/" />
9467 </p>
9468 !! html/parsoid
9469 <p><br title="" />
9470 <br title="" />
9471 <br title="" />
9472 <br title="bar" />
9473 <br title="bar" />
9474 <br title="bar/" />
9475 </p>
9476 !! end
9477
9478 !! test
9479 Horizontal ruler (should it add that extra space?)
9480 !! wikitext
9481 <hr>
9482 <hr >
9483 foo <hr
9484 > bar
9485 !! html+tidy
9486 <hr />
9487 <hr /><p>
9488 foo </p><hr /><p> bar
9489 </p>
9490 !! end
9491
9492 !! test
9493 Horizontal ruler -- 4+ dashes render hr
9494 !! wikitext
9495 ----
9496 !! html
9497 <hr />
9498
9499 !! end
9500
9501 !! test
9502 Horizontal ruler -- eats additional dashes on the same line
9503 !! wikitext
9504 ---------
9505 !! html
9506 <hr />
9507
9508 !! end
9509
9510 !! test
9511 Horizontal ruler -- does not collapse dashes on consecutive lines
9512 !! wikitext
9513 ----
9514 ----
9515 !! html
9516 <hr />
9517 <hr />
9518
9519 !! end
9520
9521 !! test
9522 Horizontal ruler -- <4 dashes render as plain text
9523 !! wikitext
9524 ---
9525 !! html
9526 <p>---
9527 </p>
9528 !! end
9529
9530 !! test
9531 Horizontal ruler -- Supports content following dashes on same line
9532 !! wikitext
9533 ---- Foo
9534 !! html
9535 <hr /> Foo
9536
9537 !! html+tidy
9538 <hr /><p> Foo
9539 </p>
9540 !! end
9541
9542 ###
9543 ### Block-level elements
9544 ###
9545 !! test
9546 Common list
9547 !! wikitext
9548 *Common list
9549 *item 2
9550 *item 3
9551 !! html
9552 <ul><li>Common list</li>
9553 <li>item 2</li>
9554 <li>item 3</li></ul>
9555
9556 !! end
9557
9558 !! test
9559 Numbered list
9560 !! wikitext
9561 #Numbered list
9562 #item 2
9563 #item 3
9564 !! html
9565 <ol><li>Numbered list</li>
9566 <li>item 2</li>
9567 <li>item 3</li></ol>
9568
9569 !! end
9570
9571 # the switch from level 3 to ordered should not introduce a newline between
9572 !! test
9573 Mixed list
9574 !! wikitext
9575 *Mixed list
9576 *#with numbers
9577 **and bullets
9578 *#and numbers
9579 *bullets again
9580 **bullet level 2
9581 ***bullet level 3
9582 ***#Number on level 4
9583 **bullet level 2
9584 **#Number on level 3
9585 **#Number on level 3
9586 *#number level 2
9587 *Level 1
9588 ***Level 3
9589 #**Level 3, but ordered
9590 !! html
9591 <ul><li>Mixed list
9592 <ol><li>with numbers</li></ol>
9593 <ul><li>and bullets</li></ul>
9594 <ol><li>and numbers</li></ol></li>
9595 <li>bullets again
9596 <ul><li>bullet level 2
9597 <ul><li>bullet level 3
9598 <ol><li>Number on level 4</li></ol></li></ul></li>
9599 <li>bullet level 2
9600 <ol><li>Number on level 3</li>
9601 <li>Number on level 3</li></ol></li></ul>
9602 <ol><li>number level 2</li></ol></li>
9603 <li>Level 1
9604 <ul><li><ul><li>Level 3</li></ul></li></ul></li></ul>
9605 <ol><li><ul><li><ul><li>Level 3, but ordered</li></ul></li></ul></li></ol>
9606
9607 !! end
9608
9609 !! test
9610 1. Nested mixed wikitext and html list
9611 !! wikitext
9612 *hi
9613 *<ul><li>ho</li></ul>
9614 *hi
9615 **ho
9616 !! html/php
9617 <ul><li>hi</li>
9618 <li><ul><li>ho</li></ul></li>
9619 <li>hi
9620 <ul><li>ho</li></ul></li></ul>
9621
9622 !! html/parsoid
9623 <ul><li>hi</li>
9624 <li><ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9625 <li>hi
9626 <ul><li>ho</li></ul></li></ul>
9627 !! end
9628
9629 !! test
9630 2. Nested mixed wikitext and html list (incompatible)
9631 !! wikitext
9632 ;hi
9633 :{{echo|<li>ho</li>}}
9634 !! html/php
9635 <dl><dt>hi</dt>
9636 <dd><li>ho</li></dd></dl>
9637
9638 !! html/parsoid
9639 <dl><dt>hi</dt>
9640 <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>
9641 !! end
9642
9643 !! test
9644 Nested lists 1
9645 !! wikitext
9646 *foo
9647 **bar
9648 !! html
9649 <ul><li>foo
9650 <ul><li>bar</li></ul></li></ul>
9651
9652 !! end
9653
9654 !! test
9655 Nested lists 2
9656 !! wikitext
9657 **foo
9658 *bar
9659 !! html
9660 <ul><li><ul><li>foo</li></ul></li>
9661 <li>bar</li></ul>
9662
9663 !! end
9664
9665 !! test
9666 Nested lists 3 (first element empty)
9667 !! wikitext
9668 *
9669 **bar
9670 !! html
9671 <ul><li>
9672 <ul><li>bar</li></ul></li></ul>
9673
9674 !! end
9675
9676 !! test
9677 Nested lists 4 (first element empty)
9678 !! wikitext
9679 **
9680 *bar
9681 !! html
9682 <ul><li><ul><li></li></ul></li>
9683 <li>bar</li></ul>
9684
9685 !! end
9686
9687 !! test
9688 Nested lists 5 (both elements empty)
9689 !! wikitext
9690 **
9691 *
9692 !! html
9693 <ul><li><ul><li></li></ul></li>
9694 <li></li></ul>
9695
9696 !! end
9697
9698 !! test
9699 Nested lists 6 (both elements empty)
9700 !! wikitext
9701 *
9702 **
9703 !! html
9704 <ul><li>
9705 <ul><li></li></ul></li></ul>
9706
9707 !! end
9708
9709 !! test
9710 Nested lists 7 (skip initial nesting levels)
9711 !! wikitext
9712 ***foo
9713 !! html
9714 <ul><li><ul><li><ul><li>foo</li></ul></li></ul></li></ul>
9715
9716 !! end
9717
9718 !! test
9719 Nested lists 8 (multiple nesting transitions)
9720 !! wikitext
9721 *foo
9722 ***bar
9723 **baz
9724 *boo
9725 !! html
9726 <ul><li>foo
9727 <ul><li><ul><li>bar</li></ul></li>
9728 <li>baz</li></ul></li>
9729 <li>boo</li></ul>
9730
9731 !! end
9732
9733 !! test
9734 Nested lists 9 (extension interaction)
9735 !! options
9736 parsoid
9737 !! wikitext
9738 *<references />
9739 !! html/parsoid
9740 <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>
9741 !! end
9742
9743 !! test
9744 1. Lists with start-of-line-transparent tokens before bullets: Comments
9745 !! wikitext
9746 *foo
9747 *<!--cmt-->bar
9748 <!--cmt-->*baz
9749 !! html
9750 <ul><li>foo</li>
9751 <li>bar</li>
9752 <li>baz</li></ul>
9753
9754 !! end
9755
9756 !! test
9757 2. Lists with start-of-line-transparent tokens before bullets: Template close
9758 !! wikitext
9759 *foo {{echo|bar
9760 }}*baz
9761 !! html
9762 <ul><li>foo bar</li>
9763 <li>baz</li></ul>
9764
9765 !! end
9766
9767 !! test
9768 List items are not parsed correctly following a <pre> block (T2785)
9769 !! wikitext
9770 *<pre>foo</pre>
9771 *<pre>bar</pre>
9772 *zar
9773 !! html/php
9774 <ul><li><pre>foo</pre></li>
9775 <li><pre>bar</pre></li>
9776 <li>zar</li></ul>
9777
9778 !! html/parsoid
9779 <ul><li><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
9780 <li><pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
9781 <li>zar</li></ul>
9782 !! end
9783
9784 # FIXME: Might benefit from a html/parsoid since this has a template
9785 !! test
9786 List items from template
9787 !! wikitext
9788
9789 {{inner list}}
9790 *item 2
9791
9792 *item 0
9793 {{inner list}}
9794 *item 2
9795
9796 *item 0
9797 *notSOL{{inner list}}
9798 *item 2
9799 !! html
9800 <ul><li>item 1</li>
9801 <li>item 2</li></ul>
9802 <ul><li>item 0</li>
9803 <li>item 1</li>
9804 <li>item 2</li></ul>
9805 <ul><li>item 0</li>
9806 <li>notSOL</li>
9807 <li>item 1</li>
9808 <li>item 2</li></ul>
9809
9810 !! end
9811
9812 !! test
9813 List interrupted by empty line or heading
9814 !! wikitext
9815 *foo
9816
9817 **bar
9818 ==A heading==
9819 *Another list item
9820 !! html
9821 <ul><li>foo</li></ul>
9822 <ul><li><ul><li>bar</li></ul></li></ul>
9823 <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>
9824 <ul><li>Another list item</li></ul>
9825
9826 !!end
9827
9828 !!test
9829 Multiple list tags generated by templates
9830 !! wikitext
9831 {{echo|<li>}}a
9832 {{echo|<li>}}b
9833 {{echo|<li>}}c
9834 !! html
9835 <li>a
9836 <li>b
9837 <li>c</li>
9838 </li>
9839 </li>
9840
9841 !! html+tidy
9842 <li>a
9843 </li><li>b
9844 </li><li>c
9845 </li>
9846 !! html/parsoid
9847 <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
9848 </li><li about="#mwt1">b
9849 </li><li about="#mwt1" data-parsoid='{"stx":"html","autoInsertedEnd":true,"dsr":[null,44,null,0]}'>c</li>
9850 !!end
9851
9852 !!test
9853 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
9854 !! wikitext
9855 *a
9856 <!--This line will NOT split the list-->
9857 *b
9858 <!--This line will NOT split the list either-->
9859 *c
9860 <!--foo--> <!----> <!--This line NOT split the list either-->
9861 *d
9862 !! html
9863 <ul><li>a</li>
9864 <li>b</li>
9865 <li>c</li>
9866 <li>d</li></ul>
9867
9868 !!end
9869
9870 !!test
9871 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
9872 !! wikitext
9873 *a
9874 <!--This line will NOT split the list-->
9875 *b
9876 <!--This line will NOT split the list either-->
9877 *c
9878 <!--foo--> <!----> <!--This line NOT split the list
9879 either-->
9880 *d
9881 !! html
9882 <ul><li>a</li>
9883 <li>b</li>
9884 <li>c</li>
9885 <li>d</li></ul>
9886
9887 !!end
9888
9889 # FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack
9890 # That pass could possibly be removed.
9891 !!test
9892 Test the li-hack (a hack from Tidy days, but doesn't work as advertised with Remex)
9893 !!options
9894 parsoid=wt2html,wt2wt
9895 !! wikitext
9896 *foo
9897 *<li>li-hack
9898 *{{echo|<li>templated li-hack}}
9899 *<!--foo--><li> unsupported li-hack with preceding comments
9900
9901 <ul>
9902 <li><li>not a li-hack
9903 </li>
9904 </ul>
9905 !! html+tidy
9906 <ul><li>foo</li>
9907 <li class="mw-empty-elt"></li><li>li-hack</li>
9908 <li class="mw-empty-elt"></li><li>templated li-hack</li>
9909 <li class="mw-empty-elt"></li><li> unsupported li-hack with preceding comments</li></ul>
9910 <ul>
9911 <li class="mw-empty-elt"></li><li>not a li-hack
9912 </li>
9913 </ul>
9914 !! html/parsoid
9915 <ul><li> foo</li>
9916 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"*"}'>li-hack</li>
9917 <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>
9918 <li data-parsoid='{"autoInsertedEnd":true}'><!--foo--></li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>unsupported li-hack with preceding comments</li></ul>
9919
9920 <ul data-parsoid='{"stx":"html"}'>
9921 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
9922 </li>
9923 </ul>
9924
9925 !!end
9926
9927 !! test
9928 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
9929 !! options
9930 parsoid
9931 !! wikitext
9932 #foo
9933 ##bar
9934
9935 *foo
9936 **bar
9937
9938 :foo
9939 ::bar
9940 !! html
9941 <ol>
9942 <li>foo<ol>
9943 <li>bar</li>
9944 </ol></li>
9945 </ol><ul>
9946 <li>foo<ul>
9947 <li>bar</li>
9948 </ul></li>
9949 </ul><dl>
9950 <dd>foo<dl>
9951 <dd>bar</dd>
9952 </dl></dd>
9953 </dl>
9954 !! end
9955
9956 !! test
9957 Parsoid: Test of whitespace serialization with Templated bullets
9958 !! options
9959 parsoid
9960 !! wikitext
9961 * {{bullet}}
9962 !! html/parsoid
9963 <ul>
9964 <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>
9965 </ul>
9966 !! end
9967
9968 # ------------------------------------------------------------------------
9969 # The next set of tests are about Parsoid's ability to handle badly nested
9970 # tags (parse, minimize scope of fixup, and roundtrip back)
9971 # ------------------------------------------------------------------------
9972
9973 # Remex and Parsoid output stems from list handling diffs because Parsoid & PHP parser.
9974 # Parsoid's list handling is more aware of block structure.
9975 !! test
9976 Unbalanced closing block tags break a list
9977 !! wikitext
9978 <div>
9979 *a</div><div>
9980 *b</div>
9981 !! html+tidy
9982 <div>
9983 <ul><li>a</li></ul></div><div>
9984 <li>b</li></div>
9985 !! html/parsoid
9986 <div><ul>
9987 <li>a</li>
9988 </ul></div>
9989 <div><ul>
9990 <li>b</li>
9991 </ul></div>
9992 !! end
9993
9994 !! test
9995 Unbalanced closing non-block tags don't break a list
9996 !! wikitext
9997 <span>
9998 *a</span><span>
9999 *b</span>
10000 !! html/php+tidy
10001 <p><span>
10002 </span></p>
10003 <ul><li>a<span></span></li>
10004 <li>b</li></ul>
10005 !! html/parsoid
10006 <span>
10007 <ul>
10008 <li>a<span></span></li>
10009 <li>b</li>
10010 </ul>
10011 </span>
10012 !! end
10013
10014 # Parsoid does some post-dom-building cleanup
10015 # which is why its output differs from Remex.
10016 !! test
10017 Unclosed formatting tags that straddle lists are closed and reopened
10018 !! options
10019 parsoid=wt2html,wt2wt,html2html
10020 !! wikitext
10021 #<s> a
10022 #b </s>
10023 !! html/php+tidy
10024 <ol><li><s> a</s></li><s>
10025 </s><li><s>b </s></li></ol>
10026 !! html/parsoid
10027 <ol><li><s> a</s></li>
10028 <li><s>b </s></li></ol>
10029 !! end
10030
10031 # Output is ugly because of all the misnested tag fixups.
10032 # Remex is wrapping p-tags around empty elements.
10033 # Parsoid has special-case handling of this pattern of
10034 # wrapping lists in formatting tags.
10035 # FIXME: Should we remove this code from Parsoid? Or add
10036 # special support in Remex? If the latter, maybe just wait
10037 # for Parsoid to become the default parser.
10038 # See T70395.
10039 !!test
10040 1. List embedded in a formatting tag
10041 !! wikitext
10042 <small>
10043 *foo
10044 </small>
10045 !! html/php+tidy
10046 <p><small>
10047 </small></p><small><ul><li>foo</li></ul></small><small></small><p><small></small>
10048 </p>
10049 !! html/parsoid
10050 <small>
10051 <ul>
10052 <li>foo</li>
10053 </ul>
10054 </small>
10055 !!end
10056
10057 # Output is ugly because of all the misnested tag fixups
10058 # Remex is wrapping p-tags around empty elements.
10059 # Parsoid has code that strips useless p-tags.
10060 !!test
10061 2. List embedded in a formatting tag in a misnested way
10062 !! wikitext
10063 <small>
10064 *a
10065 *b</small>
10066 !! html/php+tidy
10067 <p><small>
10068 </small></p><small></small><ul><small><li>a</li>
10069 </small><li><small>b</small></li></ul>
10070 !! html/parsoid
10071 <small></small>
10072 <ul><small>
10073 <li>a</li>
10074 </small>
10075 <li><small>b</small></li>
10076 </ul>
10077 !!end
10078
10079 !! test
10080 Table with missing opening <tr> tag
10081 !! options
10082 parsoid=wt2html,wt2wt
10083 !! wikitext
10084 <table>
10085 <td>foo</td>
10086 </tr>
10087 </table>
10088 !! html+tidy
10089 <table>
10090 <tbody><tr><td>foo</td>
10091 </tr>
10092 </tbody></table>
10093 !! end
10094
10095 ###
10096 ### Magic Words
10097 ###
10098
10099 # Note that the current date is hard-coded as
10100 # 1970-01-01T00:02:03Z (a Thursday)
10101 # when running parser tests. The timezone is also fixed to GMT, so
10102 # local date will be identical to current date.
10103
10104 !! test
10105 Magic Word: {{CURRENTDAY}}
10106 !! wikitext
10107 {{CURRENTDAY}}
10108 !! html
10109 <p>1
10110 </p>
10111 !! end
10112
10113 !! test
10114 Magic Word: {{CURRENTDAY2}}
10115 !! wikitext
10116 {{CURRENTDAY2}}
10117 !! html
10118 <p>01
10119 </p>
10120 !! end
10121
10122 !! test
10123 Magic Word: {{CURRENTDAYNAME}}
10124 !! wikitext
10125 {{CURRENTDAYNAME}}
10126 !! html
10127 <p>Thursday
10128 </p>
10129 !! end
10130
10131 !! test
10132 Magic Word: {{CURRENTDOW}}
10133 !! wikitext
10134 {{CURRENTDOW}}
10135 !! html
10136 <p>4
10137 </p>
10138 !! end
10139
10140 !! test
10141 Magic Word: {{CURRENTMONTH}}
10142 !! wikitext
10143 {{CURRENTMONTH}}
10144 !! html
10145 <p>01
10146 </p>
10147 !! end
10148
10149 !! test
10150 Magic Word: {{CURRENTMONTH1}}
10151 !! wikitext
10152 {{CURRENTMONTH1}}
10153 !! html
10154 <p>1
10155 </p>
10156 !! end
10157
10158 !! test
10159 Magic Word: {{CURRENTMONTHABBREV}}
10160 !! wikitext
10161 {{CURRENTMONTHABBREV}}
10162 !! html
10163 <p>Jan
10164 </p>
10165 !! end
10166
10167 !! test
10168 Magic Word: {{CURRENTMONTHNAME}}
10169 !! wikitext
10170 {{CURRENTMONTHNAME}}
10171 !! html
10172 <p>January
10173 </p>
10174 !! end
10175
10176 !! test
10177 Magic Word: {{CURRENTMONTHNAMEGEN}}
10178 !! wikitext
10179 {{CURRENTMONTHNAMEGEN}}
10180 !! html
10181 <p>January
10182 </p>
10183 !! end
10184
10185 !! test
10186 Magic Word: {{CURRENTTIME}}
10187 !! wikitext
10188 {{CURRENTTIME}}
10189 !! html
10190 <p>00:02
10191 </p>
10192 !! end
10193
10194 !! test
10195 Magic Word: {{CURRENTHOUR}}
10196 !! wikitext
10197 {{CURRENTHOUR}}
10198 !! html
10199 <p>00
10200 </p>
10201 !! end
10202
10203 !! test
10204 Magic Word: {{CURRENTWEEK}} (T6594)
10205 !! wikitext
10206 {{CURRENTWEEK}}
10207 !! html
10208 <p>1
10209 </p>
10210 !! end
10211
10212 !! test
10213 Magic Word: {{CURRENTYEAR}}
10214 !! wikitext
10215 {{CURRENTYEAR}}
10216 !! html
10217 <p>1970
10218 </p>
10219 !! end
10220
10221 !! test
10222 Magic Word: {{CURRENTTIMESTAMP}}
10223 !! wikitext
10224 {{CURRENTTIMESTAMP}}
10225 !! html
10226 <p>19700101000203
10227 </p>
10228 !! end
10229
10230 !! test
10231 Magic Words LOCAL (UTC)
10232 !! wikitext
10233 *{{LOCALMONTH}}
10234 *{{LOCALMONTH1}}
10235 *{{LOCALMONTHNAME}}
10236 *{{LOCALMONTHNAMEGEN}}
10237 *{{LOCALMONTHABBREV}}
10238 *{{LOCALDAY}}
10239 *{{LOCALDAY2}}
10240 *{{LOCALDAYNAME}}
10241 *{{LOCALYEAR}}
10242 *{{LOCALTIME}}
10243 *{{LOCALHOUR}}
10244 *{{LOCALWEEK}}
10245 *{{LOCALDOW}}
10246 *{{LOCALTIMESTAMP}}
10247 !! html
10248 <ul><li>01</li>
10249 <li>1</li>
10250 <li>January</li>
10251 <li>January</li>
10252 <li>Jan</li>
10253 <li>1</li>
10254 <li>01</li>
10255 <li>Thursday</li>
10256 <li>1970</li>
10257 <li>00:02</li>
10258 <li>00</li>
10259 <li>1</li>
10260 <li>4</li>
10261 <li>19700101000203</li></ul>
10262
10263 !! end
10264
10265 !! test
10266 Magic Word: {{FULLPAGENAME}}
10267 !! options
10268 title=[[User:Ævar Arnfjörð Bjarmason]]
10269 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10270 !! wikitext
10271 {{FULLPAGENAME}}
10272 !! html/*
10273 <p>User:Ævar Arnfjörð Bjarmason
10274 </p>
10275 !! end
10276
10277 !! test
10278 Magic Word: {{FULLPAGENAMEE}}
10279 !! options
10280 title=[[User:Ævar Arnfjörð Bjarmason]]
10281 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10282 !! wikitext
10283 {{FULLPAGENAMEE}}
10284 !! html/*
10285 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10286 </p>
10287 !! end
10288
10289 !! test
10290 Magic Word: {{TALKSPACE}}
10291 !! options
10292 title=[[User:Ævar Arnfjörð Bjarmason]]
10293 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10294 !! wikitext
10295 {{TALKSPACE}}
10296 !! html/*
10297 <p>User talk
10298 </p>
10299 !! end
10300
10301 !! test
10302 Magic Word: {{TALKSPACE}}, same namespace
10303 !! options
10304 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10305 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10306 !! wikitext
10307 {{TALKSPACE}}
10308 !! html/*
10309 <p>User talk
10310 </p>
10311 !! end
10312
10313 !! test
10314 Magic Word: {{TALKSPACE}}, main namespace
10315 !! options
10316 title=[[Parser Test]]
10317 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10318 !! wikitext
10319 {{TALKSPACE}}
10320 !! html/*
10321 <p>Talk
10322 </p>
10323 !! end
10324
10325 !! test
10326 Magic Word: {{TALKSPACEE}}
10327 !! options
10328 title=[[User:Ævar Arnfjörð Bjarmason]]
10329 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10330 !! wikitext
10331 {{TALKSPACEE}}
10332 !! html/*
10333 <p>User_talk
10334 </p>
10335 !! end
10336
10337 !! test
10338 Magic Word: {{SUBJECTSPACE}}
10339 !! options
10340 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10341 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10342 !! wikitext
10343 {{SUBJECTSPACE}}
10344 !! html/*
10345 <p>User
10346 </p>
10347 !! end
10348
10349 !! test
10350 Magic Word: {{SUBJECTSPACE}}, same namespace
10351 !! options
10352 title=[[User:Ævar Arnfjörð Bjarmason]]
10353 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10354 !! wikitext
10355 {{SUBJECTSPACE}}
10356 !! html/*
10357 <p>User
10358 </p>
10359 !! end
10360
10361 !! test
10362 Magic Word: {{SUBJECTSPACE}}, main namespace
10363 !! options
10364 title=[[Parser Test]]
10365 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10366 !! wikitext
10367 {{SUBJECTSPACE}}
10368 !! html/*
10369
10370 !! end
10371
10372 !! test
10373 Magic Word: {{SUBJECTSPACEE}}
10374 !! options
10375 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10376 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10377 !! wikitext
10378 {{SUBJECTSPACEE}}
10379 !! html/*
10380 <p>User
10381 </p>
10382 !! end
10383
10384 !! test
10385 Magic Word: {{NAMESPACE}}
10386 !! options
10387 title=[[User:Ævar Arnfjörð Bjarmason]]
10388 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10389 !! wikitext
10390 {{NAMESPACE}}
10391 !! html/*
10392 <p>User
10393 </p>
10394 !! end
10395
10396 !! test
10397 Magic Word: {{NAMESPACEE}}
10398 !! options
10399 title=[[User:Ævar Arnfjörð Bjarmason]]
10400 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10401 !! wikitext
10402 {{NAMESPACEE}}
10403 !! html/*
10404 <p>User
10405 </p>
10406 !! end
10407
10408 !! test
10409 Magic Word: {{NAMESPACENUMBER}}
10410 !! options
10411 title=[[User:Ævar Arnfjörð Bjarmason]]
10412 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10413 !! wikitext
10414 {{NAMESPACENUMBER}}
10415 !! html/*
10416 <p>2
10417 </p>
10418 !! end
10419
10420 !! test
10421 Magic Word: {{SUBPAGENAME}}
10422 !! options
10423 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10424 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10425 !! wikitext
10426 {{SUBPAGENAME}}
10427 !! html/*
10428 <p>sub ö
10429 </p>
10430 !! end
10431
10432 !! test
10433 Magic Word: {{SUBPAGENAMEE}}
10434 !! options
10435 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10436 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10437 !! wikitext
10438 {{SUBPAGENAMEE}}
10439 !! html/*
10440 <p>sub_%C3%B6
10441 </p>
10442 !! end
10443
10444 !! test
10445 Magic Word: {{ROOTPAGENAME}}
10446 !! options
10447 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10448 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10449 !! wikitext
10450 {{ROOTPAGENAME}}
10451 !! html/*
10452 <p>Ævar Arnfjörð Bjarmason
10453 </p>
10454 !! end
10455
10456 !! test
10457 Magic Word: {{ROOTPAGENAMEE}}
10458 !! options
10459 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10460 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10461 !! wikitext
10462 {{ROOTPAGENAMEE}}
10463 !! html/*
10464 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10465 </p>
10466 !! end
10467
10468 !! test
10469 Magic Word: {{BASEPAGENAME}}
10470 !! options
10471 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10472 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10473 !! wikitext
10474 {{BASEPAGENAME}}
10475 !! html/*
10476 <p>Ævar Arnfjörð Bjarmason
10477 </p>
10478 !! end
10479
10480 !! test
10481 Magic Word: {{BASEPAGENAMEE}}
10482 !! options
10483 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10484 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10485 !! wikitext
10486 {{BASEPAGENAMEE}}
10487 !! html/*
10488 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10489 </p>
10490 !! end
10491
10492 !! test
10493 Magic Word: {{TALKPAGENAME}}
10494 !! options
10495 title=[[User:Ævar Arnfjörð Bjarmason]]
10496 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10497 !! wikitext
10498 {{TALKPAGENAME}}
10499 !! html/*
10500 <p>User talk:Ævar Arnfjörð Bjarmason
10501 </p>
10502 !! end
10503
10504 !! test
10505 Magic Word: {{TALKPAGENAMEE}}
10506 !! options
10507 title=[[User:Ævar Arnfjörð Bjarmason]]
10508 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10509 !! wikitext
10510 {{TALKPAGENAMEE}}
10511 !! html/*
10512 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10513 </p>
10514 !! end
10515
10516 !! test
10517 Magic Word: {{SUBJECTPAGENAME}}
10518 !! options
10519 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10520 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10521 !! wikitext
10522 {{SUBJECTPAGENAME}}
10523 !! html/*
10524 <p>User:Ævar Arnfjörð Bjarmason
10525 </p>
10526 !! end
10527
10528 !! test
10529 Magic Word: {{SUBJECTPAGENAMEE}}
10530 !! options
10531 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10532 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10533 !! wikitext
10534 {{SUBJECTPAGENAMEE}}
10535 !! html/*
10536 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10537 </p>
10538 !! end
10539
10540 !! test
10541 Magic Word: {{NUMBEROFFILES}}
10542 !! options
10543 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10544 !! wikitext
10545 {{NUMBEROFFILES}}
10546 !! html/*
10547 <p>7
10548 </p>
10549 !! end
10550
10551 !! test
10552 Magic Word: {{PAGENAME}}
10553 !! options
10554 title=[[User:Ævar Arnfjörð Bjarmason]]
10555 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10556 !! wikitext
10557 {{PAGENAME}}
10558 !! html/*
10559 <p>Ævar Arnfjörð Bjarmason
10560 </p>
10561 !! end
10562
10563 !! test
10564 Magic Word: {{PAGENAME}} with metacharacters
10565 !! options
10566 title=[['foo & bar = baz']]
10567 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10568 !! wikitext
10569 ''{{PAGENAME}}''
10570 !! html+tidy
10571 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10572 </p>
10573 !! end
10574
10575 !! test
10576 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10577 !! options
10578 title=[[*RFC 1234 http://example.com/]]
10579 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10580 !! wikitext
10581 {{PAGENAME}}
10582 !! html+tidy
10583 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10584 </p>
10585 !! end
10586
10587 !! test
10588 Magic Word: {{PAGENAMEE}}
10589 !! options
10590 title=[[User:Ævar Arnfjörð Bjarmason]]
10591 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10592 !! wikitext
10593 {{PAGENAMEE}}
10594 !! html/*
10595 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10596 </p>
10597 !! end
10598
10599 !! test
10600 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10601 !! options
10602 title=[[*RFC 1234 http://example.com/]]
10603 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10604 !! wikitext
10605 {{PAGENAMEE}}
10606 !! html+tidy
10607 <p>&#42;RFC_1234_http&#58;//example.com/
10608 </p>
10609 !! end
10610
10611 !! test
10612 Magic Word: {{REVISIONID}}
10613 !! options
10614 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10615 showflags
10616 !! wikitext
10617 {{REVISIONID}}
10618 !! html/*
10619 <p>1337
10620 </p>
10621 flags=vary-revision-id
10622 !! end
10623
10624 !! test
10625 Magic Word: {{SCRIPTPATH}}
10626 !! options
10627 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10628 !! wikitext
10629 {{SCRIPTPATH}}
10630 !! html/*
10631
10632 !! end
10633
10634 !! test
10635 Magic Word: {{STYLEPATH}}
10636 !! options
10637 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10638 !! wikitext
10639 {{STYLEPATH}}
10640 !! html/*
10641 <p>/skins
10642 </p>
10643 !! end
10644
10645 !! test
10646 Magic Word: {{SERVER}}
10647 !! options
10648 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10649 !! wikitext
10650 {{SERVER}}
10651 !! html/*
10652 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10653 </p>
10654 !! end
10655
10656 !! test
10657 Magic Word: {{SERVERNAME}}
10658 !! options
10659 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10660 !! wikitext
10661 {{SERVERNAME}}
10662 !! html/*
10663 <p>example.org
10664 </p>
10665 !! end
10666
10667 !! test
10668 Magic Word: {{SITENAME}}
10669 !! options
10670 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10671 !! wikitext
10672 {{SITENAME}}
10673 !! html/*
10674 <p>MediaWiki
10675 </p>
10676 !! end
10677
10678 !! test
10679 Magic Word: {{PAGELANGUAGE}}
10680 !! options
10681 language=fr
10682 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10683 !! wikitext
10684 {{PAGELANGUAGE}}
10685 !! html/*
10686 <p>fr
10687 </p>
10688 !! end
10689
10690 !! test
10691 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10692 !! options
10693 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10694 !! wikitext
10695 {{PAGELANGUAGE}}
10696 !! html/*
10697 <p>en
10698 </p>
10699 !! end
10700
10701 !! test
10702 Case-sensitive magic words, when cased differently, should just be template transclusions
10703 !! wikitext
10704 {{CurrentMonth}}
10705 {{currentday}}
10706 {{cURreNTweEK}}
10707 {{currentHour}}
10708 !! html
10709 <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>
10710 <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>
10711 <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>
10712 <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>
10713 </p>
10714 !! end
10715
10716 !! test
10717 Case-insensitive magic words should still work with weird casing.
10718 !! wikitext
10719 {{sErVeRNaMe}}
10720 {{LCFirst:AOEU}}
10721 {{ucFIRST:aoeu}}
10722 {{SERver}}
10723 !! html
10724 <p>example.org
10725 aOEU
10726 Aoeu
10727 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10728 </p>
10729 !! end
10730
10731 # From plwiki:PLOS_ONE
10732 !! test
10733 Parsoid: Page property magic word with magic word contents
10734 !! wikitext
10735 {{DISPLAYTITLE:''{{PAGENAME}}''}}
10736 !! html/parsoid
10737 <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>"}]]}'/>
10738 !! end
10739
10740 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
10741 # But, this is a limitation of our representation and is documented in
10742 # TemplateHandler.js in processSpecialMagicWord
10743 !! test
10744 Parsoid: Template-generated DISPLAYTITLE
10745 !! wikitext
10746 {{{{echo|DISPLAYTITLE}}:Foo}}
10747 !! options
10748 showtitle
10749 !! config
10750 wgAllowDisplayTitle=true
10751 wgRestrictDisplayTitle=false
10752 !! html/php
10753 Foo
10754
10755 !! html/parsoid
10756 <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"}]]}'/>
10757 !! end
10758
10759 !! test
10760 Namespace 1 {{ns:1}}
10761 !! wikitext
10762 {{ns:1}}
10763 !! html
10764 <p>Talk
10765 </p>
10766 !! end
10767
10768 !! test
10769 Namespace 1 {{ns:01}}
10770 !! wikitext
10771 {{ns:01}}
10772 !! html
10773 <p>Talk
10774 </p>
10775 !! end
10776
10777 !! test
10778 Namespace 0 {{ns:0}} (T6783)
10779 !! wikitext
10780 {{ns:0}}
10781 !! html
10782
10783 !! end
10784
10785 !! test
10786 Namespace 0 {{ns:00}} (T6783)
10787 !! wikitext
10788 {{ns:00}}
10789 !! html
10790
10791 !! end
10792
10793 !! test
10794 Namespace -1 {{ns:-1}}
10795 !! wikitext
10796 {{ns:-1}}
10797 !! html
10798 <p>Special
10799 </p>
10800 !! end
10801
10802 !! test
10803 Namespace User {{ns:User}}
10804 !! wikitext
10805 {{ns:User}}
10806 !! html
10807 <p>User
10808 </p>
10809 !! end
10810
10811 !! test
10812 Namespace User talk {{ns:User_talk}}
10813 !! wikitext
10814 {{ns:User_talk}}
10815 !! html
10816 <p>User talk
10817 </p>
10818 !! end
10819
10820 !! test
10821 Namespace User talk {{ns:uSeR tAlK}}
10822 !! wikitext
10823 {{ns:uSeR tAlK}}
10824 !! html
10825 <p>User talk
10826 </p>
10827 !! end
10828
10829 !! test
10830 Namespace File {{ns:File}}
10831 !! wikitext
10832 {{ns:File}}
10833 !! html
10834 <p>File
10835 </p>
10836 !! end
10837
10838 !! test
10839 Namespace File {{ns:Image}}
10840 !! wikitext
10841 {{ns:Image}}
10842 !! html
10843 <p>File
10844 </p>
10845 !! end
10846
10847 !! test
10848 Namespace (lang=de) Benutzer {{ns:User}}
10849 !! options
10850 language=de
10851 !! wikitext
10852 {{ns:User}}
10853 !! html
10854 <p>Benutzer
10855 </p>
10856 !! end
10857
10858 !! test
10859 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
10860 !! options
10861 language=de
10862 !! wikitext
10863 {{ns:3}}
10864 !! html
10865 <p>Benutzer Diskussion
10866 </p>
10867 !! end
10868
10869 !! test
10870 Urlencode
10871 !! wikitext
10872 {{urlencode:hi world?!}}
10873 {{urlencode:hi world?!|WIKI}}
10874 {{urlencode:hi world?!|PATH}}
10875 {{urlencode:hi world?!|QUERY}}
10876 !! html/php
10877 <p>hi+world%3F%21
10878 hi_world%3F!
10879 hi%20world%3F%21
10880 hi+world%3F%21
10881 </p>
10882 !! end
10883
10884 !! test
10885 Magic Word: prioritize type info over data-parsoid
10886 !! options
10887 parsoid=html2wt
10888 !! html/parsoid
10889 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
10890 !! wikitext
10891 __FORCETOC__
10892 !! end
10893
10894 !! test
10895 Magic Word: serialize on separate line (parsoid)
10896 !! options
10897 parsoid=wt2wt,html2wt
10898 !! wikitext
10899 foo
10900 __NOTOC__
10901 bar
10902 !! html/parsoid
10903 foo<meta property="mw:PageProp/notoc"/>bar
10904 !! end
10905
10906 !! test
10907 Magic Word: rt non-english wikis
10908 !! options
10909 parsoid=wt2wt
10910 language=de
10911 !! wikitext
10912 __NOEDITSECTION__
10913 !! html/parsoid
10914 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
10915 !! end
10916
10917 !!test
10918 __proto__ is treated as normal wikitext (T105997)
10919 !!wikitext
10920 __proto__
10921 !!html
10922 <p>__proto__
10923 </p>
10924 !!end
10925
10926 ###
10927 ### Magic links
10928 ###
10929 !! test
10930 Magic links: internal link to RFC (T2479)
10931 !! wikitext
10932 [[RFC 123]]
10933 !! html/php
10934 <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>
10935 </p>
10936 !! html/parsoid
10937 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
10938 !! end
10939
10940 !! test
10941 Magic links: RFC (T2479)
10942 !! wikitext
10943 RFC 822
10944 !! html/php
10945 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
10946 </p>
10947 !! html/parsoid
10948 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external text">RFC 822</a></p>
10949 !! end
10950
10951 !! test
10952 Magic links: RFC (T67278)
10953 !! wikitext
10954 This is RFC 822 but thisRFC 822 is not RFC 822linked.
10955 !! html/php
10956 <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.
10957 </p>
10958 !! html/parsoid
10959 <p>This is <a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external text">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
10960 !! end
10961
10962 !! test
10963 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
10964 !! wikitext
10965 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
10966 RFC
10967 822
10968 !! html/php
10969 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
10970 RFC
10971 822
10972 </p>
10973 !! html/parsoid
10974 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external text">RFC <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 822</a>
10975 RFC
10976 822</p>
10977 !! end
10978
10979 !! test
10980 Magic links: ISBN (T3937)
10981 !! wikitext
10982 ISBN 0-306-40615-2
10983 !! html/php
10984 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
10985 </p>
10986 !! html/parsoid
10987 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
10988 !! end
10989
10990 !! test
10991 Magic links: ISBN (T67278)
10992 !! wikitext
10993 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
10994 !! html/php
10995 <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.
10996 </p>
10997 !! html/parsoid
10998 <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>
10999 !! end
11000
11001 !! test
11002 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
11003 !! wikitext
11004 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
11005 ISBN
11006 9780316098113
11007 ISBN 978
11008 0316098113
11009 !! html/php
11010 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
11011 ISBN
11012 9780316098113
11013 ISBN 978
11014 0316098113
11015 </p>
11016 !! html/parsoid
11017 <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>
11018 ISBN
11019 9780316098113
11020 ISBN 978
11021 0316098113</p>
11022 !! end
11023
11024 !! test
11025 Magic links: PMID incorrectly converts space to underscore
11026 !! wikitext
11027 PMID 1234
11028 !! html/php
11029 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11030 </p>
11031 !! html/parsoid
11032 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external text">PMID 1234</a></p>
11033 !! end
11034
11035 !! test
11036 Magic links: PMID (T67278)
11037 !! wikitext
11038 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
11039 !! html/php
11040 <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.
11041 </p>
11042 !! html/parsoid
11043 <p>This is <a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external text">PMID 1234</a> but thisPMID 1234 is not PMID 1234linked.</p>
11044 !! end
11045
11046 !! test
11047 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
11048 !! wikitext
11049 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
11050 PMID
11051 1234
11052 !! html/php
11053 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11054 PMID
11055 1234
11056 </p>
11057 !! html/parsoid
11058 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external text">PMID <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 1234</a>
11059 PMID
11060 1234</p>
11061 !! end
11062
11063 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
11064 # since these are ExtLinkText, not MagicLinkText
11065 !! test
11066 Magic links: use appropriate serialization for "almost" magic links.
11067 !! wikitext
11068 X[[Special:BookSources/0978739256|foo]]
11069
11070 X[https://tools.ietf.org/html/rfc1234 foo]
11071 !! html/php
11072 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
11073 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
11074 </p>
11075 !! html/parsoid
11076 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11077 <p>X<a rel="mw:ExtLink" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
11078 !! end
11079
11080 !! test
11081 Magic links: All disabled (T47942)
11082 !! options
11083 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11084 !! wikitext
11085 ISBN 0-306-40615-2
11086 PMID 1234
11087 RFC 4321
11088 !! html/php
11089 <p>ISBN 0-306-40615-2
11090 PMID 1234
11091 RFC 4321
11092 </p>
11093 !! end
11094
11095 ###
11096 ### Templates
11097 ####
11098
11099 !! test
11100 Nonexistent template
11101 !! wikitext
11102 {{thistemplatedoesnotexist}}
11103 !! html
11104 <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>
11105 </p>
11106 !! end
11107
11108 !! test
11109 Template with invalid target containing tags
11110 !! wikitext
11111 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11112 !! html
11113 <p>{{a<b>b</b>|foo|a=b|a = b}}
11114 </p>
11115 !! end
11116
11117 !! test
11118 Template with invalid target containing unclosed tag
11119 !! wikitext
11120 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11121 !! html
11122 <p>{{a<b>|foo|a=b|a = b}}</b>
11123 </p>
11124 !! end
11125
11126 !! test
11127 Template with invalid target containing wikilink
11128 !! wikitext
11129 {{[[Main Page]]}}
11130 !! html/php
11131 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11132 </p>
11133 !! html/parsoid
11134 <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>
11135 !! end
11136
11137 !! test
11138 Template with just whitespace in it, T70421
11139 !! wikitext
11140 {{echo|{{ }}}}
11141 !! html/parsoid
11142 <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>
11143 !! end
11144
11145 !! article
11146 Template:test
11147 !! text
11148 This is a test template
11149 !! endarticle
11150
11151 !! test
11152 Simple template
11153 !! wikitext
11154 {{test}}
11155 !! html
11156 <p>This is a test template
11157 </p>
11158 !! end
11159
11160 !! test
11161 Template with explicit namespace
11162 !! wikitext
11163 {{Template:test}}
11164 !! html
11165 <p>This is a test template
11166 </p>
11167 !! end
11168
11169
11170 !! article
11171 Template:paramtest
11172 !! text
11173 This is a test template with parameter {{{param}}}
11174 !! endarticle
11175
11176 !! test
11177 Template parameter
11178 !! wikitext
11179 {{paramtest|param=foo}}
11180 !! html
11181 <p>This is a test template with parameter foo
11182 </p>
11183 !! end
11184
11185 !! article
11186 Template:paramtestnum
11187 !! text
11188 [[{{{1}}}|{{{2}}}]]
11189 !! endarticle
11190
11191 !! test
11192 Template unnamed parameter
11193 !! wikitext
11194 {{paramtestnum|Main Page|the main page}}
11195 !! html
11196 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11197 </p>
11198 !! end
11199
11200 !! article
11201 Template:templatesimple
11202 !! text
11203 (test)
11204 !! endarticle
11205
11206 !! article
11207 Template:templateredirect
11208 !! text
11209 #redirect [[Template:templatesimple]]
11210 !! endarticle
11211
11212 !! article
11213 Template:templateasargtestnum
11214 !! text
11215 {{{{{1}}}}}
11216 !! endarticle
11217
11218 !! article
11219 Template:templateasargtest
11220 !! text
11221 {{template{{{templ}}}}}
11222 !! endarticle
11223
11224 !! article
11225 Template:templateasargtest2
11226 !! text
11227 {{{{{templ}}}}}
11228 !! endarticle
11229
11230 !! test
11231 Template with template name as unnamed argument
11232 !! wikitext
11233 {{templateasargtestnum|templatesimple}}
11234 !! html
11235 <p>(test)
11236 </p>
11237 !! end
11238
11239 !! test
11240 Template with template name as argument
11241 !! wikitext
11242 {{templateasargtest|templ=simple}}
11243 !! html
11244 <p>(test)
11245 </p>
11246 !! end
11247
11248 !! test
11249 Template with template name as argument (2)
11250 !! wikitext
11251 {{templateasargtest2|templ=templatesimple}}
11252 !! html
11253 <p>(test)
11254 </p>
11255 !! end
11256
11257 !! article
11258 Template:templateasargtestdefault
11259 !! text
11260 {{{{{templ|templatesimple}}}}}
11261 !! endarticle
11262
11263 !! article
11264 Template:templa
11265 !! text
11266 '''templ'''
11267 !! endarticle
11268
11269 !! test
11270 Template with default value
11271 !! wikitext
11272 {{templateasargtestdefault}}
11273 !! html
11274 <p>(test)
11275 </p>
11276 !! end
11277
11278 !! test
11279 Template with default value (value set)
11280 !! wikitext
11281 {{templateasargtestdefault|templ=templa}}
11282 !! html
11283 <p><b>templ</b>
11284 </p>
11285 !! end
11286
11287 !! test
11288 Template redirect
11289 !! wikitext
11290 {{templateredirect}}
11291 !! html/php
11292 <p>(test)
11293 </p>
11294 !! html/parsoid
11295 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11296 !! end
11297
11298 !! test
11299 Template with argument in separate line
11300 !! wikitext
11301 {{ templateasargtest |
11302 templ = simple }}
11303 !! html
11304 <p>(test)
11305 </p>
11306 !! end
11307
11308 !! test
11309 Template with complex template as argument
11310 !! wikitext
11311 {{paramtest|
11312 param ={{ templateasargtest |
11313 templ = simple }}}}
11314 !! html
11315 <p>This is a test template with parameter (test)
11316 </p>
11317 !! end
11318
11319 !! test
11320 Templates with templated name
11321 !! wikitext
11322 {{{{echo|echo}}|foo}}
11323 {{{{echo|inner list}} }}
11324 !! html
11325 <p>foo
11326 </p>
11327 <ul><li>item 1</li></ul>
11328
11329 !! html/parsoid
11330 <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>
11331 <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>
11332 !! end
11333
11334 ## Regression test; the output here isn't really that interesting.
11335 !! test
11336 Templates with templated name and top level template args
11337 !! wikitext
11338 {{1{{2{{{3}}}|4=5}}}}
11339 !! html/parsoid
11340 <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>
11341 !! end
11342
11343 # Parsoid markup is deliberate "broken". This is an edge case.
11344 # See long comment in TemplateHandler.js:convertAttribsToString.
11345 !! test
11346 Templates with invalid templated targets
11347 !! wikitext
11348 {{echo
11349 {{echo|foo}}
11350 }}
11351 !! html/php
11352 <p>{{echo
11353 foo
11354 }}
11355 </p>
11356 !! html/parsoid
11357 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11358 foo }}</p>
11359 !! end
11360
11361 !! test
11362 Template with thumb image (with link in description)
11363 !! wikitext
11364 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11365 !! html/php
11366 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>
11367
11368 !! html+tidy
11369 <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>
11370 !! html/parsoid
11371 <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>
11372 !! end
11373
11374 !! article
11375 Template:complextemplate
11376 !! text
11377 {{{1}}} {{paramtest|
11378 param ={{{param}}}}}
11379 !! endarticle
11380
11381 !! test
11382 Template with complex arguments
11383 !! wikitext
11384 {{complextemplate|
11385 param ={{ templateasargtest |
11386 templ = simple }}|[[Template:complextemplate|link]]}}
11387 !! html
11388 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11389 </p>
11390 !! end
11391
11392 !! test
11393 T2553: link with two variables in a piped link
11394 !! wikitext
11395 {|
11396 |[[{{{1}}}|{{{2}}}]]
11397 |}
11398 !! html/php
11399 <table>
11400 <tr>
11401 <td>[[{{{1}}}|{{{2}}}]]
11402 </td></tr></table>
11403
11404 !! html/parsoid
11405 <table>
11406 <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>
11407 </tbody></table>
11408 !! end
11409
11410 # See: T2553
11411 !! test
11412 Abort table cell attribute parsing on wikilink
11413 !! wikitext
11414 {|
11415 |testing [[one|two]] |three||four
11416 |testing one two |three||four
11417 |testing="[[one|two]]" |three||four
11418 |}
11419 !! html/php
11420 <table>
11421 <tr>
11422 <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>
11423 <td>four
11424 </td>
11425 <td>three</td>
11426 <td>four
11427 </td>
11428 <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>
11429 <td>four
11430 </td></tr></table>
11431
11432 !! html/parsoid
11433 <table>
11434 <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>
11435 <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>
11436 <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>
11437 </tbody></table>
11438 !! end
11439
11440 !! test
11441 Don't abort table cell attribute parsing if wikilink is found in template arg
11442 !! wikitext
11443 {|
11444 |Test {{#tag:ref|One two "[[three]]" four}}
11445 |}
11446 !! html/parsoid
11447 <table>
11448 <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>
11449 </tbody></table>
11450 !! end
11451
11452 !! test
11453 Magic variable as template parameter
11454 !! wikitext
11455 {{paramtest|param={{SITENAME}}}}
11456 !! html
11457 <p>This is a test template with parameter MediaWiki
11458 </p>
11459 !! end
11460
11461 !! article
11462 Template:linktest
11463 !! text
11464 [[{{{param}}}|link]]
11465 !! endarticle
11466
11467 !! test
11468 Template parameter as link source
11469 !! wikitext
11470 {{linktest|param=Main Page}}
11471 !! html
11472 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11473 </p>
11474 !! end
11475
11476 !!article
11477 Template:paramtest2
11478 !! text
11479 including another template, {{paramtest|param={{{arg}}}}}
11480 !! endarticle
11481
11482 !! test
11483 Template passing argument to another template
11484 !! wikitext
11485 {{paramtest2|arg='hmm'}}
11486 !! html
11487 <p>including another template, This is a test template with parameter 'hmm'
11488 </p>
11489 !! end
11490
11491 !! article
11492 Template:Linktest2
11493 !! text
11494 Main Page
11495 !! endarticle
11496
11497 !! test
11498 Template as link source
11499 !! wikitext
11500 [[{{linktest2}}]]
11501
11502 [[{{linktest2}}|Main Page]]
11503
11504 [[{{linktest2}}]]Page
11505 !! html
11506 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11507 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11508 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11509 </p>
11510 !! end
11511
11512
11513 !! article
11514 Template:loop1
11515 !! text
11516 {{loop2}}
11517 !! endarticle
11518
11519 !! article
11520 Template:loop2
11521 !! text
11522 {{loop1}}
11523 !! endarticle
11524
11525 !! test
11526 Template infinite loop
11527 !! wikitext
11528 {{loop1}}
11529 !! html
11530 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11531 </p>
11532 !! end
11533
11534 !! test
11535 Template from main namespace
11536 !! wikitext
11537 {{:Main Page}}
11538 !! html
11539 <p>blah blah
11540 </p>
11541 !! end
11542
11543 !! test
11544 Template from non-includable namespace
11545 !! options
11546 wgNonincludableNamespaces=10
11547 !! wikitext
11548 {{echo|uh oh!}}
11549 !! html
11550 <p><a href="/wiki/Template:Echo" title="Template:Echo">Template:Echo</a>
11551 </p>
11552 !! end
11553
11554 !! article
11555 Template:table
11556 !! text
11557 {|
11558 | 1 || 2
11559 |-
11560 | 3 || 4
11561 |}
11562 !! endarticle
11563
11564 !! test
11565 T2529: Template with table, not included at beginning of line
11566 !! wikitext
11567 foo {{table}}
11568 !! html
11569 <p>foo
11570 </p>
11571 <table>
11572 <tr>
11573 <td>1</td>
11574 <td>2
11575 </td></tr>
11576 <tr>
11577 <td>3</td>
11578 <td>4
11579 </td></tr></table>
11580
11581 !! end
11582
11583 !! test
11584 T2523: Template shouldn't eat newline (or add an extra one before table)
11585 !! wikitext
11586 foo
11587 {{table}}
11588 !! html
11589 <p>foo
11590 </p>
11591 <table>
11592 <tr>
11593 <td>1</td>
11594 <td>2
11595 </td></tr>
11596 <tr>
11597 <td>3</td>
11598 <td>4
11599 </td></tr></table>
11600
11601 !! end
11602
11603 !! test
11604 T2041: Template parameters shown as broken links
11605 !! wikitext
11606 {{{parameter}}}
11607 !! html
11608 <p>{{{parameter}}}
11609 </p>
11610 !! end
11611
11612 !! test
11613 Template with targets containing wikilinks
11614 !! options
11615 parsoid=wt2html
11616 !! wikitext
11617 {{[[foo]]}}
11618
11619 {{[[{{echo|foo}}]]}}
11620
11621 {{{{echo|[[foo}}]]}}
11622 !! html/php
11623 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11624 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11625 </p><p>{{[[foo}}]]
11626 </p>
11627 !! html/parsoid
11628 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11629 <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>
11630 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11631 !! end
11632
11633 !! article
11634 Template:''
11635 !! text
11636 bar
11637 !! endarticle
11638
11639 !! test
11640 Templates: Double quotes as template target
11641 !! wikitext
11642 foo {{''}} baz
11643 !! html/php
11644 <p>foo bar baz
11645 </p>
11646 !! html/parsoid
11647 <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
11648 </p>
11649 !! end
11650
11651 ## This test is about making sure Parsoid's data-mw is well formed in the
11652 ## face of multiple templates with intersecting and overlapping ranges. The
11653 ## wikitext itself is wretched.
11654 !! test
11655 Templates with intersecting and overlapping ranges
11656 !! wikitext
11657 {|{{echo|
11658 <p>ha</p>}}
11659 {|{{echo|
11660 <p>ho</p>}}
11661 {{echo|{{!}}hi}}
11662 |}
11663 !! html/php+tidy
11664 <p>ha</p><table>
11665
11666 </table><p>ho</p><table>
11667
11668 <tbody><tr>
11669 <td>hi
11670 </td></tr></tbody></table>
11671 !! html/parsoid
11672 <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":""}]]}'>
11673
11674 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11675
11676 <tbody><tr><td>hi</td></tr>
11677 </tbody></table>
11678 !! end
11679
11680 !! article
11681 Template:MSGNW test
11682 !! text
11683 ''None'' of '''this''' should be
11684 * interpreted
11685 but rather passed unmodified
11686 {{test}}
11687 <gallery>
11688 File:Foobar.jpg
11689 </gallery>
11690 <!-- comment -->
11691 !! endarticle
11692
11693 # hmm, fix this or just deprecate msgnw and document its behavior?
11694 !! test
11695 msgnw keyword
11696 !! wikitext
11697 {{msgnw:MSGNW test}}
11698 !! html/php
11699 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11700 &#42; interpreted
11701 &#32;but rather passed unmodified
11702 &#123;&#123;test&#125;&#125;
11703 &#60;gallery&#62;
11704 File:Foobar.jpg
11705 &#60;/gallery&#62;
11706 &#60;!-- comment --&#62;
11707 </p>
11708 !! end
11709
11710 !! test
11711 int keyword
11712 !! wikitext
11713 {{int:youhavenewmessages|lots of money|not!}}
11714 !! html
11715 <p>You have lots of money (not!).
11716 </p>
11717 !! end
11718
11719 !! test
11720 int keyword - non-existing message
11721 !! wikitext
11722 {{int:var}}
11723 !! html
11724 <p>⧼var⧽
11725 </p>
11726 !! end
11727
11728 !! article
11729 Template:Includes
11730 !! text
11731 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11732 !! endarticle
11733
11734 !! test
11735 <includeonly> and <noinclude> being included
11736 !! wikitext
11737 {{Includes}}
11738 !! html
11739 <p>Foobar
11740 </p>
11741 !! end
11742
11743 !! article
11744 Template:Includes2
11745 !! text
11746 <onlyinclude>Foo</onlyinclude>bar
11747 !! endarticle
11748
11749 !! test
11750 <onlyinclude> being included
11751 !! wikitext
11752 {{Includes2}}
11753 !! html
11754 <p>Foo
11755 </p>
11756 !! end
11757
11758
11759 !! article
11760 Template:Includes3
11761 !! text
11762 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
11763 !! endarticle
11764
11765 !! test
11766 <onlyinclude> and <includeonly> being included
11767 !! wikitext
11768 {{Includes3}}
11769 !! html
11770 <p>Foo
11771 </p>
11772 !! end
11773
11774 !! test
11775 <includeonly> and <noinclude> on a page
11776 !! wikitext
11777 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11778 !! html
11779 <p>Foozar
11780 </p>
11781 !! end
11782
11783 !! test
11784 Un-closed <noinclude>
11785 !! wikitext
11786 <noinclude>
11787 !! html
11788 !! end
11789
11790 !! test
11791 <onlyinclude> on a page
11792 !! wikitext
11793 <onlyinclude>Foo</onlyinclude>bar
11794 !! html
11795 <p>Foobar
11796 </p>
11797 !! end
11798
11799 !! test
11800 Un-closed <onlyinclude>
11801 !! wikitext
11802 <onlyinclude>
11803 !! html
11804 !! end
11805
11806 !!test
11807 Self-closed noinclude, includeonly, onlyinclude tags
11808 !! wikitext
11809 <noinclude />
11810 <includeonly />
11811 <onlyinclude />
11812 !! html
11813 <p><br />
11814 </p>
11815 !!end
11816
11817 !!test
11818 Unbalanced includeonly and noinclude tags
11819 !! wikitext
11820 {|
11821 |a</noinclude>
11822 |b</noinclude></noinclude>
11823 |c</noinclude></includeonly>
11824 |d</includeonly></includeonly>
11825 |}
11826 !! html
11827 <table>
11828 <tr>
11829 <td>a
11830 </td>
11831 <td>b
11832 </td>
11833 <td>c&lt;/includeonly&gt;
11834 </td>
11835 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
11836 </td></tr></table>
11837
11838 !!end
11839
11840 !! article
11841 Template:Includeonly section
11842 !! text
11843 <includeonly>
11844 ==Includeonly section==
11845 </includeonly>
11846 ==Section T-1==
11847 !!endarticle
11848
11849 !! test
11850 T8563: Edit link generation for section shown by <includeonly>
11851 !! wikitext
11852 {{includeonly section}}
11853 !! html
11854 <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>
11855 <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>
11856
11857 !! end
11858
11859 # Uses same input as the contents of [[Template:Includeonly section]]
11860 !! test
11861 T8563: Section extraction for section shown by <includeonly>
11862 !! options
11863 section=T-2
11864 !! wikitext
11865 <includeonly>
11866 ==Includeonly section==
11867 </includeonly>
11868 ==Section T-2==
11869 !! html
11870 ==Section T-2==
11871 !! end
11872
11873 !! test
11874 T8563: Edit link generation for section suppressed by <includeonly>
11875 !! wikitext
11876 <includeonly>
11877 ==Includeonly section==
11878 </includeonly>
11879 ==Section 1==
11880 !! html
11881 <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>
11882
11883 !! end
11884
11885 !! test
11886 T8563: Section extraction for section suppressed by <includeonly>
11887 !! options
11888 section=1
11889 !! wikitext
11890 <includeonly>
11891 ==Includeonly section==
11892 </includeonly>
11893 ==Section 1==
11894 !! html
11895 ==Section 1==
11896 !! end
11897
11898 !! test
11899 Un-closed <includeonly>
11900 !! wikitext
11901 <includeonly>
11902 !! html/php
11903 !! html/parsoid
11904 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}'/>
11905 !! end
11906
11907 ## We used to, but no longer wt2wt this test since the default serializer
11908 ## will normalize the include directives to serialize on their own line.
11909 ## Selser will take care of preserving formatting in scenarios where they
11910 ## intermingled with other wikitext.
11911 !! test
11912 Includes and comments at SOL
11913 !! options
11914 parsoid=wt2html,html2html
11915 !! wikitext
11916 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->==hu==
11917
11918 <noinclude>
11919 some
11920 </noinclude>*stuff
11921 *here
11922
11923 <includeonly>can have stuff</includeonly>===here===
11924
11925 !! html/php
11926 <h2><span class="mw-headline" id="hu">hu</span></h2>
11927 <p>some
11928 </p>
11929 <ul><li>stuff</li>
11930 <li>here</li></ul>
11931 <h3><span class="mw-headline" id="here">here</span></h3>
11932
11933 !! html/parsoid
11934 <!-- 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>
11935
11936 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
11937 <p>some</p>
11938 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li>stuff</li>
11939 <li>here</li></ul>
11940
11941 <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>
11942
11943 !! end
11944
11945 # TODO: test with DOM fragment reuse!
11946 !! test
11947 Parsoid: DOM fragment reuse
11948 !! options
11949 parsoid=wt2wt,wt2html
11950 !! wikitext
11951 a{{echo|b<table></table>c}}d
11952
11953 a{{echo|b
11954 <table></table>
11955 c}}d
11956
11957 {{echo|a
11958
11959 <table></table>
11960
11961 b}}
11962 !! html
11963 <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>
11964
11965 <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">
11966 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
11967 </span><p about="#mwt2">cd</p>
11968
11969 <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">
11970
11971 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
11972
11973 </span><p about="#mwt3">b</p>
11974 !! end
11975
11976 !! test
11977 Parsoid: Merge double tds (T52603)
11978 !! options
11979 parsoid
11980 !! wikitext
11981 {|
11982 |{{echo|{{!}} foo}}
11983 |}
11984 !! html
11985 <table><tbody>
11986 <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>
11987 </tbody></table>
11988 !! end
11989
11990 !! test
11991 Parsoid: Merge double tds in nested transclusion content (T52603)
11992 !! options
11993 parsoid
11994 !! wikitext
11995 {{echo|<div>}}
11996 {|
11997 |{{echo|{{!}} foo}}
11998 |}
11999 {{echo|</div>}}
12000 !! html
12001 <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}}]}'>
12002 <table><tbody>
12003 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
12004 </tbody></table>
12005 </div>
12006 !! end
12007
12008 ###
12009 ### <includeonly> and <noinclude> in attributes
12010 ###
12011 !!test
12012 0. includeonly around the entire attribute
12013 !! wikitext
12014 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
12015 !! html
12016 <p><span id="v2">bar</span>
12017 </p>
12018 !!end
12019
12020 !!test
12021 1. includeonly in html attr key
12022 !! wikitext
12023 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
12024 !! html
12025 <p><span id="foo">bar</span>
12026 </p>
12027 !!end
12028
12029 !!test
12030 2. includeonly in html attr value
12031 !! wikitext
12032 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
12033 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
12034 !! html
12035 <p><span id="v1">bar</span>
12036 <span id="v1">bar</span>
12037 </p>
12038 !!end
12039
12040 !!test
12041 3. includeonly in part of an attr value
12042 !! wikitext
12043 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
12044 !! html
12045 <p><span style="color:red;">bar</span>
12046 </p>
12047 !!end
12048
12049 !!test
12050 4. includeonly in table attributes
12051 !! wikitext
12052 {|
12053 |- <noinclude>
12054 |-
12055 |a
12056 </noinclude>
12057 |- <includeonly>
12058 |-
12059 |b
12060 </includeonly>
12061 |}
12062 !! html
12063 <table>
12064
12065
12066 <tr>
12067 <td>a
12068 </td></tr>
12069 </table>
12070
12071 !!end
12072
12073 ###
12074 ### Preprocessor precedence tests
12075 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
12076 ###
12077 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
12078 !! test
12079 Preprocessor precedence 1: link is rightmost opening
12080 !! options
12081 parsoid=wt2html
12082 !! wikitext
12083 {{[[Foo|bar}}]]
12084
12085 But close-brace is not a valid character in a link title:
12086 {{[[Foo}}|bar]]
12087
12088 However, we can still tell this was handled as a link in the preprocessor:
12089 {{echo|[[Foo}}|bar]]|bat}}
12090 !! html/php
12091 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12092 </p><p>But close-brace is not a valid character in a link title:
12093 {{[[Foo}}|bar]]
12094 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12095 [[Foo}}|bar]]
12096 </p>
12097 !! html/parsoid
12098 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12099 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12100 <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>
12101 !! end
12102
12103 !! test
12104 Preprocessor precedence 2: template is rightmost opening
12105 !! options
12106 language=zh
12107 !! wikitext
12108 -{{echo|foo}-}}-
12109 !! html/php
12110 <p>-foo}--
12111 </p>
12112 !! html/parsoid
12113 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12114 !! end
12115
12116 !! test
12117 Preprocessor precedence 3: language converter is rightmost opening
12118 !! options
12119 language=zh
12120 parsoid=wt2html
12121 !! wikitext
12122 {{echo|hi}}
12123
12124 {{-{R|echo|hi}}}-
12125
12126 [[-{R|raw]]}-
12127 !! html/php
12128 <p>hi
12129 </p><p>{{echo|hi}}
12130 </p><p>[[raw]]
12131 </p>
12132 !! html/parsoid
12133 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12134 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12135 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12136 !! end
12137
12138 !! test
12139 Preprocessor precedence 4: left-most angle bracket
12140 !! options
12141 language=zh
12142 !! wikitext
12143 <!--{raw}-->
12144 !! html/php
12145 !! html/parsoid
12146 <!--{raw}-->
12147 !! end
12148
12149 !! article
12150 Template:Precedence5
12151 !! text
12152 {{{{{1}}}}}
12153 !! endarticle
12154
12155 !! test
12156 Preprocessor precedence 5: tplarg takes precedence over template
12157 !! wikitext
12158 {{Precedence5|Bullet}}
12159 !! html/php
12160 <ul><li>Bar</li></ul>
12161
12162 !! html/parsoid
12163 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li>Bar</li></ul>
12164 !! end
12165
12166 !! test
12167 Preprocessor precedence 6: broken link is rightmost opening
12168 !! options
12169 parsoid=wt2html
12170 !! wikitext
12171 {{echo|[[Foo}}
12172
12173 {{echo|[[Foo|bar|bat=baz}}
12174 !! html/php
12175 <p>{{echo|[[Foo}}
12176 </p><p>{{echo|[[Foo|bar|bat=baz}}
12177 </p>
12178 !! html/parsoid
12179 <p>{{echo|[[Foo}}</p>
12180 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12181 !! end
12182
12183 # This next test exposes a difference between PHP and Parsoid:
12184 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12185 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12186 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12187 # outer `[[Foo` extends until the `y]]`
12188 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12189 # intermediate result (after template expansion), and link processing
12190 # happens on this intermediate result, which moves the wikilink
12191 # boundary leftward to `[[Foo|Bar]]`
12192 # 2b) Parsoid works in a single step, so it's going to keep the
12193 # wikilink as extending to the `y]]`
12194 # 3a) Then PHP does linktrail processing which slurps up the trailing
12195 # `xy` inside the link.
12196 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12197 # `z` inside the link.
12198 # This is "correct" behavior. Parsoid's basic worldview is that the
12199 # `]]` inside the template shouldn't be allowed to leak out to affect
12200 # the surrounding wikilink. PHP may match Parsoid (in the future)
12201 # if you use {{#balance}} (T114445).
12202
12203 !! test
12204 Preprocessor precedence 7: broken template is rightmost opening
12205 !! options
12206 parsoid=wt2html
12207 !! wikitext
12208 [[Foo|{{echo|Bar]]
12209
12210 [[Foo|{{echo|Bar]]-x}}-y]]-z
12211
12212 Careful: linktrails can move the end of the wikilink:
12213 [[Foo|{{echo|y']]a}}l]]l
12214 !! html/php
12215 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12216 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12217 </p><p>Careful: linktrails can move the end of the wikilink:
12218 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12219 </p>
12220 !! html/parsoid
12221 <p>[[Foo|{{echo|Bar]]</p>
12222 <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>
12223 <p>Careful: linktrails can move the end of the wikilink:
12224 <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>
12225 !! end
12226
12227 !! test
12228 Preprocessor precedence 8: broken language converter is rightmost opening
12229 !! options
12230 language=zh
12231 !! wikitext
12232 [[Foo-{R|raw]]
12233 !! html
12234 <p>[[Foo-{R|raw]]
12235 </p>
12236 !! end
12237
12238 !! article
12239 Template:Preprocessor_precedence_9
12240 !! text
12241 ;4: {{{{1}}}}
12242 ;5: {{{{{2}}}}}
12243 ;6: {{{{{{3}}}}}}
12244 ;7: {{{{{{{4}}}}}}}
12245 !! endarticle
12246
12247 !! test
12248 Preprocessor precedence 9: groups of braces
12249 !! wikitext
12250 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12251 !! html/php
12252 <dl><dt>4</dt>
12253 <dd>{Four}</dd>
12254 <dt>5</dt>
12255 <dd></dd></dl>
12256 <ul><li>Bar</li></ul>
12257 <dl><dt>6</dt>
12258 <dd>Four</dd>
12259 <dt>7</dt>
12260 <dd>{Bullet}</dd></dl>
12261
12262 !! html/parsoid
12263 <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}}]}'>
12264 <dt>4</dt>
12265 <dd>{Four}</dd>
12266 <dt>5</dt>
12267 <dd></dd>
12268 </dl><ul about="#mwt1">
12269 <li>Bar</li>
12270 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12271 <dt>6</dt>
12272 <dd>Four</dd>
12273 <dt>7</dt>
12274 <dd>{Bullet}</dd>
12275 </dl>
12276 !! end
12277
12278 !! article
12279 Template:Preprocessor_precedence_10
12280 !! text
12281 ;1: -{R|raw}-
12282 ;2: -{{Bullet}}-
12283 ;3: -{{{1}}}-
12284 ;4: -{{{{2}}}}-
12285 ;5: -{{{{{3}}}}}-
12286 ;6: -{{{{{{4}}}}}}-
12287 ;7: -{{{{{{{5}}}}}}}-
12288 !! endarticle
12289
12290 !! test
12291 Preprocessor precedence 10: groups of braces with leading dash
12292 !! options
12293 language=zh
12294 !! wikitext
12295 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12296 !! html/php
12297 <dl><dt>1</dt>
12298 <dd>raw</dd>
12299 <dt>2</dt>
12300 <dd>-</dd></dl>
12301 <ul><li>Bar-</li></ul>
12302 <dl><dt>3</dt>
12303 <dd>-Three-</dd>
12304 <dt>4</dt>
12305 <dd>raw2</dd>
12306 <dt>5</dt>
12307 <dd>-</dd></dl>
12308 <ul><li>Bar-</li></ul>
12309 <dl><dt>6</dt>
12310 <dd>-Three-</dd>
12311 <dt>7</dt>
12312 <dd>raw2</dd></dl>
12313
12314 !! html/parsoid
12315 <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}}]}'>
12316 <dt>1</dt>
12317 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12318 <dt>2</dt>
12319 <dd>-</dd>
12320 </dl><ul about="#mwt1">
12321 <li>Bar-</li>
12322 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12323 <dt>3</dt>
12324 <dd>-Three-</dd>
12325 <dt>4</dt>
12326 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12327 <dt>5</dt>
12328 <dd>-</dd>
12329 </dl><ul about="#mwt1">
12330 <li>Bar-</li>
12331 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12332 <dt>6</dt>
12333 <dd>-Three-</dd>
12334 <dt>7</dt>
12335 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12336 </dl>
12337 !! end
12338
12339 !! test
12340 Preprocessor precedence 11: found during visual diff testing
12341 !! wikitext
12342 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12343
12344 {{echo|-{{echo|-{{echo|x}}}}}}
12345
12346 {{echo|-{{echo|x}}}}
12347 !! html/php
12348 <p><span>-<span>-x</span></span>
12349 </p><p>--x
12350 </p><p>-x
12351 </p>
12352 !! html/parsoid
12353 <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>
12354
12355 <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>
12356
12357 <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>
12358 !! end
12359
12360 !! test
12361 Preprocessor precedence 12: broken language converter closed by brace.
12362 !! options
12363 parsoid=wt2html
12364 !! wikitext
12365 This form breaks the template, which is unfortunate:
12366 *{{echo|foo-{bar}bat}}
12367
12368 But if the broken language converter markup is inside an extension
12369 tag, nothing bad happens:
12370 *<nowiki>foo-{bar}bat</nowiki>
12371 *{{echo|<nowiki>foo-{bar}bat</nowiki>}}
12372 *<pre>foo-{bar}bat</pre>
12373 *{{echo|<pre>foo-{bar}bat</pre>}}
12374
12375 <tag>foo-{bar}bat</tag>
12376 {{echo|<tag>foo-{bar}bat</tag>}}
12377
12378 !! html/php+tidy
12379 <p>This form breaks the template, which is unfortunate:
12380 </p>
12381 <ul><li>{{echo|foo-{bar}bat}}</li></ul>
12382 <p>But if the broken language converter markup is inside an extension
12383 tag, nothing bad happens:
12384 </p>
12385 <ul><li>foo-&#123;bar}bat</li>
12386 <li>foo-&#123;bar}bat</li>
12387 <li><pre>foo-{bar}bat</pre></li>
12388 <li><pre>foo-{bar}bat</pre></li></ul>
12389 <pre>'foo-{bar}bat'
12390 array (
12391 )
12392 </pre>
12393 <pre>'foo-{bar}bat'
12394 array (
12395 )
12396 </pre>
12397 !! html/parsoid
12398 <p>This form breaks the template, which is unfortunate:</p>
12399 <ul>
12400 <li>{{echo|foo-{bar}bat}}</li>
12401 </ul>
12402 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12403 <ul>
12404 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12405 <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>
12406 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12407 <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>
12408 </ul>
12409 <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>
12410 !! end
12411
12412 !! test
12413 Preprocessor precedence 13: broken language converter in external link
12414 !! options
12415 parsoid=wt2html
12416 !! wikitext
12417 *[http://example.com/-{foo Example in URL]
12418 *[http://example.com Example in -{link} description]
12419 *{{echo|[http://example.com/-{foo Breaks template, however]}}
12420 !! html/php+tidy
12421 <ul><li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12422 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12423 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li></ul>
12424 !! html/parsoid
12425 <ul>
12426 <li><a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12427 <li><a rel="mw:ExtLink" class="external text" href="http://example.com">Example in -{link} description</a></li>
12428 <li>{{echo|<a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12429 </ul>
12430 !! end
12431
12432 !! test
12433 Preprocessor precedence 14: broken language converter in comment
12434 !! wikitext
12435 *<!--{{foo}}-->...should be ok
12436 *<!---{{foo}}-->...extra dashes
12437 *{{echo|foo<!-- -{bar} -->bat}}...should be ok
12438 !! html/php+tidy
12439 <ul><li>...should be ok</li>
12440 <li>...extra dashes</li>
12441 <li>foobat...should be ok</li></ul>
12442 !! html/parsoid
12443 <ul>
12444 <li><!--{{foo}}-->...should be ok</li>
12445 <li><!--&#x2D;{{foo}}-->...extra dashes</li>
12446 <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>
12447 </ul>
12448 !! end
12449
12450 !! test
12451 Preprocessor precedence 15: broken brace markup in headings
12452 !! config
12453 wgFragmentMode=[ 'html5', 'legacy' ]
12454 !! options
12455 parsoid=wt2html
12456 !! wikitext
12457 __NOTOC__ __NOEDITSECTION__
12458 ===1 foo[bar 1===
12459 1
12460 ===2 foo[[bar 2===
12461 2
12462 ===3 foo{bar 3===
12463 3
12464 ===4 foo{{bar 4===
12465 4
12466 ===5 foo{{{bar 5===
12467 5
12468 ===6 foo-{bar 6===
12469 6
12470 !! html/php+tidy
12471 <h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3>
12472 <p>1
12473 </p>
12474 <h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3>
12475 <p>2
12476 </p>
12477 <h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3>
12478 <p>3
12479 </p>
12480 <h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3>
12481 <p>4
12482 </p>
12483 <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>
12484 <p>5
12485 </p>
12486 <h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3>
12487 <p>6
12488 </p>
12489 !! html/parsoid
12490 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/>
12491 <h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3>
12492 <p>1</p>
12493 <h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3>
12494 <p>2</p>
12495 <h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3>
12496 <p>3</p>
12497 <h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3>
12498 <p>4</p>
12499 <h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3>
12500 <p>5</p>
12501 <h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3>
12502 <p>6</p>
12503 !! end
12504
12505 !! test
12506 Preprocessor precedence 16: matching closing braces to opening braces
12507 !! options
12508 language=zh
12509 parsoid=wt2html
12510 !! wikitext
12511 -{{{echo|foo}}bar}-
12512 !! html/php
12513 <p>foobar
12514 </p>
12515 !! html/parsoid
12516 <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>
12517 !! end
12518
12519 !! test
12520 Preprocessor precedence 17: template w/o target shouldn't prevent closing
12521 !! options
12522 parsoid=wt2html
12523 !! wikitext
12524 {{echo|hi {{}}}}
12525 !! html/php
12526 <p>hi {{}}
12527 </p>
12528 !! html/parsoid
12529 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p>
12530 !! end
12531
12532 !! test
12533 Preprocessor precedence 18: another rightmost wins scenario
12534 !! options
12535 parsoid=wt2html
12536 !! wikitext
12537 {{ -{{{{1|tplarg}}} }} }-
12538 !! html/php
12539 <p>{{ -{tplarg }} }-
12540 </p>
12541 !! html/parsoid
12542 <p>{{ -{<span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"1"},"params":{"1":{"wt":"tplarg"}},"i":0}}]}'>tplarg</span> }} }-</p>
12543 !! end
12544
12545 !! test
12546 Preprocessor precedence 19: break syntax
12547 !! options
12548 parsoid=wt2html
12549 !! wikitext
12550 -{{
12551 !! html/php
12552 <p>-{{
12553 </p>
12554 !! html/parsoid
12555 <p>-{{</p>
12556 !! end
12557
12558 ###
12559 ### Token Stream Patcher tests
12560 ###
12561 ### These tests won't always pass wt2wt and other modes because
12562 ### on serialization, the table will be output on a new line.
12563 ### For now, we are blacklisting them, and using this to test selser.
12564 ###
12565
12566 !!test
12567 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12568 !!options
12569 parsoid=wt2html,wt2wt
12570 !!wikitext
12571 {{echo|}}{| width = '100%'
12572 |foo
12573 |}
12574 !!html/parsoid
12575 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12576 <tbody><tr><td>foo</td></tr>
12577 </tbody></table>
12578 !!end
12579
12580 ## We used to, but no longer wt2wt this test since the default serializer
12581 ## will normalize the include directives to serialize on their own line.
12582 ## Selser will take care of preserving formatting in scenarios where they
12583 ## intermingled with other wikitext.
12584 !!test
12585 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12586 !!options
12587 parsoid=wt2html
12588 !!wikitext
12589 <includeonly>a</includeonly>{| {{{b}}}
12590 |c
12591 |}
12592 !!html/parsoid
12593 <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":""}]]}'>
12594 <tbody><tr><td>c</td></tr>
12595 </tbody></table>
12596 !!end
12597
12598 !! test
12599 Table wikitext syntax outside wiki-tables
12600 !! wikitext
12601 a
12602 |+ not a caption
12603 ! not a table heading
12604 |- not a table row
12605 | not a table cell
12606 | class="foo bar" | baz
12607 b
12608 |}
12609 |-
12610 c
12611 !! html
12612 <p>a
12613 |+ not a caption
12614 ! not a table heading
12615 |- not a table row
12616 | not a table cell
12617 | class="foo bar" | baz
12618 b
12619 |}
12620 |-
12621 c
12622 </p>
12623 !! end
12624
12625 ###
12626 ### Testing parsing of templates where a template arg
12627 ### has the same name as the template itself.
12628 ###
12629
12630 !! article
12631 Template:quote
12632 !! text
12633 {{{quote|{{{1}}}}}}
12634 !! endarticle
12635
12636 !!test
12637 Templates: Template Name/Arg clash: 1. Use of positional param
12638 !! wikitext
12639 {{quote|foo}}
12640 !! html
12641 <p>foo
12642 </p>
12643 !!end
12644
12645 !!test
12646 Templates: Template Name/Arg clash: 2. Use of named param
12647 !! wikitext
12648 {{quote|quote=foo}}
12649 !! html
12650 <p>foo
12651 </p>
12652 !!end
12653
12654 !!test
12655 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12656 !! wikitext
12657 {{quote|quote}}
12658 !! html
12659 <p>quote
12660 </p>
12661 !!end
12662
12663 ###
12664 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12665 ###
12666
12667 !!test
12668 Templates: 1. Simple use
12669 !! wikitext
12670 {{echo|Foo}}
12671 !! html
12672 <p>Foo
12673 </p>
12674 !!end
12675
12676 !!test
12677 Templates: 2. Inside a block tag
12678 !! wikitext
12679 <div>{{echo|Foo}}</div>
12680 <blockquote>{{echo|Foo}}</blockquote>
12681 !! html
12682 <div>Foo</div>
12683 <blockquote>Foo</blockquote>
12684
12685 !! html+tidy
12686 <div>Foo</div>
12687 <blockquote><p>Foo</p></blockquote>
12688 !!end
12689
12690 !!test
12691 Templates: P-wrapping: 1a. Templates on consecutive lines
12692 !! wikitext
12693 {{echo|Foo}}
12694 {{echo|bar}}
12695 !! html
12696 <p>Foo
12697 bar
12698 </p>
12699 !!end
12700
12701 !!test
12702 Templates: P-wrapping: 1b. Templates on consecutive lines
12703 !! wikitext
12704 Foo
12705
12706 {{echo|bar}}
12707 {{echo|baz}}
12708 !! html
12709 <p>Foo
12710 </p><p>bar
12711 baz
12712 </p>
12713 !!end
12714
12715 !!test
12716 Templates: P-wrapping: 1c. Templates on consecutive lines
12717 !! wikitext
12718 {{echo|Foo}}
12719 {{echo|bar}} <div>baz</div>
12720 !! html
12721 <p>Foo
12722 </p>
12723 bar <div>baz</div>
12724
12725 !! html+tidy
12726 <p>Foo
12727 </p><p>
12728 bar </p><div>baz</div>
12729 !! end
12730
12731 !!test
12732 Templates: P-wrapping: 1d. Template preceded by comment-only line
12733 !!options
12734 parsoid
12735 !! wikitext
12736 <!-- foo -->
12737 {{echo|Bar}}
12738 !! html
12739 <!-- foo -->
12740
12741 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
12742 !!end
12743
12744 !!test
12745 Templates: Inline Text: 1. Multiple template uses
12746 !! wikitext
12747 {{echo|Foo}}bar{{echo|baz}}
12748 !! html
12749 <p>Foobarbaz
12750 </p>
12751 !!end
12752
12753 !!test
12754 Templates: Inline Text: 2. Back-to-back template uses
12755 !! wikitext
12756 {{echo|Foo}}{{echo|bar}}
12757 !! html
12758 <p>Foobar
12759 </p>
12760 !!end
12761
12762 !!test
12763 Templates: Block Tags: 1. Multiple template uses
12764 !! wikitext
12765 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
12766 !! html
12767 <div>Foo</div><div>bar</div><div>baz</div>
12768
12769 !!end
12770
12771 !!test
12772 Templates: Block Tags: 2. Back-to-back template uses
12773 !! wikitext
12774 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
12775 !! html
12776 <div>Foo</div><div>bar</div>
12777
12778 !!end
12779
12780 # This is an edge case relating to paragraph wrapping.
12781 !!test
12782 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
12783 !! wikitext
12784 {{echo|a
12785 b</p>}}
12786 !! html/parsoid
12787 <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
12788 b</p>
12789 !!end
12790
12791 !!test
12792 Templates: Links: 1. Simple example
12793 !! wikitext
12794 {{echo|[[Foo|bar]]}}
12795 !! html
12796 <p><a href="/wiki/Foo" title="Foo">bar</a>
12797 </p>
12798 !!end
12799
12800 !!test
12801 Templates: Links: 2. Generation of link href
12802 !! wikitext
12803 [[{{echo|Foo}}|bar]]
12804 !! html
12805 <p><a href="/wiki/Foo" title="Foo">bar</a>
12806 </p>
12807 !!end
12808
12809 !!test
12810 Templates: Links: 3. Generation of part of a link href
12811 !! wikitext
12812 [[Fo{{echo|o}}|bar]]
12813
12814 [[Foo{{echo|bar}}]]
12815
12816 [[Foo{{echo|bar}}baz]]
12817
12818 [[Foo{{echo|bar}}|bar]]
12819
12820 [[:Foo{{echo|bar}}]]
12821
12822 [[:Foo{{echo|bar}}|bar]]
12823 !! html
12824 <p><a href="/wiki/Foo" title="Foo">bar</a>
12825 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12826 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
12827 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12828 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12829 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12830 </p>
12831 !!end
12832
12833 !!test
12834 Templates: Links: 4. Multiple templates generating link href
12835 !! wikitext
12836 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
12837 !! html
12838 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12839 </p>
12840 !!end
12841
12842 !!test
12843 Templates: Links: 5. Generation of link text
12844 !! wikitext
12845 [[Foo|{{echo|bar}}]]
12846 !! html
12847 <p><a href="/wiki/Foo" title="Foo">bar</a>
12848 </p>
12849 !!end
12850
12851 !!test
12852 Templates: Links: 5. Nested templates (only outermost template should be marked)
12853 !! wikitext
12854 {{echo|[[{{echo|Foo}}|bar]]}}
12855 !! html
12856 <p><a href="/wiki/Foo" title="Foo">bar</a>
12857 </p>
12858 !!end
12859
12860 !!test
12861 Templates: HTML Tag: 1. Generation of HTML attr. key
12862 !! wikitext
12863 <div {{echo|style}}="color:red;">foo</div>
12864 !! html
12865 <div style="color:red;">foo</div>
12866
12867 !!end
12868
12869 !!test
12870 Templates: HTML Tag: 2. Generation of HTML attr. value
12871 !! wikitext
12872 <div style={{echo|'color:red;'}}>foo</div>
12873 !! html
12874 <div style="color:red;">foo</div>
12875
12876 !!end
12877
12878 !!test
12879 Templates: HTML Tag: 3. Generation of HTML attr key and value
12880 !! wikitext
12881 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
12882 !! html
12883 <div style="color:red;">foo</div>
12884
12885 !!end
12886
12887 !!test
12888 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
12889 !! wikitext
12890 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
12891 !! html
12892 <div title="This is a long title with just one piece templated">foo</div>
12893
12894 !!end
12895
12896 !!test
12897 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
12898 !! wikitext
12899 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
12900 !! html
12901 <div title="This is a long title with just one piece templated">foo</div>
12902
12903 !!end
12904
12905 !!test
12906 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
12907 !! wikitext
12908 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
12909 !! html
12910 <div title="This is a long title with just one piece templated">foo</div>
12911
12912 !!end
12913
12914 # SSS FIXME: While it is great we added support for all this,
12915 # do we want to make this part of the spec? Maybe we want to
12916 # deprecate this kind of usage in the future?
12917 !!test
12918 Templates: HTML Tag: 7. Generation of partial attribute key string
12919 !! wikitext
12920 <div st{{echo|yle}}="color:red;">foo</div>
12921 !! html
12922 <div style="color:red;">foo</div>
12923
12924 !!end
12925
12926 !! test
12927 Templates: HTML Tag: 8. Template-generated attribute (k=v)
12928 !! wikitext
12929 <div {{echo|1=id="v1"}}>bar</div>
12930 !! html
12931 <div id="v1">bar</div>
12932
12933 !!end
12934
12935 !! test
12936 Templates: HTML Tag: 9. Multiple template-generated attributes
12937 !! wikitext
12938 <div {{echo|1=id="v1" title="foo"}}>bar</div>
12939 !! html
12940 <div id="v1" title="foo">bar</div>
12941
12942 !!end
12943
12944 !! test
12945 Templates: Support for templates generating attributes and content
12946 !! wikitext
12947 {| {{mixed_attr_content_template}}
12948 |-
12949 |bar
12950 |}
12951 !! html/php
12952 <table style="color:red;" title="T48811">
12953
12954 <tr>
12955 <td>foo
12956 </td></tr>
12957 <tr>
12958 <td>bar
12959 </td></tr></table>
12960
12961 !! html/parsoid
12962 <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|}"]}'>
12963 <tbody><tr>
12964 <td>foo</td></tr>
12965 <tr>
12966 <td>bar</td></tr>
12967 </tbody></table>
12968 !!end
12969
12970 !! test
12971 1. Entities and nowikis inside templated attributes should be handled correctly
12972 !! wikitext
12973 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
12974 !! html/php
12975 <div style="background:#f9f9f9;">foo</div>
12976
12977 !! html/parsoid
12978 <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>
12979 !! end
12980
12981 !! test
12982 2. Entities and nowikis inside templated attributes should be handled correctly
12983 !! wikitext
12984 {|
12985 |{{table_attribs_3}}
12986 |}
12987 !! html/php
12988 <table>
12989 <tr>
12990 <td style="background:#f9f9f9;">Foo
12991 </td></tr></table>
12992
12993 !! html/parsoid
12994 <table>
12995 <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>
12996 </tbody></table>
12997 !! end
12998
12999 !! test
13000 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13001 !! wikitext
13002 {{tbl-start}}
13003 |{{table_attribs_3}}
13004 {{tbl-end}}
13005 !! html/php
13006 <table>
13007 <tr>
13008 <td style="background:#f9f9f9;">Foo
13009 </td></tr></table>
13010
13011 !! html/parsoid
13012 <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}}]}'>
13013 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
13014 </tbody></table>
13015 !! end
13016
13017 # T107622
13018 !! test
13019 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13020 !! wikitext
13021 {|
13022 |{{table_attribs_6}} hi
13023 |}
13024 !! html/php
13025 <table>
13026 <tr>
13027 <td style="background: red;">hi
13028 </td></tr></table>
13029
13030 !! html/parsoid
13031 <table>
13032 <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>
13033 </tbody></table>
13034 !! end
13035
13036 !!test
13037 Templates: HTML Tables: 1. Generating start of a HTML table
13038 !! wikitext
13039 {{echo|<table><tr><td>foo</td>}}</tr></table>
13040 !! html
13041 <table><tr><td>foo</td></tr></table>
13042
13043 !!end
13044
13045 !!test
13046 Templates: HTML Tables: 2a. Generating middle of a HTML table
13047 !! wikitext
13048 <table><tr>{{echo|<td>foo</td>}}</tr></table>
13049 !! html
13050 <table><tr><td>foo</td></tr></table>
13051
13052 !!end
13053
13054 !!test
13055 Templates: HTML Tables: 2b. Generating middle of a HTML table
13056 !! wikitext
13057 <table>{{echo|<tr><td>foo</td></tr>}}</table>
13058 !! html
13059 <table><tr><td>foo</td></tr></table>
13060
13061 !!end
13062
13063 !!test
13064 Templates: HTML Tables: 3. Generating end of a HTML table
13065 !! wikitext
13066 <table><tr>{{echo|<td>foo</td></tr></table>}}
13067 !! html
13068 <table><tr><td>foo</td></tr></table>
13069
13070 !!end
13071
13072 !!test
13073 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13074 !! wikitext
13075 {{echo|<table>}}<tr><td>foo</td></tr></table>
13076 !! html
13077 <table><tr><td>foo</td></tr></table>
13078
13079 !!end
13080
13081 !!test
13082 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13083 !! wikitext
13084 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13085 !! html
13086 <table><tr><td>foo</td></tr></table>
13087
13088 !!end
13089
13090 !!test
13091 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13092 !! wikitext
13093 <table><tr>{{echo|<td>}}foo</td></tr></table>
13094 !! html
13095 <table><tr><td>foo</td></tr></table>
13096
13097 !!end
13098
13099 !!test
13100 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13101 !! wikitext
13102 <table><tr><td>foo{{echo|</td>}}</tr></table>
13103 !! html
13104 <table><tr><td>foo</td></tr></table>
13105
13106 !!end
13107
13108 !!test
13109 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13110 !! wikitext
13111 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13112 !! html
13113 <table><tr><td>foo</td></tr></table>
13114
13115 !!end
13116
13117 !!test
13118 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13119 !! wikitext
13120 <table><tr><td>foo</td></tr>{{echo|</table>}}
13121 !! html
13122 <table><tr><td>foo</td></tr></table>
13123
13124 !!end
13125
13126 !!test
13127 Templates: HTML Tables: 5. Proper fostering of categories from inside
13128 !!options
13129 parsoid=wt2html,wt2wt
13130 !! wikitext
13131 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13132 <!--Two categories (T52330)-->
13133 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13134 !! html
13135 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13136 <!--Two categories (T52330)-->
13137 <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>
13138 !!end
13139
13140 !!test
13141 Templates: Wiki Tables: 1a. Fostering of entire template content
13142 !! wikitext
13143 {|
13144 {{echo|a}}
13145 |}
13146 !! html
13147 <table>
13148 a
13149 <tr><td></td></tr></table>
13150
13151 !! html/php+tidy
13152
13153 a
13154 <table><tbody><tr><td></td></tr></tbody></table>
13155 !! html/parsoid
13156 <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">
13157
13158 </table>
13159 !! end
13160
13161 !!test
13162 Templates: Wiki Tables: 1b. Fostering of entire template content
13163 !! wikitext
13164 {|
13165 {{echo|<div>}}
13166 foo
13167 {{echo|</div>}}
13168 |}
13169 !! html
13170 <table>
13171 <div>
13172 <p>foo
13173 </p>
13174 </div>
13175 <tr><td></td></tr></table>
13176
13177 !! html/php+tidy
13178 <div>
13179 <p>foo
13180 </p>
13181 </div><table>
13182
13183 <tbody><tr><td></td></tr></tbody></table>
13184 !! html/parsoid
13185 <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|}"]}'>
13186 <p>foo</p>
13187 </div><table about="#mwt3">
13188
13189 </table>
13190 !! end
13191
13192 !!test
13193 Templates: Wiki Tables: 2. Fostering of partial template content
13194 !! wikitext
13195 {|
13196 {{echo|a
13197 <div>b</div>}}
13198 |}
13199 !! html
13200 <table>
13201 a
13202 <div>b</div>
13203 <tr><td></td></tr></table>
13204
13205 !! html/php+tidy
13206
13207 a
13208 <div>b</div><table>
13209 <tbody><tr><td></td></tr></tbody></table>
13210 !! html/parsoid
13211 <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">
13212
13213
13214 </table>
13215 !! end
13216
13217 !!test
13218 Templates: Wiki Tables: 3. td-content via multiple templates
13219 !! wikitext
13220 {|
13221 {{echo|{{pipe}}a}}{{echo|b}}
13222 |}
13223 !! html
13224 <table>
13225 <tr>
13226 <td>ab
13227 </td></tr></table>
13228
13229 !!end
13230
13231 !!test
13232 Templates: Wiki Tables: 4. Templated tags, no content
13233 !! wikitext
13234 {{tbl-start}}
13235 {{tbl-end}}
13236 !! html
13237 <table>
13238 <tr><td></td></tr></table>
13239
13240 !!end
13241
13242 !!test
13243 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13244 !! wikitext
13245 {{tbl-start}}
13246 |foo
13247 {{tbl-end}}
13248 !! html
13249 <table>
13250 <tr>
13251 <td>foo
13252 </td></tr></table>
13253
13254 !!end
13255
13256 !!test
13257 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13258 !! wikitext
13259 {{tbl-start}}
13260 {{!}}foo
13261 {{tbl-end}}
13262 !! html
13263 <table>
13264 <tr>
13265 <td>foo
13266 </td></tr></table>
13267
13268 !!end
13269
13270 ## This test case is very specific to Parsoid's internals
13271 ## and is hence only tested for Parsoid's code. Parsoid uses
13272 ## a <meta> marker tag for <ref> tags and they are expanded
13273 ## much later. We are verifying that this <meta> tag usage
13274 ## doesn't prevent foster parenting.
13275 !!test
13276 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13277 !!wikitext
13278 {{PartialTable}}<ref>foo</ref>
13279 |}
13280
13281 <references />
13282 !!html/parsoid
13283 <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">
13284 <tbody>
13285 </tbody></table>
13286
13287 <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>
13288 !!end
13289
13290 !! test
13291 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13292 !! wikitext
13293 {{echo|
13294 {{{!}}
13295 {{!}}-}}
13296 <onlyinclude>
13297 |foo
13298 </onlyinclude>
13299 {{!}}}
13300 !! html/parsoid
13301 <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{{!}}}"]}'>
13302 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13303 <tbody><tr>
13304
13305 <td>foo
13306 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13307 </tbody></table>
13308 !! end
13309
13310 !!test
13311 Templates: Lists: Multi-line list-items via templates
13312 !! wikitext
13313 *{{echo|a {{nonexistent|
13314 unused}}}}
13315 *{{echo|b {{nonexistent|
13316 unused}}}}
13317 !! html
13318 <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>
13319 <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>
13320
13321 !!end
13322
13323 !!test
13324 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13325 !! wikitext
13326 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13327 !! html
13328 <p><i>ab</i>c<i>d</i>e
13329 </p>
13330 !!end
13331
13332 !!test
13333 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13334 (PHP parser generates misnested html)
13335 !! wikitext
13336 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13337 !! html/parsoid
13338 <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>
13339 !!end
13340
13341 !!test
13342 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13343 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13344 !! options
13345 parsoid=wt2html,wt2wt
13346 !! wikitext
13347 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13348 !! html
13349 <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>
13350 <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>
13351 <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>
13352 !!end
13353
13354 !!test
13355 Templates: Ugly nesting: 4. Divs opened/closed across templates
13356 !! wikitext
13357 a<div>b{{echo|c</div>d}}e
13358 !! html
13359 a<div>bc</div>de
13360
13361 !! html+tidy
13362 <p>a</p><div>bc</div><p>de
13363 </p>
13364 !! end
13365
13366 !! test
13367 Templates: Ugly templates: 3. newline-only template parameter
13368 !! wikitext
13369 foo {{echo|
13370 }}
13371 !! html
13372 <p>foo
13373 </p>
13374 !! end
13375
13376 # This looks like a bug: a single newline triggers p/br for some reason.
13377 !! test
13378 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13379 !! wikitext
13380 {{echo|
13381 }}
13382 !! html
13383 <p><br />
13384 </p>
13385 !! end
13386
13387 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13388 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13389 !! test
13390 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13391 !! wikitext
13392 {{echo|<table>}}
13393 {{echo|<div>foo}}
13394 {{echo|</table>}}
13395 !! html/parsoid
13396 <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
13397 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13398 </table>
13399 !! end
13400
13401 # T66017 -- ugly wikitext with fostered content generates two template ranges
13402 # that are "identical" and generate nesting cycles in the algorithm
13403 !! test
13404 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13405 !! wikitext
13406 {{echo|<table><tr><td><table>}}
13407 {{echo|<div>}}
13408 {{echo|</div>}}
13409 !! html/parsoid
13410 <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"}'>
13411 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13412 </table></td></tr></tbody></table>
13413 !! end
13414
13415 !! test
13416 Templates: Parameters substituted at the top-level
13417 !! wikitext
13418 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13419
13420 {{{foo|bar|baz}}}
13421 !! html/php
13422 <p><i>who</i> me? <b>never!</b>
13423 </p><p>bar
13424 </p>
13425 !! html/parsoid
13426 <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>
13427
13428 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13429 !! end
13430
13431 !! test
13432 Templates: Param with empty arg in the final position
13433 !! wikitext
13434 {{{hi|}}}
13435 !! html/parsoid
13436 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13437 !! end
13438
13439 !!test
13440 Parser Functions: 1. Simple example
13441 !! wikitext
13442 {{uc:foo}}
13443 !! html
13444 <p>FOO
13445 </p>
13446 !!end
13447
13448 !!test
13449 Parser Functions: 2. Nested use (only outermost should be marked up)
13450 !! wikitext
13451 {{uc:{{lc:FOO}}}}
13452 !! html
13453 <p>FOO
13454 </p>
13455 !!end
13456
13457 ###
13458 ### Pre-save transform tests
13459 ###
13460 !! test
13461 pre-save transform: subst:
13462 !! options
13463 pst
13464 !! wikitext
13465 {{subst:test}}
13466 !! html/php
13467 This is a test template
13468 !! end
13469
13470 !! test
13471 pre-save transform: normal template
13472 !! options
13473 pst
13474 !! wikitext
13475 {{test}}
13476 !! html/php
13477 {{test}}
13478 !! end
13479
13480 !! test
13481 pre-save transform: nonexistent template
13482 !! options
13483 pst
13484 !! wikitext
13485 {{thistemplatedoesnotexist}}
13486 !! html/php
13487 {{thistemplatedoesnotexist}}
13488 !! end
13489
13490 !! test
13491 pre-save transform: subst magic variables
13492 !! options
13493 pst
13494 !! wikitext
13495 {{subst:SITENAME}}
13496 !! html/php
13497 MediaWiki
13498 !! end
13499
13500 # This is T2089, which I fixed. -- wtm
13501 !! test
13502 pre-save transform: subst: templates with parameters
13503 !! options
13504 pst
13505 !! wikitext
13506 {{subst:paramtest|param="something else"}}
13507 !! html/php
13508 This is a test template with parameter "something else"
13509 !! end
13510
13511 !! article
13512 Template:nowikitest
13513 !! text
13514 <nowiki>'''not wiki'''</nowiki>
13515 !! endarticle
13516
13517 !! test
13518 pre-save transform: nowiki in subst (T3188)
13519 !! options
13520 pst
13521 !! wikitext
13522 {{subst:nowikitest}}
13523 !! html/php
13524 <nowiki>'''not wiki'''</nowiki>
13525 !! end
13526
13527 !! article
13528 Template:commenttest
13529 !! text
13530 This template has <!-- a comment --> in it.
13531 !! endarticle
13532
13533 !! test
13534 pre-save transform: comment in subst (T3936)
13535 !! options
13536 pst
13537 !! wikitext
13538 {{subst:commenttest}}
13539 !! html/php
13540 This template has <!-- a comment --> in it.
13541 !! end
13542
13543 !! test
13544 pre-save transform: unclosed tag
13545 !! options
13546 pst
13547 !! wikitext
13548 <nowiki>'''not wiki'''
13549 !! html/php
13550 <nowiki>'''not wiki'''
13551 !! end
13552
13553 !! test
13554 pre-save transform: mixed tag case
13555 !! options
13556 pst
13557 !! wikitext
13558 <NOwiki>'''not wiki'''</noWIKI>
13559 !! html/php
13560 <NOwiki>'''not wiki'''</noWIKI>
13561 !! end
13562
13563 !! test
13564 pre-save transform: unclosed comment in <nowiki>
13565 !! options
13566 pst
13567 !! wikitext
13568 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13569 !! html/php
13570 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13571 !!end
13572
13573 # Leading @ in this template definition works around a limitation
13574 # in parsoid's parserTests which otherwise strips the <span> from the
13575 # result (confusing it for a template wrapper)
13576 !! article
13577 Template:dangerous
13578 !!text
13579 @<span onmouseover="alert('crap')">Oh no</span>
13580 !!endarticle
13581
13582 !!test
13583 (confirming safety of fix for subst T3936)
13584 !! wikitext
13585 {{Template:dangerous}}
13586 !! html
13587 <p>@<span>Oh no</span>
13588 </p>
13589 !! end
13590
13591 !! test
13592 pre-save transform: comment containing gallery (T7024)
13593 !! options
13594 pst
13595 !! wikitext
13596 <!-- <gallery>data</gallery> -->
13597 !! html/php
13598 <!-- <gallery>data</gallery> -->
13599 !!end
13600
13601 !! test
13602 pre-save transform: comment containing extension
13603 !! options
13604 pst
13605 !! wikitext
13606 <!-- <tag>data</tag> -->
13607 !! html/php
13608 <!-- <tag>data</tag> -->
13609 !!end
13610
13611 !! test
13612 pre-save transform: comment containing nowiki
13613 !! options
13614 pst
13615 !! wikitext
13616 <!-- <nowiki>data</nowiki> -->
13617 !! html/php
13618 <!-- <nowiki>data</nowiki> -->
13619 !!end
13620
13621 !! test
13622 pre-save transform: <noinclude> in subst (T5298)
13623 !! options
13624 pst
13625 !! wikitext
13626 {{subst:Includes}}
13627 !! html/php
13628 Foobar
13629 !! end
13630
13631 !! test
13632 pre-save transform: <onlyinclude> in subst (T5298)
13633 !! options
13634 pst
13635 !! wikitext
13636 {{subst:Includes2}}
13637 !! html/php
13638 Foo
13639 !! end
13640
13641 !! article
13642 Template:SubstTest
13643 !!text
13644 {{<includeonly>subst:</includeonly>Includes}}
13645 !! endarticle
13646
13647 !! article
13648 Template:SafeSubstTest
13649 !! text
13650 {{<includeonly>safesubst:</includeonly>Includes}}
13651 !! endarticle
13652
13653 !! test
13654 T24297: safesubst: works during PST
13655 !! options
13656 pst
13657 !! wikitext
13658 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
13659 !! html/php
13660 FoobarFoobar
13661 !! end
13662
13663 !! test
13664 T24297: safesubst: works during normal parse
13665 !! wikitext
13666 {{SafeSubstTest}}
13667 !! html
13668 <p>Foobar
13669 </p>
13670 !! end
13671
13672 !! test
13673 subst: does not work during normal parse
13674 !! wikitext
13675 {{SubstTest}}
13676 !! html
13677 <p>{{subst:Includes}}
13678 </p>
13679 !! end
13680
13681 !! test
13682 pre-save transform: context links ("pipe trick")
13683 !! options
13684 pst
13685 !! wikitext
13686 [[Article (context)|]]
13687 [[Bar:Article|]]
13688 [[:Bar:Article|]]
13689 [[Bar:Article (context)|]]
13690 [[:Bar:Article (context)|]]
13691 [[|Article]]
13692 [[|Article (context)]]
13693 [[Bar:X (Y) Z|]]
13694 [[:Bar:X (Y) Z|]]
13695 !! html/php
13696 [[Article (context)|Article]]
13697 [[Bar:Article|Article]]
13698 [[:Bar:Article|Article]]
13699 [[Bar:Article (context)|Article]]
13700 [[:Bar:Article (context)|Article]]
13701 [[Article]]
13702 [[Article (context)]]
13703 [[Bar:X (Y) Z|X (Y) Z]]
13704 [[:Bar:X (Y) Z|X (Y) Z]]
13705 !! end
13706
13707 !! test
13708 pre-save transform: context links ("pipe trick") with interwiki prefix
13709 !! options
13710 pst
13711 !! wikitext
13712 [[interwiki:Article|]]
13713 [[:interwiki:Article|]]
13714 [[interwiki:Bar:Article|]]
13715 [[:interwiki:Bar:Article|]]
13716 !! html/php
13717 [[interwiki:Article|Article]]
13718 [[:interwiki:Article|Article]]
13719 [[interwiki:Bar:Article|Bar:Article]]
13720 [[:interwiki:Bar:Article|Bar:Article]]
13721 !! end
13722
13723 !! test
13724 pre-save transform: context links ("pipe trick") with parens in title
13725 !! options
13726 pst title=[[Somearticle (context)]]
13727 !! wikitext
13728 [[|Article]]
13729 !! html/php
13730 [[Article (context)|Article]]
13731 !! end
13732
13733 !! test
13734 pre-save transform: context links ("pipe trick") with comma in title
13735 !! options
13736 pst title=[[Someplace, Somewhere]]
13737 !! wikitext
13738 [[|Otherplace]]
13739 [[Otherplace, Elsewhere|]]
13740 [[Otherplace, Elsewhere, Anywhere|]]
13741 !! html/php
13742 [[Otherplace, Somewhere|Otherplace]]
13743 [[Otherplace, Elsewhere|Otherplace]]
13744 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
13745 !! end
13746
13747 !! test
13748 pre-save transform: context links ("pipe trick") with parens and comma
13749 !! options
13750 pst title=[[Someplace (IGNORED), Somewhere]]
13751 !! wikitext
13752 [[|Otherplace]]
13753 [[Otherplace (place), Elsewhere|]]
13754 !! html/php
13755 [[Otherplace, Somewhere|Otherplace]]
13756 [[Otherplace (place), Elsewhere|Otherplace]]
13757 !! end
13758
13759 !! test
13760 pre-save transform: context links ("pipe trick") with comma and parens
13761 !! options
13762 pst title=[[Who, me? (context)]]
13763 !! wikitext
13764 [[|Yes, you.]]
13765 [[Me, Myself, and I (1937 song)|]]
13766 !! html/php
13767 [[Yes, you. (context)|Yes, you.]]
13768 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
13769 !! end
13770
13771 !! test
13772 pre-save transform: context links ("pipe trick") with namespace
13773 !! options
13774 pst title=[[Ns:Somearticle]]
13775 !! wikitext
13776 [[|Article]]
13777 !! html/php
13778 [[Ns:Article|Article]]
13779 !! end
13780
13781 !! test
13782 pre-save transform: context links ("pipe trick") with namespace and parens
13783 !! options
13784 pst title=[[Ns:Somearticle (context)]]
13785 !! wikitext
13786 [[|Article]]
13787 !! html/php
13788 [[Ns:Article (context)|Article]]
13789 !! end
13790
13791 !! test
13792 pre-save transform: context links ("pipe trick") with namespace and comma
13793 !! options
13794 pst title=[[Ns:Somearticle, Context, Whatever]]
13795 !! wikitext
13796 [[|Article]]
13797 !! html/php
13798 [[Ns:Article, Context, Whatever|Article]]
13799 !! end
13800
13801 !! test
13802 pre-save transform: context links ("pipe trick") with namespace, comma and parens
13803 !! options
13804 pst title=[[Ns:Somearticle, Context (context)]]
13805 !! wikitext
13806 [[|Article]]
13807 !! html/php
13808 [[Ns:Article (context)|Article]]
13809 !! end
13810
13811 !! test
13812 pre-save transform: context links ("pipe trick") with namespace, parens and comma
13813 !! options
13814 pst title=[[Ns:Somearticle (IGNORED), Context]]
13815 !! wikitext
13816 [[|Article]]
13817 !! html/php
13818 [[Ns:Article, Context|Article]]
13819 !! end
13820
13821 !! test
13822 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
13823 !! options
13824 pst
13825 !! wikitext
13826 [[Article(context)|]]
13827 [[Bar:Article(context)|]]
13828 [[:Bar:Article(context)|]]
13829 [[|Article(context)]]
13830 [[Bar:X(Y)Z|]]
13831 [[:Bar:X(Y)Z|]]
13832 !! html/php
13833 [[Article(context)|Article]]
13834 [[Bar:Article(context)|Article]]
13835 [[:Bar:Article(context)|Article]]
13836 [[Article(context)]]
13837 [[Bar:X(Y)Z|X(Y)Z]]
13838 [[:Bar:X(Y)Z|X(Y)Z]]
13839 !! end
13840
13841 !! test
13842 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
13843 !! options
13844 pst
13845 !! wikitext
13846 [[Article (context)|]]
13847 [[Bar:Article (context)|]]
13848 [[:Bar:Article (context)|]]
13849 [[|Article (context)]]
13850 [[Bar:X (Y) Z|]]
13851 [[:Bar:X (Y) Z|]]
13852 !! html/php
13853 [[Article (context)|Article]]
13854 [[Bar:Article (context)|Article]]
13855 [[:Bar:Article (context)|Article]]
13856 [[Article (context)]]
13857 [[Bar:X (Y) Z|X (Y) Z]]
13858 [[:Bar:X (Y) Z|X (Y) Z]]
13859 !! end
13860
13861 !! test
13862 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
13863 !! options
13864 pst
13865 !! wikitext
13866 [[Article(context)|]]
13867 [[Bar:Article(context)|]]
13868 [[:Bar:Article(context)|]]
13869 [[|Article(context)]]
13870 [[Bar:X(Y)Z|]]
13871 [[:Bar:X(Y)Z|]]
13872 !! html/php
13873 [[Article(context)|Article]]
13874 [[Bar:Article(context)|Article]]
13875 [[:Bar:Article(context)|Article]]
13876 [[Article(context)]]
13877 [[Bar:X(Y)Z|X(Y)Z]]
13878 [[:Bar:X(Y)Z|X(Y)Z]]
13879 !! end
13880
13881 !! test
13882 pre-save transform: context links ("pipe trick") with commas (T23660)
13883 !! options
13884 pst
13885 !! wikitext
13886 [[Article (context), context|]]
13887 [[Article (context),context|]]
13888 [[Bar:Article (context), context|]]
13889 [[Bar:Article (context),context|]]
13890 [[:Bar:Article (context), context|]]
13891 [[:Bar:Article (context),context|]]
13892 !! html/php
13893 [[Article (context), context|Article]]
13894 [[Article (context),context|Article]]
13895 [[Bar:Article (context), context|Article]]
13896 [[Bar:Article (context),context|Article]]
13897 [[:Bar:Article (context), context|Article]]
13898 [[:Bar:Article (context),context|Article]]
13899 !! end
13900
13901 !! test
13902 Parsoid: backwards pipe trick
13903 !! wikitext
13904 [[|'''bar''']]
13905 !! html/php
13906 <p>[[|<b>bar</b>]]
13907 </p>
13908 !! html/parsoid
13909 <p>[[|<b>bar</b>]]</p>
13910 !! end
13911
13912 !! test
13913 pre-save transform: trim trailing empty lines
13914 !! options
13915 pst
13916 !! wikitext
13917 Empty lines are trimmed
13918
13919
13920
13921
13922 !! html/php
13923 Empty lines are trimmed
13924 !! end
13925
13926 !! test
13927 pre-save transform: Signature expansion
13928 !! options
13929 pst
13930 !! wikitext
13931 * ~~~
13932 * ~~~~
13933 * ~~~~~
13934 * <noinclude>~~~</noinclude>
13935 * <includeonly>~~~</includeonly>
13936 * <onlyinclude>~~~</onlyinclude>
13937 !! html/php
13938 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
13939 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
13940 * 00:02, 1 January 1970 (UTC)
13941 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
13942 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
13943 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
13944 !! end
13945
13946
13947 !! test
13948 ParserOutput flags from signature expansion (T84843)
13949 !! options
13950 pst
13951 showflags
13952 !! wikitext
13953 ~~~~
13954 !! html/php
13955 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
13956 flags=user-signature
13957 !! end
13958
13959
13960 !! test
13961 pre-save transform: Signature expansion in nowiki tags (T2093)
13962 !! options
13963 pst disabled
13964 !! wikitext
13965 Shall not expand:
13966
13967 <nowiki>~~~~</nowiki>
13968
13969 <includeonly><nowiki>~~~~</nowiki></includeonly>
13970
13971 <noinclude><nowiki>~~~~</nowiki></noinclude>
13972
13973 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13974
13975 {{subst:Foo}} shall be converted to FOO
13976
13977 As well as inside noinclude/onlyinclude
13978 <noinclude>{{subst:Foo}}</noinclude>
13979 <onlyinclude>{{subst:Foo}}</onlyinclude>
13980
13981 But not inside includeonly
13982 <includeonly>{{subst:Foo}}</includeonly>
13983 !! html/php
13984 Shall not expand:
13985
13986 <nowiki>~~~~</nowiki>
13987
13988 <includeonly><nowiki>~~~~</nowiki></includeonly>
13989
13990 <noinclude><nowiki>~~~~</nowiki></noinclude>
13991
13992 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13993
13994 FOO shall be converted to FOO
13995
13996 As well as inside noinclude/onlyinclude
13997 <noinclude>FOO</noinclude>
13998 <onlyinclude>FOO</onlyinclude>
13999
14000 But not inside includeonly
14001 <includeonly>{{subst:Foo}}</includeonly>
14002 !! end
14003
14004 !! test
14005 Parsoid: Recognize nowiki with trailing space in tags
14006 !! options
14007 parsoid=wt2html
14008 !! wikitext
14009 <nowiki ><div>[[foo]]</nowiki >
14010
14011 a<nowiki / >b
14012
14013 c<nowiki />d
14014
14015 e<nowiki/ >f
14016 !! html
14017 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14018 <p>ab</p>
14019 <p>cd</p>
14020 <p>ef</p>
14021 !! end
14022
14023 !! test
14024 Parsoid: Recognize nowiki with odd capitalization
14025 !! options
14026 parsoid=wt2html
14027 !! wikitext
14028 <noWikI ><div>[[foo]]</Nowiki >
14029 !! html
14030 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14031 !! end
14032
14033
14034 !! test
14035 Parsoid: Escape nowiki with trailing space in tags
14036 !! options
14037 parsoid=html2wt
14038 !! html/parsoid
14039 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14040 <p>a&lt;nowiki /&gt;b</p>
14041 <p>c&lt;nowiki/ &gt;d</p>
14042 !! wikitext
14043 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14044
14045 a&lt;nowiki /&gt;b
14046
14047 c&lt;nowiki/ &gt;d
14048 !! end
14049
14050 !! test
14051 Parsoid: Escape weird noWikI capitalizations
14052 !! options
14053 parsoid=html2wt
14054 !! html/parsoid
14055 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14056 !! wikitext
14057 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14058 !! end
14059
14060 ###
14061 ### Message transform tests
14062 ###
14063 !! test
14064 message transform: magic variables
14065 !! options
14066 msg
14067 !! wikitext
14068 {{SITENAME}}
14069 !! html
14070 MediaWiki
14071 !! end
14072
14073 !! test
14074 message transform: should not transform wiki markup
14075 !! options
14076 msg
14077 !! wikitext
14078 ''test''
14079 !! html
14080 ''test''
14081 !! end
14082
14083 !! test
14084 message transform: <noinclude> in transcluded template (T6926)
14085 !! options
14086 msg
14087 !! wikitext
14088 {{Includes}}
14089 !! html
14090 Foobar
14091 !! end
14092
14093 !! test
14094 message transform: <onlyinclude> in transcluded template (T6926)
14095 !! options
14096 msg
14097 !! wikitext
14098 {{Includes2}}
14099 !! html
14100 Foo
14101 !! end
14102
14103 !! test
14104 {{#special:}} page name, known
14105 !! options
14106 msg
14107 !! wikitext
14108 {{#special:Recentchanges}}
14109 !! html
14110 Special:RecentChanges
14111 !! end
14112
14113 !! test
14114 {{#special:}} page name with subpage, known
14115 !! options
14116 msg
14117 !! wikitext
14118 {{#special:Recentchanges/param}}
14119 !! html
14120 Special:RecentChanges/param
14121 !! end
14122
14123 !! test
14124 {{#special:}} page name, unknown
14125 !! options
14126 msg
14127 !! wikitext
14128 {{#special:foobar nonexistent}}
14129 !! html
14130 Special:Foobar nonexistent
14131 !! end
14132
14133 !! test
14134 {{#speciale:}} page name, known
14135 !! options
14136 msg
14137 !! wikitext
14138 {{#speciale:Recentchanges}}
14139 !! html
14140 Special:RecentChanges
14141 !! end
14142
14143 !! test
14144 {{#speciale:}} page name with subpage, known
14145 !! options
14146 msg
14147 !! wikitext
14148 {{#speciale:Recentchanges/param}}
14149 !! html
14150 Special:RecentChanges/param
14151 !! end
14152
14153 !! test
14154 {{#speciale:}} page name, unknown
14155 !! options
14156 msg
14157 !! wikitext
14158 {{#speciale:foobar nonexistent}}
14159 !! html
14160 Special:Foobar_nonexistent
14161 !! end
14162
14163 ###
14164 ### Images
14165 ###
14166 ### For Parsoid-specific tests, see
14167 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14168
14169 !! test
14170 Simple image
14171 !! options
14172 parsoid=wt2html,wt2wt,html2html
14173 !! wikitext
14174 [[Image:foobar.jpg]]
14175 !! html/php
14176 <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>
14177 </p>
14178 !! html/parsoid
14179 <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>
14180 !! end
14181
14182 !! test
14183 Serialize simple image with span wrapper
14184 !! options
14185 parsoid=html2wt
14186 !! html/parsoid
14187 <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>
14188 !! wikitext
14189 [[File:Foobar.jpg]]
14190 !! end
14191
14192 !! test
14193 Simple image (using File: namespace, now canonical)
14194 !! wikitext
14195 [[File:Foobar.jpg]]
14196 !! html/php
14197 <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>
14198 </p>
14199 !! html/parsoid
14200 <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>
14201 !! end
14202
14203 !! test
14204 Right-aligned image
14205 !! wikitext
14206 [[File:Foobar.jpg|right]]
14207 !! html/php
14208 <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>
14209
14210 !! html/parsoid
14211 <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>
14212 !! end
14213
14214 !! test
14215 Image with caption
14216 !! wikitext
14217 [[File:Foobar.jpg|right|Caption text]]
14218 !! html/php
14219 <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>
14220
14221 !! html/parsoid
14222 <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>
14223 !! end
14224
14225 !! test
14226 Image with caption, T55312 #1
14227 !! wikitext
14228 [[File:Foobar.jpg|right|Caption page stuff]]
14229 !! html/php
14230 <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>
14231
14232 !! html/parsoid
14233 <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>
14234 !! end
14235
14236 !! test
14237 Image with caption, T55312 #2
14238 !! wikitext
14239 [[File:Foobar.jpg|right|Caption page=]]
14240 !! html/php
14241 <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>
14242
14243 !! html/parsoid
14244 <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>
14245 !! end
14246
14247 !! test
14248 Image with caption, T55312 #3
14249 !! wikitext
14250 [[File:Foobar.jpg|right|Caption page=stuff]]
14251 !! html/php
14252 <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>
14253
14254 !! html/parsoid
14255 <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>
14256 !! end
14257
14258 !! test
14259 Image caption with pipe entity
14260 !! wikitext
14261 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14262 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14263 !! html/php
14264 <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>
14265 <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>
14266
14267 !! html/parsoid
14268 <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>
14269 <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>
14270 !! end
14271
14272 !! test
14273 Allow empty links in image captions (T62753)
14274 !! options
14275 thumbsize=220
14276 !! wikitext
14277 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14278 [[]]
14279 [[Link2]]
14280 ]]
14281 !! html/php
14282 <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>
14283
14284 !! html/parsoid
14285 <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>
14286 [[]]
14287 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14288 </figcaption></figure>
14289 !! end
14290
14291 !! test
14292 Titles in unlinked images (T23454)
14293 !! wikitext
14294 [[File:Foobar.jpg|link=|stuff]]
14295 !! html/php
14296 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
14297 </p>
14298 !! html/parsoid
14299 <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>
14300 !! end
14301
14302 !! test
14303 Link with empty target
14304 !! wikitext
14305 [[]]
14306 !! html
14307 <p>[[]]
14308 </p>
14309 !! end
14310
14311 !! test
14312 Image with link trail
14313 !! wikitext
14314 Linktrails should not work for images: [[File:Foobar.jpg]]s
14315 !! html/php
14316 <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
14317 </p>
14318 !! html/parsoid
14319 <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>
14320 !! end
14321
14322 !! test
14323 Image with empty attribute
14324 !! options
14325 parsoid=wt2html,wt2wt,html2html
14326 !! wikitext
14327 [[File:Foobar.jpg|right||Caption text]]
14328 !! html/php
14329 <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>
14330
14331 !! html/parsoid
14332 <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>
14333 !! end
14334
14335 !! test
14336 1. Block image with individual attributes from templates
14337 !! wikitext
14338 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14339 !! html/php
14340 <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>
14341
14342 !! html/parsoid
14343 <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>
14344 !! end
14345
14346 !! test
14347 2. Block Image with individual attributes from templates
14348 !! wikitext
14349 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14350 !! html/php
14351 <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>
14352
14353 !! html/parsoid
14354 <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>
14355 !! end
14356
14357 !! test
14358 3. Inline image with individual attributes from templates
14359 !! wikitext
14360 [[File:Foobar.jpg|{{echo|50px}}]]
14361 !! html/php
14362 <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>
14363 </p>
14364 !! html/parsoid
14365 <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>
14366 !! end
14367
14368 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14369 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14370 !! test
14371 Image with multiple attributes from the same template
14372 !! wikitext
14373 [[File:Foobar.jpg|{{image_attribs}}]]
14374 !! html/php
14375 <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>
14376
14377 !! html/parsoid
14378 <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>
14379 !! end
14380
14381 !! test
14382 Image with link tails
14383 !! options
14384 thumbsize=220
14385 !! wikitext
14386 123[[File:Foobar.jpg]]456
14387 123[[File:Foobar.jpg|right]]456
14388 123[[File:Foobar.jpg|thumb]]456
14389 !! html/php
14390 <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
14391 </p>
14392 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
14393 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
14394
14395 !! html/php+tidy
14396 <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
14397 </p><p>
14398 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
14399 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
14400 </p>
14401 !! html/parsoid
14402 <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>
14403 <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>
14404 <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>
14405 !! end
14406
14407 !! test
14408 Image with multiple captions -- only last one is accepted
14409 !! wikitext
14410 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14411 !! html/php
14412 <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>
14413
14414 !! html/parsoid
14415 <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>
14416 !! end
14417
14418 !! test
14419 Image with multiple widths -- use last
14420 !! wikitext
14421 [[File:Foobar.jpg|200px|300px|caption]]
14422 !! html/php
14423 <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>
14424 </p>
14425 !! html/parsoid
14426 <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>
14427 !! end
14428
14429 !! test
14430 Image with multiple alignments -- use first (T50664)
14431 !! options
14432 thumbsize=220
14433 !! wikitext
14434 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14435
14436 [[File:Foobar.jpg|middle|text-top|caption]]
14437 !! html/php
14438 <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>
14439 <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>
14440 </p>
14441 !! html/parsoid
14442 <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>
14443 <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>
14444 !! end
14445
14446 !! test
14447 Image with width attribute at different positions
14448 !! wikitext
14449 [[File:Foobar.jpg|200px|right|Caption]]
14450 [[File:Foobar.jpg|right|200px|Caption]]
14451 [[File:Foobar.jpg|right|Caption|200px]]
14452 !! html/php
14453 <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>
14454 <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>
14455 <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>
14456
14457 !! html/parsoid
14458 <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>
14459 <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>
14460 <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>
14461 !! end
14462
14463 # a sad bit of backward-compatibility
14464 !! test
14465 Image with size specified with pxpx (T15500, T53628)
14466 !! options
14467 parsoid=wt2html,wt2wt,html2html
14468 !! wikitext
14469 [[File:Foobar.jpg|20pxpx]]
14470 [[File:Foobar.jpg|200x20pxpx]]
14471 !! html/php
14472 <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>
14473 <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>
14474 </p>
14475 !! html/parsoid
14476 <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>
14477 !! end
14478
14479 !! test
14480 Image with link parameter, wiki target
14481 !! wikitext
14482 [[File:Foobar.jpg|link=Main Page]]
14483 !! html/php
14484 <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>
14485 </p>
14486 !! html/parsoid
14487 <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>
14488 !! end
14489
14490 # parsoid T51293 (part 1)
14491 !! test
14492 Image with link parameter, URL target
14493 !! wikitext
14494 [[File:Foobar.jpg|link=http://example.com/]]
14495 !! html/php
14496 <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>
14497 </p>
14498 !! html/parsoid
14499 <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>
14500 !! end
14501
14502 # parsoid T51293 (part 2)
14503 !! test
14504 Image with link parameter, protocol-less URL target
14505 !! wikitext
14506 [[File:Foobar.jpg|link=//example.com/]]
14507 !! html/php
14508 <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>
14509 </p>
14510 !! html/parsoid
14511 <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>
14512 !! end
14513
14514 !! test
14515 Escaping non-block captions (T107435)
14516 !! options
14517 parsoid={
14518 "modes": ["wt2wt"],
14519 "changes": [
14520 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14521 ]
14522 }
14523 !! wikitext
14524 [[Image:Foobar.jpg|caption]]
14525 !! wikitext/edited
14526 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14527 !! end
14528
14529 # wgExternalLinkTarget not supported by Parsoid
14530 !! test
14531 Image with link parameter, wgExternalLinkTarget
14532 !! wikitext
14533 [[Image:foobar.jpg|link=http://example.com/]]
14534 !! config
14535 wgExternalLinkTarget='foobar'
14536 !! html/php
14537 <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>
14538 </p>
14539 !! end
14540
14541 !! test
14542 Image with link parameter, wgNoFollowLinks set to false
14543 !! wikitext
14544 [[Image:foobar.jpg|link=http://example.com/]]
14545 !! config
14546 wgNoFollowLinks=false
14547 !! html/php
14548 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14549 </p>
14550 !! end
14551
14552 !! test
14553 Image with link parameter, wgNoFollowDomainExceptions
14554 !! wikitext
14555 [[Image:foobar.jpg|link=http://example.com/]]
14556 !! config
14557 wgNoFollowDomainExceptions='example.com'
14558 !! html/php
14559 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14560 </p>
14561 !! end
14562
14563 # wgExternalLinkTarget not supported by Parsoid
14564 !! test
14565 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14566 !! wikitext
14567 [[Image:foobar.jpg|link=http://example.com/|Title]]
14568 !! config
14569 wgExternalLinkTarget='foobar'
14570 !! html/php
14571 <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>
14572 </p>
14573 !! end
14574
14575 !! test
14576 Image with empty link parameter
14577 !! wikitext
14578 [[File:Foobar.jpg|link=]]
14579 !! html/php
14580 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14581 </p>
14582 !! html/parsoid
14583 <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>
14584 !! end
14585
14586 !! test
14587 Image with link parameter (wiki target) and unnamed parameter
14588 !! wikitext
14589 [[File:Foobar.jpg|link=Main_Page|Title]]
14590 !! html/php
14591 <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>
14592 </p>
14593 !! html/parsoid
14594 <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>
14595 !! end
14596
14597 !! test
14598 Image with link parameter (URL target) and unnamed parameter
14599 !! wikitext
14600 [[File:Foobar.jpg|link=http://example.com/|Title]]
14601 !! html/php
14602 <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>
14603 </p>
14604 !! html/parsoid
14605 <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>
14606 !! end
14607
14608 !! test
14609 Thumbnail image with link parameter
14610 !! options
14611 thumbsize=220
14612 parsoid=wt2html,wt2wt,html2html
14613 !! wikitext
14614 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14615 !! html/php
14616 <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>
14617
14618 !! html/parsoid
14619 <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>
14620 !! end
14621
14622 !! test
14623 Manually-specified thumbnail image
14624 !! options
14625 thumbsize=220
14626 !! wikitext
14627 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14628 !! html/php
14629 <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>
14630
14631 !! html/parsoid
14632 <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>
14633 !! end
14634
14635 !! test
14636 Manually-specified thumbnail image with explicit link to wiki page
14637 !! options
14638 thumbsize=220
14639 parsoid=wt2html,wt2wt,html2html
14640 !! wikitext
14641 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14642 !! html/php
14643 <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>
14644
14645 !! html/parsoid
14646 <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>
14647 !! end
14648
14649 !! test
14650 Manually-specified thumbnail image with explicit link to url
14651 !! options
14652 thumbsize=220
14653 parsoid=wt2html,wt2wt,html2html
14654 !! wikitext
14655 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14656 !! html/php
14657 <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>
14658
14659 !! html/parsoid
14660 <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>
14661 !! end
14662
14663 !! test
14664 Manually-specified thumbnail image with explicit no link
14665 !! options
14666 thumbsize=220
14667 parsoid=wt2html,wt2wt,html2html
14668 !! wikitext
14669 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14670 !! html/php
14671 <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>
14672
14673 !! html/parsoid
14674 <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>
14675 !! end
14676
14677 !! test
14678 Manually-specified thumbnail image with explicit link and alt text
14679 !! options
14680 thumbsize=220
14681 parsoid=wt2html,wt2wt,html2html
14682 !! wikitext
14683 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14684 !! html/php
14685 <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>
14686
14687 !! html/parsoid
14688 <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>
14689 !! end
14690
14691 !! test
14692 Image with frame and link
14693 !! options
14694 parsoid=wt2html,wt2wt,html2html
14695 !! wikitext
14696 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14697 !! html/php
14698 <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>
14699
14700 !! html/parsoid
14701 <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>
14702 !! end
14703
14704 !! test
14705 Image with frame and link and explicit alt
14706 !! options
14707 parsoid=wt2html,wt2wt,html2html
14708 !! wikitext
14709 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
14710 !! html/php
14711 <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>
14712
14713 !! html/parsoid
14714 <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>
14715 !! end
14716
14717 !! test
14718 Image with wiki markup in implicit alt
14719 !! wikitext
14720 [[Image:Foobar.jpg|testing '''bold''' in alt]]
14721
14722 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
14723 !! html/php
14724 <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>
14725 </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>
14726 </p>
14727 !! html/parsoid
14728 <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>
14729
14730 <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>
14731 !! end
14732
14733 !! test
14734 Alt image option should handle most kinds of wikitext without barfing
14735 !! wikitext
14736 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
14737 !! html/php
14738 <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>
14739
14740 !! html/parsoid
14741 <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>
14742 !! end
14743
14744 !! test
14745 Image with table with attributes in caption
14746 !! options
14747 parsoid=wt2html,html2html
14748 !! wikitext
14749 [[File:Foobar.jpg|thumb|
14750 {| class="123" |
14751 |- class="456" |
14752 | ha
14753 |}
14754 ]]
14755 !! html/parsoid
14756 <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>
14757 <table class="123">
14758 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
14759 <td> ha</td></tr>
14760 </tbody></table>
14761 </figcaption></figure>
14762 !! end
14763
14764 !! test
14765 Image with table with rows from templates in caption
14766 !! wikitext
14767 [[File:Foobar.jpg|thumb|
14768 {|
14769 {{echo|{{!}} hi}}
14770 |}
14771 ]]
14772 !! html/parsoid
14773 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"\n{|\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>
14774 <table>
14775 <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>
14776 </tbody></table>
14777 </figcaption></figure>
14778 !! end
14779
14780 !! test
14781 Image with nested tables in caption
14782 !! wikitext
14783 [[File:Foobar.jpg|thumb|Foo<br />
14784 {|
14785 |
14786 {|
14787 |z
14788 |}
14789 |}
14790 ]]
14791 !! html/parsoid
14792 <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}'/>
14793 <table>
14794 <tbody><tr><td>
14795 <table>
14796 <tbody><tr><td>z</td></tr>
14797 </tbody></table></td></tr>
14798 </tbody></table>
14799 </figcaption></figure>
14800 !! end
14801
14802 ###################
14803 # Conflicting image format options.
14804 # First option specified should 'win'.
14805 # All three cases in each test should be identical.
14806
14807 !! test
14808 Image with 'frameless' first.
14809 !! options
14810 parsoid=wt2html,wt2wt,html2html
14811 !! wikitext
14812 [[File:Foobar.jpg|frameless|caption]]
14813
14814 [[File:Foobar.jpg|frameless|frame|caption]]
14815
14816 [[File:Foobar.jpg|frameless|thumb|caption]]
14817 !! html/php
14818 <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>
14819 </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>
14820 </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>
14821 </p>
14822 !! html/parsoid
14823 <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>
14824 <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>
14825 <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>
14826 !! end
14827
14828 !! test
14829 Image with 'frame' first.
14830 !! options
14831 parsoid=wt2html,wt2wt,html2html
14832 !! wikitext
14833 [[File:Foobar.jpg|frame|caption]]
14834 [[File:Foobar.jpg|frame|frameless|caption]]
14835 [[File:Foobar.jpg|frame|thumb|caption]]
14836 !! html/php
14837 <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>
14838 <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>
14839 <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>
14840
14841 !! html/parsoid
14842 <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>
14843 <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>
14844 <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>
14845 !! end
14846
14847 !! test
14848 Image with 'thumb' first.
14849 !! options
14850 parsoid=wt2html,wt2wt,html2html
14851 !! wikitext
14852 [[File:Foobar.jpg|thumb|caption]]
14853 [[File:Foobar.jpg|thumb|frameless|caption]]
14854 [[File:Foobar.jpg|thumb|frame|caption]]
14855 !! html/php
14856 <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>
14857 <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>
14858 <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>
14859
14860 !! html/parsoid
14861 <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>
14862 <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>
14863 <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>
14864 !! end
14865
14866 ###################
14867 # Image sizing.
14868 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
14869 # and https://phabricator.wikimedia.org/T64258
14870 # Foobar has actual size of 1941x220
14871 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
14872 # a scalable format.
14873 # 2. Framed images always ignore size options; always render at default size.
14874 # 3. "Unspecified format" and border are the only types which can be
14875 # enlarged.
14876
14877 !! test
14878 Image: unspecified format and border enlarge
14879 !! options
14880 parsoid=wt2html,wt2wt,html2html
14881 !! wikitext
14882 [[File:Foobar.jpg|2000px]]
14883
14884 [[File:Foobar.jpg|border|2000px]]
14885 !! html/php
14886 <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>
14887 </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>
14888 </p>
14889 !! html/parsoid
14890 <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>
14891 <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>
14892 !! end
14893
14894 !! test
14895 Image: "unspecified format" and border reduce
14896 !! options
14897 parsoid=wt2html,wt2wt,html2html
14898 !! wikitext
14899 [[File:Foobar.jpg|1000px]]
14900
14901 [[File:Foobar.jpg|border|1000px]]
14902 !! html/php
14903 <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>
14904 </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>
14905 </p>
14906 !! html/parsoid
14907 <p><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/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>
14908 <p><figure-inline class="mw-image-border" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/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>
14909 !! end
14910
14911 !! test
14912 Image: thumbs reduce
14913 !! options
14914 parsoid=wt2html,wt2wt,html2html
14915 !! wikitext
14916 [[File:Foobar.jpg|thumb|50px]]
14917 !! html/php
14918 <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>
14919
14920 !! html/parsoid
14921 <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>
14922 !! end
14923
14924 !! test
14925 Image: bitmap thumbs can't be enlarged past original size, but vector can.
14926 !! options
14927 parsoid=wt2html,wt2wt,html2html
14928 !! wikitext
14929 [[File:Foobar.jpg|thumb|2000px]]
14930
14931 [[File:Foobar.svg|thumb|2000px]]
14932 !! html/php
14933 <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>
14934 <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>
14935
14936 !! html/parsoid
14937 <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>
14938 <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>
14939 !! end
14940
14941 !! test
14942 Image: frameless can reduce in size
14943 !! options
14944 parsoid=wt2html,wt2wt,html2html
14945 !! wikitext
14946 [[File:Foobar.jpg|frameless|50px]]
14947 !! html/php
14948 <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>
14949 </p>
14950 !! html/parsoid
14951 <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>
14952 !! end
14953
14954 !! test
14955 Image: bitmap frameless can't be enlarged past original size, but vector can
14956 !! options
14957 parsoid=wt2html,wt2wt,html2html
14958 !! wikitext
14959 [[File:Foobar.jpg|frameless|2000px]]
14960
14961 [[File:Foobar.svg|frameless|2000px]]
14962 !! html/php
14963 <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>
14964 </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>
14965 </p>
14966 !! html/parsoid
14967 <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>
14968 <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>
14969 !! end
14970
14971 !! test
14972 Image: framed images are always unscaled.
14973 !! options
14974 parsoid=wt2html,wt2wt,html2html
14975 !! wikitext
14976 [[File:Foobar.jpg|frame]]
14977
14978 [[File:Foobar.jpg|frame|50px]]
14979
14980 [[File:Foobar.jpg|frame|50x50px]]
14981
14982 [[File:Foobar.jpg|frame|2000px]]
14983 !! html/php
14984 <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>
14985 <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>
14986 <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>
14987 <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>
14988
14989 !! html/parsoid
14990 <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>
14991 <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>
14992 <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>
14993 <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>
14994 !! end
14995
14996 ###################
14997
14998 !! test
14999 Link to image page- image page normally doesn't exists, hence edit link
15000 Add test with existing image page
15001 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
15002 !! wikitext
15003 [[:Image:test]]
15004 !! html
15005 <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>
15006 </p>
15007 !! end
15008
15009 !! test
15010 T20784 Link to non-existent image page with caption should use caption as link text
15011 !! wikitext
15012 [[:Image:test|caption]]
15013 !! html
15014 <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>
15015 </p>
15016 !! end
15017
15018 !! test
15019 Frameless image caption with a free URL
15020 !! wikitext
15021 [[File:Foobar.jpg|http://example.com]]
15022 !! html/php
15023 <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>
15024 </p>
15025 !! html/parsoid
15026 <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>
15027 !! end
15028
15029 !! test
15030 Thumbnail image caption with a free URL
15031 !! options
15032 thumbsize=220
15033 !! wikitext
15034 [[File:Foobar.jpg|thumb|http://example.com]]
15035 !! html/php
15036 <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>
15037
15038 !! html/parsoid
15039 <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>
15040 !! end
15041
15042 !! test
15043 Thumbnail image caption with a free URL and explicit alt
15044 !! options
15045 thumbsize=220
15046 parsoid=wt2html,wt2wt,html2html
15047 !! wikitext
15048 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
15049 !! html/php
15050 <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>
15051
15052 !! html/parsoid
15053 <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>
15054 !! end
15055
15056 !! test
15057 SVG thumbnails with no language set
15058 !! options
15059 !! wikitext
15060 [[File:Foobar.svg|thumb|caption]]
15061 !! html/php
15062 <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>
15063
15064 !! html/parsoid
15065 <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>
15066 !! end
15067
15068 !! test
15069 SVG thumbnails with language de
15070 !! options
15071 parsoid=wt2html,wt2wt,html2html
15072 !! wikitext
15073 [[File:Foobar.svg|thumb|caption|lang=de]]
15074 !! html/php
15075 <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>
15076
15077 !! html/parsoid
15078 <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>
15079 !! end
15080
15081 !! test
15082 SVG thumbnails with invalid language code
15083 !! options
15084 parsoid=wt2html,wt2wt,html2html
15085 !! wikitext
15086 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
15087 !! html/php
15088 <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>
15089
15090 !! html/parsoid
15091 <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>
15092 !! end
15093
15094 !! test
15095 T3887: A ISBN with a thumbnail
15096 !! wikitext
15097 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15098 !! html/php
15099 <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>
15100
15101 !! html/parsoid
15102 <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>
15103 !! end
15104
15105 !! test
15106 T3887: A RFC with a thumbnail
15107 !! wikitext
15108 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15109 !! html/php
15110 <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>
15111
15112 !! html/parsoid
15113 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>This is <a href="https://tools.ietf.org/html/rfc12354" rel="mw:ExtLink" class="external text">RFC 12354</a></figcaption></figure>
15114 !! end
15115
15116 !! test
15117 T3887: A mailto link with a thumbnail
15118 !! wikitext
15119 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15120 !! html/php
15121 <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>
15122
15123 !! html/parsoid
15124 <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>
15125 !! end
15126
15127 # Pending resolution to T2368
15128 !! test
15129 T2648: Frameless image caption with a link
15130 !! wikitext
15131 [[File:Foobar.jpg|text with a [[link]] in it]]
15132 !! html/php
15133 <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>
15134 </p>
15135 !! html/parsoid
15136 <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>
15137 !! end
15138
15139 !! test
15140 T2648: Frameless image caption with a link (suffix)
15141 !! wikitext
15142 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15143 !! html/php
15144 <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>
15145 </p>
15146 !! html/parsoid
15147 <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>
15148 !! end
15149
15150 !! test
15151 T2648: Frameless image caption with an interwiki link
15152 !! wikitext
15153 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15154 !! html/php
15155 <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>
15156 </p>
15157 !! html/parsoid
15158 <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>
15159 !! end
15160
15161 !! test
15162 T2648: Frameless image caption with a piped interwiki link
15163 !! wikitext
15164 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15165 !! html/php
15166 <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>
15167 </p>
15168 !! html/parsoid
15169 <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>
15170 !! end
15171
15172 !! test
15173 T107474: Frameless image caption with <nowiki>
15174 !! wikitext
15175 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15176 !! html/parsoid
15177 <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>
15178 !! end
15179
15180 !! test
15181 Escape HTML special chars in image alt text
15182 !! wikitext
15183 [[File:Foobar.jpg|& < > "]]
15184 !! html/php
15185 <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>
15186 </p>
15187 !! html/parsoid
15188 <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>
15189 !! end
15190
15191 !! test
15192 Escape HTML special chars in image alt text with LanguageConverter
15193 !! options
15194 language=zh
15195 !! wikitext
15196 [[File:Foobar.jpg|& < > "]]
15197 !! html/php
15198 <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>
15199 </p>
15200 !! html/parsoid
15201 <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>
15202 !! end
15203
15204 !! test
15205 Entities in file name and attributes
15206 !! wikitext
15207 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
15208 !! html/php
15209 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
15210 </p>
15211 !! html/parsoid
15212 <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>
15213 !! end
15214
15215 !! test
15216 T2499: Alt text should have &#1234;, not &amp;1234;
15217 !! wikitext
15218 [[File:Foobar.jpg|&#9792;]]
15219 !! html/php
15220 <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>
15221 </p>
15222 !! html/parsoid
15223 <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>
15224 !! end
15225
15226 !! test
15227 Broken image caption with link
15228 !! options
15229 parsoid=wt2html,wt2wt,html2html
15230 !! wikitext
15231 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
15232 !! html/php
15233 <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.
15234 </p>
15235 !! html/parsoid
15236 <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>
15237 !! end
15238
15239 !! test
15240 Image caption containing another image
15241 !! wikitext
15242 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
15243 !! html/php
15244 <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>
15245
15246 !! html/parsoid
15247 <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>
15248 !! end
15249
15250 !! test
15251 Image: caption containing a newline
15252 !! wikitext
15253 [[File:Foobar.jpg|This
15254 *is some text]]
15255 !! html/php
15256 <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>
15257 </p>
15258 !! html/parsoid
15259 <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>
15260 !!end
15261
15262 !!test
15263 Image: caption containing leading space
15264 (The leading space should not trigger nowiki escaping in wt2wt mode)
15265 !! wikitext
15266 [[File:Foobar.jpg|thumb| bar]]
15267 !! html/php
15268 <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>
15269
15270 !! html/parsoid
15271 <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>
15272 !!end
15273
15274 # html/php output not have newlines after table, td, th, etc. because
15275 # Linker::makeThumbLink2() replaces the newlines with spaces since
15276 # the table is inside a caption.
15277 # FIXME: Verify if that circa 2004 fix is still required.
15278 !! test
15279 Image: caption containing a table
15280 !! options
15281 parsoid=wt2html,wt2wt,html2html
15282 !! wikitext
15283 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
15284 {|
15285 !Foo!!Bar
15286 |-
15287 |Foo1||Bar1
15288 |}
15289 and some more text.]]
15290 !! html/php
15291 <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>
15292
15293 !! html/parsoid
15294 <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
15295 <table>
15296 <tbody>
15297 <tr><th>Foo</th><th>Bar</th></tr>
15298 <tr>
15299 <td>Foo1</td>
15300 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
15301 !! end
15302
15303 !! test
15304 T5090: External links other than http: in image captions
15305 !! wikitext
15306 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
15307 !! html/php
15308 <div class="thumb tright"><div class="thumbinner" style="width:202px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" width="200" height="23" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/400px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>This 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>
15309
15310 !! html/parsoid
15311 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/200px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="23" width="200"/></a><figcaption>This 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>
15312 !! end
15313
15314 !! test
15315 Custom class
15316 !! options
15317 parsoid=wt2html,wt2wt,html2html
15318 !! wikitext
15319 [[Image:foobar.jpg|a|class=b]]
15320 !! html/php
15321 <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>
15322 </p>
15323 !! html/parsoid
15324 <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>
15325 !! end
15326
15327 !! test
15328 Localized image handling (1).
15329 !! options
15330 parsoid=wt2html,wt2wt,html2html
15331 language=es
15332 !! wikitext
15333 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
15334 !! html/php
15335 <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>
15336
15337 !! html/parsoid
15338 <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>
15339 !! end
15340
15341 !! test
15342 Localized image handling (2).
15343 !! options
15344 thumbsize=220
15345 parsoid=wt2html,wt2wt,html2html
15346 language=es
15347 !! wikitext
15348 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
15349 !! html/php
15350 <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>
15351
15352 !! html/parsoid
15353 <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>
15354 !! end
15355
15356 !! test
15357 Localized image handling (3).
15358 !! options
15359 language=fa
15360 parsoid=html2wt
15361 !! html/parsoid
15362 <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>
15363 !! wikitext
15364 [[File:Foobar.jpg|بندانگشتی]]
15365 !! end
15366
15367 !! test
15368 "border", "frameless" and "class" attributes on an image.
15369 !! options
15370 thumbsize=220
15371 parsoid=wt2html,wt2wt,html2html
15372 !! wikitext
15373 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
15374 !! html/php
15375 <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>
15376 </p>
15377 !! html/parsoid
15378 <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>
15379 !! end
15380
15381 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
15382 !! test
15383 Invalid image attributes (T64500)
15384 !! options
15385 thumbsize=220
15386 parsoid=wt2html,wt2wt,html2html
15387 !! wikitext
15388 [[File:Foobar.jpg|thumb|float|left|caption]]
15389
15390 [[File:Foobar.jpg|thumb|righ|caption]]
15391
15392 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
15393 !! html/php
15394 <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>
15395 <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>
15396 <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>
15397
15398 !! html/parsoid
15399 <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>
15400 <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>
15401 <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>
15402 !! end
15403
15404 !! article
15405 File:Barfoo.jpg
15406 !! text
15407 #REDIRECT [[File:Barfoo.jpg]]
15408 !! endarticle
15409
15410 # FIXME: Parsoid should run this test -- but we'd need to teach the
15411 # mockAPI about the redirected Barfoo.jpg image.
15412 !! test
15413 Redirected image
15414 !! wikitext
15415 [[Image:Barfoo.jpg]]
15416 !! html/php
15417 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
15418 </p>
15419 !! end
15420
15421 !! test
15422 Missing image with uploads disabled
15423 !! options
15424 wgEnableUploads=0
15425 !! wikitext
15426 [[File:Foobaz.jpg]]
15427 !! html/php
15428 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
15429 </p>
15430 !! html/parsoid
15431 <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>
15432 !! end
15433
15434 # Parsoid-specific testing for images
15435 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
15436 # Currently imperfect due to a flaw in the Parsoid testrunner
15437 # Work in progress
15438 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
15439 # image tests.
15440
15441 !! test
15442 Parsoid-specific image handling - simple image with size and middle alignment
15443 !! wikitext
15444 [[File:Foobar.jpg|middle|50px]]
15445 !! html/parsoid
15446 <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>
15447 !! end
15448
15449 !! test
15450 Parsoid-specific image handling - simple image with size, middle alignment,
15451 non-standard namespace alias
15452 !! options
15453 parsoid=wt2wt,wt2html,html2html
15454 !! wikitext
15455 [[Image:Foobar.jpg|middle|50px]]
15456 !! html/parsoid
15457 <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>
15458 !! end
15459
15460 !! test
15461 Parsoid-specific image handling - simple image with size and middle alignment
15462 (existing content)
15463 !! wikitext
15464 [[File:Foobar.jpg|50px|middle]]
15465 !! html/parsoid
15466 <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>
15467 !! end
15468
15469 !! test
15470 Parsoid-specific image handling - simple image with size and middle alignment
15471 and non-standard namespace name
15472 !! options
15473 parsoid=wt2html,wt2wt,html2html
15474 !! wikitext
15475 [[Image:Foobar.jpg|50px|middle]]
15476 !! html/parsoid
15477 <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>
15478 !! end
15479
15480 !! test
15481 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
15482 !! wikitext
15483 [[File:Foobar.jpg|500x10px|baseline|caption]]
15484 !! html/parsoid
15485 <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>
15486 !! end
15487
15488 !! test
15489 Parsoid-specific image handling - simple image with border and size spec
15490 !! wikitext
15491 [[File:Foobar.jpg|50px|border|caption]]
15492 !! html/parsoid
15493 <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>
15494 !! end
15495
15496 !! test
15497 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15498 !! wikitext
15499 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
15500 !! html/parsoid
15501 <figure class="mw-default-size mw-halign-left mw-valign-baseline" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption content</figcaption></figure>
15502 !! end
15503
15504 !! test
15505 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15506 (existing content)
15507 !! wikitext
15508 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
15509 !! html/parsoid
15510 <figure class="mw-default-size mw-halign-left mw-valign-baseline" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"left","ak":"left"},{"ck":"baseline","ak":"baseline"},{"ck":"caption","ak":"caption content"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>caption content</figcaption></figure>
15511 !! end
15512
15513 !! test
15514 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
15515 !! wikitext
15516 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
15517 !! html/parsoid
15518 <figure class="mw-halign-right mw-valign-middle" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a><figcaption>caption</figcaption></figure>
15519 !! end
15520
15521 !! test
15522 Parsoid-specific image handling - thumbnail with specific size, halign,
15523 valign, and caption (existing content)
15524 !! wikitext
15525 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
15526 !! html/parsoid
15527 <figure class="mw-halign-right mw-valign-middle" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"width","ak":"50x50px"},{"ck":"right","ak":"right"},{"ck":"middle","ak":"middle"},{"ck":"caption","ak":"caption"}],"size":"50x50"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"6","width":"50"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>caption</figcaption></figure>
15528 !! end
15529
15530 !! test
15531 Parsoid-specific image handling - framed image with specific size and caption
15532 (size is ignored)
15533 !! options
15534 parsoid=wt2html,wt2wt,html2html
15535 !! wikitext
15536 [[File:Foobar.jpg|frame|500x50px|caption]]
15537 !! html/parsoid
15538 <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>
15539 !! end
15540
15541 !! test
15542 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption
15543 (size is ignored)
15544 !! options
15545 parsoid=wt2html,wt2wt,html2html
15546 !! wikitext
15547 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
15548 !! html/parsoid
15549 <figure class="mw-halign-left mw-valign-baseline" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure>
15550 !! end
15551
15552 !! test
15553 Parsoid-specific image handling - frameless image with specific size, border, and caption
15554 !! wikitext
15555 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
15556 !! html/parsoid
15557 <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>
15558 !! end
15559
15560 !! test
15561 Parsoid-specific image handling - simple image with a formatted caption
15562 !! wikitext
15563 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
15564 !! html/parsoid
15565 <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>
15566 !! end
15567
15568 !! test
15569 Parsoid-specific image handling - caption with a template in it
15570 !! wikitext
15571 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
15572 !! html/parsoid
15573 <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>
15574 !! end
15575
15576 !! test
15577 Parsoid-specific image handling - caption with unbalanced tags in it
15578 !! options
15579 parsoid=wt2html,wt2wt,html2html
15580 !! wikitext
15581 foo
15582 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
15583 bar
15584 !! html/parsoid
15585 <p>foo</p>
15586 <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>
15587 <p>bar</p>
15588 !! end
15589
15590 !! test
15591 Parsoid-specific image handling - empty caption (1)
15592 !! options
15593 parsoid=wt2html,wt2wt
15594 !! wikitext
15595 [[File:Foobar.jpg|thumb|]]
15596 !! html/parsoid
15597 <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>
15598 !! end
15599
15600 # empty captions don't get serialized unless we're in the "round trip" case
15601 !! test
15602 Parsoid-specific image handling - empty caption (2)
15603 !! options
15604 parsoid=html2wt
15605 !! html/parsoid
15606 <figure class="mw-default-size" typeof="mw:Image/Thumb">
15607 <a href="./File:Foobar.jpg">
15608 <img resource="./File:Foobar.jpg"
15609 src="//example.com/images/3/3a/Foobar.jpg"
15610 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
15611 height="25" width="220"/>
15612 </a>
15613 <figcaption></figcaption>
15614 </figure>
15615 !! wikitext
15616 [[File:Foobar.jpg|thumb]]
15617 !! end
15618
15619 !! test
15620 Parsoid-specific image handling - whitespace caption
15621 !! wikitext
15622 [[File:Foobar.jpg|thumb| ]]
15623 !! html/parsoid
15624 <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>
15625 !! end
15626
15627 !! test
15628 Parsoid-specific image handling - lang option
15629 !! wikitext
15630 foo
15631 [[File:Foobar.svg|lang=de|caption]]
15632 bar
15633 !! html/parsoid
15634 <p>foo
15635 <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>
15636 bar</p>
15637 !! end
15638
15639 ## Edge case bugs in Parsoid from T93580
15640 !! test
15641 T93580: 1. Templated <ref> inside block images
15642 !! wikitext
15643 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
15644
15645 <references />
15646 !! html/parsoid
15647 <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>
15648
15649 <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>
15650 !! end
15651
15652 !! test
15653 T93580: 2. <ref> inside inline images
15654 !! wikitext
15655 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
15656
15657 <references />
15658 !! html/parsoid
15659 <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>
15660
15661 <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>
15662 !! end
15663
15664 !! test
15665 T93580: 3. Templated <ref> inside inline images
15666 !! wikitext
15667 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
15668
15669 <references />
15670 !! html/parsoid
15671 <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>
15672
15673 <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>
15674 !! end
15675
15676 ###
15677 ### Subpages
15678 ###
15679 !! article
15680 Subpage test/subpage
15681 !! text
15682 foo
15683 !! endarticle
15684
15685 !! test
15686 Subpage link
15687 !! options
15688 subpage title=[[Subpage test]]
15689 !! wikitext
15690 [[/subpage]]
15691 !! html
15692 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
15693 </p>
15694 !! end
15695
15696 !! test
15697 Subpage noslash link
15698 !! options
15699 subpage title=[[Subpage test]]
15700 !! wikitext
15701 [[/subpage/]]
15702 !! html
15703 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
15704 </p>
15705 !! end
15706
15707 !! article
15708 Subpage test/1/2/subpage
15709 !! text
15710 blah
15711 !! endarticle
15712
15713 !! test
15714 Relative subpage noslash link
15715 !! options
15716 parsoid=wt2wt,wt2html,html2html
15717 subpage title=[[Subpage test/1/2/3/4]]
15718 !! wikitext
15719 [[../../subpage/]]
15720
15721 [[../../subpage]]
15722 !! html/php
15723 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
15724 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
15725 </p>
15726 !! html/parsoid
15727 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
15728 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
15729 !! end
15730
15731 !! test
15732 Parsoid: dot-slash prefixed wikilinks
15733 !! wikitext
15734 [[./foo]]
15735
15736 [[././bar]]
15737
15738 [[././baz/]]
15739 !! html/php
15740 <p>[[./foo]]
15741 </p><p>[[././bar]]
15742 </p><p>[[././baz/]]
15743 </p>
15744 !! html/parsoid
15745 <p>[[./foo]]
15746 </p><p>[[././bar]]
15747 </p><p>[[././baz/]]
15748 </p>
15749 !! end
15750
15751 !! test
15752 Render invalid page names as plain text (T53090)
15753 !! wikitext
15754 [[./../foo|bar]]
15755 [[foo�|bar]]
15756 [[foo/.|bar]]
15757 [[foo/..|bar]]
15758 [[foo~~~bar]]
15759 [[foo>bar]]
15760 [[foo[bar]]
15761 [[.]]
15762 [[..]]
15763 [[foo././bar]]
15764 [[foo[http://example.com]xyz]]
15765
15766 [[{{echo|./../foo}}|bar]]
15767 [[{{echo|foo/.}}|bar]]
15768 [[{{echo|foo/..}}|bar]]
15769 [[{{echo|foo~~~~bar}}]]
15770 [[{{echo|foo>bar}}]]
15771 [[{{echo|foo././bar}}]]
15772 [[{{echo|foo{bar}}]]
15773 [[{{echo|foo}bar}}]]
15774 [[{{echo|foo[bar}}]]
15775 [[{{echo|foo]bar}}]]
15776 [[{{echo|foo<bar}}]]
15777 !!html/php
15778 <p>[[./../foo|bar]]
15779 [[foo�|bar]]
15780 [[foo/.|bar]]
15781 [[foo/..|bar]]
15782 [[foo~~~bar]]
15783 [[foo&gt;bar]]
15784 [[foo[bar]]
15785 [[.]]
15786 [[..]]
15787 [[foo././bar]]
15788 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
15789 </p><p>[[./../foo|bar]]
15790 [[foo/.|bar]]
15791 [[foo/..|bar]]
15792 [[foo~~~~bar]]
15793 [[foo&gt;bar]]
15794 [[foo././bar]]
15795 [[foo{bar]]
15796 [[foo}bar]]
15797 [[foo[bar]]
15798 [[foo]bar]]
15799 [[foo&lt;bar]]
15800 </p>
15801 !!html/parsoid
15802 <p>[[./../foo|bar]]
15803 [[foo�|bar]]
15804 [[foo/.|bar]]
15805 [[foo/..|bar]]
15806 [[foo~~~bar]]
15807 [[foo>bar]]
15808 [[foo[bar]]
15809 [[.]]
15810 [[..]]
15811 [[foo././bar]]
15812 [[foo<a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>xyz]]</p>
15813
15814 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
15815 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
15816 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
15817 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
15818 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
15819 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
15820 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
15821 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
15822 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
15823 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
15824 [[<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>
15825 !!end
15826
15827 !! test
15828 Disabled subpages
15829 !! wikitext
15830 [[/subpage]]
15831 !! html
15832 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
15833 </p>
15834 !! end
15835
15836 !! test
15837 T2561: {{/Subpage}}
15838 !! options
15839 subpage title=[[Page]]
15840 !! wikitext
15841 {{/Subpage}}
15842 !! html
15843 <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>
15844 </p>
15845 !! end
15846
15847 ###
15848 ### Categories
15849 ###
15850 !! article
15851 Category:MediaWiki User's Guide
15852 !! text
15853 blah
15854 !! endarticle
15855
15856 !! test
15857 Link to category
15858 !! wikitext
15859 [[:Category:MediaWiki User's Guide]]
15860 !! html
15861 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
15862 </p>
15863 !! end
15864
15865 !! test
15866 Simple category
15867 !! options
15868 cat
15869 !! wikitext
15870 [[Category:MediaWiki User's Guide]]
15871 !! html/php
15872 cat=MediaWiki_User's_Guide sort=
15873 !! html/parsoid
15874 <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"}}'/>
15875 !! end
15876
15877 !! test
15878 PAGESINCATEGORY invalid title fatal (r33546 fix)
15879 !! wikitext
15880 {{PAGESINCATEGORY:<bogus>}}
15881 !! html
15882 <p>0
15883 </p>
15884 !! end
15885
15886 !! test
15887 Category with different sort key
15888 !! options
15889 cat
15890 !! wikitext
15891 [[Category:MediaWiki User's Guide|Foo]]
15892 !! html/php
15893 cat=MediaWiki_User's_Guide sort=Foo
15894 !! html/parsoid
15895 <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"}}'/>
15896 !! end
15897
15898 !! test
15899 Category with identical sort key
15900 !! options
15901 cat
15902 !! wikitext
15903 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15904 !! html/php
15905 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
15906 !! html/parsoid
15907 <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"}}'/>
15908 !! end
15909
15910 !! test
15911 Category with empty sort key
15912 !! options
15913 cat
15914 pst
15915 !! wikitext
15916 [[Category:MediaWiki User's Guide|]]
15917 !! html/php
15918 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15919 !! end
15920
15921 !! test
15922 Category with empty sort key and parentheses
15923 !! options
15924 cat
15925 pst
15926 !! wikitext
15927 [[Category:Foo (bar)|]]
15928 !! html/php
15929 [[Category:Foo (bar)|Foo]]
15930 !! end
15931
15932 !! test
15933 Category with link tail
15934 !! options
15935 cat
15936 pst
15937 !! wikitext
15938 123[[Category:Foo]]456
15939 !! html/php
15940 123[[Category:Foo]]456
15941 !! end
15942
15943 !! test
15944 Category with template
15945 !! options
15946 cat
15947 pst
15948 !! wikitext
15949 [[Category:{{echo|Foo}}]]
15950 !! html/php
15951 [[Category:{{echo|Foo}}]]
15952 !! end
15953
15954 !! test
15955 Category with template in sort key
15956 !! options
15957 cat
15958 pst
15959 !! wikitext
15960 [[Category:Foo|{{echo|Bar}}]]
15961 !! html/php
15962 [[Category:Foo|{{echo|Bar}}]]
15963 !! end
15964
15965 !! test
15966 Category with template in sort key and title
15967 !! options
15968 cat
15969 pst
15970 !! wikitext
15971 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15972 !! html/php
15973 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15974 !! end
15975
15976 ## We used to, but no longer wt2wt this test since the default serializer
15977 ## will normalize all categories to serialize on their own line.
15978 ## This wikitext usage is going to be fairly uncommon in production and
15979 ## selser will take care of preserving formatting in those scenarios.
15980 !! test
15981 Category / paragraph interactions
15982 !! options
15983 parsoid=wt2html
15984 !! wikitext
15985 Foo [[Category:Baz]] Bar
15986
15987 Foo [[Category:Baz]]
15988 Bar
15989
15990 Foo
15991 [[Category:Baz]]
15992 Bar
15993
15994 Foo
15995 [[Category:Baz]] Bar
15996
15997 Foo
15998 [[Category:Baz]]
15999 [[Category:Baz]]
16000 [[Category:Baz]]
16001 Bar
16002
16003 [[Category:Baz]]
16004 [[Category:Baz]]
16005 [[Category:Baz]]
16006
16007 [[Category:Baz]]
16008 {{echo|[[Category:Baz]]}}
16009 [[Category:Baz]]
16010 !! html/php
16011 <p>Foo Bar
16012 </p><p>Foo
16013 Bar
16014 </p><p>Foo
16015 Bar
16016 </p><p>Foo Bar
16017 </p><p>Foo
16018 Bar
16019 </p>
16020 !! html/parsoid
16021 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16022 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16023 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16024 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16025 <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>
16026 <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}}]}'/>
16027 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16028 !! end
16029
16030 ## We used to, but no longer wt2wt this test since the default serializer
16031 ## will normalize all categories to serialize on their own line.
16032 ## This wikitext usage is going to be fairly uncommon in production and
16033 ## selser will take care of preserving formatting in those scenarios.
16034 ##
16035 ## The whitespace on the empty line is part of the test. Please do not delete
16036 !! test
16037 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16038 !! options
16039 parsoid=wt2html
16040 !! wikitext
16041 This
16042
16043 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16044
16045 {{echo|[[Category:Foo]] and so should this!}}
16046 !! html/php
16047 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16048 </p>
16049 !! html/parsoid
16050 <p>This
16051
16052 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16053
16054 <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>
16055 !! end
16056
16057 ## Parsoid will not try to wt2wt this while preserving newlines because
16058 ## it suppresses excess newlines within list items -- and we don't want to
16059 ## introduce a special case just for categories, which is, in reality somewhat
16060 ## odd behavior -- categories are unlikely to be used in list items like this
16061 ## in top-level pages and are only likely to show up in template-generated
16062 ## list items where this RT-ing is a non-issue.
16063 ##
16064 ## The whitespace on the empty line is part of the test. Please do not delete
16065 !! test
16066 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16067 !! options
16068 parsoid=wt2html
16069 !! wikitext
16070 * This
16071
16072 [[Category:Foo]] and this should be part of the same list item
16073 * So should this
16074
16075 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16076 !! html
16077 <ul><li>This and this should be part of the same list item</li>
16078 <li>So should this and this should be part of the same list item</li></ul>
16079 !! html/parsoid
16080 <ul>
16081 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16082 <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>
16083 </ul>
16084 !! end
16085
16086 ## Newlines and categories that follow the last item of a list
16087 ## are treated differently because this (list followed by categories)
16088 ## is an extremely common pattern on wikis.
16089 !! test
16090 3. Categories and newlines: newline suppression for last list item should RT properly
16091 !! wikitext
16092 * a
16093 * b
16094
16095 [[Category:Foo]]
16096
16097 [[Category:Bar]]
16098 [[Category:Baz]]
16099 !! html/parsoid
16100 <ul><li> a</li>
16101 <li> b</li></ul>
16102
16103 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16104
16105 <link rel="mw:PageProp/Category" href="./Category:Bar" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16106 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16107 !! end
16108
16109 !! test
16110 4. Categories and newlines: newline suppression for last list item should RT properly
16111 !! wikitext
16112 * a
16113 **** b
16114
16115 [[Category:Foo]]
16116 !! html/parsoid
16117 <ul><li> a
16118 <ul><li><ul><li><ul><li> b</li></ul></li></ul></li></ul></li></ul>
16119
16120 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16121 !! end
16122
16123 ## only wt2html for this to make sure the algo only applies to the rightmost path
16124 !! test
16125 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16126 !! options
16127 parsoid=wt2html
16128 !! wikitext
16129 * a
16130 ** b
16131 [[Category:Foo]]
16132 * c
16133 ** d
16134 [[Category:Foo]]
16135 !! html/parsoid
16136 <ul><li> a
16137 <ul><li> b
16138 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16139 <li> c
16140 <ul><li> d</li></ul></li></ul>
16141 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16142 !! end
16143
16144 ## We used to, but no longer wt2wt this test since the default serializer
16145 ## will normalize all categories to serialize on their own line.
16146 ## This wikitext usage is going to be fairly uncommon in production and
16147 ## selser will take care of preserving formatting in those scenarios.
16148 !! test
16149 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16150 !! options
16151 parsoid=wt2html
16152 !! wikitext
16153 * a [[Category:Foo]]
16154 !! html/parsoid
16155 <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>
16156 !! end
16157
16158 # This test also demonstrates because of newline+category tunneling
16159 # through the list hander, template wrapping doesn't expand to the
16160 # containing list when the list item swallows the category.
16161 !! test
16162 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16163 !! wikitext
16164 * {{echo|a
16165 [[Category:Foo]]}}
16166 !! html/parsoid
16167 <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
16168 </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>
16169 !! end
16170
16171 !! test
16172 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
16173 !! wikitext
16174 * a
16175
16176 {{echo|[[Category:Foo]]
16177 [[Category:Bar]]}}
16178 [[Category:Baz]]
16179 !! html/parsoid
16180 <ul><li> a</li></ul>
16181
16182 <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">
16183 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16184 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16185 !! end
16186
16187 !! test
16188 9. Categories and newlines: should behave properly with linkprefix (T87753)
16189 !! options
16190 language=ar
16191 !! wikitext
16192 foo bar
16193 foo bar
16194 [[تصنيف:Foo]]
16195 [[تصنيف:Bar]]
16196 !! html/php
16197 <p>foo bar
16198 foo bar
16199 </p>
16200 !! html/parsoid
16201 <p>foo bar
16202 foo bar</p>
16203 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
16204 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
16205 !! end
16206
16207 !! test
16208 10. No regressions on internal links following category (T174639)
16209 !! options
16210 parsoid=wt2html,html2html
16211 !! wikitext
16212 [[Category:Foo]]<div>a
16213
16214 [[Foo]]</div>
16215 !! html/php
16216 <div>a
16217 <a href="/wiki/Foo" title="Foo">Foo</a></div>
16218
16219 !! html/parsoid
16220 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
16221
16222 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
16223 !! end
16224
16225 # Note that Parsoid differs slightly from PHP due to T175421
16226 !! test
16227 11. Special case where only newlines separate links (T175416)
16228 !! options
16229 parsoid=wt2html,html2html
16230 !! wikitext
16231 [[Category:Foo]]
16232
16233 [[Foo]][[es:Alimento]]
16234
16235 [[Foo]]
16236 !! html/php
16237 <p><br />
16238 <a href="/wiki/Foo" title="Foo">Foo</a>
16239 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
16240 </p>
16241 !! html/parsoid
16242 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16243
16244 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16245
16246 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
16247 !! end
16248
16249 !! test
16250 Category links with multiple namespaces
16251 !! wikitext
16252 [[Category:Project:Foo]]
16253 !! html/parsoid
16254 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
16255 !! end
16256
16257 !! test
16258 Parsoid: Serialize link to category page with colon escape
16259 !! options
16260 parsoid
16261 !! wikitext
16262
16263 [[:Category:Foo]]
16264 [[:Category:Foo|Bar]]
16265 !! html
16266 <p>
16267 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
16268 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
16269 </p>
16270 !! end
16271
16272 # We used to, but no longer wt2wt this test since the default serializer
16273 # will normalize all categories to serialize on their own line.
16274 # This wikitext usage is going to be fairly uncommon in production and
16275 # selser will take care of preventing whitespace insertion if this
16276 # occurs in an article.
16277 #
16278 # html2html disabled for the same reason (whitespace insertion between
16279 # x and y).
16280 #
16281 # html2wt disabled because it localizes the "Category" namespace.
16282 !! test
16283 Link prefix/suffixes aren't applied to category links
16284 !! options
16285 parsoid=wt2html
16286 language=is
16287 !! wikitext
16288 x[[Category:Foo]]y
16289 !! html/php
16290 <p>xy
16291 </p>
16292 !! html/parsoid
16293 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
16294 !! end
16295
16296 !! test
16297 Link prefix/suffixes aren't applied to language links
16298 !! options
16299 parsoid=wt2html
16300 language=is
16301 !! wikitext
16302 x[[es:Foo]]y
16303 !! html/php
16304 <p>xy
16305 </p>
16306 !! html/parsoid
16307 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
16308 !! end
16309
16310 !! test
16311 Parsoid: Serialize link to file page with colon escape
16312 !! options
16313 parsoid
16314 !! wikitext
16315
16316 [[:File:Foo.png]]
16317 [[:File:Foo.png|Bar]]
16318 !! html
16319 <p>
16320 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
16321 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
16322 </p>
16323 !! end
16324
16325 !! test
16326 Parsoid: Serialize a genuine category link without colon escape
16327 !! options
16328 parsoid
16329 !! wikitext
16330 [[Category:Foo]]
16331 [[Category:Foo|Bar]]
16332 !! html
16333 <link rel="mw:PageProp/Category" href="./Category:Foo">
16334 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
16335 !! end
16336
16337 !! test
16338 Normalize hrefs properly before testing for invalid link targets (T72894)
16339 !! options
16340 parsoid=html2wt
16341 !! html/parsoid
16342 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
16343 !! wikitext
16344 [[Category:Toxine bactérienne]]
16345 !! end
16346
16347 !! test
16348 Parsoid: Defaultsort
16349 !! wikitext
16350 {{DEFAULTSORT:Foo}}
16351 !! html/parsoid
16352 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
16353 !! end
16354
16355 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
16356 # But, this is a limitation of our representation and is documented in
16357 # TemplateHandler.js in processSpecialMagicWord
16358 !! test
16359 Parsoid: Defaultsort (template-generated)
16360 !! wikitext
16361 {{{{echo|DEFAULTSORT}}:Foo}}
16362 !! html/parsoid
16363 <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"}]]}'/>
16364 !! end
16365
16366 ###
16367 ### Inter-language links
16368 ###
16369 !! test
16370 Interlanguage links
16371 !! options
16372 ill
16373 !! wikitext
16374 [[es:Alimento]]
16375 [[fr:Nourriture]]
16376 [[zh:食品]]
16377 !! html/php
16378 es:Alimento fr:Nourriture zh:食品
16379 !! html/parsoid
16380 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16381 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
16382 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
16383 !! end
16384
16385 !! test
16386 Duplicate interlanguage links (T26502)
16387 !! options
16388 ill
16389 !! wikitext
16390 [[es:1]]
16391 [[es:2]]
16392 [[fr:1]]
16393 [[fr:2]]
16394 !! html/php
16395 es:1 fr:1
16396 !! html/parsoid
16397 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
16398 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
16399 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
16400 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
16401 !! end
16402
16403 ###
16404 ### Sections
16405 ###
16406 !! test
16407 Basic section headings
16408 !! wikitext
16409 ==Headline 1==
16410 Some text
16411
16412 ==Headline 2==
16413 More
16414 ===Smaller headline===
16415 Blah blah
16416 !! html
16417 <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>
16418 <p>Some text
16419 </p>
16420 <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>
16421 <p>More
16422 </p>
16423 <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>
16424 <p>Blah blah
16425 </p>
16426 !! end
16427
16428 !! test
16429 Section headings with TOC
16430 !! wikitext
16431 ==Headline 1==
16432 ===Subheadline 1===
16433 =====Skipping a level=====
16434 ======Skipping a level======
16435
16436 ==Headline 2==
16437 Some text
16438 ===Another headline===
16439 !! html
16440 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16441 <ul>
16442 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
16443 <ul>
16444 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
16445 <ul>
16446 <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>
16447 <ul>
16448 <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>
16449 </ul>
16450 </li>
16451 </ul>
16452 </li>
16453 </ul>
16454 </li>
16455 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
16456 <ul>
16457 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
16458 </ul>
16459 </li>
16460 </ul>
16461 </div>
16462
16463 <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>
16464 <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>
16465 <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>
16466 <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>
16467 <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>
16468 <p>Some text
16469 </p>
16470 <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>
16471
16472 !! end
16473
16474 !! test
16475 TOC anchors don't collide
16476 !! wikitext
16477 __FORCETOC__
16478 ==Headline 2==
16479 ==Headline==
16480 ==Headline 2==
16481 ==Headline==
16482 !! html/php
16483 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16484 <ul>
16485 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
16486 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
16487 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
16488 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
16489 </ul>
16490 </div>
16491
16492 <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>
16493 <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>
16494 <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>
16495 <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>
16496
16497 !! end
16498
16499 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
16500 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
16501 !! test
16502 Handling of sections up to level 6 and beyond
16503 !! options
16504 parsoid=wt2html
16505 !! wikitext
16506 =Level 1 Heading=
16507 ==Level 2 Heading==
16508 ===Level 3 Heading===
16509 ====Level 4 Heading====
16510 =====Level 5 Heading=====
16511 ======Level 6 Heading======
16512 =======Level 7 Heading=======
16513 ========Level 8 Heading========
16514 =========Level 9 Heading=========
16515 ==========Level 10 Heading==========
16516 !! html/php
16517 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16518 <ul>
16519 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
16520 <ul>
16521 <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>
16522 <ul>
16523 <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>
16524 <ul>
16525 <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>
16526 <ul>
16527 <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>
16528 <ul>
16529 <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>
16530 <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>
16531 <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>
16532 <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>
16533 <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>
16534 </ul>
16535 </li>
16536 </ul>
16537 </li>
16538 </ul>
16539 </li>
16540 </ul>
16541 </li>
16542 </ul>
16543 </li>
16544 </ul>
16545 </div>
16546
16547 <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>
16548 <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>
16549 <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>
16550 <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>
16551 <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>
16552 <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>
16553 <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>
16554 <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>
16555 <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>
16556 <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>
16557
16558 !! html/parsoid
16559 <h1 id="Level_1_Heading" data-parsoid='{}'>Level 1 Heading</h1>
16560 <h2 id="Level_2_Heading" data-parsoid='{}'>Level 2 Heading</h2>
16561 <h3 id="Level_3_Heading" data-parsoid='{}'>Level 3 Heading</h3>
16562 <h4 id="Level_4_Heading" data-parsoid='{}'>Level 4 Heading</h4>
16563 <h5 id="Level_5_Heading" data-parsoid='{}'>Level 5 Heading</h5>
16564 <h6 id="Level_6_Heading" data-parsoid='{}'>Level 6 Heading</h6>
16565 <h6 id="=Level_7_Heading=" data-parsoid='{}'><span id=".3DLevel_7_Heading.3D" typeof="mw:FallbackId"></span>=Level 7 Heading=</h6>
16566 <h6 id="==Level_8_Heading==" data-parsoid='{}'><span id=".3D.3DLevel_8_Heading.3D.3D" typeof="mw:FallbackId"></span>==Level 8 Heading==</h6>
16567 <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>
16568 <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>
16569 !! end
16570
16571 !! test
16572 TOC regression (T11764)
16573 !! wikitext
16574 ==title 1==
16575 ===title 1.1===
16576 ====title 1.1.1====
16577 ===title 1.2===
16578 ==title 2==
16579 ===title 2.1===
16580 !! html
16581 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16582 <ul>
16583 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16584 <ul>
16585 <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>
16586 <ul>
16587 <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>
16588 </ul>
16589 </li>
16590 <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>
16591 </ul>
16592 </li>
16593 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16594 <ul>
16595 <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>
16596 </ul>
16597 </li>
16598 </ul>
16599 </div>
16600
16601 <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>
16602 <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>
16603 <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>
16604 <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>
16605 <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>
16606 <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>
16607
16608 !! end
16609
16610 !! test
16611 TOC for heading containing <span id="..."></span> (T96153)
16612 !! wikitext
16613 __FORCETOC__
16614 ==<span id="old-anchor"></span>New title==
16615 !! html/php
16616 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16617 <ul>
16618 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
16619 </ul>
16620 </div>
16621
16622 <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>
16623
16624 !! end
16625
16626 !! test
16627 TOC with wgMaxTocLevel=3 (T8204)
16628 !! options
16629 wgMaxTocLevel=3
16630 !! wikitext
16631 ==title 1==
16632 ===title 1.1===
16633 ====title 1.1.1====
16634 ===title 1.2===
16635 ==title 2==
16636 ===title 2.1===
16637 !! html
16638 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16639 <ul>
16640 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16641 <ul>
16642 <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>
16643 <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>
16644 </ul>
16645 </li>
16646 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16647 <ul>
16648 <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>
16649 </ul>
16650 </li>
16651 </ul>
16652 </div>
16653
16654 <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>
16655 <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>
16656 <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>
16657 <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>
16658 <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>
16659 <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>
16660
16661 !! end
16662
16663 !! test
16664 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
16665 !! options
16666 wgMaxTocLevel=3
16667 !! wikitext
16668 ==Section 1==
16669 ===Section 1.1===
16670 ====Section 1.1.1====
16671 ====Section 1.1.1.1====
16672 ==Section 2==
16673 !! html
16674 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16675 <ul>
16676 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
16677 <ul>
16678 <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>
16679 </ul>
16680 </li>
16681 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
16682 </ul>
16683 </div>
16684
16685 <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>
16686 <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>
16687 <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>
16688 <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>
16689 <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>
16690
16691 !! end
16692
16693
16694 !! test
16695 Resolving duplicate section names
16696 !! wikitext
16697 ==Foo bar==
16698 ==Foo bar==
16699 !! html
16700 <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>
16701 <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>
16702
16703 !! end
16704
16705 !! test
16706 Resolving duplicate section names with differing case (T12721)
16707 !! wikitext
16708 ==Foo bar==
16709 ==Foo Bar==
16710 !! html
16711 <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>
16712 <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>
16713
16714 !! end
16715
16716 !! article
16717 Template:sections
16718 !! text
16719 ===Section 1===
16720 ==Section 2==
16721 !! endarticle
16722
16723 !! test
16724 Template with sections, __NOTOC__
16725 !! wikitext
16726 __NOTOC__
16727 ==Section 0==
16728 {{sections}}
16729 ==Section 4==
16730 !! html
16731 <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>
16732 <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>
16733 <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>
16734 <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>
16735
16736 !! end
16737
16738 !! test
16739 __NOEDITSECTION__ keyword
16740 !! wikitext
16741 __NOEDITSECTION__
16742 ==Section 1==
16743 ==Section 2==
16744 !! html
16745 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
16746 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
16747
16748 !! end
16749
16750 !! test
16751 Link inside a section heading
16752 !! wikitext
16753 ==Section with a [[Main Page|link]] in it==
16754 !! html
16755 <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>
16756
16757 !! end
16758
16759 !! test
16760 TOC regression (T14077)
16761 !! wikitext
16762 __TOC__
16763 ==title 1==
16764 ===title 1.1===
16765 ==title 2==
16766 !! html
16767 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16768 <ul>
16769 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16770 <ul>
16771 <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>
16772 </ul>
16773 </li>
16774 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
16775 </ul>
16776 </div>
16777
16778 <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>
16779 <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>
16780 <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>
16781
16782 !! end
16783
16784 !! test
16785 T3219 URL next to image (good)
16786 !! wikitext
16787 http://example.com [[File:Foobar.jpg]]
16788 !! html/php
16789 <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>
16790 </p>
16791 !! html/parsoid
16792 <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>
16793 !!end
16794
16795 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
16796 !! test
16797 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
16798 !! options
16799 parsoid=wt2html,html2html
16800 !! wikitext
16801 ===
16802 The line above must have a trailing space!
16803 === <!--
16804 --> <!-- -->
16805 But just in case it doesn't...
16806 !! html/php
16807 <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>
16808 <p>The line above must have a trailing space!
16809 </p>
16810 <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>
16811 <p>But just in case it doesn't...
16812 </p>
16813 !! html/parsoid
16814 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
16815 <p>The line above must have a trailing space!</p>
16816 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
16817 --> <!-- -->
16818 <p>But just in case it doesn't...</p>
16819 !! end
16820
16821 !! test
16822 Header with special characters (T27462)
16823 !! wikitext
16824 The tooltips shall not show entities to the user (ie. be double escaped)
16825
16826 ==text > text==
16827 section 1
16828
16829 ==text < text==
16830 section 2
16831
16832 ==text & text==
16833 section 3
16834
16835 ==text ' text==
16836 section 4
16837
16838 ==text " text==
16839 section 5
16840 !! html/php
16841 <p>The tooltips shall not show entities to the user (ie. be double escaped)
16842 </p>
16843 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16844 <ul>
16845 <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>
16846 <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>
16847 <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>
16848 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
16849 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
16850 </ul>
16851 </div>
16852
16853 <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>
16854 <p>section 1
16855 </p>
16856 <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>
16857 <p>section 2
16858 </p>
16859 <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>
16860 <p>section 3
16861 </p>
16862 <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>
16863 <p>section 4
16864 </p>
16865 <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>
16866 <p>section 5
16867 </p>
16868 !! html/parsoid
16869 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
16870
16871 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span>text > text</h2>
16872 <p>section 1</p>
16873
16874 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span>text &lt; text</h2>
16875 <p>section 2</p>
16876
16877 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span>text &amp; text</h2>
16878 <p>section 3</p>
16879
16880 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span>text ' text</h2>
16881 <p>section 4</p>
16882
16883 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span>text " text</h2>
16884 <p>section 5</p>
16885 !! end
16886
16887 !! test
16888 Header with space, plus and underscore as entity
16889 !! wikitext
16890 Id should not contain + for spaces
16891
16892 ==Space between Text==
16893 section 1
16894
16895 ==Space-Entity&#32;between&#32;Text==
16896 section 2
16897
16898 ==Plus+between+Text==
16899 section 3
16900
16901 ==Plus-Entity&#43;between&#43;Text==
16902 section 4
16903
16904 ==Underscore_between_Text==
16905 section 5
16906
16907 ==Underscore-Entity&#95;between&#95;Text==
16908 section 6
16909
16910 [[#Space between Text]]
16911 [[#Space-Entity&#32;between&#32;Text]]
16912 [[#Plus+between+Text]]
16913 [[#Plus-Entity&#43;between&#43;Text]]
16914 [[#Underscore_between_Text]]
16915 [[#Underscore-Entity&#95;between&#95;Text]]
16916 !! html/php
16917 <p>Id should not contain + for spaces
16918 </p>
16919 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16920 <ul>
16921 <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>
16922 <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>
16923 <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>
16924 <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>
16925 <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>
16926 <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>
16927 </ul>
16928 </div>
16929
16930 <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>
16931 <p>section 1
16932 </p>
16933 <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>
16934 <p>section 2
16935 </p>
16936 <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>
16937 <p>section 3
16938 </p>
16939 <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>
16940 <p>section 4
16941 </p>
16942 <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>
16943 <p>section 5
16944 </p>
16945 <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>
16946 <p>section 6
16947 </p><p><a href="#Space_between_Text">#Space between Text</a>
16948 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
16949 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
16950 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
16951 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
16952 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
16953 </p>
16954 !! html/parsoid
16955 <p>Id should not contain + for spaces</p>
16956
16957 <h2 id="Space_between_Text">Space between Text</h2>
16958 <p>section 1</p>
16959
16960 <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>
16961 <p>section 2</p>
16962
16963 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus+between+Text</h2>
16964 <p>section 3</p>
16965
16966 <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>
16967 <p>section 4</p>
16968
16969 <h2 id="Underscore_between_Text">Underscore_between_Text</h2>
16970 <p>section 5</p>
16971
16972 <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>
16973 <p>section 6</p>
16974
16975 <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>
16976 <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>
16977 <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>
16978 <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>
16979 <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>
16980 <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>
16981 !! end
16982
16983 # Parsoid html2wt disabled because it adds padding spaces around =
16984 !! test
16985 Headers with excess '=' characters
16986 (Are similar tests necessary beyond the 1st level?)
16987 !! options
16988 parsoid=wt2html,wt2wt,html2html
16989 !! wikitext
16990 =foo==
16991 ==foo=
16992 =''italic'' heading==
16993 ==''italic'' heading=
16994 !! html/php
16995 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16996 <ul>
16997 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
16998 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
16999 <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>
17000 <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>
17001 </ul>
17002 </div>
17003
17004 <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>
17005 <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>
17006 <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>
17007 <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>
17008
17009 !! html/parsoid
17010 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
17011 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
17012 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
17013 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
17014 !! end
17015
17016 !! test
17017 HTML headers vs TOC (T25393)
17018 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17019 !! wikitext
17020 <h1>Header 1</h1>
17021 ==Header 1.1==
17022 ==Header 1.2==
17023
17024 <h1>Header 2
17025 </h1>
17026 ==Header 2.1==
17027 ==Header 2.2==
17028 __NOEDITSECTION__
17029 !! html/php
17030 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
17031 <ul>
17032 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17033 <ul>
17034 <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>
17035 <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>
17036 </ul>
17037 </li>
17038 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17039 <ul>
17040 <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>
17041 <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>
17042 </ul>
17043 </li>
17044 </ul>
17045 </div>
17046
17047 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17048 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17049 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17050 <h1><span class="mw-headline" id="Header_2">Header 2
17051 </span></h1>
17052 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17053 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17054
17055 !! html/parsoid
17056 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
17057 <h2 id="Header_1.1" data-parsoid='{}'>Header 1.1</h2>
17058 <h2 id="Header_1.2" data-parsoid='{}'>Header 1.2</h2>
17059
17060 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
17061 </h1>
17062 <h2 id="Header_2.1" data-parsoid='{}'>Header 2.1</h2>
17063 <h2 id="Header_2.2" data-parsoid='{}'>Header 2.2</h2>
17064 <meta property="mw:PageProp/noeditsection"/>
17065 !! end
17066
17067 !! test
17068 Single-line or multiline-comments can follow headings
17069 !! options
17070 parsoid=wt2html,wt2wt
17071 !! wikitext
17072 ==foo==<!---->
17073 ==bar==<!--c1-->
17074 ==baz==<!--
17075 c2
17076 c3-->
17077 !! html/php
17078 <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>
17079 <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>
17080 <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>
17081
17082 !! html/parsoid
17083 <h2 id="foo">foo</h2><!---->
17084 <h2 id="bar">bar</h2><!--c1-->
17085 <h2 id="baz">baz</h2><!--
17086 c2
17087 c3-->
17088 !! end
17089
17090 !! test
17091 T3219 URL next to image (broken)
17092 !! wikitext
17093 http://example.com[[File:Foobar.jpg]]
17094 !! html/php
17095 <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>
17096 </p>
17097 !! html/parsoid
17098 <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>
17099 !!end
17100
17101 !! test
17102 T3186 news: in the middle of text
17103 !! wikitext
17104 http://en.wikinews.org/wiki/Wikinews:Workplace
17105 !! html
17106 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
17107 </p>
17108 !!end
17109
17110
17111 !! test
17112 Namespaced link must have a title
17113 !! wikitext
17114 [[Project:]]
17115 !! html
17116 <p>[[Project:]]
17117 </p>
17118 !!end
17119
17120 !! test
17121 Namespaced link must have a title (bad fragment version)
17122 !! wikitext
17123 [[Project:#fragment]]
17124 !! html
17125 <p>[[Project:#fragment]]
17126 </p>
17127 !!end
17128
17129
17130 ###
17131 ### HTML tags and HTML attributes
17132 ###
17133
17134 !! test
17135 div with no attributes
17136 !! wikitext
17137 <div>HTML rocks</div>
17138 !! html
17139 <div>HTML rocks</div>
17140
17141 !! end
17142
17143 !! test
17144 div with double-quoted attribute
17145 !! wikitext
17146 <div id="rock">HTML rocks</div>
17147 !! html
17148 <div id="rock">HTML rocks</div>
17149
17150 !! end
17151
17152 !! test
17153 div with single-quoted attribute
17154 !! wikitext
17155 <div id='rock'>HTML rocks</div>
17156 !! html
17157 <div id="rock">HTML rocks</div>
17158
17159 !! end
17160
17161 !! test
17162 div with unquoted attribute
17163 !! wikitext
17164 <div id=rock>HTML rocks</div>
17165 !! html
17166 <div id="rock">HTML rocks</div>
17167
17168 !! end
17169
17170 !! test
17171 div with illegal double attributes
17172 !! wikitext
17173 <div id="a" id="b">HTML rocks</div>
17174 !! html
17175 <div id="b">HTML rocks</div>
17176
17177 !!end
17178
17179 !! test
17180 div with empty attribute value, space before equals
17181 !! options
17182 parsoid=wt2html,html2html
17183 !! wikitext
17184 <div class =>HTML rocks</div>
17185 !! html/php
17186 <div class="">HTML rocks</div>
17187
17188 !! html/parsoid
17189 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17190 !! end
17191
17192 !! test
17193 div with multiple empty attribute values
17194 !! config
17195 wgFragmentMode=[ 'html5', 'legacy' ]
17196 !! options
17197 parsoid=wt2html,html2html
17198 !! wikitext
17199 <div id= title=>HTML rocks</div>
17200 !! html/php
17201 <div id="title=">HTML rocks</div>
17202
17203 !! html/parsoid
17204 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17205 !! end
17206
17207 # FIXME Parsoid doesn't actually match PHP here.
17208 # Probably we should use the synthetic <foo /> or <indicator>
17209 # extensions for this test, which are enabled when running parser tests.
17210 !! test
17211 Extension tag in attribute value
17212 !! wikitext
17213 <span title="<translate>123</translate>">ok</span>
17214 !! html/php+disabled
17215 <p>&lt;span title="&lt;translate&gt;123&lt;/translate&gt;"&gt;ok&lt;/span&gt;
17216 </p>
17217 !! html/parsoid
17218 <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>
17219 !! end
17220
17221 !! test
17222 table with multiple empty attribute values
17223 !! options
17224 parsoid=wt2html,html2html
17225 !! wikitext
17226 {| title= id=
17227 |hi
17228 |}
17229 !! html/php
17230 <table title="id=">
17231 <tr>
17232 <td>hi
17233 </td></tr></table>
17234
17235 !! html/parsoid
17236 <table title="id=">
17237 <tbody><tr><td>hi</td></tr>
17238 </tbody></table>
17239 !! end
17240
17241 !! test
17242 div with braces in attribute value
17243 !! wikitext
17244 <div title="{}">Foo</div>
17245 !! html/php
17246 <div title="&#123;&#125;">Foo</div>
17247
17248 !! html/parsoid
17249 <div title="{}">Foo</div>
17250 !! end
17251
17252 !! test
17253 div with empty attribute value, no space before equals
17254 !! options
17255 parsoid=wt2html,html2html
17256 !! wikitext
17257 <div class=>HTML rocks</div>
17258 !! html/php
17259 <div class="">HTML rocks</div>
17260
17261 !! html/parsoid
17262 <div class="">HTML rocks</div>
17263 !! end
17264
17265 !! test
17266 HTML multiple attributes correction
17267 !! wikitext
17268 <p class="error" class="awesome">Awesome!</p>
17269 !! html
17270 <p class="awesome">Awesome!</p>
17271
17272 !!end
17273
17274 !! test
17275 Table multiple attributes correction
17276 !! wikitext
17277 {|
17278 !+ class="error" class="awesome"|status
17279 |}
17280 !! html
17281 <table>
17282 <tr>
17283 <th class="awesome">status
17284 </th></tr></table>
17285
17286 !!end
17287
17288 !! test
17289 DIV IN UPPERCASE
17290 !! wikitext
17291 <DIV ID="x">HTML ROCKS</DIV>
17292 !! html
17293 <div id="x">HTML ROCKS</div>
17294
17295 !!end
17296
17297 !! test
17298 Non-ASCII pseudo-tags are rendered as text
17299 !! wikitext
17300 <khyô>
17301 !! html
17302 <p>&lt;khyô&gt;
17303 </p>
17304 !! end
17305
17306 !! test
17307 Pseudo-tag with URL 'name' renders as url link
17308 !! wikitext
17309 <http://example.com/>
17310 !! html
17311 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
17312 </p>
17313 !! end
17314
17315 !! test
17316 text with amp in the middle of nowhere
17317 !! wikitext
17318 Remember AT&T?
17319 !! html
17320 <p>Remember AT&amp;T?
17321 </p>
17322 !! end
17323
17324 !! test
17325 text with character entity: eacute
17326 !! wikitext
17327 I always thought &eacute; was a cute letter.
17328 !! html+tidy
17329 <p>I always thought &#233; was a cute letter.
17330 </p>
17331 !! end
17332
17333 !! test
17334 text with entity-escaped character entity-like string: eacute
17335 !! wikitext
17336 I always thought &amp;eacute; was a cute letter.
17337 !! html
17338 <p>I always thought &amp;eacute; was a cute letter.
17339 </p>
17340 !! end
17341
17342 !! test
17343 text with undefined character entity: xacute
17344 !! wikitext
17345 I always thought &xacute; was a cute letter.
17346 !! html
17347 <p>I always thought &amp;xacute; was a cute letter.
17348 </p>
17349 !! end
17350
17351 !! test
17352 HTML5 tags
17353 !! wikitext
17354 <data value="5">five</data>
17355 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17356 <mark>This highlighted text</mark>
17357 !! html
17358 <p><data value="5">five</data>
17359 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17360 <mark>This highlighted text</mark>
17361 </p>
17362 !! end
17363
17364 !! test
17365 HTML tag with leading space is parsed as text
17366 !! wikitext
17367 < div>foo< /div>
17368 !! html
17369 <p>&lt; div&gt;foo&lt; /div&gt;
17370 </p>
17371 !! end
17372
17373 ## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
17374 ## the HTML5 parsing spec.
17375 !! test
17376 Element with broken attribute syntax
17377 !! options
17378 parsoid=wt2html
17379 !! wikitext
17380 <div style=" style="123">hi</div>
17381 <div =>ho</div>
17382 !! html/php
17383 <div style="123">hi</div>
17384 <div>ho</div>
17385
17386 !! html/parsoid
17387 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
17388 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
17389 !! end
17390
17391 ###
17392 ### Nesting tests (see T43545, T52604, T53081)
17393 ###
17394
17395 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
17396 # Note that html2wt is considerably more difficult if we use <b> in
17397 # the test case, instead of <small>
17398 !! test
17399 Ensure that HTML adoption agency algorithm is properly implemented.
17400 !! wikitext
17401 <small>X<small>Y</small>Z</small>
17402 !! html
17403 <p><small>X<small>Y</small>Z</small>
17404 </p>
17405 !! end
17406
17407 # This was T43545 in the PHP parser.
17408 !! test
17409 Nesting of <kbd>
17410 !! wikitext
17411 <kbd>X<kbd>Y</kbd>Z</kbd>
17412 !! html+tidy
17413 <p><kbd>X<kbd>Y</kbd>Z</kbd>
17414 </p>
17415 !! end
17416
17417 # The following cases were T53081 in the PHP parser.
17418 # Note that there are some other nestable tags (b, i, etc) which are
17419 # not covered; see T53081 for discussion.
17420
17421 !! test
17422 Nesting of <em>
17423 !! wikitext
17424 <em>X<em>Y</em>Z</em>
17425 !! html+tidy
17426 <p><em>X<em>Y</em>Z</em>
17427 </p>
17428 !! end
17429
17430 !! test
17431 Nesting of <strong>
17432 !! wikitext
17433 <strong>X<strong>Y</strong>Z</strong>
17434 !! html+tidy
17435 <p><strong>X<strong>Y</strong>Z</strong>
17436 </p>
17437 !! end
17438
17439 !! test
17440 Nesting of <q>
17441 !! wikitext
17442 <q>X<q>Y</q>Z</q>
17443 !! html+tidy
17444 <p><q>X<q>Y</q>Z</q>
17445 </p>
17446 !! end
17447
17448 !! test
17449 Nesting of <ruby>
17450 !! wikitext
17451 <ruby>X<ruby>Y</ruby>Z</ruby>
17452 !! html
17453 <p><ruby>X<ruby>Y</ruby>Z</ruby>
17454 </p>
17455 !! end
17456
17457 !! test
17458 Nesting of <bdo>
17459 !! wikitext
17460 <bdo>X<bdo>Y</bdo>Z</bdo>
17461 !! html
17462 <p><bdo>X<bdo>Y</bdo>Z</bdo>
17463 </p>
17464 !! end
17465
17466
17467 ###
17468 ### Media links
17469 ###
17470
17471 !! test
17472 Media link
17473 !! wikitext
17474 [[Media:Foobar.jpg]]
17475 [[Media:Video.ogv]]
17476 [[:Media:Video.ogv]]
17477 !! html/php
17478 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
17479 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17480 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17481 </p>
17482 !! html/parsoid
17483 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
17484 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv">Media:Video.ogv</a>
17485 <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>
17486 !! end
17487
17488 !! test
17489 Media link with text
17490 !! wikitext
17491 [[Media:Foobar.jpg|A neat file to look at]]
17492 !! html/php
17493 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
17494 </p>
17495 !! html/parsoid
17496 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
17497 !! end
17498
17499 # FIXME: this is still bad HTML tag nesting
17500 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
17501 # Parsoid & Remex fix the p-wrapping since they operate on the DOM.
17502 !! test
17503 Media link with nasty text
17504 !! wikitext
17505 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
17506 !! html/php
17507 <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>
17508
17509 !! html/php+tidy
17510 <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>
17511 !! html/parsoid
17512 <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>
17513
17514 !! end
17515
17516 !! test
17517 Media link to nonexistent file (T3702)
17518 !! wikitext
17519 [[Media:No such.jpg]]
17520 [[Media:No_such file.jpg]]
17521 !! html/php
17522 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
17523 <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>
17524 </p>
17525 !! html/parsoid
17526 <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>
17527 <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>
17528 !! end
17529
17530 !! test
17531 Image link to nonexistent file (T3850 - good)
17532 !! wikitext
17533 [[File:No_such.jpg]]
17534 !! html/php
17535 <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>
17536 </p>
17537 !! html/parsoid
17538 <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>
17539 !! end
17540
17541 !! test
17542 :Image link to nonexistent file (T3850 - bad)
17543 !! wikitext
17544 [[:Image:No such.jpg]]
17545 !! html/php
17546 <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>
17547 </p>
17548 !! html/parsoid
17549 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
17550 !! end
17551
17552 !! test
17553 Character reference normalization in link text (T3938)
17554 !! wikitext
17555 [[Main Page|this&that]]
17556 !! html
17557 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
17558 </p>
17559 !!end
17560
17561 !! article
17562 אַ
17563 !! text
17564 Test for unicode normalization
17565
17566 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
17567 !! endarticle
17568
17569 !! test
17570 (T21451) Links should refer to the normalized form.
17571 !! wikitext
17572 [[&#xFB2E;]]
17573 [[&#x5d0;&#x5b7;]]
17574 [[&#x5d0;ַ]]
17575 [[א&#x5b7;]]
17576 [[אַ]]
17577 !! html
17578 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
17579 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
17580 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
17581 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
17582 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
17583 </p>
17584 !! end
17585
17586 !! test
17587 Empty attribute crash test (T4067)
17588 !! wikitext
17589 <font color="">foo</font>
17590 !! html
17591 <p><font color="">foo</font>
17592 </p>
17593 !! end
17594
17595 !! test
17596 Empty attribute crash test single-quotes (T4067)
17597 !! wikitext
17598 <font color=''>foo</font>
17599 !! html
17600 <p><font color="">foo</font>
17601 </p>
17602 !! end
17603
17604 !! test
17605 Attribute test: equals, then nothing
17606 !! options
17607 parsoid=wt2html,html2html
17608 !! wikitext
17609 <font color=>foo</font>
17610 !! html/php
17611 <p><font color="">foo</font>
17612 </p>
17613 !! html/parsoid
17614 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
17615 !! end
17616
17617 !! test
17618 Attribute test: unquoted value
17619 !! options
17620 parsoid=wt2html,html2html
17621 !! wikitext
17622 <font color=x>foo</font>
17623 !! html/php
17624 <p><font color="x">foo</font>
17625 </p>
17626 !! html/parsoid
17627 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
17628 !! end
17629
17630 !! test
17631 Attribute test: unquoted but illegal value (hash)
17632 !! wikitext
17633 <font color=#x>foo</font>
17634 !! html
17635 <p><font color="#x">foo</font>
17636 </p>
17637 !! end
17638
17639 # Parsoid does not serialize to empty attribute syntax,
17640 # so wt2wt and html2wt cases are skipped
17641 !! test
17642 Attribute test: no value (T54330)
17643 !! options
17644 parsoid=wt2html,html2html
17645 !! wikitext
17646 <font color>foo</font>
17647 !! html/php
17648 <p><font color="">foo</font>
17649 </p>
17650 !! html/parsoid
17651 <p><font color="">foo</font></p>
17652 !! end
17653
17654 !! test
17655 T4095: link with three closing brackets
17656 !! wikitext
17657 [[Main Page]]]
17658 !! html/php
17659 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
17660 </p>
17661 !! html/parsoid
17662 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
17663 !! end
17664
17665 !! test
17666 T4095: link with pipe and three closing brackets
17667 !! wikitext
17668 [[Main Page|link]]]
17669 !! html/php
17670 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
17671 </p>
17672 !! html/parsoid
17673 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
17674 !! end
17675
17676 !! test
17677 T4095: link with pipe and three closing brackets, version 2
17678 !! wikitext
17679 [[Main Page|[http://example.com/]]]
17680 !! html/php
17681 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
17682 </p>
17683 !! html/parsoid
17684 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
17685 !! end
17686
17687
17688 ###
17689 ### Safety
17690 ###
17691
17692 !! article
17693 Template:Dangerous attribute
17694 !! text
17695 " onmouseover="alert(document.cookie)
17696 !! endarticle
17697
17698 !! article
17699 Template:Dangerous style attribute
17700 !! text
17701 border-size: expression(alert(document.cookie))
17702 !! endarticle
17703
17704 !! article
17705 Template:Div style
17706 !! text
17707 <div style="float: right; {{{1}}}">Magic div</div>
17708 !! endarticle
17709
17710 !! test
17711 T4304: HTML attribute safety (safe template; regression T4309)
17712 !! wikitext
17713 <div title="{{test}}"></div>
17714 !! html/php
17715 <div title="This is a test template"></div>
17716
17717 !! html/parsoid
17718 <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>
17719 !! end
17720
17721 # Parsoid has enough context to handle this case
17722 !! test
17723 T4304: HTML attribute safety (dangerous template; 2309)
17724 !! wikitext
17725 <div title="{{dangerous attribute}}"></div>
17726 !! html/php
17727 <div title=""></div>
17728
17729 !! html/parsoid
17730 <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>
17731 !! end
17732
17733 !! test
17734 T4304: HTML attribute safety (dangerous style template; 2309)
17735 !! wikitext
17736 <div style="{{dangerous style attribute}}"></div>
17737 !! html/php
17738 <div style="/* insecure input */"></div>
17739
17740 !! html/parsoid
17741 <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>
17742 !! end
17743
17744 !! test
17745 T4304: HTML attribute safety (safe parameter; 2309)
17746 !! wikitext
17747 {{div style|width: 200px}}
17748 !! html/php
17749 <div style="float: right; width: 200px">Magic div</div>
17750
17751 !! html/parsoid
17752 <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>
17753 !! end
17754
17755 !! test
17756 T4304: HTML attribute safety (unsafe parameter; 2309)
17757 !! wikitext
17758 {{div style|width: expression(alert(document.cookie))}}
17759 !! html/php
17760 <div style="/* insecure input */">Magic div</div>
17761
17762 !! html/parsoid
17763 <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>
17764 !! end
17765
17766 ## Parsoid output here differs; needs investigation.
17767 !! test
17768 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
17769 !! wikitext
17770 {{div style|"><script>alert(document.cookie)</script>}}
17771 !! html
17772 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17773
17774 !! end
17775
17776 ## Parsoid output here differs; needs investigation.
17777 !! test
17778 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
17779 !! wikitext
17780 {{div style|" ><script>alert(document.cookie)</script>}}
17781 !! html
17782 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17783
17784 !! end
17785
17786 !! test
17787 T4304: HTML attribute safety (link)
17788 !! wikitext
17789 <div title="[[Main Page]]"></div>
17790 !! html/php
17791 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
17792
17793 !! html/parsoid
17794 <div title="[[Main Page]]"></div>
17795 !! end
17796
17797 !! test
17798 T4304: HTML attribute safety (italics)
17799 !! wikitext
17800 <div title="''foobar''"></div>
17801 !! html
17802 <div title="&#39;&#39;foobar&#39;&#39;"></div>
17803
17804 !! end
17805
17806 !! test
17807 T4304: HTML attribute safety (bold)
17808 !! wikitext
17809 <div title="'''foobar'''"></div>
17810 !! html
17811 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
17812
17813 !! end
17814
17815 !! test
17816 T4304: HTML attribute safety (ISBN)
17817 !! wikitext
17818 <div title="ISBN 1234567890"></div>
17819 !! html
17820 <div title="&#73;SBN 1234567890"></div>
17821
17822 !! end
17823
17824 !! test
17825 T4304: HTML attribute safety (RFC)
17826 !! wikitext
17827 <div title="RFC 1234"></div>
17828 !! html
17829 <div title="&#82;FC 1234"></div>
17830
17831 !! end
17832
17833 !! test
17834 T4304: HTML attribute safety (PMID)
17835 !! wikitext
17836 <div title="PMID 1234567890"></div>
17837 !! html
17838 <div title="&#80;MID 1234567890"></div>
17839
17840 !! end
17841
17842 !! test
17843 T4304: HTML attribute safety (web link)
17844 !! wikitext
17845 <div title="http://example.com/"></div>
17846 !! html
17847 <div title="http&#58;//example.com/"></div>
17848
17849 !! end
17850
17851 !! test
17852 T4304: HTML attribute safety (named web link)
17853 !! wikitext
17854 <div title="[http://example.com/ link]"></div>
17855 !! html/php
17856 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
17857
17858 !! html/parsoid
17859 <div title="[http://example.com/ link]"></div>
17860 !! end
17861
17862 !! test
17863 T5244: HTML attribute safety (extension; safe)
17864 !! wikitext
17865 <div style="<nowiki>background:blue</nowiki>"></div>
17866 !! html/php
17867 <div style="background:blue"></div>
17868
17869 !! html/parsoid
17870 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
17871 !! end
17872
17873 !! test
17874 T5244: HTML attribute safety (extension; unsafe)
17875 !! wikitext
17876 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
17877 !! html/php
17878 <div style="/* insecure input */"></div>
17879
17880 !! html/parsoid
17881 <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>
17882 !! end
17883
17884 # More MSIE fun discovered by Tom Gilder
17885
17886 !! test
17887 MSIE CSS safety test: spurious slash
17888 !! wikitext
17889 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
17890 !! html/php
17891 <div style="/* insecure input */">evil</div>
17892
17893 !! html/parsoid
17894 <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>
17895 !! end
17896
17897 !! test
17898 MSIE CSS safety test: hex code
17899 !! wikitext
17900 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
17901 !! html/php
17902 <div style="/* insecure input */">evil</div>
17903
17904 !! html/parsoid
17905 <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>
17906 !! end
17907
17908 !! test
17909 MSIE CSS safety test: comment in url
17910 !! wikitext
17911 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
17912 !! html/php
17913 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
17914
17915 !! html/parsoid
17916 <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>
17917 !! end
17918
17919 !! test
17920 MSIE CSS safety test: comment in expression
17921 !! wikitext
17922 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
17923 !! html/php
17924 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
17925
17926 !! html/parsoid
17927 <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>
17928 !! end
17929
17930 !! test
17931 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
17932 !! wikitext
17933 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
17934 !! html/php
17935 <p style="/* invalid control char */">A</p>
17936
17937 !! html/parsoid
17938 <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>
17939 !! end
17940
17941 !! test
17942 MSIE 6 CSS safety test: Fullwidth (T57332)
17943 !! wikitext
17944 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
17945 <div style="top:EXPRESSION(alert())">B</div>
17946 !! html/php
17947 <p style="/* insecure input */">A</p>
17948 <div style="/* insecure input */">B</div>
17949
17950 !! html/parsoid
17951 <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>
17952 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
17953 !! end
17954
17955 !! test
17956 MSIE 6 CSS safety test: IPA extensions (T57332)
17957 !! wikitext
17958 <div style="background-image:uʀʟ(javascript:alert())">A</div>
17959 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
17960 !! html/php
17961 <div style="/* insecure input */">A</div>
17962 <p style="/* insecure input */">B</p>
17963
17964 !! html/parsoid
17965 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
17966 <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>
17967 !! end
17968
17969 !! test
17970 MSIE 6 CSS safety test: sup/sub script (T57332)
17971 !! wikitext
17972 <div style="background-image:url⁽javascript:alert())">A</div>
17973 <div style="background-image:url₍javascript:alert())">B</div>
17974 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
17975 !! html/php
17976 <div style="/* insecure input */">A</div>
17977 <div style="/* insecure input */">B</div>
17978 <p style="/* insecure input */">C</p>
17979
17980 !! html/parsoid
17981 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
17982 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
17983 <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>
17984 !! end
17985
17986 !! test
17987 Opera -o-link CSS
17988 !! options
17989 parsoid=wt2html,html2html
17990 !! wikitext
17991 <div
17992 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;"
17993 style="-o-link:attr(title);-o-link-source:current">X</div>
17994 !! html/php
17995 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
17996
17997 !! html/parsoid
17998 <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>
17999 !! end
18000
18001 !! test
18002 MSIE 6 CSS safety test: Repetition markers (T57332)
18003 !! wikitext
18004 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
18005 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
18006 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
18007 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
18008 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
18009 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
18010 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
18011 !! html/php
18012 <p style="/* insecure input */">A</p>
18013 <p style="/* insecure input */">B</p>
18014 <p style="/* insecure input */">C</p>
18015 <p style="/* insecure input */">D</p>
18016 <p style="/* insecure input */">E</p>
18017 <p style="/* insecure input */">F</p>
18018 <p style="/* insecure input */">G</p>
18019
18020 !! html/parsoid
18021 <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>
18022 <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>
18023 <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>
18024 <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>
18025 <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>
18026 <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>
18027 <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>
18028 !! end
18029
18030 !! test
18031 Table attribute legitimate extension
18032 !! wikitext
18033 {|
18034 !+ style="<nowiki>color:blue</nowiki>"|status
18035 |}
18036 !! html
18037 <table>
18038 <tr>
18039 <th style="color:blue">status
18040 </th></tr></table>
18041
18042 !!end
18043
18044 !! test
18045 Table attribute safety
18046 !! wikitext
18047 {|
18048 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"|status
18049 |}
18050 !! html
18051 <table>
18052 <tr>
18053 <th style="/* insecure input */">status
18054 </th></tr></table>
18055
18056 !! end
18057
18058 !! test
18059 CSS line continuation 1
18060 !! wikitext
18061 <div style="background-image: u\&#10;rl(test.jpg);"></div>
18062 !! html
18063 <div style="/* insecure input */"></div>
18064
18065 !! end
18066
18067 !! test
18068 CSS line continuation 2
18069 !! wikitext
18070 <div style="background-image: u\&#13;rl(test.jpg); "></div>
18071 !! html
18072 <div style="/* invalid control char */"></div>
18073
18074 !! end
18075
18076 !! article
18077 Template:Identity
18078 !! text
18079 {{{1}}}
18080 !! endarticle
18081
18082 !! test
18083 Expansion of multi-line templates in attribute values (T8255)
18084 !! wikitext
18085 <div style="background: {{identity|#00FF00}}">-</div>
18086 !! html
18087 <div style="background: #00FF00">-</div>
18088
18089 !! end
18090
18091 !! test
18092 Expansion of multi-line templates in attribute values (T8255 sanity check)
18093 !! wikitext
18094 <div style="background:
18095 #00FF00">-</div>
18096 !! html/php
18097 <div style="background: #00FF00">-</div>
18098
18099 !! html/parsoid
18100 <div style="background:
18101 #00FF00">-</div>
18102 !! end
18103
18104 !! test
18105 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
18106 !! wikitext
18107 <div style="background: &#10;#00FF00">-</div>
18108 !! html
18109 <div style="background: &#10;#00FF00">-</div>
18110
18111 !! end
18112
18113 !! test
18114 Tags which are hidden from tidiers cannot pass through the Sanitizer
18115 !! wikitext
18116 <mw:toc><script>alert();</script></mw:toc>
18117 !! html+tidy
18118 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;
18119 </p>
18120 !! end
18121
18122 ###
18123 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
18124 ###
18125
18126 !! test
18127 Parser hook: empty input
18128 !! wikitext
18129 <tag></tag>
18130 !! html/php
18131 <pre>
18132 ''
18133 array (
18134 )
18135 </pre>
18136
18137 !! html/parsoid
18138 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18139 !! end
18140
18141 ## Don't expect parsoid to rt this form.
18142 !! test
18143 Parser hook: empty input using terminated empty elements
18144 !! options
18145 parsoid=wt2html,html2html
18146 !! wikitext
18147 <tag/>
18148 !! html/php
18149 <pre>
18150 NULL
18151 array (
18152 )
18153 </pre>
18154
18155 !! html/parsoid
18156 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18157 !! end
18158
18159 !! test
18160 Parser hook: empty input using terminated empty elements (space before)
18161 !! wikitext
18162 <tag />
18163 !! html/php
18164 <pre>
18165 NULL
18166 array (
18167 )
18168 </pre>
18169
18170 !! html/parsoid
18171 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18172 !! end
18173
18174 !! test
18175 Parser hook: basic input
18176 !! wikitext
18177 <tag>input</tag>
18178 !! html/php
18179 <pre>
18180 'input'
18181 array (
18182 )
18183 </pre>
18184
18185 !! html/parsoid
18186 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18187 !! end
18188
18189 ## Don't expect parsoid to rt this form.
18190 !! test
18191 Parser hook: case insensitive
18192 !! options
18193 parsoid=wt2html,html2html
18194 !! wikitext
18195 <TAG>input</TAG>
18196 !! html/php
18197 <pre>
18198 'input'
18199 array (
18200 )
18201 </pre>
18202
18203 !! html/parsoid
18204 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18205 !! end
18206
18207 ## Don't expect parsoid to rt this form.
18208 !! test
18209 Parser hook: case insensitive, redux
18210 !! options
18211 parsoid=wt2html,html2html
18212 !! wikitext
18213 <TaG>input</TAg>
18214 !! html/php
18215 <pre>
18216 'input'
18217 array (
18218 )
18219 </pre>
18220
18221 !! html/parsoid
18222 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18223 !! end
18224
18225 !! test
18226 Parser hook: nested tags
18227 !! wikitext
18228 <tag><tag></tag></tag>
18229 !! html/php
18230 <pre>
18231 '<tag>'
18232 array (
18233 )
18234 </pre>&lt;/tag&gt;
18235
18236 !! html/parsoid
18237 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}' data-parsoid='{}' about="#mwt2"></pre>&lt;/tag>
18238 !! end
18239
18240 !! test
18241 Parser hook: basic arguments
18242 !! wikitext
18243 <tag width="200" height="100" depth="50" square=""></tag>
18244 !! html/php
18245 <pre>
18246 ''
18247 array (
18248 'width' => '200',
18249 'height' => '100',
18250 'depth' => '50',
18251 'square' => '',
18252 )
18253 </pre>
18254
18255 !! html/parsoid
18256 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18257 !! end
18258
18259 ## Don't expect parsoid to rt this form.
18260 !! test
18261 Parser hook: basic arguments, variations
18262 !! options
18263 parsoid=wt2html,html2html
18264 !! wikitext
18265 <tag width=200 height = "100" depth = '50' square></tag>
18266 !! html/php
18267 <pre>
18268 ''
18269 array (
18270 'width' => '200',
18271 'height' => '100',
18272 'depth' => '50',
18273 'square' => '',
18274 )
18275 </pre>
18276
18277 !! html/parsoid
18278 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18279 !! end
18280
18281 !! test
18282 Parser hook: argument containing a forward slash (T7344)
18283 !! wikitext
18284 <tag filename="/tmp/bla"></tag>
18285 !! html/php
18286 <pre>
18287 ''
18288 array (
18289 'filename' => '/tmp/bla',
18290 )
18291 </pre>
18292
18293 !! html/parsoid
18294 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18295 !! end
18296
18297 ## Don't expect parsoid to rt this form.
18298 !! test
18299 Parser hook: empty input using terminated empty elements (T4374)
18300 !! options
18301 parsoid=wt2html,html2html
18302 !! wikitext
18303 <tag foo=bar/>text
18304 !! html/php
18305 <pre>
18306 NULL
18307 array (
18308 'foo' => 'bar',
18309 )
18310 </pre>text
18311
18312 !! html/parsoid
18313 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text
18314 !! end
18315
18316 ## </tag> should be output literally since there is no matching tag that begins it
18317 ## Don't expect parsoid to rt this form.
18318 !! test
18319 Parser hook: basic arguments using terminated empty elements (T4374)
18320 !! options
18321 parsoid=wt2html
18322 !! wikitext
18323 <tag width=200 height = "100" depth = '50' square/>
18324 other stuff
18325 </tag>
18326 !! html/php
18327 <pre>
18328 NULL
18329 array (
18330 'width' => '200',
18331 'height' => '100',
18332 'depth' => '50',
18333 'square' => '',
18334 )
18335 </pre>
18336 <p>other stuff
18337 &lt;/tag&gt;
18338 </p>
18339 !! html/parsoid
18340 <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
18341 &lt;/tag></p>
18342 !! end
18343
18344 ## Don't expect parsoid to rt this form.
18345 !! test
18346 Parser hook: Don't allow unclosed extension tags
18347 !! options
18348 parsoid=wt2html
18349 !! wikitext
18350 test <tag>123
18351
18352 this is a '''test'''
18353 !! html/php
18354 <p>test &lt;tag&gt;123
18355 </p><p>this is a <b>test</b>
18356 </p>
18357 !! html/parsoid
18358 <p>test &lt;tag>123</p>
18359
18360 <p>this is a <b>test</b></p>
18361 !! end
18362
18363 !! test
18364 Parser hook: horizontal rule inside extension tag that outputs <pre>
18365 !! wikitext
18366 <tag>
18367 Hello
18368 <hr/>
18369 Goodbye
18370 </tag>
18371 !! html/php
18372 <pre>
18373 '
18374 Hello
18375 <hr/>
18376 Goodbye
18377 '
18378 array (
18379 )
18380 </pre>
18381
18382 !! end
18383
18384 ###
18385 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
18386 ###
18387
18388 !! test
18389 Parser hook: static parser hook not inside a comment
18390 !! wikitext
18391 <statictag>hello, world</statictag>
18392
18393 <statictag action="flush" />
18394 !! html/php
18395 <p><br />
18396 hello, world
18397 </p>
18398 !! html/parsoid
18399 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
18400 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p>
18401 !! end
18402
18403 !! test
18404 Parser hook: static parser hook inside a comment
18405 !! wikitext
18406 <!-- <statictag>hello, world</statictag> -->
18407 <statictag action="flush" />
18408 !! html/php
18409 <p><br />
18410 </p>
18411 !! html/parsoid
18412 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
18413 <p typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about='#mwt2'></p>
18414 !! end
18415
18416 # Nested template calls; this case was broken by Parser.php rev 1.506,
18417 # since reverted.
18418
18419 !! article
18420 Template:One-parameter
18421 !! text
18422 (My parameter is: {{{1}}})
18423 !! endarticle
18424
18425 !! article
18426 Template:Map-one-parameter
18427 !! text
18428 {{{{{1}}}|{{{2}}}}}
18429 !! endarticle
18430
18431 !! test
18432 Nested template calls
18433 !! wikitext
18434 {{Map-one-parameter|One-parameter|param}}
18435 !! html
18436 <p>(My parameter is: param)
18437 </p>
18438 !! end
18439
18440
18441 ###
18442 ### Sanitizer
18443 ###
18444
18445 # Remex wraps empty tag runs with p-tags.
18446 # Parsoid strips them out during p-wrapping.
18447 !! test
18448 Sanitizer: Closing of open tags
18449 !! wikitext
18450 <s></s><table></table>
18451 !! html/php+tidy
18452 <p><s></s></p><table></table>
18453 !! html/parsoid
18454 <s></s><table></table>
18455 !! end
18456
18457 !! test
18458 Sanitizer: Closing of open but not closed tags
18459 !! wikitext
18460 <s>foo
18461 !! html
18462 <p><s>foo</s>
18463 </p>
18464 !! end
18465
18466 !! test
18467 Sanitizer: Closing of closed but not open tags
18468 !! options
18469 parsoid=wt2html
18470 !! wikitext
18471 </s>
18472 !! html/php+tidy
18473 <p class="mw-empty-elt">
18474 </p>
18475 !! html/parsoid
18476 !! end
18477
18478 !! test
18479 Sanitizer: Closing of closed but not open table tags
18480 !! options
18481 parsoid=wt2html
18482 !! wikitext
18483 Table not started</td></tr></table>
18484 !! html+tidy
18485 <p>Table not started
18486 </p>
18487 !! end
18488
18489 !! test
18490 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
18491 !! config
18492 wgFragmentMode=[ 'html5', 'legacy' ]
18493 !! wikitext
18494 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18495 !! html/php
18496 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
18497 </p>
18498 !! html/parsoid
18499 <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>
18500 !! end
18501
18502 !! test
18503 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
18504 !! config
18505 wgFragmentMode=[ 'legacy' ]
18506 !! wikitext
18507 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18508 !! html/php
18509 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
18510 </p>
18511 !! end
18512
18513 # In HTML5, the restrictions are that id must contain at least one character,
18514 # and must not contain any space characters.
18515 !! test
18516 Sanitizer: Validating the contents of the id attribute (T6515)
18517 !! options
18518 disabled
18519 !! wikitext
18520 <br id="" /><br id="a space" />
18521 !! html
18522 Something ...
18523 !! end
18524
18525 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
18526 !! test
18527 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
18528 !! options
18529 disabled
18530 !! wikitext
18531 <br id="foo" /><br id="foo" />
18532 !! html
18533 Something need to be done. foo-2 ?
18534 !! end
18535
18536 !! test
18537 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
18538 !! wikitext
18539 <div itemscope>
18540 <meta itemprop="hello" content="world">
18541 <meta http-equiv="refresh" content="5">
18542 <meta itemprop="hello" http-equiv="refresh" content="5">
18543 <link itemprop="hello" href="{{SERVER}}">
18544 <link rel="stylesheet" href="{{SERVER}}">
18545 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
18546 </div>
18547 !! html
18548 <div itemscope="">
18549 <p> <meta itemprop="hello" content="world" />
18550 &lt;meta http-equiv="refresh" content="5"&gt;
18551 <meta itemprop="hello" content="5" />
18552 <link itemprop="hello" href="http&#58;//example.org" />
18553 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
18554 <link itemprop="hello" href="http&#58;//example.org" />
18555 </p>
18556 </div>
18557
18558 !! end
18559
18560 !! test
18561 Sanitizer: Strip comments from CSS attributes
18562 !! options
18563 parsoid=wt2html,wt2wt
18564 !! wikitext
18565 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
18566 !! html/php
18567 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
18568 </p>
18569 !! html/parsoid
18570 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
18571 !! end
18572
18573 !! test
18574 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
18575 !! wikitext
18576 [[meatball:Soft"Security]]
18577 !! html/php
18578 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
18579 </p>
18580 !! html/parsoid
18581 <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>
18582 !! end
18583
18584 !! test
18585 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
18586 !! wikitext
18587 [[meatball:Foo<Bar]]
18588 [[meatball:Foo>Bar]]
18589 [[meatball:Foo&lt;bar]]
18590 [[meatball:Foo&gt;bar]]
18591 !! html/php
18592 <p>[[meatball:Foo&lt;Bar]]
18593 [[meatball:Foo&gt;Bar]]
18594 [[meatball:Foo&lt;bar]]
18595 [[meatball:Foo&gt;bar]]
18596 </p>
18597 !! html/parsoid
18598 <p>[[meatball:Foo&lt;Bar]]
18599 [[meatball:Foo>Bar]]
18600 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
18601 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
18602 !! end
18603
18604 !! test
18605 Language converter: output gets cut off unexpectedly (T7757)
18606 !! options
18607 language=zh
18608 !! wikitext
18609 this bit is safe: }-
18610
18611 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
18612
18613 then we get cut off here: }-
18614
18615 all additional text is vanished
18616 !! html/php
18617 <p>this bit is safe: }-
18618 </p><p>but if we add a conversion instance: xxx
18619 </p><p>then we get cut off here: }-
18620 </p><p>all additional text is vanished
18621 </p>
18622 !! html/parsoid
18623 <p>this bit is safe: }-</p>
18624 <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>
18625 <p>then we get cut off here: }-</p>
18626 <p>all additional text is vanished</p>
18627 !! end
18628
18629 !! test
18630 Language converter glossary rules inside attributes (T119158)
18631 !! options
18632 language=sr variant=sr-el
18633 !! wikitext
18634 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
18635
18636 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
18637 !! html/php
18638 <p>
18639 </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>
18640 </p>
18641 !! html/parsoid
18642 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
18643
18644 <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>
18645 !! end
18646
18647 !! test
18648 Self closed html pairs (T7487)
18649 !! wikitext
18650 <center><font id="bug" />Centered text</center>
18651 <div><font id="bug2" />In div text</div>
18652 !! html+tidy
18653 <center><font id="bug"></font>Centered text</center>
18654 <div><font id="bug2"></font>In div text</div>
18655 !! end
18656
18657 !! test
18658 Punctuation: nbsp before exclamation
18659 !! wikitext
18660 C'est grave !
18661 !! html
18662 <p>C'est grave&#160;!
18663 </p>
18664 !! end
18665
18666 !! test
18667 Punctuation: CSS !important (T13874)
18668 !! wikitext
18669 <div style="width:50% !important">important</div>
18670 !! html
18671 <div style="width:50% !important">important</div>
18672
18673 !!end
18674
18675 !! test
18676 Punctuation: CSS ! important (T13874; with space after)
18677 !! wikitext
18678 <div style="width:50% ! important">important</div>
18679 !! html
18680 <div style="width:50% ! important">important</div>
18681
18682 !!end
18683
18684 !! test
18685 HTML bullet list, closed tags (T7497)
18686 !! wikitext
18687 <ul>
18688 <li>One</li>
18689 <li>Two</li>
18690 </ul>
18691 !! html/php
18692 <ul>
18693 <li>One</li>
18694 <li>Two</li>
18695 </ul>
18696
18697 !! html/parsoid
18698 <ul data-parsoid='{"stx":"html"}'>
18699 <li data-parsoid='{"stx":"html"}'>One</li>
18700 <li data-parsoid='{"stx":"html"}'>Two</li>
18701 </ul>
18702
18703 !! end
18704
18705 !! test
18706 HTML bullet list, unclosed tags (T7497)
18707 !! wikitext
18708 <ul>
18709 <li>One
18710 <li>Two
18711 </ul>
18712 !! html/php+tidy
18713 <ul>
18714 <li>One
18715 </li><li>Two
18716 </li></ul>
18717 !! html/parsoid
18718 <ul data-parsoid='{"stx":"html"}'>
18719 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18720 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18721 </ul>
18722
18723 !! end
18724
18725 !! test
18726 HTML ordered list, closed tags (T7497)
18727 !! wikitext
18728 <ol>
18729 <li>One</li>
18730 <li>Two</li>
18731 </ol>
18732 !! html/php
18733 <ol>
18734 <li>One</li>
18735 <li>Two</li>
18736 </ol>
18737
18738 !! html/parsoid
18739 <ol data-parsoid='{"stx":"html"}'>
18740 <li data-parsoid='{"stx":"html"}'>One</li>
18741 <li data-parsoid='{"stx":"html"}'>Two</li>
18742 </ol>
18743
18744 !! end
18745
18746 !! test
18747 HTML ordered list, unclosed tags (T7497)
18748 !! options
18749 !! wikitext
18750 <ol>
18751 <li>One
18752 <li>Two
18753 </ol>
18754 !! html/php+tidy
18755 <ol>
18756 <li>One
18757 </li><li>Two
18758 </li></ol>
18759 !! html/parsoid
18760 <ol data-parsoid='{"stx":"html"}'>
18761 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18762 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18763 </ol>
18764
18765 !! end
18766
18767 !! test
18768 HTML nested bullet list, closed tags (T7497)
18769 !! wikitext
18770 <ul>
18771 <li>One</li>
18772 <li>Two:
18773 <ul>
18774 <li>Sub-one</li>
18775 <li>Sub-two</li>
18776 </ul>
18777 </li>
18778 </ul>
18779 !! html/php
18780 <ul>
18781 <li>One</li>
18782 <li>Two:
18783 <ul>
18784 <li>Sub-one</li>
18785 <li>Sub-two</li>
18786 </ul>
18787 </li>
18788 </ul>
18789
18790 !! html/parsoid
18791 <ul data-parsoid='{"stx":"html"}'>
18792 <li data-parsoid='{"stx":"html"}'>One</li>
18793 <li data-parsoid='{"stx":"html"}'>Two:
18794 <ul data-parsoid='{"stx":"html"}'>
18795 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
18796 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
18797 </ul>
18798 </li>
18799 </ul>
18800 !! end
18801
18802 !! test
18803 HTML nested bullet list, open tags (T7497)
18804 !! wikitext
18805 <ul>
18806 <li>One
18807 <li>Two:
18808 <ul>
18809 <li>Sub-one
18810 <li>Sub-two
18811 </ul>
18812 </ul>
18813 !! html+tidy
18814 <ul>
18815 <li>One
18816 </li><li>Two:
18817 <ul>
18818 <li>Sub-one
18819 </li><li>Sub-two
18820 </li></ul>
18821 </li></ul>
18822 !! end
18823
18824 !! test
18825 HTML nested ordered list, closed tags (T7497)
18826 !! wikitext
18827 <ol>
18828 <li>One</li>
18829 <li>Two:
18830 <ol>
18831 <li>Sub-one</li>
18832 <li>Sub-two</li>
18833 </ol>
18834 </li>
18835 </ol>
18836 !! html
18837 <ol>
18838 <li>One</li>
18839 <li>Two:
18840 <ol>
18841 <li>Sub-one</li>
18842 <li>Sub-two</li>
18843 </ol>
18844 </li>
18845 </ol>
18846
18847 !! end
18848
18849 !! test
18850 HTML nested ordered list, open tags (T7497)
18851 !! wikitext
18852 <ol>
18853 <li>One
18854 <li>Two:
18855 <ol>
18856 <li>Sub-one
18857 <li>Sub-two
18858 </ol>
18859 </ol>
18860 !! html/php
18861 <ol>
18862 <li>One
18863 <li>Two:
18864 <ol>
18865 <li>Sub-one
18866 <li>Sub-two
18867 </ol>
18868 </ol>
18869
18870 !! html/parsoid
18871 <ol>
18872 <li>One
18873 </li>
18874 <li>Two:
18875 <ol>
18876 <li>Sub-one
18877 </li>
18878 <li>Sub-two
18879 </li>
18880 </ol>
18881 </li>
18882 </ol>
18883
18884 !! end
18885
18886 !! test
18887 HTML ordered list item with parameters oddity
18888 !! wikitext
18889 <ol><li id="fragment">One</li>
18890 </ol>
18891 !! html
18892 <ol><li id="fragment">One</li>
18893 </ol>
18894
18895 !! end
18896
18897 # parsoid doesn't explicitly mark autonumbered links, see T55505
18898 !!test
18899 T7918: autonumbering
18900 !! wikitext
18901 [http://first/] [http://second] [ftp://ftp]
18902
18903 ftp://inlineftp
18904
18905 [mailto:enclosed@mail.tld With target]
18906
18907 [mailto:enclosed@mail.tld]
18908
18909 mailto:inline@mail.tld
18910 !! html/php
18911 <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>
18912 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
18913 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
18914 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
18915 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
18916 </p>
18917 !! html/parsoid
18918 <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>
18919 <p><a rel="mw:ExtLink" class="external free" href="ftp://inlineftp">ftp://inlineftp</a></p>
18920 <p><a rel="mw:ExtLink" class="external text" href="mailto:enclosed@mail.tld">With target</a></p>
18921 <p><a rel="mw:ExtLink" class="external autonumber" href="mailto:enclosed@mail.tld"></a></p>
18922 <p><a rel="mw:ExtLink" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
18923 !! end
18924
18925
18926 #
18927 # Security and HTML correctness
18928 # From Nick Jenkins' fuzz testing
18929 #
18930
18931 !! test
18932 Fuzz testing: Parser13
18933 !! wikitext
18934 {|
18935 | http://a|
18936 !! html
18937 <table>
18938 <tr>
18939 <td>
18940 </td>
18941 </tr>
18942 </table>
18943
18944 !! end
18945
18946 # Note that Parsoid output differs from the PHP parser here: the PHP
18947 # parser breaks the URL for the magic word, while in Parsoid the URL
18948 # production takes precedence.
18949 !! test
18950 Fuzz testing: Parser14
18951 !! wikitext
18952 ==onmouseover===
18953 http://__TOC__
18954 !! html/php
18955 <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>
18956 http://<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
18957 <ul>
18958 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18959 </ul>
18960 </div>
18961
18962
18963 !! html/php+tidy
18964 <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>
18965 http://</p><div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
18966 <ul>
18967 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18968 </ul>
18969 </div>
18970 !! html/parsoid
18971 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span>onmouseover=</h2>
18972 <p><a rel="mw:ExtLink" class="external free" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
18973 !! end
18974
18975 !! test
18976 Fuzz testing: Parser14-table
18977 !! options
18978 parsoid=wt2html,html2html
18979 !! wikitext
18980 ==a==
18981 {| STYLE=__TOC__
18982 !! html
18983 <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>
18984 <table style="&#95;_TOC&#95;_">
18985 <tr><td></td></tr>
18986 </table>
18987
18988 !! html+tidy
18989 <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>
18990 <table style="__TOC__">
18991 <tr>
18992 <td></td>
18993 </tr>
18994 </table>
18995 !! html/parsoid
18996 <h2 id="a">a</h2>
18997 <table style="__TOC__"></table>
18998 !! end
18999
19000 # Known to produce bogus xml (extra </td>)
19001 # Don't add the html/php section since it generates broken HTML
19002 !! test
19003 Fuzz testing: Parser16
19004 !! wikitext
19005 {|
19006 !https://||||||
19007 !! html+tidy
19008 <table>
19009 <tbody><tr>
19010 <th>https://</th>
19011 <th></th>
19012 <th></th>
19013 <th>
19014
19015 </th></tr>
19016 </tbody></table>
19017 !! end
19018
19019 !! test
19020 Fuzz testing: Parser21
19021 !! wikitext
19022 {|
19023 !irc://{{ftp://a" onmouseover="alert('hello world');"
19024 |
19025 !! html
19026 <table>
19027 <tr>
19028 <th><a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
19029 </th>
19030 <td>
19031 </td>
19032 </tr>
19033 </table>
19034
19035 !! end
19036
19037 !! test
19038 Fuzz testing: Parser22
19039 !! wikitext
19040 http://===r:::https://b
19041
19042 {|
19043 !! html
19044 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
19045 </p>
19046 <table>
19047 <tr><td></td></tr>
19048 </table>
19049
19050 !! end
19051
19052 # Known to produce bad XML for now
19053 !! test
19054 Fuzz testing: Parser24
19055 !! options
19056 parsoid=wt2html
19057 !! wikitext
19058 {|
19059 {{{|
19060 <u CLASS=
19061 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
19062 <br style="onmouseover='alert(document.cookie);' " />
19063
19064 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19065 |
19066 !! html/php
19067 <table>
19068 {{{|
19069 <u class="&#124;">}}}} &gt;
19070 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19071
19072 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19073 <tr>
19074 <td></u>
19075 </td>
19076 </tr>
19077 </table>
19078
19079 !! html/parsoid
19080 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
19081 <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>"}'/>}}}} >
19082 <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}'>
19083
19084
19085
19086 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table>
19087 !! end
19088
19089 # Note: the current result listed for this is not what the original one was,
19090 # but the original bug was JavaScript injection, which is fixed in any case.
19091 # It's not clear that the original result listed was any more correct than the
19092 # current one. Original result:
19093 # <p>{{{|
19094 # </p>
19095 # <li class="&#124;&#124;">
19096 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19097 !!test
19098 Fuzz testing: Parser25 (T8055)
19099 !! wikitext
19100 {{{
19101 |
19102 <LI CLASS=||
19103 >
19104 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
19105 !! html/php
19106 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19107 </p>
19108 !! html/parsoid
19109 <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"]}'>
19110 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
19111 !! end
19112
19113 !!test
19114 Fuzz testing: URL adjacent extension (with space, clean)
19115 !! wikitext
19116 http://example.com <nowiki>junk</nowiki>
19117 !! html/php
19118 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
19119 </p>
19120 !! html/parsoid
19121 <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>
19122 !! end
19123
19124 !!test
19125 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
19126 !! wikitext
19127 http://example.com<nowiki>junk</nowiki>
19128 !! html/php
19129 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
19130 </p>
19131 !! html/parsoid
19132 <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>
19133 !! end
19134
19135 !! test
19136 Fuzz testing: URL adjacent extension (no space, dirty; pre)
19137 !! wikitext
19138 http://example.com<pre>junk</pre>
19139 !! html/php
19140 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
19141
19142 !! html/php+tidy
19143 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
19144 !! html/parsoid
19145 <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>
19146 !! end
19147
19148 !! test
19149 Fuzz testing: image with bogus manual thumbnail
19150 !! wikitext
19151 [[Image:foobar.jpg|thumbnail= ]]
19152 !! html/php
19153 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
19154
19155 !! html/parsoid
19156 <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>
19157 !! end
19158
19159 # Parsoid will emit the newline literally in wt2wt; see next test case.
19160 !! test
19161 Fuzz testing: encoded newline in generated HTML replacements (T8577)
19162 !! options
19163 parsoid=wt2html
19164 !! wikitext
19165 <pre dir="&#10;"></pre>
19166 !! html/php
19167 <pre dir="&#10;"></pre>
19168
19169 !! html/parsoid
19170 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19171 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19172 !! end
19173
19174 !! test
19175 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
19176 !! options
19177 parsoid=html2wt
19178 !! html/parsoid
19179 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19180 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19181 !! wikitext
19182 <pre dir="
19183 "></pre>
19184 !! html/php
19185 <pre dir=""></pre>
19186
19187 !! end
19188
19189 !! test
19190 Templates in extension attributes are not expanded
19191 !! wikitext
19192 <pre dir="{{echo|ltr}}"></pre>
19193 !! html/php
19194 <pre dir="{{echo|ltr}}"></pre>
19195
19196 !! html/parsoid
19197 <pre typeof="mw:Extension/pre" about="#mwt2" dir="{{echo|ltr}}" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
19198 !! end
19199
19200 !! test
19201 Parsing optional HTML elements (T8171)
19202 !! options
19203 !! wikitext
19204 <table>
19205 <tr>
19206 <td> Some tabular data</td>
19207 <td> More tabular data ...
19208 <td> And yet som tabular data</td>
19209 </tr>
19210 </table>
19211 !! html
19212 <table>
19213 <tr>
19214 <td> Some tabular data</td>
19215 <td> More tabular data ...
19216 </td><td> And yet som tabular data</td>
19217 </tr>
19218 </table>
19219
19220 !! end
19221
19222 !! test
19223 Correct handling of <td>, <tr> (T8171)
19224 !! options
19225 !! wikitext
19226 <table>
19227 <tr>
19228 <td> Some tabular data</td>
19229 <td> More tabular data ...</td>
19230 <td> And yet som tabular data</td>
19231 </tr>
19232 </table>
19233 !! html
19234 <table>
19235 <tr>
19236 <td> Some tabular data</td>
19237 <td> More tabular data ...</td>
19238 <td> And yet som tabular data</td>
19239 </tr>
19240 </table>
19241
19242 !! end
19243
19244
19245 !! test
19246 Parsing crashing regression (fr:JavaScript)
19247 !! wikitext
19248 </body></x>
19249 !! html
19250 <p>&lt;/body&gt;&lt;/x&gt;
19251 </p>
19252 !! end
19253
19254 !! test
19255 Inline wiki vs wiki block nesting
19256 !! wikitext
19257 '''Bold paragraph
19258
19259 New wiki paragraph
19260 !! html
19261 <p><b>Bold paragraph</b>
19262 </p><p>New wiki paragraph
19263 </p>
19264 !! end
19265
19266 # FIXME: The current php output is documented
19267 # and desired output is the parsoid target.
19268 !! test
19269 Inline HTML vs wiki block nesting
19270 !! wikitext
19271 <b>Bold paragraph
19272
19273 New wiki paragraph
19274 !! html/php
19275 <p><b>Bold paragraph
19276 </p><p>New wiki paragraph</b>
19277 </p>
19278 !! html/parsoid
19279 <p><b>Bold paragraph</b>
19280 </p><p>New wiki paragraph
19281 </p>
19282 !! end
19283
19284 # Original result was this:
19285 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
19286 # </p>
19287 # While that might be marginally more intuitive, maybe, the six-apostrophe
19288 # construct is clearly pathological and the result stated here (which is what
19289 # the parser actually does) is about as reasonable as anything.
19290 !!test
19291 Mixing markup for italics and bold
19292 !! options
19293 !! wikitext
19294 '''bold''''''bold''bolditalics'''''
19295 !! html
19296 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
19297 </p>
19298 !! end
19299
19300
19301 !! article
19302 Xyzzyx
19303 !! text
19304 Article for special page transclusion test
19305 !! endarticle
19306
19307 !! test
19308 Special page transclusion
19309 !! options
19310 !! wikitext
19311 {{Special:Prefixindex/Xyzzyx}}
19312 !! html
19313 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19314 </ul>
19315
19316 !! end
19317
19318 !! test
19319 Special page transclusion twice (T7021)
19320 !! options
19321 !! wikitext
19322 {{Special:Prefixindex/Xyzzyx}}
19323 {{Special:Prefixindex/Xyzzyx}}
19324 !! html
19325 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19326 </ul>
19327 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19328 </ul>
19329
19330 !! end
19331
19332 !! test
19333 Transclusion of default MediaWiki message
19334 !! wikitext
19335 {{MediaWiki:Mainpage}}
19336 !! html
19337 <p>Main Page
19338 </p>
19339 !! end
19340
19341 !! test
19342 Transclusion of nonexistent MediaWiki message
19343 !! wikitext
19344 {{MediaWiki:Mainpagexxx}}
19345 !! html
19346 <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>
19347 </p>
19348 !! end
19349
19350 !! test
19351 Transclusion of MediaWiki message with underscore
19352 !! wikitext
19353 {{MediaWiki:history_short}}
19354 !! html
19355 <p>History
19356 </p>
19357 !! end
19358
19359 !! test
19360 Transclusion of MediaWiki message with space
19361 !! wikitext
19362 {{MediaWiki:history short}}
19363 !! html
19364 <p>History
19365 </p>
19366 !! end
19367
19368 !! test
19369 Invalid header with following text
19370 !! wikitext
19371 = x = y
19372 !! html
19373 <p>= x = y
19374 </p>
19375 !! end
19376
19377
19378 !! test
19379 Section extraction test (section 0)
19380 !! options
19381 section=0
19382 !! wikitext
19383 start
19384 ==a==
19385 ===aa===
19386 ====aaa====
19387 ==b==
19388 ===ba===
19389 ===bb===
19390 ====bba====
19391 ===bc===
19392 ==c==
19393 ===ca===
19394 !! html/php
19395 start
19396 !! end
19397
19398 !! test
19399 Section extraction test (section 1)
19400 !! options
19401 section=1
19402 !! wikitext
19403 start
19404 ==a==
19405 ===aa===
19406 ====aaa====
19407 ==b==
19408 ===ba===
19409 ===bb===
19410 ====bba====
19411 ===bc===
19412 ==c==
19413 ===ca===
19414 !! html/php
19415 ==a==
19416 ===aa===
19417 ====aaa====
19418 !! end
19419
19420 !! test
19421 Section extraction test (section 2)
19422 !! options
19423 section=2
19424 !! wikitext
19425 start
19426 ==a==
19427 ===aa===
19428 ====aaa====
19429 ==b==
19430 ===ba===
19431 ===bb===
19432 ====bba====
19433 ===bc===
19434 ==c==
19435 ===ca===
19436 !! html/php
19437 ===aa===
19438 ====aaa====
19439 !! end
19440
19441 !! test
19442 Section extraction test (section 3)
19443 !! options
19444 section=3
19445 !! wikitext
19446 start
19447 ==a==
19448 ===aa===
19449 ====aaa====
19450 ==b==
19451 ===ba===
19452 ===bb===
19453 ====bba====
19454 ===bc===
19455 ==c==
19456 ===ca===
19457 !! html/php
19458 ====aaa====
19459 !! end
19460
19461 !! test
19462 Section extraction test (section 4)
19463 !! options
19464 section=4
19465 !! wikitext
19466 start
19467 ==a==
19468 ===aa===
19469 ====aaa====
19470 ==b==
19471 ===ba===
19472 ===bb===
19473 ====bba====
19474 ===bc===
19475 ==c==
19476 ===ca===
19477 !! html/php
19478 ==b==
19479 ===ba===
19480 ===bb===
19481 ====bba====
19482 ===bc===
19483 !! end
19484
19485 !! test
19486 Section extraction test (section 5)
19487 !! options
19488 section=5
19489 !! wikitext
19490 start
19491 ==a==
19492 ===aa===
19493 ====aaa====
19494 ==b==
19495 ===ba===
19496 ===bb===
19497 ====bba====
19498 ===bc===
19499 ==c==
19500 ===ca===
19501 !! html/php
19502 ===ba===
19503 !! end
19504
19505 !! test
19506 Section extraction test (section 6)
19507 !! options
19508 section=6
19509 !! wikitext
19510 start
19511 ==a==
19512 ===aa===
19513 ====aaa====
19514 ==b==
19515 ===ba===
19516 ===bb===
19517 ====bba====
19518 ===bc===
19519 ==c==
19520 ===ca===
19521 !! html/php
19522 ===bb===
19523 ====bba====
19524 !! end
19525
19526 !! test
19527 Section extraction test (section 7)
19528 !! options
19529 section=7
19530 !! wikitext
19531 start
19532 ==a==
19533 ===aa===
19534 ====aaa====
19535 ==b==
19536 ===ba===
19537 ===bb===
19538 ====bba====
19539 ===bc===
19540 ==c==
19541 ===ca===
19542 !! html/php
19543 ====bba====
19544 !! end
19545
19546 !! test
19547 Section extraction test (section 8)
19548 !! options
19549 section=8
19550 !! wikitext
19551 start
19552 ==a==
19553 ===aa===
19554 ====aaa====
19555 ==b==
19556 ===ba===
19557 ===bb===
19558 ====bba====
19559 ===bc===
19560 ==c==
19561 ===ca===
19562 !! html/php
19563 ===bc===
19564 !! end
19565
19566 !! test
19567 Section extraction test (section 9)
19568 !! options
19569 section=9
19570 !! wikitext
19571 start
19572 ==a==
19573 ===aa===
19574 ====aaa====
19575 ==b==
19576 ===ba===
19577 ===bb===
19578 ====bba====
19579 ===bc===
19580 ==c==
19581 ===ca===
19582 !! html/php
19583 ==c==
19584 ===ca===
19585 !! end
19586
19587 !! test
19588 Section extraction test (section 10)
19589 !! options
19590 section=10
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 ===ca===
19605 !! end
19606
19607 !! test
19608 Section extraction test (nonexistent section 11)
19609 !! options
19610 section=11
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 !! end
19625
19626 !! test
19627 Section extraction test with bogus heading (section 1)
19628 !! options
19629 section=1
19630 !! wikitext
19631 ==a==
19632 ==bogus== not a legal section
19633 ==b==
19634 !! html/php
19635 ==a==
19636 ==bogus== not a legal section
19637 !! end
19638
19639 !! test
19640 Section extraction test with bogus heading (section 2)
19641 !! options
19642 section=2
19643 !! wikitext
19644 ==a==
19645 ==bogus== not a legal section
19646 ==b==
19647 !! html/php
19648 ==b==
19649 !! end
19650
19651 !! test
19652 Section extraction test with comment after heading (section 1)
19653 !! options
19654 section=1
19655 !! wikitext
19656 ==a==
19657 ==b== <!-- -->
19658 ==c==
19659 !! html/php
19660 ==a==
19661 !! end
19662
19663 !! test
19664 Section extraction test with comment after heading (section 2)
19665 !! options
19666 section=2
19667 !! wikitext
19668 ==a==
19669 ==b== <!-- -->
19670 ==c==
19671 !! html/php
19672 ==b== <!-- -->
19673 !! end
19674
19675 !! test
19676 Section extraction test with bogus <nowiki> heading (section 1)
19677 !! options
19678 section=1
19679 !! wikitext
19680 ==a==
19681 ==bogus== <nowiki>not a legal section</nowiki>
19682 ==b==
19683 !! html/php
19684 ==a==
19685 ==bogus== <nowiki>not a legal section</nowiki>
19686 !! end
19687
19688 !! test
19689 Section extraction test with bogus <nowiki> heading (section 2)
19690 !! options
19691 section=2
19692 !! wikitext
19693 ==a==
19694 ==bogus== <nowiki>not a legal section</nowiki>
19695 ==b==
19696 !! html/php
19697 ==b==
19698 !! end
19699
19700 # Formerly testing for T4587, now resolved by the use of unmarked sections
19701 # instead of respecting commented sections
19702 !! test
19703 Section extraction prefixed by comment (section 1)
19704 !! options
19705 section=1
19706 !! wikitext
19707 <!-- -->==sec1==
19708 ==sec2==
19709 !! html/php
19710 ==sec2==
19711 !!end
19712
19713 !! test
19714 Section extraction prefixed by comment (section 2)
19715 !! options
19716 section=2
19717 !! wikitext
19718 <!-- -->==sec1==
19719 ==sec2==
19720 !! html/php
19721
19722 !!end
19723
19724 # Formerly testing for T4607, now resolved by the use of unmarked sections
19725 # instead of respecting HTML-style headings
19726 !! test
19727 Section extraction, mixed wiki and html (section 1)
19728 !! options
19729 section=1
19730 !! wikitext
19731 <h2>unmarked</h2>
19732 unmarked
19733 ==1==
19734 one
19735 ==2==
19736 two
19737 !! html/php
19738 ==1==
19739 one
19740 !! end
19741
19742 !! test
19743 Section extraction, mixed wiki and html (section 2)
19744 !! options
19745 section=2
19746 !! wikitext
19747 <h2>unmarked</h2>
19748 unmarked
19749 ==1==
19750 one
19751 ==2==
19752 two
19753 !! html/php
19754 ==2==
19755 two
19756 !! end
19757
19758
19759 # Formerly testing for T5342
19760 !! test
19761 Section extraction, heading surrounded by <noinclude>
19762 !! options
19763 section=1
19764 !! wikitext
19765 <noinclude>==unmarked==</noinclude>
19766 ==marked==
19767 !! html/php
19768 ==marked==
19769 !!end
19770
19771 # Test behavior of T21910
19772 !! test
19773 Sectiion with all-equals
19774 !! options
19775 section=2
19776 !! wikitext
19777 ===
19778 The line above must have a trailing space
19779 === <!--
19780 --> <!-- -->
19781 But just in case it doesn't...
19782 !! html/php
19783 === <!--
19784 --> <!-- -->
19785 But just in case it doesn't...
19786 !! end
19787
19788 !! test
19789 Section replacement test (section 0)
19790 !! options
19791 replace=0,"xxx"
19792 !! wikitext
19793 start
19794 ==a==
19795 ===aa===
19796 ====aaa====
19797 ==b==
19798 ===ba===
19799 ===bb===
19800 ====bba====
19801 ===bc===
19802 ==c==
19803 ===ca===
19804 !! html/php
19805 xxx
19806
19807 ==a==
19808 ===aa===
19809 ====aaa====
19810 ==b==
19811 ===ba===
19812 ===bb===
19813 ====bba====
19814 ===bc===
19815 ==c==
19816 ===ca===
19817 !! end
19818
19819 !! test
19820 Section replacement test (section 1)
19821 !! options
19822 replace=1,"xxx"
19823 !! wikitext
19824 start
19825 ==a==
19826 ===aa===
19827 ====aaa====
19828 ==b==
19829 ===ba===
19830 ===bb===
19831 ====bba====
19832 ===bc===
19833 ==c==
19834 ===ca===
19835 !! html/php
19836 start
19837 xxx
19838
19839 ==b==
19840 ===ba===
19841 ===bb===
19842 ====bba====
19843 ===bc===
19844 ==c==
19845 ===ca===
19846 !! end
19847
19848 !! test
19849 Section replacement test (section 2)
19850 !! options
19851 replace=2,"xxx"
19852 !! wikitext
19853 start
19854 ==a==
19855 ===aa===
19856 ====aaa====
19857 ==b==
19858 ===ba===
19859 ===bb===
19860 ====bba====
19861 ===bc===
19862 ==c==
19863 ===ca===
19864 !! html/php
19865 start
19866 ==a==
19867 xxx
19868
19869 ==b==
19870 ===ba===
19871 ===bb===
19872 ====bba====
19873 ===bc===
19874 ==c==
19875 ===ca===
19876 !! end
19877
19878 !! test
19879 Section replacement test (section 3)
19880 !! options
19881 replace=3,"xxx"
19882 !! wikitext
19883 start
19884 ==a==
19885 ===aa===
19886 ====aaa====
19887 ==b==
19888 ===ba===
19889 ===bb===
19890 ====bba====
19891 ===bc===
19892 ==c==
19893 ===ca===
19894 !! html/php
19895 start
19896 ==a==
19897 ===aa===
19898 xxx
19899
19900 ==b==
19901 ===ba===
19902 ===bb===
19903 ====bba====
19904 ===bc===
19905 ==c==
19906 ===ca===
19907 !! end
19908
19909 !! test
19910 Section replacement test (section 4)
19911 !! options
19912 replace=4,"xxx"
19913 !! wikitext
19914 start
19915 ==a==
19916 ===aa===
19917 ====aaa====
19918 ==b==
19919 ===ba===
19920 ===bb===
19921 ====bba====
19922 ===bc===
19923 ==c==
19924 ===ca===
19925 !! html/php
19926 start
19927 ==a==
19928 ===aa===
19929 ====aaa====
19930 xxx
19931
19932 ==c==
19933 ===ca===
19934 !! end
19935
19936 !! test
19937 Section replacement test (section 5)
19938 !! options
19939 replace=5,"xxx"
19940 !! wikitext
19941 start
19942 ==a==
19943 ===aa===
19944 ====aaa====
19945 ==b==
19946 ===ba===
19947 ===bb===
19948 ====bba====
19949 ===bc===
19950 ==c==
19951 ===ca===
19952 !! html/php
19953 start
19954 ==a==
19955 ===aa===
19956 ====aaa====
19957 ==b==
19958 xxx
19959
19960 ===bb===
19961 ====bba====
19962 ===bc===
19963 ==c==
19964 ===ca===
19965 !! end
19966
19967 !! test
19968 Section replacement test (section 6)
19969 !! options
19970 replace=6,"xxx"
19971 !! wikitext
19972 start
19973 ==a==
19974 ===aa===
19975 ====aaa====
19976 ==b==
19977 ===ba===
19978 ===bb===
19979 ====bba====
19980 ===bc===
19981 ==c==
19982 ===ca===
19983 !! html/php
19984 start
19985 ==a==
19986 ===aa===
19987 ====aaa====
19988 ==b==
19989 ===ba===
19990 xxx
19991
19992 ===bc===
19993 ==c==
19994 ===ca===
19995 !! end
19996
19997 !! test
19998 Section replacement test (section 7)
19999 !! options
20000 replace=7,"xxx"
20001 !! wikitext
20002 start
20003 ==a==
20004 ===aa===
20005 ====aaa====
20006 ==b==
20007 ===ba===
20008 ===bb===
20009 ====bba====
20010 ===bc===
20011 ==c==
20012 ===ca===
20013 !! html/php
20014 start
20015 ==a==
20016 ===aa===
20017 ====aaa====
20018 ==b==
20019 ===ba===
20020 ===bb===
20021 xxx
20022
20023 ===bc===
20024 ==c==
20025 ===ca===
20026 !! end
20027
20028 !! test
20029 Section replacement test (section 8)
20030 !! options
20031 replace=8,"xxx"
20032 !! wikitext
20033 start
20034 ==a==
20035 ===aa===
20036 ====aaa====
20037 ==b==
20038 ===ba===
20039 ===bb===
20040 ====bba====
20041 ===bc===
20042 ==c==
20043 ===ca===
20044 !! html/php
20045 start
20046 ==a==
20047 ===aa===
20048 ====aaa====
20049 ==b==
20050 ===ba===
20051 ===bb===
20052 ====bba====
20053 xxx
20054
20055 ==c==
20056 ===ca===
20057 !!end
20058
20059 !! test
20060 Section replacement test (section 9)
20061 !! options
20062 replace=9,"xxx"
20063 !! wikitext
20064 start
20065 ==a==
20066 ===aa===
20067 ====aaa====
20068 ==b==
20069 ===ba===
20070 ===bb===
20071 ====bba====
20072 ===bc===
20073 ==c==
20074 ===ca===
20075 !! html/php
20076 start
20077 ==a==
20078 ===aa===
20079 ====aaa====
20080 ==b==
20081 ===ba===
20082 ===bb===
20083 ====bba====
20084 ===bc===
20085 xxx
20086 !! end
20087
20088 !! test
20089 Section replacement test (section 10)
20090 !! options
20091 replace=10,"xxx"
20092 !! wikitext
20093 start
20094 ==a==
20095 ===aa===
20096 ====aaa====
20097 ==b==
20098 ===ba===
20099 ===bb===
20100 ====bba====
20101 ===bc===
20102 ==c==
20103 ===ca===
20104 !! html/php
20105 start
20106 ==a==
20107 ===aa===
20108 ====aaa====
20109 ==b==
20110 ===ba===
20111 ===bb===
20112 ====bba====
20113 ===bc===
20114 ==c==
20115 xxx
20116 !! end
20117
20118 !! test
20119 Section replacement test with initial whitespace (T15728)
20120 !! options
20121 replace=2,"xxx"
20122 !! wikitext
20123 Preformatted initial line
20124 ==a==
20125 ===a===
20126 !! html/php
20127 Preformatted initial line
20128 ==a==
20129 xxx
20130 !! end
20131
20132
20133 !! test
20134 Section extraction, heading followed by pre with 20 spaces (T8398)
20135 !! options
20136 section=1
20137 !! wikitext
20138 ==a==
20139 a
20140 !! html/php
20141 ==a==
20142 a
20143 !! end
20144
20145 !! test
20146 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
20147 !! options
20148 section=1
20149 !! wikitext
20150 ==a==
20151 a
20152 !! html/php
20153 ==a==
20154 a
20155 !! end
20156
20157
20158 !! test
20159 Section extraction, <pre> around bogus header (T12309)
20160 !! options
20161 section=2
20162 !! wikitext
20163 == Section One ==
20164 <pre>
20165 =======
20166 </pre>
20167
20168 == Section Two ==
20169 stuff
20170 !! html/php
20171 == Section Two ==
20172 stuff
20173 !! end
20174
20175 !! test
20176 Section replacement, <pre> around bogus header (T12309)
20177 !! options
20178 replace=2,"xxx"
20179 !! wikitext
20180 == Section One ==
20181 <pre>
20182 =======
20183 </pre>
20184
20185 == Section Two ==
20186 stuff
20187 !! html/php
20188 == Section One ==
20189 <pre>
20190 =======
20191 </pre>
20192
20193 xxx
20194 !! end
20195
20196 !! test
20197 Handling of &#x0A; in URLs
20198 !! wikitext
20199 *irc://&#x0A;a
20200 !! html/php
20201 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20202
20203 !! html/parsoid
20204 <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>
20205 !! end
20206
20207 !! test
20208 Handling of %0A in URLs
20209 !! wikitext
20210 *irc://%0Aa
20211 !! html/php
20212 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20213
20214 !! html/parsoid
20215 <ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
20216 !! end
20217
20218 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
20219 !! test
20220 5 quotes, code coverage +1 line
20221 !! options
20222 parsoid=wt2html
20223 !! wikitext
20224 '''''
20225 !! html/php
20226 !! html/parsoid
20227 <b><i></i></b>
20228 !! end
20229
20230 # same html as previous, but wikitext adjusted to match parsoid html2wt
20231 # note that wt2html and html2html will put the <i> before the <b>
20232 !! test
20233 5 quotes, code coverage +1 line w/ nowiki (1)
20234 !! options
20235 parsoid=wt2wt,html2wt
20236 !! wikitext
20237 '''''<nowiki/>'''''
20238 !! html/php
20239 <p><i></i>
20240 </p>
20241 !! html/parsoid
20242 <p><b><i></i></b></p>
20243 !! end
20244
20245 # same as previous, just swapping the <i> and <b>
20246 !! test
20247 5 quotes, code coverage +1 line w/ nowiki (2)
20248 !! wikitext
20249 '''''<nowiki/>'''''
20250 !! html/php
20251 <p><i></i>
20252 </p>
20253 !! html/parsoid
20254 <p><i><b></b></i></p>
20255 !! end
20256
20257 !! test
20258 Special:Search page linking.
20259 !! wikitext
20260 {{Special:search}}
20261 !! html
20262 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
20263 </p>
20264 !! end
20265
20266 !! test
20267 {{!}} is a magic word
20268 !! wikitext
20269 {{!}} is a magic word there and {{!}} is still a magic word here
20270 | is not a magic word here but {{!}} is still a magic word here
20271 !! html/php
20272 <p>| is a magic word there and | is still a magic word here
20273 | is not a magic word here but | is still a magic word here
20274 </p>
20275 !! html/parsoid
20276 <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
20277 | 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>
20278 !! end
20279
20280 !! test
20281 Say the magic word
20282 !! options
20283 title=[[Parser test]]
20284 !! wikitext
20285 *{{PAGENAME}}
20286 *{{PAGENAMEE}}
20287 *{{FULLPAGENAME}}
20288 *{{FULLPAGENAMEE}}
20289 *{{BASEPAGENAME}}
20290 *{{BASEPAGENAMEE}}
20291 *{{SUBPAGENAME}}
20292 *{{SUBPAGENAMEE}}
20293 *{{ROOTPAGENAME}}
20294 *{{ROOTPAGENAMEE}}
20295 *{{TALKPAGENAME}}
20296 *{{TALKPAGENAMEE}}
20297 *{{SUBJECTPAGENAME}}
20298 *{{SUBJECTPAGENAMEE}}
20299 *{{NAMESPACEE}}
20300 *{{NAMESPACE}}
20301 *{{NAMESPACENUMBER}}
20302 *{{TALKSPACE}}
20303 *{{TALKSPACEE}}
20304 *{{SUBJECTSPACE}}
20305 *{{SUBJECTSPACEE}}
20306 *{{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
20307 !! html
20308 <ul><li>Parser test</li>
20309 <li>Parser_test</li>
20310 <li>Parser test</li>
20311 <li>Parser_test</li>
20312 <li>Parser test</li>
20313 <li>Parser_test</li>
20314 <li>Parser test</li>
20315 <li>Parser_test</li>
20316 <li>Parser test</li>
20317 <li>Parser_test</li>
20318 <li>Talk:Parser test</li>
20319 <li>Talk:Parser_test</li>
20320 <li>Parser test</li>
20321 <li>Parser_test</li>
20322 <li></li>
20323 <li></li>
20324 <li>0</li>
20325 <li>Talk</li>
20326 <li>Talk</li>
20327 <li></li>
20328 <li></li>
20329 <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>
20330
20331 !! end
20332 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
20333
20334 !! test
20335 Gallery with valid attributes
20336 !! wikitext
20337 <gallery type="123" summary="345">
20338 File:File:Foobar.jpg
20339 </gallery>
20340 !! html/php
20341 <ul class="gallery mw-gallery-traditional" type="123">
20342 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20343 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
20344 <div class="gallerytext">
20345 </div>
20346 </div></li>
20347 </ul>
20348
20349 !! html/parsoid
20350 <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"}}'>
20351 <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>
20352 </ul>
20353 !! end
20354
20355 ## Parsoid thinks the "centre" here is a property, not a caption.
20356 !! test
20357 Gallery
20358 !! options
20359 parsoid={
20360 "modes": ["wt2html"],
20361 "nativeGallery": true
20362 }
20363 !! wikitext
20364 <gallery>
20365 image1.png |
20366 image2.gif|||||
20367
20368 image3|
20369 image4 |300px| centre
20370 image5.svg| http://///////
20371 [[x|xx]]]]
20372 * image6
20373 </gallery>
20374 !! html/php
20375 <ul class="gallery mw-gallery-traditional">
20376 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20377 <div class="thumb" style="height: 150px;">Image1.png</div>
20378 <div class="gallerytext">
20379 </div>
20380 </div></li>
20381 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20382 <div class="thumb" style="height: 150px;">Image2.gif</div>
20383 <div class="gallerytext">
20384 </div>
20385 </div></li>
20386 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20387 <div class="thumb" style="height: 150px;">Image3</div>
20388 <div class="gallerytext">
20389 </div>
20390 </div></li>
20391 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20392 <div class="thumb" style="height: 150px;">Image4</div>
20393 <div class="gallerytext">
20394 <pre>centre
20395 </pre>
20396 </div>
20397 </div></li>
20398 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20399 <div class="thumb" style="height: 150px;">Image5.svg</div>
20400 <div class="gallerytext">
20401 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
20402 </p>
20403 </div>
20404 </div></li>
20405 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20406 <div class="thumb" style="height: 150px;">* image6</div>
20407 <div class="gallerytext">
20408 </div>
20409 </div></li>
20410 </ul>
20411
20412 !! html/parsoid
20413 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20414 <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>
20415 <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>
20416 <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>
20417 <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>
20418 <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>
20419 <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>
20420 </ul>
20421 !! end
20422
20423 !! test
20424 Gallery (with options, html)
20425 !! options
20426 parsoid={
20427 "modes": ["wt2html", "html2html"],
20428 "nativeGallery": true
20429 }
20430 !! wikitext
20431 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20432 File:Nonexistent.jpg|caption
20433 File:Nonexistent.jpg
20434 image:foobar.jpg|some '''caption''' [[Main Page]]
20435 image:foobar.jpg
20436 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20437 </gallery>
20438 !! html/php
20439 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20440 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20441 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20442 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20443 <div class="gallerytext">
20444 <p>caption
20445 </p>
20446 </div>
20447 </div></li>
20448 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20449 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20450 <div class="gallerytext">
20451 </div>
20452 </div></li>
20453 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20454 <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>
20455 <div class="gallerytext">
20456 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20457 </p>
20458 </div>
20459 </div></li>
20460 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20461 <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>
20462 <div class="gallerytext">
20463 </div>
20464 </div></li>
20465 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20466 <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>
20467 <div class="gallerytext">
20468 <p>blabla.
20469 </p>
20470 </div>
20471 </div></li>
20472 </ul>
20473
20474 !! html/parsoid
20475 <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":{}}'>
20476 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20477 <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>
20478 <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>
20479 <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>
20480 <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>
20481 <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>
20482 </ul>
20483 !! end
20484
20485 !! test
20486 Gallery (with options, extsrc)
20487 !! options
20488 parsoid={
20489 "nativeGallery": false
20490 }
20491 !! wikitext
20492 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20493 File:Nonexistent.jpg|caption
20494 File:Nonexistent.jpg
20495 image:foobar.jpg|some '''caption''' [[Main Page]]
20496 image:foobar.jpg
20497 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20498 </gallery>
20499 !! html/php
20500 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20501 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20502 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20503 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20504 <div class="gallerytext">
20505 <p>caption
20506 </p>
20507 </div>
20508 </div></li>
20509 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20510 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20511 <div class="gallerytext">
20512 </div>
20513 </div></li>
20514 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20515 <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>
20516 <div class="gallerytext">
20517 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20518 </p>
20519 </div>
20520 </div></li>
20521 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20522 <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>
20523 <div class="gallerytext">
20524 </div>
20525 </div></li>
20526 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20527 <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>
20528 <div class="gallerytext">
20529 <p>blabla.
20530 </p>
20531 </div>
20532 </div></li>
20533 </ul>
20534
20535 !! html/parsoid
20536 <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"}}'>
20537 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20538 <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>
20539 <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>
20540 <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>
20541 <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>
20542 <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>
20543 </ul>
20544 !! end
20545
20546 !! test
20547 Gallery (without px units)
20548 !! wikitext
20549 <gallery widths="70" heights="40">
20550 File:Foobar.jpg
20551 </gallery>
20552 !! html/php
20553 <ul class="gallery mw-gallery-traditional">
20554 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20555 <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>
20556 <div class="gallerytext">
20557 </div>
20558 </div></li>
20559 </ul>
20560
20561 !! html/parsoid
20562 <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"}}'>
20563 <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>
20564 </ul>
20565 !! end
20566
20567 !! test
20568 Gallery (with invalid units)
20569 !! wikitext
20570 <gallery widths="70em" heights="40em">
20571 File:Foobar.jpg
20572 </gallery>
20573 !! html/php
20574 <ul class="gallery mw-gallery-traditional">
20575 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20576 <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>
20577 <div class="gallerytext">
20578 </div>
20579 </div></li>
20580 </ul>
20581
20582 !! html/parsoid
20583 <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"}}'>
20584 <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>
20585 </ul>
20586 !! end
20587
20588 !! test
20589 Gallery with link that has fragment
20590 !! options
20591 parsoid={
20592 "modes": ["wt2html", "html2html"],
20593 "nativeGallery": true
20594 }
20595 !! wikitext
20596 <gallery>
20597 image:foobar.jpg|link=Main_Page
20598 image:foobar.jpg|link=Main_Page#section
20599 image:foobar.jpg|link=Main Page#section|caption
20600 </gallery>
20601 !! html/php
20602 <ul class="gallery mw-gallery-traditional">
20603 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20604 <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>
20605 <div class="gallerytext">
20606 </div>
20607 </div></li>
20608 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20609 <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>
20610 <div class="gallerytext">
20611 </div>
20612 </div></li>
20613 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20614 <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>
20615 <div class="gallerytext">
20616 <p>caption
20617 </p>
20618 </div>
20619 </div></li>
20620 </ul>
20621
20622 !! html/parsoid
20623 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20624 <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>
20625 <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>
20626 <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>
20627 </ul>
20628 !! end
20629
20630 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
20631 !! test
20632 Gallery with template inside caption
20633 !! options
20634 parsoid={
20635 "nativeGallery": true
20636 }
20637 !! wikitext
20638 <gallery caption="{{echo|hi}}">
20639 File:Foobar.jpg|{{echo|ho}}
20640 </gallery>
20641 !! html/php
20642 <ul class="gallery mw-gallery-traditional">
20643 <li class='gallerycaption'>{{echo|hi}}</li>
20644 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20645 <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>
20646 <div class="gallerytext">
20647 <p>ho
20648 </p>
20649 </div>
20650 </div></li>
20651 </ul>
20652
20653 !! html/parsoid
20654 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20655 <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>
20656 <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>
20657 </ul>
20658 !! end
20659
20660 !! test
20661 Gallery with wikitext inside caption
20662 !! options
20663 parsoid={
20664 "nativeGallery": true
20665 }
20666 !! wikitext
20667 <gallery>
20668 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
20669 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
20670 </gallery>
20671 !! html/php
20672 <ul class="gallery mw-gallery-traditional">
20673 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20674 <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>
20675 <div class="gallerytext">
20676 <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>
20677 </p>
20678 </div>
20679 </div></li>
20680 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20681 <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>
20682 <div class="gallerytext">
20683 <p>This is a test template
20684 </p>
20685 </div>
20686 </div></li>
20687 </ul>
20688
20689 !! html/parsoid
20690 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20691 <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>
20692 <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>
20693 </ul>
20694 !! end
20695
20696 !! test
20697 Gallery (with showfilename option)
20698 !! options
20699 parsoid={
20700 "nativeGallery": true
20701 }
20702 !! wikitext
20703 <gallery showfilename="">
20704 File:Nonexistent.jpg|caption
20705 File:Nonexistent.jpg
20706 File:Foobar.jpg|some '''caption''' [[Main Page]]
20707 File:Foobar.jpg
20708 </gallery>
20709 !! html/php
20710 <ul class="gallery mw-gallery-traditional">
20711 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20712 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20713 <div class="gallerytext">
20714 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20715 caption
20716 </p>
20717 </div>
20718 </div></li>
20719 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20720 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20721 <div class="gallerytext">
20722 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20723 </p>
20724 </div>
20725 </div></li>
20726 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20727 <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>
20728 <div class="gallerytext">
20729 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20730 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20731 </p>
20732 </div>
20733 </div></li>
20734 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20735 <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>
20736 <div class="gallerytext">
20737 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20738 </p>
20739 </div>
20740 </div></li>
20741 </ul>
20742
20743 !! html/parsoid
20744 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
20745 <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>
20746 <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>
20747 <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>
20748 <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>
20749 </ul>
20750 !! end
20751
20752 ## Should Parsoid be preserving these variations? See T151367
20753 !! test
20754 Gallery (with namespace-less filenames)
20755 !! options
20756 parsoid={
20757 "modes": ["wt2html", "html2html"],
20758 "nativeGallery": true
20759 }
20760 !! wikitext
20761 <gallery>
20762 File:Nonexistent.jpg
20763 Nonexistent.jpg
20764 image:foobar.jpg
20765 foobar.jpg
20766 </gallery>
20767 !! html/php
20768 <ul class="gallery mw-gallery-traditional">
20769 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20770 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20771 <div class="gallerytext">
20772 </div>
20773 </div></li>
20774 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20775 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20776 <div class="gallerytext">
20777 </div>
20778 </div></li>
20779 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20780 <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>
20781 <div class="gallerytext">
20782 </div>
20783 </div></li>
20784 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20785 <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>
20786 <div class="gallerytext">
20787 </div>
20788 </div></li>
20789 </ul>
20790
20791 !! html/parsoid
20792 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" 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: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>
20794 <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>
20795 <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>
20796 <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>
20797 </ul>
20798 !! end
20799
20800 !! test
20801 Gallery override link with wikilink (T36852)
20802 !! options
20803 parsoid={
20804 "nativeGallery": true
20805 }
20806 !! wikitext
20807 <gallery>
20808 File:Foobar.jpg|alt=galleryalt|link=Wikilink
20809 </gallery>
20810 !! html/php
20811 <ul class="gallery mw-gallery-traditional">
20812 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20813 <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>
20814 <div class="gallerytext">
20815 </div>
20816 </div></li>
20817 </ul>
20818
20819 !! html/parsoid
20820 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20821 <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>
20822 </ul>
20823 !! end
20824
20825 !! test
20826 Gallery override link with absolute external link (T36852)
20827 !! options
20828 parsoid={
20829 "nativeGallery": true
20830 }
20831 !! wikitext
20832 <gallery>
20833 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
20834 </gallery>
20835 !! html/php
20836 <ul class="gallery mw-gallery-traditional">
20837 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20838 <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>
20839 <div class="gallerytext">
20840 </div>
20841 </div></li>
20842 </ul>
20843
20844 !! html/parsoid
20845 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20846 <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>
20847 </ul>
20848 !! end
20849
20850 !! test
20851 Gallery override link with absolute external link with LanguageConverter
20852 !! options
20853 language=zh
20854 !! wikitext
20855 <gallery>
20856 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
20857 </gallery>
20858 !! html/php
20859 <ul class="gallery mw-gallery-traditional">
20860 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20861 <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>
20862 <div class="gallerytext">
20863 <p>caption
20864 </p>
20865 </div>
20866 </div></li>
20867 </ul>
20868
20869 !! html/parsoid
20870 <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"}}'>
20871 <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>
20872 </ul>
20873 !! end
20874
20875 !! test
20876 Gallery override link with malicious javascript (T36852)
20877 !! options
20878 parsoid={
20879 "modes": ["wt2html", "html2html"],
20880 "nativeGallery": true
20881 }
20882 !! wikitext
20883 <gallery>
20884 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
20885 </gallery>
20886 !! html/php
20887 <ul class="gallery mw-gallery-traditional">
20888 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20889 <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>
20890 <div class="gallerytext">
20891 </div>
20892 </div></li>
20893 </ul>
20894
20895 !! html/parsoid
20896 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20897 <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>
20898 </ul>
20899 !! end
20900
20901 # Note that parsoid uses the invalid link as a caption, PHP does not.
20902 !! test
20903 Gallery with invalid title as link (T45964)
20904 !! options
20905 parsoid={
20906 "modes": ["wt2html", "html2html"],
20907 "nativeGallery": true
20908 }
20909 !! wikitext
20910 <gallery>
20911 File:Foobar.jpg|link=<
20912 </gallery>
20913 !! html/php
20914 <ul class="gallery mw-gallery-traditional">
20915 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20916 <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>
20917 <div class="gallerytext">
20918 </div>
20919 </div></li>
20920 </ul>
20921
20922 !! html/parsoid
20923 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20924 <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>
20925 </ul>
20926 !! end
20927
20928 !! test
20929 Serialize gallery without attrs in data-mw
20930 !! options
20931 parsoid={
20932 "modes": ["html2wt"],
20933 "nativeGallery": true
20934 }
20935 !! html/parsoid
20936 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
20937 <li class="gallerycaption">123</li>
20938 <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>
20939 </ul>
20940 !! wikitext
20941 <gallery caption="123">
20942 File:Test.png
20943 </gallery>
20944 !! end
20945
20946 !! test
20947 Gallery with class and style attributes
20948 !! options
20949 parsoid={
20950 "nativeGallery": true
20951 }
20952 !! wikitext
20953 <gallery class="center" style="text-align: center;">
20954 File:Foobar.jpg
20955 </gallery>
20956 !! html/php
20957 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
20958 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20959 <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>
20960 <div class="gallerytext">
20961 </div>
20962 </div></li>
20963 </ul>
20964
20965 !! html/parsoid
20966 <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":{}}'>
20967 <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>
20968 </ul>
20969 !! end
20970
20971 !! test
20972 Gallery in slideshow mode
20973 !! options
20974 parsoid={
20975 "nativeGallery": true
20976 }
20977 !! wikitext
20978 <gallery mode="slideshow" showthumbnails="">
20979 File:Foobar.jpg
20980 </gallery>
20981 !! html/php
20982 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
20983 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20984 <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>
20985 <div class="gallerytext">
20986 </div>
20987 </div></li>
20988 </ul>
20989
20990 !! html/parsoid
20991 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
20992 <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>
20993 </ul>
20994 !! end
20995
20996 !! test
20997 HTML Hex character encoding (spells the word "JavaScript")
20998 !! options
20999 parsoid=wt2html,wt2wt,html2html
21000 !! wikitext
21001 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
21002 !! html/php
21003 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
21004 </p>
21005 !! html/parsoid
21006 <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>
21007 !! end
21008
21009 !! test
21010 HTML Hex character encoding bogus encoding (T28437 regression check)
21011 !! wikitext
21012 &#xsee;&#XSEE;
21013 !! html
21014 <p>&amp;#xsee;&amp;#XSEE;
21015 </p>
21016 !! end
21017
21018 !! test
21019 HTML Hex character encoding mixed case
21020 !! options
21021 parsoid=wt2html,wt2wt,html2html
21022 !! wikitext
21023 &#xEE;&#Xee;
21024 !! html/php
21025 <p>&#xee;&#xee;
21026 </p>
21027 !! html/parsoid
21028 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
21029 !! end
21030
21031 # See: https://www.w3.org/TR/html5/syntax.html#character-references
21032 # Note that U+000C (form feed) is not a valid XML character, so
21033 # it is banned even though allowed in HTML5.
21034 !! test
21035 Illegal character references (T106578)
21036 !! wikitext
21037 ; Null: &#00;
21038 ; FF: &#xC;
21039 ; CR: &#xD;
21040 ; Control (low): &#8;
21041 ; Control (high): &#x7F; &#x9F;
21042 ; Surrogate: &#xD83D;&#xDCA9;
21043 ; This is an okay astral character: &#x1F4A9;
21044 !! html+tidy
21045 <dl><dt>Null</dt>
21046 <dd>&amp;#00;</dd>
21047 <dt>FF</dt>
21048 <dd>&amp;#xC;</dd>
21049 <dt>CR</dt>
21050 <dd>&amp;#xD;</dd>
21051 <dt>Control (low)</dt>
21052 <dd>&amp;#8;</dd>
21053 <dt>Control (high)</dt>
21054 <dd>&amp;#x7F; &amp;#x9F;</dd>
21055 <dt>Surrogate</dt>
21056 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
21057 <dt>This is an okay astral character</dt>
21058 <dd>&#x1f4a9;</dd></dl>
21059 !! end
21060
21061 !! test
21062 __FORCETOC__ override
21063 !! wikitext
21064 __NEWSECTIONLINK__
21065 __FORCETOC__
21066 !! html/php
21067 <p><br />
21068 </p>
21069 !! end
21070
21071 !! test
21072 ISBN code coverage
21073 !! wikitext
21074 ISBN 978-0-1234-56&#x20;789
21075 !! html/php
21076 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
21077 </p>
21078 !! html/parsoid
21079 <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>
21080 !! end
21081
21082 !! test
21083 ISBN followed by 5 spaces
21084 !! wikitext
21085 ISBN
21086 !! html
21087 <p>ISBN
21088 </p>
21089 !! end
21090
21091 !! test
21092 Double ISBN
21093 !! wikitext
21094 ISBN ISBN 1234567890
21095 !! html/php
21096 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21097 </p>
21098 !! html/parsoid
21099 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21100 !! end
21101
21102 # Uppercase X and lowercase x as well
21103 !! test
21104 ISBN with an X
21105 !! wikitext
21106 ISBN 3-462-04561-X
21107 ISBN 3-462-04561-x
21108 ISBN 080442957X
21109 ISBN 080442957x
21110 ISBN 978080442957X
21111 ISBN 978080442957x
21112 !! html/php
21113 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
21114 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
21115 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
21116 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
21117 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
21118 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
21119 </p>
21120 !! html/parsoid
21121 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
21122 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
21123 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
21124 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
21125 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
21126 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
21127 !! end
21128
21129 !! test
21130 ISBN with empty prefix (parsoid test)
21131 !! wikitext
21132 ISBN 1234567890
21133 !! html/php
21134 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21135 </p>
21136 !! html/parsoid
21137 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
21138 !! end
21139
21140 !! test
21141 T24905: <abbr> followed by ISBN followed by </a>
21142 !! wikitext
21143 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
21144 !! html/php
21145 <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>
21146 </p>
21147 !! html/parsoid
21148 <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>
21149 !! end
21150
21151 !! test
21152 Double RFC
21153 !! wikitext
21154 RFC RFC 1234
21155 !! html
21156 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
21157 </p>
21158 !! end
21159
21160 !! test
21161 Double RFC with a wiki link
21162 !! wikitext
21163 RFC [[RFC 1234]]
21164 !! html
21165 <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>
21166 </p>
21167 !! end
21168
21169 !! test
21170 RFC code coverage
21171 !! wikitext
21172 RFC 983&#x20;987
21173 !! html/php
21174 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
21175 </p>
21176 !! html/parsoid
21177 <p><a href="https://tools.ietf.org/html/rfc983" rel="mw:ExtLink" class="external text" data-parsoid='{"stx":"magiclink"}'>RFC 983</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#x20;","srcContent":" "}'> </span>987</p>
21178 !! end
21179
21180 !! test
21181 Centre-aligned image
21182 !! wikitext
21183 [[Image:foobar.jpg|centre]]
21184 !! html/php
21185 <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>
21186
21187 !! html/parsoid
21188 <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>
21189 !! end
21190
21191 !! test
21192 None-aligned image
21193 !! wikitext
21194 [[Image:foobar.jpg|none]]
21195 !! html/php
21196 <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>
21197
21198 !! html/parsoid
21199 <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>
21200 !! end
21201
21202 !! test
21203 Width + Height sized image (using px) (height is ignored)
21204 !! wikitext
21205 [[Image:foobar.jpg|640x480px]]
21206 !! html/php
21207 <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>
21208 </p>
21209 !! html/parsoid
21210 <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>
21211 !! end
21212
21213 !! test
21214 Width-sized image (using px, no following whitespace)
21215 !! wikitext
21216 [[Image:foobar.jpg|640px]]
21217 !! html/php
21218 <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>
21219 </p>
21220 !! html/parsoid
21221 <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>
21222 !! end
21223
21224 !! test
21225 Width-sized image (using px, with following whitespace - test regression from r39467)
21226 !! wikitext
21227 [[Image:foobar.jpg|640px ]]
21228 !! html/php
21229 <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>
21230 </p>
21231 !! html/parsoid
21232 <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>
21233 !!end
21234
21235 !! test
21236 Width-sized image (using px, with preceding whitespace - test regression from r39467)
21237 !! wikitext
21238 [[Image:foobar.jpg| 640px]]
21239 !! html/php
21240 <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>
21241 </p>
21242 !! html/parsoid
21243 <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>
21244 !! end
21245
21246 !! test
21247 Image with page parameter
21248 !! options
21249 djvu
21250 !! wikitext
21251 [[File:LoremIpsum.djvu|page=2]]
21252 !! html/php
21253 <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>
21254 </p>
21255 !! html/parsoid
21256 <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>
21257 !! end
21258
21259 !! test
21260 Another italics / bold test
21261 !! wikitext
21262 ''' ''x'
21263 !! html
21264 <pre>'<i> </i>x'
21265 </pre>
21266 !!end
21267
21268 # FIXME: The php output seems broken. It's interleaving some open/close tags.
21269 !! test
21270 dt/dd/dl test
21271 !! wikitext
21272 :;;;::
21273 !! html/php
21274 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
21275
21276 !! html/parsoid
21277 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
21278
21279 !!end
21280
21281 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
21282 !! test
21283 Images with the "|" character in the comment
21284 !! wikitext
21285 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
21286 !! html/php
21287 <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>
21288
21289 !! html/parsoid
21290 <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>
21291 !! end
21292
21293 !! test
21294 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
21295 !! wikitext
21296 <html><script>alert(1);</script></html>
21297 !! html
21298 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
21299 </p>
21300 !! end
21301
21302 !! test
21303 HTML with raw HTML ($wgRawHtml==true)
21304 !! options
21305 wgRawHtml=1
21306 !! wikitext
21307 <html><script>alert(1);</script></html>
21308 !! html/php
21309 <p><script>alert(1);</script>
21310 </p>
21311 !! end
21312
21313 !! test
21314 Parents of subpages, one level up
21315 !! options
21316 subpage title=[[Subpage test/L1/L2/L3]]
21317 !! wikitext
21318 [[../|L2]]
21319 !! html
21320 <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>
21321 </p>
21322 !! end
21323
21324
21325 !! test
21326 Parents of subpages, one level up, not named
21327 !! options
21328 subpage title=[[Subpage test/L1/L2/L3]]
21329 !! wikitext
21330 [[../]]
21331 !! html
21332 <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>
21333 </p>
21334 !! end
21335
21336
21337
21338 !! test
21339 Parents of subpages, two levels up
21340 !! options
21341 subpage title=[[Subpage test/L1/L2/L3]]
21342 !! wikitext
21343 [[../../|L1]]2
21344
21345 [[../../|L1]]l
21346 !! html
21347 <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
21348 </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>
21349 </p>
21350 !! end
21351
21352 !! test
21353 Parents of subpages, two levels up, without trailing slash or name.
21354 !! options
21355 subpage title=[[Subpage test/L1/L2/L3]]
21356 !! wikitext
21357 [[../..]]
21358 !! html
21359 <p>[[../..]]
21360 </p>
21361 !! end
21362
21363 !! test
21364 Parents of subpages, two levels up, with lots of extra trailing slashes.
21365 !! options
21366 subpage title=[[Subpage test/L1/L2/L3]]
21367 !! wikitext
21368 [[../../////]]
21369 !! html
21370 <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>
21371 </p>
21372 !! end
21373
21374 !! article
21375 Subpage test/L1/L2/L3Sibling
21376 !! text
21377 Sibling article
21378 !! endarticle
21379
21380 !! test
21381 Transclusion of a sibling page (one level up)
21382 !! options
21383 subpage title=[[Subpage test/L1/L2/L3]]
21384 !! wikitext
21385 {{../L3Sibling}}
21386 !! html
21387 <p>Sibling article
21388 </p>
21389 !! end
21390
21391 !! test
21392 Transclusion of a child page
21393 !! options
21394 subpage title=[[Subpage test/L1/L2]]
21395 !! wikitext
21396 {{/L3Sibling}}
21397 !! html
21398 <p>Sibling article
21399 </p>
21400 !! end
21401
21402 # This is wt2html only in Parsoid because we add <nowiki>
21403 # because of {{..}} and we don't expect to fix that to
21404 # eliminate the nowikis selective for {{..}} markup.
21405 !! test
21406 Non-transclusion because of too many up levels
21407 !! options
21408 subpage title=[[Subpage test/L1/L2/L3]]
21409 parsoid=wt2html
21410 !! wikitext
21411 {{../../../../More than parent}}
21412 !! html/php
21413 <p>{{../../../../More than parent}}
21414 </p>
21415 !! html/parsoid
21416 <p>{{../../../../More than parent}}</p>
21417 !! end
21418
21419 !! test
21420 Definition list code coverage
21421 !! wikitext
21422 ;title : def
21423 ;title : def
21424 ;title: def
21425 !! html/php
21426 <dl><dt>title &#160;</dt>
21427 <dd>def</dd>
21428 <dt>title&#160;</dt>
21429 <dd>def</dd>
21430 <dt>title</dt>
21431 <dd>def</dd></dl>
21432
21433 !! html/parsoid
21434 <dl><dt>title <span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21435 <dt>title<span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21436 <dt>title</dt><dd> def</dd></dl>
21437 !! end
21438
21439 !! test
21440 Don't fall for the self-closing div
21441 !! wikitext
21442 <div>hello world</div/>
21443 !! html
21444 <div>hello world</div>
21445
21446 !! end
21447
21448 !! test
21449 MSGNW magic word
21450 !! wikitext
21451 {{MSGNW:msg}}
21452 !! html/php
21453 <p>&#91;&#91;:Template:Msg&#93;&#93;
21454 </p>
21455 !! end
21456
21457 !! test
21458 RAW magic word
21459 !! wikitext
21460 {{RAW:QUERTY}}
21461 !! html
21462 <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>
21463 </p>
21464 !! end
21465
21466 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
21467 !! test
21468 Always escape literal '>' in output, not just after '<'
21469 !! wikitext
21470 ><>
21471 !! html
21472 <p>&gt;&lt;&gt;
21473 </p>
21474 !! end
21475
21476 !! test
21477 Template caching
21478 !! wikitext
21479 {{Test}}
21480 {{Test}}
21481 !! html
21482 <p>This is a test template
21483 This is a test template
21484 </p>
21485 !! end
21486
21487
21488 !! article
21489 MediaWiki:Fake
21490 !! text
21491 ==header==
21492 !! endarticle
21493
21494 !! test
21495 Inclusion of !userCanEdit() content
21496 !! wikitext
21497 {{MediaWiki:Fake}}
21498 !! html
21499 <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>
21500
21501 !! end
21502
21503
21504 !! test
21505 Out-of-order TOC heading levels
21506 !! wikitext
21507 ==2==
21508 ======6======
21509 ===3===
21510 =1=
21511 =====5=====
21512 ==2==
21513 !! html
21514 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
21515 <ul>
21516 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
21517 <ul>
21518 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
21519 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
21520 </ul>
21521 </li>
21522 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
21523 <ul>
21524 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
21525 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
21526 </ul>
21527 </li>
21528 </ul>
21529 </div>
21530
21531 <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>
21532 <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>
21533 <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>
21534 <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>
21535 <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>
21536 <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>
21537
21538 !! end
21539
21540
21541 !! test
21542 ISBN with a dummy number
21543 !! wikitext
21544 ISBN ---
21545 !! html
21546 <p>ISBN ---
21547 </p>
21548 !! end
21549
21550
21551 !! test
21552 ISBN with space-delimited number
21553 !! wikitext
21554 ISBN 92 9017 032 8
21555 !! html/php
21556 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
21557 </p>
21558 !! html/parsoid
21559 <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>
21560 !! end
21561
21562
21563 !! test
21564 ISBN with multiple spaces, no number
21565 !! wikitext
21566 ISBN foo
21567 !! html
21568 <p>ISBN foo
21569 </p>
21570 !! end
21571
21572
21573 !! test
21574 ISBN length
21575 !! wikitext
21576 ISBN 123456789
21577
21578 ISBN 1234567890
21579
21580 ISBN 12345678901
21581 !! html/php
21582 <p>ISBN 123456789
21583 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21584 </p><p>ISBN 12345678901
21585 </p>
21586 !! html/parsoid
21587 <p>ISBN 123456789</p>
21588
21589 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21590
21591 <p>ISBN 12345678901</p>
21592 !! end
21593
21594
21595 !! test
21596 ISBN with trailing year (T9110)
21597 !! wikitext
21598 ISBN 1-234-56789-0 - 2006
21599
21600 ISBN 1 234 56789 0 - 2006
21601 !! html/php
21602 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
21603 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
21604 </p>
21605 !! html/parsoid
21606 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
21607
21608 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
21609 !! end
21610
21611
21612 !! test
21613 anchorencode
21614 !! config
21615 wgFragmentMode=[ 'html5', 'legacy' ]
21616 !! wikitext
21617 {{anchorencode:foo bar©#%n}}
21618 !! html/php
21619 <p>foo_bar©#%n
21620 </p>
21621 !! html/parsoid
21622 <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>
21623 !! end
21624
21625 !! test
21626 anchorencode (legacy)
21627 !! config
21628 wgFragmentMode=[ 'legacy' ]
21629 !! wikitext
21630 {{anchorencode:foo bar©#%n}}
21631 !! html/php
21632 <p>foo_bar.C2.A9.23.25n
21633 </p>
21634 !! end
21635
21636 !! test
21637 anchorencode trims spaces
21638 !! config
21639 wgFragmentMode=[ 'html5', 'legacy' ]
21640 !! wikitext
21641 {{anchorencode: __pretty__please__}}
21642 !! html/php
21643 <p>pretty_please
21644 </p>
21645 !! html/parsoid
21646 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
21647 !! end
21648
21649 !! test
21650 anchorencode deals with links
21651 !! config
21652 wgFragmentMode=[ 'html5', 'legacy' ]
21653 !! wikitext
21654 {{anchorencode: [[hello|world]] [[hi]]}}
21655 !! html/php
21656 <p>world_hi
21657 </p>
21658 !! html/parsoid
21659 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
21660 !! end
21661
21662 !! test
21663 anchorencode deals with templates
21664 !! config
21665 wgFragmentMode=[ 'html5', 'legacy' ]
21666 !! wikitext
21667 {{anchorencode: {{Foo}} x}}
21668 !! html/php
21669 <p>FOO_x
21670 </p>
21671 !! html/parsoid
21672 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
21673 !! end
21674
21675 !! test
21676 anchorencode encodes like the TOC generator: (T20431)
21677 !! config
21678 wgFragmentMode=[ 'html5', 'legacy' ]
21679 !! wikitext
21680 ===_ +:.3A%3A _ &&amp;]] x===
21681 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
21682 __NOEDITSECTION__
21683 !! html/php
21684 <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>
21685 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
21686 </p>
21687 !! html/parsoid
21688 <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>
21689 <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>
21690 <meta property="mw:PageProp/noeditsection"/>
21691 !! end
21692
21693 !! test
21694 anchorencode encodes like the TOC generator: (T20431) (legacy)
21695 !! config
21696 wgFragmentMode=[ 'legacy' ]
21697 !! wikitext
21698 ===_ +:.3A%3A&&amp;]]===
21699 {{anchorencode: _ +:.3A%3A&&amp;]] }}
21700 __NOEDITSECTION__
21701 !! html/php
21702 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
21703 <p>.2B:.3A.253A.26.26.5D.5D
21704 </p>
21705 !! end
21706
21707 !! test
21708 T8200: blockquotes and paragraph formatting
21709 !! wikitext
21710 <blockquote>
21711 foo
21712 </blockquote>
21713
21714 bar
21715
21716 baz
21717 !! html
21718 <blockquote>
21719 <p>foo
21720 </p>
21721 </blockquote>
21722 <p>bar
21723 </p>
21724 <pre>baz
21725 </pre>
21726 !! end
21727
21728 !! test
21729 T10293: Use of center tag ruins paragraph formatting
21730 !! wikitext
21731 <center>
21732 foo
21733 </center>
21734
21735 bar
21736
21737 baz
21738 !! html
21739 <center>
21740 <p>foo
21741 </p>
21742 </center>
21743 <p>bar
21744 </p>
21745 <pre>baz
21746 </pre>
21747 !! end
21748
21749 !!test
21750 Parsing of overlapping (improperly nested) inline html tags
21751 !! wikitext
21752 <span><s>x</span></s>
21753 !! html/php
21754 <p><span><s>x&lt;/span&gt;</s></span>
21755 </p>
21756 !! html/parsoid
21757 <p><span><s>x</s></span>
21758 </p>
21759 !!end
21760
21761 ###
21762 ### Language variants related tests
21763 ###
21764
21765 # Parsoid does not mark self-links.
21766 # Parsoid does not convert links; PHP will do any necessary redirects.
21767
21768 !! test
21769 Self-link in language variants
21770 !! options
21771 title=[[Dunav]] language=sr
21772 !! wikitext
21773 Both [[Dunav]] and [[Дунав]] are names for this river.
21774 !! html/php
21775 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
21776 </p>
21777 !! html/parsoid
21778 <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>
21779 !! end
21780
21781 !! article
21782 Дуна
21783 !! text
21784 content
21785 !! endarticle
21786
21787 !! test
21788 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
21789 !! options
21790 title=[[Duna]] language=sr
21791 !! wikitext
21792 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
21793 !! html/php
21794 <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.
21795 </p>
21796 !! html/parsoid
21797 <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>
21798 !! end
21799
21800 !! test
21801 Link to a section of a variant of this title shouldn't be parsed as self-link
21802 !! options
21803 title=[[Duna]] language=sr
21804 !! wikitext
21805 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
21806 !! html/php
21807 <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.
21808 </p>
21809 !! html/parsoid
21810 <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>
21811 !! end
21812
21813 !! test
21814 Link to pages in language variants
21815 !! options
21816 language=sr
21817 !! wikitext
21818 Main Page can be written as [[Маин Паге]]
21819 !! html/php
21820 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
21821 </p>
21822 !! html/parsoid
21823 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
21824 !! end
21825
21826
21827 !! test
21828 Multiple links to pages in language variants
21829 !! options
21830 language=sr
21831 !! wikitext
21832 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
21833 !! html/php
21834 <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>.
21835 </p>
21836 !! html/parsoid
21837 <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>
21838 !! end
21839
21840
21841 !! test
21842 Simple template in language variants
21843 !! options
21844 language=sr
21845 !! wikitext
21846 {{тест}}
21847 !! html/php
21848 <p>This is a test template
21849 </p>
21850 !! end
21851
21852
21853 !! test
21854 Template with explicit namespace in language variants
21855 !! options
21856 language=sr
21857 !! wikitext
21858 {{Template:тест}}
21859 !! html/php
21860 <p>This is a test template
21861 </p>
21862 !! end
21863
21864
21865 !! test
21866 Basic test for template parameter in language variants
21867 !! options
21868 language=sr
21869 !! wikitext
21870 {{парамтест|param=foo}}
21871 !! html/php
21872 <p>This is a test template with parameter foo
21873 </p>
21874 !! end
21875
21876 !! test
21877 Simple category in language variants
21878 !! options
21879 language=sr cat
21880 !! wikitext
21881 [[Category:МедиаWики Усер'с Гуиде]]
21882 !! html/php
21883 cat=МедиаWики_Усер'с_Гуиде sort=
21884 !! html/parsoid
21885 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
21886 !! end
21887
21888 !! article
21889 Category:分类
21890 !! text
21891 blah
21892 !! endarticle
21893
21894 !! article
21895 Category:分類
21896 !! text
21897 blah
21898 !! endarticle
21899
21900 ## We used to, but no longer wt2wt this test since the default serializer
21901 ## will normalize all categories to serialize on their own line.
21902 ## This wikitext usage is going to be fairly uncommon in production and
21903 ## selser will take care of preserving formatting in those scenarios.
21904 !! test
21905 Don't convert blue categorylinks to another variant (T35210)
21906 !! options
21907 cat
21908 language=zh
21909 parsoid=wt2html
21910 !! wikitext
21911 [[A]][[Category:分类]]
21912 !! html/php
21913 cat=分类 sort=
21914 !! html/parsoid
21915 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
21916 <link rel="mw:PageProp/Category" href="./Category:分类"/>
21917 !! end
21918
21919 !! test
21920 Stripping -{}- tags (language variants)
21921 !! options
21922 language=sr
21923 !! wikitext
21924 Latin proverb: -{Ne nuntium necare}-
21925 !! html/php
21926 <p>Latin proverb: Ne nuntium necare
21927 </p>
21928 !! html/parsoid
21929 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21930 !! end
21931
21932
21933 !! test
21934 Prevent conversion with -{}- tags (language variants)
21935 !! options
21936 language=sr variant=sr-ec
21937 !! wikitext
21938 Latinski: -{Ne nuntium necare}-
21939 !! html/php
21940 <p>Латински: Ne nuntium necare
21941 </p>
21942 !! html/parsoid
21943 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21944 !! end
21945
21946
21947 !! test
21948 Prevent conversion of text with -{}- tags (language variants)
21949 !! options
21950 language=sr variant=sr-ec
21951 !! wikitext
21952 Latinski: -{Ne nuntium necare}-
21953 !! html/php
21954 <p>Латински: Ne nuntium necare
21955 </p>
21956 !! html/parsoid
21957 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21958 !! end
21959
21960
21961 !! test
21962 Prevent conversion of links with -{}- tags (language variants)
21963 !! options
21964 language=sr variant=sr-ec
21965 !! wikitext
21966 -{[[Main Page]]}-
21967 !! html/php
21968 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21969 </p>
21970 !! html/parsoid
21971 <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>
21972 !! end
21973
21974
21975 !! test
21976 -{}- tags within headlines (within html for parserConvert())
21977 !! config
21978 wgFragmentMode=[ 'html5', 'legacy' ]
21979 !! options
21980 language=sr variant=sr-ec
21981 !! wikitext
21982 ==-{Naslov}-==
21983
21984 Note that even an unprotected headline ID is not affected by language
21985 conversion:
21986
21987 ==Latinski==
21988 !! html/php
21989 <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>
21990 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
21991 цонверсион:
21992 </p>
21993 <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>
21994
21995 !! html/parsoid
21996 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
21997
21998 <p>Note that even an unprotected headline ID is not affected by language
21999 conversion:</p>
22000
22001 <h2 id="Latinski">Latinski</h2>
22002 !! end
22003
22004 !! test
22005 Explicit definition of language variant alternatives
22006 !! options
22007 language=zh variant=zh-tw
22008 !! wikitext
22009 -{zh:China;zh-tw:Taiwan}-, not China
22010 !! html/php
22011 <p>Taiwan, not China
22012 </p>
22013 !! html/parsoid
22014 <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>
22015 !! end
22016
22017 !! test
22018 Filter syntax for language variants
22019 !! options
22020 language=zh variant=zh-tw
22021 !! wikitext
22022 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
22023 !! html/php
22024 <p>fooblog, WEBJOURNAL, WEBLOGquux
22025 </p>
22026 !! html/parsoid
22027 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
22028 !! end
22029
22030 # Note that Parsoid post-processing for language variants needs to
22031 # update the `title` attribute here, based on the mw:ExpandedAttrs property
22032 !! test
22033 Conversion around HTML tags
22034 !! options
22035 language=sr variant=sr-ec
22036 !! wikitext
22037 -{H|span=>sr-ec:script;title=>sr-ec:src}-
22038 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
22039 !! html/php
22040 <p>
22041 <span title="ЛаCтин">ски</span>
22042 </p>
22043 !! html/parsoid
22044 <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"}]}'/>
22045 <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>
22046 !! end
22047
22048 !! test
22049 Explicit session-wise two-way language variant mapping (A flag and - flag)
22050 !! options
22051 language=zh variant=zh-tw
22052 !! wikitext
22053 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
22054
22055 Taiwan is not China.
22056
22057 But -{A|zh:China; zh-tw:Taiwan}- is China,
22058
22059 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
22060
22061 and -{China}- is China.
22062 !! html/php
22063 <p>This is Taiwan, but we'll forget that now.
22064 </p><p>Taiwan is not China.
22065 </p><p>But Taiwan is Taiwan,
22066 </p><p>(This should be stripped!)
22067 </p><p>and China is China.
22068 </p>
22069 !! html/parsoid
22070 <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>
22071 <p>Taiwan is not China.</p>
22072 <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>
22073 <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>
22074 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
22075 !! end
22076
22077 !! test
22078 Explicit session-wise one-way language variant mapping (A flag and - flag)
22079 !! options
22080 language=zh variant=zh-tw
22081 !! wikitext
22082 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
22083
22084 COUNTRY is China or Taiwan.
22085
22086 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
22087
22088 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22089
22090 and -{COUNTRY}- is COUNTRY.
22091 !! html/php
22092 <p>This is Taiwan, but we'll forget that now.
22093 </p><p>COUNTRY is China or Taiwan.
22094 </p><p>But Taiwan is Taiwan,
22095 </p><p>(This should be stripped!)
22096 </p><p>and COUNTRY is COUNTRY.
22097 </p>
22098 !! html/parsoid
22099 <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>
22100 <p>COUNTRY is China or Taiwan.</p>
22101 <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>
22102 <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>
22103 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
22104 !! end
22105
22106 !! test
22107 Explicit session-wise two-way language variant mapping (H flag for hide)
22108 !! options
22109 language=zh variant=zh-tw
22110 !! wikitext
22111 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
22112
22113 Taiwan is China.
22114 !! html/php
22115 <p>(This should be stripped!)
22116 </p><p>Taiwan is Taiwan.
22117 </p>
22118 !! html/parsoid
22119 <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>
22120 <p>Taiwan is China.</p>
22121 !! end
22122
22123 !! test
22124 Explicit session-wise one-way language variant mapping (H flag for hide)
22125 !! options
22126 language=zh variant=zh-tw
22127 !! wikitext
22128 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22129
22130 COUNTRY is Taiwan or China.
22131 !! html/php
22132 <p>(This should be stripped!)
22133 </p><p>Taiwan is Taiwan or China.
22134 </p>
22135 !! html/parsoid
22136 <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>
22137 <p>COUNTRY is Taiwan or China.</p>
22138 !! end
22139
22140 ## Note that parsoid test runner does not support 'showtitle' option.
22141 !! test
22142 Adding explicit conversion rule for title (T flag)
22143 !! options
22144 language=zh variant=zh-tw showtitle
22145 !! wikitext
22146 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
22147
22148 Taiwan is China.
22149 !! html/php
22150 Taiwan
22151 <p>Should be stripped!
22152 </p><p>Taiwan is China.
22153 </p>
22154 !! html/parsoid
22155 <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>
22156 <p>Taiwan is China.</p>
22157 !! end
22158
22159 !! test
22160 Code coverage: T combined with H flag
22161 !! options
22162 language=zh variant=zh-tw showtitle
22163 !! wikitext
22164 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
22165
22166 Taiwan is China.
22167 !! html/php
22168 Taiwan
22169 <p>Should be stripped!
22170 </p><p>Taiwan is Taiwan.
22171 </p>
22172 !! html/parsoid
22173 <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>
22174 <p>Taiwan is China.</p>
22175 !! end
22176
22177 !! test
22178 Code coverage: T with no variants
22179 !! options
22180 language=zh variant=zh-tw showtitle
22181 !! wikitext
22182 -{H|zh:China; zh-tw:Taiwan}-
22183 Taiwan is China.-{T|Taiwan is China}-
22184 !! html/php
22185 Taiwan is China
22186 <p>
22187 Taiwan is Taiwan.
22188 </p>
22189 !! html/parsoid
22190 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22191 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
22192 !! end
22193
22194 !! test
22195 Code coverage: rules with no variants
22196 !! options
22197 language=zh variant=zh-tw
22198 !! wikitext
22199 -{H|zh:China; zh-tw:Taiwan}-
22200 Taiwan is China.
22201 -{H|China}-
22202 Taiwan is China.
22203 !! html/php
22204 <p>
22205 Taiwan is Taiwan.
22206
22207 Taiwan is China.
22208 </p>
22209 !! html/parsoid
22210 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22211 Taiwan is China.
22212 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
22213 Taiwan is China.</p>
22214 !! end
22215
22216
22217 !! test
22218 Code coverage: D flag for conversion rule
22219 !! options
22220 language=zh variant=zh-tw
22221 !! wikitext
22222 -{D|zh-cn:XA; zh-tw:YA}-
22223 -{A;D|zh-cn:XB; zh-tw:YB}-
22224 -{D;H|zh-cn:XC; zh-tw:YC}-
22225
22226 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
22227
22228 -{D|0=>zh-tw:1}-
22229 -{A;D|2=>zh-tw:3}-
22230 -{D;H|4=>zh-tw:5}-
22231
22232 XA XB XC YA YB YC FOO BAR BAT 012345
22233 !! html/php
22234 <p>大陆:XA;台灣:YA;
22235
22236 大陆:XC;台灣:YC;
22237 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
22238 </p><p>0⇒台灣:1;
22239
22240 4⇒台灣:5;
22241 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
22242 </p>
22243 !! html/parsoid
22244 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
22245 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
22246 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
22247 <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>
22248 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
22249 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
22250 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
22251 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
22252 !! end
22253
22254 !! test
22255 Code coverage: N flag for conversion rule
22256 !! options
22257 language=zh variant=zh-cn
22258 !! wikitext
22259 -{N|zh-cn}-
22260
22261 -{N|zh-tw}-
22262
22263 -{N|sr-ec}-
22264 !! html/php
22265 <p>大陆
22266 </p><p>台灣
22267 </p><p>српски (ћирилица)‎
22268 </p>
22269 !! html/parsoid
22270 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
22271 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
22272 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
22273 !! end
22274
22275 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
22276 !! test
22277 Code coverage: N flag for conversion rule (wt2html only)
22278 !! options
22279 language=zh variant=zh-cn
22280 parsoid=wt2html,html2html
22281 !! wikitext
22282 -{D;N|en}-
22283 !! html/php
22284 <p>English
22285 </p>
22286 !! html/parsoid
22287 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
22288 !! end
22289
22290 !! test
22291 Testing that changing the language variant here in the tests actually works
22292 !! options
22293 language=zh variant=zh showtitle
22294 !! wikitext
22295 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22296 !! html/php
22297 China
22298 <p>Should be stripped!
22299 </p>
22300 !! html/parsoid
22301 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
22302 !! end
22303
22304 !! test
22305 Recursive conversion of alt and title attrs shouldn't clear converter state
22306 !! options
22307 language=zh variant=zh-cn
22308 showtitle
22309 !! wikitext
22310 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
22311 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
22312 !! html/php
22313 China
22314 <p>
22315 Should be stripped<span title="Exclamation">!</span>
22316 </p>
22317 !! html/parsoid
22318 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
22319 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>
22320 !! end
22321
22322 !! test
22323 T26072: more test on conversion rule for title
22324 !! options
22325 language=zh variant=zh-tw showtitle
22326 !! wikitext
22327 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22328
22329 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
22330 !! html/php
22331 Taiwan
22332 <p>This should be stripped!
22333 </p><p>This won't take interferes with the title rule.
22334 </p>
22335 !! html/parsoid
22336 <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>
22337 <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>
22338 !! end
22339
22340 !! test
22341 Partly disable title conversion if variant == main language code
22342 !! options
22343 language=zh variant=zh title=[[ZH]] showtitle
22344 !! wikitext
22345 -{T|zh-cn:CN;zh-tw:TW}-
22346 !! html/php
22347 ZH
22348 <p>
22349 </p>
22350 !! html/parsoid
22351 <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>
22352 !! end
22353
22354 !! test
22355 Partly disable title conversion if variant == main language code, more
22356 !! options
22357 language=zh variant=zh title=[[ZH]] showtitle
22358 !! wikitext
22359 -{T|TW}-
22360 !! html/php
22361 ZH
22362 <p>
22363 </p>
22364 !! html/parsoid
22365 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
22366 !! end
22367
22368 !! test
22369 Raw output of variant escape tags (R flag)
22370 !! options
22371 language=zh variant=zh-tw
22372 !! wikitext
22373 Raw: -{R|zh:China;zh-tw:Taiwan}-
22374 !! html/php
22375 <p>Raw: zh:China;zh-tw:Taiwan
22376 </p>
22377 !! html/parsoid
22378 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
22379 !! end
22380
22381 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
22382 !! test
22383 Raw output of variant escape tags (R flag) (wt2html only)
22384 !! options
22385 language=zh variant=zh-tw
22386 parsoid=wt2html,html2html
22387 !! wikitext
22388 -{Variant}- -{D|syntax}- -{D;R|options}-
22389 !! html/php
22390 <p>Variant syntax options
22391 </p>
22392 !! html/parsoid
22393 <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>
22394 !! end
22395
22396 !! test
22397 Nested markup inside raw output of variant escape tags (R flag)
22398 !! options
22399 language=zh variant=zh-tw
22400 !! wikitext
22401 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
22402 !! html/php
22403 <p>Nested raw: nested Taiwan nested
22404 </p>
22405 !! html/parsoid
22406 <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>
22407 !! end
22408
22409 !! test
22410 Nested markup and spaces inside raw output of variant escape tags (R flag)
22411 !! options
22412 language=zh variant=zh-tw
22413 !! wikitext
22414 X-{ outer -{ inner }- outer }-X
22415 !! html/php
22416 <p>X outer inner outer X
22417 </p>
22418 !! html/parsoid
22419 <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>
22420 !! end
22421
22422 !! test
22423 Templates inside raw output of variant escape tags (R flag)
22424 !! options
22425 language=zh variant=zh-tw
22426 !! wikitext
22427 Nested raw: -{R|nested {{echo|hi}} templates}-
22428 !! html/php
22429 <p>Nested raw: nested hi templates
22430 </p>
22431 !! html/parsoid
22432 <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>
22433 !! end
22434
22435 !! test
22436 Strings evaluating false shouldn't be ignored by Language converter (T51072)
22437 !! options
22438 language=zh variant=zh-cn
22439 !! wikitext
22440 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
22441 !! html/php
22442 <p>0
22443 </p>
22444 !! html/parsoid
22445 <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>
22446 !! end
22447
22448 !! test
22449 Conversion rules from [numeric-only string] to [something else] (T48634)
22450 !! options
22451 language=zh variant=zh-cn
22452 !! wikitext
22453 -{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
22454 !! html/php
22455 <p>D12345EE12345
22456 </p>
22457 !! html/parsoid
22458 <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>
22459 !! end
22460
22461 !! test
22462 Two-way converter rule entries with an empty value should be ignored (T53551)
22463 !! options
22464 language=zh variant=zh-cn
22465 !! wikitext
22466 -{H|zh-cn:foo;zh-tw:;}-foobar
22467 !! html/php
22468 <p>foobar
22469 </p>
22470 !! html/parsoid
22471 <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>
22472 !! end
22473
22474 !! test
22475 One-way converter rule entries with an empty "from" string should be ignored (T53551)
22476 !! options
22477 language=zh variant=zh-cn
22478 !! wikitext
22479 -{H|=>zh-cn:foo;}-foobar
22480 !! html/php
22481 <p>foobar
22482 </p>
22483 !! html/parsoid
22484 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
22485 !! end
22486
22487 !! test
22488 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
22489 !! options
22490 language=zh variant=zh-cn
22491 !! wikitext
22492 -{H|}-foobar
22493 !! html/php
22494 <p>foobar
22495 </p>
22496 !! html/parsoid
22497 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
22498 !! end
22499
22500 !! test
22501 Nested using of manual convert syntax
22502 !! options
22503 language=zh variant=zh-hk
22504 !! wikitext
22505 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
22506 !! html/php
22507 <p>Nested: Hello Hong Kong!
22508 </p>
22509 !! html/parsoid
22510 <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>
22511 !! end
22512
22513 !! test
22514 HTML markups with conversion syntax in attribs, nested in other conversion blocks
22515 !! options
22516 language=zh variant=zh-cn
22517 !! wikitext
22518 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
22519 !! html/php
22520 <p><span title="X">A</span>
22521 </p>
22522 !! html/parsoid
22523 <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>
22524 !! end
22525
22526 !! test
22527 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
22528 !! options
22529 language=zh variant=zh-cn
22530 !! wikitext
22531 -{<span title="-{X}-">A</span>}-
22532 !! html/php+disabled
22533 <p><span title="X">A</span>
22534 </p>
22535 !! html/parsoid
22536 <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>
22537 !! end
22538
22539 # Parsoid and PHP disagree on how to parse this example: Parsoid
22540 # insists that the content of a language converter element be a valid
22541 # DOM fragment or attribute string
22542 !! test
22543 Language converter markup with block content
22544 !! options
22545 language=zh variant=zh-cn
22546 !! wikitext
22547 <span>a-{b<div>c}-d
22548
22549 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
22550
22551 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
22552 !! html/php+tidy
22553 <span>ab<div>cd
22554 <span>ab<div>cd
22555 <span>ad
22556 </span></div></span></div></span>
22557 !! html/parsoid
22558 <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>
22559
22560 <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>
22561
22562 <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>
22563 !! end
22564
22565 !! test
22566 LanguageConverter selser (1)
22567 !! options
22568 language=zh variant=zh-cn
22569 parsoid={
22570 "modes": ["wt2wt", "selser"],
22571 "changes": [
22572 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22573 ]
22574 }
22575 !! wikitext
22576 -{raw}-
22577 !! wikitext/edited
22578 -{edited}-
22579 !! end
22580
22581 !! test
22582 LanguageConverter selser (2)
22583 !! options
22584 language=zh variant=zh-cn
22585 parsoid={
22586 "modes": ["wt2wt", "selser"],
22587 "changes": [
22588 ["span[class='x']", "contents", "text", "-{foo}-"],
22589 ["a", "contents", "text", "-{"],
22590 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
22591 ]
22592 }
22593 !! wikitext
22594 <span class="x">TEXT1</span>
22595 [http://example.com TEXT2]
22596 [[Foo|TEXT3]]
22597 {{echo|TEXT4}}
22598 !! wikitext/edited
22599 <span class="x"><nowiki>-{foo}-</nowiki></span>
22600 [http://example.com -{]
22601 [[Foo|<nowiki>-{</nowiki>]]
22602 {{1x|<nowiki>-{</nowiki>}}
22603 !! end
22604
22605 # Tests LanguageVariantText in ConstrainedText
22606 !! test
22607 LanguageConverter selser (3)
22608 !! options
22609 language=zh variant=zh-cn
22610 parsoid={
22611 "modes": ["wt2wt", "selser"],
22612 "changes": [
22613 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
22614 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22615 ]
22616 }
22617 !! wikitext
22618 {|
22619 |-
22620 |<span>Foo</span>
22621 |}
22622 !! wikitext/edited
22623 {|
22624 |-
22625 |<nowiki/>-{edited}-
22626 |}
22627 !! end
22628
22629 # Tests LanguageVariantText._fromSelSer
22630 !! test
22631 LanguageConverter selser (4)
22632 !! options
22633 language=zh variant=zh-cn
22634 parsoid={
22635 "modes": ["wt2wt", "selser"],
22636 "changes": [
22637 ["td > span.x", "remove"]
22638 ]
22639 }
22640 !! wikitext
22641 {|
22642 |-
22643 |<span class="x">Foo</span>-{Bar}-
22644 ||<span class="x">Foo</span>-{Bar}-
22645 |}
22646 !! wikitext/edited
22647 {|
22648 |-
22649 |<nowiki/>-{Bar}-
22650 ||-{Bar}-
22651 |}
22652 !! end
22653
22654 # Since Parsoid is starting to emit canonical wikitext for links,
22655 # [http://example.com http://example.com] will not RT back to that
22656 # form anymore.
22657 # Parsoid does not language-convert links (it is done in a
22658 # post-processing step)
22659 !! test
22660 Proper conversion of text in external links
22661 !! options
22662 language=sr variant=sr-ec
22663 parsoid=wt2html
22664 !! wikitext
22665 http://www.google.com
22666 gopher://www.google.com
22667 [http://www.google.com http://www.google.com]
22668 [gopher://www.google.com gopher://www.google.com]
22669 [https://www.google.com irc://www.google.com]
22670 [ftp://www.google.com www.google.com/ftp://dir]
22671 [//www.google.com www.google.com]
22672 !! html/php
22673 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22674 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22675 <a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a>
22676 <a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
22677 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
22678 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
22679 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
22680 </p>
22681 !! html/parsoid
22682 <p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
22683 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22684 <a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
22685 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22686 <a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a>
22687 <a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a>
22688 <a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p>
22689 !! end
22690
22691 !! test
22692 Do not convert roman numbers to language variants
22693 !! options
22694 language=sr variant=sr-ec
22695 !! wikitext
22696 Fridrih IV je car.
22697 !! html/php
22698 <p>Фридрих IV је цар.
22699 </p>
22700 !! html/parsoid
22701 <p>Fridrih IV je car.</p>
22702 !! end
22703
22704 !! test
22705 Unclosed language converter markup "-{"
22706 !! options
22707 language=sr
22708 !! wikitext
22709 -{T|hello
22710 !! html
22711 <p>-{T|hello
22712 </p>
22713 !! end
22714
22715 !! test
22716 Don't convert raw rule "-{R|=&gt;}-" to "=>"
22717 !! options
22718 language=sr
22719 !! wikitext
22720 -{R|=&gt;}-
22721 !! html/php
22722 <p>=&gt;
22723 </p>
22724 !! html/parsoid
22725 <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>
22726 !!end
22727
22728 !! test
22729 Don't break link parsing if language converter markup is in the caption.
22730 !! options
22731 language=sr variant=sr-ec
22732 !! wikitext
22733 [[Main Page|-{R|main page}-]]
22734 !! html/php
22735 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
22736 </p>
22737 !! html/parsoid
22738 <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>
22739 !! end
22740
22741 !! test
22742 T146304: Don't break template parsing if language converter markup is in the parameter.
22743 !! options
22744 language=sr variant=sr-ec
22745 !! wikitext
22746 {{echo|-{R|foo}-}}
22747 !! html/php
22748 <p>foo
22749 </p>
22750 !! html/parsoid
22751 <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>
22752 !! end
22753
22754 !! test
22755 T146305: Don't break image parsing if language converter markup is in the caption.
22756 !! options
22757 language=sr
22758 !! wikitext
22759 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
22760 !! html/php
22761 <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>
22762
22763 !! html/parsoid
22764 <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>
22765 !! end
22766
22767 !! test
22768 T146305: Don't break image parsing if nested language converter markup is in the caption.
22769 !! options
22770 language=zh variant=zh-cn
22771 !! wikitext
22772 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
22773 !! html/php
22774 <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>
22775
22776 !! html/parsoid
22777 <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>
22778 !! end
22779
22780 # XXX html2wt disabled because rich markup in alt is not preserved.
22781 !! test
22782 Don't break gallery if language converter markup is inside.
22783 !! options
22784 language=zh
22785 !! wikitext
22786 <gallery>
22787 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
22788 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
22789 </gallery>
22790 !! html/php
22791 <ul class="gallery mw-gallery-traditional">
22792 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22793 <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>
22794 <div class="gallerytext">
22795 <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>
22796 </p>
22797 </div>
22798 </div></li>
22799 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22800 <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>
22801 <div class="gallerytext">
22802 <p>This is a test template
22803 </p>
22804 </div>
22805 </div></li>
22806 </ul>
22807
22808 !! html/parsoid
22809 <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"}}'>
22810 <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>
22811 <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>
22812 </ul>
22813 !! end
22814
22815 !! test
22816 T153135: Don't break list handling if language converter markup is in the item.
22817 !! options
22818 language=zh variant=zh-cn
22819 !! wikitext
22820 ;-{zh-cn:AAA;zh-tw:BBB}-
22821 ;-{R|foo:bar}-
22822 !! html/php
22823 <dl><dt>AAA</dt>
22824 <dt>foo:bar</dt></dl>
22825
22826 !! html/parsoid
22827 <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>
22828 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
22829 </dl>
22830 !! end
22831
22832 // Note that parsoid does not protect colons unless language converter
22833 // markup is properly nested, because it is a backtracking parser.
22834 !! test
22835 T153135: Unclosed markup in definition list (code coverage)
22836 !! options
22837 language=zh variant=zh-cn
22838 !! wikitext
22839 ;<b>foo:bar
22840 ;-{zh-cn:AAA
22841 !! html/php+tidy
22842 <dl><dt><b>foo:bar</b></dt><b>
22843 <dt>-{zh-cn:AAA</dt></b></dl><p><b>
22844 </b></p>
22845 !! html/parsoid
22846 <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}'>
22847 <dt data-parsoid='{"dsr":[12,20,1,0]}'>-{zh-cn</dt>
22848 <dd data-parsoid='{"stx":"row","dsr":[20,24,1,0]}'>AAA</dd>
22849 </b></dl>
22850 !! end
22851
22852 !! test
22853 T153135: Nested language converter markup in definition list (code coverage)
22854 !! options
22855 language=zh variant=zh-cn
22856 !! wikitext
22857 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
22858 !! html/php
22859 <dl><dt>AAA foo:bar bat:baz</dt>
22860 <dd>def</dd></dl>
22861
22862 !! html/parsoid
22863 <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>
22864 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
22865 </dl>
22866 !! end
22867
22868 # html2wt mode disabled due to <nowiki> insertion.
22869 !! test
22870 T153140: Don't break table handling if language converter markup is in the cell.
22871 !! options
22872 language=sr variant=sr-ec
22873 parsoid=wt2html,wt2wt,html2html
22874 !! wikitext
22875 {|
22876 |-
22877 | -{R|B}-
22878 |}
22879 !! html/php
22880 <table>
22881
22882 <tr>
22883 <td>B
22884 </td></tr></table>
22885
22886 !! html/parsoid
22887 <table>
22888 <tbody>
22889 <tr>
22890 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
22891 </tr>
22892 </tbody>
22893 </table>
22894 !! end
22895
22896 !! test
22897 Language converter tricky html2wt cases (1)
22898 !! options
22899 language=sr
22900 parsoid=html2wt,wt2wt
22901 !! html/parsoid
22902 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
22903 !! wikitext
22904 -{<nowiki>}-</nowiki>}-
22905 !! html/php
22906 <p>&#125;-
22907 </p>
22908 !! end
22909
22910 !! test
22911 Language converter tricky html2wt cases (2)
22912 !! options
22913 language=sr
22914 parsoid=html2wt,wt2wt
22915 !! html/parsoid
22916 <p>-{foo}-</p>
22917 !! wikitext
22918 <nowiki>-{foo}-</nowiki>
22919 !! html/php
22920 <p>-&#123;foo&#125;-
22921 </p>
22922 !! end
22923
22924 !! test
22925 Language converter tricky html2wt cases (3)
22926 !! options
22927 language=sr
22928 parsoid=html2wt,wt2wt
22929 !! html/parsoid
22930 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
22931 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
22932 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
22933 !! wikitext
22934 -{R||}-
22935
22936 -{R|R|raw}-
22937
22938 -{<nowiki>-{foo}-</nowiki>}-
22939 !! html/php
22940 <p>|
22941 </p><p>R|raw
22942 </p><p>-&#123;foo&#125;-
22943 </p>
22944 !! end
22945
22946 !! test
22947 Language converter tricky html2wt cases (4)
22948 !! options
22949 language=sr
22950 parsoid=html2wt,wt2wt
22951 !! html/parsoid
22952 <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>
22953 !! wikitext
22954 -{R|{{echo|hey}}}-
22955 !! html/php
22956 <p>hey
22957 </p>
22958 !! end
22959
22960 # Note that the <nowiki> escaping added by parsoid for source text,
22961 # destination text, and language names only works on the PHP side
22962 # for *destination text*. (HTML entity escaping wouldn't work
22963 # any better.) This is probably a bug, at least for source texts.
22964 # (For language names PHP uses a precise regexp based on the languages
22965 # it currently knows have variants, which is fragile since this set
22966 # can grow/shrink over time.)
22967 !! test
22968 Language converter tricky html2wt cases (5)
22969 !! options
22970 language=zh variant=zh-cn
22971 !! html/parsoid
22972 <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>
22973 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
22974 <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>
22975 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
22976 <p>a:b=>c xyz</p>
22977 !! wikitext
22978 -{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
22979
22980 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
22981
22982 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
22983
22984 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
22985
22986 a:b=>c xyz
22987 !! html/php+disabled
22988 <p>foobat;xyz=&gt;zh-cn:abc
22989 </p><p>A
22990 </p><p>0;zh-tw:bar
22991 </p><p>abc
22992 </p><p>a:b=&gt;c 0;zh-tw:bar
22993 </p>
22994 !! end
22995
22996 !! test
22997 T179579: Nowiki and lc interaction
22998 !! options
22999 parsoid=wt2html
23000 language=sr
23001 !! wikitext
23002 -{</nowiki>123}-
23003
23004 -{123<nowiki>|</nowiki>456}-
23005 !! html/parsoid
23006 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
23007
23008 <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>
23009 !! end
23010
23011 !! test
23012 T2529: Uncovered bullet
23013 !! wikitext
23014 *Foo {{bullet}}
23015 !! html
23016 <ul><li>Foo</li>
23017 <li>Bar</li></ul>
23018
23019 !! end
23020
23021 !! test
23022 T2529: Uncovered bullet in a deeply nested list
23023 !! wikitext
23024 *******Foo {{bullet}}
23025 !! html
23026 <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>
23027 <li>Bar</li></ul>
23028
23029 !! end
23030
23031 !! test
23032 T2529: Uncovered table already at line-start
23033 !! wikitext
23034 x
23035
23036 {{table}}
23037 y
23038 !! html
23039 <p>x
23040 </p>
23041 <table>
23042 <tr>
23043 <td>1</td>
23044 <td>2
23045 </td></tr>
23046 <tr>
23047 <td>3</td>
23048 <td>4
23049 </td></tr></table>
23050 <p>y
23051 </p>
23052 !! end
23053
23054 !! test
23055 T2529: Uncovered bullet in parser function result
23056 !! wikitext
23057 *Foo {{lc:{{bullet}} }}
23058 !! html
23059 <ul><li>Foo</li>
23060 <li>bar</li></ul>
23061
23062 !! end
23063
23064 !! test
23065 T7678: Double-parsed template argument
23066 !! wikitext
23067 {{lc:{{{1}}}|hello}}
23068 !! html
23069 <p>{{{1}}}
23070 </p>
23071 !! end
23072
23073 !! test
23074 T7678: Double-parsed template invocation
23075 !! wikitext
23076 {{lc:{{paramtest {{!}} param = hello }} }}
23077 !! html
23078 <p>{{paramtest | param = hello }}
23079 </p>
23080 !! end
23081
23082 !! test
23083 Case insensitivity of parser functions for non-ASCII characters (T10143)
23084 !! options
23085 language=cs
23086 title=[[Main Page]]
23087 !! wikitext
23088 {{PRVNÍVELKÉ:ěščř}}
23089 {{prvnívelké:ěščř}}
23090 {{PRVNÍMALÉ:ěščř}}
23091 {{prvnímalé:ěščř}}
23092 {{MALÁ:ěščř}}
23093 {{malá:ěščř}}
23094 {{VELKÁ:ěščř}}
23095 {{velká:ěščř}}
23096 !! html
23097 <p>Ěščř
23098 Ěščř
23099 ěščř
23100 ěščř
23101 ěščř
23102 ěščř
23103 ĚŠČŘ
23104 ĚŠČŘ
23105 </p>
23106 !! end
23107
23108 !! test
23109 Morwen/13: Unclosed link followed by heading
23110 !! wikitext
23111 [[link
23112 ==heading==
23113 !! html
23114 <p>[[link
23115 </p>
23116 <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>
23117
23118 !! end
23119
23120 !! test
23121 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
23122 !! wikitext
23123 {{foo|
23124 =heading=
23125 !! html
23126 <p>{{foo|
23127 </p>
23128 <h1><span class="mw-headline" id="heading">heading</span></h1>
23129
23130 !! end
23131
23132 !! test
23133 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
23134 !! wikitext
23135 {{foo|
23136 ==heading==
23137 !! html
23138 <p>{{foo|
23139 </p>
23140 <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>
23141
23142 !! end
23143
23144 !! test
23145 Tildes in comments
23146 !! options
23147 pst
23148 !! wikitext
23149 <!-- ~~~~ -->
23150 !! html/php
23151 <!-- ~~~~ -->
23152 !! end
23153
23154 !! test
23155 Paragraphs inside divs (no extra line breaks)
23156 !! wikitext
23157 <div>Line one
23158
23159 Line two</div>
23160 !! html
23161 <div>Line one
23162 Line two</div>
23163
23164 !! end
23165
23166 !! test
23167 Paragraphs inside divs (extra line break on open)
23168 !! wikitext
23169 <div>
23170 Line one
23171
23172 Line two</div>
23173 !! html
23174 <div>
23175 <p>Line one
23176 </p>
23177 Line two</div>
23178
23179 !! end
23180
23181 !! test
23182 Paragraphs inside divs (extra line break on close)
23183 !! wikitext
23184 <div>Line one
23185
23186 Line two
23187 </div>
23188 !! html
23189 <div>Line one
23190 <p>Line two
23191 </p>
23192 </div>
23193
23194 !! end
23195
23196 !! test
23197 Paragraphs inside divs (extra line break on open and close)
23198 !! wikitext
23199 <div>
23200 Line one
23201
23202 Line two
23203 </div>
23204 !! html
23205 <div>
23206 <p>Line one
23207 </p><p>Line two
23208 </p>
23209 </div>
23210
23211 !! end
23212
23213 # doBlockLevels screws up this output and Remex cleans up as much as it can.
23214 # Parsoid seems to do a better job here since its p-wrapper is probably smarter.
23215 !! test
23216 Nesting tags, paragraphs on lines which begin with <div>
23217 !! wikitext
23218 <div></div><strong>A
23219 B</strong>
23220 !! html/php+tidy
23221 <div></div><p><strong>A
23222 </strong></p><strong></strong><p><strong>B</strong>
23223 </p>
23224 !! html/parsoid
23225 <div></div>
23226 <p><strong>A
23227 B</strong>
23228 </p>
23229 !! end
23230
23231 # T8200: <blockquote> should behave like <div> with respect to line breaks
23232 !! test
23233 T8200: paragraphs inside blockquotes (no extra line breaks)
23234 !! wikitext
23235 <blockquote>Line one
23236
23237 Line two</blockquote>
23238 !! html
23239 <blockquote>Line one
23240 Line two</blockquote>
23241
23242 !! html+tidy
23243 <blockquote><p>Line one
23244 Line two</p></blockquote>
23245 !! end
23246
23247 !! test
23248 T8200: paragraphs inside blockquotes (extra line break on open)
23249 !! wikitext
23250 <blockquote>
23251 Line one
23252
23253 Line two</blockquote>
23254 !! html
23255 <blockquote>
23256 <p>Line one
23257 </p>
23258 Line two</blockquote>
23259
23260 !! html+tidy
23261 <blockquote>
23262 <p>Line one
23263 </p><p>
23264 Line two</p></blockquote>
23265 !! end
23266
23267 # Parsoid's output is broken on this because of Tidy-compatibility cruft
23268 !! test
23269 T8200: paragraphs inside blockquotes (extra line break on close)
23270 !! wikitext
23271 <blockquote>Line one
23272
23273 Line two
23274 </blockquote>
23275 !! html
23276 <blockquote>Line one
23277 <p>Line two
23278 </p>
23279 </blockquote>
23280
23281 !! html+tidy
23282 <blockquote><p>Line one
23283 </p><p>Line two
23284 </p>
23285 </blockquote>
23286 !! end
23287
23288 !! test
23289 T8200: paragraphs inside blockquotes (extra line break on open and close)
23290 !! wikitext
23291 <blockquote>
23292 Line one
23293
23294 Line two
23295 </blockquote>
23296 !! html
23297 <blockquote>
23298 <p>Line one
23299 </p><p>Line two
23300 </p>
23301 </blockquote>
23302
23303 !! end
23304
23305 # FIXME: Why does/should the blockquote+div combo suppress p-wrapping here?
23306 !! test
23307 Paragraphs inside blockquotes/divs (no extra line breaks)
23308 !! wikitext
23309 <blockquote><div>Line one
23310
23311 Line two</div></blockquote>
23312 !! html
23313 <blockquote><div>Line one
23314 Line two</div></blockquote>
23315
23316 !! end
23317
23318 !! test
23319 Paragraphs inside blockquotes/divs (extra line break on open)
23320 !! wikitext
23321 <blockquote><div>
23322 Line one
23323
23324 Line two</div></blockquote>
23325 !! html
23326 <blockquote><div>
23327 <p>Line one
23328 </p>
23329 Line two</div></blockquote>
23330
23331 !! end
23332
23333 !! test
23334 Paragraphs inside blockquotes/divs (extra line break on close)
23335 !! wikitext
23336 <blockquote><div>Line one
23337
23338 Line two
23339 </div></blockquote>
23340 !! html
23341 <blockquote><div>Line one
23342 <p>Line two
23343 </p>
23344 </div></blockquote>
23345
23346 !! end
23347
23348 !! test
23349 Paragraphs inside blockquotes/divs (extra line break on open and close)
23350 !! wikitext
23351 <blockquote><div>
23352 Line one
23353
23354 Line two
23355 </div></blockquote>
23356 !! html
23357 <blockquote><div>
23358 <p>Line one
23359 </p><p>Line two
23360 </p>
23361 </div></blockquote>
23362
23363 !! end
23364
23365 !! test
23366 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
23367 !! options
23368 wgLinkHolderBatchSize=0
23369 !! wikitext
23370 [[meatball:1]]
23371 [[meatball:2]]
23372 [[meatball:3]]
23373 !! html
23374 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
23375 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
23376 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
23377 </p>
23378 !! end
23379
23380 !! test
23381 Free external link invading image caption
23382 !! wikitext
23383 [[Image:Foobar.jpg|thumb|http://x|hello]]
23384 !! html/php
23385 <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>
23386
23387 !! html/parsoid
23388 <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>
23389 !! end
23390
23391 !! test
23392 T17196: localised external link numbers
23393 !! options
23394 language=fa
23395 !! wikitext
23396 [http://en.wikipedia.org/]
23397 !! html/php
23398 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
23399 </p>
23400 !! html/parsoid
23401 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p>
23402 !! end
23403
23404 !! test
23405 Multibyte character in padleft
23406 !! wikitext
23407 {{padleft:-Hello|7|Æ}}
23408 !! html/php
23409 <p>Æ-Hello
23410 </p>
23411 !! html/parsoid
23412 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p>
23413 !! end
23414
23415 !! test
23416 Multibyte character in padright
23417 !! wikitext
23418 {{padright:Hello-|7|Æ}}
23419 !! html/php
23420 <p>Hello-Æ
23421 </p>
23422 !! html/parsoid
23423 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p>
23424 !! end
23425
23426 !!test
23427 formatdate parser function
23428 !! wikitext
23429 {{#formatdate:2009-03-24}}
23430 !! html
23431 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
23432 </p>
23433 !! end
23434
23435 !!test
23436 formatdate parser function, with default format
23437 !! wikitext
23438 {{#formatdate:2009-03-24|mdy}}
23439 !! html
23440 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
23441 </p>
23442 !! end
23443
23444 !! test
23445 Spacing of numbers in formatted dates
23446 !! wikitext
23447 {{#formatdate:January 15}}
23448 !! html
23449 <p><span class="mw-formatted-date" title="01-15">January 15</span>
23450 </p>
23451 !! end
23452
23453 !! test
23454 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
23455 !! options
23456 language=nl title=[[MediaWiki:Common.css]]
23457 !! wikitext
23458 {{#formatdate:2009-03-24|dmy}}
23459 !! html
23460 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
23461 </p>
23462 !! end
23463
23464 #
23465 #
23466 #
23467
23468 #
23469 # Edit comments
23470 #
23471
23472 !! test
23473 Edit comment with link
23474 !! options
23475 comment
23476 !! wikitext
23477 I like the [[Main Page]] a lot
23478 !! html/php
23479 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
23480 !!end
23481
23482 !! test
23483 Edit comment with link and link text
23484 !! options
23485 comment
23486 !! wikitext
23487 I like the [[Main Page|best pages]] a lot
23488 !! html/php
23489 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23490 !!end
23491
23492 !! test
23493 Edit comment with link and link text with suffix
23494 !! options
23495 comment
23496 !! wikitext
23497 I like the [[Main Page|best page]]s a lot
23498 !! html/php
23499 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23500 !!end
23501
23502 !! test
23503 Edit comment with section link (non-local, eg in history list)
23504 !! options
23505 comment title=[[Main Page]]
23506 !! wikitext
23507 /* External links */ removed bogus entries
23508 !! html/php
23509 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23510 !!end
23511
23512 !! test
23513 Edit comment with section link and text before it (non-local, eg in history list)
23514 !! options
23515 comment title=[[Main Page]]
23516 !! wikitext
23517 pre-comment text /* External links */ removed bogus entries
23518 !! html/php
23519 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>
23520 !!end
23521
23522 !! test
23523 Edit comment with section link (local, eg in diff view)
23524 !! options
23525 comment local title=[[Main Page]]
23526 !! wikitext
23527 /* External links */ removed bogus entries
23528 !! html/php
23529 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23530 !!end
23531
23532 !! test
23533 Edit comment with subpage link (T16080)
23534 !! options
23535 comment
23536 subpage
23537 title=[[Subpage test]]
23538 !! wikitext
23539 Poked at a [[/subpage]] here...
23540 !! html/php
23541 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
23542 !!end
23543
23544 !! test
23545 Edit comment with subpage link and link text (T16080)
23546 !! options
23547 comment
23548 subpage
23549 title=[[Subpage test]]
23550 !! wikitext
23551 Poked at a [[/subpage|neat little page]] here...
23552 !! html/php
23553 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
23554 !!end
23555
23556 !! test
23557 Edit comment with bogus subpage link in non-subpage NS (T16080)
23558 !! options
23559 comment
23560 title=[[Subpage test]]
23561 !! wikitext
23562 Poked at a [[/subpage]] here...
23563 !! html/php
23564 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...
23565 !!end
23566
23567 !! test
23568 Edit comment with bare anchor link (local, as on diff)
23569 !! options
23570 comment
23571 local
23572 title=[[Main Page]]
23573 !! wikitext
23574 [[#section]]
23575 !! html/php
23576 <a href="#section">#section</a>
23577 !! end
23578
23579 !! test
23580 Edit comment with bare anchor link (non-local, as on history)
23581 !! options
23582 comment
23583 title=[[Main Page]]
23584 !! wikitext
23585 [[#section]]
23586 !! html/php
23587 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
23588 !! end
23589
23590 !! test
23591 Anchor starting with underscore
23592 !! options
23593 title=[[Foo]]
23594 !! wikitext
23595 [[#_ref|One]]
23596 !! html/php
23597 <p><a href="#_ref">One</a>
23598 </p>
23599 !! html/parsoid
23600 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
23601 !! end
23602
23603 !! test
23604 Id starting with underscore
23605 !! wikitext
23606 <div id="_ref"></div>
23607 !! html/*
23608 <div id="_ref"></div>
23609
23610 !! end
23611
23612 !! test
23613 Edit comment with link with more than one pipe (T99346)
23614 !! options
23615 comment
23616 !! wikitext
23617 [[Main Page|Many|pipes]]
23618 !! html/php
23619 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
23620 !! end
23621
23622 !! test
23623 Complex edit comment with link with more than one pipe (T99346)
23624 !! options
23625 comment
23626 !! wikitext
23627 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
23628 !! html/php
23629 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;
23630 !! end
23631
23632 !! test
23633 Space normalisation on autocomment (T24784)
23634 !! options
23635 comment
23636 title=[[Main Page]]
23637 !! wikitext
23638 /* __hello__world__ */
23639 !! html/php
23640 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
23641 !! end
23642
23643 !! test
23644 percent-encoding and + signs in comments (T28410)
23645 !! options
23646 comment
23647 !! wikitext
23648 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
23649 !! html/php
23650 <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>
23651 !! end
23652
23653 # Parsoid doesn't support this yet: see T75581
23654 # but it *should* omit the 'src' attribute if the image is bad.
23655 # PHP side of tests was disabled in
23656 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
23657 # because of issues in the PHP parserTests infrastructure
23658 # (but the output below is indeed what the PHP side emits)
23659 !! test
23660 Bad images - basic functionality
23661 !! wikitext
23662 [[File:Bad.jpg]]
23663 !! html/php+disabled
23664 !! html/parsoid
23665 <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>
23666 !! end
23667
23668 !! test
23669 Bad images - T18039: text after bad image disappears
23670 !! wikitext
23671 Foo bar
23672 [[File:Bad.jpg]]
23673 Bar foo
23674 !! html/php+disabled
23675 <p>Foo bar
23676 </p><p>Bar foo
23677 </p>
23678 !! html/parsoid
23679 <p>Foo bar
23680 <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>
23681 Bar foo</p>
23682 !! end
23683
23684 !! test
23685 Verify that displaytitle works (T24501) no displaytitle
23686 !! options
23687 showtitle
23688 !! config
23689 wgAllowDisplayTitle=true
23690 wgRestrictDisplayTitle=false
23691 !! wikitext
23692 this is not the the title
23693 !! html/php
23694 Parser test
23695 <p>this is not the the title
23696 </p>
23697 !! end
23698
23699 !! test
23700 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
23701 !! options
23702 showtitle
23703 title=[[Screen]]
23704 !! config
23705 wgAllowDisplayTitle=true
23706 wgRestrictDisplayTitle=false
23707 !! wikitext
23708 this is not the the title
23709 {{DISPLAYTITLE:whatever}}
23710 !! html/php
23711 whatever
23712 <p>this is not the the title
23713 </p>
23714 !! end
23715
23716 !! test
23717 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
23718 !! options
23719 showtitle
23720 title=[[Screen]]
23721 !! config
23722 wgAllowDisplayTitle=true
23723 wgRestrictDisplayTitle=true
23724 !! wikitext
23725 this is not the the title
23726 {{DISPLAYTITLE:whatever}}
23727 !! html/php
23728 Screen
23729 <p>this is not the the title
23730 </p>
23731 !! end
23732
23733 !! test
23734 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
23735 !! options
23736 showtitle
23737 title=[[Screen]]
23738 !! config
23739 wgAllowDisplayTitle=true
23740 wgRestrictDisplayTitle=true
23741 !! wikitext
23742 this is not the the title
23743 {{DISPLAYTITLE:screen}}
23744 !! html/php
23745 screen
23746 <p>this is not the the title
23747 </p>
23748 !! end
23749
23750 !! test
23751 Verify that displaytitle works (T24501) AllowDisplayTitle=false
23752 !! options
23753 showtitle
23754 title=[[Screen]]
23755 !! config
23756 wgAllowDisplayTitle=false
23757 !! wikitext
23758 this is not the the title
23759 {{DISPLAYTITLE:screen}}
23760 !! html/php
23761 Screen
23762 <p>this is not the the title
23763 <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>
23764 </p>
23765 !! end
23766
23767 !! test
23768 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
23769 !! options
23770 showtitle
23771 title=[[Screen]]
23772 !! config
23773 wgAllowDisplayTitle=false
23774 !! wikitext
23775 this is not the the title
23776 !! html/php
23777 Screen
23778 <p>this is not the the title
23779 </p>
23780 !! end
23781
23782 !! test
23783 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
23784 !! options
23785 showtitle
23786 title=[[Screen]]
23787 !! config
23788 wgAllowDisplayTitle=true
23789 wgRestrictDisplayTitle=true
23790 !! wikitext
23791 this is not the the title
23792 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
23793 !! html/php
23794 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
23795 <p>this is not the the title
23796 </p>
23797 !! end
23798
23799 !! test
23800 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
23801 !! options
23802 showtitle
23803 title=[[Screen]]
23804 !! config
23805 wgAllowDisplayTitle=true
23806 wgRestrictDisplayTitle=true
23807 !! wikitext
23808 this is not the the title
23809 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
23810 !! html/php
23811 <span style="color: red;">s</span>creen
23812 <p>this is not the the title
23813 </p>
23814 !! end
23815
23816 !! test
23817 Page status indicators: Empty name is invalid
23818 !! options
23819 showindicators
23820 !! wikitext
23821 <indicator name=" "></indicator>
23822 <indicator></indicator>
23823 !! html/php
23824 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23825 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23826 </p>
23827 !! end
23828
23829 !! test
23830 Page status indicators: Weird syntaxes that are okay
23831 !! options
23832 showindicators
23833 !! wikitext
23834 <indicator name="empty" />
23835 <indicator name="name"></indicator>
23836 !! html/php
23837 empty=
23838 name=
23839 <p><br />
23840 </p>
23841 !! end
23842
23843 !! test
23844 Page status indicators: Torture test
23845 !! options
23846 showindicators
23847 !! wikitext
23848 <indicator name="01">hello world</indicator>
23849 <indicator name="02">[[Main Page]]</indicator>
23850 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
23851 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
23852 <indicator name="05">*foo
23853 *bar</indicator>
23854 <indicator name="06"><nowiki>foo</nowiki></indicator>
23855 <indicator name="07"> Preformatted</indicator>
23856 <indicator name="08"><div>Broken tag</indicator>
23857 <indicator name="09">{| class=wikitable
23858 |cell
23859 |}</indicator>
23860 <indicator name="10">Two
23861
23862 paragraphs</indicator>
23863 !! html/php
23864 01=hello world
23865 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
23866 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" />
23867 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>
23868 05=<ul><li>foo</li>
23869 <li>bar</li></ul>
23870
23871 06=foo
23872 07=<pre>Preformatted
23873 </pre>
23874 08=<div>Broken tag</div>
23875
23876 09=<table class="wikitable">
23877 <tr>
23878 <td>cell
23879 </td></tr></table>
23880
23881 10=<p>Two
23882 </p><p>paragraphs
23883 </p>
23884 <p><br />
23885 </p><p><br />
23886 </p><p><br />
23887 </p><p><br />
23888 </p><p><br />
23889 </p>
23890 !! end
23891
23892 !! test
23893 preload: check <noinclude> and <includeonly>
23894 !! options
23895 preload
23896 !! wikitext
23897 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
23898 !! html/php
23899 Hello kind world.
23900 !! end
23901
23902 !! test
23903 preload: check <onlyinclude>
23904 !! options
23905 preload
23906 !! wikitext
23907 Goodbye <onlyinclude>Hello world</onlyinclude>
23908 !! html/php
23909 Hello world
23910 !! end
23911
23912 !! test
23913 preload: can pass tags through if we want to
23914 !! options
23915 preload
23916 !! wikitext
23917 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
23918 !! html/php
23919 <includeonly>Hello world</includeonly>
23920 !! end
23921
23922 !! test
23923 preload: check that it doesn't try to do tricks
23924 !! options
23925 preload
23926 !! wikitext
23927 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
23928 !! html/php
23929 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
23930 !! end
23931
23932 !! test
23933 Play a bit with r67090 and T5158
23934 !! wikitext
23935 <div style="width:50% !important">&nbsp;</div>
23936 <div style="width:50%&nbsp;!important">&nbsp;</div>
23937 <div style="width:50%&#160;!important">&nbsp;</div>
23938 <div style="border : solid;">&nbsp;</div>
23939 !! html/php
23940 <div style="width:50% !important">&#160;</div>
23941 <div style="width:50% !important">&#160;</div>
23942 <div style="width:50% !important">&#160;</div>
23943 <div style="border&#160;: solid;">&#160;</div>
23944
23945 !! html/parsoid
23946 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
23947 <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>
23948 <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>
23949 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
23950
23951 !! end
23952
23953 !! test
23954 HTML5 data attributes
23955 !! wikitext
23956 <span data-foo="bar">Baz</span>
23957 <p data-abc-def_hij="">Quuz</p>
23958 !! html/php
23959 <p><span data-foo="bar">Baz</span>
23960 </p>
23961 <p data-abc-def_hij="">Quuz</p>
23962
23963 !! html/parsoid
23964 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
23965 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
23966 !! end
23967
23968 !! test
23969 Strip reserved data attributes
23970 !! wikitext
23971 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
23972 !! html/php
23973 <div data-ok="fred">d</div>
23974
23975 !! html/parsoid
23976 <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>
23977 !! end
23978
23979 !! test
23980 percent-encoding and + signs in internal links (T28410)
23981 !! wikitext
23982 [[User:+%]] [[Page+title%]]
23983 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
23984 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
23985 [[%33%45]] [[%33%45+]]
23986 !! html/php
23987 <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>
23988 <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>
23989 <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>
23990 <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>
23991 </p>
23992 !! html/parsoid
23993 <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>
23994 <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>
23995 <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>
23996 <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>
23997 !! end
23998
23999 !! test
24000 Special characters in embedded file links (T29679)
24001 !! wikitext
24002 [[File:Contains & ampersand.jpg]]
24003 [[File:Does not exist.jpg|Title with & ampersand]]
24004 !! html/php
24005 <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>
24006 <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>
24007 </p>
24008 !! html/parsoid
24009 <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>
24010 <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>
24011 !! end
24012
24013 !! test
24014 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
24015 !! wikitext
24016 Text&apos;s been normalized?
24017 !! html
24018 <p>Text&#39;s been normalized?
24019 </p>
24020 !! end
24021
24022 !! test
24023 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
24024 !! wikitext
24025 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
24026 !! html
24027 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
24028 </p>
24029 !! end
24030
24031 !! test
24032 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
24033 !! wikitext
24034 [http://www.example.org/ ideograms]
24035 !! html
24036 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
24037 </p>
24038 !! end
24039
24040 !! test
24041 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
24042 !! wikitext
24043 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
24044 !! html
24045 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
24046 </p>
24047 !! end
24048
24049 !! article
24050 Mediawiki:loop1
24051 !! text
24052 {{Identical|A}}
24053 !! endarticle
24054
24055 !! article
24056 Mediawiki:loop2
24057 !! text
24058 {{Identical|B}}
24059 !! endarticle
24060
24061 !! article
24062 Template:Identical
24063 !! text
24064 {{int:loop1}}
24065 {{int:loop2}}
24066 !! endarticle
24067
24068 !! test
24069 T33098 Template which includes system messages which includes the template
24070 !! wikitext
24071 {{Identical}}
24072 !! html
24073 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24074 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24075 </p>
24076 !! end
24077
24078 !! test
24079 T33490 Turkish: ucfirst 'blah'
24080 !! options
24081 language=tr
24082 !! wikitext
24083 {{ucfirst:blah}}
24084 !! html
24085 <p>Blah
24086 </p>
24087 !! end
24088
24089 !! test
24090 T33490 Turkish: ucfirst 'ix'
24091 !! options
24092 language=tr
24093 !! wikitext
24094 {{ucfirst:ix}}
24095 !! html
24096 <p>İx
24097 </p>
24098 !! end
24099
24100 !! test
24101 T33490 Turkish: lcfirst 'BLAH'
24102 !! options
24103 language=tr
24104 !! wikitext
24105 {{lcfirst:BLAH}}
24106 !! html
24107 <p>bLAH
24108 </p>
24109 !! end
24110
24111 !! test
24112 T33490 Turkish: ucfırst (with a dotless i)
24113 !! options
24114 language=tr
24115 !! wikitext
24116 {{ucfırst:blah}}
24117 !! html
24118 <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>
24119 </p>
24120 !! end
24121
24122 !! test
24123 T33490 ucfırst (with a dotless i) with English language
24124 !! options
24125 language=en
24126 !! wikitext
24127 {{ucfırst:blah}}
24128 !! html
24129 <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>
24130 </p>
24131 !! end
24132
24133 # Note that Parsoid doesn't emit an explicit TOC.
24134 # Note also that the html2wt direction tends to emit an extra newline
24135 # between the __TOC__ magicword and the first heading unless *both*
24136 # the <meta> and the <h2> have a data-parsoid attribute set (even if
24137 # it's "{}").
24138
24139 !! test
24140 T28375: TOC with italics
24141 !! options
24142 title=[[Main Page]]
24143 !! wikitext
24144 __TOC__
24145 ==''Lost'' episodes==
24146 !! html/php
24147 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24148 <ul>
24149 <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>
24150 </ul>
24151 </div>
24152
24153 <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>
24154
24155 !! html/parsoid
24156 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24157 <h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2>
24158 !! end
24159
24160 !! test
24161 T28375: TOC with bold
24162 !! options
24163 title=[[Main Page]]
24164 !! wikitext
24165 __TOC__
24166 =='''should be bold''' then normal text==
24167 !! html/php
24168 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24169 <ul>
24170 <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>
24171 </ul>
24172 </div>
24173
24174 <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>
24175
24176 !! html/parsoid
24177 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24178 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2>
24179 !! end
24180
24181 !! test
24182 T35845: Headings become cursive in TOC when they contain an image
24183 !! options
24184 title=[[Main Page]]
24185 !! wikitext
24186 __TOC__
24187 ==Image [[Image:foobar.jpg]]==
24188 !! html/php
24189 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24190 <ul>
24191 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
24192 </ul>
24193 </div>
24194
24195 <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>
24196
24197 !! html/parsoid
24198 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24199 <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>
24200 !! end
24201
24202 !! test
24203 T35845 (2): Headings become bold in TOC when they contain a blockquote
24204 !! options
24205 title=[[Main Page]]
24206 !! wikitext
24207 __TOC__
24208 ==<blockquote>Quote</blockquote>==
24209 !! html/php
24210 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24211 <ul>
24212 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24213 </ul>
24214 </div>
24215
24216 <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>
24217
24218 !! html/php+tidy
24219 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24220 <ul>
24221 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24222 </ul>
24223 </div>
24224
24225 <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>
24226 !! html/parsoid
24227 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24228 <h2 id="Quote" data-parsoid='{}'><blockquote>Quote</blockquote></h2>
24229 !! end
24230
24231 !! test
24232 Unclosed tags in TOC
24233 !! config
24234 wgFragmentMode=[ 'html5', 'legacy' ]
24235 !! options
24236 title=[[Main Page]]
24237 !! wikitext
24238 __TOC__
24239 ==Proof: 2 < 3==
24240 <small>Hanc marginis exiguitas non caperet.</small>
24241 QED
24242 !! html/php
24243 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24244 <ul>
24245 <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>
24246 </ul>
24247 </div>
24248
24249 <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>
24250 <p><small>Hanc marginis exiguitas non caperet.</small>
24251 QED
24252 </p>
24253 !! html/parsoid
24254 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24255 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 &lt; 3</h2>
24256 <p><small>Hanc marginis exiguitas non caperet.</small>
24257 QED</p>
24258 !! end
24259
24260 !! test
24261 Multiple tags in TOC
24262 !! wikitext
24263 __TOC__
24264 ==<i>Foo</i> <b>Bar</b>==
24265
24266 ==<i>Foo</i> <blockquote>Bar</blockquote>==
24267 !! html/php
24268 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24269 <ul>
24270 <li class="toclevel-1 tocsection-1"><a href="#Foo_Bar"><span class="tocnumber">1</span> <span class="toctext"><i>Foo</i> <b>Bar</b></span></a></li>
24271 <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>
24272 </ul>
24273 </div>
24274
24275 <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>
24276 <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>
24277
24278 !! html/php+tidy
24279 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24280 <ul>
24281 <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>
24282 <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>
24283 </ul>
24284 </div>
24285
24286 <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>
24287 <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>
24288 !! html/parsoid
24289 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24290 <h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2>
24291
24292 <h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote></h2>
24293 !! end
24294
24295 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
24296 # html5 tag parsing.
24297 !! test
24298 Tags with parameters in TOC
24299 !! options
24300 parsoid=wt2html
24301 !! wikitext
24302 __TOC__
24303 ==<sup class="in-h2">Hello</sup>==
24304
24305 ==<sup class="a > b">Evilbye</sup>==
24306 !! html/php
24307 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24308 <ul>
24309 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
24310 <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>
24311 </ul>
24312 </div>
24313
24314 <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>
24315 <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>
24316
24317 !! html/parsoid
24318 <meta property="mw:PageProp/toc" />
24319 <h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2>
24320
24321 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2>
24322 !! end
24323
24324 !! test
24325 span tags with directionality in TOC
24326 !! wikitext
24327 __TOC__
24328 ==<span dir="ltr">C++</span>==
24329
24330 ==<span dir="rtl">זבנג!</span>==
24331
24332 ==<span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span>==
24333
24334 ==<span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span>==
24335
24336 ==<span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span>==
24337 !! html/php
24338 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24339 <ul>
24340 <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>
24341 <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>
24342 <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>
24343 <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>
24344 <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>
24345 </ul>
24346 </div>
24347
24348 <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>
24349 <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>
24350 <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>
24351 <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>
24352 <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>
24353
24354 !! html/parsoid
24355 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24356 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2>
24357 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2>
24358 <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>
24359 <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>
24360 <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>
24361 !! end
24362
24363 !! test
24364 T74884: bdi element in ToC
24365 !! wikitext
24366 __TOC__
24367 ==<bdi>test</bdi>==
24368 !! html/php
24369 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24370 <ul>
24371 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
24372 </ul>
24373 </div>
24374
24375 <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>
24376
24377 !! html/parsoid
24378 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24379 <h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2>
24380 !! end
24381
24382 !! test
24383 T35715: s/strike element in ToC
24384 !! wikitext
24385 __TOC__
24386 ==<s>test</s> test <strike>test</strike>==
24387 !! html/php
24388 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24389 <ul>
24390 <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>
24391 </ul>
24392 </div>
24393
24394 <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>
24395
24396 !! html/parsoid
24397 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24398 <h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2>
24399 !! end
24400
24401 !! test
24402 Empty <p> tag in TOC, removed by Sanitizer (T92892)
24403 !! wikitext
24404 __TOC__
24405 ==x==
24406 !! html/php
24407 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24408 <ul>
24409 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
24410 </ul>
24411 </div>
24412
24413 <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>
24414
24415 !! html/parsoid
24416 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24417 <h2 id="x" data-parsoid='{}'>x</h2>
24418 !! end
24419
24420 !! article
24421 MediaWiki:T34057
24422 !! text
24423 == {{int:headline_sample}} ==
24424 !! endarticle
24425
24426 !! test
24427 T34057: Title needed when expanding <h> nodes.
24428 !! options
24429 title=[[Main Page]]
24430 !! wikitext
24431 {{int:T34057}}
24432 !! html
24433 <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>
24434
24435 !! end
24436
24437 !! test
24438 Strip marker in urlencode
24439 !! wikitext
24440 {{urlencode:x<nowiki/>y}}
24441 {{urlencode:x<nowiki/>y|wiki}}
24442 {{urlencode:x<nowiki/>y|path}}
24443 {{urlencode:x<pre id="one">two</pre>y}}
24444 !! html/php
24445 <p>xy
24446 xy
24447 xy
24448 xy
24449 </p>
24450 !! end
24451
24452 !! test
24453 Strip marker in lc
24454 !! wikitext
24455 {{lc:x<nowiki/>y}}
24456 !! html
24457 <p>xy
24458 </p>
24459 !! end
24460
24461 !! test
24462 Strip marker in uc
24463 !! wikitext
24464 {{uc:x<nowiki/>y}}
24465 !! html
24466 <p>XY
24467 </p>
24468 !! end
24469
24470 !! test
24471 Strip marker in formatNum
24472 !! wikitext
24473 {{formatnum:1<nowiki/>2}}
24474 {{formatnum:1<nowiki/>2|R}}
24475 !! html
24476 <p>12
24477 12
24478 </p>
24479 !! end
24480
24481 !! test
24482 Check noCommafy in formatNum
24483 !! options
24484 language=be-tarask
24485 !! wikitext
24486 {{formatnum:123456.78}}
24487 {{formatnum:123456.78|NOSEP}}
24488 !! html
24489 <p>123 456,78
24490 123456.78
24491 </p>
24492 !! end
24493
24494 !! test
24495 Wrong option for formatNum (T58199)
24496 !! wikitext
24497 {{formatnum:1,234.56|Random}}
24498 {{formatnum:1,234.56|EVERYTHING}}
24499 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
24500 !! html
24501 <p>1,234.56
24502 1,234.56
24503 1,234.56
24504 </p>
24505 !! end
24506
24507 !! test
24508 Strip marker in grammar
24509 !! options
24510 language=fi
24511 !! wikitext
24512 {{grammar:elative|foo<nowiki/>bar}}
24513 !! html
24514 <p>foobarista
24515 </p>
24516 !! end
24517
24518 !! test
24519 Strip marker in padleft
24520 !! wikitext
24521 {{padleft:|2|x<nowiki/>y}}
24522 !! html
24523 <p>xy
24524 </p>
24525 !! end
24526
24527 !! test
24528 Strip marker in padright
24529 !! wikitext
24530 {{padright:|2|x<nowiki/>y}}
24531 !! html
24532 <p>xy
24533 </p>
24534 !! end
24535
24536 !! test
24537 Strip marker in anchorencode
24538 !! wikitext
24539 {{anchorencode:x<nowiki/>y}}
24540 !! html/php
24541 <p>xy
24542 </p>
24543 !! html/parsoid
24544 <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>
24545 !! end
24546
24547 !! test
24548 nowiki inside link inside heading (T20295)
24549 !! wikitext
24550 ==[[foo|x<nowiki>y</nowiki>z]]==
24551 !! html
24552 <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>
24553
24554 !! end
24555
24556 !! test
24557 new support for bdi element (T33817)
24558 !! wikitext
24559 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24560 !! html
24561 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24562
24563 !!end
24564
24565 !! test
24566 Ignore pipe between table row attributes
24567 !! wikitext
24568 {|
24569 |quux
24570 |- id=foo | style='color: red'
24571 |bar
24572 |}
24573 !! html
24574 <table>
24575 <tr>
24576 <td>quux
24577 </td></tr>
24578 <tr id="foo" style="color: red">
24579 <td>bar
24580 </td></tr></table>
24581
24582 !! end
24583
24584 !!test
24585 Language parser function
24586 !! wikitext
24587 {{#language:ar}}
24588 !! html
24589 <p>العربية
24590 </p>
24591 !! end
24592
24593 !!test
24594 Padleft and padright (default 0-padding)
24595 !! wikitext
24596 {{padleft:xyz|5}}
24597 {{padright:xyz|5}}
24598 !! html/php
24599 <p>00xyz
24600 xyz00
24601 </p>
24602 !! html/parsoid
24603 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span>
24604 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p>
24605 !! end
24606
24607 !!test
24608 Padleft and padright (partial fill)
24609 !! wikitext
24610 {{padleft:xyz|6|ab}}
24611 {{padright:xyz|6|ab}}
24612 !! html/php
24613 <p>abaxyz
24614 xyzaba
24615 </p>
24616 !! html/parsoid
24617 <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>
24618 <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>
24619 !! end
24620
24621 !!test
24622 Padleft and padright as substr
24623 !! wikitext
24624 {{padleft:|3|abcde}}
24625 {{padright:|3|abcde}}
24626 !! html/php
24627 <p>abc
24628 abc
24629 </p>
24630 !! html/parsoid
24631 <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>
24632 <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>
24633 !! end
24634
24635 !!test
24636 Special parser function
24637 !! wikitext
24638 {{#special:RandomPage}}
24639 {{#special:BaDtItLe}}
24640 {{#special:Foobar}}
24641 !! html
24642 <p>Special:Random
24643 Special:Badtitle
24644 Special:Foobar
24645 </p>
24646 !! end
24647
24648 !!test
24649 T36939 - Case insensitive link parsing ([HttP://])
24650 !! wikitext
24651 [HttP://MediaWiki.Org/]
24652 !! html/php
24653 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
24654 </p>
24655 !! html/parsoid
24656 <p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p>
24657 !! end
24658
24659 !!test
24660 T36939 - Case insensitive link parsing ([HttP:// title])
24661 !! wikitext
24662 [HttP://MediaWiki.Org/ MediaWiki]
24663 !! html
24664 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
24665 </p>
24666 !! end
24667
24668 !!test
24669 T36939 - Case insensitive link parsing (HttP://)
24670 !! wikitext
24671 HttP://MediaWiki.Org/
24672 !! html/php
24673 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
24674 </p>
24675 !! html/parsoid
24676 <p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
24677 !! end
24678
24679 !!test
24680 Disable TOC
24681 !! options
24682 notoc
24683 !! wikitext
24684 Lead
24685 ==Section 1==
24686 ==Section 2==
24687 ==Section 3==
24688 ==Section 4==
24689 ==Section 5==
24690 !! html
24691 <p>Lead
24692 </p>
24693
24694 <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>
24695 <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>
24696 <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>
24697 <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>
24698 <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>
24699
24700 !! end
24701
24702
24703 ###
24704 ### Parsoid-specific tests
24705 ### Parsoid-PHP parser incompatibilities
24706 ###
24707 !!test
24708 1. SOL-sensitive wikitext tokens as template-args
24709 !!options
24710 parsoid=wt2html,wt2wt
24711 !! wikitext
24712 {{echo|*a}}
24713 {{echo|#a}}
24714 {{echo|:a}}
24715 !! html
24716 <span about="#mwt1" typeof="mw:Transclusion">
24717 </span><ul about="#mwt1"><li>a</li>
24718 </ul>
24719 <span about="#mwt2" typeof="mw:Transclusion">
24720 </span><ol about="#mwt2"><li>a</li>
24721 </ol>
24722 <span about="#mwt3" typeof="mw:Transclusion">
24723 </span><dl about="#mwt3"><dd>a</dd>
24724 </dl>
24725 !!end
24726
24727 #### -----------------------------------------------------------------
24728 #### Parsoid-specific functionality tests
24729 #### -----------------------------------------------------------------
24730
24731 # T65642/T68749: Formatting elt fixup around images is cleaned up.
24732 # We know wt2wt will fail, but we expect selser to pass.
24733 # Due to the nature of our testing, wt2wt and selser tests will enter the
24734 # blacklist and we'll catch selser regressions based on changes to the
24735 # blacklist entries for selser tests.
24736 !! test
24737 1. Bad treebuilder fixup of formatting elt is cleaned up
24738 !! options
24739 parsoid=wt2html,wt2wt
24740 !! wikitext
24741 {|
24742 |
24743 <small>
24744 [[Image:Foobar.jpg|right|Test]]
24745 </small>
24746 |}
24747 !! html/parsoid
24748 <table>
24749 <tbody><tr><td>
24750 <small>
24751 <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>
24752 </small>
24753 </td></tr>
24754 </tbody></table>
24755 !! end
24756
24757 !! test
24758 2. Bad treebuilder fixup of formatting elt is cleaned up
24759 !! options
24760 parsoid=wt2html,wt2wt
24761 !! wikitext
24762 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
24763
24764 <small>[[Image:Foobar.jpg|right|300px]]</small>
24765 !! html/parsoid
24766
24767 <p><b>foo</b></p>
24768 <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>
24769 <p><b>bar</b></p>
24770 <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>
24771 !! end
24772
24773 !! test
24774 3. Bad treebuilder fixup of formatting elt is cleaned up
24775 !! options
24776 parsoid=wt2html,wt2wt
24777 !! wikitext
24778 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
24779 !! html/parsoid
24780 <p><small><b>foo</b></small></p>
24781 <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>
24782 <p><small><b>bar</b></small></p>
24783 !! end
24784
24785 !! test
24786 4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
24787 !! options
24788 parsoid=wt2html,wt2wt
24789 !! wikitext
24790 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
24791 !! html/parsoid
24792 <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>
24793 !! end
24794
24795 #### ----------------------------------------------------------------
24796 #### Parsoid-only testing of Parsoid's impl of LST
24797 #### Not implemented yet, see
24798 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
24799 #### ----------------------------------------------------------------
24800
24801 ## We still need to support serializing the older format while content is stored.
24802 !! test
24803 LST Sections: Backwards compatibility
24804 !! options
24805 parsoid={
24806 "suppressErrors": true,
24807 "modes": ["html2wt"]
24808 }
24809 !! wikitext
24810 <section begin="2011-05-16" />
24811 <section end="2014-04-10 (MW 1.23wmf22)" />
24812 !! html/parsoid
24813 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
24814 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
24815 !! end
24816
24817 !! test
24818 LST Sections: Newfangled approach
24819 !! wikitext
24820 <section begin="2011-05-16" />
24821 <section end="2014-04-10 (MW 1.23wmf22)" />
24822 !! html/parsoid
24823 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'>
24824 </span>
24825 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null}'>
24826 </span></p>
24827 !! end
24828
24829 #--------- Test stripping of empty nodes in template content ----------
24830
24831 !! test
24832 Empty LI and TR nodes should be stripped from template content
24833 !! wikitext
24834 {{EmptyLITest}}
24835 {{EmptyTRTest}}
24836 !! html/parsoid
24837 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
24838 <li>a</li>
24839 <li>b</li>
24840 </ul>
24841 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
24842 <tbody>
24843 <tr>
24844 <td>foo</td>
24845 </tr>
24846 <tr>
24847 <td>bar</td>
24848 </tr>
24849 </tbody>
24850 </table>
24851 !! end
24852
24853 !! test
24854 Empty LI and TR nodes should not be stripped from top-level content
24855 !! wikitext
24856 * a
24857 *
24858 * b
24859
24860 {|
24861 |-
24862 |-
24863 |foo
24864 |}
24865 !! html/parsoid
24866 <ul>
24867 <li> a</li>
24868 <li class='mw-empty-elt'></li>
24869 <li> b</li>
24870 </ul>
24871 <table>
24872 <tbody>
24873 <tr class='mw-empty-elt'></tr>
24874 <tr>
24875 <td>foo</td>
24876 </tr>
24877 </tbody>
24878 </table>
24879 !! end
24880
24881 !! test
24882 Empty TR nodes should not be stripped if they have any attributes set
24883 !! wikitext
24884 {{EmptyTRWithHTMLAttrTest}}
24885 !! html/parsoid
24886 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
24887 <tr align='center'></tr>
24888 <tr><td>foo</td></tr>
24889 <tr align='center'></tr>
24890 <tr><td>bar</td></tr>
24891 </table>
24892 !! end
24893
24894 #### ----------------------------------------------------------------
24895 #### The following section of tests are primarily to test
24896 #### wikitext escaping capabilities of Parsoid. Given that
24897 #### escaping can be done any number of ways, the wikitext (input)
24898 #### is always adjusted to reflect how Parsoid adds nowiki
24899 #### escape tags.
24900 ####
24901 #### We are marking several tests as parsoid-only since the
24902 #### HTML in the result section is different from what the
24903 #### PHP parser generates for it.
24904 #### ----------------------------------------------------------------
24905
24906
24907 #### --------------- Headings ---------------
24908 #### 0. Unnested
24909 #### 1. Nested inside html <h1>=foo=</h1>
24910 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
24911 #### 3. Nested inside html with wikitext split by html tags
24912 #### 4. No escape needed
24913 #### 5. Empty headings <h1></h1>
24914 #### 6. Heading chars in SOL context
24915 #### ----------------------------------------
24916 !! test
24917 Headings: 0. Unnested
24918 !! options
24919 parsoid=html2wt
24920 !! html/parsoid
24921 <p>=foo=</p>
24922
24923 <p> =foo=
24924 <!--cmt-->
24925 =foo=</p>
24926
24927 <p>=foo<i>a</i>=</p>
24928 !! wikitext
24929 <nowiki>=foo=</nowiki>
24930
24931 <nowiki> </nowiki>=foo=
24932 <!--cmt-->
24933 <nowiki>=foo=</nowiki>
24934
24935 =foo''a''<nowiki>=</nowiki>
24936 !!end
24937
24938 # New headings and existing headings are handled differently
24939 !! test
24940 Headings: 1. Nested inside html
24941 !! options
24942 parsoid=html2wt
24943 !! html/parsoid
24944 <h1>=foo=</h1>
24945 <h2>=foo=</h2>
24946 <h3>=foo=</h3>
24947
24948 <h1 data-parsoid=''>=foo=</h1>
24949 <h2 data-parsoid=''>=foo=</h2>
24950 <h3 data-parsoid=''>=foo=</h3>
24951 <h4 data-parsoid=''>=foo=</h4>
24952 <h5 data-parsoid=''>=foo=</h5>
24953 <h6 data-parsoid=''>=foo=</h6>
24954 !! wikitext
24955 = =foo= =
24956
24957 == =foo= ==
24958
24959 === =foo= ===
24960
24961 =<nowiki>=foo=</nowiki>=
24962 ==<nowiki>=foo=</nowiki>==
24963 ===<nowiki>=foo=</nowiki>===
24964 ====<nowiki>=foo=</nowiki>====
24965 =====<nowiki>=foo=</nowiki>=====
24966 ======<nowiki>=foo=</nowiki>======
24967
24968 !!end
24969
24970 !! test
24971 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
24972 !! options
24973 parsoid=html2wt
24974 !! html/parsoid
24975 <h1>foo</h1>*bar
24976 <h1>foo</h1>=bar
24977 <h1>foo</h1>=bar=
24978 !! wikitext
24979 = foo =
24980 <nowiki>*</nowiki>bar
24981
24982 = foo =
24983 =bar
24984
24985 = foo =
24986 <nowiki>=bar=</nowiki>
24987 !!end
24988
24989 !! test
24990 Headings: 3. Nested inside html with wikitext split by html tags
24991 !! options
24992 parsoid=html2wt
24993 !! html/parsoid
24994 <h1>=<b>bold</b>foo=</h1>
24995 !! wikitext
24996 = ='''bold'''foo= =
24997 !!end
24998
24999 !! test
25000 Headings: 4a. No escaping needed (testing just h1 and h2)
25001 !! options
25002 parsoid=html2wt
25003 !! html/parsoid
25004 <h1>=foo</h1>
25005 <h1>foo=</h1>
25006 <h1> =foo= </h1>
25007 <h1>=foo= bar</h1>
25008 <h2>=foo</h2>
25009 <h2>foo=</h2>
25010 <h1>=</h1>
25011 <h1><i>=</i>foo=</h1>
25012 !! wikitext
25013 = =foo =
25014
25015 = foo= =
25016
25017 = =foo= =
25018
25019 = =foo= bar =
25020
25021 == =foo ==
25022
25023 == foo= ==
25024
25025 = = =
25026
25027 = ''=''foo= =
25028 !!end
25029
25030 !! test
25031 Headings: 4b. No escaping needed (inside p-tags)
25032 !! options
25033 parsoid=html2wt
25034 !! html/parsoid
25035 <p>=foo= x
25036 =foo= <s></s>
25037 </p>
25038 !! wikitext
25039 =foo= x
25040 =foo= <s></s>
25041 !! html/php
25042 <p>=foo= x
25043 =foo= <s></s>
25044 </p>
25045 !!end
25046
25047 !! test
25048 Headings: 4c. Short headings (1)
25049 !! options
25050 parsoid=html2wt
25051 !! html/parsoid
25052 <p>===
25053 </p>
25054 !! wikitext
25055 <nowiki>===</nowiki>
25056 !! html/php
25057 <p>===
25058 </p>
25059 !! end
25060
25061 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
25062 !! test
25063 Headings: 4d. Short headings (2)
25064 !! options
25065 parsoid=wt2html,html2html
25066 !! wikitext
25067 =
25068 ==
25069 ===
25070 ====
25071 =====
25072 !! html/php
25073 <p>=
25074 ==
25075 </p>
25076 <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>
25077 <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>
25078 <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>
25079
25080 !! html/parsoid
25081 <p>=
25082 ==</p>
25083 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
25084 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
25085 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
25086 !! end
25087
25088 !! test
25089 Headings: 5. Empty headings
25090 !! options
25091 parsoid=html2wt
25092 !! html/parsoid
25093 <h1 data-parsoid='{}'></h1>
25094
25095 <h2 data-parsoid='{}'></h2>
25096
25097 <h3 data-parsoid='{}'></h3>
25098
25099 <h4 data-parsoid='{}'></h4>
25100
25101 <h5 data-parsoid='{}'></h5>
25102
25103 <h6 data-parsoid='{}'></h6>
25104 !! wikitext
25105 =<nowiki/>=
25106
25107 ==<nowiki/>==
25108
25109 ===<nowiki/>===
25110
25111 ====<nowiki/>====
25112
25113 =====<nowiki/>=====
25114
25115 ======<nowiki/>======
25116 !!end
25117
25118 !! test
25119 Headings: 6a. Heading chars in SOL context (with trailing spaces)
25120 !! options
25121 parsoid=html2wt
25122 !! html/parsoid
25123 <p>=a=</p>
25124
25125 <p>=a=</p>
25126
25127 <p>=a=</p>
25128 !! wikitext
25129 <nowiki>=a=</nowiki>
25130
25131 <nowiki>=a=</nowiki>
25132
25133 <nowiki>=a=</nowiki>
25134 !!end
25135
25136 !! test
25137 Headings: 6b. Heading chars in SOL context (with trailing newlines)
25138 !! options
25139 parsoid=html2wt
25140 !! html/parsoid
25141 <p>=a=
25142 b</p>
25143
25144 <p>=a=
25145 b</p>
25146
25147 <p>=a=
25148 b</p>
25149 !! wikitext
25150 <nowiki>=a=</nowiki>
25151 b
25152
25153 <nowiki>=a=</nowiki>
25154 b
25155
25156 <nowiki>=a=</nowiki>
25157 b
25158 !!end
25159
25160 !! test
25161 Headings: 6c. Heading chars in SOL context (leading newline break)
25162 !! options
25163 parsoid=html2wt
25164 !! html/parsoid
25165 <p>a
25166 =b=</p>
25167 !! wikitext
25168 a
25169 <nowiki>=b=</nowiki>
25170 !!end
25171
25172 !! test
25173 Headings: 6d. Heading chars in SOL context (with interspersed comments)
25174 !! options
25175 parsoid=html2wt
25176 !! html/parsoid
25177 <!--c0--><p>=a=</p>
25178
25179 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
25180 !! wikitext
25181 <!--c0--><nowiki>=a=</nowiki>
25182
25183 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
25184 !!end
25185
25186 !! test
25187 Headings: 6d. Heading chars in SOL context (No escaping needed)
25188 !! options
25189 parsoid=html2wt
25190 !! html/parsoid
25191 =a=<div>b</div>
25192 !! wikitext
25193 =a=<div>b</div>
25194 !!end
25195
25196 !! test
25197 Headings: 7. Insert a newline between new content and headings
25198 !! options
25199 parsoid=html2wt
25200 !! html/parsoid
25201 <h2>NEW</h2>
25202 <p>new</p>
25203 <h2 data-parsoid='{}'>A</h2>
25204 <p data-parsoid='{}'>a</p>
25205 !! wikitext
25206 == NEW ==
25207 new
25208
25209 ==A==
25210 a
25211
25212 !! end
25213
25214 !! test
25215 Headings: Used as horizontal rule
25216 !! config
25217 wgFragmentMode=[ 'html5', 'legacy' ]
25218 !! options
25219 parsoid=wt2html
25220 !! wikitext
25221 ===============
25222 !! html/php
25223 <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>
25224
25225 !! html/parsoid
25226 <h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6>
25227 !! end
25228
25229 #### --------------- Lists ---------------
25230 #### 0. Outside nests (*foo, etc.)
25231 #### 1. Nested inside html <ul><li>*foo</li></ul>
25232 #### 2. Inside definition lists
25233 #### 3. Only bullets at start should be escaped
25234 #### 4. No escapes needed
25235 #### 5. No unnecessary escapes
25236 #### 6. Escape bullets in SOL position
25237 #### 7. Escape bullets in a multi-line context
25238 #### ----------------------------------------
25239
25240 !! test
25241 Lists: 0. Outside nests
25242 !! options
25243 parsoid=html2wt
25244 !! html/parsoid
25245 <p>*foo</p>
25246
25247 <p>#foo</p>
25248
25249 <p>;Foo:bar</p>
25250 !! wikitext
25251 <nowiki>*</nowiki>foo
25252
25253 <nowiki>#</nowiki>foo
25254
25255 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
25256 !!end
25257
25258 ## Making these next 3 tests Parsoid-only since they are html2wt tests
25259 ## to test wikitext escaping, and insignificant whitespace diffs
25260 ## cause PHP parser tests to barf
25261 !! test
25262 Lists: 1. Nested inside html (No unnecessary escapes)
25263 !! options
25264 parsoid=html2wt
25265 !! html/parsoid
25266 <ul>
25267 <li>*foo</li>
25268 <li>#foo</li>
25269 <li>:foo</li>
25270 <li>;foo</li>
25271 <li data-parsoid='{}'>*foo</li>
25272 <li data-parsoid='{}'>#foo</li>
25273 <li data-parsoid='{}'>:foo</li>
25274 <li data-parsoid='{}'>;foo</li>
25275 </ul>
25276
25277 <ol>
25278 <li>*foo</li>
25279 <li>#foo</li>
25280 <li>:foo</li>
25281 <li>;foo</li>
25282 <li data-parsoid='{}'>*foo</li>
25283 <li data-parsoid='{}'>#foo</li>
25284 <li data-parsoid='{}'>:foo</li>
25285 <li data-parsoid='{}'>;foo</li>
25286 </ol>
25287 !! wikitext
25288 * *foo
25289 * #foo
25290 * :foo
25291 * ;foo
25292 *<nowiki>*foo</nowiki>
25293 *<nowiki>#foo</nowiki>
25294 *<nowiki>:foo</nowiki>
25295 *<nowiki>;foo</nowiki>
25296
25297 # *foo
25298 # #foo
25299 # :foo
25300 # ;foo
25301 #<nowiki>*foo</nowiki>
25302 #<nowiki>#foo</nowiki>
25303 #<nowiki>:foo</nowiki>
25304 #<nowiki>;foo</nowiki>
25305 !!end
25306
25307 !! test
25308 Lists: 2. Inside definition lists
25309 !! options
25310 parsoid=html2wt
25311 !! html/parsoid
25312 <dl><dt>;foo</dt></dl>
25313 <dl><dt>:foo</dt></dl>
25314 <dl><dt>:foo</dt>
25315 <dd>bar</dd></dl>
25316 <dl><dd>:foo</dd></dl>
25317 !! wikitext
25318 ; ;foo
25319
25320 ; <nowiki>:foo</nowiki>
25321
25322 ; <nowiki>:foo</nowiki>
25323 : bar
25324
25325 : :foo
25326 !!end
25327
25328 !! test
25329 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
25330 !! options
25331 parsoid=html2wt
25332 !! html/parsoid
25333 <ul>
25334 <li>*foo*bar</li>
25335 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
25336 </ul>
25337 !! wikitext
25338 * *foo*bar
25339 *<nowiki>*foo</nowiki>''it''*bar
25340 !!end
25341
25342 !! test
25343 Lists: 4. No escapes needed
25344 !! options
25345 parsoid=html2wt
25346 !! html/parsoid
25347 <ul>
25348 <li>foo*bar
25349 </li>
25350 </ul>
25351 <ul>
25352 <li><i>foo</i>*bar
25353 </li>
25354 </ul>
25355 <ul>
25356 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
25357 </li>
25358 </ul>
25359 <ul>
25360 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
25361 </li>
25362 </ul>
25363 !! wikitext
25364 *foo*bar
25365
25366 *''foo''*bar
25367
25368 *[[Foo]]: bar
25369
25370 *[[Foo]]*bar
25371 !!end
25372
25373 !! test
25374 Lists: 5. No unnecessary escapes
25375 !! options
25376 parsoid=html2wt
25377 !! html/parsoid
25378 <ul><li> bar <span>[[foo]]</span></li></ul>
25379 <ul><li> =bar <span>[[foo]]</span></li></ul>
25380 <ul><li> [[bar <span>[[foo]]</span></li></ul>
25381 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
25382 <ul><li> =bar <span>foo]]</span>=</li></ul>
25383 <ul><li> <s></s>: a</li></ul>
25384 <ul><li> <i>* foo</i></li></ul>
25385
25386 !! wikitext
25387 * bar <span><nowiki>[[foo]]</nowiki></span>
25388
25389 * =bar <span><nowiki>[[foo]]</nowiki></span>
25390
25391 * [[bar <span><nowiki>[[foo]]</nowiki></span>
25392
25393 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
25394
25395 * =bar <span>foo]]</span>=
25396
25397 * <s></s>: a
25398
25399 * ''* foo''
25400 !!end
25401
25402 !! test
25403 Lists: 6. Escape bullets in SOL position
25404 !! options
25405 parsoid=html2wt
25406 !! html/parsoid
25407 <p><!--cmt-->*foo</p>
25408 !! wikitext
25409 <!--cmt--><nowiki>*</nowiki>foo
25410 !!end
25411
25412 !! test
25413 Lists: 7. Escape bullets in a multi-line context
25414 !! options
25415 parsoid=html2wt
25416 !! html/parsoid
25417 <p>a
25418 *b
25419 </p>
25420 !! wikitext
25421 a
25422 <nowiki>*</nowiki>b
25423 !!end
25424
25425 !! test
25426 Lists: 8. Escape colons only if not present in tags
25427 !! options
25428 parsoid=html2wt
25429 !! html/parsoid
25430 <dl><dt>a:b<i>c:d</i></dt></dl>
25431 !! wikitext
25432 ; <nowiki>a:b</nowiki>''c:d''
25433 !! end
25434
25435 #### --------------- HRs ---------------
25436 #### 1. Single line
25437 #### -----------------------------------
25438
25439 !! test
25440 HRs: 1. Single line
25441 !! options
25442 parsoid=html2wt
25443 !! html/parsoid
25444 <hr />----
25445 <hr />=foo=
25446 <hr />*foo
25447 !! wikitext
25448 ----<nowiki>----</nowiki>
25449 ----=foo=
25450 ----*foo
25451 !! end
25452
25453 #### --------------- Tables ---------------
25454 #### 1a. Simple example
25455 #### 1b. No escaping needed (!foo)
25456 #### 1c. No escaping needed (|foo)
25457 #### 1d. No escaping needed (|}foo)
25458 ####
25459 #### 2a. Nested in td (<td>foo|bar</td>)
25460 #### 2b. Nested in td (<td>foo||bar</td>)
25461 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
25462 ####
25463 #### 3a. Nested in th (<th>foo!bar</th>)
25464 #### 3b. Nested in th (<th>foo!!bar</th>)
25465 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
25466 ####
25467 #### 4a. Escape -
25468 #### 4b. Escape +
25469 #### 4c. No escaping needed
25470 #### --------------------------------------
25471
25472 !! test
25473 Tables: 1a. Simple example
25474 !! options
25475 parsoid=html2wt
25476 !! html/parsoid
25477 <p>{|
25478 |}
25479 </p>
25480 !! wikitext
25481 <nowiki>{|</nowiki>
25482 |}
25483 !! end
25484
25485 !! test
25486 Tables: 1b. No escaping needed
25487 !! options
25488 parsoid=html2wt
25489 !! html/parsoid
25490 <p>!foo
25491 </p>
25492 !! wikitext
25493 !foo
25494 !! end
25495
25496 !! test
25497 Tables: 1c. No escaping needed
25498 !! options
25499 parsoid=html2wt
25500 !! html/parsoid
25501 <p>|foo
25502 </p>
25503 !! wikitext
25504 |foo
25505 !! end
25506
25507 !! test
25508 Tables: 1d. No escaping needed
25509 !! options
25510 parsoid=html2wt
25511 !! html/parsoid
25512 <p>|}foo
25513 </p>
25514 !! wikitext
25515 |}foo
25516 !! end
25517
25518 !! test
25519 Tables: 2a. Nested in td
25520 !! options
25521 parsoid=html2wt
25522 !! html/parsoid
25523 <table><tbody><tr>
25524 <td>foo|bar</td></tr>
25525 <tr><td>x<div>a|b</div></td>
25526 </tbody></table>
25527 !! wikitext
25528 {|
25529 |<nowiki>foo|bar</nowiki>
25530 |-
25531 |x<div><nowiki>a|b</nowiki></div>
25532 |}
25533 !! html/php+tidy
25534 <table>
25535 <tbody><tr>
25536 <td>foo|bar
25537 </td></tr>
25538 <tr>
25539 <td>x<div>a|b</div>
25540 </td></tr></tbody></table>
25541 !! end
25542
25543 !! test
25544 Tables: 2b. Nested in td
25545 !! options
25546 parsoid=html2wt
25547 !! html/parsoid
25548 <table><tbody><tr>
25549 <td>foo||bar</td>
25550 <td>a<i>b||c</i></td>
25551 <td>a<i><div>b||c</div></i></td>
25552 </tr></tbody></table>
25553 !! wikitext
25554 {|
25555 |<nowiki>foo||bar</nowiki>
25556 |a''<nowiki>b||c</nowiki>''
25557 |a''<div><nowiki>b||c</nowiki></div>''
25558 |}
25559 !! html/php
25560 <table>
25561 <tr>
25562 <td>foo||bar
25563 </td>
25564 <td>a<i>b||c</i>
25565 </td>
25566 <td>a<i><div>b||c</div></i>
25567 </td></tr></table>
25568
25569 !! end
25570
25571 !! test
25572 Tables: 2c. Nested in td -- no escaping needed
25573 !! options
25574 parsoid=html2wt
25575 !! html/*
25576 <table>
25577 <tr>
25578 <td>foo!!bar
25579 </td></tr></table>
25580
25581 !! wikitext
25582 {|
25583 |foo!!bar
25584 |}
25585 !! end
25586
25587 !! test
25588 Tables: 3a. Nested in th
25589 !! options
25590 parsoid=html2wt
25591 !! html/*
25592 <table>
25593 <tr>
25594 <th>foo!bar
25595 </th></tr></table>
25596
25597 !! wikitext
25598 {|
25599 !foo!bar
25600 |}
25601 !! end
25602
25603 !! test
25604 Tables: 3b. Nested in th
25605 !! options
25606 parsoid=html2wt
25607 !! html/parsoid
25608 <table><tbody>
25609 <tr><th>foo!!bar</th>
25610 <th><i>foo|bar</i></th>
25611 <th><i>foo!!bar</i></th>
25612 <th><i><span>foo!!bar</span></i></th>
25613 </tr></tbody></table>
25614 !! wikitext
25615 {|
25616 !<nowiki>foo!!bar</nowiki>
25617 !''<nowiki>foo|bar</nowiki>''
25618 !''<nowiki>foo!!bar</nowiki>''
25619 !''<span><nowiki>foo!!bar</nowiki></span>''
25620 |}
25621 !! html/php
25622 <table>
25623 <tr>
25624 <th>foo!!bar
25625 </th>
25626 <th><i>foo|bar</i>
25627 </th>
25628 <th><i>foo!!bar</i>
25629 </th>
25630 <th><i><span>foo!!bar</span></i>
25631 </th></tr></table>
25632
25633 !! end
25634
25635 !! test
25636 Tables: 3c. Nested in th
25637 !! options
25638 parsoid=html2wt
25639 !! html/parsoid
25640 <table><tbody>
25641 <tr><th>foo||bar</th>
25642 <th><span typeof="mw:Nowiki">foo||bar</span></th>
25643 </tr></tbody></table>
25644 !! wikitext
25645 {|
25646 !<nowiki>foo||bar</nowiki>
25647 !<nowiki>foo||bar</nowiki>
25648 |}
25649 !! html/php
25650 <table>
25651 <tr>
25652 <th>foo||bar
25653 </th>
25654 <th>foo||bar
25655 </th></tr></table>
25656
25657 !! end
25658
25659 !! test
25660 Tables: 4a. Escape -
25661 !! options
25662 parsoid=html2wt
25663 !! html/*
25664 <table>
25665 <tr>
25666 <th>-bar
25667 </th></tr>
25668 <tr>
25669 <td>-bar
25670 </td></tr></table>
25671
25672 !! wikitext
25673 {|
25674 !-bar
25675 |-
25676 |<nowiki>-bar</nowiki>
25677 |}
25678 !! end
25679
25680 !! test
25681 Tables: 4b. Escape +
25682 !! options
25683 parsoid=html2wt
25684 !! html/*
25685 <table>
25686 <tr>
25687 <th>+bar
25688 </th></tr>
25689 <tr>
25690 <td>+bar
25691 </td></tr></table>
25692
25693 !! wikitext
25694 {|
25695 !+bar
25696 |-
25697 |<nowiki>+bar</nowiki>
25698 |}
25699 !! end
25700
25701 !! test
25702 Tables: 4c. No escaping needed
25703 !! options
25704 parsoid=html2wt
25705 !! html/parsoid
25706 <table><tbody>
25707 <tr><td>foo-bar</td><td>foo+bar</td></tr>
25708 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
25709 <tr><td>foo
25710 <p>bar|baz
25711 +bar
25712 -bar</p></td></tr>
25713 <tr><td>x
25714 <div>a|b</div></td>
25715 </tbody></table>
25716 !! wikitext
25717 {|
25718 |foo-bar
25719 |foo+bar
25720 |-
25721 |''foo''-bar
25722 |''foo''+bar
25723 |-
25724 |foo
25725 bar|baz
25726 +bar
25727 -bar
25728 |-
25729 |x
25730 <div>a|b</div>
25731 |}
25732 !! html/php
25733 <table>
25734 <tr>
25735 <td>foo-bar
25736 </td>
25737 <td>foo+bar
25738 </td></tr>
25739 <tr>
25740 <td><i>foo</i>-bar
25741 </td>
25742 <td><i>foo</i>+bar
25743 </td></tr>
25744 <tr>
25745 <td>foo
25746 <p>bar|baz
25747 +bar
25748 -bar
25749 </p>
25750 </td></tr>
25751 <tr>
25752 <td>x
25753 <div>a|b</div>
25754 </td></tr></table>
25755
25756 !! end
25757
25758 !! test
25759 Tables: 4d. No escaping needed
25760 !! options
25761 parsoid=html2wt
25762 !! html/parsoid
25763 <table>
25764 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
25765 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
25766 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
25767 </tbody></table>
25768 !! wikitext
25769 {|
25770 |[[Foo]]-bar
25771 ||+1
25772 ||-2
25773 |}
25774 !! html/php
25775 <table>
25776 <tr>
25777 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
25778 </td>
25779 <td>+1
25780 </td>
25781 <td>-2
25782 </td></tr></table>
25783
25784 !! end
25785
25786 !! test
25787 T97430: Don't emit empty nowiki pairs around marker meta tags
25788 !! options
25789 parsoid=html2wt
25790 !! html/parsoid
25791 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25792 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
25793 !! wikitext
25794 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25795 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
25796 !! end
25797
25798 !! test
25799 Unclosed xmlish element in table line shouldn't eat end delimiters
25800 !! options
25801 parsoid=html2wt
25802 !! html/parsoid
25803 <table>
25804 <tbody><tr><td> &lt;foo</td>
25805 <td> bar></td></tr>
25806 </tbody></table>
25807 !! wikitext
25808 {|
25809 | <foo
25810 | bar>
25811 |}
25812 !! html/php
25813 <table>
25814 <tr>
25815 <td>&lt;foo
25816 </td>
25817 <td>bar&gt;
25818 </td></tr></table>
25819
25820 !! end
25821
25822 #### --------------- Links ----------------
25823 #### 1. Quote marks in link text
25824 #### 2. Wikilinks: Escapes needed
25825 #### 3. Wikilinks: No escapes needed
25826 #### 4. Extlinks: Escapes needed
25827 #### 5. Extlinks: No escapes needed
25828 #### --------------------------------------
25829 !! test
25830 Links 1. WikiLinks: No escapes needed
25831 !! options
25832 parsoid=html2wt
25833 !! html/parsoid
25834 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
25835 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
25836 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
25837 !! wikitext
25838 [[Foo|Foo''boo'']]
25839 [[Foo|[Foobar]]]
25840 [[Foo|x [Foobar] x]]
25841 !! html/php
25842 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
25843 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
25844 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
25845 </p>
25846 !! end
25847
25848 !! test
25849 Links 2. WikiLinks: Escapes needed
25850 !! options
25851 parsoid=html2wt
25852 !! html/parsoid
25853 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
25854 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
25855 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
25856 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
25857 <a href="Foo" rel="mw:WikiLink">|Bar</a>
25858 <a href="Foo" rel="mw:WikiLink">]]bar</a>
25859 <a href="Foo" rel="mw:WikiLink">[[bar</a>
25860 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
25861 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
25862 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
25863 !! wikitext
25864 [[Foo|<nowiki>Foobar]</nowiki>]]
25865 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
25866 [[Foo|<nowiki>[[Bar]]</nowiki>]]
25867 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
25868 [[Foo|<nowiki>|Bar</nowiki>]]
25869 [[Foo|<nowiki>]]bar</nowiki>]]
25870 [[Foo|<nowiki>[[bar</nowiki>]]
25871 [[Foo|<nowiki>x [[ y</nowiki>]]
25872 [[Foo|<nowiki>x ]] y</nowiki>]]
25873 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
25874 !! html/php
25875 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
25876 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
25877 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
25878 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
25879 <a href="/wiki/Foo" title="Foo">|Bar</a>
25880 <a href="/wiki/Foo" title="Foo">]]bar</a>
25881 <a href="/wiki/Foo" title="Foo">[[bar</a>
25882 <a href="/wiki/Foo" title="Foo">x [[ y</a>
25883 <a href="/wiki/Foo" title="Foo">x ]] y</a>
25884 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
25885 </p>
25886 !! end
25887
25888 !! test
25889 Links 3. WikiLinks: No escapes needed
25890 !! options
25891 parsoid=html2wt
25892 !! html/parsoid
25893 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
25894 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
25895 !! wikitext
25896 [[Foo|[Foobar]]
25897 [[Foo|foo|bar]]
25898 !! html/php
25899 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
25900 <a href="/wiki/Foo" title="Foo">foo|bar</a>
25901 </p>
25902 !! end
25903
25904 !! test
25905 Links 4. ExtLinks: Escapes needed
25906 !! options
25907 parsoid=html2wt
25908 !! html/parsoid
25909 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
25910 <a rel="mw:ExtLink" href="http://google.com">google]</a>
25911 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
25912 <p>[http://google.com]</p>
25913 <p>[http://google.com google]</p>
25914 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
25915 <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>
25916 !! wikitext
25917 [http://google.com <nowiki>[google]</nowiki>]
25918 [http://google.com <nowiki>google]</nowiki>]
25919 [http://google.com <nowiki>goog] le</nowiki>]
25920
25921 <nowiki>[http://google.com]</nowiki>
25922
25923 <nowiki>[http://google.com google]</nowiki>
25924
25925 [http://google.com<nowiki>]</nowiki>
25926
25927 [{{echo|http://google.com}}<nowiki>]</nowiki>
25928 !! html/php
25929 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
25930 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
25931 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
25932 </p><p>[http://google.com]
25933 </p><p>[http://google.com google]
25934 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
25935 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
25936 </p>
25937 !! end
25938
25939 !! test
25940 Links 5. ExtLinks: No escapes needed
25941 !! options
25942 parsoid=html2wt
25943 !! html/parsoid
25944 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
25945 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
25946 !! wikitext
25947 [http://google.com [google]
25948
25949 [[http://google.com]]
25950 !! html/php
25951 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
25952 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
25953 </p>
25954 !! end
25955
25956 !! test
25957 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
25958 !! options
25959 parsoid=html2wt
25960 !! html/parsoid
25961 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
25962 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
25963 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
25964 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
25965 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
25966 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
25967 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
25968 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
25969 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
25970 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
25971 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
25972 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
25973 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
25974 </p>
25975 !! wikitext
25976 x<nowiki/>http://example.com<nowiki/>y
25977 http://example.com<nowiki/>?x
25978 http://example.com<nowiki/>&x
25979 http://example.com<nowiki/>'x
25980 http://example.com<nowiki/>,x
25981 http://example.com<nowiki/>.x
25982 http://example.com<nowiki/>;x
25983 http://example.com<nowiki/>:x
25984 http://example.com<nowiki/>;x
25985 http://example.com<nowiki/>!x
25986 http://example.com<nowiki/>=x
25987 http://example.com<nowiki/>(x)
25988 http://example.com(x<nowiki/>)
25989 !! end
25990
25991 !! test
25992 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
25993 !! options
25994 parsoid=html2wt
25995 !! html/parsoid
25996 <p>x
25997 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
25998 y
25999 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
26000 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
26001 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
26002 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
26003 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
26004 </p>
26005 !! wikitext
26006 x
26007 http://example.com
26008 y
26009 "http://example.com"
26010 (http://example.com)
26011 (http://example.com) foo
26012 http://example.com,
26013 http://example.com, foo
26014 !! html/php
26015 <p>x
26016 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
26017 y
26018 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
26019 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
26020 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
26021 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
26022 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
26023 </p>
26024 !! end
26025
26026 !! test
26027 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
26028 !! options
26029 parsoid=html2wt
26030 !! html/parsoid
26031 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
26032 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
26033 !! wikitext
26034 http://example.com.,;:!?\
26035 -http://example.com:
26036 !! html/php
26037 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
26038 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
26039 </p>
26040 !! end
26041
26042 !! test
26043 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
26044 !! options
26045 parsoid=html2wt
26046 !! html/parsoid
26047 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
26048 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
26049 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
26050 !! wikitext
26051 RFC 123<nowiki/>4
26052 RFC 123<nowiki/>y
26053 X<nowiki/>RFC 123<nowiki/>y
26054 !! end
26055
26056 !! test
26057 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
26058 !! options
26059 parsoid=html2wt
26060 !! html/parsoid
26061 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
26062 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
26063 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
26064 </p>
26065 !! wikitext
26066 RFC 123?foo
26067 RFC 123&foo
26068 -RFC 123-
26069 !! html/php
26070 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
26071 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
26072 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
26073 </p>
26074 !! end
26075
26076 !! test
26077 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
26078 !! options
26079 parsoid=html2wt
26080 !! html/parsoid
26081 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
26082 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
26083 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
26084 !! wikitext
26085 PMID 123<nowiki/>4
26086 PMID 123<nowiki/>y
26087 X<nowiki/>PMID 123<nowiki/>y
26088 !! end
26089
26090 !! test
26091 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
26092 !! options
26093 parsoid=html2wt
26094 !! html/parsoid
26095 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
26096 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
26097 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
26098 </p>
26099 !! wikitext
26100 PMID 123?foo
26101 PMID 123&foo
26102 -PMID 123-
26103 !! html/php
26104 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
26105 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
26106 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
26107 </p>
26108 !! end
26109
26110 !! test
26111 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
26112 !! options
26113 parsoid=html2wt
26114 !! html/parsoid
26115 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
26116 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
26117 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
26118 </p>
26119 !! wikitext
26120 ISBN 1234567890<nowiki/>1
26121 ISBN 1234567890<nowiki/>x
26122 a<nowiki/>ISBN 1234567890<nowiki/>b
26123 !! end
26124
26125 !! test
26126 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
26127 !! options
26128 parsoid=html2wt
26129 !! html/parsoid
26130 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
26131 !! wikitext
26132 -ISBN 1234567890's
26133 !! html/php
26134 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
26135 </p>
26136 !! end
26137
26138 !! test
26139 Links 14. Protect link-like plain text. (Parsoid bug T78425)
26140 !! options
26141 parsoid=html2wt
26142 !! html/*
26143 <p>this is not a link: http://example.com
26144 </p>
26145 !! wikitext
26146 this is not a link: <nowiki>http://example.com</nowiki>
26147 !! end
26148
26149 !! test
26150 Links 15. Link trails can't become link prefixes.
26151 !! options
26152 language=is
26153 parsoid=html2wt
26154 !! html/parsoid
26155 <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>
26156 !! wikitext
26157 [[Söfnuður]]-[[00]]
26158 !! html/php
26159 <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>
26160 </p>
26161 !! end
26162
26163 #### --------------- Quotes ---------------
26164 #### 1. Quotes inside <b> and <i>
26165 #### 2. Link fragments separated by <i> and <b> tags
26166 #### 3. Link fragments inside <i> and <b>
26167 #### 4. No escaping needed
26168 #### --------------------------------------
26169 !! test
26170 1a. Quotes inside <b> and <i>
26171 !! options
26172 parsoid=html2wt
26173 !! html/*
26174 <p><i>'foo'</i>
26175 <i>''foo''</i>
26176 <i>'''foo'''</i>
26177 <i>foo</i>'s
26178 <b>'foo'</b>
26179 <b>''foo''</b>
26180 <b>'''foo'''</b>
26181 <b>foo'<i>bar'</i>baz</b>
26182 <b>foo</b>'s
26183 '<i>foo</i>
26184 <i>foo</i>'
26185 <i>foo'</i>'
26186 '<i>foo</i>'
26187 '<b>foo</b>
26188 <b>foo</b>'
26189 '<b>foo</b>'
26190 <i>fools'<span> errand</span></i>
26191 <i><span>fool</span>'s errand</i>
26192 '<i>foo</i> bar '<i>baz</i>
26193 a|!*#-:;+-~[]{}b'<i>x</i>
26194 </p>
26195 !! wikitext
26196 ''<nowiki/>'foo'''
26197 ''<nowiki>''foo''</nowiki>''
26198 ''<nowiki>'''foo'''</nowiki>''
26199 ''foo''<nowiki/>'s
26200 '''<nowiki/>'foo''''
26201 '''<nowiki>''foo''</nowiki>'''
26202 '''<nowiki>'''foo'''</nowiki>'''
26203 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
26204 '''foo'''<nowiki/>'s
26205 '''foo''
26206 ''foo''<nowiki/>'
26207 ''foo'''<nowiki/>'
26208 '''foo''<nowiki/>'
26209 ''''foo'''
26210 '''foo'''<nowiki/>'
26211 ''''foo'''<nowiki/>'
26212 ''fools'<span> errand</span>''
26213 ''<span>fool</span>'s errand''
26214 '<nowiki/>''foo'' bar '''baz''
26215 a|!*#-:;+-~[]{}b'''x''
26216 !! end
26217
26218 !! test
26219 1b. Quotes inside <b> and <i> with other tags on same line
26220 !! options
26221 parsoid=html2wt
26222 !! html/parsoid
26223 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26224 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26225 <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>
26226 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
26227 '<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>
26228 '<i>foo</i> <div title="name">test</div>
26229 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
26230 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
26231 <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>
26232 </ol>
26233 !! wikitext
26234 '''a'' foo ''[[bar]]''
26235 ''a''' foo ''[[bar]]''
26236 ''a''' foo '''{{echo|[[bar]]}}'''
26237 [[foo]] x'''[[bar]]''
26238 '''foo'' <ref>test</ref>
26239 '''foo'' <div title="name">test</div>
26240 '''foo'' and <br> bar
26241 <references />
26242 !! end
26243
26244 !! test
26245 2. Link fragments separated by <i> and <b> tags
26246 !! options
26247 parsoid=html2wt
26248 !! html/parsoid
26249 <p>[[<i>foo</i>hello]]</p>
26250 <p>[[<b>foo</b>hello]]</p>
26251 !! wikitext
26252 [[''foo''<nowiki>hello]]</nowiki>
26253
26254 [['''foo'''<nowiki>hello]]</nowiki>
26255 !! end
26256
26257 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
26258 # this is one of the shortcomings of this format
26259 !! test
26260 3. Link fragments inside <i> and <b>
26261 !! options
26262 parsoid=html2wt
26263 !! html/parsoid
26264 <p><i>[[foo</i>]]</p>
26265 <p><b>[[foo</b>]]</p>
26266 !! wikitext
26267 ''[[foo''<nowiki>]]</nowiki>
26268
26269 '''[[foo'''<nowiki>]]</nowiki>
26270 !! end
26271
26272 !! test
26273 4. No escaping needed
26274 !! options
26275 parsoid=html2wt
26276 !! html/parsoid
26277 <p>'<span><i>bar</i></span>'
26278 '<span><b>bar</b></span>'
26279 'a:b'foo
26280 </p>
26281 !! wikitext
26282 '<span>''bar''</span>'
26283 '<span>'''bar'''</span>'
26284 'a:b'foo
26285 !! end
26286
26287 #### ----------- Paragraphs ---------------
26288 #### 1. No unnecessary escapes
26289 #### --------------------------------------
26290
26291 !! test
26292 1. No unnecessary escapes
26293 !! options
26294 parsoid=html2wt
26295 !! html/parsoid
26296 <p>bar <span>[[foo]]</span>
26297 </p><p>=bar <span>[[foo]]</span>
26298 </p><p>[[bar <span>[[foo]]</span>
26299 </p><p>]]bar <span>[[foo]]</span>
26300 </p><p>=bar <span>foo]]</span>=
26301 </p>
26302 !! wikitext
26303 bar <span><nowiki>[[foo]]</nowiki></span>
26304
26305 =bar <span><nowiki>[[foo]]</nowiki></span>
26306
26307 [[bar <span><nowiki>[[foo]]</nowiki></span>
26308
26309 ]]bar <span><nowiki>[[foo]]</nowiki></span>
26310
26311 =bar <span>foo]]</span><nowiki>=</nowiki>
26312 !!end
26313
26314 #### ----------------------- PRE --------------------------
26315 #### 1. Leading whitespace in SOL context should be escaped
26316 #### ------------------------------------------------------
26317 !! test
26318 1. Leading whitespace in SOL context should be escaped
26319 !! options
26320 parsoid=html2wt
26321 !! html/parsoid
26322 <p> a</p>
26323
26324 <p> a</p>
26325
26326 <p> a(tab)</p>
26327
26328 <p> a
26329 <!--cmt-->
26330 a</p>
26331
26332 <p>a
26333 b</p>
26334
26335 <p>a
26336 b</p>
26337
26338 <p>a
26339 b</p>
26340 !! wikitext
26341 <nowiki> </nowiki>a
26342
26343 <nowiki> </nowiki> a
26344
26345 a(tab)
26346
26347 <nowiki> </nowiki> a
26348 <!--cmt-->
26349 <nowiki> </nowiki>a
26350
26351 a
26352 <nowiki> </nowiki>b
26353
26354 a
26355 b
26356
26357 a
26358 b
26359 !! html/php
26360 <p> a
26361 </p><p> a
26362 </p><p> a(tab)
26363 </p><p> a
26364 a
26365 </p><p>a
26366 b
26367 </p><p>a
26368 b
26369 </p><p>a
26370 b
26371 </p>
26372 !! end
26373
26374 !! test
26375 2. Leading whitespace in non-indent-pre contexts should not be escaped
26376 !! options
26377 parsoid=html2wt
26378 !! html/parsoid
26379 <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>
26380 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
26381 <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>
26382 b</span></li>
26383 </ol>
26384 !! wikitext
26385 foo <ref>''a''
26386 b</ref>
26387 <references />
26388 !! end
26389
26390 !! test
26391 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
26392 !! options
26393 parsoid=html2wt
26394 !! html/parsoid
26395 <blockquote>
26396 <p>
26397 a
26398 <span>b</span>
26399 c</p>
26400 </blockquote>
26401 !! wikitext
26402 <blockquote>
26403 a
26404 <span>b</span>
26405 c
26406 </blockquote>
26407 !! end
26408
26409 !! test
26410 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
26411 !! options
26412 parsoid=html2wt
26413 !! html/parsoid
26414 <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>
26415 !! wikitext
26416 [[File:Foobar.jpg|thumb|caption]]
26417 !! end
26418
26419 !! test
26420 5. Nowiki escaping should account for indent-pres
26421 !! options
26422 parsoid=html2wt
26423 !! html/parsoid
26424 <pre>==foo==</pre>
26425 !! wikitext
26426 ==foo==
26427 !! end
26428
26429 !!test
26430 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
26431 !! options
26432 parsoid=html2wt
26433 !! html/parsoid
26434 <pre>
26435 * foo
26436 * bar
26437 </pre>
26438 !! wikitext
26439 * foo
26440 * bar
26441 !! end
26442
26443 #### --------------- Behavior Switches --------------------
26444
26445 !! test
26446 1. Valid behavior switches should be escaped
26447 !! options
26448 parsoid=html2wt
26449 !! html/parsoid
26450 __TOC__
26451 <i>__TOC__</i>
26452 !! wikitext
26453 <nowiki>__TOC__</nowiki>
26454 ''<nowiki>__TOC__</nowiki>''
26455 !! end
26456
26457 !! test
26458 2. Invalid behavior switches should not be escaped
26459 !! options
26460 parsoid=html2wt
26461 !! html/parsoid
26462 __TOO__
26463 __|__
26464 !! wikitext
26465 __TOO__
26466 __|__
26467 !! end
26468
26469 # We use indent-pre as an indirect way to test for sol-transparent behavior.
26470 !! test
26471 Behavior switches should be SOL-transparent
26472 !! options
26473 parsoid=html2wt
26474 !! html/parsoid
26475 <meta property="mw:PageProp/toc" />
26476
26477 <!-- this one's bogus -->
26478 <pre>__TOO__</pre>
26479
26480 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
26481
26482 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
26483 !! wikitext
26484 __TOC__
26485
26486 <!-- this one's bogus -->
26487 __TOO__
26488
26489 __TOC__ foo
26490
26491 __TOC__
26492 bar
26493 !! end
26494
26495 #### --------------- HTML tags ---------------
26496 #### 1. a tags
26497 #### 2. other tags
26498 #### 3. multi-line html tag
26499 #### 4. extension tags
26500 #### -----------------------------------------
26501 !! test
26502 1. a tags
26503 !! options
26504 parsoid=html2wt
26505 !! html/parsoid
26506 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
26507 !! wikitext
26508 <a href="http://google.com">google</a>
26509 !! end
26510
26511 !! test
26512 2. other tags
26513 !! options
26514 parsoid=html2wt
26515 !! html/parsoid
26516 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
26517 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
26518 <li> &lt;td&gt;</li></ul>
26519
26520 !! wikitext
26521 * <nowiki><div>foo</div></nowiki>
26522 * <nowiki><div style="color:red">foo</div></nowiki>
26523 * <nowiki><td></nowiki>
26524 !! end
26525
26526 !! test
26527 3. multi-line html tag
26528 !! options
26529 parsoid=html2wt
26530 !! html/parsoid
26531 <p>&lt;div
26532 &gt;foo&lt;/div
26533 &gt;
26534 </p>
26535 !! wikitext
26536 <nowiki><div
26537 >foo</div
26538 ></nowiki>
26539 !! end
26540
26541 !! test
26542 4. extension tags
26543 !! options
26544 parsoid=html2wt
26545 !! html/parsoid
26546 <p>&lt;ref&gt;foo&lt;/ref&gt;
26547 </p><p>&lt;ref&gt;bar
26548 </p><p>baz&lt;/ref&gt;
26549 </p>
26550 !! wikitext
26551 <nowiki><ref>foo</ref></nowiki>
26552
26553 <nowiki><ref>bar</nowiki>
26554
26555 baz<nowiki></ref></nowiki>
26556 !! end
26557
26558 #### --------------- Others ---------------
26559 !! test
26560 Escaping nowikis
26561 !! options
26562 parsoid=html2wt
26563 !! html/parsoid
26564 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
26565 </p>
26566 !! wikitext
26567 &lt;nowiki&gt;foo&lt;/nowiki&gt;
26568 !! end
26569
26570 ## The quote-char in the input is necessary for triggering the bug
26571 !! test
26572 (T54035) Nowiki-escaping should not get tripped by " :" in text
26573 !! options
26574 parsoid=html2wt
26575 !! html/parsoid
26576 <p>foo's bar :</p>
26577 !! wikitext
26578 foo's bar :
26579 !! end
26580
26581 #----------- End of wikitext escaping tests --------------
26582
26583 !! test
26584
26585 Tag-like HTML structures are passed through as text
26586 !! wikitext
26587 <x y>
26588
26589 <x.y>
26590
26591 <x-y>
26592
26593 1>2
26594
26595 x<y
26596
26597 a>b
26598
26599 1<d e>f
26600 !! html
26601 <p>&lt;x y&gt;
26602 </p><p>&lt;x.y&gt;
26603 </p><p>&lt;x-y&gt;
26604 </p><p>1&gt;2
26605 </p><p>x&lt;y
26606 </p><p>a&gt;b
26607 </p><p>1&lt;d e&gt;f
26608 </p>
26609 !! end
26610
26611 !! test
26612 HTML tag with necessary entities in attributes
26613 !! wikitext
26614 <span title="&amp;amp;">foo</span>
26615 !! html
26616 <p><span title="&amp;amp;">foo</span>
26617 </p>
26618 !! end
26619
26620 !! test
26621 HTML tag with 'unnecessary' entity encoding in attributes
26622 !! wikitext
26623 <span title="&amp;">foo</span>
26624 !! html
26625 <p><span title="&amp;">foo</span>
26626 </p>
26627 !! end
26628
26629 !! test
26630 HTML tag with broken attribute value quoting
26631 !! options
26632 parsoid=wt2html,html2html
26633 !! wikitext
26634 <span title="Hello world>Foo</span>
26635 !! html/php
26636 <p><span title="Hello world">Foo</span>
26637 </p>
26638 !! html/parsoid
26639 <p><span title="Hello world">Foo</span></p>
26640 !! end
26641
26642 !! test
26643 Self-closed tag with broken attribute value quoting
26644 !! options
26645 parsoid=wt2html,html2html
26646 !! wikitext
26647 <div title="Hello world />Foo
26648 !! html/php+tidy
26649 <div title="Hello world"></div><p>Foo
26650 </p>
26651 !! html/parsoid
26652 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
26653 !! end
26654
26655 !! test
26656 Table with broken attribute value quoting
26657 !! options
26658 parsoid=wt2html,html2html
26659 !! wikitext
26660 {|
26661 | title="Hello world|Foo
26662 |}
26663 !! html/php
26664 <table>
26665 <tr>
26666 <td title="Hello world">Foo
26667 </td></tr></table>
26668
26669 !! html/parsoid
26670 <table>
26671 <tr>
26672 <td title="Hello world">Foo
26673 </td></tr></table>
26674
26675 !! end
26676
26677 !! test
26678 Table with broken attribute value quoting on consecutive lines
26679 !! options
26680 parsoid=wt2html,html2html
26681 !! wikitext
26682 {|
26683 | title="Hello world|Foo
26684 | style="color:red|Bar
26685 |}
26686 !! html/php
26687 <table>
26688 <tr>
26689 <td title="Hello world">Foo
26690 </td>
26691 <td style="color:red">Bar
26692 </td></tr></table>
26693
26694 !! html/parsoid
26695 <table><tbody>
26696 <tr>
26697 <td title="Hello world">Foo
26698 </td><td style="color: red">Bar
26699 </td></tr></tbody></table>
26700
26701 !! end
26702
26703 !!test
26704 Accept empty td cell attribute
26705 !! wikitext
26706 {|
26707 | align="center" |foo|| |
26708 |}
26709 !! html
26710 <table>
26711 <tr>
26712 <td align="center">foo</td>
26713 <td>
26714 </td></tr></table>
26715
26716 !!end
26717
26718 !!test
26719 Non-empty attributes in th-cells
26720 !! wikitext
26721 {|
26722 !Foo!! style="color: red" |Bar
26723 |}
26724 !! html
26725 <table>
26726 <tr>
26727 <th>Foo</th>
26728 <th style="color: red">Bar
26729 </th></tr></table>
26730
26731 !!end
26732
26733 !!test
26734 Accept empty attributes in th-cells
26735 !! wikitext
26736 {|
26737 !|foo!!|bar
26738 |}
26739 !! html
26740 <table>
26741 <tr>
26742 <th>foo</th>
26743 <th>bar
26744 </th></tr></table>
26745
26746 !!end
26747
26748 !!test
26749 Empty table rows go away
26750 !! wikitext
26751 {|
26752 |Hello
26753 |there
26754 |- class="foo"
26755 |-
26756 |}
26757 !! html
26758 <table>
26759 <tr>
26760 <td>Hello
26761 </td>
26762 <td>there
26763 </td></tr>
26764
26765 </table>
26766
26767 !! end
26768
26769 ###
26770 ### Parsoid-centric tests for testing RTing of inter-element separators
26771 ### Edge cases not tested by existing parser tests and specific to
26772 ### Parsoid-specific serialization strategies.
26773 ###
26774
26775 !!test
26776 RT-ed inter-element separators should be valid separators
26777 !! wikitext
26778 {|
26779 |- [[foo]]
26780 |}
26781 !! html/php
26782 <table>
26783
26784 </table>
26785
26786 !! html/parsoid
26787 <table>
26788 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
26789 </tbody></table>
26790 !!end
26791
26792 # Parsoid-only test of a DOM pass
26793 !!test
26794 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
26795 !! wikitext
26796 {|
26797 |<small>foo
26798 bar
26799 |}
26800
26801 {|
26802 |<small>foo<small>
26803 |}
26804 !! html/parsoid
26805 <table>
26806 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
26807 <p>bar</p></small></td></tr>
26808 </tbody></table>
26809
26810 <table>
26811 <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>
26812 </tbody></table>
26813 !!end
26814
26815 # Note that the "style" attribute is really a template parameter here.
26816 # The = would have to be {{=}} if you wanted the literal.
26817 !!test
26818 Empty TD followed by TD with tpl-generated attribute
26819 !! wikitext
26820 {|
26821 |-
26822 |
26823 |{{echo|style='color:red'}}|foo
26824 |}
26825 !! html
26826 <table>
26827
26828 <tr>
26829 <td>
26830 </td>
26831 <td>foo
26832 </td></tr></table>
26833
26834 !!end
26835
26836 !!test
26837 Indented table with an empty td
26838 !! wikitext
26839 {|
26840 |-
26841 |
26842 |foo
26843 |}
26844 !! html
26845 <table>
26846
26847 <tr>
26848 <td>
26849 </td>
26850 <td>foo
26851 </td></tr></table>
26852
26853 !!end
26854
26855 ## We have some newline diffs RT-ing this edge case
26856 ## and it is not important enough -- we seem to be emitting
26857 ## at most 2 newlines after a </tr> and this is unrelated to
26858 ## the issue from T85627 that this is testing.
26859 !!test
26860 Indented table with blank lines in between (T85627)
26861 !! options
26862 parsoid=wt2html
26863 !! wikitext
26864 {|
26865 |foo
26866
26867
26868 |}
26869 !! html
26870 <table>
26871
26872 <tr>
26873 <td>foo
26874 </td></tr></table>
26875
26876 !!end
26877
26878 !!test
26879 Indented block & table
26880 !! wikitext
26881 <div>foo</div>
26882 {|
26883 |foo
26884 |}
26885 !! html/php
26886 <div>foo</div>
26887 <table>
26888 <tr>
26889 <td>foo
26890 </td></tr></table>
26891
26892 !! html/parsoid
26893 <div data-parsoid='{"stx":"html"}'>foo</div>
26894 <table><tbody>
26895 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
26896 </tbody></table>
26897 !!end
26898
26899 !! test
26900 Indent and comment before table row
26901 !! wikitext
26902 {|
26903 <!--hi-->|-
26904 |there
26905 |}
26906 !! html/php
26907 <table>
26908
26909 <tr>
26910 <td>there
26911 </td></tr></table>
26912
26913 !! html/parsoid
26914 <table>
26915 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
26916 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
26917 </tbody></table>
26918 !! end
26919
26920 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
26921 !!test
26922 Empty TR followed by a template-generated TR
26923 !!options
26924 parsoid
26925 !! wikitext
26926 {|
26927 |-
26928 {{echo|<tr><td>foo</td></tr>}}
26929 |}
26930 !! html
26931 <table>
26932 <tbody>
26933 <tr class='mw-empty-elt'></tr>
26934 <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}}]}'>
26935 <td>foo</td></tr>
26936 </tbody></table>
26937 !!end
26938
26939 ## PHP and parsoid output differ for this, and since this is primarily
26940 ## for testing Parsoid's serializer, marking this Parsoid only
26941 !!test
26942 Empty TR followed by mixed-ws-comment line should RT correctly
26943 !!options
26944 parsoid
26945 !! wikitext
26946 {|
26947 |-
26948 <!--c-->
26949 |-
26950 <!--c--> <!--d-->
26951 |}
26952 !! html
26953 <table>
26954 <tbody>
26955 <tr class='mw-empty-elt'></tr>
26956 <!--c-->
26957 <tr>
26958 <!--c--> </tr><!--d-->
26959 </tbody></table>
26960
26961 !!end
26962
26963 !!test
26964 Multi-line image caption generated by templates with/without trailing newlines
26965 !! wikitext
26966 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
26967 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
26968 !! html/parsoid
26969 <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>
26970 <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>
26971 !!end
26972
26973 !! test
26974 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
26975 !! options
26976 parsoid=html2wt
26977 !! html/parsoid
26978 <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>
26979
26980 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
26981 !! wikitext
26982 <includeonly>foo</includeonly>
26983 new para
26984
26985 [[Category:Foo]]
26986
26987 = new heading =
26988 !! end
26989
26990 ## PHP emits broken html for this, and since this is primarily
26991 ## a Parsoid serializer test, marking this Parsoid only
26992 !!test
26993 Improperly nested inline or quotes tags with whitespace in between
26994 !! wikitext
26995 <span> <s>x</span> </s>
26996 ''' ''x''' ''
26997 !! html/parsoid
26998 <p><span> <s>x</s></span><s> </s>
26999 <b> <i>x</i></b><i> </i>
27000 </p>
27001 !!end
27002
27003 !!test
27004 Encapsulate protected attributes from wt
27005 !! wikitext
27006 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
27007
27008 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
27009 | ok
27010 |}
27011 !! html/parsoid
27012 <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>
27013
27014 <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">
27015 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'> ok</td></tr>
27016 </tbody></table>
27017 !!end
27018
27019 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
27020 ## Having nested or stray pre tags results in the attempt to add duplicates,
27021 ## causing an assertion fail. This test tries to prevent that situation.
27022 !!test
27023 Ensure ParagraphWrapper can deal with stray closing pre tags
27024 !!options
27025 parsoid=wt2html
27026 !! wikitext
27027 plain text</pre>
27028 !! html/parsoid
27029 plain text
27030 !!end
27031
27032 !!test
27033 1. Ensure fostered text content is wrapped in element nodes
27034 !!options
27035 parsoid=wt2html
27036 !! wikitext
27037 <table>hi</table><table>ho</table>
27038 !! html/parsoid
27039 <p>hi</p>
27040 <table></table>
27041 <p>ho</p>
27042 <table></table>
27043 !!end
27044
27045 !!test
27046 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
27047 !!options
27048 parsoid=wt2html,wt2wt
27049 !! wikitext
27050 <table>
27051 <tr> || ||
27052 <td> a
27053 </table>
27054 !! html/parsoid
27055 <p> || ||
27056 </p><table>
27057 <tbody><tr><td> a</td></tr>
27058 </tbody></table>
27059 !!end
27060
27061 !!test
27062 Encapsulation properly handles null DSR information from foster box
27063 !!options
27064 parsoid=wt2html,wt2wt
27065 !! wikitext
27066 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
27067 !! html/parsoid
27068 <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>
27069 !!end
27070
27071 !!test
27072 1. Encapsulate foster-parented transclusion content
27073 !!options
27074 parsoid=wt2wt,wt2html
27075 !! wikitext
27076 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
27077 !! html/parsoid
27078 <p typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table>&quot;,{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo<tr><td>bar</td></tr>&quot;}},&quot;i&quot;:0}},&quot;</table>&quot;]}">foo</p><table>
27079 <tbody>
27080 <tr>
27081 <td>bar</td>
27082 </tr>
27083 </tbody>
27084 </table>
27085 !!end
27086
27087 !!test
27088 2. Encapsulate foster-parented transclusion content
27089 !!options
27090 parsoid=wt2wt,wt2html
27091 !! wikitext
27092 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
27093 !! html/parsoid
27094 <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>
27095 <table>
27096 <tbody>
27097 <tr>
27098 <td>bar</td>
27099 </tr>
27100 </tbody>
27101 </table>
27102 !!end
27103
27104 !!test
27105 3. Encapsulate foster-parented transclusion content
27106 !!options
27107 parsoid=wt2wt,wt2html
27108 !! wikitext
27109 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
27110 !! html/parsoid
27111 <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;]}">
27112 <p>foo</p>
27113 </div>
27114 <table>
27115 <tbody>
27116 <tr>
27117 <td>bar</td>
27118 </tr>
27119 </tbody>
27120 </table>
27121 !!end
27122
27123 !!test
27124 4. Encapsulate foster-parented transclusion content
27125 !!options
27126 parsoid=wt2wt,wt2html
27127 !! wikitext
27128 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
27129 !! html/parsoid
27130 <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;]}">
27131 <p>foo</p>
27132 </div>
27133 <table>
27134 <tbody>
27135 <tr>
27136 <td>bar</td>
27137 </tr>
27138 </tbody>
27139 </table>
27140 !!end
27141
27142 !!test
27143 5. Encapsulate foster-parented transclusion content
27144 !!options
27145 parsoid=wt2wt,wt2html
27146 !! wikitext
27147 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
27148 !! html/parsoid
27149 <p typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table><tr><td><div><p>&quot;,{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo</p></div></td>foo&quot;}},&quot;i&quot;:0}},&quot;</tr></table>&quot;]}">foo</p>
27150 <table>
27151 <tbody>
27152 <tr>
27153 <td>
27154 <div>
27155 <p>foo</p>
27156 </div>
27157 </td>
27158 </tr>
27159 </tbody>
27160 </table>
27161 !!end
27162
27163 !!test
27164 6. Encapsulate foster-parented transclusion content
27165 !!options
27166 parsoid=wt2wt,wt2html
27167 !! wikitext
27168 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
27169 !! html/parsoid
27170 <p typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table><tr><td><div><p>&quot;,{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo</p></div></td>foo</tr></table>&quot;}},&quot;i&quot;:0}}]}">foo</p>
27171 <table>
27172 <tbody>
27173 <tr>
27174 <td>
27175 <div>
27176 <p>foo</p>
27177 </div>
27178 </td>
27179 </tr>
27180 </tbody>
27181 </table>
27182 <p>ok</p>
27183 !!end
27184
27185 !!test
27186 7. Encapsulate foster-parented transclusion content
27187 !!options
27188 parsoid=wt2wt,wt2html
27189 !! wikitext
27190 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
27191 !! html/parsoid
27192 <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>
27193 <table>
27194 <tbody>
27195 <tr>
27196 <td>bar</td>
27197 </tr>
27198 </tbody>
27199 </table>
27200 !!end
27201
27202 # Note that the wt is broken on purpose: the = should be {{=}} if you
27203 # don't want it to be a template parameter key.
27204 !!test
27205 8. Encapsulate foster-parented transclusion content
27206 !!options
27207 parsoid=wt2wt,wt2html
27208 !! wikitext
27209 {{echo|a
27210 }}{|{{echo|style='color:red'}}
27211 |-
27212 |b
27213 |}
27214 !! html/parsoid
27215 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}'>a</p>
27216 <span> </span>
27217 <p typeof="mw:Transclusion" data-mw='{"parts":["{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"style":{"wt":"&#39;color:red&#39;"}},"i":0}},"\n|-\n|b\n|}"]}'>{{{1}}}</p>
27218 <table>
27219 <tbody>
27220 <tr>
27221 <td>b</td>
27222 </tr>
27223 </tbody>
27224 </table>
27225 !!end
27226
27227 !!test
27228 9. Encapsulate foster-parented transclusion content
27229 !!options
27230 parsoid=wt2wt,wt2html
27231 !! wikitext
27232 <table>{{echo|hi</table>hello}}
27233 !! html/parsoid
27234 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":["&lt;table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;/table>hello"}},"i":0}}]}' data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"pi":[[{"k":"1"}]]}'>hi</p><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><p about="#mwt2">hello</p>
27235 !!end
27236
27237 !!test
27238 Table in fosterable position
27239 !!options
27240 parsoid=wt2html
27241 !! wikitext
27242 {{OpenTable}}
27243 <div>
27244 {|
27245 |}
27246 </div>
27247 |}
27248 !! html/parsoid
27249 <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">
27250 </span>
27251 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
27252
27253 <table>
27254 </table>
27255 !!end
27256
27257 # Parsoid only for T66747
27258 !! test
27259 Properly encapsulate empty-content transclusions in fosterable positions
27260 !! wikitext
27261 <table>
27262 {{#if:|
27263 <td>foo</td>
27264 }}
27265 </table>
27266 !! html/parsoid
27267 <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"}]]}'>
27268
27269 </table>
27270 !! end
27271
27272 !! test
27273 Always encapsulate foster box when template range is expanded to table
27274 !! options
27275 parsoid=wt2wt
27276 !! wikitext
27277 {|
27278 hello
27279 {{OpenTable}}
27280 |}
27281 !! html/parsoid
27282
27283 !! end
27284
27285 !! test
27286 T115289: Unclosed table
27287 !! wikitext
27288 {{echo|<table>}}<!--c-->[[Category:Two]]
27289 !! html/parsoid
27290 <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>
27291 !! end
27292
27293 !! test
27294 T115289: Don't migrate newlines out of tables with fostered content
27295 !! wikitext
27296 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
27297 !! html/parsoid
27298 <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>
27299 !! end
27300
27301 !! test
27302 T73074: More fostering fun
27303 !! wikitext
27304 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
27305 !! html/parsoid
27306 <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>
27307 !! end
27308
27309 !!test
27310 Support <object> element with .data attribute
27311 !!options
27312 parsoid=html2wt
27313 !! html/parsoid
27314 <object data="test.swf"></object>
27315 !! wikitext
27316 <object data="test.swf"></object>
27317 !!end
27318
27319 !! test
27320 Don't block XML namespace declaration
27321 !! wikitext
27322 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27323 !! html/php
27324 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27325 </p>
27326 !! html/parsoid
27327 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
27328 !! end
27329
27330 # -----------------------------------------------------------------
27331 # The following section of tests are primarily to spec requirements
27332 # around Parsoid's serialization (old, new, edited content)
27333 #
27334 # All these tests are marked Parsoid html2wt and html2html only
27335 # ----------------------------------------------------------------
27336
27337 !! test
27338 Ignore rel attribute in a-tags during serialization to url-links
27339 !! options
27340 parsoid=html2wt
27341 !! html/parsoid
27342 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
27343 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
27344 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
27345 !! wikitext
27346 http://en.wikipedia.org/wiki/Foobar
27347 http://en.wikipedia.org/wiki/Foobar
27348 http://en.wikipedia.org/wiki/Foobar
27349 !! end
27350
27351 # 'mi' is a localinterwiki prefix as well as a language
27352 !! test
27353 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
27354 !! options
27355 parsoid=html2wt
27356 !! html/parsoid
27357 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
27358 !! wikitext
27359 [[Foo]]
27360 !! end
27361
27362 !! test
27363 Parsoid should accept interwiki shortcuts
27364 !! options
27365 parsoid=html2wt
27366 !! html/parsoid
27367 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
27368 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
27369 <a href='./fr:Foo'>Foo</a></p>
27370 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
27371 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
27372 <a href='fr%3AFoo'>Foo</a></p>
27373 <p><a href='FR%3AFoo'>Foo</a>
27374 <a href='./FR:Foo'>Foo</a></p>
27375 !! wikitext
27376 [[:fr:Foo|Foo]]
27377 [[:fr:Foo|Foo]]
27378 [[:fr:Foo|Foo]]
27379
27380 [[:fr:Foo|Foo]]
27381 [[:fr:Foo|Foo]]
27382 [[:fr:Foo|Foo]]
27383
27384 [[:fr:Foo|Foo]]
27385 [[:fr:Foo|Foo]]
27386 !! end
27387
27388 !! test
27389 Parsoid should not accept invalid interwiki shortcuts
27390 !! options
27391 parsoid=html2wt
27392 !! html/parsoid
27393 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
27394 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
27395 <a href='news:Foo'>Foo</a></p>
27396 !! wikitext
27397 [news:Foo Foo]
27398 [news:Foo Foo]
27399 [news:Foo Foo]
27400 !! end
27401
27402 # See T93839
27403 !! test
27404 New wikilinks should be serialized properly
27405 !! options
27406 parsoid=html2wt
27407 !! html/parsoid
27408 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
27409 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
27410 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
27411 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
27412 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
27413 !! wikitext
27414 [[Foo]]
27415 [[Foo]]
27416 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
27417 http://en.wikipedia.org/wiki/Foo
27418 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
27419 !! end
27420
27421 !! test
27422 New wiki links (href variations)
27423 !! options
27424 parsoid=html2wt
27425 !! html/parsoid
27426 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27427 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
27428 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
27429 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
27430 !! wikitext
27431 [[Foo_bar]]
27432 [[Foo_bar]]
27433 [[Foo_bar]]
27434 [[Toxine bactérienne]]
27435 !! end
27436
27437 !! test
27438 New wiki links (content string variations)
27439 !! options
27440 parsoid=html2wt
27441 !! html/parsoid
27442 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27443 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
27444 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
27445 !! wikitext
27446 [[Foo_bar]]
27447 [[Foo bar]]
27448 [[Foo_bar|./Foo_bar]]
27449 !! end
27450
27451 !! test
27452 New category links (href variations)
27453 !! options
27454 parsoid=html2wt
27455 !! html/parsoid
27456 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
27457 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
27458 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
27459 !! wikitext
27460 [[Category:Toxine bactérienne]]
27461 [[Category:Toxine bactérienne]]
27462 [[Category:Toxine bactérienne]]
27463 !! end
27464
27465 !! test
27466 New sol transparent links don't need indent-pre nowiki protection
27467 !! options
27468 parsoid=html2wt
27469 language=de
27470 !! html/parsoid
27471 <link rel="mw:PageProp/redirect" href="./Main_Page">
27472 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
27473 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
27474 !! wikitext
27475 #WEITERLEITUNG [[Main Page]]
27476 <!-- this is good --> [[Category:Good]]
27477 <!-- this is great --> [[Kategorie:Great]]
27478 !! end
27479
27480 !! test
27481 New interlanguage links (href variations)
27482 !! options
27483 parsoid=html2wt
27484 !! html/parsoid
27485 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
27486 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
27487 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
27488 !! wikitext
27489 [[es:Toxine bactérienne]]
27490 [[es:Toxine_bactérienne]]
27491 [[es:Toxine_bactérienne]]
27492 !! end
27493
27494 !! test
27495 Image: Modifying size of an image (1)
27496 !! options
27497 parsoid={
27498 "modes": ["wt2wt"],
27499 "changes": [
27500 ["img[height]", "attr", "height", "22"],
27501 ["img[width]", "attr", "width", "200"]
27502 ]
27503 }
27504 !! wikitext
27505 [[Image:Foobar.jpg|230x230px]]
27506 !! wikitext/edited
27507 [[Image:Foobar.jpg|200x200px]]
27508 !!end
27509
27510 !! test
27511 Image: Modifying size of an image (2)
27512 !! options
27513 parsoid={
27514 "modes": ["wt2wt"],
27515 "changes": [
27516 ["img[height]", "attr", "height", "100"],
27517 ["img[width]", "attr", "width", "500"]
27518 ]
27519 }
27520 !! wikitext
27521 [[Image:Foobar.jpg|230x230px]]
27522 !! wikitext/edited
27523 [[Image:Foobar.jpg|500x500px]]
27524 !!end
27525
27526 # Change in size is ignored so long as class='mw-default-size'
27527 !! test
27528 Image: Modifying size of an image (3)
27529 !! options
27530 parsoid={
27531 "modes": ["wt2wt"],
27532 "changes": [
27533 ["figure[class]", "removeClass", "mw-default-size"],
27534 ["figure img", "attr", "height", "19"],
27535 ["figure img", "attr", "width", "170"]
27536 ]
27537 }
27538 !! wikitext
27539 [[Image:Foobar.jpg|thumb]]
27540 !! wikitext/edited
27541 [[Image:Foobar.jpg|thumb|170x170px]]
27542 !!end
27543
27544 !! test
27545 Image: Modifying alignment of an image (T50665)
27546 !! options
27547 parsoid={
27548 "modes": ["wt2wt"],
27549 "changes": [
27550 ["figure[class]", "removeClass", "mw-halign-right"],
27551 ["figure[class]", "addClass", "mw-halign-left"]
27552 ]
27553 }
27554 !! wikitext
27555 [[Image:Foobar.jpg|thumb|caption|right]]
27556 !! wikitext/edited
27557 [[Image:Foobar.jpg|thumb|caption|left]]
27558 !! end
27559
27560 !! test
27561 Image: Modifying mw-default-size of an frameless image (T64805)
27562 !! options
27563 parsoid={
27564 "modes": ["wt2wt"],
27565 "changes": [
27566 ["figure.mw-default-size", "removeClass", "mw-default-size"]
27567 ]
27568 }
27569 !! wikitext
27570 [[Image:Foobar.jpg|frameless|right]]
27571 !! wikitext/edited
27572 [[Image:Foobar.jpg|frameless|right|220x220px]]
27573 !! end
27574
27575 !! test
27576 Image: Modifying valign of an image (T51221)
27577 !! options
27578 parsoid={
27579 "modes": ["wt2wt"],
27580 "changes": [
27581 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
27582 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
27583 ]
27584 }
27585 !! wikitext
27586 [[File:Foobar.jpg|20px|middle]]
27587 !! wikitext/edited
27588 [[File:Foobar.jpg|20px|text-top]]
27589 !! end
27590
27591 !! test
27592 Image: Modifying alt attribute of an image (T58400)
27593 !! options
27594 parsoid={
27595 "modes": ["wt2wt"],
27596 "changes": [
27597 ["img[alt]", "attr", "alt", "some alternate edited text"]
27598 ]
27599 }
27600 !! wikitext
27601 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
27602 !! wikitext/edited
27603 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
27604 !!end
27605
27606 !! test
27607 Image: Modifying caption of an image
27608 !! options
27609 parsoid={
27610 "modes": ["wt2wt"],
27611 "changes": [
27612 ["figcaption", "text", "new caption"]
27613 ]
27614 }
27615 !! wikitext
27616 [[Image:Foobar.jpg|thumb|original caption]]
27617 !! wikitext/edited
27618 [[Image:Foobar.jpg|thumb|new caption]]
27619 !!end
27620
27621 !! test
27622 Image: empty alt attribute (T50924)
27623 !! options
27624 parsoid
27625 !! wikitext
27626 [[File:Foobar.jpg|thumb|alt=|bar]]
27627 !! html
27628 <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>
27629 !! end
27630
27631 !! test
27632 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
27633 !! options
27634 parsoid=html2wt
27635 language=ar
27636 disabled
27637 !! html/parsoid
27638 <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>
27639 !! wikitext
27640 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
27641 !! end
27642
27643 !! test
27644 Image: Block level image should have \n before and after
27645 !! wikitext
27646 123
27647 [[File:Foobar.jpg|right|thumb|150x150px]]
27648 456
27649 !! html/parsoid
27650 <p>123</p>
27651 <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>
27652 <p>456</p>
27653 !! end
27654
27655 !! test
27656 Image: New block level image should have \n before and after (existing content)
27657 !! wikitext
27658 123
27659 [[File:Foobar.jpg|right|thumb|150x150px]]
27660 456
27661 !! html/parsoid
27662 <p>123</p>
27663 <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>
27664 <p>456</p>
27665 !! end
27666
27667 !! test
27668 Image: upright option (parsoid)
27669 !! wikitext
27670 [[File:Foobar.jpg|thumb|upright|caption]]
27671 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
27672 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
27673 !! html/parsoid
27674 <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>
27675 <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>
27676 <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>
27677 !! end
27678
27679 !! test
27680 Image: upright option is ignored on inline and frame images (parsoid)
27681 !! wikitext
27682 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
27683 !! html/parsoid
27684 <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>
27685 !! end
27686
27687 !! test
27688 Image: in template parameter with empty parameter
27689 !! wikitext
27690 {{echo|[[File:Foobar.jpg|link=]]}}
27691 !! html/parsoid
27692 <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>
27693 !! end
27694
27695 !! test
27696 Image: from basic HTML (1)
27697 !! options
27698 parsoid=html2wt
27699 !! html/parsoid
27700 <span typeof="mw:Image">
27701 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27702 </span>
27703 !! wikitext
27704 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27705 !! end
27706
27707 !! test
27708 Image: from basic HTML (2)
27709 !! options
27710 parsoid=html2wt
27711 !! html/parsoid
27712 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27713 !! wikitext
27714 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27715 !! end
27716
27717 !! test
27718 Image: from basic HTML (3)
27719 !! options
27720 parsoid=html2wt
27721 !! html/parsoid
27722 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
27723 !! wikitext
27724 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
27725 !! end
27726
27727 !! test
27728 Image: from basic HTML (4)
27729 !! options
27730 parsoid=html2wt
27731 !! html/parsoid
27732 <img src="./File:Foobar.jpg">
27733 !! wikitext
27734 [[File:Foobar.jpg|link=]]
27735 !! end
27736
27737 !! test
27738 Image: Invalid title as link
27739 !! wikitext
27740 [[File:Foobar.jpg|link=<]]
27741 !! html/php
27742 <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>
27743 </p>
27744 !! html/parsoid
27745 <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>
27746 !! end
27747
27748 !! test
27749 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
27750 !! options
27751 parsoid=html2wt
27752 !! html/parsoid
27753 <ul>
27754 <li><p>foo</p></li>
27755 </ul>
27756 !! wikitext
27757 * foo
27758 !! end
27759
27760 !! test
27761 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
27762 !! options
27763 parsoid=html2wt
27764 !! html/parsoid
27765 <ul> <li>foo</li></ul>
27766 !! wikitext
27767 * foo
27768 !! end
27769
27770 !! test
27771 Don't strip leading whitespace when handling indent-pre suppressing tags
27772 !! options
27773 parsoid=html2wt
27774 !! html/parsoid
27775 <table>
27776 <tr><td> indented row</td></tr>
27777 </table>
27778 <blockquote><p>
27779 <b>This is very bold of you!</b>
27780 </p>
27781 <table><tr><td>
27782 indented cell (no pre-wrapping!)
27783 </td></tr></table>
27784 </blockquote>
27785 <p>foo</p>
27786 <div>bar</div>
27787 !! wikitext
27788 {|
27789 | indented row
27790 |}
27791 <blockquote>
27792 '''This is very bold of you!'''
27793
27794 {|
27795 |
27796 indented cell (no pre-wrapping!)
27797 |}
27798 </blockquote>
27799 foo
27800 <div>bar</div>
27801 !! end
27802
27803 !! test
27804 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
27805 !! options
27806 parsoid=html2wt
27807 !! html/parsoid
27808 <p>foo</p>
27809 <span>bar</span>
27810
27811 <span>foo2
27812 </span>bar2
27813
27814 <div>foo</div>
27815 <span>bar</span>
27816
27817 <div>
27818 <span>foo</span>
27819 </div>
27820 !! wikitext
27821 foo
27822
27823 <span>bar</span>
27824
27825 <span>foo2
27826 <nowiki> </nowiki></span>bar2
27827
27828 <div>foo</div>
27829 <nowiki> </nowiki><span>bar</span>
27830
27831 <div>
27832 <nowiki> </nowiki><span>foo</span>
27833 </div>
27834 !! end
27835
27836 !! test
27837 Lists: Dont insert newlines in a serialized list item.
27838 !! options
27839 parsoid=html2wt
27840 !! html/parsoid
27841 <ul><li>a<br>b</li><li>c</li></ul>
27842 !! wikitext
27843 * a<br />b
27844 * c
27845 !! end
27846
27847 !! test
27848 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
27849 !! options
27850 parsoid={
27851 "modes": ["html2wt"],
27852 "scrubWikitext": false
27853 }
27854 !! html/parsoid
27855 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
27856 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
27857
27858 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
27859 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
27860
27861 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
27862
27863 <h2><meta property="mw:PageProp/toc" /> ok</h2>
27864 !! wikitext
27865 == hello there [[Category:A1]] ==
27866
27867 == [[Category:A2]] hi pal ==
27868
27869 == <!--foo--> [[Category:A3]] how goes it ==
27870
27871 == it goes well [[Category:A4]] <!--bar--> ==
27872
27873 ==howdy [[Category:A5]]==
27874
27875 == __TOC__ ok ==
27876 !! end
27877
27878 !! test
27879 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
27880 !! options
27881 parsoid={
27882 "modes": ["html2wt"],
27883 "scrubWikitext": true
27884 }
27885 !! html/parsoid
27886 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
27887 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
27888
27889 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
27890 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
27891
27892 <h2><meta property="mw:PageProp/toc" /> ok</h2>
27893 !! wikitext
27894 == hello there ==
27895 [[Category:A1]]
27896 [[Category:A2]]
27897
27898 == hi pal ==
27899
27900 <!--foo--> [[Category:A3]]
27901
27902 == how goes it ==
27903
27904 == it goes well ==
27905 [[Category:A4]] <!--bar-->
27906
27907 __TOC__
27908
27909 == ok ==
27910 !! end
27911
27912 !! test
27913 Headings: Don't hoist metas that come from templates
27914 !! options
27915 parsoid={
27916 "modes": ["html2wt"],
27917 "scrubWikitext": true
27918 }
27919 !! html/parsoid
27920 <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>
27921 !! wikitext
27922 == {{echo|foo [[Category:Foo]]}} ==
27923 !! end
27924
27925 !! test
27926 Headings: Category in ref isn't hoisted
27927 !! options
27928 parsoid={
27929 "modes": ["html2wt"],
27930 "scrubWikitext": true
27931 }
27932 !! html/parsoid
27933 <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>
27934
27935 <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>
27936 !! wikitext
27937 == foo <ref>bar
27938 [[Category:Baz]] </ref> ==
27939
27940 <references />
27941 !! end
27942
27943 !! test
27944 Parsoid: Serialize positional parameters with = in them as named parameter
27945 !! options
27946 parsoid=html2wt
27947 !! html/parsoid
27948 <p about="#mwt1" typeof="mw:Transclusion"
27949 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
27950
27951 <p about="#mwt1" typeof="mw:Transclusion"
27952 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
27953
27954 <!--Orig params with data-parsoid has heuristics for handling = chars-->
27955 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
27956 <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>
27957 !! wikitext
27958 {{echo|1=f=oo}}
27959
27960 {{echo|1=f=oo|2=bar}}
27961
27962 <!--Orig params with data-parsoid has heuristics for handling = chars-->
27963 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
27964 {{echo|<nowiki>f=oo</nowiki>|bar}}
27965 !! end
27966
27967 !! test
27968 Parsoid: Serialize positional parameters with = in extlink as named parameter
27969 !! options
27970 parsoid=html2wt
27971 !! html/parsoid
27972 <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>
27973 !! wikitext
27974 {{echo|1=http://stuff?is=ok}}
27975 !! end
27976
27977 !! test
27978 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
27979 !! options
27980 parsoid=html2wt
27981 !! html/parsoid
27982 <div>a<p>b</p></div>
27983 <div>a
27984 <p>b</p></div>
27985 <div>
27986 a
27987 <p>b</p></div>
27988 !! wikitext
27989 <div>a
27990 b
27991 </div>
27992 <div>a
27993 b
27994 </div>
27995 <div>
27996 a
27997
27998 b
27999 </div>
28000 !! end
28001
28002 !! test
28003 Substrings resembling wikitext in hrefs should not get nowiki escapes
28004 !! options
28005 parsoid=html2wt
28006 !! html/parsoid
28007 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
28008 !! wikitext
28009 [[Foo''bar''baz]]
28010 !! end
28011
28012 !! test
28013 Enforce single-line context in the serializer
28014 !! options
28015 parsoid=html2wt
28016 !! html/parsoid
28017 <h2>testing
28018 123</h2>
28019
28020 <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">
28021 </span><span about="#mwt1">you</span> </h2>
28022
28023 <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>
28024
28025 <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
28026 there</span></li></ol>
28027
28028 <ul><li>asd
28029 sdf</li></ul>
28030
28031 <ul><li>foo
28032 bar
28033 baz</li>
28034 <li>foo <b>bar</b>
28035 baz</li></ul>
28036
28037 <dl><dt>hi
28038 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
28039 ho</dd></dl>
28040
28041 <dl><dd> <table>
28042 <tbody><tr><td> ha
28043 ha
28044 ha</td></tr>
28045 </tbody></table></dd></dl>
28046 !! wikitext
28047 == testing 123 ==
28048
28049 == hi {{bogus|there
28050 you}} ==
28051
28052 == foo <ref>hello
28053 there</ref> ==
28054
28055 <references />
28056
28057 * asd sdf
28058
28059 * foo bar baz
28060 * foo '''bar''' baz
28061
28062 ; hi ho : hi ho
28063
28064 : {|
28065 | ha
28066 ha
28067 ha
28068 |}
28069 !! end
28070
28071 !! test
28072 Serialize new placeholder space without spans
28073 !! options
28074 parsoid=html2wt
28075 !! html/parsoid
28076 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
28077
28078 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
28079
28080 <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>
28081 !! wikitext
28082 foo : bar
28083
28084 foo : bar
28085
28086 <ref>foo : bar</ref>ok
28087 !! end
28088
28089
28090 #-----------------------
28091 # Tag minimization tests
28092 #-----------------------
28093
28094 !! test
28095 1. I/B quote minimization: wikitext-only tags should be combined
28096 !! options
28097 parsoid=html2wt
28098 !! html/parsoid
28099 <p><i>A</i><i>B</i></p>
28100 <p><b>A</b><b>B</b></p>
28101 <p><i>A</i><b><i>B</i></b></p>
28102 <p><b>A</b><i><b>B</b></i></p>
28103 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
28104 <p><i><b>A</b></i><i><b>B</b></i></p>
28105 <p><i><b>A</b></i><b><i>B</i></b></p>
28106 <p><b><i>A</i></b><i><b>B</b></i></p>
28107 !! wikitext
28108 ''AB''
28109
28110 '''AB'''
28111
28112 ''A'''B'''''
28113
28114 '''A''B'''''
28115
28116 '''A''BC''D'''
28117
28118 '''''AB'''''
28119
28120 '''''AB'''''
28121
28122 '''''AB'''''
28123 !! end
28124
28125 !! test
28126 2. I/B quote minimization: wikitext and html tags should not be combined
28127 !! options
28128 parsoid=html2wt
28129 !! html/parsoid
28130 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
28131 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
28132 !! wikitext
28133 ''A''<i>B</i>
28134
28135 ''A''<nowiki/>'''<i>B</i>'''
28136 !! end
28137
28138 !! test
28139 3. I/B quote minimization: templated content stops minimization
28140 !! options
28141 parsoid=html2wt
28142 !! html/parsoid
28143 <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>
28144 <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>
28145 !! wikitext
28146 ''A''{{echo|''B''}}
28147
28148 ''A''{{echo|'''''B'''''}}
28149 !! end
28150
28151 !! test
28152 4. I/B quote minimization: new content should be mimimized with adjacent old content
28153 !! options
28154 parsoid=html2wt
28155 !! html/parsoid
28156 <p><i>A</i><i>B</i></p>
28157 <p><b>A</b><b>B</b></p>
28158 <p><i>A</i><b><i>B</i></b></p>
28159 !! wikitext
28160 ''AB''
28161
28162 '''AB'''
28163
28164 ''A'''B'''''
28165 !! end
28166
28167 !! test
28168 5a. Merge adjacent quote nodes if they've been edited
28169 !! options
28170 parsoid={
28171 "modes": ["wt2wt", "selser"],
28172 "changes": [
28173 ["p", "contents", "remove", ":contains('b')"]
28174 ]
28175 }
28176 !! wikitext
28177 ''a''b''c''
28178 !! wikitext/edited
28179 ''ac''
28180 !! end
28181
28182 !! test
28183 5b. Merge adjacent quote nodes if they've been edited
28184 !! options
28185 parsoid={
28186 "modes": ["wt2wt", "selser"],
28187 "changes": [
28188 ["#x", "remove"]
28189 ]
28190 }
28191 !! wikitext
28192 ''a''<span id="x">b</span>''c''
28193 !! wikitext/edited
28194 ''ac''
28195 !! end
28196
28197 !! test
28198 1. Merge adjacent link nodes as long as at least one element is new
28199 !! options
28200 parsoid={
28201 "modes": ["html2wt"],
28202 "scrubWikitext": true
28203 }
28204 !! html/parsoid
28205 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28206 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28207 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
28208 !! wikitext
28209 [[Football]]
28210 [[Football]]
28211 [[Football|Foot]][[Football|ball]]
28212 !! end
28213
28214 !! test
28215 2. Merge adjacent link nodes and enable additional normalizations
28216 !! options
28217 parsoid={
28218 "modes": ["html2wt"],
28219 "scrubWikitext": true
28220 }
28221 !! html/parsoid
28222 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
28223 !! wikitext
28224 [[Football|''Football'']]
28225 !! end
28226
28227 !! test
28228 3. Don't merge adjacent link nodes if scrubWikitext is false
28229 !! options
28230 parsoid={
28231 "modes": ["html2wt"],
28232 "scrubWikitext": false
28233 }
28234 !! html/parsoid
28235 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28236 !! wikitext
28237 [[Football|Foot]][[Football|ball]]
28238 !! end
28239
28240 #------------------------------
28241 # End of tag minimization tests
28242 #------------------------------
28243
28244 !!test
28245 T56262: New entities
28246 !! options
28247 parsoid=html2wt
28248 !! html/parsoid
28249 <span typeof="mw:Entity">&nbsp;</span>
28250 !! wikitext
28251 &nbsp;
28252 !! end
28253
28254 ## Note that there is no wikitext output for 'unknownproperty' ##
28255 ## Unknown magic words are silently dropped ##
28256
28257 !! test
28258 Magic words
28259 !! options
28260 parsoid=html2wt
28261 !! html/parsoid
28262 <meta property='mw:PageProp/toc' />
28263 <meta property='mw:PageProp/notoc' />
28264 <meta property='mw:PageProp/forcetoc' />
28265 <meta property='mw:PageProp/index' />
28266 <meta property='mw:PageProp/noindex' />
28267 <meta property='mw:PageProp/nogallery' />
28268 <meta property='mw:PageProp/noeditsection' />
28269 <meta property='mw:PageProp/notitleconvert' />
28270 <meta property='mw:PageProp/nocontentconvert' />
28271 <meta property='mw:PageProp/unknownproperty' />
28272 !! wikitext
28273 __TOC__
28274 __NOTOC__
28275 __FORCETOC__
28276 __INDEX__
28277 __NOINDEX__
28278 __NOGALLERY__
28279 __NOEDITSECTION__
28280 __NOTITLECONVERT__
28281 __NOCONTENTCONVERT__
28282 !! end
28283
28284 !! test
28285 Consecutive <pre>s should not get merged
28286 !! options
28287 parsoid=html2wt,html2html
28288 !! html/parsoid
28289 <pre>a</pre><pre>b</pre>
28290
28291 <pre>c
28292 </pre><pre>
28293 d</pre>
28294
28295 <pre>e
28296
28297 </pre><pre>
28298
28299 f</pre>
28300 !! wikitext
28301 a
28302
28303 b
28304
28305 c
28306
28307 d
28308
28309 e
28310
28311
28312
28313 f
28314 !! end
28315
28316 !! test
28317 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
28318 !! options
28319 parsoid=html2wt
28320 !! html/parsoid
28321 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
28322 !! wikitext
28323 [[Special:BookSources/1234567890|ISBN 1234567895]]
28324 !! end
28325
28326 !! test
28327 Edited RFC links not serializable as RFC links should serialize as extlinks
28328 !! options
28329 parsoid=html2wt
28330 !! html/parsoid
28331 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
28332 !! wikitext
28333 [https://tools.ietf.org/html/rfc123 New RFC]
28334 !! end
28335
28336 !! test
28337 Edited PMID links not serializable as PMID links should serialize as extlinks
28338 !! options
28339 parsoid=html2wt
28340 !! html/parsoid
28341 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
28342 !! wikitext
28343 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
28344 !! end
28345
28346 !! test
28347 WTS of autolinks with trailing/surrounding context
28348 !! options
28349 parsoid=html2wt
28350 !! html/parsoid
28351 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
28352 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
28353 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
28354 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
28355 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
28356 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
28357 !! wikitext
28358 http://cscott.net'''foo'''
28359
28360 http://cscott.net<b>foo</b>
28361
28362 '''http://cscott.net'''
28363
28364 '''http://cscott.net '''
28365
28366 '''http://cscott.net<nowiki/>x'''
28367
28368 http://cscott.net<nowiki/>x
28369 !! end
28370
28371 !! test
28372 WTS of autolinks with nowikis (round-trip)
28373 !! wikitext
28374 x<nowiki/>http://cscott.net<nowiki/>x
28375 !! html/parsoid
28376 <p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p>
28377 !! end
28378
28379 # this is the "easy" test because it leaves in place all the
28380 # data-parsoid information indicating this is an autolink
28381 !! test
28382 WTS of autolinks with escapes (editing)
28383 !! options
28384 parsoid={
28385 "modes": ["wt2wt"],
28386 "changes": [
28387 [ "span", "remove" ]
28388 ]
28389 }
28390 !! wikitext
28391 x<nowiki/>http://cscott.net<nowiki/>x
28392 !! wikitext/edited
28393 x<nowiki/>http://cscott.net<nowiki/>x
28394 !! end
28395
28396 !! test
28397 WTS of edited autolink-like text (T103364)
28398 !! options
28399 parsoid={
28400 "modes": ["wt2wt"],
28401 "changes": [
28402 [ "span[typeof]", "removeAttr", "typeof" ]
28403 ]
28404 }
28405 !! wikitext
28406 Not a link: <nowiki>http://example.com</nowiki>.
28407 !! wikitext/edited
28408 Not a link: <span><nowiki>http://example.com</nowiki></span>.
28409 !! end
28410
28411 !! test
28412 WTS of newly-authored autolink-like text (T103364)
28413 !! options
28414 parsoid=html2wt
28415 !! html/parsoid
28416 <p>http://example.com is not a link.</p>
28417 !! wikitext
28418 <nowiki>http://example.com</nowiki> is not a link.
28419 !! end
28420
28421 !! test
28422 WTS of autolink-like text after an autolink (T108563)
28423 !! options
28424 parsoid=html2wt
28425 !! html/parsoid
28426 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
28427 !! wikitext
28428 http://example.com <nowiki>http://example.com</nowiki> is not a link.
28429 !! end
28430
28431 !! test
28432 Magic links inside links (not autolinked)
28433 !! wikitext
28434 [[Foo|http://example.com]]
28435 [[Foo|RFC 1234]]
28436 [[Foo|PMID 1234]]
28437 [[Foo|ISBN 123456789x]]
28438
28439 [http://foo.com http://example.com]
28440 [http://foo.com RFC 1234]
28441 [http://foo.com PMID 1234]
28442 [http://foo.com ISBN 123456789x]
28443 !! html+tidy
28444 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
28445 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
28446 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
28447 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
28448 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
28449 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
28450 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
28451 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
28452 </p>
28453 !! html/parsoid
28454 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
28455 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
28456 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
28457 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
28458
28459 <p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a>
28460 <a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a>
28461 <a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a>
28462 <a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
28463 !! end
28464
28465 !! test
28466 Magic links inside image captions (autolinked)
28467 !! wikitext
28468 [[File:Foobar.jpg|thumb|http://example.com]]
28469 [[File:Foobar.jpg|thumb|RFC 1234]]
28470 [[File:Foobar.jpg|thumb|PMID 1234]]
28471 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
28472 !! html+tidy
28473 <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>
28474 <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>
28475 <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>
28476 <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>
28477 !! html/parsoid
28478 <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>
28479 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external text">RFC 1234</a></figcaption></figure>
28480 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external text">PMID 1234</a></figcaption></figure>
28481 <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>
28482 !! end
28483
28484 !! test
28485 WTS of magic word text (T109371)
28486 !! options
28487 parsoid=html2wt
28488 !! html/parsoid
28489 <p>RFC 1234</p>
28490 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
28491 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
28492 !! wikitext
28493 <nowiki>RFC 1234</nowiki>
28494
28495 [http://foo.com RFC 1234]
28496
28497 [[Foo|RFC 1234]]
28498 !! end
28499
28500 !! test
28501 Edited Redirect link should emit a non-piped wikitext link
28502 !! options
28503 parsoid=html2wt
28504 !! html/parsoid
28505 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
28506 !! wikitext
28507 #REDIRECT [[Bar]]
28508 !! end
28509
28510 !! test
28511 T75121: Infer extension name from typeOf if data-mw is not present
28512 !! options
28513 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28514 !! html/parsoid
28515 <div typeOf="mw:Extension/foo"></div>
28516 !! wikitext
28517 <foo />
28518 !! end
28519
28520 # Note that the <p> wrapping isn't present in PHP parser output
28521 # The important thing for this test is that P-wrapping doesn't
28522 # interfere with the <nowiki> protection for leading - in <td>
28523 # (which isn't necessary for <th>).
28524 !! test
28525 T88318: p-wrapped dash in table.
28526 !! options
28527 parsoid=html2wt,wt2wt
28528 !! html/parsoid
28529 <table><tbody>
28530 <tr><th><p>-</p></th><th><p>- </p></th></tr>
28531 <tr><td><p>-</p></td><td><p>- </p></td></tr>
28532 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
28533 </tbody></table>
28534 !! wikitext
28535 {|
28536 !-
28537 !-
28538 |-
28539 |<nowiki>-</nowiki>
28540 |<nowiki>- </nowiki>
28541 |-
28542 |<small>-</small>
28543 |<br />
28544 -
28545 |<br />
28546 -
28547 |}
28548 !! html/php+tidy
28549 <table>
28550 <tbody><tr>
28551 <th>-
28552 </th>
28553 <th>-
28554 </th></tr>
28555 <tr>
28556 <td>-
28557 </td>
28558 <td>-
28559 </td></tr>
28560 <tr>
28561 <td><small>-</small>
28562 </td>
28563 <td><br />
28564 <p>-
28565 </p>
28566 </td>
28567 <td><br />
28568 <p>-
28569 </p>
28570 </td></tr></tbody></table>
28571 !! end
28572
28573 !! test
28574 T149209: WTS: Handle newlines in table cells properly
28575 !! options
28576 parsoid=html2wt
28577 !! html/parsoid
28578 <table>
28579 <tbody>
28580 <tr><td>a
28581 b
28582 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
28583 <tr><td><p>x</p>
28584 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
28585 </tbody></table>
28586 <table>
28587 <tbody>
28588 <tr><th>a
28589 b
28590 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
28591 <tr><th><p>x</h>
28592 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
28593 </tbody></table>
28594 !! wikitext
28595 {|
28596 |a
28597 b
28598 |c
28599 |-
28600 |x
28601 {{!}}y
28602 |}
28603 {|
28604 !a
28605 b
28606 !c
28607 |-
28608 !x
28609 !y
28610 |}
28611 !! end
28612
28613 !! test
28614 T149209: Selser: Handle newlines in table cells properly
28615 !! options
28616 parsoid={
28617 "modes": ["selser"],
28618 "changes": [
28619 [ "#h1", "html", "a\nb\n" ],
28620 [ "#h2", "html", "a\nb\n" ],
28621 [ "#c1", "html", "a\nb\n" ],
28622 [ "#c2", "html", "<p>a</p>" ],
28623 [ "#c3", "html", "<p>a</p>" ],
28624 [ "#c4", "html", "edit-me<p>a</p>" ]
28625 ]
28626 }
28627 !! wikitext
28628 {|
28629 ! id="h1" |edit-me!!1
28630 |-
28631 ! id="h2" |edit-me||2
28632 |-
28633 | id="c1" |edit-me||3
28634 |-
28635 | id="c2" |edit-me||4
28636 |-
28637 | id="c3" |edit-me||p||q||r
28638 |-
28639 | id="c4" |edit-me||p||q||r
28640 |}
28641 !! wikitext/edited
28642 {|
28643 ! id="h1" |a
28644 b
28645 !1
28646 |-
28647 ! id="h2" |a
28648 b
28649 !2
28650 |-
28651 | id="c1" |a
28652 b
28653 |3
28654 |-
28655 | id="c2" |a
28656 |4
28657 |-
28658 | id="c3" |a
28659 |p||q||r
28660 |-
28661 | id="c4" |edit-me
28662 a
28663 |p||q||r
28664 |}
28665 !! end
28666
28667 !! test
28668 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
28669 !! options
28670 parsoid=html2wt
28671 !! html/parsoid
28672 <table id='mwAb'>
28673 <td id='mwAc'>foo</td>
28674 <td id='serialize-this'>bar</td>
28675 </table>
28676 !! wikitext
28677 {|
28678 |foo
28679 | id="serialize-this" |bar
28680 |}
28681 !! end
28682
28683 !! test
28684 Parsoid-like element ids should not be serialized to wikitext unless shadowed
28685 !! options
28686 parsoid=html2wt
28687 !! html/parsoid
28688 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
28689 !! wikitext
28690 <div id="hello">ok</div>
28691 !! end
28692
28693 !! test
28694 WTS change modes
28695 !! options
28696 parsoid={
28697 "modes": ["wt2wt"],
28698 "changes": [
28699 [ "#xyz", "before", "<b>before</b> stuff " ],
28700 [ "#xyz", "after", " stuff <i>after</i>" ],
28701 [ "#xyz", "html", "x <b>y</b> z" ]
28702 ]
28703 }
28704 !! wikitext
28705 <span id="xyz">hello</span>
28706 !! wikitext/edited
28707 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
28708 !! end
28709
28710 !! test
28711 Never serialize a-tag as html, regardless of what data-parsoid has to say
28712 !! options
28713 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28714 !! html/parsoid
28715 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
28716 !! wikitext
28717 [[Foo]]
28718 !! end
28719
28720 ## SSS FIXME: This is broken output nevertheless.
28721 ## What might be a reasonable non-broken output for this?
28722 ## This is an edge case unlikely to be seen in production
28723 ## that I am not wasting more time on this right now.
28724 !! test
28725 Never serialize a-tag as html, no matter what attributes it has
28726 !! options
28727 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28728 !! html/parsoid
28729 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
28730 !! wikitext
28731 [http://boo.org http://boohoo.org]
28732 !! end
28733
28734 # Misnested is an indication that selser can reuse the source but these have
28735 # shown to sneak through on occasion. See T101768.
28736 # The original wikitext here is: [http://test.com [[one]] two three]
28737 !! test
28738 Strip span tags added to mark misnested links
28739 !! options
28740 parsoid=html2wt
28741 !! html/parsoid
28742 <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>
28743 !! wikitext
28744 [http://test.com][[one]] two three
28745 !! end
28746
28747 !! test
28748 Catch regression when unpacking misnested links
28749 !! options
28750 parsoid=wt2html
28751 !! wikitext
28752 {{echo|hi}}[http://example.com [[ho]]]
28753 !! html/parsoid
28754 <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>
28755 !! end
28756
28757 !! test
28758 Catch regression when unpacking with trailing content
28759 !! wikitext
28760 {{echo|Foo <references/> bar}}
28761 !! html/parsoid
28762 <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>
28763 !! end
28764
28765 !! test
28766 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
28767 !! options
28768 parsoid=html2wt
28769 !! html/parsoid
28770 <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|}"]}'>
28771 <tbody><tr><td>d
28772 </td></tr>
28773 </tbody></table>
28774 !! wikitext
28775 {{echo|a}}
28776 {|{{echo|c
28777 {{!}}d
28778 }}
28779 |}
28780 !! end
28781
28782 ## This test verifies the presence and computation of this attribute indirectly
28783 ## by making an edit and ensuring that the serialization is correct (which it would be
28784 ## only if firstWikitextNode is properly set).
28785 !! test
28786 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
28787 !! options
28788 parsoid= {
28789 "modes": ["wt2wt"],
28790 "changes": [
28791 [ "div#x", "remove" ],
28792 [ "div", "before", "<div>new</div>" ]
28793 ]
28794 }
28795 !! wikitext
28796 <div id="x">foo</div>
28797 {|
28798 {{echo|<div>boo</div>
28799 {{!}}b}}
28800 |c
28801 |}
28802 !! wikitext/edited
28803
28804 <div>new</div>
28805 {|
28806 {{echo|<div>boo</div>
28807 {{!}}b}}
28808 |c
28809 |}
28810 !! end
28811
28812 # --------------------------------------------
28813 # Tests spec'ing wikitext serialization norms |
28814 # --------------------------------------------
28815
28816 !! test
28817 Serialize multi-line indent-pre starting with wikitext syntax
28818 !! options
28819 parsoid=html2wt
28820 !! html/parsoid
28821 <pre>* 1
28822 ** 2
28823 * 3</pre>
28824 !! wikitext
28825 * 1
28826 ** 2
28827 * 3
28828 !! end
28829
28830 !! test
28831 1. Categories should always be serialized on their own line
28832 !! options
28833 parsoid=html2wt
28834 !! html/parsoid
28835 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
28836 !! wikitext
28837 foo
28838 [[Category:Foo]]
28839 bar
28840 !! end
28841
28842 !! test
28843 2. Categories that are part of templates should not introduce a line break
28844 !! wikitext
28845 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
28846 !! html/parsoid
28847 <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>
28848 !! end
28849
28850 # Careful while editing these next 2 tests. There are \u200f characters
28851 # before and after the <link> tags in the HTML and following some
28852 # of the categories in wikitext
28853 # Do not remove these characters in edits.
28854 #
28855 # As part of the serialization, these Unicode directional formatting characters will get stripped.
28856 !! test
28857 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
28858 !! options
28859 parsoid={
28860 "modes": ["html2wt"],
28861 "scrubWikitext": true
28862 }
28863 !! html/parsoid
28864 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
28865 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
28866 !! wikitext
28867 [[קטגוריה:טקסים]]
28868 [[קטגוריה: שיטות משפט]]
28869 !! end
28870
28871 !! test
28872 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
28873 !! options
28874 parsoid={
28875 "modes": ["html2wt"],
28876 "scrubWikitext": true
28877 }
28878 !! html/parsoid
28879 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
28880 !! wikitext
28881 [[קטגוריה:טקסים]]
28882 ‏y
28883 !! end
28884
28885 !! test
28886 Lists: Add space after bullets
28887 !! options
28888 parsoid=html2wt
28889 !! html/parsoid
28890 <ul>
28891 <li>foo</li>
28892 <li> bar</li>
28893 <li><span> baz</span></li>
28894 </ul>
28895 !! wikitext
28896 * foo
28897 * bar
28898 * <span> baz</span>
28899 !! end
28900
28901 !! test
28902 1. Headings: Add space before/after == (T53744)
28903 !! options
28904 parsoid=html2wt
28905 !! html/parsoid
28906 <h2>foo</h2>
28907 <h2> bar</h2>
28908 <h2>baz </h2>
28909 <h2><span> baz</span></h2>
28910 !! wikitext
28911 == foo ==
28912
28913 == bar ==
28914
28915 == baz ==
28916
28917 == <span> baz</span> ==
28918 !! end
28919
28920 !! test
28921 2. Headings: Add space before/after == even after hoisted content
28922 !! options
28923 parsoid={
28924 "modes": ["html2wt"],
28925 "scrubWikitext": true
28926 }
28927 !! html/parsoid
28928 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
28929 !! wikitext
28930 [[Category:A2]]
28931
28932 == ok ==
28933 !! end
28934
28935 !! test
28936 1. Headings: suppress newly created empty headings
28937 !! options
28938 parsoid={
28939 "modes": ["html2wt"],
28940 "scrubWikitext": true
28941 }
28942 !! html/parsoid
28943 <h2></h2>
28944 !! wikitext
28945 !! end
28946
28947 !! test
28948 2. Headings: don't suppress empty headings if scrubWikitext is false
28949 !! options
28950 parsoid=html2wt
28951 !! html/parsoid
28952 <h2></h2>
28953 !! wikitext
28954 ==<nowiki/>==
28955 !! end
28956
28957 !! test
28958 3. Headings: suppress empty headings on edits
28959 !! options
28960 parsoid={
28961 "modes": ["selser"],
28962 "scrubWikitext": true,
28963 "changes": [
28964 [ "#x", "remove"]
28965 ]
28966 }
28967 !! wikitext
28968 ==<span id="x">foo</span>==
28969 !! wikitext/edited
28970 !! end
28971
28972 !! test
28973 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
28974 !! options
28975 parsoid={
28976 "modes": ["html2wt"],
28977 "scrubWikitext": true
28978 }
28979 !! html/parsoid
28980 <h2>foo<br/>bar</h2>
28981 <h2>foo <span><br/>bar</span> baz</h2>
28982 !! wikitext
28983 == foo bar ==
28984
28985 == foo <span> bar</span> baz ==
28986 !! end
28987
28988 !! test
28989 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
28990 !! options
28991 parsoid={
28992 "modes": ["html2wt"],
28993 "scrubWikitext": false
28994 }
28995 !! html/parsoid
28996 <h2>foo<br/>bar</h2>
28997 !! wikitext
28998 == foo<br /> bar ==
28999 !! end
29000
29001 !! test
29002 1. WT Quote Tags: suppress newly created empty style tags
29003 !! options
29004 parsoid={
29005 "modes": ["html2wt"],
29006 "scrubWikitext": true
29007 }
29008 !! html/parsoid
29009 <i></i><b></b>
29010 !! wikitext
29011 !! end
29012
29013 !! test
29014 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
29015 !! options
29016 parsoid=html2wt
29017 !! html/parsoid
29018 <i></i><b></b>
29019 !! wikitext
29020 ''<nowiki/>'''''<nowiki/>'''
29021 !! end
29022
29023 !! test
29024 3. WT Quote Tags: suppress empty style tags on edits
29025 !! options
29026 parsoid={
29027 "modes": ["selser"],
29028 "scrubWikitext": true,
29029 "changes": [
29030 [ "#x", "remove"]
29031 ]
29032 }
29033 !! wikitext
29034 '''<span id="x">foo</span>'''
29035 !! wikitext/edited
29036 !! end
29037
29038 !! test
29039 1. Anchors: suppress newly created empty anchors
29040 !! options
29041 parsoid={
29042 "modes": ["html2wt"],
29043 "scrubWikitext": true
29044 }
29045 !! html/parsoid
29046 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
29047 !! wikitext
29048 !! end
29049
29050 !! test
29051 2. Anchors: don't suppress empty anchors if scrubWikitext is false
29052 !! options
29053 parsoid={
29054 "modes": ["html2wt"],
29055 "scrubWikitext": false
29056 }
29057 !! html/parsoid
29058 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
29059 !! wikitext
29060 [[Test|<nowiki/>]]
29061 !! end
29062
29063 !! test
29064 3. Anchors: suppress empty anchors on edits
29065 !! options
29066 parsoid={
29067 "modes": ["selser"],
29068 "scrubWikitext": true,
29069 "changes": [
29070 [ "#x", "remove"]
29071 ]
29072 }
29073 !! wikitext
29074 [[Test|<span id="x">foo</span>]]
29075 !! wikitext/edited
29076 !! end
29077
29078 !! test
29079 3a. Anchors: do not suppress numbered extlinks
29080 !! options
29081 parsoid={
29082 "modes": ["wt2wt"],
29083 "scrubWikitext": true
29084 }
29085 !! wikitext
29086 [http://foo.com]
29087 !! html/parsoid
29088 <a rel="mw:ExtLink" href="http://foo.com"></a>
29089 !! end
29090
29091 !! test
29092 3b. Anchors: do not suppress numbered extlinks
29093 !! options
29094 parsoid={
29095 "modes": ["wt2wt"],
29096 "scrubWikitext": true,
29097 "changes": [
29098 [ "#x", "remove"]
29099 ]
29100 }
29101 !! wikitext
29102 [http://foo.com <span id="x">foo</span>]
29103 !! wikitext/edited
29104 [http://foo.com]
29105 !! end
29106
29107 !!test
29108 Normalizations should be restricted to edited content
29109 !!options
29110 parsoid={
29111 "modes": ["selser"],
29112 "scrubWikitext": true,
29113 "changes": [
29114 [ "h1", "before", "<i></i>"]
29115 ]
29116 }
29117 !!wikitext
29118 a
29119 = =
29120 b
29121 !!wikitext/edited
29122 a
29123 = =
29124 b
29125 !!end
29126
29127 !! test
29128 1. Multiple normalizations (html2wt)
29129 !! options
29130 parsoid={
29131 "modes": ["html2wt"],
29132 "scrubWikitext": true
29133 }
29134 !! html
29135 <h2><i></i></h2>
29136 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
29137 </a><b><i></i></b>x</p>
29138 !! wikitext
29139
29140 [[foo]]
29141 x
29142
29143 !! end
29144
29145 !! test
29146 2. Multiple normalizations (selser)
29147 !! options
29148 parsoid={
29149 "modes": ["selser"],
29150 "scrubWikitext": true,
29151 "changes": [
29152 [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
29153 ]
29154 }
29155 !! wikitext
29156 <span id="x">foo</span>
29157 !! wikitext/edited
29158 <span id="x">foo</span>
29159
29160 x
29161 !! end
29162
29163 !! test
29164 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
29165 !! options
29166 parsoid={
29167 "modes": ["html2wt"],
29168 "scrubWikitext": true
29169 }
29170 !! html/parsoid
29171 <p> hi</p>
29172 <p> hello</p>
29173 !! wikitext
29174 hi
29175
29176 hello
29177 !! end
29178
29179 !! test
29180 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
29181 !! options
29182 parsoid=html2wt
29183 !! html/parsoid
29184 <p> hi</p>
29185 <p> hello</p>
29186 !! wikitext
29187 <nowiki> </nowiki>hi
29188
29189 <nowiki> </nowiki> hello
29190 !! end
29191
29192 !! test
29193 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
29194 !! options
29195 parsoid={
29196 "modes": ["html2wt"],
29197 "scrubWikitext": true
29198 }
29199 !! html/parsoid
29200 <p>Foo
29201 bar
29202 baz</p>
29203
29204 <table><tr><td>Foo
29205 bar
29206 baz bang</td></tr></table>
29207
29208 <p><!--boo--> foo
29209 bar</p>
29210
29211 <p> foo
29212 bar<span>boo</span></p>
29213 !! wikitext
29214 Foo
29215 bar
29216 baz
29217
29218 {|
29219 |Foo
29220 bar
29221 baz bang
29222 |}
29223
29224 <!--boo-->foo
29225 bar
29226
29227 foo
29228 bar<span>boo</span>
29229 !! end
29230
29231 !! test
29232 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
29233 !! options
29234 parsoid={
29235 "modes": ["selser"],
29236 "scrubWikitext": true,
29237 "changes": [
29238 [ "p", "html", " a\n b" ]
29239 ]
29240 }
29241 !! wikitext
29242 xyz
29243 !! wikitext/edited
29244 a
29245 b
29246 !! end
29247
29248 !! test
29249 1. New links that end in spaces
29250 !! options
29251 parsoid={
29252 "modes": ["html2wt"],
29253 "scrubWikitext": false
29254 }
29255 !! html/parsoid
29256 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29257 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29258 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29259 !! wikitext
29260 [[Berlin ]]<nowiki/>is the capital of Germany.
29261
29262 [[Foo ]]'''bar'''
29263
29264 [[Boston ]] is a city.
29265 !! end
29266
29267 !! test
29268 2. New links that end in spaces
29269 !! options
29270 parsoid={
29271 "modes": ["html2wt"],
29272 "scrubWikitext": true
29273 }
29274 !! html/parsoid
29275 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29276 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29277 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29278 !! wikitext
29279 [[Berlin]] is the capital of Germany.
29280
29281 [[Foo]] '''bar'''
29282
29283 [[Boston]] is a city.
29284 !! end
29285
29286 !! test
29287 1. Table cells with escapable prefixes
29288 !! options
29289 parsoid={
29290 "modes": ["html2wt"],
29291 "scrubWikitext": false
29292 }
29293 !! html
29294 <table>
29295 <tr><td>a</td></tr>
29296 <tr><td>-</td></tr>
29297 <tr><td>+</td></tr>
29298 </table>
29299 !! wikitext
29300 {|
29301 |a
29302 |-
29303 |<nowiki>-</nowiki>
29304 |-
29305 |<nowiki>+</nowiki>
29306 |}
29307 !! end
29308
29309 !! test
29310 2. Table cells with escapable prefixes
29311 !! options
29312 parsoid={
29313 "modes": ["html2wt"],
29314 "scrubWikitext": true
29315 }
29316 !! html
29317 <table>
29318 <tr><td>a</td></tr>
29319 <tr><td>-</td></tr>
29320 <tr><td>+</td></tr>
29321 </table>
29322 !! wikitext
29323 {|
29324 |a
29325 |-
29326 | -
29327 |-
29328 | +
29329 |}
29330 !! end
29331
29332 !! test
29333 3a. Table cells with escapable prefixes after edits
29334 !! options
29335 parsoid={
29336 "modes": ["selser"],
29337 "scrubWikitext": true,
29338 "changes": [
29339 [ "table tbody tr:first-child td:first-child", "remove"]
29340 ]
29341 }
29342 !! wikitext
29343 {|
29344 |a||-
29345 |}
29346 !! wikitext/edited
29347 {|
29348 | -
29349 |}
29350 !! end
29351
29352 !! test
29353 3b. Table cells with escapable prefixes after edits
29354 !! options
29355 parsoid={
29356 "modes": ["selser"],
29357 "scrubWikitext": true,
29358 "changes": [
29359 [ "table tbody tr:first-child td:first-child", "html", "-" ],
29360 [ "#x", "remove" ]
29361 ]
29362 }
29363 !! wikitext
29364 {|
29365 |pqr
29366 |<span id="x">foo</span>+
29367 |}
29368 !! wikitext/edited
29369 {|
29370 | -
29371 | +
29372 |}
29373 !! end
29374
29375 # FIXME: This test will fail because
29376 # normalization doesn't realize that the id attribute
29377 # will eliminate the escapable scenario
29378 !! test
29379 4a. Table cells without escapable prefixes after edits
29380 !! options
29381 parsoid={
29382 "modes": ["selser"],
29383 "scrubWikitext": true,
29384 "changes": [
29385 [ "#x", "html", "-" ]
29386 ]
29387 }
29388 !! wikitext
29389 {|
29390 | id="x" |abcd
29391 |}
29392 !! wikitext/edited
29393 {|
29394 | id="x" |-
29395 |}
29396 !! end
29397
29398 ## This tests normalizer's ability to discriminate between
29399 ## cells having identical content.
29400 !! test
29401 4b. Table cells without escapable prefixes after edits
29402 !! options
29403 parsoid={
29404 "modes": ["selser"],
29405 "scrubWikitext": true,
29406 "changes": [
29407 [ "td", "html", "-" ]
29408 ]
29409 }
29410 !! wikitext
29411 {|
29412 |a||b
29413 |}
29414 !! wikitext/edited
29415 {|
29416 | -||-
29417 |}
29418 !! end
29419
29420 ## This tests normalizer's ability to not be tripped by
29421 ## comments (and whitespace)
29422 !! test
29423 4c. Table cells without escapable prefixes after edits
29424 !! options
29425 parsoid={
29426 "modes": ["selser"],
29427 "scrubWikitext": true,
29428 "changes": [
29429 [ "table tbody tr td:first-child", "remove" ]
29430 ]
29431 }
29432 !! wikitext
29433 {|
29434 |-
29435 <!--foo--> |a||-
29436 |}
29437 !! wikitext/edited
29438 {|
29439 |-
29440 <!--foo--> | -
29441 |}
29442 !! end
29443
29444 ## This tests normalizer's ability to handle HTML cells
29445 !! test
29446 4d. Table cells without escapable prefixes after edits
29447 !! options
29448 parsoid={
29449 "modes": ["selser"],
29450 "scrubWikitext": true,
29451 "changes": [
29452 [ "td", "html", "-" ]
29453 ]
29454 }
29455 !! wikitext
29456 <table>
29457 <tr><td>a</td></tr>
29458 </table>
29459 !! wikitext/edited
29460 <table>
29461 <tr><td>-</td></tr>
29462 </table>
29463 !! end
29464
29465 ## T111151 Remove font elements without attributes
29466 !! test
29467 5a. font tags without attributes should be dropped in scrubWikitext mode
29468 !! options
29469 parsoid={
29470 "modes": ["html2wt"],
29471 "scrubWikitext": true
29472 }
29473 !! html
29474 <font>foo</font>
29475 <font><font>bar</font></font>
29476 <font class="x">boo</font>
29477 !! wikitext
29478 foo
29479 bar
29480 <font class="x">boo</font>
29481 !! end
29482
29483 !! test
29484 5b. font tags should not be dropped without scrubWikitext being enabled
29485 !! options
29486 parsoid={
29487 "modes": ["html2wt"],
29488 "scrubWikitext": false
29489 }
29490 !! html
29491 <font>foo</font>
29492 !! wikitext
29493 <font>foo</font>
29494 !! end
29495
29496 !! test
29497 Escape nowiki DOM elements
29498 !! options
29499 parsoid=html2wt
29500 !! html/parsoid
29501 <nowiki><i>foo</i></nowiki>
29502 !! wikitext
29503 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
29504 !! end
29505
29506 # This is meant to be an interim fix while we go about figuring out
29507 # how to not introduce these trailing <nowiki/>s in the first place.
29508 !! test
29509 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
29510 !! options
29511 parsoid=html2wt
29512 !! html/parsoid
29513 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
29514 y</p>
29515 <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>
29516 <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>
29517 !! wikitext
29518 x
29519 y
29520
29521 {{echo|
29522 1 = <nowiki/>}}
29523
29524 {{echo|
29525 1 = <nowiki/>
29526 }}
29527 !! end
29528
29529 !! test
29530 New list is serialized on newlines
29531 !! options
29532 parsoid=html2wt
29533 !! html/parsoid
29534 <p>The quick brown fox jumps over the lazy dog.</p><ul>
29535 <li>Yesterday</li>
29536 <li>Today</li>
29537 <li>Tomorrow</li>
29538 </ul><p>The quick onyx goblin jumps over the lazy dwarf.</p>
29539 !! wikitext
29540 The quick brown fox jumps over the lazy dog.
29541
29542 * Yesterday
29543 * Today
29544 * Tomorrow
29545
29546 The quick onyx goblin jumps over the lazy dwarf.
29547 !! end
29548
29549 !! test
29550 New lists in formatting elements serialized w/o newlines
29551 !! options
29552 parsoid=html2wt
29553 !! html/parsoid
29554 <small>
29555
29556 <ul>
29557 <li>123</li>
29558 </ul>
29559
29560 </small>
29561
29562 <small><ul><li>hi</li></ul></small>
29563 !! wikitext
29564 <small>
29565 * 123
29566 </small>
29567
29568 <small>
29569 * hi
29570 </small>
29571 !! end
29572
29573 !! test
29574 New list in table doesn't need newlines
29575 !! options
29576 parsoid=html2wt
29577 !! html/parsoid
29578 <table><tr><td><ul><li>test</li><li>123</li></td></tr></table>
29579 !! wikitext
29580 {|
29581 |
29582 * test
29583 * 123
29584 |}
29585 !! end
29586
29587 # ---------------------------------------------------
29588 # End of tests spec'ing wikitext serialization norms |
29589 # ---------------------------------------------------
29590
29591 # T104032
29592 !! test
29593 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
29594 !! options
29595 parsoid=html2wt
29596 !! html/parsoid
29597 a<p>b</p>
29598 <b>c</b><p>d</p>
29599 <table><tr>
29600 <td>a<p>b</p></td>
29601 <td><b>c</b><p>d</p></td>
29602 </tr></table>
29603 !! wikitext
29604 a
29605
29606 b
29607
29608 '''c'''
29609
29610 d
29611 {|
29612 |a
29613 b
29614 |'''c'''
29615 d
29616 |}
29617 !! end
29618
29619 !! test
29620 Anchor without href scenarios
29621 !! options
29622 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29623 !! html/parsoid
29624 <a class="bc"></a>
29625 <a class="no">dice</a>
29626 <a name="foo"></a>
29627 !! wikitext
29628
29629 dice
29630 <span name="foo"></span>
29631 !! end
29632
29633 !! test
29634 New transclusion added after a list should be serialized after the list
29635 !! options
29636 parsoid=html2wt
29637 !! html/parsoid
29638 <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>
29639 !! wikitext
29640 * a
29641 {{echo|foo}}
29642 !! end
29643
29644 # -----------------------------------------------------------------
29645 # End of section for Parsoid-only html2wt tests for serialization
29646 # of new content
29647 # -----------------------------------------------------------------
29648
29649 # -----------------------------------------------------------------
29650 # The following section of tests are primarily to spec behavior of
29651 # the selective serializer. All these tests have manual selser
29652 # changes. The automated selser changes for all tests handle the
29653 # wide variation of changes, but these tests here capture specs
29654 # deterministically.
29655 # ----------------------------------------------------------------
29656
29657 ## T90517
29658 !! test
29659 Selser: New comments should not be lost
29660 !! options
29661 parsoid={
29662 "modes": ["selser"],
29663 "changes": [
29664 [ "#a", "after", "<!--c1-->" ],
29665 [ "#b", "before", "<!--c2-->" ]
29666 ]
29667 }
29668 !! wikitext
29669 <span id="a">a</span>
29670
29671 <span id="b">b</span>
29672 !! wikitext/edited
29673 <span id="a">a</span><!--c1-->
29674
29675 <!--c2--><span id="b">b</span>
29676 !! end
29677
29678 ## T89383
29679 !! test
29680 Selser: Check for validity of DSR before using it
29681 !! options
29682 parsoid={
29683 "modes": ["selser"],
29684 "changes": [
29685 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
29686 ]
29687 }
29688 !! wikitext
29689 <span id="a">a</span>
29690 !! wikitext/edited
29691 {{DISPLAYTITLE:foo}}
29692 <span id="a">a</span>
29693 !! end
29694
29695 !! test
29696 1. DOMDiff: Changes to <ref> content should be looked up using id
29697 !! options
29698 parsoid={
29699 "modes": ["selser"],
29700 "changes": [
29701 ["#X", "after", "bar"],
29702 ["#Y", "after", "baz"]
29703 ]
29704 }
29705 !! wikitext
29706 X <ref><span id="X">foo</span></ref>
29707 Y <ref name="a" />
29708 <references>
29709 <ref name="a"><span id="Y">foo</span></ref>
29710 </references>
29711 !! wikitext/edited
29712 X <ref><span id="X">foo</span>bar</ref>
29713 Y <ref name="a" />
29714 <references>
29715 <ref name="a"><span id="Y">foo</span>baz</ref>
29716 </references>
29717 !! end
29718
29719 !! test
29720 2. DOMDiff: Changes to <ref> content should be looked up using id
29721 !! options
29722 parsoid={
29723 "modes": ["selser"],
29724 "changes": [
29725 ["#Z", "after", "bar"]
29726 ]
29727 }
29728 !! wikitext
29729 A <ref>foo bar for a</ref>
29730 B <ref group="X" name="b" />
29731
29732 <references />
29733
29734 <references group="X">
29735 <ref name="b"><span id="Z">foo</span></ref>
29736 </references>
29737 !! wikitext/edited
29738 A <ref>foo bar for a</ref>
29739 B <ref group="X" name="b" />
29740
29741 <references />
29742
29743 <references group="X">
29744 <ref name="b"><span id="Z">foo</span>bar</ref>
29745 </references>
29746 !! end
29747
29748 !! test
29749 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
29750 !! options
29751 parsoid={
29752 "modes": ["selser"],
29753 "changes": [
29754 [ "div:first-child", "text", "bar" ]
29755 ]
29756 }
29757 !! wikitext
29758 <div style="{{1x|color:red;}}%">foo</div>
29759 !! wikitext/edited
29760 <div style="{{1x|color:red;}}%">bar</div>
29761 !! end
29762
29763 !! test
29764 Empty LI (T49673)
29765 !! wikitext
29766 *a
29767 *
29768 *
29769 *b
29770 !! html+tidy
29771 <ul><li>a</li>
29772 <li class="mw-empty-elt"></li>
29773 <li class="mw-empty-elt"></li>
29774 <li>b</li></ul>
29775 !! end
29776
29777 !! test
29778 Thumbnail output
29779 !! wikitext
29780 [[File:Thumb.png|thumb]]
29781 !! html/php+tidy
29782 <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>
29783 !! html/parsoid
29784 <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>
29785 !! end
29786
29787 !! test
29788 unclosed internal link XSS (T137264)
29789 !! wikitext
29790 [[#%3Cscript%3Ealert(1)%3C/script%3E|
29791 !! html/php
29792 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
29793 </p>
29794 !! html/parsoid
29795 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
29796 !! end
29797
29798 !! test
29799 Validating that <style> isn't eaten by tidy (T167349)
29800 !! options
29801 styletag=1
29802 !! wikitext
29803 <div class="foo">
29804 <style>.foo::before { content: "<foo>"; }</style>
29805 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
29806 </div>
29807 !! html/php+tidy
29808 <div class="foo">
29809 <style>.foo::before { content: "<foo>"; }</style>
29810 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
29811 </div>
29812 !! end
29813
29814 !! test
29815 Validating that <style> isn't wrapped in a paragraph (T186965)
29816 !! options
29817 styletag=1
29818 !! wikitext
29819 A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
29820
29821 <style>.foo::before { content: "<foo>"; }</style>
29822
29823 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
29824
29825 But if it's on a line with other content, let it be wrapped.
29826
29827 <style>.foo::before { content: "<foo>"; }</style> bar
29828
29829 foo <style>.foo::before { content: "<foo>"; }</style>
29830
29831 foo <style>.foo::before { content: "<foo>"; }</style> bar
29832
29833 And the same if we have non-paragraph-breaking whitespace
29834
29835 foo
29836 <style>.foo::before { content: "<foo>"; }</style>
29837 bar
29838 !! html/php
29839 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
29840 </p>
29841 <style>.foo::before { content: "<foo>"; }</style>
29842 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
29843 <p>But if it's on a line with other content, let it be wrapped.
29844 </p><p><style>.foo::before { content: "<foo>"; }</style> bar
29845 </p><p>foo <style>.foo::before { content: "<foo>"; }</style>
29846 </p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
29847 </p><p>And the same if we have non-paragraph-breaking whitespace
29848 </p><p>foo
29849 <style>.foo::before { content: "<foo>"; }</style>
29850 bar
29851 </p>
29852 !! end
29853
29854 !! test
29855 Validating that <link> isn't wrapped in a paragraph (T186965)
29856 !! options
29857 styletag=1
29858 !! wikitext
29859 A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
29860
29861 <link rel="foo" href="bar"/>
29862
29863 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
29864
29865 But if it's on a line with other content, let it be wrapped.
29866
29867 <link rel="foo" href="bar"/> bar
29868
29869 foo <link rel="foo" href="bar"/>
29870
29871 foo <link rel="foo" href="bar"/> bar
29872
29873 And the same if we have non-paragraph-breaking whitespace
29874
29875 foo
29876 <link rel="foo" href="bar"/>
29877 bar
29878 !! html/php
29879 <p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
29880 </p>
29881 <link rel="foo" href="bar"/>
29882 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
29883 <p>But if it's on a line with other content, let it be wrapped.
29884 </p><p><link rel="foo" href="bar"/> bar
29885 </p><p>foo <link rel="foo" href="bar"/>
29886 </p><p>foo <link rel="foo" href="bar"/> bar
29887 </p><p>And the same if we have non-paragraph-breaking whitespace
29888 </p><p>foo
29889 <link rel="foo" href="bar"/>
29890 bar
29891 </p>
29892 !! end
29893
29894 !! test
29895 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
29896 !! config
29897 wgFragmentMode=[ 'html5', 'legacy' ]
29898 !! wikitext
29899 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
29900 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
29901 !! html/php
29902 <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>
29903 <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>
29904 </p>
29905 !! html/parsoid
29906 <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>
29907 <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>
29908 !! end
29909
29910 !! test
29911 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
29912 !! config
29913 wgFragmentMode=[ 'legacy' ]
29914 !! wikitext
29915 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
29916 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
29917 !! html/php
29918 <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>
29919 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
29920 </p>
29921 !! end
29922
29923 !! test
29924 Decoding of HTML entities in embedded HTML tags
29925 !! wikitext
29926 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
29927 !! html/php
29928 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
29929
29930 !! html/parsoid
29931 <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>
29932 !! end
29933
29934 !! test
29935 Decoding of HTML entities in indicator names for IDs (T104196)
29936 !! options
29937 parsoid=wt2html,html2html
29938 showindicators
29939 !! wikitext
29940 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
29941 !! html/php
29942 1&2&3&amp;4&amp;amp;5=Indicator
29943
29944 !! html/parsoid
29945 <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>
29946 !! end
29947
29948 # this version of the test strips out the ambiguity so Parsoid rts cleanly
29949 !! test
29950 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
29951 !! options
29952 showindicators
29953 !! wikitext
29954 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
29955 !! html/php
29956 1&2&3&amp;4&amp;amp;5=Indicator
29957
29958 !! html/parsoid
29959 <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>
29960 !! end
29961
29962 # This fragment mode is what Parsoid supports.
29963 !! test
29964 HTML5 ids: fallback to legacy
29965 !! config
29966 wgFragmentMode=[ 'html5', 'legacy' ]
29967 !! wikitext
29968 ==Foo bar==
29969
29970 ==foo Bar==
29971
29972 ==Тест==
29973
29974 ==Тест==
29975
29976 ==тест==
29977
29978 ==Hey < # " > % : '==
29979 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
29980
29981 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
29982
29983 <!-- These two links should produce identical HTML -->
29984 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
29985
29986 !! html/php
29987 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
29988 <ul>
29989 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
29990 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
29991 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
29992 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
29993 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
29994 <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>
29995 </ul>
29996 </div>
29997
29998 <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>
29999 <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>
30000 <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>
30001 <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>
30002 <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>
30003 <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>
30004 <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>
30005 </p><p>💩 <span id="💩"></span>
30006 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
30007 </p>
30008 !! html/parsoid
30009 <h2 id="Foo_bar">Foo bar</h2>
30010
30011 <h2 id="foo_Bar_2">foo Bar</h2>
30012
30013 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2>
30014
30015 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2>
30016
30017 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>
30018
30019 <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>
30020 <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>
30021
30022 <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>
30023
30024 <!-- These two links should produce identical HTML -->
30025 <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>
30026 !! end
30027
30028 # Parsoid doesn't support this mode
30029 !! test
30030 HTML5 ids: legacy with a fallback to modern
30031 !! config
30032 wgFragmentMode=[ 'legacy', 'html5' ]
30033 !! wikitext
30034 ==Foo bar==
30035
30036 ==foo Bar==
30037
30038 ==Тест==
30039
30040 ==Тест==
30041
30042 ==тест==
30043
30044 ==Hey < # " > % : '==
30045 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30046
30047 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30048
30049 <!-- These two links should produce identical HTML -->
30050 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30051
30052 !! html/php
30053 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
30054 <ul>
30055 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30056 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30057 <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>
30058 <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>
30059 <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>
30060 <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>
30061 </ul>
30062 </div>
30063
30064 <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>
30065 <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>
30066 <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>
30067 <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>
30068 <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>
30069 <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>
30070 <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>
30071 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
30072 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
30073 </p>
30074 !! end
30075
30076 # Parsoid doesn't support this mode.
30077 !! test
30078 HTML5 ids: no legacy
30079 !! config
30080 wgFragmentMode=[ 'html5' ]
30081 !! wikitext
30082 ==Foo bar==
30083
30084 ==foo Bar==
30085
30086 ==Тест==
30087
30088 ==Тест==
30089
30090 ==тест==
30091
30092 ==Hey < # " > % : '==
30093 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30094
30095 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30096
30097 <!-- These two links should produce identical HTML -->
30098 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30099
30100 !! html/php
30101 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
30102 <ul>
30103 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30104 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30105 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
30106 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
30107 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
30108 <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>
30109 </ul>
30110 </div>
30111
30112 <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>
30113 <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>
30114 <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>
30115 <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>
30116 <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>
30117 <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>
30118 <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>
30119 </p><p>💩 <span id="💩"></span>
30120 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
30121 </p>
30122 !! end
30123
30124 !! test
30125 T90902: Normalize weird characters in section IDs
30126 !! config
30127 wgFragmentMode=[ 'html5', 'legacy' ]
30128 !! wikitext
30129 ==Foo&nbsp;bar==
30130 [[#Foo&nbsp;bar]]
30131
30132 !! html/php
30133 <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>
30134 <p><a href="#Foo_bar">#Foo&#160;bar</a>
30135 </p>
30136 !! html/parsoid
30137 <h2 id="Foo_bar"> Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>bar </h2>
30138 <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>
30139 !! end
30140
30141 !! test
30142 T51672: Test for brackets in attributes of elements in external link texts
30143 !! wikitext
30144 [http://example.com/ link <span title="title with [brackets]">span</span>]
30145 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
30146
30147 !! html/php
30148 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
30149 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
30150 </p>
30151 !! html/parsoid
30152 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
30153 <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>
30154 !! end
30155
30156 !! test
30157 T72875: Test for brackets in attributes of elements in internal link texts
30158 !! wikitext
30159 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
30160 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
30161
30162 !! html/php
30163 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
30164 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
30165 </p>
30166 !! html/parsoid
30167 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
30168 <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>
30169 !! end
30170
30171 !! test
30172 T179544: {{anchorencode:}} output should be always usable in links
30173 !! config
30174 wgFragmentMode=[ 'html5' ]
30175 !! wikitext
30176 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
30177 !! html/php
30178 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
30179 </p>
30180 !! html/parsoid
30181 <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>
30182 !! end
30183
30184 ## ------------------------------
30185 ## Parsoid section-wrapping tests
30186 ## ------------------------------
30187 !! test
30188 Section wrapping for well-nested sections (no leading content)
30189 !! options
30190 parsoid={
30191 "wrapSections": true
30192 }
30193 !! wikitext
30194 =1=
30195 a
30196
30197 =2=
30198 b
30199
30200 ==2.1==
30201 c
30202
30203 ==2.2==
30204 d
30205
30206 ===2.2.1===
30207 e
30208
30209 =3=
30210 f
30211 !! html/parsoid
30212 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30213 <p>a</p>
30214
30215 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
30216 <p>b</p>
30217
30218 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
30219 <p>c</p>
30220
30221 </section><section data-mw-section-id="4"><h2 id="2.2">2.2</h2>
30222 <p>d</p>
30223
30224 <section data-mw-section-id="5"><h3 id="2.2.1">2.2.1</h3>
30225 <p>e</p>
30226
30227 </section></section></section><section data-mw-section-id="6"><h1 id="3">3</h1>
30228 <p>f</p>
30229
30230 </section>
30231 !! end
30232
30233 !! test
30234 Section wrapping for well-nested sections (with leading content)
30235 !! options
30236 parsoid={
30237 "wrapSections": true
30238 }
30239 !! wikitext
30240 Para 1.
30241
30242 Para 2 with a <div>nested in it</div>
30243
30244 Para 3.
30245
30246 =1=
30247 a
30248
30249 =2=
30250 b
30251
30252 ==2.1==
30253 c
30254 !! html/parsoid
30255 <section data-mw-section-id="0"><p>Para 1.</p>
30256
30257 <p>Para 2 with a </p><div>nested in it</div>
30258
30259 <p>Para 3.</p>
30260
30261 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
30262 <p>a</p>
30263
30264 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
30265 <p>b</p>
30266
30267 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
30268 <p>c</p>
30269
30270 </section></section>
30271 !! end
30272
30273 !! test
30274 Section wrapping with template-generated sections (good nesting 1)
30275 !! options
30276 parsoid={
30277 "wrapSections": true
30278 }
30279 !! wikitext
30280 =1=
30281 a
30282
30283 {{echo|1=
30284 ==1.1==
30285 b
30286 }}
30287
30288 ==1.2==
30289 c
30290
30291 =2=
30292 d
30293 !! html/parsoid
30294 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30295 <p>a</p>
30296
30297 <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">
30298 </span><p about="#mwt1">b</p>
30299 </section><section data-mw-section-id="3"><h2 id="1.2">1.2</h2>
30300 <p>c</p>
30301
30302 </section></section><section data-mw-section-id="4"><h1 id="2">2</h1>
30303 <p>d</p></section>
30304 !! end
30305
30306 # In this example, the template scope is mildly expanded to incorporate the
30307 # trailing newline after the transclusion since that is part of section 1.1.1
30308 !! test
30309 Section wrapping with template-generated sections (good nesting 2)
30310 !! options
30311 parsoid={
30312 "wrapSections": true,
30313 "modes": ["wt2html", "wt2wt"]
30314 }
30315 !! wikitext
30316 =1=
30317 a
30318
30319 {{echo|1=
30320 ==1.1==
30321 b
30322 ===1.1.1===
30323 d
30324 }}
30325 =2=
30326 e
30327 !! html/parsoid
30328 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30329 <p>a</p>
30330
30331 <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">
30332 </span><p about="#mwt1">b</p><span about="#mwt1">
30333 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1">
30334 </span><p about="#mwt1">d</p><span about="#mwt1">
30335 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2">2</h1>
30336 <p>e</p></section>
30337 !! end
30338
30339 # In this example, the template scope is mildly expanded to incorporate the
30340 # trailing newline after the transclusion since that is part of section 1.2.1
30341 !! test
30342 Section wrapping with template-generated sections (good nesting 3)
30343 !! options
30344 parsoid={
30345 "wrapSections": true,
30346 "modes": ["wt2html", "wt2wt"]
30347 }
30348 !! wikitext
30349 =1=
30350 a
30351
30352 {{echo|1=
30353 x
30354 ==1.1==
30355 b
30356 ==1.2==
30357 c
30358 ===1.2.1===
30359 d
30360 }}
30361 =2=
30362 e
30363 !! html/parsoid
30364 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
30365 <p>a</p>
30366
30367 <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">
30368 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1">
30369 </span><p about="#mwt1">b</p><span about="#mwt1">
30370 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
30371 </span><p about="#mwt1">c</p><span about="#mwt1">
30372 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
30373 </span><p about="#mwt1">d</p><span about="#mwt1">
30374 </span></section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1>
30375 <p>e</p></section>
30376 !! end
30377
30378 # Because of section-wrapping and template-wrapping interactions,
30379 # the scope of the template is expanded so that the template markup
30380 # is valid in the presence of <section> tags.
30381 # This exercises the s1 is null scenario in the wrapSections code
30382 !! test
30383 Section wrapping with template-generated sections (bad nesting 1)
30384 !! options
30385 parsoid={
30386 "wrapSections": true
30387 }
30388 !! wikitext
30389 <div>
30390 a
30391
30392 {{echo|
30393 =1=
30394 b
30395 }}
30396
30397 c
30398 </div>
30399 !! html/parsoid
30400 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
30401 <p>a</p>
30402
30403 <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"]}'>
30404 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1">1</h1><span about="#mwt1">
30405 </span><p about="#mwt1">b
30406 </p><span about="#mwt1">
30407
30408 </span><p about="#mwt1">c</p><span about="#mwt1">
30409 </span></section></div></section>
30410 !! end
30411
30412 # Because of section-wrapping and template-wrapping interactions,
30413 # the scope of the template is expanded so that the template markup
30414 # is valid in the presence of <section> tags.
30415 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
30416 !! test
30417 Section wrapping with template-generated sections (bad nesting 2)
30418 !! options
30419 parsoid={
30420 "wrapSections": true
30421 }
30422 !! wikitext
30423 =1=
30424 a
30425
30426 {{echo|1=
30427 =2=
30428 b
30429 ==2.1==
30430 c
30431 }}
30432
30433 d
30434
30435 =3=
30436 e
30437 !! html/parsoid
30438 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
30439 <p>a</p>
30440
30441 </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">
30442 </span><p about="#mwt1">b</p><span about="#mwt1">
30443 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1">
30444 </span><p about="#mwt1">c</p><span about="#mwt1">
30445
30446 </span><p about="#mwt1">d</p><span about="#mwt1">
30447
30448 </span></section></section><section data-mw-section-id="4"><h1 id="3">3</h1>
30449 <p>e</p></section>
30450 !! end
30451
30452 # Because of section-wrapping and template-wrapping interactions,
30453 # additional template wrappers are added to <section> tags
30454 # so that template wrapping semantics are valid whether section
30455 # tags are retained or stripped. But, the template scope can expand
30456 # greatly when accounting for section tags.
30457 # This exercises the s1 and s2 are in different subtrees scenario
30458 !! test
30459 Section wrapping with template-generated sections (bad nesting 3)
30460 !! options
30461 parsoid={
30462 "wrapSections": true,
30463 "modes": ["wt2html", "wt2wt"]
30464 }
30465 !! wikitext
30466 =1=
30467 a
30468
30469 {{echo|1=
30470 ==1.2==
30471 b
30472 =2=
30473 c
30474 }}
30475
30476 d
30477
30478 =3=
30479 e
30480 !! html/parsoid
30481 <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>
30482 <p>a</p>
30483
30484 <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">
30485 </span><p about="#mwt1">b</p><span about="#mwt1">
30486 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1">
30487 </span><p about="#mwt1">c</p>
30488
30489 <p>d</p>
30490 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3">3</h1>
30491 <p>e</p></section>
30492 !! end
30493
30494 !! test
30495 Section wrapping with uneditable lead section + div wrapping multiple sections
30496 !! options
30497 parsoid={
30498 "wrapSections": true
30499 }
30500 !! wikitext
30501 foo
30502
30503 <div style="border:1px solid red;">
30504 =1=
30505 a
30506
30507 ==1.1==
30508 b
30509
30510 =2=
30511 c
30512 </div>
30513
30514 =3=
30515 d
30516
30517 ==3.1==
30518 e
30519 !! html/parsoid
30520 <section data-mw-section-id="-1"><p>foo</p>
30521
30522 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
30523 <section data-mw-section-id="1"><h1 id="1">1</h1>
30524 <p>a</p>
30525
30526 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
30527 <p>b</p>
30528
30529 </section></section><section data-mw-section-id="-1"><h1 id="2">2</h1>
30530 <p>c</p>
30531 </section></div>
30532
30533 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
30534 <p>d</p>
30535
30536 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
30537 <p>e</p>
30538 </section></section>
30539 !! end
30540
30541 !! test
30542 Section wrapping with editable lead section + div overlapping multiple sections
30543 !! options
30544 parsoid={
30545 "wrapSections": true
30546 }
30547 !! wikitext
30548 foo
30549
30550 =1=
30551 a
30552 <div style="border:1px solid red;">
30553 b
30554
30555 ==1.1==
30556 c
30557
30558 =2=
30559 d
30560 </div>
30561 e
30562
30563 =3=
30564 f
30565
30566 ==3.1==
30567 g
30568 !! html/parsoid
30569 <section data-mw-section-id="0"><p>foo</p>
30570
30571 </section><section data-mw-section-id="-1"><h1 id="1">1</h1>
30572 <p>a</p>
30573 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
30574 <p>b</p>
30575
30576 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
30577 <p>c</p>
30578
30579 </section><section data-mw-section-id="-1"><h1 id="2">2</h1>
30580 <p>d</p>
30581 </section></div>
30582 <p>e</p>
30583
30584 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
30585 <p>f</p>
30586
30587 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
30588 <p>g</p>
30589 </section></section>
30590 !! end
30591
30592 !! test
30593 HTML header tags should not be wrapped in section tags
30594 !! options
30595 parsoid={
30596 "wrapSections": true
30597 }
30598 !! wikitext
30599 foo
30600
30601 <h1>a</h1>
30602
30603 =b=
30604
30605 <h1>c</h1>
30606
30607 =d=
30608 !! html/parsoid
30609 <section data-mw-section-id="0"><p>foo</p>
30610
30611 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
30612
30613 </section><section data-mw-section-id="1"><h1 id="b">b</h1>
30614
30615 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
30616
30617 </section><section data-mw-section-id="2"><h1 id="d">d</h1></section>
30618 !! end
30619
30620 !! test
30621 Lead section containing only whitespace and comments.
30622 !! options
30623 parsoid={
30624 "wrapSections": true
30625 }
30626 !! wikitext
30627
30628 <!-- this is a comment, presumably significant to editors -->
30629 =1=
30630 a
30631
30632 =2=
30633 b
30634 !! html/parsoid
30635 <section data-mw-section-id="0" data-parsoid="{}">
30636 <!-- this is a comment, presumably significant to editors -->
30637 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
30638 <p>a</p>
30639
30640 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
30641 <p>b</p></section>
30642 !! end
30643
30644 !! test
30645 Pseudo-sections emitted by templates should have id -2
30646 !! options
30647 parsoid={
30648 "wrapSections": true
30649 }
30650 !! wikitext
30651 foo
30652 {{echo|<div>
30653 ==a==
30654 ==b==
30655 </div>
30656 }}
30657 !! html/parsoid
30658 <section data-mw-section-id="-1"><p>foo</p>
30659 </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}}]}'>
30660 <section data-mw-section-id="-1"><h2 id="a">a</h2>
30661 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
30662 </section></div><span about="#mwt1">
30663 </span></section>
30664 !! end
30665
30666 ##########################################################################
30667 Tests demonstrating white-space insensitivity in input wikitext
30668 for wikitext headings, wikitext list items, and wikitext table captions,
30669 headings, and cells. HTML versions of the same should preserve whitespace.
30670 ##########################################################################
30671 !! test
30672 Trim whitespace in wikitext headings, list items, table captions, headings, and cells
30673 !! wikitext
30674 __NOTOC__
30675 == <!--c1--> <!--c2--> Spaces <!--c3--> <!--c4--> ==
30676 == <!--c2--> <!--c2--> Tabs <!--c3--><!--c4--> ==
30677 * <!--c1--> <!--c2--> List item <!--c3--> <!--c4-->
30678 ; <!--term to define--> term : <!--term's definition--> definition
30679 {|
30680 |+ <!--c1--> <!--c2--> Table Caption <!--c3--> <!--c4-->
30681 |-
30682 ! <!--c1--> <!--c2--> Table Heading 1 <!--c3--> <!--c4--> !! Table Heading 2 <!--c5-->
30683 |-
30684 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
30685 |-
30686 | class="foo" || <!--c1--> <!--c2--> Table Cell 3 <!--c3--> <!--c4-->
30687 |-
30688 | <!--c1--> testing [[one|two]] <!--c2--> | <!--c3--> some content
30689 |}
30690 : {|
30691 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
30692 |} foo <!--c1-->
30693 !! html/php+tidy
30694 <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>
30695 <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>
30696 <ul><li>List item</li></ul>
30697 <dl><dt>term&#160;</dt>
30698 <dd>definition</dd></dl>
30699 <table>
30700 <caption>Table Caption
30701 </caption>
30702 <tbody><tr>
30703 <th>Table Heading 1</th>
30704 <th>Table Heading 2
30705 </th></tr>
30706 <tr>
30707 <td>Table Cell 1</td>
30708 <td>Table Cell 2
30709 </td></tr>
30710 <tr>
30711 <td>class="foo"</td>
30712 <td>Table Cell 3
30713 </td></tr>
30714 <tr>
30715 <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
30716 </td></tr></tbody></table>
30717 <dl><dd><table>
30718 <tbody><tr>
30719 <td>Table Cell 1</td>
30720 <td>Table Cell 2
30721 </td></tr></tbody></table> foo</dd></dl>
30722 !! end
30723
30724 # Looks like <caption> is not accepted in HTML
30725 !! test
30726 Do not trim whitespace in HTML headings, list items, table captions, headings, and cells
30727 !! wikitext
30728 __NOTOC__
30729 <h2> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
30730 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
30731 <table>
30732 <tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> <th></tr>
30733 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> <th></tr>
30734 </table>
30735 !! html/php+tidy
30736 <h2><span class="mw-headline" id="Heading"> Heading </span></h2>
30737 <ul><li> List item </li></ul>
30738 <table>
30739 <tbody><tr><th> Table Heading </th><th></th></tr>
30740 <tr><td> Table Cell </td><th></th></tr>
30741 </tbody></table>
30742 !! end
30743
30744 !! test
30745 Do not trim whitespace in links and quotes
30746 !! wikitext
30747 foo '' <!--c1--> italic <!--c2--> '' and ''' <!--c3--> bold <!--c4--> '''
30748 [[Foo| some text ]]
30749 !! html/php+tidy
30750 <p>foo <i> italic </i> and <b> bold </b>
30751 <a href="/wiki/Foo" title="Foo"> some text </a>
30752 </p>
30753 !! end
30754
30755 !! test
30756 Remove p tags surrounding a single element in a figcaption
30757 !! options
30758 parsoid=html2wt
30759 !! wikitext
30760 [[File:Foobar.jpg|right|200x200px|Caption]]
30761 !! html/parsoid
30762 <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>
30763 !! end
30764
30765 !! test
30766 Selser preserves lack of newline before list and allows newline after the list
30767 !! options
30768 parsoid={
30769 "modes": ["selser"],
30770 "scrubWikitext": true,
30771 "changes": [
30772 [ "ul", "after", "<p>footer</p>" ]
30773 ]
30774 }
30775 !! wikitext
30776 header
30777 *foo
30778 *bar
30779 !! wikitext/edited
30780 header
30781 *foo
30782 *bar
30783
30784 footer
30785 !! end
30786
30787
30788 !! test
30789 Selser does not introduce newlines between unedited paragraph preceding the list
30790 !! options
30791 parsoid={
30792 "modes": ["selser"],
30793 "changes": [
30794 [ "table tbody tr td p:last-child", "empty" ]
30795 ]
30796 }
30797 !! wikitext
30798 {|
30799 |
30800 header
30801 *foo
30802 *bar
30803 footer
30804 |}
30805 !! wikitext/edited
30806 {|
30807 |
30808 header
30809 *foo
30810 *bar
30811
30812 |}
30813 !! end
30814
30815 !! test
30816 Selser does not introduce newlines between unedited paragraph following the list
30817 !! options
30818 parsoid={
30819 "modes": ["selser"],
30820 "changes": [
30821 [ "table tbody tr td p:first-child", "empty" ]
30822 ]
30823 }
30824 !! wikitext
30825 {|
30826 |
30827 header
30828 *foo
30829 *bar
30830 footer
30831 |}
30832 !! wikitext/edited
30833 {|
30834 |
30835
30836 *foo
30837 *bar
30838 footer
30839 |}
30840 !! end
30841
30842 !! test
30843 Remove a list item but do not insert newline above list
30844 !! options
30845 parsoid={
30846 "modes": ["selser"],
30847 "changes": [
30848 [ "ul li:last-child", "remove" ]
30849 ]
30850 }
30851 !! wikitext
30852 header
30853 *foo
30854 *bar
30855 footer
30856 !! wikitext/edited
30857 header
30858 *foo
30859 footer
30860 !! end
30861
30862 !! test
30863 Check soft hyphens as entities (&shy;) in displaytitle (T66528)
30864 !! options
30865 showtitle
30866 title=[[Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon]]
30867 !! wikitext
30868 {{DISPLAYTITLE:Lopado&shy;temacho&shy;selacho&shy;galeo&shy;kranio&shy;leipsano&shy;drim&shy;hypo&shy;trimmato&shy;silphio&shy;parao&shy;melito&shy;katakechy&shy;meno&shy;kichl&shy;epi&shy;kossypho&shy;phatto&shy;perister&shy;alektryon&shy;opte&shy;kephallio&shy;kigklo&shy;peleio&shy;lagoio&shy;siraio&shy;baphe&shy;tragano&shy;pterygon}}
30869 !! html/php
30870 Lopado&#173;temacho&#173;selacho&#173;galeo&#173;kranio&#173;leipsano&#173;drim&#173;hypo&#173;trimmato&#173;silphio&#173;parao&#173;melito&#173;katakechy&#173;meno&#173;kichl&#173;epi&#173;kossypho&#173;phatto&#173;perister&#173;alektryon&#173;opte&#173;kephallio&#173;kigklo&#173;peleio&#173;lagoio&#173;siraio&#173;baphe&#173;tragano&#173;pterygon
30871
30872 !! end
30873
30874 !! test
30875 Check soft hyphens as Unicode characters (U+00AD) in displaytitle (T66528)
30876 !! options
30877 showtitle
30878 title=[[Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralektryonoptekephalliokigklopeleiolagoiosiraiobaphetraganopterygon]]
30879 !! wikitext
30880 {{DISPLAYTITLE:Lopado­temacho­selacho­galeo­kranio­leipsano­drim­hypo­trimmato­silphio­parao­melito­katakechy­meno­kichl­epi­kossypho­phatto­perister­alektryon­opte­kephallio­kigklo­peleio­lagoio­siraio­baphe­tragano­pterygon}}
30881 !! html/php
30882 Lopado­temacho­selacho­galeo­kranio­leipsano­drim­hypo­trimmato­silphio­parao­melito­katakechy­meno­kichl­epi­kossypho­phatto­perister­alektryon­opte­kephallio­kigklo­peleio­lagoio­siraio­baphe­tragano­pterygon
30883
30884 !! end