Merge "mediawiki.ui: Remove unused `.mw-ui-checked` class"
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
1 # MediaWiki Parser test cases
2 # Some taken from https://meta.wikimedia.org/wiki/Parser_testing
3 # All (C) their respective authors and released under the GPL
4 #
5 # The syntax should be fairly self-explanatory.
6 #
7 # Currently supported test options:
8 # One of the following three:
9 #
10 # (default) generate HTML output
11 # pst apply pre-save transform
12 # msg apply message transform
13 #
14 # Plus any combination of these:
15 #
16 # cat add category links
17 # (ignored by Parsoid, since it emits <link>s)
18 # ill add inter-language links
19 # (ignored by Parsoid, since it emits <link>s)
20 # subpage enable subpages (disabled by default)
21 # title=[[XXX]] run test using article title XXX
22 # language=XXX set content language to XXX for this test
23 # variant=XXX set the variant of language for this test (eg zh-tw)
24 # disabled do not run test
25 # parsoid parsoid-specific options (not run by PHP parser unless
26 # the test includes an html/php section)
27 # php php-only test (not run by the parsoid parser unless
28 # the test includes an html/parsoid section)
29 # showtitle make the first line the title
30 # showindicators make the first lines the page status indicators
31 # comment run through Linker::formatComment() instead of main parser
32 # local format section links in edit comment text as local links
33 # notoc disable table of contents
34 # thumbsize=NNN set the default thumb size to NNNpx for this test
35 # wrap include the normal wrapper <div class="mw-parser-output"> (since 1.30)
36 #
37 # You can also set the following parser properties via test options:
38 # wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
39 # wgLinkHolderBatchSize, wgRawHtml, wgInterwikiMagic,
40 # wgEnableMagicLinks, wgMediaInTargetLanguage
41 #
42 # For testing purposes, temporary articles can created:
43 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
44 # where '/' denotes a newline.
45
46 # This is the standard article assumed to exist.
47 !! article
48 Main Page
49 !! text
50 blah blah
51 !! endarticle
52
53 !!article
54 Foo
55 !!text
56 FOO
57 !!endarticle
58
59 !!article
60 Foo''s bar''s
61 !!text
62 Article titles can contain single quotes!
63 !!endarticle
64
65 !!article
66 Template:Foo
67 !!text
68 FOO
69 !!endarticle
70
71 !! article
72 Template:redirect to foo
73 !! text
74 #REDIRECT [[Template:Foo]]
75 !! endarticle
76
77 !! article
78 Template:Blank
79 !! text
80 !! endarticle
81
82 !! article
83 Template:pipe
84 !! text
85 |
86 !! endarticle
87
88 !! article
89 Template:=
90 !! text
91 <nowiki>=</nowiki>
92 !! endarticle
93
94 !!article
95 MediaWiki:bad image list
96 !!text
97 * [[File:Bad.jpg]] except [[Nasty page]]
98 !!endarticle
99
100 !! article
101 Template:inner list
102 !! text
103 * item 1
104 !! endarticle
105
106 !! article
107 Template:tbl-start
108 !! text
109 {|
110 !! endarticle
111
112 !! article
113 Template:tbl-end
114 !! text
115 |}
116 !! endarticle
117
118 !! article
119 Template:echo
120 !! text
121 {{{1}}}
122 !! endarticle
123
124 !! article
125 Template:echo3
126 !! text
127 {{{1}}}
128 {{{1}}}
129 {{{1}}}
130 !! endarticle
131
132 // For Serbian; localize Template namespace
133 !! article
134 Шаблон:Echo
135 !! text
136 {{{1}}}
137 !! endarticle
138
139 !! article
140 Template:echo_with_span
141 !! text
142 <span>{{{1}}}</span>
143 !! endarticle
144
145 !! article
146 Template:echo_with_div
147 !! text
148 <div>{{{1}}}</div>
149 !! endarticle
150
151 !! article
152 Template:echo with depth
153 !! text
154 {{echo|{{{1}}}}}
155 !! endarticle
156
157 !! article
158 Template:blank_param
159 !! text
160 {{{1}}}
161 {{{}}}
162 !! endarticle
163
164 !! article
165 Template:table_attribs
166 !! text
167 <noinclude>
168 |</noinclude>style="color:red;"|Foo
169 !! endarticle
170
171 !! article
172 Template:table_attribs_2
173 !! text
174 <noinclude>
175 |</noinclude>style="color:red;"|Foo
176 |Bar||Baz
177 !! endarticle
178
179 !! article
180 Template:table_attribs_3
181 !! text
182 <noinclude>
183 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo
184 !! endarticle
185
186 !! article
187 Template:table_attribs_4
188 !! text
189 | style="background-color:#DC241f;" width="10px" |
190 !! endarticle
191
192 !! article
193 Template:table_attribs_5
194 !! text
195 <noinclude>
196 |</noinclude>style="color:red;"||Bar
197 !! endarticle
198
199 !! article
200 Template:table_attribs_6
201 !! text
202 style="background: <nowiki>
203
204
205 red;</nowiki>" |
206 !! endarticle
207
208 !! article
209 Template:table_attribs_7
210 !! text
211 <noinclude>
212 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
213 !! endarticle
214
215 !! article
216 Template:table_header_cells
217 !! text
218 {{table_attribs}}!!style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
219 !! endarticle
220
221 !! article
222 Template:table_cells
223 !! text
224 {{table_attribs}}||style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
225 !! endarticle
226
227 !! article
228 Template:PartialTable
229 !! text
230 {|
231 |-
232 !! endarticle
233
234 !! article
235 Template:image_attribs
236 !! text
237 <noinclude>
238 [[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
239 !! endarticle
240
241 ## See T48811 for details
242 !! article
243 Template:mixed_attr_content_template
244 !! text
245 style="color:red;" title="T48811"
246 |-
247 |foo
248 !! endarticle
249
250 !! article
251 Template:definition_list
252 !! text
253 one
254 ::two
255 !! endarticle
256
257 !! article
258 A?b
259 !! text
260 Weirdo titles!
261 !! endarticle
262
263 !!article
264 Template:Bullet
265 !!text
266 *Bar
267 !!endarticle
268
269 !!article
270 Template:OpenTable
271 !!text
272 {|
273 !!endarticle
274
275 !!article
276 Template:EmptyLITest
277 !!text
278 *a
279 *
280 *
281 *b
282 !!endarticle
283
284 !!article
285 Template:EmptyTRTest
286 !!text
287 {|
288 |-
289 |-
290 |foo
291 |-
292 |-
293 |bar
294 |}
295 !!endarticle
296
297 !!article
298 Template:EmptyTRWithHTMLAttrTest
299 !!text
300 <table>
301 <tr align="center"></tr>
302 <tr><td>foo</td></tr>
303 <tr align="center"></tr>
304 <tr><td>bar</td></tr>
305 </table>
306 !!endarticle
307
308 !! article
309 Template:With: Colon
310 !! text
311 Template with colon
312 !! endarticle
313
314 ###
315 ### Basic tests
316 ###
317
318 !! test
319 Blank input
320 !! wikitext
321 !! html
322 !! end
323
324 !! test
325 Simple paragraph
326 !! wikitext
327 This is a simple paragraph.
328 !! html
329 <p>This is a simple paragraph.
330 </p>
331 !! end
332
333 !! test
334 Paragraphs with extra newline spacing
335 !! wikitext
336 a
337
338 b (+2 nls)
339
340
341 c (+3 nls)
342
343
344
345 d (+4 nls)
346
347
348
349
350 e (+5 nls)
351 !! html
352 <p>a
353 </p><p>b (+2 nls)
354 </p><p><br />
355 c (+3 nls)
356 </p><p><br />
357 </p><p>d (+4 nls)
358 </p><p><br />
359 </p><p><br />
360 e (+5 nls)
361 </p>
362 !! end
363
364 !! test
365 Paragraphs with newline spacing with comment lines in between
366 !! wikitext
367 ----
368 a
369 <!--foo-->
370 b
371 ----
372 a
373 <!--foo--><!--More than 1 comment, still stripped-->
374 b
375 ----
376 a
377 <!--foo--> <!----> <!-- bar -->
378 b
379 ----
380 a
381 <!--foo-->
382
383 b
384 ----
385 a
386
387 <!--foo-->
388 b
389 ----
390 a
391 <!--foo-->
392
393
394 b
395 ----
396 a
397
398
399 <!--foo-->
400 b
401 ----
402 !! html
403 <hr />
404 <p>a
405 b
406 </p>
407 <hr />
408 <p>a
409 b
410 </p>
411 <hr />
412 <p>a
413 b
414 </p>
415 <hr />
416 <p>a
417 </p><p>b
418 </p>
419 <hr />
420 <p>a
421 </p><p>b
422 </p>
423 <hr />
424 <p>a
425 </p><p><br />
426 b
427 </p>
428 <hr />
429 <p>a
430 </p><p><br />
431 b
432 </p>
433 <hr />
434
435 !! end
436
437 !! test
438 Paragraphs with newline spacing with non-empty white-space lines in between
439 !! wikitext
440 ----
441 a
442
443 b
444 ----
445 a
446
447
448 b
449 ----
450 !! html
451 <hr />
452 <p>a
453 </p><p>b
454 </p>
455 <hr />
456 <p>a
457 </p><p><br />
458 b
459 </p>
460 <hr />
461
462 !! end
463
464 !! test
465 Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
466 !! wikitext
467 ----
468 a
469 <!--foo-->
470 b
471 ----
472 a
473 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
474 b
475 ----
476 a
477
478 <!--foo-->
479 <!--bar-->
480 b
481 ----
482 a
483
484 <!--foo-->
485 <!--bar-->
486
487 b
488 ----
489 !! html
490 <hr />
491 <p>a
492 b
493 </p>
494 <hr />
495 <p>a
496 b
497 </p>
498 <hr />
499 <p>a
500 </p><p>b
501 </p>
502 <hr />
503 <p>a
504 </p><p><br />
505 b
506 </p>
507 <hr />
508
509 !! end
510
511 !! test
512 Extra newlines: More paragraphs with indented comment
513 !! wikitext
514 a
515
516 <!--boo-->
517
518 b
519 !! html
520 <p>a
521 </p><p><br />
522 b
523 </p>
524 !!end
525
526 !! test
527 Extra newlines followed by heading
528 !! wikitext
529 a
530
531
532 =b=
533 [[a]]
534
535
536 =b=
537 !! html
538 <p>a
539 </p><p><br />
540 </p>
541 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
542 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
543 </p><p><br />
544 </p>
545 <h1><span class="mw-headline" id="b_2">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
546
547 !! end
548
549 !! test
550 Extra newlines between heading and content are swallowed (Parsoid does not)
551 !! wikitext
552 =b=
553
554
555
556 [[a]]
557 !! html/php+tidy
558 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
559 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
560 </p>
561 !! html/parsoid
562 <h1 id="b">b</h1>
563 <p>
564 <br></p>
565
566 <p><a rel="mw:WikiLink" href="./A" title="A">a</a></p>
567 !! end
568
569 !! test
570 Extra new lines before and after lists are preserved
571 !! wikitext
572 a
573
574
575 *b
576
577
578 c
579 !! html/php+tidy
580 <p>a
581 </p><p><br />
582 </p>
583 <ul><li>b</li></ul>
584 <p><br />
585 c
586 </p>
587 !! html/parsoid
588 <p>a</p>
589 <p>
590 <br></p>
591 <ul><li>b</li></ul>
592 <p>
593 <br>
594 c</p>
595 !! end
596
597 # Parsoid regression test
598 !!test
599 Multiple newlines after tables are converted to p-br-p tags
600 !!options
601 parsoid=wt2html,wt2wt
602 !!wikitext
603 {|
604 |x
605 |}
606
607
608
609
610 =b=
611 !!html/php+tidy
612 <table>
613 <tbody><tr>
614 <td>x
615 </td></tr></tbody></table>
616 <p><br />
617 </p><p><br />
618 </p>
619 <h1><span class="mw-headline" id="b">b</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
620 !!html/parsoid
621 <table>
622 <tbody>
623 <tr>
624 <td>x</td>
625 </tr>
626 </tbody>
627 </table>
628 <p><br/></p>
629 <p><br/></p>
630 <h1 id="b">b</h1>
631 !!end
632
633 !! test
634 Heading with line break in nowiki
635 !! options
636 parsoid=wt2html
637 !! config
638 wgFragmentMode=[ 'html5', 'legacy' ]
639 !! wikitext
640 ==A <nowiki>B
641 C</nowiki>==
642 !! html/php
643 <h2><span id="A_B.0AC"></span><span class="mw-headline" id="A_B
644 C">A B
645 C</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: A B&#10;C">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
646
647 !! html/parsoid
648 <h2 id="A_B
649 C"><span id="A_B.0AC" typeof="mw:FallbackId"></span>A <span typeof="mw:Nowiki">B
650 C</span></h2>
651 !! end
652
653 !! test
654 Parsing an URL
655 !! wikitext
656 http://fr.wikipedia.org/wiki/🍺
657 <!-- EasterEgg we love beer, better be able be able to link to it -->
658 !! html
659 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
660 </p>
661 !! end
662
663 !! test
664 Simple list
665 !! wikitext
666 *Item 1
667 *Item 2
668 !! html
669 <ul><li>Item 1</li>
670 <li>Item 2</li></ul>
671
672 !! end
673
674 !! test
675 Italics and bold
676 !! wikitext
677 *plain
678 *plain''italic''plain
679 *plain''italic''plain''italic''plain
680 *plain'''bold'''plain
681 *plain'''bold'''plain'''bold'''plain
682 *plain''italic''plain'''bold'''plain
683 *plain'''bold'''plain''italic''plain
684 *plain''italic'''bold-italic'''italic''plain
685 *plain'''bold''bold-italic''bold'''plain
686 *plain'''''bold-italic'''italic''plain
687 *plain'''''bold-italic''bold'''plain
688 *plain''italic'''bold-italic'''''plain
689 *plain'''bold''bold-italic'''''plain
690 *plain l'''italic''plain
691 *plain l''''bold''' plain
692 !! html
693 <ul><li>plain</li>
694 <li>plain<i>italic</i>plain</li>
695 <li>plain<i>italic</i>plain<i>italic</i>plain</li>
696 <li>plain<b>bold</b>plain</li>
697 <li>plain<b>bold</b>plain<b>bold</b>plain</li>
698 <li>plain<i>italic</i>plain<b>bold</b>plain</li>
699 <li>plain<b>bold</b>plain<i>italic</i>plain</li>
700 <li>plain<i>italic<b>bold-italic</b>italic</i>plain</li>
701 <li>plain<b>bold<i>bold-italic</i>bold</b>plain</li>
702 <li>plain<i><b>bold-italic</b>italic</i>plain</li>
703 <li>plain<b><i>bold-italic</i>bold</b>plain</li>
704 <li>plain<i>italic<b>bold-italic</b></i>plain</li>
705 <li>plain<b>bold<i>bold-italic</i></b>plain</li>
706 <li>plain l'<i>italic</i>plain</li>
707 <li>plain l'<b>bold</b> plain</li></ul>
708
709 !! end
710
711 # this example taken from the [[simple:Moon]] article (T49326)
712 !! test
713 Italics and possessives (1)
714 !! wikitext
715 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
716 !! html
717 <p>obtained by <i><a href="/index.php?title=Lunar_Prospector&amp;action=edit&amp;redlink=1" class="new" title="Lunar Prospector (page does not exist)">Lunar Prospector</a>'</i>s gamma-ray spectrometer
718 </p>
719 !! end
720
721 # this example taken from [[en:Flaming Pie]] (T51926)
722 !! test
723 Italics and possessives (2)
724 !! wikitext
725 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
726 !! html
727 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
728 </p>
729 !! end
730
731 # this example taken from [[en:Dictionary]] (T51926)
732 !! test
733 Italics and possessives (3)
734 !! wikitext
735 The first monolingual dictionary written in a Romance language was ''Sebastián Covarrubias''' ''Tesoro de la lengua castellana o española'', published in 1611 in Madrid. In 1612 the first edition of the ''Vocabolario dell'[[Accademia della Crusca]]'', for Italian, was published. In 1690 in Rotterdam was published, posthumously, the ''Dictionnaire Universel''.
736 !! html
737 <p>The first monolingual dictionary written in a Romance language was <i>Sebastián Covarrubias'</i> <i>Tesoro de la lengua castellana o española</i>, published in 1611 in Madrid. In 1612 the first edition of the <i>Vocabolario dell'<a href="/index.php?title=Accademia_della_Crusca&amp;action=edit&amp;redlink=1" class="new" title="Accademia della Crusca (page does not exist)">Accademia della Crusca</a></i>, for Italian, was published. In 1690 in Rotterdam was published, posthumously, the <i>Dictionnaire Universel</i>.
738 </p>
739 !! end
740
741
742 ###
743 ### 2-quote opening sequence tests
744 ###
745 !! test
746 Italics and bold: 2-quote opening sequence: (2,2)
747 !! wikitext
748 ''foo''
749 !! html
750 <p><i>foo</i>
751 </p>
752 !!end
753
754 !! test
755 Italics and bold: 2-quote opening sequence: (2,3)
756 !! wikitext
757 ''foo'''
758 !! html/*
759 <p><i>foo'</i>
760 </p>
761 !!end
762
763 !! test
764 Italics and bold: 2-quote opening sequence: (2,4)
765 !! options
766 parsoid=wt2html
767 !! wikitext
768 ''foo''''
769 !! html/*
770 <p><i>foo''</i>
771 </p>
772 !!end
773
774 # same html as previous, but wikitext adjusted to match parsoid html2wt
775 !! test
776 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
777 !! wikitext
778 ''foo<nowiki>''</nowiki>''
779 !! html
780 <p><i>foo''</i>
781 </p>
782 !! end
783
784 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
785 !! test
786 Italics and bold: 2-quote opening sequence: (2,5)
787 !! options
788 parsoid=wt2html
789 !! wikitext
790 ''foo'''''
791 !! html/php
792 <p><i>foo</i>
793 </p>
794 !! html/parsoid
795 <p><i>foo</i><b></b>
796 </p>
797 !!end
798
799 # same html as previous, but wikitext adjusted to match parsoid html2wt
800 !! test
801 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
802 !! wikitext
803 ''foo'''''<nowiki/>'''
804 !! html/php
805 <p><i>foo</i>
806 </p>
807 !! html/parsoid
808 <p><i>foo</i><b></b>
809 </p>
810 !! end
811
812
813 ###
814 ### 3-quote opening sequence tests
815 ###
816
817 !! test
818 Italics and bold: 3-quote opening sequence: (3,2)
819 !! wikitext
820 '''foo''
821 !! html/*
822 <p>'<i>foo</i>
823 </p>
824 !!end
825
826 !! test
827 Italics and bold: 3-quote opening sequence: (3,3)
828 !! wikitext
829 '''foo'''
830 !! html
831 <p><b>foo</b>
832 </p>
833 !!end
834
835 !! test
836 Italics and bold: 3-quote opening sequence: (3,4)
837 !! wikitext
838 '''foo''''
839 !! html/*
840 <p><b>foo'</b>
841 </p>
842 !!end
843
844 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
845 !! test
846 Italics and bold: 3-quote opening sequence: (3,5)
847 !! options
848 parsoid=wt2html
849 !! wikitext
850 '''foo'''''
851 !! html/php
852 <p><b>foo</b>
853 </p>
854 !! html/parsoid
855 <p><b>foo</b><i></i>
856 </p>
857 !!end
858
859 # same html as previous, but wikitext adjusted to match parsoid html2wt
860 !! test
861 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
862 !! wikitext
863 '''foo'''''<nowiki/>''
864 !! html/php
865 <p><b>foo</b>
866 </p>
867 !! html/parsoid
868 <p><b>foo</b><i></i>
869 </p>
870 !! end
871
872
873 ###
874 ### 4-quote opening sequence tests
875 ###
876
877 !! test
878 Italics and bold: 4-quote opening sequence: (4,2)
879 !! options
880 parsoid=wt2html
881 !! wikitext
882 ''''foo''
883 !! html/*
884 <p>''<i>foo</i>
885 </p>
886 !!end
887
888 # same html as previous, but wikitext adjusted to match parsoid html2wt
889 !! test
890 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
891 !! wikitext
892 <nowiki>''</nowiki>''foo''
893 !! html
894 <p>''<i>foo</i>
895 </p>
896 !! end
897
898 !! test
899 Italics and bold: 4-quote opening sequence: (4,3)
900 !! wikitext
901 ''''foo'''
902 !! html/*
903 <p>'<b>foo</b>
904 </p>
905 !!end
906
907 !! test
908 Italics and bold: 4-quote opening sequence: (4,4)
909 !! options
910 parsoid=wt2html
911 !! wikitext
912 ''''foo''''
913 !! html/*
914 <p>'<b>foo'</b>
915 </p>
916 !!end
917
918 # same html as previous, but wikitext adjusted to match parsoid html2wt
919 !! test
920 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
921 !! wikitext
922 '<nowiki/>'''foo''''
923 !! html
924 <p>'<b>foo'</b>
925 </p>
926 !! end
927
928 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
929 !! test
930 Italics and bold: 4-quote opening sequence: (4,5)
931 !! options
932 parsoid=wt2html
933 !! wikitext
934 ''''foo'''''
935 !! html/php
936 <p>'<b>foo</b>
937 </p>
938 !! html/parsoid
939 <p>'<b>foo</b><i></i>
940 </p>
941 !!end
942
943 # same html as previous, but wikitext adjusted to match parsoid html2wt
944 !! test
945 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
946 !! wikitext
947 '<nowiki/>'''foo'''''<nowiki/>''
948 !! html/php
949 <p>'<b>foo</b>
950 </p>
951 !! html/parsoid
952 <p>'<b>foo</b><i></i>
953 </p>
954 !! end
955
956
957 ###
958 ### 5-quote opening sequence tests
959 ###
960
961 !! test
962 Italics and bold: 5-quote opening sequence: (5,2)
963 !! options
964 parsoid=wt2html
965 !! wikitext
966 '''''foo''
967 !! html/*
968 <p><b><i>foo</i></b>
969 </p>
970 !!end
971
972 # same html as previous, but wikitext adjusted to match parsoid html2wt
973 !! test
974 Italics and bold: 5-quote opening sequence: (5,2+3)
975 !! wikitext
976 '''''foo'''''
977 !! html/*
978 <p><i><b>foo</b></i>
979 </p>
980 !! end
981
982 !! test
983 Italics and bold: 5-quote opening sequence: (5,3)
984 !! options
985 parsoid=wt2html
986 !! wikitext
987 '''''foo'''
988 !! html/*
989 <p><i><b>foo</b></i>
990 </p>
991 !!end
992
993 # same html as previous, but wikitext adjusted to match parsoid html2wt
994 !! test
995 Italics and bold: 5-quote opening sequence: (5,3+2)
996 !! wikitext
997 '''''foo'''''
998 !! html
999 <p><i><b>foo</b></i>
1000 </p>
1001 !! end
1002
1003 !! test
1004 Italics and bold: 5-quote opening sequence: (5,4)
1005 !! options
1006 parsoid=wt2html
1007 !! wikitext
1008 '''''foo''''
1009 !! html/*
1010 <p><i><b>foo'</b></i>
1011 </p>
1012 !!end
1013
1014 !! test
1015 Italics and bold: 5-quote opening sequence: (5,5)
1016 !! wikitext
1017 '''''foo'''''
1018 !! html
1019 <p><i><b>foo</b></i>
1020 </p>
1021 !!end
1022
1023 !! test
1024 Italics and bold: 5-quote opening sequence: (5,6)
1025 !! wikitext
1026 '''''foo''''''
1027 !! html/*
1028 <p><i><b>foo'</b></i>
1029 </p>
1030 !! end
1031
1032 ###
1033 ### multiple quote sequences in a line
1034 ###
1035
1036 !! test
1037 Italics and bold: multiple quote sequences: (2,4,2)
1038 !! options
1039 parsoid=wt2html
1040 !! wikitext
1041 ''foo''''bar''
1042 !! html/*
1043 <p><i>foo'<b>bar</b></i>
1044 </p>
1045 !! end
1046
1047 # same html as previous, but wikitext adjusted to match parsoid html2wt
1048 !! test
1049 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
1050 !! wikitext
1051 ''foo'<nowiki/>'''bar'''''
1052 !! html
1053 <p><i>foo'<b>bar</b></i>
1054 </p>
1055 !! end
1056
1057 !! test
1058 Italics and bold: multiple quote sequences: (2,4,3)
1059 !! options
1060 parsoid=wt2html
1061 !! wikitext
1062 ''foo''''bar'''
1063 !! html/*
1064 <p><i>foo'<b>bar</b></i>
1065 </p>
1066 !! end
1067
1068 # same html as previous, but wikitext adjusted to match parsoid html2wt
1069 !! test
1070 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
1071 !! wikitext
1072 ''foo'<nowiki/>'''bar'''''
1073 !! html
1074 <p><i>foo'<b>bar</b></i>
1075 </p>
1076 !! end
1077
1078 !! test
1079 Italics and bold: multiple quote sequences: (2,4,4)
1080 !! options
1081 parsoid=wt2html
1082 !! wikitext
1083 ''foo''''bar''''
1084 !! html/*
1085 <p><i>foo'<b>bar'</b></i>
1086 </p>
1087 !! end
1088
1089 # same html as previous, but wikitext adjusted to match parsoid html2wt
1090 !! test
1091 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
1092 !! wikitext
1093 ''foo'<nowiki/>'''bar'<nowiki/>'''''
1094 !! html
1095 <p><i>foo'<b>bar'</b></i>
1096 </p>
1097 !! end
1098
1099 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1100 !! test
1101 Italics and bold: multiple quote sequences: (3,4,2)
1102 !! options
1103 parsoid=wt2html
1104 !! wikitext
1105 '''foo''''bar''
1106 !! html/php
1107 <p><b>foo'</b>bar
1108 </p>
1109 !! html/parsoid
1110 <p><b>foo'</b>bar<i></i>
1111 </p>
1112 !! end
1113
1114 # same html as previous, but wikitext adjusted to match parsoid html2wt
1115 !! test
1116 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1117 !! wikitext
1118 '''foo''''bar''<nowiki/>''
1119 !! html/php
1120 <p><b>foo'</b>bar
1121 </p>
1122 !! html/parsoid
1123 <p><b>foo'</b>bar<i></i>
1124 </p>
1125 !! end
1126
1127 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1128 !! test
1129 Italics and bold: multiple quote sequences: (3,4,3)
1130 !! options
1131 parsoid=wt2html
1132 !! wikitext
1133 '''foo''''bar'''
1134 !! html/php
1135 <p><b>foo'</b>bar
1136 </p>
1137 !! html/parsoid
1138 <p><b>foo'</b>bar<b></b>
1139 </p>
1140 !! end
1141
1142 # same html as previous, but wikitext adjusted to match parsoid html2wt
1143 !! test
1144 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1145 !! wikitext
1146 '''foo''''bar'''<nowiki/>'''
1147 !! html/php
1148 <p><b>foo'</b>bar
1149 </p>
1150 !! html/parsoid
1151 <p><b>foo'</b>bar<b></b>
1152 </p>
1153 !! end
1154
1155 ###
1156 ### other quote tests
1157 ###
1158 !! test
1159 Italics and bold: other quote tests: (2,3,5)
1160 !! wikitext
1161 ''this is about '''foo's family'''''
1162 !! html
1163 <p><i>this is about <b>foo's family</b></i>
1164 </p>
1165 !!end
1166
1167
1168 !! test
1169 Italics and bold: other quote tests: (2,(3,3),2)
1170 !! wikitext
1171 ''this is about '''foo's''' family''
1172 !! html
1173 <p><i>this is about <b>foo's</b> family</i>
1174 </p>
1175 !!end
1176
1177
1178 !! test
1179 Italics and bold: other quote tests: (3,2,3,2)
1180 !! options
1181 parsoid=wt2html
1182 !! wikitext
1183 '''this is about ''foo'''s family''
1184 !! html/*
1185 <p><b>this is about <i>foo</i></b><i>s family</i>
1186 </p>
1187 !!end
1188
1189
1190 # same html as previous, but wikitext adjusted to match parsoid html2wt
1191 !! test
1192 Italics and bold: other quote tests: (3,2,3+2+2,2)
1193 !! wikitext
1194 '''this is about ''foo'''''<nowiki/>''s family''
1195 !! html
1196 <p><b>this is about <i>foo</i></b><i>s family</i>
1197 </p>
1198 !! end
1199
1200
1201 !! test
1202 Italics and bold: other quote tests: (3,2,3,3)
1203 !! wikitext
1204 '''this is about ''foo'''s family'''
1205 !! html/*
1206 <p>'<i>this is about </i>foo<b>s family</b>
1207 </p>
1208 !!end
1209
1210
1211 !! test
1212 Italics and bold: other quote tests: (3,(2,2),3)
1213 !! wikitext
1214 '''this is about ''foo's'' family'''
1215 !! html
1216 <p><b>this is about <i>foo's</i> family</b>
1217 </p>
1218 !!end
1219
1220
1221 !! test
1222 Italicized possessive
1223 !! wikitext
1224 The ''[[Main Page]]'''s talk page.
1225 !! html/php
1226 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1227 </p>
1228 !! html/parsoid
1229 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1230 !! end
1231
1232 !! test
1233 Quote balancing context should be restricted to td/th cells on the same wikitext line
1234 !! options
1235 parsoid=wt2html,wt2wt
1236 !! wikitext
1237 {|
1238 !''a!!''b
1239 |''a||''b
1240 |}
1241 !! html+tidy
1242 <table>
1243 <tbody><tr>
1244 <th><i>a</i></th>
1245 <th><i>b</i>
1246 </th>
1247 <td><i>a</i></td>
1248 <td><i>b</i>
1249 </td></tr></tbody></table>
1250 !! end
1251
1252 ###
1253 ### Non-html5 tags
1254 ###
1255
1256 !! test
1257 Non-html5 tags should be accepted
1258 !! wikitext
1259 <center>''foo''</center>
1260 <big>''foo''</big>
1261 <font>''foo''</font>
1262 <strike>''foo''</strike>
1263 <tt>''foo''</tt>
1264 !! html
1265 <center><i>foo</i></center>
1266 <p><big><i>foo</i></big>
1267 <font><i>foo</i></font>
1268 <strike><i>foo</i></strike>
1269 <tt><i>foo</i></tt>
1270 </p>
1271 !! end
1272
1273 !! test
1274 <wbr> is valid wikitext (T54468)
1275 !! wikitext
1276 <wbr>
1277 !! html
1278 <p><wbr />
1279 </p>
1280 !! end
1281
1282 # <strike> is HTML4, <s> is HTML4/5.
1283 !! test
1284 <s> or <strike> for strikethrough
1285 !! wikitext
1286 <strike>strike</strike>
1287
1288 <s>s</s>
1289 !! html
1290 <p><strike>strike</strike>
1291 </p><p><s>s</s>
1292 </p>
1293 !! end
1294
1295 ## a not permitted
1296 ## i,b,br omitted
1297 !! test
1298 Text-level semantic html elements in wikitext
1299 !! wikitext
1300 <em>text</em>
1301 <strong>text</strong>
1302 <small>text</small>
1303 <s>text</s>
1304 <cite>text</cite>
1305 <q>text</q>
1306 <dfn>text</dfn>
1307 <abbr>text</abbr>
1308 <data>text</data>
1309 <time>text</time>
1310 <code>text</code>
1311 <var>text</var>
1312 <samp>text</samp>
1313 <kbd>text</kbd>
1314 <sub>text</sub>
1315 <u>text</u>
1316 <mark>text</mark>
1317 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1318 <bdi>text</bdi>
1319 <bdo>text</bdo>
1320 <span>text</span>
1321 <wbr />
1322 !! html
1323 <p><em>text</em>
1324 <strong>text</strong>
1325 <small>text</small>
1326 <s>text</s>
1327 <cite>text</cite>
1328 <q>text</q>
1329 <dfn>text</dfn>
1330 <abbr>text</abbr>
1331 <data>text</data>
1332 <time>text</time>
1333 <code>text</code>
1334 <var>text</var>
1335 <samp>text</samp>
1336 <kbd>text</kbd>
1337 <sub>text</sub>
1338 <u>text</u>
1339 <mark>text</mark>
1340 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1341 <bdi>text</bdi>
1342 <bdo>text</bdo>
1343 <span>text</span>
1344 <wbr />
1345 </p>
1346 !! end
1347
1348 # test cases taken from
1349 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1350 !! test
1351 Ruby markup (W3C-style)
1352 !! wikitext
1353 ;Mono-ruby for individual base characters
1354 :<ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1355 ;Group ruby
1356 :<ruby>今日<rt>きょう</rt></ruby>
1357 ;Jukugo ruby
1358 :<ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1359 ;Inline ruby
1360 :<ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1361 ;Double-sided ruby
1362 :<ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1363
1364 <ruby>
1365 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1366 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1367 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1368 </ruby>
1369 !! html
1370 <dl><dt>Mono-ruby for individual base characters</dt>
1371 <dd><ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1372 <dt>Group ruby</dt>
1373 <dd><ruby>今日<rt>きょう</rt></ruby></dd>
1374 <dt>Jukugo ruby</dt>
1375 <dd><ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1376 <dt>Inline ruby</dt>
1377 <dd><ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1378 <dt>Double-sided ruby</dt>
1379 <dd><ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby></dd></dl>
1380 <p><ruby>
1381 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1382 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1383 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1384 </ruby>
1385 </p>
1386 !! end
1387
1388 # The next two test different paths in the sanitizer.
1389 !! test
1390 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1391 !! wikitext
1392 <blockquote|>a</blockquote>
1393
1394 <b→> doesn't terminate </b→>
1395
1396 <bä> doesn't terminate </bä>
1397
1398 <boo> doesn't terminate </boo>
1399
1400 <s.foo> doesn't terminate </s.foo>
1401
1402 <sub-ID#1>
1403 !! html/php
1404 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1405 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1406 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1407 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1408 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1409 </p><p>&lt;sub-ID#1&gt;
1410 </p>
1411 !! end
1412
1413 !! test
1414 Non-word characters don't terminate tag names
1415 !! wikitext
1416 <blockquote|>a</blockquote>
1417
1418 <b→> doesn't terminate </b→>
1419
1420 <bä> doesn't terminate </bä>
1421
1422 <boo> doesn't terminate </boo>
1423
1424 <s.foo> doesn't terminate </s.foo>
1425
1426 <sub-ID#1>
1427 !! html+tidy
1428 <p>&lt;blockquote|&gt;a
1429 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1430 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1431 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1432 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1433 </p><p>&lt;sub-ID#1&gt;
1434 </p>
1435 !! end
1436
1437 ###
1438 ### See tests/parser/ParserTestParserHook.php for the <tåg> extension)
1439 ### This checks that HTML5 tags (with non-word characters in the tag
1440 ### name) make it safely through the parser -- the Sanitizer will
1441 ### munge them later, as it should.
1442 ###
1443 !! test
1444 Non-word characters are valid in extension tags (T19663)
1445 !! wikitext
1446 <tåg>tåg</tåg>
1447 !! html/php
1448 <pre>
1449 'tåg'
1450 array (
1451 )
1452 </pre>
1453
1454 !! html/parsoid
1455 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1456 !! end
1457
1458 !! test
1459 Isolated close tags should be treated as literal text (T54760)
1460 !! options
1461 parsoid=wt2html
1462 !! wikitext
1463 </b>
1464
1465 <s.foo>s</s>
1466 !! html+tidy
1467 <p class="mw-empty-elt">
1468 </p><p>&lt;s.foo&gt;s
1469 </p>
1470 !! end
1471
1472 ###
1473 ### Special characters
1474 ###
1475
1476 !! test
1477 Bare pipe character (T54363)
1478 !! wikitext
1479 |
1480 !! html
1481 <p>|
1482 </p>
1483 !! end
1484
1485 !! test
1486 Bare pipe character from a template (T54363)
1487 !! wikitext
1488 {{pipe}}
1489 !! html
1490 <p>|
1491 </p>
1492 !! end
1493
1494 ###
1495 ### <nowiki> test cases
1496 ###
1497
1498 !! test
1499 <nowiki> unordered list
1500 !! wikitext
1501 <nowiki>* This is not an unordered list item.</nowiki>
1502 !! html/php
1503 <p>* This is not an unordered list item.
1504 </p>
1505 !! html/parsoid
1506 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1507 !! end
1508
1509 !! test
1510 <nowiki> spacing
1511 !! wikitext
1512 <nowiki>Lorem ipsum dolor
1513
1514 sed abit.
1515 sed nullum.
1516
1517 :and a colon
1518 </nowiki>
1519 !! html/php
1520 <p>Lorem ipsum dolor
1521
1522 sed abit.
1523 sed nullum.
1524
1525 :and a colon
1526
1527 </p>
1528 !! html/parsoid
1529 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1530
1531 sed abit.
1532 sed nullum.
1533
1534 :and a colon
1535 </span></p>
1536 !! end
1537
1538 !! test
1539 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1540 !! wikitext
1541 <nowiki><span class="error"></nowiki>
1542 !! html/php
1543 <p>&lt;span class="error"&gt;
1544 </p>
1545 !! html/parsoid
1546 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1547 !! end
1548
1549 !! test
1550 nowiki 3
1551 !! wikitext
1552 :There is not nowiki.
1553 :There is <nowiki>nowiki</nowiki>.
1554
1555 #There is not nowiki.
1556 #There is <nowiki>nowiki</nowiki>.
1557
1558 *There is not nowiki.
1559 *There is <nowiki>nowiki</nowiki>.
1560 !! html/php
1561 <dl><dd>There is not nowiki.</dd>
1562 <dd>There is nowiki.</dd></dl>
1563 <ol><li>There is not nowiki.</li>
1564 <li>There is nowiki.</li></ol>
1565 <ul><li>There is not nowiki.</li>
1566 <li>There is nowiki.</li></ul>
1567
1568 !! html/parsoid
1569 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1570 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1571
1572 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1573 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1574
1575 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1576 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1577 !! end
1578
1579 !! test
1580 Entities inside <nowiki>
1581 !! wikitext
1582 <nowiki>&lt;</nowiki>
1583 !! html/php
1584 <p>&lt;
1585 </p>
1586 !! html/parsoid
1587 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1588 !! end
1589
1590 !! test
1591 Entities inside template parameters
1592 !! wikitext
1593 {{echo|&ndash;}}
1594 !! html/php+tidy
1595 <p>&#8211;
1596 </p>
1597 !! html/parsoid
1598 <p><span typeof="mw:Transclusion mw:Entity" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&amp;ndash;"}},"i":0}}]}'>&ndash;</span></p>
1599 !! end
1600
1601 !! test
1602 Properly escape nowiki when combined with other wiki markup
1603 !! options
1604 parsoid=html2wt
1605 !! html/parsoid
1606 <p>* &lt;/nowiki&gt; tag</p>
1607 !! wikitext
1608 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1609 !! end
1610
1611 !! test
1612 T93824: Put escaped HTML tags inside nowiki
1613 !! options
1614 parsoid=html2wt
1615 !! html/parsoid
1616 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1617 !! wikitext
1618 <nowiki><h2>foo</h2></nowiki>
1619 !! end
1620
1621 !! test
1622 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1623 !! options
1624 parsoid=html2wt
1625 !! html/parsoid
1626 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1627 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1628 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1629 !! wikitext
1630 This text: L'[[Foo]]
1631 This text: L<nowiki>''</nowiki>[[Foo]]
1632 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1633 !! end
1634
1635 # This test fails because wikitext whitespace is not normalized before comparing.
1636 !! test
1637 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1638 !! options
1639 parsoid=html2wt
1640 !! html/parsoid
1641 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1642 </p>
1643 !! wikitext
1644 This text : L<nowiki>''</nowiki>[[Foo]]
1645 !! end
1646
1647 # This test and the next one are html2wt only as they test that incorrect wikitext
1648 # passed in template arguments gets escaped or wrapped in nowikis where required.
1649 !! test
1650 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1651 !! options
1652 parsoid=html2wt
1653 !! html/parsoid
1654 <p><span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo|bar&quot;}},&quot;i&quot;:0}}]}" about="#mwt1"></span>
1655 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo|bar |[[&quot;}},&quot;i&quot;:0}}]}" about="#mwt2"></p>
1656 !! wikitext
1657 {{echo|foo{{!}}bar}}
1658 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1659 !! end
1660
1661 !! test
1662 T53961: Output correct nowikis in template arguments
1663 !! options
1664 parsoid=html2wt
1665 !! html/parsoid
1666 <p><span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a [ b&quot;}},&quot;i&quot;:0}}]}" about="#mwt1"></span>
1667 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a }} b&quot;}},&quot;i&quot;:0}}]}" about="#mwt2"></span>
1668 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a [[ b&quot;}},&quot;i&quot;:0}}]}" about="#mwt3"></span>
1669 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a | {{ ]]&quot;}},&quot;i&quot;:0}}]}" about="#mwt4"></span>
1670 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a }&quot;}},&quot;i&quot;:0}}]}" about="#mwt5"></span></p>
1671 !! wikitext
1672 {{echo|a [ b}}
1673 {{echo|<nowiki>a }} b</nowiki>}}
1674 {{echo|<nowiki>a [[ b</nowiki>}}
1675 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1676 {{echo|a <nowiki>}</nowiki>}}
1677 !! end
1678
1679 !! test
1680 Cases where "!!" needs nowiki protection
1681 !! options
1682 parsoid=html2wt
1683 !! html/parsoid
1684 <table>
1685 <tr><th>this needs protection !! here</th></tr>
1686 </table>
1687
1688 <table>
1689 <tr><th>this does not need
1690 protection !! here</th></tr>
1691 </table>
1692 !! wikitext
1693 {|
1694 !<nowiki>this needs protection !! here</nowiki>
1695 |}
1696
1697 {|
1698 !this does not need
1699 protection !! here
1700 |}
1701 !! end
1702
1703 ###
1704 ### Comments
1705 ###
1706 !! test
1707 Comments and Indent-Pre
1708 !! wikitext
1709 <!-- comment 1 --> asdf
1710
1711 <!-- comment 1 --> asdf
1712 <!-- comment 2 -->
1713
1714 <!-- comment 1 --> asdf
1715 <!-- comment 2 -->xyz
1716
1717 <!-- comment 1 --> asdf
1718 <!-- comment 2 --> xyz
1719 !! html
1720 <pre>asdf
1721 </pre>
1722 <pre>asdf
1723 </pre>
1724 <pre>asdf
1725 </pre>
1726 <p>xyz
1727 </p>
1728 <pre>asdf
1729 xyz
1730 </pre>
1731 !! end
1732
1733 !! test
1734 Comment test 2a
1735 !! wikitext
1736 asdf
1737 <!-- comment 1 -->
1738 jkl
1739 !! html
1740 <p>asdf
1741 jkl
1742 </p>
1743 !! end
1744
1745 !! test
1746 Comment test 2b
1747 !! wikitext
1748 asdf
1749 <!-- comment 1 -->
1750
1751 jkl
1752 !! html
1753 <p>asdf
1754 </p><p>jkl
1755 </p>
1756 !! end
1757
1758 !! test
1759 Comment test 3
1760 !! wikitext
1761 asdf
1762 <!-- comment 1 -->
1763 <!-- comment 2 -->
1764 jkl
1765 !! html
1766 <p>asdf
1767 jkl
1768 </p>
1769 !! end
1770
1771 !! test
1772 Comment test 4
1773 !! wikitext
1774 asdf<!-- comment 1 -->jkl
1775 !! html
1776 <p>asdfjkl
1777 </p>
1778 !! end
1779
1780 !! test
1781 Comment spacing
1782 !! wikitext
1783 a
1784 <!-- foo --> b <!-- bar -->
1785 c
1786 !! html
1787 <p>a
1788 </p>
1789 <pre> b
1790 </pre>
1791 <p>c
1792 </p>
1793 !! end
1794
1795 !! test
1796 Comment whitespace
1797 !! wikitext
1798 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1799 !! html
1800
1801 !! end
1802
1803 !! test
1804 Comment semantics and delimiters
1805 !! wikitext
1806 <!-- --><!----><!-----><!------>
1807 !! html/php
1808
1809 !! html/parsoid
1810 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1811 !! end
1812
1813 !! test
1814 Comment semantics and delimiters, redux
1815 !! wikitext
1816 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1817 -- foo -- funky huh? ... -->
1818 !! html/php
1819
1820 !! html/parsoid
1821 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1822 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1823 !! end
1824
1825 !! test
1826 Comment semantics and delimiters: directors cut
1827 !! wikitext
1828 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1829 everything starting with < followed by !-- until the first -- and > we see,
1830 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1831 -->-->
1832 !! html/php
1833 <p>--&gt;
1834 </p>
1835 !! html/parsoid
1836 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1837 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1838 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1839 --><p>--></p>
1840 !! end
1841
1842 !! test
1843 Comment semantics: nesting
1844 !! wikitext
1845 <!--<!-- no, we're not going to do anything fancy here -->-->
1846 !! html/php
1847 <p>--&gt;
1848 </p>
1849 !! html/parsoid
1850 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1851 !! end
1852
1853 # Parsoid closes the unclosed comment, even if it means a slight
1854 # round-trip diff.
1855 !! test
1856 Comment semantics: unclosed comment at end
1857 !! options
1858 parsoid=wt2html,html2html
1859 !! wikitext
1860 <!--This comment will run out to the end of the document
1861 !! html/php
1862
1863 !! html/parsoid
1864 <!--This comment will run out to the end of the document-->
1865 !! end
1866
1867 !! test
1868 Comment semantics: normalize comments to play nice with XML and browsers
1869 !! wikitext
1870 <!-- Browsers --!> think this is closed -->
1871 <!--> This would normally be text -->
1872 <!---> As would this -->
1873 <!-- XML doesn't like trailing dashes -------->
1874 <!-- Nor doubled hyphens -- anywhere in the data -->
1875 But this is not a comment.
1876 !! html/php
1877 <p>But this is not a comment.
1878 </p>
1879 !! html/parsoid
1880 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1881 <!--&#x3E; This would normally be text -->
1882 <!--&#x2D;&#x3E; As would this -->
1883 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1884 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1885 <p>But this is not a comment.</p>
1886 !! end
1887
1888 !! test
1889 Comment semantics: round-trip even text which contains encoded -->
1890 !! wikitext
1891 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1892 !! html/parsoid
1893 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1894 !! end
1895
1896 !! test
1897 Comment in template title
1898 !! wikitext
1899 {{f<!---->oo}}
1900 !! html
1901 <p>FOO
1902 </p>
1903 !! end
1904
1905 !! test
1906 Comment on its own line post-expand
1907 !! wikitext
1908 a
1909 {{blank}}<!---->
1910 b
1911 !! html
1912 <p>a
1913 </p><p>b
1914 </p>
1915 !! end
1916
1917 !! test
1918 Comment on its own line post-expand with non-significant whitespace
1919 !! wikitext
1920 a
1921 {{blank}} <!---->
1922 b
1923 !! html
1924 <p>a
1925 </p><p>b
1926 </p>
1927 !! end
1928
1929 !! test
1930 post-expand include size being exceeded
1931 !! options
1932 maxincludesize=20
1933 !! wikitext
1934 {{echo3|1234567890}}
1935 !! html
1936 <p><a href="/wiki/Template:Echo3" title="Template:Echo3">Template:Echo3</a><!-- WARNING: template omitted, post-expand include size too large -->
1937 </p>
1938 !! end
1939
1940 !! test
1941 max template depth being reached
1942 !! options
1943 maxtemplatedepth=1
1944 !! wikitext
1945 {{echo with depth|too deep!}}
1946 !! html
1947 <p><span class="error">Template recursion depth limit exceeded (1)</span>
1948 </p>
1949 !! end
1950
1951 !! test
1952 multiple templates that are redirects
1953 !! wikitext
1954 {{redirect to foo}}
1955 {{redirect to foo}}
1956 !! html
1957 <p>FOO
1958 FOO
1959 </p>
1960 !! end
1961
1962 !! test
1963 Multiple comments should still parse as SOL-transparent
1964 !! options
1965 parsoid=wt2html,wt2wt
1966 !! wikitext
1967 <!--c1-->*a
1968 <!--c2--><!--c3--><!--c4-->*b
1969 !! html/php
1970 <ul><li>a</li>
1971 <li>b</li></ul>
1972
1973 !! html/parsoid
1974 <!--c1--><ul>
1975 <li>a
1976 </li>
1977 <!--c2--><!--c3--><!--c4-->
1978 <li>b
1979 </li>
1980 </ul>
1981 !! end
1982
1983 ## Make sure ">" gets escaped in comments to avoid XSS
1984 !! test
1985 IE conditional comments
1986 !! wikitext
1987 <!--[if lt IE 9]>
1988 <script>alert('hi');</script>
1989 <![endif]-->
1990 !! html/parsoid
1991 <!--[if lt IE 9]&#x3E;
1992 <script&#x3E;alert('hi');</script&#x3E;
1993 <![endif]-->
1994 !! end
1995
1996 ###
1997 ### paragraph wrapping tests
1998 ###
1999
2000 !! test
2001 No block tags
2002 !! wikitext
2003 a
2004
2005 b
2006 !! html
2007 <p>a
2008 </p><p>b
2009 </p>
2010 !! end
2011
2012 !! test
2013 Block tag on one line (<div>)
2014 !! wikitext
2015 a <div>foo</div>
2016
2017 b
2018 !! html
2019 a <div>foo</div>
2020 <p>b
2021 </p>
2022 !! html+tidy
2023 <p>a </p><div>foo</div>
2024 <p>b
2025 </p>
2026 !! end
2027
2028 !! test
2029 No p-wrappable content
2030 !! options
2031 parsoid=wt2html,html2html
2032 !! wikitext
2033 <span><div>x</div></span>
2034 <span><s><div>x</div></s></span>
2035 <small><em></em></small><span><s><div>x</div></s></span>
2036 !! html+tidy
2037 <span><div>x</div></span>
2038 <span><s><div>x</div></s></span>
2039 <p><small><em></em></small></p><span><s><div>x</div></s></span>
2040 !! end
2041
2042 # T177612: Parsoid-only test
2043 !! test
2044 Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
2045 !! wikitext
2046 {{echo|<span><div>x</div></span>}}
2047 x
2048 !! html/parsoid
2049 <span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;span>&lt;div>x&lt;/div>&lt;/span>"}},"i":0}}]}'><div>x</div></span>
2050 <p>x</p>
2051 !! end
2052
2053 !! test
2054 Block tag on one line (<blockquote>)
2055 !! wikitext
2056 a <blockquote>foo</blockquote>
2057
2058 b
2059 !! html
2060 a <blockquote>foo</blockquote>
2061 <p>b
2062 </p>
2063 !! html+tidy
2064 <p>a </p><blockquote><p>foo</p></blockquote>
2065 <p>b
2066 </p>
2067 !! end
2068
2069 !! test
2070 Block tag on both lines (<div>)
2071 !! wikitext
2072 a <div>foo</div>
2073
2074 b <div>foo</div>
2075 !! html
2076 a <div>foo</div>
2077 b <div>foo</div>
2078
2079 !! html+tidy
2080 <p>a </p><div>foo</div><p>
2081 b </p><div>foo</div>
2082 !! end
2083
2084 !! test
2085 Block tag on both lines (<blockquote>)
2086 !! wikitext
2087 a <blockquote>foo</blockquote>
2088
2089 b <blockquote>foo</blockquote>
2090 !! html
2091 a <blockquote>foo</blockquote>
2092 b <blockquote>foo</blockquote>
2093
2094 !! html+tidy
2095 <p>a </p><blockquote><p>foo</p></blockquote><p>
2096 b </p><blockquote><p>foo</p></blockquote>
2097 !! end
2098
2099 !! test
2100 Multiple lines without block tags
2101 !! wikitext
2102 <div>foo</div> a
2103 b
2104 c
2105 d<!--foo--> e
2106 x <div>foo</div> z
2107 !! html
2108 <div>foo</div> a
2109 <p>b
2110 c
2111 d e
2112 </p>
2113 x <div>foo</div> z
2114
2115 !! html+tidy
2116 <div>foo</div><p> a
2117 </p><p>b
2118 c
2119 d e
2120 </p><p>
2121 x </p><div>foo</div><p> z
2122 </p>
2123 !! end
2124
2125 !! test
2126 Empty lines between lines with block tags
2127 !! wikitext
2128 <div></div>
2129
2130
2131 <div></div>a
2132
2133 b
2134 <div>a</div>b
2135
2136 <div>b</div>d
2137
2138
2139 <div>e</div>
2140 !! html
2141 <div></div>
2142 <p><br />
2143 </p>
2144 <div></div>a
2145 <p>b
2146 </p>
2147 <div>a</div>b
2148 <div>b</div>d
2149 <p><br />
2150 </p>
2151 <div>e</div>
2152
2153 !! html+tidy
2154 <div></div>
2155 <p><br />
2156 </p>
2157 <div></div><p>a
2158 </p><p>b
2159 </p>
2160 <div>a</div><p>b
2161 </p><div>b</div><p>d
2162 </p><p><br />
2163 </p>
2164 <div>e</div>
2165 !! html/parsoid
2166 <div data-parsoid='{"stx":"html"}'></div>
2167
2168 <p><br /></p>
2169 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2170
2171 <p>b</p>
2172 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2173
2174 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2175
2176 <p><br /></p>
2177 <div data-parsoid='{"stx":"html"}'>e</div>
2178 !! end
2179
2180 !! test
2181 Unclosed HTML p-tags should be handled properly
2182 !! wikitext
2183 <div><p>foo</div>
2184 a
2185
2186 b
2187 !! html/php+tidy
2188 <div><p>foo</p></div>
2189 <p>a
2190 </p><p>b
2191 </p>
2192 !! html/parsoid
2193 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2194 <p>a</p>
2195 <p>b</p>
2196 !! end
2197
2198 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2199 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2200 ## them for now.
2201 !! test
2202 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2203 !! options
2204 parsoid=wt2html
2205 !! wikitext
2206 a [[Category:A1]] [[Category:A2]]
2207 [[Category:A3]]
2208 [[Category:A4]]
2209 !! html/parsoid
2210 <p>a</p>
2211 <link rel="mw:PageProp/Category" href="./Category:A1"/> <link rel="mw:PageProp/Category" href="./Category:A2"/> <link rel="mw:PageProp/Category" href="./Category:A3"/> <link rel="mw:PageProp/Category" href="./Category:A4"/>
2212 !! end
2213
2214 !! test
2215 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2216 !! options
2217 parsoid=wt2html
2218 !! wikitext
2219 [[Category:A1]]a
2220 !! html/parsoid
2221 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2222 !! end
2223
2224 !! test
2225 No paragraph necessary for SOL transparent template
2226 !! wikitext
2227 <span><div>foo</div></span>
2228 [[Category:Foo]]
2229
2230 <span><div>foo</div></span>
2231 {{echo|[[Category:Foo]]}}
2232 !! html/php
2233 <span><div>foo</div></span>
2234 <span><div>foo</div></span>
2235
2236 !! html/parsoid
2237 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2238 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
2239
2240 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2241 <link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[Category:Foo]]"}},"i":0}}]}'/>
2242 !! end
2243
2244 !! test
2245 Avoid expanding multiline sol transparent template ranges unnecessarily
2246 !! wikitext
2247 hi
2248
2249
2250 {{echo|<br/>
2251 }}
2252
2253 [[Category:Ho]]
2254 !! html/php
2255 <p>hi
2256 </p><p><br />
2257 <br />
2258 </p>
2259 !! html/parsoid
2260 <p>hi</p>
2261
2262 <p><br />
2263 <br about="#mwt1" typeof="mw:Transclusion" data-parsoid='{}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;br/>\n"}},"i":0}}]}'/><span about="#mwt1">
2264 </span></p>
2265
2266 <link rel="mw:PageProp/Category" href="./Category:Ho" />
2267 !! end
2268
2269 !! test
2270 Paragraph wrapping following unclosed table
2271 !! options
2272 parsoid=wt2html,html2html
2273 !! wikitext
2274 {|
2275 |-
2276
2277 {|
2278 | x
2279 |}
2280
2281 a
2282
2283 b
2284
2285 c
2286 !! html/php+tidy
2287 <table>
2288
2289
2290 </table><table>
2291 <tbody><tr>
2292 <td>x
2293 </td></tr></tbody></table>
2294 <p>a
2295 </p><p>b
2296 </p><p>c
2297 </p>
2298 !! html/parsoid
2299 <table data-parsoid='{"autoInsertedEnd":true}'>
2300 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr>
2301
2302 </tbody></table><table>
2303 <tbody><tr data-parsoid='{"autoInsertedStart":true}'><td>x</td></tr>
2304 </tbody></table>
2305
2306 <p>a</p>
2307
2308 <p>b</p>
2309
2310 <p>c</p>
2311 !! end
2312
2313 !! test
2314 Paragraph wrapping suppressed in html p
2315 !! options
2316 parsoid=wt2html,html2html
2317 !! wikitext
2318 <p>
2319
2320
2321 hi
2322
2323
2324
2325 </p>
2326 !! html/php+tidy
2327 <p>
2328
2329
2330 hi
2331
2332
2333
2334 </p>
2335 !! html/parsoid
2336 <p data-parsoid='{"stx":"html"}'>
2337
2338
2339 hi
2340
2341
2342
2343 </p>
2344 !! end
2345
2346 !! test
2347 Dangling table row doesn't prevent p-wrapping
2348 !! options
2349 parsoid=wt2html,html2html
2350 !! wikitext
2351 {|
2352 | hi
2353 |-
2354 |} ho
2355 !! html/parsoid
2356 <table>
2357 <tbody><tr><td>hi</td></tr>
2358 <tr class="mw-empty-elt"></tr>
2359 </tbody></table><p> ho</p>
2360 !! end
2361
2362 ###
2363 ### Preformatted text
2364 ###
2365
2366 !! test
2367 Preformatted text
2368 !! wikitext
2369 This is some
2370 Preformatted text
2371 With ''italic''
2372 And '''bold'''
2373 And a [[Main Page|link]]
2374 !! html
2375 <pre>This is some
2376 Preformatted text
2377 With <i>italic</i>
2378 And <b>bold</b>
2379 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2380 </pre>
2381 !! end
2382
2383 !! test
2384 Tabs don't trigger preformatted text
2385 !! wikitext
2386 This is not
2387 preformatted text.
2388 This is preformatted text.
2389 So is this.
2390 !! html/php
2391 <p> This is not
2392 preformatted text.
2393 </p>
2394 <pre>This is preformatted text.
2395 So is this.
2396 </pre>
2397 !! html/parsoid
2398 <p> This is not
2399 preformatted text.</p>
2400 <pre>This is preformatted text.
2401 So is this.</pre>
2402 !! end
2403
2404 !! test
2405 Space before tab needs nowiki pre protection
2406 !! options
2407 parsoid=html2wt
2408 !! html/parsoid
2409 <p> a</p>
2410 !! wikitext
2411 <nowiki> </nowiki> a
2412 !! end
2413
2414 !! test
2415 Ident preformatting with inline content
2416 !! wikitext
2417 a
2418 ''b''
2419 !! html
2420 <pre>a
2421 <i>b</i>
2422 </pre>
2423 !! end
2424
2425 !! test
2426 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2427 !! wikitext
2428 <pre><nowiki>
2429 <b>
2430 <cite>
2431 <em>
2432 </nowiki></pre>
2433 !! html
2434 <pre>
2435 &lt;b&gt;
2436 &lt;cite&gt;
2437 &lt;em&gt;
2438 </pre>
2439
2440 !! end
2441
2442 !! test
2443 Regression with preformatted in <center>
2444 !! wikitext
2445 <center>
2446 Blah
2447 </center>
2448 !! html
2449 <center>
2450 <pre>Blah
2451 </pre>
2452 </center>
2453
2454 !! end
2455
2456 !! test
2457 T54763: Preformatted in <blockquote>
2458 !! wikitext
2459 <blockquote>
2460 Blah
2461 {|
2462 |
2463 indented cell (no pre-wrapping!)
2464 |}
2465 </blockquote>
2466 !! html
2467 <blockquote>
2468 <p> Blah
2469 </p>
2470 <table>
2471 <tr>
2472 <td>
2473 <p> indented cell (no pre-wrapping!)
2474 </p>
2475 </td></tr></table>
2476 </blockquote>
2477
2478 !! end
2479
2480 !! test
2481 T53086: Double newlines in blockquotes should be turned into paragraphs
2482 !! wikitext
2483 <blockquote>
2484 Foo
2485
2486 Bar
2487 </blockquote>
2488 !! html
2489 <blockquote>
2490 <p>Foo
2491 </p><p>Bar
2492 </p>
2493 </blockquote>
2494
2495 !! end
2496
2497 !! test
2498 T17491: <ins>/<del> in blockquote
2499 !! wikitext
2500 <blockquote>
2501 Foo <del>bar</del> <ins>baz</ins> quux
2502 </blockquote>
2503 !! html
2504 <blockquote>
2505 <p>Foo <del>bar</del> <ins>baz</ins> quux
2506 </p>
2507 </blockquote>
2508
2509 !! html+tidy
2510 <blockquote>
2511 <p>Foo <del>bar</del> <ins>baz</ins> quux
2512 </p>
2513 </blockquote>
2514 !! end
2515
2516 !! test
2517 T17491: <ins>/<del> in blockquote (2)
2518 !! wikitext
2519 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2520 </blockquote>
2521 !! html
2522 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2523 </blockquote>
2524
2525 !! html+tidy
2526 <blockquote><p>Foo <del>bar</del> <ins>baz</ins> quux
2527 </p></blockquote>
2528 !! end
2529
2530 !! test
2531 <pre> with attributes (T5202)
2532 !! wikitext
2533 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2534 !! html
2535 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2536
2537 !! end
2538
2539 !! test
2540 <pre> with width attribute (T5202)
2541 !! wikitext
2542 <pre width="8">Narrow screen goodies</pre>
2543 !! html
2544 <pre width="8">Narrow screen goodies</pre>
2545
2546 !! end
2547
2548 !! test
2549 <pre> with forbidden attribute (T5202)
2550 !! wikitext
2551 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2552 !! html
2553 <pre width="8">Narrow screen goodies</pre>
2554
2555 !! end
2556
2557 !! test
2558 Entities inside <pre>
2559 !! wikitext
2560 <pre>&lt;</pre>
2561 !! html
2562 <pre>&lt;</pre>
2563
2564 !! end
2565
2566 !! test
2567 <pre> with forbidden attribute values (T5202)
2568 !! wikitext
2569 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2570 !! html
2571 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2572
2573 !! end
2574
2575 !! test
2576 <nowiki> inside <pre> (T15238)
2577 !! wikitext
2578 <pre>
2579 <nowiki>
2580 </pre>
2581 <pre>
2582 <nowiki></nowiki>
2583 </pre>
2584 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2585 !! html
2586 <pre>
2587 &lt;nowiki&gt;
2588 </pre>
2589 <pre>
2590
2591 </pre>
2592 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2593
2594 !! end
2595
2596 !! test
2597 <nowiki> inside of #tag:pre
2598 !! wikitext
2599 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2600 !! html/php
2601 <pre>Foo &#8594;bar</pre>
2602
2603 !! html/parsoid
2604 <pre about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"#tag:pre","function":"tag"},"params":{"1":{"wt":"Foo &lt;nowiki>&amp;rarr;bar&lt;/nowiki>"}},"i":0}}]}'>Foo <span typeof="mw:Entity">→</span>bar</pre>
2605 !! end
2606
2607 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2608 ## aren't enclosed in nowikis.
2609 !! test
2610 <nowiki> and <pre> preference (first one wins)
2611 !! options
2612 parsoid=wt2html
2613 !! wikitext
2614 <pre>
2615 <nowiki>
2616 </pre>
2617 </nowiki>
2618 </pre>
2619
2620 <nowiki>
2621 <pre>
2622 <nowiki>
2623 </pre>
2624 </nowiki>
2625 </pre>
2626
2627 !! html/php
2628 <pre>
2629 &lt;nowiki&gt;
2630 </pre>
2631 <p>&lt;/nowiki&gt;
2632 &lt;/pre&gt;
2633 </p><p>
2634 &lt;pre&gt;
2635 &lt;nowiki&gt;
2636 &lt;/pre&gt;
2637
2638 &lt;/pre&gt;
2639 </p>
2640 !! html/parsoid
2641 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2642 </pre>
2643 <p>&lt;/nowiki></p>
2644
2645
2646 <p><span typeof="mw:Nowiki">
2647 &lt;pre>
2648 &lt;nowiki>
2649 &lt;/pre>
2650 </span></p>
2651 !! end
2652
2653 !! test
2654 </pre> inside nowiki
2655 !! wikitext
2656 <nowiki></pre></nowiki>
2657 !! html
2658 <p>&lt;/pre&gt;
2659 </p>
2660 !! end
2661
2662 !! test
2663 Empty pre; pre inside other HTML tags (T56946)
2664 !! wikitext
2665 a
2666
2667 <div><pre>
2668 foo
2669 </pre></div>
2670 <pre></pre>
2671 !! html/php+tidy
2672 <p>a
2673 </p>
2674 <div><pre>foo
2675 </pre></div>
2676 <pre></pre>
2677 !! html/parsoid
2678 <p>a</p>
2679
2680 <div data-parsoid='{"stx":"html"}'><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
2681 </pre></div>
2682 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2683 !! end
2684
2685 !! test
2686 HTML pre followed by indent-pre
2687 !! wikitext
2688 <pre>foo</pre>
2689 bar
2690 !! html
2691 <pre>foo</pre>
2692 <pre>bar
2693 </pre>
2694 !! end
2695
2696 !! test
2697 Block tag pre
2698 !! wikitext
2699 <p><pre>foo</pre></p>
2700 !! html/php+tidy
2701 <p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p>
2702 !! html/parsoid
2703 <p class='mw-empty-elt' data-parsoid='{"stx":"html","autoInsertedEnd":true}'></p><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre><p class='mw-empty-elt' data-parsoid='{"autoInsertedStart":true,"stx":"html"}'></p>
2704 !! end
2705
2706 !!test
2707 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2708 !! wikitext
2709 {{echo|}}
2710 !! html
2711
2712 !!end
2713
2714 !!test
2715 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2716 !! wikitext
2717 {{echo|
2718 foo}}
2719 !! html
2720 <p>foo
2721 </p>
2722 !!end
2723
2724 !! test
2725 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2726 !! wikitext
2727 {{echo|a
2728 b}}
2729 !! html
2730 <pre>a
2731 </pre>
2732 <p>b
2733 </p>
2734 !!end
2735
2736 !! test
2737 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2738 !! wikitext
2739 {{echo|a
2740 b
2741 c
2742 d
2743 e
2744 }}
2745 !! html
2746 <pre>a
2747 </pre>
2748 <p>b
2749 c
2750 </p>
2751 <pre>d
2752 </pre>
2753 <p>e
2754 </p>
2755 !!end
2756
2757 !!test
2758 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2759 !! wikitext
2760 {{echo| foo}}
2761
2762 {{echo| foo}}{{echo| bar}}
2763
2764 {{echo| foo}}
2765 {{echo| bar}}
2766
2767 {{echo|<!--cmt--> foo}}
2768
2769 <!--cmt-->{{echo| foo}}
2770
2771 {{echo|{{echo| }}bar}}
2772 !! html
2773 <pre>foo
2774 </pre>
2775 <pre>foo bar
2776 </pre>
2777 <pre>foo
2778 bar
2779 </pre>
2780 <pre>foo
2781 </pre>
2782 <pre>foo
2783 </pre>
2784 <pre>bar
2785 </pre>
2786 !!end
2787
2788 !! test
2789 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2790 !! wikitext
2791 {{echo| }}a
2792
2793 {{echo|
2794 }}a
2795
2796 {{echo|
2797 b}}
2798
2799 {{echo|a
2800 }}b
2801
2802 {{echo|a
2803 }} b
2804 !! html
2805 <pre>a
2806 </pre>
2807 <p><br />
2808 </p>
2809 <pre>a
2810 </pre>
2811 <p><br />
2812 </p>
2813 <pre>b
2814 </pre>
2815 <p>a
2816 </p>
2817 <pre>b
2818 </pre>
2819 <p>a
2820 </p>
2821 <pre>b
2822 </pre>
2823 !!end
2824
2825 ## Hmm, should Parsoid rt this?
2826 !! test
2827 Pres with newline attributes
2828 !! options
2829 parsoid=wt2html,html2html
2830 !! wikitext
2831 <pre class="one
2832 two">hi</pre>
2833 !! html/php
2834 <pre class="one two">hi</pre>
2835
2836 !! html/parsoid
2837 <pre class="one two" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2838 !! end
2839
2840 !! test
2841 Things that look like <pre> tags aren't treated as such
2842 !! wikitext
2843 Barack Obama <President> of the United States
2844 <President></President>
2845 !! html
2846 <p>Barack Obama &lt;President&gt; of the United States
2847 &lt;President&gt;&lt;/President&gt;
2848 </p>
2849 !! end
2850
2851 ## Remex doesn't account for fostered content.
2852 ## The difference between Parsoid and the PHP parser can be attributed to core
2853 ## commit 674e8388cba and 710618f89af in Parsoid's repo. Parsoid doesn't
2854 ## tokenize unmatched extension tags that shadow html tags as strings to ease
2855 ## an escaping mechanism. See the comment in `maybeExtensionTag`.
2856 !! test
2857 Handle broken pre-like tags (T66025)
2858 !! options
2859 parsoid=wt2html
2860 !! wikitext
2861 {{echo|<pre <pre>x</pre>}}
2862
2863 <table><pre </table>
2864 !! html/php
2865 <pre>x</pre>
2866 <table>&lt;pre </table>
2867
2868 !! html/php+tidy
2869 <pre>x</pre>
2870 &lt;pre <table></table>
2871 !! html/parsoid
2872 <pre typeof="mw:Extension/pre mw:Transclusion" about="#mwt2" data-parsoid='{"stx":"html","a":{"&lt;pre":null},"sa":{"&lt;pre":""},"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre &lt;pre>x&lt;/pre>"}},"i":0}}]}'>x</pre>
2873
2874 <pre data-parsoid='{"stx":"html","src":"&lt;pre &lt;/table>","tagWidths":[13,0],"a":{"&lt;":null,"table":null},"sa":{"&lt;":"","table":""},"fostered":true,"autoInsertedEnd":true}'></pre><table data-parsoid='{"stx":"html","autoInsertedEnd":true}'></table>
2875 !! end
2876
2877 ## Similar to the above, but shows the difference between extension and html tags
2878 !! test
2879 Less than in attribute position
2880 !! wikitext
2881 <pre <pre>123</pre>
2882
2883 <div <div>123</div>
2884 !! html/php+tidy
2885 <pre>123</pre><p>
2886 &lt;div </p><div>123</div>
2887 !! html/parsoid
2888 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"&lt;pre":""},"body":{"extsrc":"123"}}'>123</pre><p>
2889
2890 &lt;div </p><div>123</div>
2891 !! end
2892
2893 !! test
2894 Parsoid: handle pre with space after attribute
2895 !! options
2896 parsoid=wt2html
2897 !! wikitext
2898 <pre style="width:50%;" >{{echo|foo}}</pre>
2899 !! html/php
2900 <pre style="width:50%;">{{echo|foo}}</pre>
2901
2902 !! html/parsoid
2903 <pre typeof="mw:Extension/pre" about="#mwt2" style="width:50%;" data-mw='{"name":"pre","attrs":{"style":"width:50%;"},"body":{"extsrc":"{{echo|foo}}"}}'>{{echo|foo}}</pre>
2904 !! end
2905
2906 !! test
2907 Self-closed pre
2908 !! wikitext
2909 <pre />
2910 !! html/php
2911 <pre></pre>
2912
2913 !! html/parsoid
2914 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{}}'></pre>
2915 !! end
2916
2917 !! test
2918 Newline before table-close generates empty table row: T208619
2919 !! wikitext
2920 {|
2921
2922 |}
2923 !! html/php+tidy
2924 <table>
2925
2926 <tbody><tr><td></td></tr></tbody></table>
2927 !! html/parsoid
2928 <table data-parsoid='{}'>
2929
2930 </table>
2931 !! end
2932
2933 # PHP has one more row in the output than Parsoid does: T208619
2934 !! test
2935 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2936 !! options
2937 parsoid=wt2html
2938 !! wikitext
2939 {|
2940 <td>
2941 <td>
2942 </td>
2943
2944
2945
2946 |}
2947 !! html/php+tidy
2948 <table>
2949 <tbody><tr><td>
2950 </td><td>
2951 </td>
2952
2953
2954
2955 </tr><tr><td></td></tr></tbody></table>
2956 !! html/parsoid
2957 <table>
2958
2959 <tbody>
2960 <tr>
2961 <td></td>
2962
2963 <td>
2964 </td></tr>
2965
2966
2967
2968 </tbody></table>
2969 !! end
2970
2971
2972 #--------------------------------------------------------------------
2973 # Transclusion parameter whitespace stripping tests
2974 # Behavior is different for positional and named parameters
2975 #--------------------------------------------------------------------
2976 !! test
2977 Templates: Strip leading and trailing whitespace from named-param values
2978 !! wikitext
2979 {{echo|1= a }}
2980
2981 {{echo|1= {{echo|b}} }}
2982
2983 {{echo| 1 =
2984 c }}
2985
2986 {{echo| 1 =
2987 * d
2988 }}
2989 !! html
2990 <p>a
2991 </p><p>b
2992 </p><p>c
2993 </p>
2994 <ul><li>d</li></ul>
2995
2996 !! end
2997
2998 !! test
2999 Templates: Don't strip whitespace from positional-param values
3000 !! wikitext
3001 {{echo|a }}
3002
3003 {{echo|{{echo|b}} }}
3004
3005 {{echo| c
3006 }}
3007
3008 {{echo| {{echo|d}}
3009 }}
3010
3011 {{echo|
3012 e}}
3013
3014 {{echo|
3015 *f}}
3016
3017 {{echo|
3018 }}g
3019 !! html
3020 <p>a
3021 </p><p>b
3022 </p>
3023 <pre>c
3024 </pre>
3025 <p><br />
3026 </p>
3027 <pre>d
3028 </pre>
3029 <p><br />
3030 </p>
3031 <pre>e
3032 </pre>
3033 <p><br />
3034 </p>
3035 <ul><li>f</li></ul>
3036 <p><br />
3037 </p>
3038 <pre>g
3039 </pre>
3040 !! end
3041
3042 !! test
3043 Templates: Don't recognize targets split by newlines
3044 !! options
3045 parsoid=wt2html
3046 !! wikitext
3047 {{ech
3048 o|foo}}
3049 !! html/php
3050 <p>{{ech
3051 o|foo}}
3052 </p>
3053 !! html/parsoid
3054 <p>{{ech
3055 o|foo}}</p>
3056 !! end
3057
3058 !! test
3059 Templates: Recognize targets when newlines and comments don't split the target
3060 !! options
3061 parsoid=wt2html
3062 !! wikitext
3063 {{
3064 <!--X--> ech<!--X-->o<!--X-->
3065 <!--X--> <!--X-->
3066
3067 |foo}}
3068 !! html/php
3069 <p>foo
3070 </p>
3071 !! html/parsoid
3072 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"ech&lt;!--X-->o&lt;!--X--> \n &lt;!--X--> &lt;!--X-->\n\n ","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
3073 !! end
3074
3075 !! test
3076 Templates: Handle empty comment-and-ws-only lines correctly
3077 !! wikitext
3078 {{echo|foo
3079 <!--should be ignored-->
3080 <!--should be ignored as well-->
3081 bar}}
3082 !! html/php
3083 <p>foo
3084 bar
3085 </p>
3086 !! html/parsoid
3087 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo\n&lt;!--should be ignored-->\n &lt;!--should be ignored as well-->\nbar"}},"i":0}}]}'>foo <!--should be ignored--> <!--should be ignored as well--> bar</p>
3088 !! end
3089
3090 !! test
3091 Templates: Handle comments in the target
3092 !! wikitext
3093 {{echo
3094 <!-- should be ignored -->
3095 |foo}}
3096
3097 {{echo
3098 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
3099 |foo}}
3100
3101 {{echo<!-- should be ignored -->
3102 |foo}}
3103
3104 {{echo<!-- should be ignored -->|foo}}
3105
3106 {{<!-- should be ignored -->echo|foo}}
3107 !! html/php
3108 <p>foo
3109 </p><p>foo
3110 </p><p>foo
3111 </p><p>foo
3112 </p><p>foo
3113 </p>
3114 !! html/parsoid
3115 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n&lt;!-- should be ignored -->\n","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
3116
3117 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n&lt;!-- should be ignored and spaces on next line should not trip us up (T147742) -->\n ","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
3118
3119 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo&lt;!-- should be ignored -->\n","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
3120
3121 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo&lt;!-- should be ignored -->","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
3122
3123 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
3124 !! end
3125
3126 !! test
3127 Templates: Handle comments in parameter names (T69657)
3128 !! wikitext
3129 {{echo|1
3130 <!-- should be ignored -->
3131 =foo}}
3132
3133 {{echo|
3134 <!-- should be ignored -->
3135 1 = foo}}
3136
3137 {{echo|1<!-- should be ignored -->=foo}}
3138
3139 {{echo|<!-- should be ignored -->1=foo}}
3140 !! html/php
3141 <p>foo
3142 </p><p>foo
3143 </p><p>foo
3144 </p><p>foo
3145 </p>
3146 !! html/parsoid
3147 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo","key":{"wt":"1\n&lt;!-- should be ignored -->"}}},"i":0}}]}'>foo</p>
3148
3149 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo","key":{"wt":"&lt;!-- should be ignored -->\n1"}}},"i":0}}]}'>foo</p>
3150
3151 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo","key":{"wt":"1&lt;!-- should be ignored -->"}}},"i":0}}]}'>foo</p>
3152
3153 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo","key":{"wt":"&lt;!-- should be ignored -->1"}}},"i":0}}]}'>foo</p>
3154 !! end
3155
3156 !! test
3157 Templates: Other wikitext in parameter names (T69657)
3158 !! wikitext
3159 {{echo|''1''=foo}}
3160 !! html/php
3161 <p>{{{1}}}
3162 </p>
3163 !! html/parsoid
3164 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"&#39;&#39;1&#39;&#39;":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3165 !! end
3166
3167 !! test
3168 Templates: With colons
3169 !! wikitext
3170 {{With: Colon}}
3171 !! html/php
3172 <p>Template with colon
3173 </p>
3174 !! html/parsoid
3175 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"With: Colon","href":"./Template:With:_Colon"},"params":{},"i":0}}]}'>Template with colon</p>
3176 !! end
3177
3178 #--------------------------------------------------------------------
3179 # Transclusion parameter escaping tests
3180 #--------------------------------------------------------------------
3181
3182 !! test
3183 Templates: Parsoid parameter escaping test 1
3184 !! wikitext
3185 {{echo|[foo]|{{echo|[bar]}}}}
3186 !! html/php+tidy
3187 <p>[foo]
3188 </p>
3189 !! html/parsoid
3190 <p about="#mwt1" typeof="mw:Transclusion"
3191 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
3192 !! end
3193
3194 !! test
3195 Parsoid: Pipes in external links in template parameter
3196 !! wikitext
3197 {{echo|[{{echo|http://example.com}} link]}}
3198 !! html/php+tidy
3199 <p><a rel="nofollow" class="external text" href="http://example.com">link</a>
3200 </p>
3201 !! html/parsoid
3202 <p><a rel="mw:ExtLink" class="external text" href="http://example.com" about="#mwt31" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{echo|http://example.com}} link]"}},"i":0}}]}'>link</a></p>
3203 !! end
3204
3205 !! test
3206 Parsoid: pipe in transclusion parameter
3207 !! wikitext
3208 {{echo|http://foo.com/a&#124;b}}
3209 !! html/php+tidy
3210 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a>
3211 </p>
3212 !! html/parsoid
3213 <p><a rel="mw:ExtLink" class="external free" href="http://foo.com/a%7Cb" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"http://foo.com/a&amp;#124;b"}},"i":0}}]}'>http://foo.com/a%7Cb</a></p>
3214 !! end
3215
3216 !! test
3217 Parsoid: Pipe in external link target and content in template parameter
3218 !! options
3219 parsoid=html2wt,wt2wt
3220 !! wikitext
3221 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
3222 !! html/php+tidy
3223 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a&#124;b</a>
3224 </p>
3225 !! html/parsoid
3226 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
3227 typeof="mw:Transclusion"
3228 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
3229 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
3230 !! end
3231
3232 !! test
3233 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
3234 !! wikitext
3235 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
3236 !! html/php+tidy
3237 <p><a rel="nofollow" class="external text" href="http://example.org/index.php?title=Parser_test&amp;action=edit">bar</a>
3238 </p>
3239 !! html/parsoid
3240 <p><a rel="mw:ExtLink" class="external text" href="http://example.org/index.php?title=Parser_test&amp;action=edit" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]"}},"i":0}}]}'>bar</a></p>
3241 !! end
3242
3243 !! test
3244 Templates: Don't escape already nowiki-escaped text in template parameters
3245 !! options
3246 parsoid=html2wt,wt2wt
3247 !! wikitext
3248 {{echo|foo<nowiki>|</nowiki>bar}}
3249 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
3250 {{echo|<nowiki></nowiki>}}
3251 !! html/php+tidy
3252 <p>foo|bar
3253 &lt;div&gt;
3254
3255 </p>
3256 !! html/parsoid
3257 <p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo<nowiki>|</nowiki>bar"}},"i":0}}]}'}'>foo</span><span typeof="mw:Nowiki" about="#mwt1">|</span><span about="#mwt1">bar</span>
3258 <span typeof="mw:Transclusion mw:Nowiki" about="#mwt2" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<nowiki>&amp;lt;div&amp;gt;</nowiki>"}},"i":0}}]}'><span typeof="mw:Entity">&lt;</span>div<span typeof="mw:Entity">&gt;</span></span>
3259 <span typeof="mw:Transclusion mw:Nowiki" about="#mwt3" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"<nowiki></nowiki>"}},"i":0}}]}'></span>
3260 </p>
3261 !! end
3262
3263 ## T54824
3264 !! test
3265 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
3266 !! options
3267 parsoid=html2wt,wt2wt
3268 !! wikitext
3269 {{echo|{{echo|1=bar}}}}
3270 !! html/php+tidy
3271 <p>bar
3272 </p>
3273 !! html/parsoid
3274 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"{{echo|1=bar}}"}},"i":0}}]}'>bar</p>
3275 !! end
3276
3277 ## T58733
3278 !! test
3279 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
3280 !! wikitext
3281 {{echo|a : b}}
3282 !! html/php+tidy
3283 <p>a&#160;: b
3284 </p>
3285 !! html/parsoid
3286 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a : b"}},"i":0}}]}'>a<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"isDisplayHack":true}'> </span>: b</p>
3287 !! end
3288
3289 ## T73412
3290 !! test
3291 Templates: Preserve blank parameter names
3292 !! wikitext
3293 {{echo|=foo}}
3294 !! html/php+tidy
3295 <p>{{{1}}}
3296 </p>
3297 !! html/parsoid
3298 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3299 !! end
3300
3301 !! test
3302 Templates: Preserve blank parameter names in other positions
3303 !! wikitext
3304 {{blank_param|bar|=foo}}
3305 !! html/php+tidy
3306 <p>bar
3307 foo
3308 </p>
3309 !! html/parsoid
3310 <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"},{"k":"","named":true}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"blank_param","href":"./Template:Blank_param"},"params":{"1":{"wt":"bar"},"":{"wt":"foo"}},"i":0}}]}'>bar
3311 foo</p>
3312 !! end
3313
3314 ###
3315 ### Parsoid-centric tests for testing RT edge cases for pre
3316 ###
3317
3318 !!test
3319 1a. Indent-Pre and Comments
3320 !! wikitext
3321 a
3322 <!--a-->
3323 c
3324 !! html
3325 <pre>a
3326 </pre>
3327 <p>c
3328 </p>
3329 !!end
3330
3331 !!test
3332 1b. Indent-Pre and Comments
3333 !! wikitext
3334 a
3335 <!--a-->
3336 c
3337 !! html
3338 <pre>a
3339 </pre>
3340 <p>c
3341 </p>
3342 !!end
3343
3344 !!test
3345 1c. Indent-Pre and Comments
3346 !! wikitext
3347 <!--a--> a
3348
3349 <!--a--> a
3350 !! html
3351 <pre> a
3352 </pre>
3353 <pre> a
3354 </pre>
3355 !!end
3356
3357 !!test
3358 1d. Indent-Pre and Comments
3359 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3360 !! wikitext
3361 <!--a--> a
3362
3363 <!--b-->b
3364 !! html
3365 <pre>a
3366 </pre>
3367 <pre>b
3368 </pre>
3369 !!end
3370
3371 !!test
3372 2a. Indent-Pre and tables
3373 !! wikitext
3374 {|
3375 |-
3376 !h1!!h2
3377 |foo||bar
3378 |}
3379 !! html
3380 <table>
3381
3382 <tr>
3383 <th>h1</th>
3384 <th>h2
3385 </th>
3386 <td>foo</td>
3387 <td>bar
3388 </td></tr></table>
3389
3390 !!end
3391
3392 !!test
3393 2b. Indent-Pre and tables
3394 !! wikitext
3395 {|
3396 |-
3397 |foo
3398 |}
3399 !! html
3400 <table>
3401
3402 <tr>
3403 <td>foo
3404 </td></tr></table>
3405
3406 !!end
3407
3408 !!test
3409 2c. Indent-Pre and tables (T44252)
3410 !! wikitext
3411 {|
3412 |+foo
3413 ! |bar
3414 |}
3415 !! html
3416 <table>
3417 <caption>foo
3418 </caption>
3419 <tr>
3420 <th>bar
3421 </th></tr></table>
3422
3423 !!end
3424
3425 !!test
3426 2d. Indent-Pre and tables
3427 !! wikitext
3428 a
3429 {|
3430 |b
3431 |}
3432 !! html/php
3433 <pre>a
3434 </pre>
3435 <table>
3436 <tr>
3437 <td>b
3438 </td></tr></table>
3439
3440 !! html/parsoid
3441 <pre>a</pre>
3442 <table>
3443 <tbody><tr><td> b</td></tr>
3444 </tbody></table>
3445 !!end
3446
3447 !!test
3448 2e. Indent-Pre and table-line syntax
3449 !! wikitext
3450 a
3451 | b
3452 | c
3453 !! html/php
3454 <pre>a
3455 | b
3456 | c
3457 </pre>
3458 !!end
3459
3460 !!test
3461 2f. Indent-pre started by table-line syntax
3462 !! wikitext
3463 a
3464 | b
3465 | c
3466 !! html/php
3467 <p>a
3468 </p>
3469 <pre>| b
3470 | c
3471 </pre>
3472 !! html/parsoid
3473 <p>a</p>
3474 <pre>
3475 | b
3476 | c</pre>
3477 !!end
3478
3479 !! test
3480 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3481 !! wikitext
3482 <table>
3483 <tr>
3484 <td>
3485 Text that should be rendered preformatted
3486 </td>
3487 </tr>
3488 </table>
3489 !! html
3490 <table>
3491 <tr>
3492 <td>
3493 <pre>Text that should be rendered preformatted
3494 </pre>
3495 </td>
3496 </tr>
3497 </table>
3498
3499 !! end
3500
3501 !! test
3502 2h. Indent pre in tables
3503 !! options
3504 parsoid=wt2html,html2html
3505 !! wikitext
3506 {|
3507 !
3508 foo
3509 !
3510 bar
3511 |-
3512 |
3513 baz
3514 {{!}}
3515 bam
3516 |}
3517 !! html/php
3518 <table>
3519 <tr>
3520 <th>
3521 <pre>foo
3522 </pre>
3523 </th>
3524 <th>
3525 <pre>bar
3526 </pre>
3527 </th></tr>
3528 <tr>
3529 <td>
3530 <pre>baz
3531 </pre>
3532 </td>
3533 <td>
3534 <pre>bam
3535 </pre>
3536 </td></tr></table>
3537
3538 !! html/parsoid
3539 <table>
3540 <tbody><tr><th>
3541 <pre>foo</pre>
3542 </th><th>
3543 <pre>bar</pre>
3544 </th></tr><tr>
3545 <td>
3546 <pre>baz</pre>
3547 </td><td data-parsoid='{"startTagSrc":"{{!}}"}'>
3548 <pre>bam</pre>
3549 </td></tr></tbody></table>
3550 !! end
3551
3552 !! test
3553 3a. Indent-Pre and block tags (single-line html)
3554 !! wikitext
3555 a <p> foo </p>
3556 b <div> foo </div>
3557 c <blockquote> foo </blockquote>
3558 <span> foo </span>
3559 !! html
3560 a <p> foo </p>
3561 b <div> foo </div>
3562 c <blockquote> foo </blockquote>
3563 <pre><span> foo </span>
3564 </pre>
3565 !! html/php+tidy
3566 <p> a </p><p> foo </p><p>
3567 b </p><div> foo </div><p>
3568 c </p><blockquote><p> foo </p></blockquote>
3569 <pre><span> foo </span>
3570 </pre>
3571 !! html/parsoid
3572 <p> a </p><p data-parsoid='{"stx":"html"}'> foo </p><p>
3573 b </p><div data-parsoid='{"stx":"html"}'> foo </div><p>
3574 c </p><blockquote data-parsoid='{"stx":"html"}'><p> foo </p></blockquote>
3575 <pre><span data-parsoid='{"stx":"html"}'> foo </span></pre>
3576 !! end
3577
3578 !! test
3579 3b. Indent-Pre and block tags (multi-line html)
3580 !! wikitext
3581 a <span>foo</span>
3582 <!-- comment --> b <div> foo </div>
3583 !! html/php
3584 <pre>a <span>foo</span>
3585 </pre>
3586 b <div> foo </div>
3587
3588 !! html/parsoid
3589 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3590 <!-- comment --> <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3591 !! html/php+tidy
3592 <pre>a <span>foo</span>
3593 </pre><p>
3594 b </p><div> foo </div>
3595 !! end
3596
3597 !!test
3598 3c. Indent-Pre and block tags (pre-content on separate line)
3599 !! wikitext
3600 <p>
3601 foo
3602 </p>
3603
3604 <div>
3605 foo
3606 </div>
3607
3608 <center>
3609 foo
3610 </center>
3611
3612 <blockquote>
3613 foo
3614 </blockquote>
3615
3616 <blockquote>
3617 <pre>
3618 foo
3619 </pre>
3620 </blockquote>
3621
3622 <table><tr><td>
3623 foo
3624 </td></tr></table>
3625
3626 <ul><li>
3627 foo
3628 </li></ul>
3629
3630 !! html
3631 <p>
3632 foo
3633 </p>
3634 <div>
3635 <pre>foo
3636 </pre>
3637 </div>
3638 <center>
3639 <pre>foo
3640 </pre>
3641 </center>
3642 <blockquote>
3643 <p> foo
3644 </p>
3645 </blockquote>
3646 <blockquote>
3647 <pre>
3648 foo
3649 </pre>
3650 </blockquote>
3651 <table><tr><td>
3652 <pre>foo
3653 </pre>
3654 </td></tr></table>
3655 <ul><li>
3656 foo
3657 </li></ul>
3658
3659 !!end
3660
3661 !! test
3662 4. Indent-Pre and extension tags
3663 !! options
3664 parsoid=wt2html,html2html
3665 !! wikitext
3666 a <tag />
3667 !! html/php+tidy
3668 <p> a </p><pre>NULL
3669 array (
3670 )
3671 </pre>
3672 !! html/parsoid
3673 <p> a </p><pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{}}'></pre>
3674 !! end
3675
3676 !! test
3677 5. Indent-Pre and html pre
3678 !! wikitext
3679 <pre class="123">hi</pre>
3680 !! html/php
3681 <pre class="123">hi</pre>
3682
3683 !! html/parsoid
3684 <pre class="123" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3685 !! end
3686
3687 !!test
3688 Render paragraphs when indent-pre is suppressed in blocklevels
3689 !! wikitext
3690 <blockquote>
3691 foo
3692
3693 bar
3694 </blockquote>
3695 !! html
3696 <blockquote>
3697 <p> foo
3698 </p><p> bar
3699 </p>
3700 </blockquote>
3701
3702 !!end
3703
3704 !!test
3705 4. Multiple spaces at start-of-line
3706 !! wikitext
3707 <p> foo </p>
3708 foo
3709 {|
3710 |foo
3711 |}
3712 !! html
3713 <p> foo </p>
3714 <pre> foo
3715 </pre>
3716 <table>
3717 <tr>
3718 <td>foo
3719 </td></tr></table>
3720
3721 !!end
3722
3723 ## NOTE: the leading white-space chars on empty line are significant
3724 !! test
3725 5a. White-space in indent-pre
3726 !! wikitext
3727 a<br />
3728
3729 b
3730 !! html
3731 <pre>a<br />
3732
3733 b
3734 </pre>
3735 !! end
3736
3737 ## NOTE: the leading white-space chars on empty line are significant
3738 !! test
3739 5b. White-space in indent-pre
3740 !! wikitext
3741 a
3742
3743 b
3744
3745
3746 c
3747 !! html
3748 <pre>a
3749
3750 b
3751
3752
3753 c
3754 </pre>
3755 !! end
3756
3757 !! test
3758 5c. White-space in indent-pre
3759 !! wikitext
3760 ''a''
3761 ''b''
3762 ''c''
3763 !! html
3764 <pre><i>a</i>
3765 <i>b</i>
3766 <i>c</i>
3767 </pre>
3768 !! end
3769
3770 !! test
3771 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3772 !! wikitext
3773 a
3774
3775 <!-- continue -->
3776 b
3777
3778 c
3779
3780 d
3781 !! html
3782 <pre>a
3783
3784 b
3785 </pre>
3786 <pre>c
3787
3788 </pre>
3789 <p>d
3790 </p>
3791 !! end
3792
3793 !! test
3794 7a. Indent-pre and category links
3795 !! options
3796 parsoid=wt2html,wt2wt
3797 !! wikitext
3798 [[Category:foo]] <!-- No pre-wrapping -->
3799 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3800 !! html/php+tidy
3801 !! html/parsoid
3802 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3803 <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":" [[Category:foo]]"}},"i":0}}]}'> </span><link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1"> <!-- No pre&#x2D;wrapping -->
3804 !! end
3805
3806 ## We used to, but no longer wt2wt this test since the default serializer
3807 ## will normalize all categories to serialize on their own line.
3808 ## This wikitext usage is going to be fairly uncommon in production and
3809 ## selser will take care of preserving formatting in those scenarios.
3810 !! test
3811 7b. Indent-pre and category links
3812 !! options
3813 parsoid=wt2html
3814 !! wikitext
3815 [[Category:foo]] a
3816 [[Category:foo]] {{echo|b}}
3817 !! html/parsoid
3818 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3819 <link rel="mw:PageProp/Category" href="./Category:Foo"> <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"b"}},"i":0}}]}'>b</span></pre>
3820 !! end
3821
3822 !! test
3823 Indent-Pre: Newlines in comments shouldn't affect sol state
3824 !! wikitext
3825 a <!--
3826 foo
3827 --> b
3828 !! html/php+tidy
3829 <p>a b
3830 </p>
3831 !! html/parsoid
3832 <p>a <!--
3833 foo
3834 --> b</p>
3835 !! end
3836
3837 ###
3838 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3839 ###
3840
3841 !!test
3842 HTML-pre: 1. embedded newlines
3843 !! wikitext
3844 <pre>foo</pre>
3845
3846 <pre>
3847 foo
3848 </pre>
3849
3850 <pre>
3851
3852 foo
3853 </pre>
3854
3855 <pre>
3856
3857
3858 foo
3859 </pre>
3860 !! html/php+tidy
3861 <pre>foo</pre>
3862 <pre>foo
3863 </pre>
3864 <pre>
3865
3866 foo
3867 </pre>
3868 <pre>
3869
3870
3871 foo
3872 </pre>
3873 !! html/parsoid
3874 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3875
3876 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3877 </pre>
3878
3879 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3880
3881 foo
3882 </pre>
3883
3884 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3885
3886
3887 foo
3888 </pre>
3889 !!end
3890
3891 !! test
3892 HTML-pre: big spaces
3893 !! wikitext
3894 <pre>
3895
3896
3897
3898
3899 haha
3900
3901
3902
3903
3904 haha
3905
3906
3907
3908
3909 </pre>
3910 !! html/php+tidy
3911 <pre>
3912
3913
3914
3915
3916 haha
3917
3918
3919
3920
3921 haha
3922
3923
3924
3925
3926 </pre>
3927 !! html/parsoid
3928 <pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\n\n\nhaha\n\n\n\n\nhaha\n\n\n\n\n"}}'>
3929
3930
3931
3932
3933 haha
3934
3935
3936
3937
3938 haha
3939
3940
3941
3942
3943 </pre>
3944 !! end
3945
3946 !!test
3947 HTML-pre: 2: indented text
3948 !! wikitext
3949 <pre>
3950 foo
3951 </pre>
3952 !! html
3953 <pre>
3954 foo
3955 </pre>
3956
3957 !!end
3958
3959 !!test
3960 HTML-pre: 3: other wikitext
3961 !! wikitext
3962 <pre>
3963 * foo
3964 # bar
3965 = no-h =
3966 '' no-italic ''
3967 [[ NoLink ]]
3968 </pre>
3969 !! html/php
3970 <pre>
3971 * foo
3972 # bar
3973 = no-h =
3974 '' no-italic ''
3975 [[ NoLink ]]
3976 </pre>
3977
3978 !! html/parsoid
3979 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n* foo\n# bar\n= no-h =\n&#39;&#39; no-italic &#39;&#39;\n[[ NoLink ]]\n"}}'>* foo
3980 # bar
3981 = no-h =
3982 '' no-italic ''
3983 [[ NoLink ]]
3984 </pre>
3985 !!end
3986
3987 ###
3988 ### Definition lists
3989 ###
3990 !! test
3991 Simple definition
3992 !! wikitext
3993 ;name :Definition
3994 !! html
3995 <dl><dt>name</dt>
3996 <dd>Definition</dd></dl>
3997
3998 !! end
3999
4000 !! test
4001 Definition list for indentation only
4002 !! wikitext
4003 :Indented text
4004 !! html
4005 <dl><dd>Indented text</dd></dl>
4006
4007 !! end
4008
4009 !! test
4010 Definition list with no space
4011 !! wikitext
4012 ;name:Definition
4013 !! html
4014 <dl><dt>name</dt>
4015 <dd>Definition</dd></dl>
4016
4017 !!end
4018
4019 !! test
4020 Definition list with URL link
4021 !! wikitext
4022 ;http://example.com/ :definition
4023 !! html
4024 <dl><dt><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a></dt>
4025 <dd>definition</dd></dl>
4026
4027 !! end
4028
4029 !! test
4030 Definition list with bracketed URL link
4031 !! wikitext
4032 ;[http://www.example.com/ Example]:Something about it
4033 !! html
4034 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
4035 <dd>Something about it</dd></dl>
4036
4037 !! end
4038
4039 !! test
4040 Definition list with wikilink containing colon
4041 !! wikitext
4042 ;[[Help:FAQ]]:The least-read page on Wikipedia
4043 !! html
4044 <dl><dt><a href="/index.php?title=Help:FAQ&amp;action=edit&amp;redlink=1" class="new" title="Help:FAQ (page does not exist)">Help:FAQ</a></dt>
4045 <dd>The least-read page on Wikipedia</dd></dl>
4046
4047 !! end
4048
4049 # At Brion's and JeLuF's insistence... :)
4050 !! test
4051 Definition list with news link containing colon
4052 !! wikitext
4053 ;news:alt.wikipedia.rox :This isn't even a real newsgroup!
4054 !! html/php
4055 <dl><dt><a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
4056 <dd>This isn't even a real newsgroup!</dd></dl>
4057
4058 !! html/parsoid
4059 <dl><dt><a rel="mw:ExtLink" class="external free" href="news:alt.wikipedia.rox" data-parsoid='{"stx":"url"}'>news:alt.wikipedia.rox</a></dt><dd data-parsoid='{"stx":"row"}'>This isn't even a real newsgroup!</dd></dl>
4060 !! end
4061
4062 !! test
4063 Malformed definition list with colon
4064 !! wikitext
4065 ;news:alt.wikipedia.rox -- don't crash or enter an infinite loop
4066 !! html
4067 <dl><dt><a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a> -- don't crash or enter an infinite loop</dt></dl>
4068
4069 !! end
4070
4071 !! test
4072 Definition lists: colon in external link text
4073 !! wikitext
4074 ;[http://www.wikipedia2.org/ Wikipedia :The Next Generation] :OK, I made that up
4075 !! html
4076 <dl><dt><a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia :The Next Generation</a></dt>
4077 <dd>OK, I made that up</dd></dl>
4078
4079 !! end
4080
4081 !! test
4082 Definition lists: colon in HTML attribute
4083 !! wikitext
4084 ;<b style="display: inline">bold</b>
4085 !! html
4086 <dl><dt><b style="display: inline">bold</b></dt></dl>
4087
4088 !! end
4089
4090 !! test
4091 Definition lists: self-closed tag
4092 !! wikitext
4093 ;one<br/>two :two-line fun
4094 !! html
4095 <dl><dt>one<br />two</dt>
4096 <dd>two-line fun</dd></dl>
4097
4098 !! end
4099
4100 !! test
4101 Definition lists: ignore colons inside tags
4102 !! wikitext
4103 ;one <b>two : tag <i>fun:</i>:</b>:def
4104 !! html
4105 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
4106 <dd>def</dd></dl>
4107
4108 !! end
4109
4110 !! test
4111 Definition lists: excess closed tags
4112 !! wikitext
4113 ;one</b>two :bad tag fun
4114 !! html/php+tidy
4115 <dl><dt>onetwo</dt>
4116 <dd>bad tag fun</dd></dl>
4117 !! html/parsoid
4118 <dl>
4119 <dt>onetwo</dt>
4120 <dd>bad tag fun</dd>
4121 </dl>
4122 !! end
4123
4124 !! test
4125 T13748: Literal closing tags
4126 !! wikitext
4127 <dl>
4128 <dt>test 1</dt>
4129 <dd>test test test test test</dd>
4130 <dt>test 2</dt>
4131 <dd>test test test test test</dd>
4132 </dl>
4133 !! html
4134 <dl>
4135 <dt>test 1</dt>
4136 <dd>test test test test test</dd>
4137 <dt>test 2</dt>
4138 <dd>test test test test test</dd>
4139 </dl>
4140
4141 !! end
4142
4143 !! test
4144 Definition and unordered list using wiki syntax nested in unordered list using html tags.
4145 !! wikitext
4146 <ul><li>
4147 ;term :description
4148 *unordered
4149 </li></ul>
4150 !! html
4151 <ul><li>
4152 <dl><dt>term</dt>
4153 <dd>description</dd></dl>
4154 <ul><li>unordered</li></ul>
4155 </li></ul>
4156
4157 !! end
4158
4159 !! test
4160 Definition list with empty definition and following paragraph
4161 !! wikitext
4162 ;term:
4163
4164 Paragraph text
4165 !! html
4166 <dl><dt>term</dt>
4167 <dd></dd></dl>
4168 <p>Paragraph text
4169 </p>
4170 !! end
4171
4172 !! test
4173 Nested definition lists using html syntax
4174 !! wikitext
4175 <dl><dt>x</dt>
4176 <dd>a</dd>
4177 <dd>b</dd></dl>
4178 !! html
4179 <dl><dt>x</dt>
4180 <dd>a</dd>
4181 <dd>b</dd></dl>
4182
4183 !! end
4184
4185 !! test
4186 Definition Lists: No nesting: Multiple dd's
4187 !! wikitext
4188 ;x
4189 :a
4190 :b
4191 !! html
4192 <dl><dt>x</dt>
4193 <dd>a</dd>
4194 <dd>b</dd></dl>
4195
4196 !! end
4197
4198 !! test
4199 Definition Lists: Indentation: Regular
4200 !! wikitext
4201 :i1
4202 ::i2
4203 :::i3
4204 !! html
4205 <dl><dd>i1
4206 <dl><dd>i2
4207 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4208
4209 !! end
4210
4211 !! test
4212 Definition Lists: Indentation: Missing 1st level
4213 !! wikitext
4214 ::i2
4215 :::i3
4216 !! html
4217 <dl><dd><dl><dd>i2
4218 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
4219
4220 !! end
4221
4222 !! test
4223 Definition Lists: Indentation: Multi-level indent
4224 !! wikitext
4225 :::i3
4226 !! html
4227 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
4228
4229 !! end
4230
4231 !! test
4232 Definition Lists: Hacky use to indent tables
4233 !! wikitext
4234 ::{|
4235 |foo
4236 |bar
4237 |}
4238 this text
4239 should be left alone
4240 !! html
4241 <dl><dd><dl><dd><table>
4242 <tr>
4243 <td>foo
4244 </td>
4245 <td>bar
4246 </td></tr></table></dd></dl></dd></dl>
4247 <p>this text
4248 should be left alone
4249 </p>
4250 !! end
4251
4252 !! test
4253 Definition Lists: Hacky use to indent tables (with content following table)
4254 !! wikitext
4255 :{|
4256 |foo
4257 |bar
4258 |} <!--c1--> this text should be part of the dl
4259 !! html/php+tidy
4260 <dl><dd><table>
4261 <tbody><tr>
4262 <td>foo
4263 </td>
4264 <td>bar
4265 </td></tr></tbody></table> this text should be part of the dl</dd></dl>
4266 !! html/parsoid
4267 <dl><dd><table>
4268 <tbody><tr>
4269 <td>foo
4270 </td>
4271 <td>bar
4272 </td></tr></tbody></table> <!--c1--> this text should be part of the dl</dd></dl>
4273 !! end
4274
4275 !! test
4276 Definition Lists: Hacky use to indent tables, with comments (T65979)
4277 !! wikitext
4278 <!-- foo -->
4279 ::{|
4280 |foo
4281 |bar
4282 |}<!-- bar -->
4283 this text
4284 should be left alone
4285 !! html/parsoid
4286 <!-- foo -->
4287 <dl><dd><dl><dd><table><tr>
4288 <td>foo</td>
4289 <td>bar</td>
4290 </tr></table><!-- bar --></dd></dl></dd></dl>
4291 <p>this text
4292 should be left alone</p>
4293 !! end
4294
4295 !! test
4296 Definition Lists: Hacky use to indent tables, with comment before table
4297 !!options
4298 parsoid=wt2html
4299 !! wikitext
4300 ::<!-- foo -->{|
4301 |foo
4302 |}
4303 !! html/parsoid
4304 <dl><dd><dl><dd><!-- foo --><table><tr>
4305 <td>foo</td>
4306 </tr></table></dd></dl></dd></dl>
4307 !! end
4308
4309 # The trailing whitespace in this test is to catch a regression in
4310 # Parsoid after T54473.
4311 !! test
4312 Definition Lists: Hacky use to indent tables (WS-insensitive)
4313 !! wikitext
4314 :{|
4315 |a
4316 |}
4317 !! html/php
4318 <dl><dd><table>
4319 <tr>
4320 <td>a
4321 </td></tr></table></dd></dl>
4322
4323 !! html/parsoid
4324 <dl><dd><table>
4325 <tbody><tr><td>a</td></tr>
4326 </tbody></table></dd></dl>
4327 !! end
4328
4329 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
4330 ## as an empty dt item. It also ignores all but the last ";" when followed
4331 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
4332 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
4333 ## ";"s.
4334 ##
4335 ## Ex: ";;t2 ::d2" is transformed into:
4336 ##
4337 ## <dl>
4338 ## <dt>t2 </dt>
4339 ## <dd>
4340 ## <dl>
4341 ## <dt></dt>
4342 ## <dd>d2</dd>
4343 ## </dl>
4344 ## </dd>
4345 ## </dl>
4346 ##
4347 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
4348 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
4349 ##
4350 ## <dl>
4351 ## <dt>
4352 ## <dl>
4353 ## <dt>t2 </dt>
4354 ## <dd>:d2</dd>
4355 ## </dl>
4356 ## </dt>
4357 ## </dl>
4358 ##
4359 ## All Parsoid only definition list tests have this difference.
4360 ##
4361 ## See also: https://phabricator.wikimedia.org/T8569
4362 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4363
4364 !! test
4365 Table / list interaction: indented table with lists in table contents
4366 !! wikitext
4367 :{|
4368 |-
4369 |a
4370
4371 *b
4372 |-
4373 |c
4374
4375 *d
4376 |}
4377 !! html
4378 <dl><dd><table>
4379
4380 <tr>
4381 <td>a
4382 <ul><li>b</li></ul>
4383 </td></tr>
4384 <tr>
4385 <td>c
4386 <ul><li>d</li></ul>
4387 </td></tr></table></dd></dl>
4388
4389 !! end
4390
4391 !!test
4392 Table / list interaction: lists nested in tables nested in indented lists
4393 !! wikitext
4394 :{|
4395 |
4396 :a
4397 :b
4398 |
4399 *c
4400 *d
4401 |}
4402
4403 *e
4404 *f
4405 !! html
4406 <dl><dd><table>
4407 <tr>
4408 <td>
4409 <dl><dd>a</dd>
4410 <dd>b</dd></dl>
4411 </td>
4412 <td>
4413 <ul><li>c</li>
4414 <li>d</li></ul>
4415 </td></tr></table></dd></dl>
4416 <ul><li>e</li>
4417 <li>f</li></ul>
4418
4419 !!end
4420
4421 !! test
4422 Definition Lists: Nesting: Multi-level (Parsoid only)
4423 !! wikitext
4424 ;t1 :d1
4425 ;;t2 ::d2
4426 ;;;t3 :::d3
4427 !! html/parsoid
4428 <dl>
4429 <dt>t1 </dt>
4430 <dd>d1</dd>
4431 <dt>
4432 <dl>
4433 <dt>t2 </dt>
4434 <dd>:d2</dd>
4435 <dt>
4436 <dl>
4437 <dt>t3 </dt>
4438 <dd>::d3</dd>
4439 </dl>
4440 </dt>
4441 </dl>
4442 </dt>
4443 </dl>
4444
4445
4446 !! end
4447
4448
4449 !! test
4450 Definition Lists: Nesting: Test 2
4451 !! wikitext
4452 ;t1
4453 ::d2
4454 !! html+tidy
4455 <dl><dt>t1</dt>
4456 <dd>
4457 <dl><dd>d2</dd></dl></dd></dl>
4458 !! end
4459
4460
4461 !! test
4462 Definition Lists: Nesting: Test 3
4463 !! wikitext
4464 :;t1
4465 ::::d2
4466 !! html+tidy
4467 <dl><dd><dl><dt>t1</dt>
4468 <dd>
4469 <dl><dd><dl><dd>d2</dd></dl></dd></dl></dd></dl></dd></dl>
4470 !! end
4471
4472
4473 !! test
4474 Definition Lists: Nesting: Test 4
4475 !! wikitext
4476 ::;t3
4477 :::d3
4478 !! html
4479 <dl><dd><dl><dd><dl><dt>t3</dt>
4480 <dd>d3</dd></dl></dd></dl></dd></dl>
4481
4482 !! end
4483
4484
4485 ## The Parsoid team believes the following three test exposes a
4486 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4487 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4488 ## It also exposes a "misfeature" in tidy, which doesn't like
4489 ## <dl> tags with a single <dt> child; it converts the <dt> into
4490 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4491 !! test
4492 Definition Lists: Mixed Lists: Test 1
4493 !! wikitext
4494 :;*foo
4495 ::*bar
4496 :;baz
4497 !! html/php
4498 <dl><dd><dl><dt><ul><li>foo</li>
4499 <li>bar</li></ul></dt></dl>
4500 <dl><dt>baz</dt></dl></dd></dl>
4501
4502 !! html/php+tidy
4503 <dl><dd><dl><dt><ul><li>foo</li>
4504 <li>bar</li></ul></dt></dl>
4505 <dl><dt>baz</dt></dl></dd></dl>
4506 !! html/parsoid
4507 <dl>
4508 <dd><dl>
4509 <dt><ul>
4510 <li>foo
4511 </li>
4512 </ul></dt>
4513 <dd><ul>
4514 <li>bar
4515 </li>
4516 </ul></dd>
4517 <dt>baz</dt>
4518 </dl></dd>
4519 </dl>
4520 !! end
4521
4522 !! test
4523 Definition Lists: Mixed Lists: Test 2
4524 !! wikitext
4525 *:d1
4526 *:d2
4527 !! html
4528 <ul><li><dl><dd>d1</dd>
4529 <dd>d2</dd></dl></li></ul>
4530
4531 !! end
4532
4533
4534 !! test
4535 Definition Lists: Mixed Lists: Test 3
4536 !! wikitext
4537 *:::d1
4538 *:::d2
4539 !! html
4540 <ul><li><dl><dd><dl><dd><dl><dd>d1</dd>
4541 <dd>d2</dd></dl></dd></dl></dd></dl></li></ul>
4542
4543 !! end
4544
4545
4546 !! test
4547 Definition Lists: Mixed Lists: Test 4
4548 !! wikitext
4549 *;d1 :d2
4550 *;d3 :d4
4551 !! html
4552 <ul><li><dl><dt>d1</dt>
4553 <dd>d2</dd>
4554 <dt>d3</dt>
4555 <dd>d4</dd></dl></li></ul>
4556
4557 !! end
4558
4559
4560 !! test
4561 Definition Lists: Mixed Lists: Test 5
4562 !! wikitext
4563 *:d1
4564 *::d2
4565 !! html
4566 <ul><li><dl><dd>d1
4567 <dl><dd>d2</dd></dl></dd></dl></li></ul>
4568
4569 !! end
4570
4571
4572 !! test
4573 Definition Lists: Mixed Lists: Test 6
4574 !! wikitext
4575 #*:d1
4576 #*:::d3
4577 !! html
4578 <ol><li><ul><li><dl><dd>d1
4579 <dl><dd><dl><dd>d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4580
4581 !! end
4582
4583
4584 !! test
4585 Definition Lists: Mixed Lists: Test 7
4586 !! wikitext
4587 :*d1
4588 :*d2
4589 !! html
4590 <dl><dd><ul><li>d1</li>
4591 <li>d2</li></ul></dd></dl>
4592
4593 !! end
4594
4595
4596 !! test
4597 Definition Lists: Mixed Lists: Test 8
4598 !! wikitext
4599 :*d1
4600 ::*d2
4601 !! html
4602 <dl><dd><ul><li>d1</li></ul>
4603 <dl><dd><ul><li>d2</li></ul></dd></dl></dd></dl>
4604
4605 !! end
4606
4607
4608 !! test
4609 Definition Lists: Mixed Lists: Test 9
4610 !! wikitext
4611 *;foo :bar
4612 !! html
4613 <ul><li><dl><dt>foo</dt>
4614 <dd>bar</dd></dl></li></ul>
4615
4616 !! end
4617
4618
4619 !! test
4620 Definition Lists: Mixed Lists: Test 10
4621 !! wikitext
4622 *#;foo :bar
4623 !! html
4624 <ul><li><ol><li><dl><dt>foo</dt>
4625 <dd>bar</dd></dl></li></ol></li></ul>
4626
4627 !! end
4628
4629 # The Parsoid team disagrees with the PHP parser's seemingly-random
4630 # rules regarding dd/dt on the next few tests. Parsoid is more
4631 # consistent, and recognizes the shared nesting and keeps the
4632 # still-open tags around until the nesting is complete.
4633
4634 # This is a regression test for T175099
4635 !! test
4636 Definition Lists: Mixed Lists: Test 11
4637 !! wikitext
4638 ;a
4639 :*b
4640 !! html/php
4641 <dl><dt>a</dt>
4642 <dd>
4643 <ul><li>b</li></ul></dd></dl>
4644
4645 !! html/parsoid
4646 <dl><dt>a
4647 <dd><ul><li>b</li></ul></dd></dl>
4648 !! end
4649
4650 # FIXME: Maybe get rid of this test?
4651 !! test
4652 Definition Lists: Mixed Lists: Test 12
4653 !! wikitext
4654 *#*#;*;;foo :bar
4655 *#*#;boo :baz
4656 !! html/php
4657 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo</dt>
4658 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4659 <dl><dt>boo</dt>
4660 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4661
4662 !! html/php+tidy
4663 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo</dt>
4664 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4665 <dl><dt>boo</dt>
4666 <dd>baz</dd></dl></li></ol></li></ul>
4667 !! html/parsoid
4668 <ul>
4669 <li>
4670 <ol>
4671 <li>
4672 <ul>
4673 <li>
4674 <ol>
4675 <li>
4676 <dl>
4677 <dt>
4678 <ul>
4679 <li>
4680 <dl>
4681 <dt>
4682 <dl>
4683 <dt>foo</dt>
4684 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4685 </dl></dt>
4686 </dl></li>
4687 </ul></dt>
4688 <dt>boo</dt>
4689 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4690 </dl></li>
4691 </ol></li>
4692 </ul></li>
4693 </ol></li>
4694 </ul>
4695 !! end
4696
4697 !! test
4698 Definition Lists: Mixed Lists: Test 13
4699 !! wikitext
4700 *#*#;*;;foo : bar
4701 *#*#;boo : baz
4702 !! html+tidy
4703 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4704 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4705 <dl><dt>boo&#160;</dt>
4706 <dd>baz</dd></dl></li></ol></li></ul>
4707 !! end
4708
4709 # FIXME: Maybe get rid of this test?
4710 # From whitelist:
4711 # * The test is wrong, there are two colons where there should be :;
4712 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4713 !! test
4714 Definition Lists: Weird Ones: Test 1
4715 !! wikitext
4716 *#;*::;;foo :bar (who uses this?)
4717 !! html/php+tidy
4718 <ul><li><ol><li><dl><dt>foo</dt>
4719 <dd><ul><li><dl><dd><dl><dd><dl><dt><dl><dt>bar (who uses this?)</dt></dl></dt></dl></dd></dl></dd></dl></li></ul></dd></dl></li></ol></li></ul>
4720 !! html/parsoid
4721 <ul>
4722 <li>
4723 <ol>
4724 <li>
4725 <dl>
4726 <dt>
4727 <ul>
4728 <li>
4729 <dl>
4730 <dd>
4731 <dl>
4732 <dd>
4733 <dl>
4734 <dt>
4735 <dl>
4736 <dt>foo</dt>
4737 <dd data-parsoid='{"stx":"row"}'>bar (who uses this?)</dd>
4738 </dl></dt>
4739 </dl></dd>
4740 </dl></dd>
4741 </dl></li>
4742 </ul></dt>
4743 </dl></li>
4744 </ol></li>
4745 </ul>
4746 !! end
4747
4748 !! test
4749 Definition Lists: colons occurring in tags
4750 !! wikitext
4751 ;a:b
4752 ;'''a:b'''
4753 ;<i>a:b</i>
4754 ;<span>a:b</span>
4755 ;<div>a:b</div>
4756 ;<div>a
4757 :b</div>
4758 ;{{echo|a:b}}
4759 ;{{echo|''a:b''}}
4760 ;;;''a:b''
4761 !! html+tidy
4762 <dl><dt>a</dt>
4763 <dd>b</dd>
4764 <dt><b>a:b</b></dt>
4765 <dt><i>a:b</i></dt>
4766 <dt><span>a:b</span></dt>
4767 <dt><div>a:b</div></dt>
4768 <dt><div>a</div></dt>
4769 <dd>b</dd>
4770 <dt>a</dt>
4771 <dd>b</dd>
4772 <dt><i>a:b</i></dt></dl>
4773 <dl><dt><dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4774 !! html/parsoid
4775 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4776 <dt><b>a:b</b></dt>
4777 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4778 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4779 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4780 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4781 <dd>b</dd>
4782 <dt><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a:b"}},"i":0}}]}'>a:b</span></dt>
4783 <dt><i about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&#39;&#39;a:b&#39;&#39;"}},"i":0}}]}'>a:b</i>
4784 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4785 !! end
4786
4787 # Parsoid's output differs here again because it shares
4788 # nesting between the two lists unlike the PHP parser.
4789 # Unsure which is more desirable.
4790 !! test
4791 Definition Lists: colons and tables 1
4792 !! wikitext
4793 :{|
4794 |x
4795 |}
4796 :{|
4797 |y
4798 |}
4799 !! html/php
4800 <dl><dd><table>
4801 <tr>
4802 <td>x
4803 </td></tr></table></dd></dl>
4804 <dl><dd><table>
4805 <tr>
4806 <td>y
4807 </td></tr></table></dd></dl>
4808
4809 !! html/parsoid
4810 <dl><dd><table>
4811 <tr>
4812 <td>x
4813 </td></tr></table></dd>
4814 <dd><table>
4815 <tr>
4816 <td>y
4817 </td></tr></table></dd></dl>
4818 !! end
4819
4820 # FIXME: Does this need a html/php section?
4821 !! test
4822 Definition Lists: template interaction
4823 !! wikitext
4824 ::{{definition_list}}
4825
4826 :one
4827 ::{{definition_list}}
4828 :::two
4829 :::three
4830 ::four
4831 !! html/parsoid
4832 <dl><dd><dl data-parsoid='{}'><dd about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[":",{"template":{"target":{"wt":"definition_list","href":"./Template:Definition_list"},"params":{},"i":0}}]}'>one</dd><span about="#mwt1">
4833 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4834
4835 <dl><dd data-parsoid='{}'>one
4836 <dl><dd about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":["::",{"template":{"target":{"wt":"definition_list","href":"./Template:Definition_list"},"params":{},"i":0}},"\n:::two\n:::three"]}'>one</dd><span about="#mwt2">
4837 </span><dd about="#mwt2">two
4838 <dl><dd>two</dd>
4839 <dd>three</dd></dl></dd>
4840 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4841 !! end
4842
4843
4844 ###
4845 ### External links
4846 ###
4847 !! test
4848 External links: non-bracketed
4849 !! wikitext
4850 Non-bracketed: http://example.com
4851 !! html
4852 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4853 </p>
4854 !! end
4855
4856 # parsoid doesn't explicitly mark autonumbered links, see T55505
4857 !! test
4858 External links: numbered
4859 !! wikitext
4860 Numbered: [http://example.com]
4861 Numbered: [http://example.net]
4862 Numbered: [http://example.com]
4863 !! html/php
4864 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4865 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4866 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4867 </p>
4868 !! html/parsoid
4869 <p>Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>
4870 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.net"></a>
4871 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a></p>
4872 !!end
4873
4874 !! test
4875 External links: specified text
4876 !! wikitext
4877 Specified text: [http://example.com link]
4878 !! html
4879 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4880 </p>
4881 !!end
4882
4883 !! test
4884 External links: trail
4885 !! wikitext
4886 Linktrails should not work for external links: [http://example.com link]s
4887 !! html
4888 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4889 </p>
4890 !! end
4891
4892 !! test
4893 External links: dollar sign in URL
4894 !! wikitext
4895 http://example.com/1$2345
4896 !! html
4897 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4898 </p>
4899 !! end
4900
4901 # parsoid doesn't explicitly mark autonumbered links, see T55505
4902 !! test
4903 External links: dollar sign in URL (autonumber)
4904 !! wikitext
4905 [http://example.com/1$2345]
4906 !! html/php
4907 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4908 </p>
4909 !! html/parsoid
4910 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/1$2345"></a></p>
4911 !!end
4912
4913 !! test
4914 External links: open square bracket forbidden in URL (T6377)
4915 !! options
4916 parsoid=wt2html,wt2wt,html2html
4917 !! wikitext
4918 http://example.com/1[2345
4919 !! html/php
4920 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4921 </p>
4922 !! html/parsoid
4923 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/1">http://example.com/1</a>[2345</p>
4924 !! end
4925
4926 !! test
4927 External links: open square bracket forbidden in URL (named) (T6377)
4928 !! options
4929 parsoid=wt2html,html2html
4930 !! wikitext
4931 [http://example.com/1[2345]
4932 !! html/php
4933 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4934 </p>
4935 !! html/parsoid
4936 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/1">[2345</a></p>
4937 !!end
4938
4939 # parsoid adds a space before the link name
4940 !! test
4941 External links: open square bracket forbidden in URL (named) (T6377)
4942 Parsoid variant.
4943 !! wikitext
4944 [http://example.com/1 [2345]
4945 !! html
4946 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4947 </p>
4948 !!end
4949
4950 !! test
4951 External links: nowiki in URL link text (T8230)
4952 !! wikitext
4953 [http://example.com/ <nowiki>''example site''</nowiki>]
4954 !! html
4955 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4956 </p>
4957 !! end
4958
4959 !! test
4960 External links: newline forbidden in text (T8230 regression check)
4961 !! wikitext
4962 [http://example.com/ first
4963 second]
4964 !! html
4965 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4966 second]
4967 </p>
4968 !!end
4969
4970 !! test
4971 External links: Pipe char between url and text
4972 !! wikitext
4973 [http://example.com | link]
4974 !! html
4975 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4976 </p>
4977 !!end
4978
4979 !! test
4980 External links: protocol-relative URL in brackets
4981 !! wikitext
4982 [//example.com/ Test]
4983 !! html
4984 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4985 </p>
4986 !! end
4987
4988 # parsoid doesn't explicitly mark autonumbered links, see T55505
4989 !! test
4990 External links: protocol-relative URL in brackets without text
4991 !! wikitext
4992 [//example.com]
4993 !! html/php
4994 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
4995 </p>
4996 !! html/parsoid
4997 <p><a rel="mw:ExtLink" class="external autonumber" href="//example.com"></a></p>
4998 !! end
4999
5000 !! test
5001 External links: protocol-relative URL in free text is left alone
5002 !! wikitext
5003 //example.com/Foo
5004 !! html
5005 <p>//example.com/Foo
5006 </p>
5007 !!end
5008
5009 !! test
5010 External links: protocol-relative URL in the middle of a word is left alone (T32269)
5011 !! wikitext
5012 foo//example.com/Foo
5013 !! html
5014 <p>foo//example.com/Foo
5015 </p>
5016 !! end
5017
5018 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
5019 !! test
5020 External links: with no contents
5021 !! options
5022 parsoid=wt2html,wt2wt
5023 !! wikitext
5024 [http://en.wikipedia.org/wiki/Foo]
5025
5026 [[wikipedia:Foo|Bar]]
5027
5028 [[wikipedia:Foo|<span>Bar</span>]]
5029 !! html/php
5030 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
5031 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
5032 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
5033 </p>
5034 !! html/parsoid
5035 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo"></a></p>
5036 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
5037 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
5038 !! end
5039
5040 !! test
5041 External links: Free with trailing punctuation
5042 !! wikitext
5043 http://example.com,
5044 http://example.com;
5045 http://example.com\
5046 http://example.com.
5047 http://example.com:
5048 http://example.com!
5049 http://example.com?
5050 http://example.com)
5051 http://example.com/url_with_(brackets)
5052 (http://example.com/url_without_brackets)
5053 http://example.com/url_with_entity&amp;
5054 http://example.com/url_with_entity&#x26;
5055 http://example.com/url_with_entity&#038;
5056 http://example.com/url_with_entity&nbsp;
5057 http://example.com/url_with_entity&#xA0;
5058 http://example.com/url_with_entity&#160;
5059 http://example.com/url_with_entity&lt;
5060 http://example.com/url_with_entity&#x3C;
5061 http://example.com/url_with_entity&#60;
5062 !! html/php
5063 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
5064 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
5065 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
5066 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
5067 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
5068 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
5069 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
5070 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5071 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5072 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5073 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5074 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5075 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5076 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5077 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
5078 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
5079 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
5080 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
5081 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
5082 </p>
5083 !! html/parsoid
5084 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>,
5085 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>;
5086 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>\
5087 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>.
5088 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>:
5089 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>!
5090 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>?
5091 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)
5092 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
5093 (<a rel="mw:ExtLink" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
5094 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5095 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5096 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
5097 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>
5098 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span>
5099 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span>
5100 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>
5101 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#x3C;","srcContent":"&lt;"}'>&lt;</span>
5102 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#60;","srcContent":"&lt;"}'>&lt;</span></p>
5103 !! end
5104
5105 !! test
5106 External links: tricky Parsoid html2html case
5107 !! options
5108 parsoid=wt2html,wt2wt,html2html
5109 !! wikitext
5110 http://example.com/url_with_entity&amp;amp;
5111 !! html/php
5112 <p><a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;amp">http://example.com/url_with_entity&amp;amp</a>;
5113 </p>
5114 !! html/parsoid
5115 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;amp">http://example.com/url_with_entity&amp;amp</a>;</p>
5116 !! end
5117
5118 !! test
5119 External links: Free with trailing quotes (T113666)
5120 !! wikitext
5121 '''News:''' Stuff here
5122
5123 news:'a'b''c''d e
5124 !! html/php
5125 <p><b>News:</b> Stuff here
5126 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
5127 </p>
5128 !! html/parsoid
5129 <p><b>News:</b> Stuff here</p>
5130 <p><a rel="mw:ExtLink" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
5131 !! end
5132
5133 !! test
5134 External links: with entity
5135 !! wikitext
5136 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
5137 !! html/php
5138 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
5139 </p>
5140 !! html/parsoid
5141 <p><a rel="mw:ExtLink" class="external text" href="http://+www.librarieswithoutborders.org" data-parsoid='{"a":{"href":"http://+www.librarieswithoutborders.org"},"sa":{"href":"http://&amp;#x20;www.librarieswithoutborders.org"}}'>Libraries without borders</a></p>
5142 !! end
5143
5144 !! test
5145 External links: Lone protocols are never linked (T105697)
5146 !! wikitext
5147 http://
5148 http://;
5149 (http://)
5150 bitcoin:
5151 bitcoin:;
5152 (bitcoin:)
5153 !! html
5154 <p>http://
5155 http://;
5156 (http://)
5157 bitcoin:
5158 bitcoin:;
5159 (bitcoin:)
5160 </p>
5161 !! end
5162
5163 !! test
5164 External links: No preceding word characters allowed (T67278)
5165 !! wikitext
5166 NOPEhttp://example.com
5167 N0http://example.com
5168 ok:http://example.com
5169 ok-http://example.com
5170 !! html
5171 <p>NOPEhttp://example.com
5172 N0http://example.com
5173 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5174 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5175 </p>
5176 !! end
5177
5178 !! test
5179 External links: nofollow domain exception
5180 !! wikitext
5181 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
5182 !! html
5183 <p>A <a class="external text" href="https://no-nofollow.org/foobar">link</a>, and another <a rel="nofollow" class="external text" href="https://example.org">link</a>.
5184 </p>
5185 !!end
5186
5187 !! test
5188 External image
5189 !! wikitext
5190 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5191 !! html
5192 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5193 </p>
5194 !! end
5195
5196 !! test
5197 External image from https
5198 !! wikitext
5199 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5200 !! html
5201 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5202 </p>
5203 !! end
5204
5205 !! test
5206 External image (when not allowed)
5207 !! options
5208 wgAllowExternalImages=0
5209 !! wikitext
5210 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5211 !! html
5212 <p>External image: <a rel="nofollow" class="external free" href="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png">http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png</a>
5213 </p>
5214 !! end
5215
5216 !! test
5217 Link to non-http image, no img tag
5218 !! wikitext
5219 Link to non-http image, no img tag: ftp://example.com/test.jpg
5220 !! html
5221 <p>Link to non-http image, no img tag: <a rel="nofollow" class="external free" href="ftp://example.com/test.jpg">ftp://example.com/test.jpg</a>
5222 </p>
5223 !! end
5224
5225 !! test
5226 External links: terminating separator
5227 !! wikitext
5228 Terminating separator: http://example.com/thing,
5229 !! html
5230 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
5231 </p>
5232 !! end
5233
5234 !! test
5235 External links: intervening separator
5236 !! wikitext
5237 Intervening separator: http://example.com/1,2,3
5238 !! html
5239 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
5240 </p>
5241 !! end
5242
5243 !! test
5244 External links: old bug with URL in query
5245 !! wikitext
5246 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
5247 !! html
5248 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
5249 </p>
5250 !! end
5251
5252 !! test
5253 External links: old URL-in-URL bug, mixed protocols
5254 !! wikitext
5255 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
5256 !! html
5257 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
5258 </p>
5259 !!end
5260
5261 # Since Parsoid is starting to emit canonical wikitext for links,
5262 # [http://example.com http://example.com] will not RT back to that
5263 # form anymore.
5264 !! test
5265 External links: URL in text
5266 !! options
5267 parsoid=wt2html
5268 !! wikitext
5269 URL in text: [http://example.com http://example.com]
5270 !! html/php
5271 <p>URL in text: <a rel="nofollow" class="external text" href="http://example.com">http://example.com</a>
5272 </p>
5273 !! html/parsoid
5274 <p>URL in text: <a rel="mw:ExtLink" class="external text" href="http://example.com">http://example.com</a></p>
5275 !! end
5276
5277 !! test
5278 External links: Clickable images
5279 !! wikitext
5280 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5281 !! html/php
5282 <p>ja-style clickable images: <a rel="nofollow" class="external text" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/></a>
5283 </p>
5284 !! html/parsoid
5285 <p>ja-style clickable images: <a rel="mw:ExtLink" class="external text" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" data-parsoid='{"type":"extlink"}'/></a></p>
5286 !! end
5287
5288 !! test
5289 External links: raw ampersand
5290 !! wikitext
5291 Old &amp; use: http://x&y
5292 !! html
5293 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5294 </p>
5295 !! end
5296
5297 !! test
5298 External links: encoded ampersand
5299 !! wikitext
5300 Old &amp; use: http://x&amp;y
5301 !! html/php
5302 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5303 </p>
5304 !! html/parsoid
5305 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external free" href="http://x&amp;y">http://x&amp;y</a></p>
5306 !! end
5307
5308 !! test
5309 External links: encoded equals (T8102)
5310 !! wikitext
5311 http://example.com/?foo&#61;bar
5312 !! html/php
5313 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5314 </p>
5315 !! html/parsoid
5316 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5317 !! end
5318
5319 ##
5320 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5321 ## does it number them. As discussed in T55505, we can identify
5322 ## autonumbered links via CSS.
5323 ##
5324
5325 !! test
5326 External links: [raw ampersand]
5327 !! wikitext
5328 Old &amp; use: [http://x&y]
5329 !! html/php
5330 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5331 </p>
5332 !! html/parsoid
5333 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5334 !! end
5335
5336 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5337 # mode will return the [raw ampersand] wikitext
5338 !! test
5339 External links: [encoded ampersand]
5340 !! options
5341 parsoid=wt2html,wt2wt,html2html
5342 !! wikitext
5343 Old &amp; use: [http://x&amp;y]
5344 !! html/php
5345 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5346 </p>
5347 !! html/parsoid
5348 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5349 !! end
5350
5351 !! test
5352 External links: [raw equals]
5353 !! wikitext
5354 [http://example.com/?foo=bar]
5355 !! html/php
5356 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5357 </p>
5358 !! html/parsoid
5359 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5360 !! end
5361
5362 # note that parsoid html is identical to [raw equals] case; so html2wt
5363 # mode will return the [raw equals] wikitext
5364 !! test
5365 External links: [encoded equals] (T8102)
5366 !! options
5367 parsoid=wt2html,wt2wt,html2html
5368 !! wikitext
5369 [http://example.com/?foo&#61;bar]
5370 !! html/php
5371 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5372 </p>
5373 !! html/parsoid
5374 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/?foo=bar"></a></p>
5375 !! end
5376
5377 # xxx parsoid strips the IDN character, so the round-trip tests will
5378 # obviously fail and are disabled. --cscott
5379 !! test
5380 External links: [IDN ignored character reference in hostname; strip it right off]
5381 !! options
5382 parsoid=wt2html,wt2wt,html2html
5383 !! wikitext
5384 [http://e&zwnj;xample.com/]
5385 !! html/php
5386 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5387 </p>
5388 !! html/parsoid
5389 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/"></a></p>
5390 !! end
5391
5392 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5393 # Where an external link could easily circumvent the sanitization of the text of
5394 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5395 # test demands a higher standard. That's a bit strange.
5396 #
5397 # Example:
5398 #
5399 # http://e‌xample.com -> [http://example.com|http://example.com]
5400 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5401 #
5402 # The first example is sanitized, but the second is not. Any security benefits
5403 # from this production are trivial to circumvent. Either remove this test and
5404 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5405 # the test accordingly.
5406 #
5407 # All our love,
5408 # The Parsoid team.
5409 # xxx parsoid strips the IDN character, so the round-trip tests will
5410 # obviously fail and are disabled. --cscott
5411 !! test
5412 External links: IDN ignored character reference in hostname; strip it right off
5413 !! options
5414 parsoid=wt2html,html2html
5415 !! wikitext
5416 http://e&zwnj;xample.com/
5417 !! html/php
5418 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5419 </p>
5420 !! html/parsoid
5421 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/">http://example.com/</a></p>
5422 !! end
5423
5424 !! test
5425 External links: www.jpeg.org (T2554)
5426 !! wikitext
5427 http://www.jpeg.org
5428 !! html
5429 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5430 </p>
5431 !! end
5432
5433 # parsoid doesn't explicitly mark autonumbered links, see T55505
5434 !! test
5435 External links: URL within URL (T2002)
5436 !! wikitext
5437 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5438 !! html/php
5439 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5440 </p>
5441 !! html/parsoid
5442 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp"></a></p>
5443 !! end
5444
5445 !! test
5446 T2361: URL inside bracketed URL
5447 !! wikitext
5448 [http://www.example.com/foo http://www.example.com/bar]
5449 !! html
5450 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5451 </p>
5452 !! end
5453
5454 !! test
5455 T2361: URL within URL, not bracketed
5456 !! wikitext
5457 http://www.example.com/foo?=http://www.example.com/bar
5458 !! html
5459 <p><a rel="nofollow" class="external free" href="http://www.example.com/foo?=http://www.example.com/bar">http://www.example.com/foo?=http://www.example.com/bar</a>
5460 </p>
5461 !! end
5462
5463 !! test
5464 T2289: ">"-token in URL-tail
5465 !! wikitext
5466 http://www.example.com/<hello>
5467 !! html
5468 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5469 </p>
5470 !!end
5471
5472 !! test
5473 T2289: literal ">"-token in URL-tail
5474 !! wikitext
5475 http://www.example.com/<b>html</b>
5476 !! html/php
5477 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5478 </p>
5479 !! html/parsoid
5480 <p><a rel="mw:ExtLink" class="external free" href="http://www.example.com/" data-parsoid='{"stx":"url"}'>http://www.example.com/</a><b data-parsoid='{"stx":"html"}'>html</b></p>
5481 !! end
5482
5483 !! test
5484 T2289: ">"-token in bracketed URL
5485 !! wikitext
5486 [http://www.example.com/<hello> stuff]
5487 !! html
5488 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5489 </p>
5490 !!end
5491
5492 !! test
5493 T2289: literal ">"-token in bracketed URL
5494 !! wikitext
5495 [http://www.example.com/<b>html</b> stuff]
5496 !! html
5497 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5498 </p>
5499 !!end
5500
5501 !! test
5502 T2289: literal double quote at end of URL
5503 !! wikitext
5504 http://www.example.com/"hello"
5505 !! html
5506 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5507 </p>
5508 !!end
5509
5510 !! test
5511 T2289: literal double quote in bracketed URL
5512 !! wikitext
5513 [http://www.example.com/"hello" stuff]
5514 !! html
5515 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5516 </p>
5517 !!end
5518
5519 !! test
5520 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5521 !! wikitext
5522 [http://www.example.com test]
5523 !! html
5524 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5525 </p>
5526 !! end
5527
5528 !! test
5529 External links: link text with spaces
5530 !! wikitext
5531 [http://www.example.com a b c]
5532 [http://www.example.com ''a'' ''b'']
5533 !! html
5534 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5535 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5536 </p>
5537 !! end
5538
5539 # Note edge case difference between PHP and Parsoid here.
5540 !! test
5541 External links: wiki links within external link (T5695)
5542 !! options
5543 parsoid=wt2html,html2html
5544 !! wikitext
5545 [http://example.com [[wikilink]] embedded in ext link]
5546
5547 [http://example.com test [[wikilink]] embedded in ext link]
5548 !! html/php
5549 <p><a rel="nofollow" class="external text" href="http://example.com"></a><a href="/index.php?title=Wikilink&amp;action=edit&amp;redlink=1" class="new" title="Wikilink (page does not exist)">wikilink</a><a rel="nofollow" class="external text" href="http://example.com"> embedded in ext link</a>
5550 </p><p><a rel="nofollow" class="external text" href="http://example.com">test </a><a href="/index.php?title=Wikilink&amp;action=edit&amp;redlink=1" class="new" title="Wikilink (page does not exist)">wikilink</a><a rel="nofollow" class="external text" href="http://example.com"> embedded in ext link</a>
5551 </p>
5552 !! html/parsoid
5553 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a><a rel="mw:WikiLink" href="./Wikilink" title="Wikilink">wikilink</a><span> embedded in ext link</span></p>
5554 <p><a rel="mw:ExtLink" class="external text" href="http://example.com">test </a><a rel="mw:WikiLink" href="./Wikilink" title="Wikilink">wikilink</a><span> embedded in ext link</span></p>
5555 !! end
5556
5557 !! test
5558 T2787: Links with one slash after the url protocol are invalid
5559 !! wikitext
5560 http:/example.com
5561
5562 [http:/example.com title]
5563 !! html
5564 <p>http:/example.com
5565 </p><p>[http:/example.com title]
5566 </p>
5567 !! end
5568
5569 !! test
5570 Bracketed external links with template-generated invalid target
5571 !! wikitext
5572 [{{echo|http:/example.com}} title]
5573 !! html
5574 <p>[http:/example.com title]
5575 </p>
5576 !! end
5577
5578 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5579 !! test
5580 Broken wikilinks (but not external links) prevent templates from closing
5581 !! options
5582 parsoid=wt2html
5583 !! wikitext
5584 [http://example.com x
5585
5586 {{echo|[http://example.com x}}
5587
5588 [[Foo
5589
5590 {{echo|[[Foo}}
5591 !! html/php
5592 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5593 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5594 </p><p>[[Foo
5595 </p><p>{{echo|[[Foo}}
5596 </p>
5597 !! html/parsoid
5598 <p>[<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> x</p>
5599 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[http://example.com x"}},"i":0}}]}'>[<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a> x</p>
5600 <p>[[Foo</p>
5601 <p>{{echo|[[Foo}}</p>
5602 !! end
5603
5604 !! test
5605 Wikilinks with embedded newlines are not broken
5606 !! wikitext
5607 {{echo|[[ Foo
5608 B
5609 C]]}}
5610 !! html/php
5611 <p>[[ Foo
5612 B
5613 C]]
5614 </p>
5615 !! html/parsoid
5616 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[ Foo\nB\nC]]"}},"i":0}}]}'>[[ Foo B C]]</p>
5617 !! end
5618
5619 !! test
5620 Broken templates
5621 !! options
5622 parsoid=wt2html
5623 !! wikitext
5624 {{echo|[[Foo|}}]]
5625
5626 [[Foo|{{echo|]]}}
5627 !! html/php
5628 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5629 </p><p>[[Foo|]]
5630 </p>
5631 !! html/parsoid
5632 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5633 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5634 !! end
5635
5636 !! test
5637 T4702: Mismatched <i>, <b> and <a> tags are invalid
5638 !! wikitext
5639 ''[http://example.com text'']
5640 [http://example.com '''text]'''
5641 ''Something [http://example.com in italic'']
5642 ''Something [http://example.com mixed''''', even bold]'''
5643 '''''Now [http://example.com both''''']
5644 !! html
5645 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5646 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5647 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5648 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5649 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5650 </p>
5651 !! end
5652
5653
5654 !! test
5655 T6781: %26 in URL
5656 !! wikitext
5657 http://www.example.com/?title=AT%26T
5658 !! html/php
5659 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5660 </p>
5661 !! html/parsoid
5662 <p><a rel="mw:ExtLink" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a></p>
5663 !! end
5664
5665 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5666 # % is actually legal in HTML5. Any change in output would need testing though.
5667 !! test
5668 T6781, T7267: %25 in URL
5669 !! wikitext
5670 http://www.example.com/?title=100%25_Bran
5671 !! html/php
5672 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=100%25_Bran">http://www.example.com/?title=100%25_Bran</a>
5673 </p>
5674 !! html/parsoid
5675 <p><a rel="mw:ExtLink" class="external free" href="http://www.example.com/?title=100%25_Bran">http://www.example.com/?title=100%25_Bran</a></p>
5676 !! end
5677
5678 !! test
5679 T6781, T7267: %28, %29 in URL
5680 !! wikitext
5681 http://www.example.com/?title=Ben-Hur_%281959_film%29
5682 !! html/php
5683 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">http://www.example.com/?title=Ben-Hur_%281959_film%29</a>
5684 </p>
5685 !! html/parsoid
5686 <p><a rel="mw:ExtLink" class="external free" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">http://www.example.com/?title=Ben-Hur_%281959_film%29</a></p>
5687 !! end
5688
5689
5690 !! test
5691 T6781: %26 in autonumber URL
5692 !! wikitext
5693 [http://www.example.com/?title=AT%26T]
5694 !! html/php
5695 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5696 </p>
5697 !! html/parsoid
5698 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=AT%26T"></a></p>
5699 !! end
5700
5701 !! test
5702 T6781, T7267: %26 in autonumber URL
5703 !! wikitext
5704 [http://www.example.com/?title=100%25_Bran]
5705 !! html/php
5706 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5707 </p>
5708 !! html/parsoid
5709 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=100%25_Bran"></a></p>
5710 !! end
5711
5712 !! test
5713 T6781, T7267: %28, %29 in autonumber URL
5714 !! wikitext
5715 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5716 !! html/php
5717 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5718 </p>
5719 !! html/parsoid
5720 <p><a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5721 !! end
5722
5723
5724 !! test
5725 T6781: %26 in bracketed URL
5726 !! wikitext
5727 [http://www.example.com/?title=AT%26T link]
5728 !! html/php
5729 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5730 </p>
5731 !! html/parsoid
5732 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=AT%26T">link</a></p>
5733 !! end
5734
5735 !! test
5736 T6781, T7267: %25 in bracketed URL
5737 !! wikitext
5738 [http://www.example.com/?title=100%25_Bran link]
5739 !! html
5740 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5741 </p>
5742 !! end
5743
5744 !! test
5745 T6781, T7267: %28, %29 in bracketed URL
5746 !! wikitext
5747 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5748 !! html/php
5749 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5750 </p>
5751 !! html/parsoid
5752 <p><a rel="mw:ExtLink" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5753 !! end
5754
5755 !! test
5756 External link containing a period in the anchor. (T65947)
5757 !! wikitext
5758 [//foo.org/bar#baz. bang]
5759
5760 [//foo.org/bar. bang]
5761 !! html/php
5762 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5763 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5764 </p>
5765 !! html/parsoid
5766 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar#baz.">bang</a></p>
5767 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar.">bang</a></p>
5768 !! end
5769
5770 !! test
5771 External link containing a single quote. (T65947)
5772 !! wikitext
5773 [//foo.org/bar'baz]
5774
5775 [//foo.org/bar'baz bang]
5776 !! html/php
5777 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
5778 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
5779 </p>
5780 !! html/parsoid
5781 <p><a rel="mw:ExtLink" class="external autonumber" href="//foo.org/bar'baz"></a></p>
5782 <p><a rel="mw:ExtLink" class="external text" href="//foo.org/bar'baz">bang</a></p>
5783 !! end
5784
5785 !! test
5786 External link containing double-single-quotes in text '' (T6598 sanity check)
5787 !! wikitext
5788 Some [http://example.com/ pretty ''italics'' and stuff]!
5789 !! html
5790 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5791 </p>
5792 !! end
5793
5794 !! test
5795 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5796 !! wikitext
5797 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5798 !! html
5799 <p><i>Some </i><a rel="nofollow" class="external text" href="http://example.com/"><i>pretty </i>italics<i> and stuff</i></a><i>!</i>
5800 </p>
5801 !! end
5802
5803 # Don't add the html/php section since the output is broken and there isn't any reason to spec it
5804 !! test
5805 External link containing double-single-quotes with no space separating the url from text in italics
5806 !! wikitext
5807 [http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm''La muerte de Casagemas'' (1901) en el sitio de [[Museo Picasso (París)|Museo Picasso]].]
5808 !! html/php+tidy
5809 <p><a rel="nofollow" class="external text" href="http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm"><i>La muerte de Casagemas</i> (1901) en el sitio de </a><a href="/index.php?title=Museo_Picasso_(Par%C3%ADs)&amp;action=edit&amp;redlink=1" class="new" title="Museo Picasso (París) (page does not exist)">Museo Picasso</a>.
5810 </p>
5811 !! html/parsoid
5812 <p><a rel="mw:ExtLink" class="external text" href="http://www.musee-picasso.fr/pages/page_id18528_u1l2.htm"><i>La muerte de Casagemas</i> (1901) en el sitio de </a><a rel="mw:WikiLink" href="./Museo_Picasso_(París)" title="Museo Picasso (París)">Museo Picasso</a><span>.</span></p>
5813 !! end
5814
5815 !! test
5816 External link with comments in link text
5817 !! wikitext
5818 [http://www.google.com Google <!-- comment -->]
5819 !! html/php
5820 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5821 </p>
5822 !! html/parsoid
5823 <p><a rel="mw:ExtLink" class="external text" href="http://www.google.com">Google <!-- comment --></a></p>
5824 !! end
5825
5826 !! test
5827 External link to bare IPv4 address
5828 !! wikitext
5829 [http://192.168.0.1 Link]
5830 !! html/php
5831 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5832 </p>
5833 !! html/parsoid
5834 <p><a rel="mw:ExtLink" class="external text" href="http://192.168.0.1">Link</a></p>
5835 !! end
5836
5837 !! test
5838 URL-encoding in URL functions (single parameter)
5839 !! wikitext
5840 {{localurl:Some page|amp=&}}
5841 !! html
5842 <p>/index.php?title=Some_page&amp;amp=&amp;
5843 </p>
5844 !! end
5845
5846 !! test
5847 URL-encoding in URL functions (multiple parameters)
5848 !! wikitext
5849 {{localurl:Some page|q=?&amp=&}}
5850 !! html
5851 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5852 </p>
5853 !! end
5854
5855 !! test
5856 Brackets in urls
5857 !! wikitext
5858 http://example.com/index.php?foozoid%5B%5D=bar
5859
5860 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5861 !! html/php
5862 <p><a rel="nofollow" class="external free" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a>
5863 </p><p><a rel="nofollow" class="external free" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a>
5864 </p>
5865 !! html/parsoid
5866 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a></p>
5867
5868 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/index.php?foozoid%5B%5D=bar" data-parsoid='{"stx":"url","a":{"href":"http://example.com/index.php?foozoid%5B%5D=bar"},"sa":{"href":"http://example.com/index.php?foozoid&amp;#x5B;&amp;#x5D;=bar"}}'>http://example.com/index.php?foozoid%5B%5D=bar</a></p>
5869 !! end
5870
5871 !! test
5872 IPv6 urls, autolink format (T23261)
5873 !! wikitext
5874 http://[2404:130:0:1000::187:2]/index.php
5875
5876 Examples from RFC 2373, section 2.2:
5877
5878 *http://[1080::8:800:200C:417A]/unicast
5879 *http://[FF01::101]/multicast
5880 *http://[::1]/loopback
5881 *http://[::]/unspecified
5882 *http://[::13.1.68.3]/ipv4compat
5883 *http://[::FFFF:129.144.52.38]/ipv4compat
5884
5885 Examples from RFC 2732, section 2:
5886
5887 *http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5888 *http://[1080:0:0:0:8:800:200C:417A]/index.html
5889 *http://[3ffe:2a00:100:7031::1]
5890 *http://[1080::8:800:200C:417A]/foo
5891 *http://[::192.9.5.5]/ipng
5892 *http://[::FFFF:129.144.52.38]:80/index.html
5893 *http://[2010:836B:4179::836B:4179]
5894 !! html/php
5895 <p><a rel="nofollow" class="external free" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a>
5896 </p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
5897 </p>
5898 <ul><li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
5899 <li><a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5900 <li><a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5901 <li><a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5902 <li><a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5903 <li><a rel="nofollow" class="external free" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
5904 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5905 </p>
5906 <ul><li><a rel="nofollow" class="external free" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a></li>
5907 <li><a rel="nofollow" class="external free" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">http://[1080:0:0:0:8:800:200C:417A]/index.html</a></li>
5908 <li><a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5909 <li><a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5910 <li><a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5911 <li><a rel="nofollow" class="external free" href="http://[::FFFF:129.144.52.38]:80/index.html">http://[::FFFF:129.144.52.38]:80/index.html</a></li>
5912 <li><a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5913
5914 !! html/parsoid
5915 <p><a rel="mw:ExtLink" class="external free" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a></p>
5916
5917 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink" class="external mw-magiclink">RFC 2373</a>, section 2.2:</p>
5918 <ul><li><a rel="mw:ExtLink" class="external free" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
5919 <li><a rel="mw:ExtLink" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5920 <li><a rel="mw:ExtLink" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5921 <li><a rel="mw:ExtLink" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5922 <li><a rel="mw:ExtLink" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5923 <li><a rel="mw:ExtLink" class="external free" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
5924
5925 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
5926 <ul><li><a rel="mw:ExtLink" class="external free" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html</a></li>
5927 <li><a rel="mw:ExtLink" class="external free" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">http://[1080:0:0:0:8:800:200C:417A]/index.html</a></li>
5928 <li><a rel="mw:ExtLink" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5929 <li><a rel="mw:ExtLink" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5930 <li><a rel="mw:ExtLink" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5931 <li><a rel="mw:ExtLink" class="external free" href="http://[::FFFF:129.144.52.38]:80/index.html">http://[::FFFF:129.144.52.38]:80/index.html</a></li>
5932 <li><a rel="mw:ExtLink" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5933 !! end
5934
5935 !! test
5936 IPv6 urls, bracketed format (T23261)
5937 !! wikitext
5938 [http://[2404:130:0:1000::187:2]/index.php test]
5939
5940 Examples from RFC 2373, section 2.2:
5941
5942 *[http://[1080::8:800:200C:417A] unicast]
5943 *[http://[FF01::101] multicast]
5944 *[http://[::1]/ loopback]
5945 *[http://[::] unspecified]
5946 *[http://[::13.1.68.3] ipv4compat]
5947 *[http://[::FFFF:129.144.52.38] ipv4compat]
5948
5949 Examples from RFC 2732, section 2:
5950
5951 *[http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5952 *[http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5953 *[http://[3ffe:2a00:100:7031::1] 3]
5954 *[http://[1080::8:800:200C:417A]/foo 4]
5955 *[http://[::192.9.5.5]/ipng 5]
5956 *[http://[::FFFF:129.144.52.38]:80/index.html 6]
5957 *[http://[2010:836B:4179::836B:4179] 7]
5958 !! html/php
5959 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5960 </p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
5961 </p>
5962 <ul><li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5963 <li><a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5964 <li><a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5965 <li><a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5966 <li><a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5967 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5968 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5969 </p>
5970 <ul><li><a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5971 <li><a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5972 <li><a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5973 <li><a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5974 <li><a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5975 <li><a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5976 <li><a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5977
5978 !! html/parsoid
5979 <p><a rel="mw:ExtLink" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5980
5981 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink" class="external mw-magiclink">RFC 2373</a>, section 2.2:</p>
5982 <ul><li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5983 <li><a rel="mw:ExtLink" class="external text" href="http://[FF01::101]">multicast</a></li>
5984 <li><a rel="mw:ExtLink" class="external text" href="http://[::1]/">loopback</a></li>
5985 <li><a rel="mw:ExtLink" class="external text" href="http://[::]">unspecified</a></li>
5986 <li><a rel="mw:ExtLink" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5987 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5988
5989 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink" class="external mw-magiclink">RFC 2732</a>, section 2:</p>
5990 <ul><li><a rel="mw:ExtLink" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5991 <li><a rel="mw:ExtLink" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5992 <li><a rel="mw:ExtLink" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5993 <li><a rel="mw:ExtLink" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5994 <li><a rel="mw:ExtLink" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5995 <li><a rel="mw:ExtLink" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5996 <li><a rel="mw:ExtLink" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5997 !! end
5998
5999 !! test
6000 Non-extlinks in brackets
6001 !! wikitext
6002 [foo]
6003 [foo bar]
6004 [foo ''bar'']
6005 [fool's] errand
6006 [fool's errand]
6007 [{{echo|foo}}]
6008 [{{echo|foo}} bar]
6009 [{{echo|foo}} ''bar'']
6010 [{{echo|foo}}l's] errand
6011 [{{echo|foo}}l's errand]
6012 [url={{echo|foo}}]
6013 [url=http://example.com]
6014 [http:// bare protocols don't count]
6015 !! html/php
6016 <p>[foo]
6017 [foo bar]
6018 [foo <i>bar</i>]
6019 [fool's] errand
6020 [fool's errand]
6021 [foo]
6022 [foo bar]
6023 [foo <i>bar</i>]
6024 [fool's] errand
6025 [fool's errand]
6026 [url=foo]
6027 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
6028 [http:// bare protocols don't count]
6029 </p>
6030 !! html/parsoid
6031 <p>[foo]
6032 [foo bar]
6033 [foo <i>bar</i>]
6034 [fool's] errand
6035 [fool's errand]
6036 [<span about="#mwt19" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
6037 [<span about="#mwt20" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span> bar]
6038 [<span about="#mwt21" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span> <i>bar</i>]
6039 [<span about="#mwt22" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>l's] errand
6040 [<span about="#mwt23" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>l's errand]
6041 [url=<span about="#mwt24" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>]
6042 [url=<a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>]
6043 [http:// bare protocols don't count]</p>
6044 !! end
6045
6046 !! test
6047 Percent encoding in external links
6048 !! wikitext
6049 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
6050 !! html/php
6051 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
6052 </p>
6053 !! html/parsoid
6054 <p><a rel="mw:ExtLink" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
6055 !! end
6056
6057 !! test
6058 Use url link syntax for links where the content is equal the link target
6059 !! wikitext
6060 http://example.com
6061 !! html/php
6062 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
6063 </p>
6064 !! html/parsoid
6065 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
6066 !! end
6067
6068 !! test
6069 Parenthesis in external links, especially URL links
6070 !! wikitext
6071 http://example.com)
6072
6073 http://example.com/test)
6074
6075 http://example.com/(test)
6076
6077 http://example.com/((test)
6078
6079 (http://example.com/(test))
6080
6081 (http://example.com/(test)))))
6082
6083 http://example.com/a)b
6084
6085 [http://example.com) foo]
6086 !! html/php
6087 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6088 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
6089 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
6090 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
6091 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
6092 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
6093 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
6094 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
6095 </p>
6096 !! html/parsoid
6097 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)</p>
6098 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/test">http://example.com/test</a>)</p>
6099 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/(test)">http://example.com/(test)</a></p>
6100 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/((test)">http://example.com/((test)</a></p>
6101 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test))">http://example.com/(test))</a></p>
6102 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
6103 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/a)b">http://example.com/a)b</a></p>
6104 <p><a rel="mw:ExtLink" class="external text" href="http://example.com)">foo</a></p>
6105 !! end
6106
6107 !! test
6108 Parenthesis in external links, w/ transclusion or comment
6109 !! wikitext
6110 (http://example.com/{{echo|hi}})
6111
6112 (http://example.com<!-- hi -->)
6113 !! html/php
6114 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
6115 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
6116 </p>
6117 !! html/parsoid
6118 <p>(<a typeof="mw:ExpandedAttrs" about="#mwt2" rel="mw:ExtLink" class="external free" href="http://example.com/hi" data-parsoid='{"stx":"url","a":{"href":"http://example.com/hi"},"sa":{"href":"http://example.com/{{echo|hi}}"}}' data-mw='{"attribs":[[{"txt":"href"},{"html":"http://example.com/&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[{\"k\":\"1\"}]],\"dsr\":[20,31,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"hi\"}},\"i\":0}}]}&#39;>hi&lt;/span>"}]]}'>http://example.com/hi</a>)</p>
6119
6120 <p>(<a rel="mw:ExtLink" class="external free" href="http://example.com" data-parsoid='{"stx":"url","a":{"href":"http://example.com"},"sa":{"href":"http://example.com&lt;!-- hi -->"}}'>http://example.com</a>)</p>
6121 !! end
6122
6123 !! test
6124 Serialize <a> tags with invalid link targets as plain text
6125 !! options
6126 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
6127 !! html/parsoid
6128 <a rel="mw:WikiLink" href="[[foo]]">text</a>
6129 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
6130 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
6131 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
6132 !! wikitext
6133 text
6134 <nowiki>*</nowiki>text
6135 <nowiki>[[foo]]</nowiki>
6136 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
6137 !! end
6138
6139 !! test
6140 mw:ExtLink -vs- mw:WikiLink (T94723)
6141 !! options
6142 parsoid=html2wt
6143 !! html/parsoid
6144 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
6145 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
6146 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6147 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
6148 <p>
6149 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6150 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
6151 </p>
6152 !! wikitext
6153 [[Foo|Bar]]
6154 [[Foo|Bar]]
6155 [[:en:Foo|Bar]]
6156 [[:en:Foo|Bar]]
6157
6158 [[:en:European_Robin|European Robin]]
6159 [[:en:European_Robin|European Robin]]
6160 !! end
6161
6162 !! test
6163 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
6164 !! options
6165 parsoid=wt2wt
6166 !! wikitext
6167 [http://en.wikipedia.org/wiki/European_Robin European Robin]
6168 !! html/parsoid
6169 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
6170 !! end
6171
6172
6173 ###
6174 ### Quotes
6175 ###
6176
6177 !! test
6178 Quotes
6179 !! wikitext
6180 Normal text. '''Bold text.''' Normal text. ''Italic text.''
6181
6182 Normal text. '''''Bold italic text.''''' Normal text.
6183 !! html
6184 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
6185 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
6186 </p>
6187 !! end
6188
6189 !! test
6190 Quotes wrapping HTML table
6191 !! wikitext
6192 '''<table><tr><td>hi</td></tr></table>'''
6193 !! html/php+tidy
6194 <b><table><tbody><tr><td>hi</td></tr></tbody></table></b>
6195 !! html/parsoid
6196 <b><table data-parsoid='{"stx":"html"}'><tbody><tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>hi</td></tr></tbody></table></b>
6197 !! end
6198
6199 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
6200 # parser strips. The wikitext contains just the first half of the bold
6201 # quote pair.
6202 !! test
6203 Unclosed and unmatched quotes
6204 !! wikitext
6205 '''''Bold italic text '''with bold deactivated''' in between.'''''
6206
6207 '''''Bold italic text ''with italic deactivated'' in between.'''''
6208
6209 '''Bold text..
6210
6211 ..spanning two paragraphs (should not work).'''
6212
6213 '''Bold tag left open
6214
6215 ''Italic tag left open
6216
6217 Normal text.
6218
6219 <!-- Unmatching number of opening, closing tags: -->
6220 '''This year''''s election ''should'' beat '''last year''''s.
6221
6222 ''Tom'''s car is bigger than ''Susan'''s.
6223
6224 Plain ''italic'''s plain
6225 !! html/php
6226 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6227 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6228 </p><p><b>Bold text..</b>
6229 </p><p>..spanning two paragraphs (should not work).
6230 </p><p><b>Bold tag left open</b>
6231 </p><p><i>Italic tag left open</i>
6232 </p><p>Normal text.
6233 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6234 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6235 </p><p>Plain <i>italic'</i>s plain
6236 </p>
6237 !! html/parsoid
6238 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6239 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6240 </p><p><b>Bold text..</b>
6241 </p><p>..spanning two paragraphs (should not work).<b></b>
6242 </p><p><b>Bold tag left open</b>
6243 </p><p><i>Italic tag left open</i>
6244 </p><p>Normal text.
6245 </p>
6246 <!-- Unmatching number of opening, closing tags: -->
6247 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6248 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6249 </p><p>Plain <i>italic'</i>s plain
6250 </p>
6251 !! end
6252
6253 ###
6254 ### Tables
6255 ###
6256 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
6257 ###
6258
6259 # This should not produce <table></table> as <table><tr><td></td></tr></table>
6260 # is the bare minimum required by the spec, see:
6261 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
6262 # Parsoid team replies: empty table tags are legal in HTML5
6263 !! test
6264 A table with no data.
6265 !! options
6266 parsoid=wt2html
6267 !! wikitext
6268 {||}
6269 !! html/php
6270
6271 !! html/parsoid
6272 <table></table>
6273
6274 !! end
6275
6276 # Note that the PHP parser output appears to be broken when the table
6277 # end tag is not separated by a space from the style attribute
6278 !! test
6279 A table with stray table end tags on start tag line (wt2html)
6280 !! options
6281 parsoid=wt2html
6282 !! wikitext
6283 {|style="color: red;"|}
6284
6285 {|style="color: red;" |}
6286 |foo
6287 |}
6288
6289 {|style="color: red;"|} id="foo"
6290 |foo
6291 |}
6292
6293 {|style="color: red;" |} id="foo"
6294 |foo
6295 |}
6296 !! html/php+tidy
6297 <table style="&quot;color:">
6298
6299 </table><table style="color: red;">
6300 <tbody><tr>
6301 <td>foo
6302 </td></tr></tbody></table>
6303 <table style="&quot;color:" id="foo">
6304 <tbody><tr>
6305 <td>foo
6306 </td></tr></tbody></table>
6307 <table style="color: red;" id="foo">
6308 <tbody><tr>
6309 <td>foo
6310 </td></tr></tbody></table>
6311 !! html/parsoid
6312 <table style="color: red;"></table>
6313
6314 <table style="color: red;">
6315 <tbody><tr>
6316 <td>foo</td>
6317 </tr></tbody>
6318 </table>
6319
6320 <table style="color: red;" id="foo">
6321 <tbody><tr>
6322 <td>foo</td>
6323 </tr></tbody>
6324 </table>
6325
6326 <table style="color: red;" id="foo">
6327 <tbody><tr>
6328 <td>foo</td>
6329 </tr></tbody>
6330 </table>
6331
6332 !! end
6333
6334 !! test
6335 A table with no data (take 2)
6336 !! wikitext
6337 {|
6338 |}
6339 !! html/parsoid
6340 <table></table>
6341 !! end
6342
6343 # A table with nothing but a caption is invalid XHTML, we might want to render
6344 # this as <p>caption</p>
6345 # Parsoid team replies: table with only a caption is legal in HTML5
6346 !! test
6347 A table with nothing but a caption
6348 !! wikitext
6349 {|
6350 |+caption
6351 |}
6352 !! html/php
6353 <table>
6354 <caption>caption
6355 </caption><tr><td></td></tr></table>
6356
6357 !! html/parsoid
6358 <table><caption>caption</caption></table>
6359 !! end
6360
6361 !! test
6362 A table with caption with default-spaced attributes and a table row
6363 !! wikitext
6364 {|
6365 |+ style="color: red;" |caption1
6366 |-
6367 |foo
6368 |}
6369 !! html
6370 <table>
6371 <caption style="color: red;">caption1
6372 </caption>
6373 <tr>
6374 <td>foo
6375 </td></tr></table>
6376
6377 !! end
6378
6379 !! test
6380 A table with captions with non-default spaced attributes and a table row
6381 !! wikitext
6382 {|
6383 |+style="color: red;"|caption2
6384 |+ style="color: red;"|caption3
6385 |-
6386 |foo
6387 |}
6388 !! html
6389 <table>
6390 <caption style="color: red;">caption2
6391 </caption>
6392 <caption style="color: red;">caption3
6393 </caption>
6394 <tr>
6395 <td>foo
6396 </td></tr></table>
6397
6398 !! end
6399
6400 !! test
6401 Table td-cell syntax variations
6402 !! wikitext
6403 {|
6404 |foo bar foo|baz
6405 |foo bar foo||baz
6406 |style='color:red;'|baz
6407 |style='color:red;'||baz
6408 |}
6409 !! html
6410 <table>
6411 <tr>
6412 <td>baz
6413 </td>
6414 <td>foo bar foo</td>
6415 <td>baz
6416 </td>
6417 <td style="color:red;">baz
6418 </td>
6419 <td>style='color:red;'</td>
6420 <td>baz
6421 </td></tr></table>
6422
6423 !! end
6424
6425 !! test
6426 Simple table
6427 !! wikitext
6428 {|
6429 |1||2
6430 |-
6431 |3||4
6432 |}
6433 !! html
6434 <table>
6435 <tr>
6436 <td>1</td>
6437 <td>2
6438 </td></tr>
6439 <tr>
6440 <td>3</td>
6441 <td>4
6442 </td></tr></table>
6443
6444 !! end
6445
6446 !! test
6447 Simple table but with multiple dashes for row wikitext
6448 !! wikitext
6449 {|
6450 |foo
6451 |-----
6452 |bar
6453 |}
6454 !! html
6455 <table>
6456 <tr>
6457 <td>foo
6458 </td></tr>
6459 <tr>
6460 <td>bar
6461 </td></tr></table>
6462
6463 !! end
6464
6465 !! test
6466 Multiplication table
6467 !! wikitext
6468 {| border="1" cellpadding="2"
6469 |+Multiplication table
6470 |-
6471 !&times;!!1!!2!!3
6472 |-
6473 !1
6474 |1||2||3
6475 |-
6476 !2
6477 |2||4||6
6478 |-
6479 !3
6480 |3||6||9
6481 |-
6482 !4
6483 |4||8||12
6484 |-
6485 !5
6486 |5||10||15
6487 |}
6488 !! html
6489 <table border="1" cellpadding="2">
6490 <caption>Multiplication table
6491 </caption>
6492 <tr>
6493 <th>&#215;</th>
6494 <th>1</th>
6495 <th>2</th>
6496 <th>3
6497 </th></tr>
6498 <tr>
6499 <th>1
6500 </th>
6501 <td>1</td>
6502 <td>2</td>
6503 <td>3
6504 </td></tr>
6505 <tr>
6506 <th>2
6507 </th>
6508 <td>2</td>
6509 <td>4</td>
6510 <td>6
6511 </td></tr>
6512 <tr>
6513 <th>3
6514 </th>
6515 <td>3</td>
6516 <td>6</td>
6517 <td>9
6518 </td></tr>
6519 <tr>
6520 <th>4
6521 </th>
6522 <td>4</td>
6523 <td>8</td>
6524 <td>12
6525 </td></tr>
6526 <tr>
6527 <th>5
6528 </th>
6529 <td>5</td>
6530 <td>10</td>
6531 <td>15
6532 </td></tr></table>
6533
6534 !! end
6535
6536 !! test
6537 Accept "||" in table headings
6538 !! wikitext
6539 {|
6540 !h1||h2
6541 |}
6542 !! html
6543 <table>
6544 <tr>
6545 <th>h1</th>
6546 <th>h2
6547 </th></tr></table>
6548
6549 !! end
6550
6551 !! test
6552 Accept "!!" in table data
6553 !! wikitext
6554 {|
6555 |Foo!!||
6556 |}
6557 !! html
6558 <table>
6559 <tr>
6560 <td>Foo!!</td>
6561 <td>
6562 </td></tr></table>
6563
6564 !! html/parsoid
6565 <table>
6566 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
6567 </tbody></table>
6568 !! end
6569
6570 !! test
6571 Accept "||" in indented table headings
6572 !! wikitext
6573 :{|
6574 !h1||h2
6575 |}
6576 !! html
6577 <dl><dd><table>
6578 <tr>
6579 <th>h1</th>
6580 <th>h2
6581 </th></tr></table></dd></dl>
6582
6583 !! end
6584
6585 !! test
6586 Accept "!!" in templates
6587 !! wikitext
6588 {|
6589 !a {{echo|b!!c}}
6590 |}
6591 !! html/php
6592 <table>
6593 <tr>
6594 <th>a b</th>
6595 <th>c
6596 </th></tr></table>
6597
6598 !! html/parsoid
6599 <table>
6600 <tbody><tr><th typeof="mw:Transclusion" about="#mwt1" data-parsoid='{"autoInsertedEnd":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":["!a ",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"b!!c"}},"i":0}}]}'>a b</th><th about="#mwt1">c</th></tr>
6601 !! end
6602
6603 !! test
6604 Accept "!!" in table headings after newline
6605 !! wikitext
6606 {|
6607 !a
6608 b!!c
6609 |}
6610 !! html/php
6611 <table>
6612 <tr>
6613 <th>a
6614 <p>b!!c
6615 </p>
6616 </th></tr></table>
6617
6618 !! html/parsoid
6619 <table>
6620 <tbody><tr><th>a
6621 <p>b!!c</p></th></tr>
6622 </tbody></table>
6623 !! end
6624
6625 !! test
6626 Accept "!!" in table data of mixed wikitext / html syntax
6627 !! wikitext
6628 {|
6629 !a
6630 <tr><td>b!!c</td></tr>
6631 |}
6632 !! html/php+tidy
6633 <table>
6634 <tbody><tr>
6635 <th>a
6636 </th></tr><tr><td>b!!c</td></tr>
6637 </tbody></table>
6638 !! html/parsoid
6639 <table>
6640 <tbody><tr><th>a</th></tr>
6641 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6642 </tbody></table>
6643 !! end
6644
6645 !! test
6646 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6647 !! wikitext
6648 {|
6649 !|h1
6650 ||a
6651 |}
6652 !! html
6653 <table>
6654 <tr>
6655 <th>h1
6656 </th>
6657 <td>a
6658 </td></tr></table>
6659
6660 !! end
6661
6662 !!test
6663 Accept "| !" at start of line in tables (ignore !-attribute)
6664 !! wikitext
6665 {|
6666 |-
6667 |!style="color:red"|bar
6668 |}
6669 !! html
6670 <table>
6671
6672 <tr>
6673 <td>bar
6674 </td></tr></table>
6675
6676 !!end
6677
6678 !!test
6679 Allow +/- in 2nd and later cells in a row, in 1st cell when td-attrs are present, or in 1st cell when there is a space between "|" and +/-
6680 !! wikitext
6681 {|
6682 |-
6683 |style='color:red;'|+1
6684 |style='color:blue;'|-1
6685 |-
6686 |1||2||3
6687 |1||+2||-3
6688 |-
6689 | +1
6690 | -1
6691 |}
6692 !! html
6693 <table>
6694
6695 <tr>
6696 <td style="color:red;">+1
6697 </td>
6698 <td style="color:blue;">-1
6699 </td></tr>
6700 <tr>
6701 <td>1</td>
6702 <td>2</td>
6703 <td>3
6704 </td>
6705 <td>1</td>
6706 <td>+2</td>
6707 <td>-3
6708 </td></tr>
6709 <tr>
6710 <td>+1
6711 </td>
6712 <td>-1
6713 </td></tr></table>
6714
6715 !!end
6716
6717 !! test
6718 Table rowspan
6719 !! wikitext
6720 {| border=1
6721 |Cell 1, row 1
6722 |rowspan=2|Cell 2, row 1 (and 2)
6723 |Cell 3, row 1
6724 |-
6725 |Cell 1, row 2
6726 |Cell 3, row 2
6727 |}
6728 !! html
6729 <table border="1">
6730 <tr>
6731 <td>Cell 1, row 1
6732 </td>
6733 <td rowspan="2">Cell 2, row 1 (and 2)
6734 </td>
6735 <td>Cell 3, row 1
6736 </td></tr>
6737 <tr>
6738 <td>Cell 1, row 2
6739 </td>
6740 <td>Cell 3, row 2
6741 </td></tr></table>
6742
6743 !! end
6744
6745 !! test
6746 Nested table
6747 !! wikitext
6748 {| border=1
6749 | &alpha;
6750 |
6751 {| bgcolor=#ABCDEF border=2
6752 |nested
6753 |-
6754 |table
6755 |}
6756 |the original table again
6757 |}
6758 !! html
6759 <table border="1">
6760 <tr>
6761 <td>&#945;
6762 </td>
6763 <td>
6764 <table bgcolor="#ABCDEF" border="2">
6765 <tr>
6766 <td>nested
6767 </td></tr>
6768 <tr>
6769 <td>table
6770 </td></tr></table>
6771 </td>
6772 <td>the original table again
6773 </td></tr></table>
6774
6775 !! end
6776
6777 !! test
6778 Invalid attributes in table cell (T3830)
6779 !! wikitext
6780 {|
6781 |Cell:|broken
6782 |}
6783 !! html
6784 <table>
6785 <tr>
6786 <td>broken
6787 </td></tr></table>
6788
6789 !! end
6790
6791 !! test
6792 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6793 !! wikitext
6794 {|
6795 |title="foo" |bar
6796 |title="foo<nowiki>|</nowiki>" |bar
6797 |title="foo<nowiki>|</nowiki>" bar
6798 |}
6799 !! html/php
6800 <table>
6801 <tr>
6802 <td title="foo">bar
6803 </td>
6804 <td title="foo&#124;">bar
6805 </td>
6806 <td>title="foo|" bar
6807 </td></tr></table>
6808
6809 !! html/parsoid
6810 <table>
6811 <tbody><tr><td title="foo">bar</td>
6812 <td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
6813 <td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6814 </tbody></table>
6815 !! end
6816
6817 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6818 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6819 # *2wt modes will fail.
6820 !! test
6821 Table security: embedded pipes
6822 !! options
6823 parsoid=wt2html,html2html
6824 !! wikitext
6825 {|
6826 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6827 !! html/php
6828 <table>
6829 <tr>
6830 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6831 <td>]" onmouseover="alert(document.cookie)"&gt;test
6832 </td>
6833 </tr>
6834 </table>
6835
6836 !! html/parsoid
6837 <table><tbody>
6838 <tr>
6839 <td data-parsoid='{"startTagSrc":"| ","attrSepSrc":"|","autoInsertedEnd":true}'>[<a rel="mw:ExtLink" class="external free" href="ftp://%7Cx" data-parsoid='{"stx":"url","a":{"href":"ftp://%7Cx"},"sa":{"href":"ftp://|x"}}'>ftp://%7Cx</a></td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'>]" onmouseover="alert(document.cookie)">test</td></tr></tbody></table>
6840 !! end
6841
6842 !! test
6843 Element attributes with double ! should not be broken up by <th>
6844 !! wikitext
6845 {|
6846 !hi <div class="!!">ha</div> ho
6847 |}
6848 !! html/php
6849 <table>
6850 <tr>
6851 <th>hi <div class="!!">ha</div> ho
6852 </th></tr></table>
6853
6854 !! html/parsoid
6855 <table>
6856 <tbody><tr><th>hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6857 </tbody></table>
6858 !! end
6859
6860 !! test
6861 ! and || in element attributes should not be parsed as <th>/<td>
6862 !! wikitext
6863 {|
6864 |<div style="color: red !important;" data-contrived="put this here ||">hi</div>
6865 |}
6866 !! html/php
6867 <table>
6868 <tr>
6869 <td><div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
6870 </td></tr></table>
6871
6872 !! html/parsoid
6873 <table>
6874 <tbody><tr><td><div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6875 </tbody></table>
6876 !! end
6877
6878 # FIXME: The output seems broken. Filed as T110268.
6879 !! test
6880 ! and || in td attributes should not be parsed as <th>/<td>
6881 !! options
6882 parsoid=wt2html
6883 !! wikitext
6884 {|
6885 |style="color: red !important;" data-contrived="put this here ||"|foo
6886 |}
6887 !! html/php
6888 <table>
6889 <tr>
6890 <td>style="color: red !important;" data-contrived="put this here</td>
6891 <td>foo
6892 </td></tr></table>
6893
6894 !! html/parsoid
6895 <table>
6896 <tbody><tr><td>style="color: red !important;" data-contrived="put this here</td><td data-parsoid='{"stx":"row","a":{"\"":null},"sa":{"\"":""},"autoInsertedEnd":true}'>foo</td></tr>
6897 </tbody></table>
6898 !! end
6899
6900 !! test
6901 Break on | in element attribute in template
6902 !! options
6903 parsoid=wt2html,html2html
6904 !! wikitext
6905 {{echo|1=<div class="hi|ho">ha</div>}}
6906 !! html/php
6907 <p>ho"&gt;ha&lt;/div&gt;
6908 </p>
6909 !! html/parsoid
6910 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"ho\">ha&lt;/div>"}},"i":0}}]}'>ho">ha</p>
6911 !! end
6912
6913 !! test
6914 Break on | in element attribute name in template
6915 !! wikitext
6916 {{echo|<div cla|ss="hiho">ha</div>}}
6917 !! html/parsoid
6918 <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"},{"k":"ss","named":true}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;div cla"},"ss":{"wt":"\"hiho\">ha&lt;/div>"}},"i":0}}]}'>&lt;div cla</p>
6919 !! end
6920
6921 !! test
6922 Don't break on | in extension attribute in template
6923 !! wikitext
6924 {{echo|<ref name="hi|ho">ha</ref>}}
6925
6926 <references />
6927 !! html/parsoid
6928 <p><sup about="#mwt2" class="mw-ref" id="cite_ref-hi|ho_1-0" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;ref name=\"hi|ho\">ha&lt;/ref>"}},"i":0}}]}'><a href="./Parser_test#cite_note-hi|ho-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></p>
6929
6930 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-hi|ho-1" id="cite_note-hi|ho-1"><a href="./Parser_test#cite_ref-hi|ho_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-hi|ho-1" class="mw-reference-text">ha</span></li></ol>
6931 !! end
6932
6933 ## We don't support roundtripping of these attributes in Parsoid.
6934 ## Selective serialization takes care of preventing dirty diffs.
6935 ## But, on edits, we dirty-diff the invalid attribute text.
6936 !! test
6937 Invalid text in table attributes should be discarded
6938 !! options
6939 parsoid=wt2html
6940 !! wikitext
6941 {| <span>boo</span> style='border:1px solid black'
6942 | <span>boo</span> style='color:blue' |1
6943 |<span>boo</span> style='color:blue'|2
6944 |}
6945 !! html/php
6946 <table style="border:1px solid black">
6947 <tr>
6948 <td style="color:blue">1
6949 </td>
6950 <td style="color:blue">2
6951 </td></tr></table>
6952
6953 !! html/parsoid
6954 <table style="border:1px solid black">
6955 <tr>
6956 <td style="color:blue">1</td>
6957 <td style="color:blue">2</td>
6958 </tr>
6959 </table>
6960 !! end
6961
6962 !! test
6963 Invalid text in table attributes should be preserved by selective serializer
6964 !! options
6965 parsoid={
6966 "modes": ["selser"],
6967 "changes": [
6968 ["td:first-child", "text", "abc"],
6969 ["td + td", "text", "xyz"]
6970 ]
6971 }
6972 !! wikitext
6973 {| <span>boo</span> style='border:1px solid black'
6974 | <span>boo</span> style='color:blue' | 1
6975 |<span>boo</span> style='color:blue'| 2
6976 |}
6977 !! wikitext/edited
6978 {| <span>boo</span> style='border:1px solid black'
6979 | <span>boo</span> style='color:blue' | abc
6980 |<span>boo</span> style='color:blue'| xyz
6981 |}
6982 !! end
6983
6984 !! test
6985 1. Template-generated table cell attributes and cell content
6986 !! wikitext
6987 {|
6988 |{{table_attribs}}
6989 | {{table_attribs}}
6990 || {{table_attribs_5}}
6991 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
6992 |align=center {{table_attribs}}
6993 | <!--foo--> align=center <!--bar--> {{table_attribs}}
6994 |}
6995 !! html
6996 <table>
6997 <tr>
6998 <td style="color:red;">Foo
6999 </td>
7000 <td style="color:red;">Foo
7001 </td>
7002 <td>style="color:red;"</td>
7003 <td>Bar
7004 </td>
7005 <td style="color:red;">Foo
7006 </td>
7007 <td align="center" style="color:red;">Foo
7008 </td>
7009 <td align="center" style="color:red;">Foo
7010 </td></tr></table>
7011
7012 !! end
7013
7014 !! test
7015 2. Template-generated table cell attributes and cell content
7016 !! wikitext
7017 {|
7018 |{{table_attribs_2}}
7019 |}
7020 !! html/php
7021 <table>
7022 <tr>
7023 <td style="color:red;">Foo
7024 </td>
7025 <td>Bar</td>
7026 <td>Baz
7027 </td></tr></table>
7028
7029 !! html/parsoid
7030 <table>
7031 <tbody><tr><td about="#mwt1" typeof="mw:Transclusion" style="color:red;" data-mw='{"parts":["|",{"template":{"target":{"wt":"table_attribs_2","href":"./Template:Table_attribs_2"},"params":{},"i":0}}]}'>Foo</td>
7032 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
7033 </tbody></table>
7034 !! end
7035
7036 !! test
7037 3. Template-generated table cell attributes and cell content
7038 !! wikitext
7039 {|
7040 !align=center {{table_header_cells}}
7041 |-
7042 |align=center {{table_cells}}
7043 |}
7044 !! html/php
7045 <table>
7046 <tr>
7047 <th align="center" style="color:red;">Foo</th>
7048 <th style="color:red;"><i>Bar</i></th>
7049 <th style="color:brown;"><i>Foo</i> and Baz
7050 </th></tr>
7051 <tr>
7052 <td align="center" style="color:red;">Foo</td>
7053 <td style="color:red;"><i>Bar</i></td>
7054 <td style="color:brown;"><i>Foo</i> and Baz
7055 </td></tr></table>
7056
7057 !! html/parsoid
7058 <table>
7059 <tbody><tr><th align="center" style="color:red;" typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":["!align=center ",{"template":{"target":{"wt":"table_header_cells","href":"./Template:Table_header_cells"},"params":{},"i":0}}]}'>Foo</th><th about="#mwt1" style="color:red;"><i about="#mwt1">Bar</i></th><th about="#mwt1" style="color:brown;"><i about="#mwt1">Foo</i> and Baz</th></tr><tr>
7060 <td align="center" style="color:red;" typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":["|align=center ",{"template":{"target":{"wt":"table_cells","href":"./Template:Table_cells"},"params":{},"i":0}}]}'>Foo</td><td about="#mwt1" style="color:red;"><i about="#mwt1">Bar</i></td><td about="#mwt1" style="color:brown;"><i about="#mwt1">Foo</i> and Baz</td></tr>
7061 </tbody></table>
7062 !! end
7063
7064 !! test
7065 4. Template-generated table cell attributes and cell content inside a templated table
7066 !! wikitext
7067 {{tbl-start}}
7068 !align=center {{table_header_cells}}
7069 |-
7070 |align=center {{table_cells}}
7071 {{tbl-end}}
7072 !! html/php
7073 <table>
7074 <tr>
7075 <th align="center" style="color:red;">Foo</th>
7076 <th style="color:red;"><i>Bar</i></th>
7077 <th style="color:brown;"><i>Foo</i> and Baz
7078 </th></tr>
7079 <tr>
7080 <td align="center" style="color:red;">Foo</td>
7081 <td style="color:red;"><i>Bar</i></td>
7082 <td style="color:brown;"><i>Foo</i> and Baz
7083 </td></tr></table>
7084
7085 !! html/parsoid
7086 <table about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[],[],[],[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"tbl-start","href":"./Template:Tbl-start"},"params":{},"i":0}},"\n!align=center ",{"template":{"target":{"wt":"table_header_cells","href":"./Template:Table_header_cells"},"params":{},"i":1}},"\n|-\n|align=center ",{"template":{"target":{"wt":"table_cells","href":"./Template:Table_cells"},"params":{},"i":2}},"\n",{"template":{"target":{"wt":"tbl-end","href":"./Template:Tbl-end"},"params":{},"i":3}}]}'>
7087 <tbody><tr><th align="center" style="color:red;">Foo</th><th style="color:red;"><i>Bar</i></th><th style="color:brown;"><i>Foo</i> and Baz</th></tr>
7088 <tr>
7089 <td align="center" style="color:red;">Foo</td><td style="color:red;"><i>Bar</i></td><td style="color:brown;"><i>Foo</i> and Baz</td></tr>
7090 </tbody></table>
7091 !! end
7092
7093 ## Edge case fix to prevent future regressions
7094 !! test
7095 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
7096 !! wikitext
7097 {|
7098 |{{table_attribs_7}}
7099 |}
7100 <references />
7101 !! html/parsoid
7102 <table>
7103 <tbody><tr><td style="background:#f9f9f9;" typeof="mw:Transclusion" about="#mwt1" data-mw='{"parts":["|",{"template":{"target":{"wt":"table_attribs_7","href":"./Template:Table_attribs_7"},"params":{},"i":0}}]}'>Foo<sup class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-1"}}'><a href="./Parser_test#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></s></td></tr>
7104 </tbody></table>
7105 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Parser_test#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
7106 !! end
7107
7108 !! test
7109 Table with row followed by newlines and table heading
7110 !! options
7111 parsoid=wt2html,html2html
7112 !! wikitext
7113 {|
7114 |-
7115
7116 !foo
7117 |}
7118 !! html/*
7119 <table>
7120
7121
7122 <tr>
7123 <th>foo
7124 </th></tr></table>
7125
7126 !! end
7127
7128 !! test
7129 Table with empty line following the start tag
7130 !! options
7131 parsoid=wt2html,html2html
7132 !! wikitext
7133 {|
7134
7135 |-
7136 |foo
7137 |}
7138 !! html/*
7139 <table>
7140
7141
7142 <tr>
7143 <td>foo
7144 </td></tr></table>
7145
7146 !! end
7147
7148 !! test
7149 Table attributes with empty value
7150 !! options
7151 parsoid=wt2html,html2html
7152 !! wikitext
7153 {|
7154 | style=|hello
7155 |}
7156 !! html/php
7157 <table>
7158 <tr>
7159 <td style="">hello
7160 </td></tr></table>
7161
7162 !! html/parsoid
7163 <table>
7164 <tbody><tr><td style="">hello</td></tr>
7165 </tbody></table>
7166 !! end
7167
7168 !! test
7169 Wikitext table with a lot of comments
7170 !! wikitext
7171 {|
7172 <!-- c0 -->
7173 |foo
7174 <!-- c1 -->
7175 |-<!-- c2 -->
7176 <!-- c3 -->
7177 |<!-- c4 -->
7178 <!-- c5 -->
7179 |}
7180 !! html
7181 <table>
7182 <tr>
7183 <td>foo
7184 </td></tr>
7185 <tr>
7186 <td>
7187 </td></tr></table>
7188
7189 !! end
7190
7191 !! test
7192 Wikitext table comments represented in parsoid dom
7193 !! wikitext
7194 {|<!--c1--><!--c2-->
7195 |-<!--c3-->
7196 |x
7197 |}
7198 !! html/php+tidy
7199 <table>
7200
7201 <tbody><tr>
7202 <td>x
7203 </td></tr></tbody></table>
7204 !! html/parsoid
7205 <table><!--c1--><!--c2-->
7206 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
7207 <td data-parsoid='{"autoInsertedEnd":true}'>x</td></tr>
7208 </tbody></table>
7209 !! end
7210
7211 !! test
7212 Wikitext table with double-line table cell
7213 !! wikitext
7214 {|
7215 |a
7216 b
7217 |}
7218 !! html
7219 <table>
7220 <tr>
7221 <td>a
7222 <p>b
7223 </p>
7224 </td></tr></table>
7225
7226 !! end
7227
7228 !! test
7229 Table cell with a single comment
7230 !! wikitext
7231 {|
7232 |<!-- c1 -->
7233 |a
7234 |}
7235 !! html
7236 <table>
7237 <tr>
7238 <td>
7239 </td>
7240 <td>a
7241 </td></tr></table>
7242
7243 !! end
7244
7245 !! test
7246 Table-cell after a comment-only-empty-line
7247 !! wikitext
7248 {|
7249 |a
7250 <!--c1-->
7251 <!--c2-->|b
7252 |}
7253 !! html
7254 <table>
7255 <tr>
7256 <td>a
7257 </td>
7258 <td>b
7259 </td></tr></table>
7260
7261 !! html/parsoid
7262 <table>
7263 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
7264 <!--c1-->
7265 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'>b</td></tr>
7266 </tbody></table>
7267
7268 !! end
7269
7270 !! test
7271 Build table with {{!}}
7272 !! wikitext
7273 {{{!}} class="wikitable"
7274 !header
7275 !second header
7276 {{!}}- style="color:red;"
7277 {{!}}data{{!}}{{!}} style="color:red;" {{!}}second data
7278 {{!}}}
7279 !! html
7280 <table class="wikitable">
7281 <tr>
7282 <th>header
7283 </th>
7284 <th>second header
7285 </th></tr>
7286 <tr style="color:red;">
7287 <td>data</td>
7288 <td style="color:red;">second data
7289 </td></tr></table>
7290
7291 !! end
7292
7293 !! test
7294 Build table with pipe as data
7295 !! wikitext
7296 {| class="wikitable"
7297 !header
7298 !second header
7299 |- style="color:red;"
7300 |data|| style="color:red;" |second data
7301 |-
7302 | style="color:red;" |data with | || style="color:red;" | second data with |
7303 |-
7304 ||data with | |||second data with |
7305 |}
7306 !! html
7307 <table class="wikitable">
7308 <tr>
7309 <th>header
7310 </th>
7311 <th>second header
7312 </th></tr>
7313 <tr style="color:red;">
7314 <td>data</td>
7315 <td style="color:red;">second data
7316 </td></tr>
7317 <tr>
7318 <td style="color:red;">data with |</td>
7319 <td style="color:red;">second data with |
7320 </td></tr>
7321 <tr>
7322 <td>data with |</td>
7323 <td>second data with |
7324 </td></tr></table>
7325
7326 !! end
7327
7328 !! test
7329 Build table with wikilink
7330 !! wikitext
7331 {| class="wikitable"
7332 !header||second header
7333 |- style="color:red;"
7334 |data [[Main Page|linktext]]||second data [[Main Page|linktext]]
7335 |-
7336 |data||second data [[Main Page|link|text with pipe]]
7337 |}
7338 !! html
7339 <table class="wikitable">
7340 <tr>
7341 <th>header</th>
7342 <th>second header
7343 </th></tr>
7344 <tr style="color:red;">
7345 <td>data <a href="/wiki/Main_Page" title="Main Page">linktext</a></td>
7346 <td>second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
7347 </td></tr>
7348 <tr>
7349 <td>data</td>
7350 <td>second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
7351 </td></tr></table>
7352
7353 !! end
7354
7355 # The expected HTML structure in this test is debatable. The PHP parser does
7356 # not parse this kind of table at all. The main focus for Parsoid is on
7357 # round-tripping, so this output is ok for now. TODO: revisit!
7358 !! test
7359 Wikitext table with html-syntax row
7360 !! wikitext
7361 {|
7362 |-
7363 <td>foo</td>
7364 |}
7365 !! html/parsoid
7366 <table>
7367 <tbody>
7368 <tr>
7369 <td>foo</td></tr></tbody></table>
7370 !! end
7371
7372 ## Remex doesn't account for fostered content.
7373 !! test
7374 Fostered content in tables: Plain text
7375 !! options
7376 parsoid=wt2html
7377 !! wikitext
7378 {|
7379 |-
7380 a
7381 |}
7382 !! html/php
7383 <table>
7384
7385 a
7386 </table>
7387
7388 !! html/php+tidy
7389
7390
7391 a
7392 <table></table>
7393 !! html/parsoid
7394 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
7395 a</p>
7396 <table>
7397 <tbody><tr class="mw-empty-elt" data-parsoid='{"startTagSrc":"|-"}'></tr></tbody></table>
7398 !! end
7399
7400 !! test
7401 Fostered content in tables: Lists
7402 !! options
7403 parsoid=wt2html,html2html
7404 !! wikitext
7405 {|
7406 |-
7407 *a
7408 |}
7409 !! html/php
7410 <table>
7411
7412 <ul><li>a</li></ul>
7413 </table>
7414
7415 !! html/php+tidy
7416 <ul><li>a</li></ul><table>
7417
7418
7419 </table>
7420 !! html/parsoid
7421 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7422 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7423
7424 </tr></tbody></table>
7425 !! end
7426
7427 !! test
7428 Template generated table cell with attributes
7429 !! wikitext
7430 {|
7431 |-
7432 {{table_attribs_4}} ||a||b
7433 |}
7434 !! html/php+tidy
7435 <table>
7436
7437 <tbody><tr>
7438 <td style="background-color:#DC241f;" width="10px"></td>
7439 <td>a</td>
7440 <td>b
7441 </td></tr></tbody></table>
7442 !! html/parsoid
7443 <table>
7444 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7445 <td style="background-color:#DC241f;" width="10px" about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"autoInsertedEnd":true,"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"table_attribs_4","href":"./Template:Table_attribs_4"},"params":{},"i":0}}," ||a||b"]}'></td><td about="#mwt1">a</td><td about="#mwt1">b</td></tr>
7446 !! end
7447
7448 !! test
7449 Parsoid: Round-trip tables directly followed by content (T53219)
7450 !! options
7451 parsoid=wt2html,wt2wt
7452 !! wikitext
7453 {|
7454 |foo
7455 |} bar
7456
7457 {|
7458 |baz
7459 |}<b>quux</b>
7460 !! html+tidy
7461 <table>
7462 <tbody><tr>
7463 <td>foo
7464 </td></tr></tbody></table><p> bar
7465 </p><table>
7466 <tbody><tr>
7467 <td>baz
7468 </td></tr></tbody></table><p><b>quux</b>
7469 </p>
7470 !! end
7471
7472 !! test
7473 Parsoid: Default to a newline after tables in new content (T53219)
7474 !! options
7475 parsoid=html2wt
7476 !! html/parsoid
7477 <table><tbody>
7478 <tr><td>foo</td></tr></tbody></table> bar
7479 <table><tbody>
7480 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7481 !! wikitext
7482 {|
7483 |foo
7484 |}
7485 <nowiki> </nowiki>bar
7486 {|
7487 |baz
7488 |}
7489 '''quux'''
7490 !! end
7491
7492 !! test
7493 Parsoid: Row-syntax table headings followed by comment & table cells
7494 !! options
7495 parsoid=wt2html,wt2wt
7496 !! wikitext
7497 {|
7498 !foo||bar
7499 <!-- foo --> ||baz||quux
7500 |}
7501 !! html/php
7502 <table>
7503 <tr>
7504 <th>foo</th>
7505 <th>bar
7506 </th>
7507 <td>baz</td>
7508 <td>quux
7509 </td></tr></table>
7510
7511 !! html/parsoid
7512 <table>
7513 <tbody><tr><th>foo</th><th>bar
7514 <!-- foo --></th><td> baz </td><td>quux</td></tr>
7515 </tbody></table>
7516 !! end
7517
7518 !!test
7519 Parsoid: Recover better from broken table attributes
7520 !!options
7521 parsoid=wt2html
7522 !!wikitext
7523 {| class="foo
7524 | class="bar" |
7525 foo
7526 |}
7527 !!html/php+tidy
7528 <table class="foo">
7529 <tbody><tr>
7530 <td class="bar">
7531 <p>foo
7532 </p>
7533 </td></tr></tbody></table>
7534 !!html/parsoid
7535 <table class="foo">
7536 <tr>
7537 <td class="bar">
7538 <p>foo</p></td></tr>
7539 </tbody></table>
7540 !!end
7541
7542 # Note: PHP parser omits empty rows
7543 !! test
7544 Tables: Digest broken attributes on table and tr tag
7545 !! options
7546 parsoid=wt2html
7547 !! wikitext
7548 {| || |} ++
7549 |- || || ++ --
7550 |- > [
7551 |}
7552 !! html/php+tidy
7553 <table>
7554
7555
7556 </table>
7557 !! html/parsoid
7558 <table>
7559 <tbody>
7560 <tr class='mw-empty-elt'></tr>
7561 <tr class='mw-empty-elt'></tr>
7562 </tbody></table>
7563 !! end
7564
7565 !! test
7566 Table with missing opening <tr> tag
7567 !! options
7568 parsoid=wt2html,wt2wt
7569 !! wikitext
7570 <table>
7571 <td>foo</td>
7572 </tr>
7573 </table>
7574 !! html+tidy
7575 <table>
7576 <tbody><tr><td>foo</td>
7577 </tr>
7578 </tbody></table>
7579 !! end
7580
7581 # T137406: Whitespace in the HTML
7582 !! test
7583 1. Generate correct wikitext for tables with thead/tbody/tfoot
7584 !! options
7585 parsoid=html2wt
7586 !! html/parsoid
7587 <table>
7588 <caption>Test</caption>
7589 <thead>
7590 <tr>
7591 <th>Month</th>
7592 <th>Savings</th>
7593 </tr>
7594 </thead>
7595 <tbody>
7596 <tr>
7597 <td>January</td>
7598 <td>$100</td>
7599 </tr>
7600 <tr>
7601 <td>February</td>
7602 <td>$80</td>
7603 </tr>
7604 </tbody>
7605 <tfoot>
7606 <tr>
7607 <td>Sum</td>
7608 <td>$180</td>
7609 </tr>
7610 </tfoot>
7611 </table>
7612 !! wikitext
7613 {|
7614 |+Test
7615 !Month
7616 !Savings
7617 |-
7618 |January
7619 |$100
7620 |-
7621 |February
7622 |$80
7623 |-
7624 |Sum
7625 |$180
7626 |}
7627 !! html/php+tidy
7628 <table>
7629 <caption>Test
7630 </caption>
7631 <tbody><tr>
7632 <th>Month
7633 </th>
7634 <th>Savings
7635 </th></tr>
7636 <tr>
7637 <td>January
7638 </td>
7639 <td>$100
7640 </td></tr>
7641 <tr>
7642 <td>February
7643 </td>
7644 <td>$80
7645 </td></tr>
7646 <tr>
7647 <td>Sum
7648 </td>
7649 <td>$180
7650 </td></tr></tbody></table>
7651 !! end
7652
7653 # T137406: No whitespace in the HTML
7654 !! test
7655 2. Generate correct wikitext for tables with thead/tbody/tfoot
7656 !! options
7657 parsoid=html2wt
7658 !! html/parsoid
7659 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7660 !! wikitext
7661 {|
7662 !heading
7663 |-
7664 |foo
7665 |}
7666 !! end
7667
7668 !! test
7669 Wikitext tables can be nested inside HTML tables
7670 !! options
7671 parsoid=html2wt
7672 !! html/parsoid
7673 <table data-parsoid='{"stx":"html"}'>
7674 <tr><td>
7675 <table>
7676 <tr><td>foo</td></tr>
7677 </table>
7678 </td></tr>
7679 </table>
7680 !! wikitext
7681 <table>
7682 <tr><td>
7683 {|
7684 |foo
7685 |}
7686 </td></tr>
7687 </table>
7688 !! html/php+tidy
7689 <table>
7690 <tbody><tr><td>
7691 <table>
7692 <tbody><tr>
7693 <td>foo
7694 </td></tr></tbody></table>
7695 </td></tr>
7696 </tbody></table>
7697 !! end
7698
7699 ###
7700 ### Internal links
7701 ###
7702 !! test
7703 Plain link, capitalized
7704 !! wikitext
7705 [[Main Page]]
7706 !! html
7707 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7708 </p>
7709 !! end
7710
7711 !! test
7712 Plain link, uncapitalized
7713 !! wikitext
7714 [[main Page]]
7715 !! html
7716 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7717 </p>
7718 !! end
7719
7720 !! test
7721 Piped link
7722 !! wikitext
7723 [[Main Page|The Main Page]]
7724 !! html
7725 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7726 </p>
7727 !! end
7728
7729 !! test
7730 Piped link with comment in link text
7731 !! wikitext
7732 [[Main Page|The Main<!--front--> Page]]
7733 !! html
7734 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7735 </p>
7736 !! end
7737
7738 !! test
7739 Piped link with multiple pipe characters in link text
7740 !! wikitext
7741 [[Main Page||The|Main|Page|]]
7742 !! html/php
7743 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7744 </p>
7745 !! html/parsoid
7746 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7747 !! end
7748
7749 !! test
7750 Piped link with no link text
7751 !! wikitext
7752 [[Thomas Bek (bishop of St David's)|]]
7753 !! html/php
7754 <p>[[Thomas Bek (bishop of St David's)|]]
7755 </p>
7756 !! html/parsoid
7757 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7758 !! end
7759
7760 !! test
7761 Piped link with empty link text
7762 !! wikitext
7763 [[Main Page|<nowiki/>]] - empty nowiki
7764 [[Main Page| ]] - empty space
7765 [[Main Page|&nbsp;]] - empty non breaking space
7766 !! html/php
7767 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7768 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7769 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7770 </p>
7771 !! html/parsoid
7772 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7773 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7774 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span></a> - empty non breaking space</p>
7775 !! end
7776
7777 !! test
7778 Broken link
7779 !! wikitext
7780 [[Zigzagzogzagzig]]
7781 !! html
7782 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7783 </p>
7784 !! end
7785
7786 !! test
7787 Broken link with fragment
7788 !! wikitext
7789 [[Zigzagzogzagzig#zug]]
7790 !! html
7791 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7792 </p>
7793 !! end
7794
7795 !! test
7796 Special page link with fragment
7797 !! wikitext
7798 [[Special:Version#anchor]]
7799 !! html
7800 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7801 </p>
7802 !! end
7803
7804 !! test
7805 Nonexistent special page link with fragment
7806 !! wikitext
7807 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7808 !! html
7809 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7810 </p>
7811 !! end
7812
7813 !! test
7814 Link with prefix
7815 !! wikitext
7816 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7817 !! html
7818 <p>xxx<a href="/wiki/Main_Page" title="Main Page">main Page</a>, xxx<a href="/wiki/Main_Page" title="Main Page">Main Page</a>, Xxx<a href="/wiki/Main_Page" title="Main Page">main Page</a> XXX<a href="/wiki/Main_Page" title="Main Page">main Page</a>, XXX<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7819 </p>
7820 !! end
7821
7822 !! test
7823 Link with suffix
7824 !! wikitext
7825 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7826 !! html
7827 <p><a href="/wiki/Main_Page" title="Main Page">Main Pagexxx</a>, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>XXX, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>!!!
7828 </p>
7829 !! end
7830
7831 !! article
7832 prefixed article
7833 !! text
7834 Some text
7835 !! endarticle
7836
7837 !! test
7838 T45661: Piped links with identical prefixes
7839 !! wikitext
7840 [[prefixed article|prefixed articles with spaces]]
7841
7842 [[prefixed article|prefixed articlesaoeu]]
7843
7844 [[Main Page|Main Page test]]
7845 !! html
7846 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7847 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7848 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7849 </p>
7850 !! end
7851
7852
7853 !! test
7854 Link with HTML entity in suffix / tail
7855 !! wikitext
7856 [[Main Page]]&quot;, [[Main Page]]&#97;
7857 !! html/php
7858 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>&quot;, <a href="/wiki/Main_Page" title="Main Page">Main Page</a>&#97;
7859 </p>
7860 !! html/parsoid
7861 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;quot;","srcContent":"\""}'>"</span>, <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#97;","srcContent":"a"}'>a</span></p>
7862 !! end
7863
7864 !! test
7865 Link with 3 brackets
7866 !! wikitext
7867 [[[Main Page]]]
7868 Foo [[[Main Page]]]
7869 !! html
7870 <p>[[[Main Page]]]
7871 Foo [[[Main Page]]]
7872 </p>
7873 !! end
7874
7875 !! test
7876 Link with 4 brackets
7877 !! wikitext
7878 [[[[Main Page]]]]
7879 !! html
7880 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7881 </p>
7882 !! end
7883
7884 !! test
7885 Piped link with 3 brackets
7886 !! wikitext
7887 [[[main page|the main page]]]
7888 !! html
7889 <p>[[[main page|the main page]]]
7890 </p>
7891 !! end
7892
7893 !! test
7894 Piped link with extlink-like text
7895 !! wikitext
7896 [[Main Page|[bar]]]
7897 [[Main Page|This is a [bar]]]
7898 [[Main Page|[bar]]
7899 !! html/php
7900 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7901 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7902 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7903 </p>
7904 !! html/parsoid
7905 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7906 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7907 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7908 !! end
7909
7910 !! test
7911 Link with multiple pipes
7912 !! wikitext
7913 [[Main Page|The|Main|Page]]
7914 !! html
7915 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7916 </p>
7917 !! end
7918
7919 !! test
7920 Anchor containing a #. (T65430)
7921 !! config
7922 wgFragmentMode=[ 'html5', 'legacy' ]
7923 !! wikitext
7924 [[Main Page#And#Link]]
7925 !! html/php
7926 <p><a href="/wiki/Main_Page#And#Link" title="Main Page">Main Page#And#Link</a>
7927 </p>
7928 !! html/parsoid
7929 <p><a rel="mw:WikiLink" href="./Main_Page#And#Link" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#And#Link"},"sa":{"href":"Main Page#And#Link"}}'>Main Page#And#Link</a></p>
7930 !! end
7931
7932 !! test
7933 Link to namespaces
7934 !! wikitext
7935 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7936 !! html
7937 <p><a href="/index.php?title=Talk:Parser_testing&amp;action=edit&amp;redlink=1" class="new" title="Talk:Parser testing (page does not exist)">Talk:Parser testing</a>, <a href="/index.php?title=Meta:Disclaimers&amp;action=edit&amp;redlink=1" class="new" title="Meta:Disclaimers (page does not exist)">Meta:Disclaimers</a>
7938 </p>
7939 !! end
7940
7941 !! test
7942 Link with space in namespace
7943 !! wikitext
7944 [[User talk:Foo bar]]
7945 !! html
7946 <p><a href="/index.php?title=User_talk:Foo_bar&amp;action=edit&amp;redlink=1" class="new" title="User talk:Foo bar (page does not exist)">User talk:Foo bar</a>
7947 </p>
7948 !! end
7949
7950 !! article
7951 MemoryAlpha:AlphaTest
7952 !! text
7953 This is an article in the MemoryAlpha namespace
7954 (which shadows the memoryalpha interwiki link).
7955 !! endarticle
7956
7957 !! test
7958 Namespace takes precedence over interwiki link (T53680)
7959 !! wikitext
7960 [[MemoryAlpha:AlphaTest]]
7961 !! html
7962 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7963 </p>
7964 !! end
7965
7966 # The previous test doesn't work correctly in html2*, due to not recognizing the
7967 # link as an internal one. This one checks for the correct behavior.
7968 !! test
7969 Link to namespace preferred over interwiki with correct rel attribute
7970 !! options
7971 parsoid=html2wt,html2html
7972 !! html/parsoid
7973 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7974 !! wikitext
7975 [[MemoryAlpha:AlphaTest]]
7976 !! end
7977
7978 !! test
7979 Piped link to namespace
7980 !! wikitext
7981 [[Meta:Disclaimers|The disclaimers]]
7982 !! html
7983 <p><a href="/index.php?title=Meta:Disclaimers&amp;action=edit&amp;redlink=1" class="new" title="Meta:Disclaimers (page does not exist)">The disclaimers</a>
7984 </p>
7985 !! end
7986
7987 !! test
7988 Link containing }
7989 !! wikitext
7990 [[Usually caused by a typo (oops}]]
7991 !! html
7992 <p>[[Usually caused by a typo (oops}]]
7993 </p>
7994 !! end
7995
7996 !! article
7997 7% Solution
7998 !! text
7999 Just a test of an article title containing a percent.
8000 !! endarticle
8001
8002 !! test
8003 Link containing % (not as a hex sequence)
8004 !! wikitext
8005 [[7% Solution]]
8006 [[7% Solution|7%25 Solution]]
8007 !! html/php
8008 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
8009 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
8010 </p>
8011 !! html/parsoid
8012 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
8013 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
8014 !! end
8015
8016 # note that the parsoid HTML is identical to the previous test output,
8017 # so the previous test ensures that the html2wt mode will generate the
8018 # "not as a hex sequence" wikitext.
8019 !! test
8020 Link containing % as a single hex sequence interpreted to char
8021 !! options
8022 parsoid=wt2wt,wt2html,html2html
8023 !! wikitext
8024 [[7%25 Solution]]
8025 [[7%25 Solution|7%25 Solution]]
8026 !! html/php
8027 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
8028 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
8029 </p>
8030 !! html/parsoid
8031 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
8032 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
8033 !!end
8034
8035 !! test
8036 Link containing % as a double hex sequence interpreted to hex sequence
8037 !! wikitext
8038 [[7%2525 Solution]]
8039 !! html
8040 <p>[[7%2525 Solution]]
8041 </p>
8042 !!end
8043
8044 ## Example for such a section: == < ==
8045 !! test
8046 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
8047 !! options
8048 title=[[Main Page]]
8049 !! config
8050 wgFragmentMode=[ 'html5', 'legacy' ]
8051 !! wikitext
8052 [[%23%3c]][[%23%3e]]
8053 !! html/php
8054 <p><a href="#&lt;">#&lt;</a><a href="#&gt;">#&gt;</a>
8055 </p>
8056 !! html/parsoid
8057 <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>
8058 !! end
8059
8060 ## Example for such a section: == < ==
8061 !! test
8062 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy)
8063 !! config
8064 wgFragmentMode=[ 'legacy' ]
8065 !! wikitext
8066 [[%23%3c]][[%23%3e]]
8067 !! html/php
8068 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
8069 </p>
8070 !! end
8071
8072 !! test
8073 Link containing "<#" and ">#" as a hex sequences
8074 !! wikitext
8075 [[%3c%23]][[%3e%23]]
8076 !! html
8077 <p>[[%3c%23]][[%3e%23]]
8078 </p>
8079 !! end
8080
8081 !! test
8082 Link containing an equals sign
8083 !! wikitext
8084 [[Special:BookSources/isbn=4-00-026157-6]]
8085 !! html/php
8086 <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>
8087 </p>
8088 !! html/parsoid
8089 <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>
8090 !! end
8091
8092 !! article
8093 Foo & bar
8094 !! text
8095 Just a test of an article title containing an ampersand
8096 !! endarticle
8097
8098 !! test
8099 Link containing an ampersand
8100 !! wikitext
8101 [[Foo & bar]]
8102
8103 [[Foo &amp; bar]]
8104
8105 [[Foo &amp;amp; bar]]
8106 !! html/php+tidy
8107 <p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar">Foo &amp; bar</a>
8108 </p><p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar">Foo &amp; bar</a>
8109 </p><p>[[Foo &amp;amp; bar]]
8110 </p>
8111 !! html/parsoid
8112 <p><a rel="mw:WikiLink" href="./Foo_&amp;_bar" title="Foo &amp; bar">Foo &amp; bar</a></p>
8113 <p><a rel="mw:WikiLink" href="./Foo_&amp;_bar" title="Foo &amp; bar" data-parsoid='{"stx":"simple","a":{"href":"./Foo_&amp;_bar"},"sa":{"href":"Foo &amp;amp; bar"}}'>Foo &amp; bar</a></p>
8114 <p>[[Foo <span typeof="mw:Entity" data-parsoid='{"src":"&amp;amp;","srcContent":"&amp;"}'>&amp;</span>amp; bar]]</p>
8115 !! end
8116
8117 !! article
8118 Foo~bar
8119 !! text
8120 Just a test of an article title containing a tilde.
8121 !! endarticle
8122
8123 # note that links containing signatures, like [[Foo~~~~]], are
8124 # massaged by the pre-save transform (PST) and so the tildes are never
8125 # seen by the parser.
8126 !! test
8127 Link containing a tilde
8128 !! wikitext
8129 [[Foo~bar]]
8130 !! html/php
8131 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
8132 </p>
8133 !! html/parsoid
8134 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
8135 !! end
8136
8137 !! test
8138 Link containing double-single-quotes '' (T6598)
8139 !! wikitext
8140 [[Lista d''e paise d''o munno]]
8141 !! html/php
8142 <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>
8143 </p>
8144 !! html/parsoid
8145 <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>
8146 !! end
8147
8148 !! test
8149 Link containing double quotes and spaces
8150 !! wikitext
8151 [[Cool "Gator"]]
8152 !! html/php
8153 <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>
8154 </p>
8155 !! html/parsoid
8156 <p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p>
8157 !! end
8158
8159 !! test
8160 File containing double quotes and spaces
8161 !! wikitext
8162 [[File:Cool "Gator".png]]
8163 !! html/parsoid
8164 <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>
8165 !! end
8166
8167 !! test
8168 Redirect containing double quotes and spaces
8169 !! wikitext
8170 #REDIRECT [[Cool "Gator"]]
8171 !! html/parsoid
8172 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
8173 !! end
8174
8175 !! test
8176 Link containing double-single-quotes '' in text (T6598 sanity check)
8177 !! wikitext
8178 Some [[Link|pretty ''italics'' and stuff]]!
8179 !! html/php
8180 <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>!
8181 </p>
8182 !! html/parsoid
8183 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
8184 !! end
8185
8186 !! test
8187 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
8188 !! wikitext
8189 ''Some [[Link|pretty ''italics'' and stuff]]!''
8190 !! html
8191 <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>
8192 </p>
8193 !! end
8194
8195 !! test
8196 Link with double quotes in title part (literal) and alternate part (interpreted)
8197 !! wikitext
8198 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
8199
8200 [[''Pentecoste'']]
8201
8202 [[''Pentecoste''|Pentecoste]]
8203
8204 [[''Pentecoste''|''Pentecoste'']]
8205 !! html/php
8206 <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>
8207 </p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="&#39;&#39;Pentecoste&#39;&#39; (page does not exist)">''Pentecoste''</a>
8208 </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>
8209 </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>
8210 </p>
8211 !! html/parsoid
8212 <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>
8213 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
8214 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
8215 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
8216 !! end
8217
8218 !! test
8219 Broken image links with HTML captions (T41700)
8220 !! wikitext
8221 [[File:Nonexistent|<script></script>]]
8222 [[File:Nonexistent|100x100px|<script></script>]]
8223 [[File:Nonexistent|&lt;]]
8224 [[File:Nonexistent|a<i>b</i>c]]
8225 !! html/php
8226 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8227 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8228 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8229 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8230 </p>
8231 !! html/parsoid
8232 <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>
8233 <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>
8234 <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>
8235 <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>
8236 !! end
8237
8238 !! test
8239 Plain link to URL
8240 !! wikitext
8241 [[http://www.example.com]]
8242 !! html/php
8243 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8244 </p>
8245 !! html/parsoid
8246 <p>[<a rel="mw:ExtLink" class="external autonumber" href="http://www.example.com"></a>]</p>
8247 !! end
8248
8249 !! test
8250 Plain link to URL with link text
8251 !! wikitext
8252 [[http://www.example.com Link text]]
8253 !! html
8254 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8255 </p>
8256 !! end
8257
8258 !! test
8259 Plain link to protocol-relative URL
8260 !! wikitext
8261 [[//www.example.com]]
8262 !! html/php
8263 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8264 </p>
8265 !! html/parsoid
8266 <p>[<a rel="mw:ExtLink" class="external autonumber" href="//www.example.com"></a>]</p>
8267 !! end
8268
8269 !! test
8270 Plain link to protocol-relative URL with link text
8271 !! wikitext
8272 [[//www.example.com Link text]]
8273 !! html
8274 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8275 </p>
8276 !! end
8277
8278 !! test
8279 Plain link to page with question mark in title
8280 !! wikitext
8281 [[A?b]]
8282
8283 [[A?b|Baz]]
8284 !! html
8285 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8286 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8287 </p>
8288 !! end
8289
8290 # I'm fairly sure the expected result here is wrong.
8291 # We want these to be URL links, not pseudo-pages with URLs for titles....
8292 # However the current output is also pretty screwy.
8293 #
8294 # ----
8295 # I'm changing it to match the current output--it arguably makes more
8296 # sense in the light of the test above. Old expected result was:
8297 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8298 #</p>
8299 # But I think this test is bordering on "garbage in, garbage out" anyway.
8300 # -- wtm
8301 !! test
8302 Piped link to URL
8303 !! wikitext
8304 Piped link to URL: [[http://www.example.com|an example URL]]
8305 !! html/php
8306 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8307 </p>
8308 !! html/parsoid
8309 <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>
8310 !! end
8311
8312 !! test
8313 Plain link in template argument
8314 !! options
8315 parsoid=wt2html
8316 !! wikitext
8317 {{echo|[http://www.example.com |123]}}
8318
8319 {{echo|[[http://www.example.com |123]]}}
8320
8321 {{echo|[[http://www.example.com |123]}}
8322
8323 {{echo|[http://www.example.com |123]]}}
8324 !! html/php
8325 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8326 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8327 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8328 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8329 </p>
8330 !! html/parsoid
8331 <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>
8332
8333 <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>
8334
8335 <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>
8336
8337 <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>
8338 !! end
8339
8340 !! test
8341 T2002: [[page|http://url/]] should link to page, not http://url/
8342 !! wikitext
8343 [[Main Page|http://url/]]
8344 !! html/php
8345 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8346 </p>
8347 !! html/parsoid
8348 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8349 !! end
8350
8351 # Parsoid does not mark self-links, by design.
8352 !! test
8353 T2337: Escaped self-links should be bold
8354 !! options
8355 title=[[Bug462]]
8356 !! wikitext
8357 [[Bu&#103;462]] [[Bug462]]
8358 !! html/php+tidy
8359 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8360 </p>
8361 !! html/parsoid
8362 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8363 !! end
8364
8365 !! test
8366 Self-link to section should not be bold
8367 !! options
8368 title=[[Main Page]]
8369 !! wikitext
8370 [[Main Page#section]]
8371 !! html
8372 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8373 </p>
8374 !! end
8375
8376 !! article
8377 00
8378 !! text
8379 This is 00.
8380 !! endarticle
8381
8382 !!test
8383 Self-link to numeric title
8384 !!options
8385 title=[[0]]
8386 !! wikitext
8387 [[0]]
8388 !! html
8389 <p><a class="mw-selflink selflink">0</a>
8390 </p>
8391 !!end
8392
8393 !!test
8394 Link to numeric-equivalent title
8395 !!options
8396 title=[[0]]
8397 !! wikitext
8398 [[00]]
8399 !! html
8400 <p><a href="/wiki/00" title="00">00</a>
8401 </p>
8402 !!end
8403
8404 !! test
8405 <nowiki> inside a link
8406 !! wikitext
8407 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8408 !! html
8409 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8410 </p>
8411 !! end
8412
8413 !! test
8414 Non-breaking spaces in title
8415 !! wikitext
8416 [[&nbsp; Main &nbsp; Page &nbsp;]]
8417 !! html
8418 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8419 </p>
8420 !!end
8421
8422 # Add new article for the test below so that it doesn't red-link
8423 !! article
8424 Foo bar baz
8425 !! text
8426 boo
8427 !! endarticle
8428
8429 !! test
8430 Multiple spaces in titles should normalize to a single underscore
8431 !! options
8432 parsoid=wt2html,wt2wt
8433 !! wikitext
8434 [[Foo bar baz|x]]
8435 [[Foo bar baz|x]]
8436 [[Foo bar baz|x]]
8437 !! html/php
8438 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8439 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8440 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8441 </p>
8442 !! html/parsoid
8443 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8444 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8445 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8446 </p>
8447 !! end
8448
8449 !! test
8450 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8451 !! options
8452 language=ca
8453 !! wikitext
8454 '''[[Main Page]]'''
8455 !! html
8456 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8457 </p>
8458 !! end
8459
8460 !! test
8461 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8462 !! options
8463 language=ca
8464 !! wikitext
8465 ''[[Main Page]]''
8466 !! html
8467 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8468 </p>
8469 !! end
8470
8471 !! test
8472 Internal link with en linktrail: no apostrophes (T29473)
8473 !! options
8474 language=en
8475 !! wikitext
8476 [[Something]]'nice
8477 !! html
8478 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8479 </p>
8480 !! end
8481
8482 !! test
8483 Internal link with ca linktrail with apostrophes (T29473)
8484 !! options
8485 language=ca
8486 !! wikitext
8487 [[Something]]'nice
8488 !! html
8489 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8490 </p>
8491 !! end
8492
8493 !! test
8494 Internal link with kaa linktrail with apostrophes (T29473)
8495 !! options
8496 language=kaa
8497 !! wikitext
8498 [[Something]]'nice
8499 !! html
8500 <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>
8501 </p>
8502 !! end
8503
8504 !! test
8505 Link with multiple ":" in a subpage-supporting namespace (T65636)
8506 !! wikitext
8507 [[User:Foo/Test/63636:Bar|Test]]
8508 !! html/php
8509 <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>
8510 </p>
8511 !! html/parsoid
8512 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8513 !! end
8514
8515 ## Mainly a sanity check for Parsoid
8516 !! test
8517 Handle title parsing for subpages
8518 !! options
8519 title=[[/123123]]
8520 subpage
8521 !! wikitext
8522 123
8523 !! html/php
8524 <p>123
8525 </p>
8526 !! html/parsoid
8527 <p>123</p>
8528 !! end
8529
8530 !! article
8531 User:Test/123
8532 !! text
8533 test 123
8534 !! endarticle
8535
8536 !! test
8537 Link to a subpage from a namespace other than main
8538 !! options
8539 title=[[User:Test]]
8540 subpage
8541 !! wikitext
8542 [[/123]]
8543 !! html/php
8544 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8545 </p>
8546 !! html/parsoid
8547 <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>
8548 !! end
8549
8550 !! test
8551 Ensure that transclusion titles are not url-decoded
8552 !! options
8553 subpage title=[[Test]]
8554 parsoid=wt2html
8555 !! wikitext
8556 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8557 !! html/php
8558 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8559 </p>
8560 !! html/parsoid
8561 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8562 !! end
8563
8564 !! test
8565 Purely hash wikilink
8566 !! options
8567 title=[[User:Test/123]]
8568 subpage
8569 !! wikitext
8570 [[#a|b]]
8571 !! html/php
8572 <p><a href="#a">b</a>
8573 </p>
8574 !! html/parsoid
8575 <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>
8576 !! end
8577
8578 !! test
8579 Serialization of purely hash wikilink
8580 !! options
8581 title=[[User:Test/123]]
8582 subpage
8583 parsoid=html2wt
8584 !! html/parsoid
8585 <p><a href="#a">[[</a></p>
8586 !! wikitext
8587 [[#a|<nowiki>[[</nowiki>]]
8588 !! html/php
8589 <p><a href="#a">[[</a>
8590 </p>
8591 !! end
8592
8593 !! test
8594 1. Interaction of linktrail and template encapsulation
8595 !! wikitext
8596 {{echo|[[Foo]]}}l
8597 !! html/php+tidy
8598 <p><a href="/wiki/Foo" title="Foo">Fool</a>
8599 </p>
8600 !! html/parsoid
8601 <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>
8602 !! end
8603
8604 !! test
8605 2. Interaction of linktrail and template encapsulation
8606 !! wikitext
8607 {{echo|Some [[Fool]]}}s
8608 !! html/php+tidy
8609 <p>Some <a href="/index.php?title=Fool&amp;action=edit&amp;redlink=1" class="new" title="Fool (page does not exist)">Fools</a>
8610 </p>
8611 !! html/parsoid
8612 <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>
8613 !! end
8614
8615 !! test
8616 3. Interaction of linktrail and template encapsulation
8617 !! wikitext
8618 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8619 !! html/php+tidy
8620 <p>Some <a href="/index.php?title=Fool&amp;action=edit&amp;redlink=1" class="new" title="Fool (page does not exist)">Fools</a> are <b>bold and foolish</b>
8621 </p>
8622 !! html/parsoid
8623 <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>
8624 !! end
8625
8626 !! article
8627 Söfnuður
8628 !! text
8629 Test.
8630 !! endarticle
8631
8632 !! test
8633 Internal link with is link prefix
8634 !! options
8635 language=is
8636 !! wikitext
8637 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8638 !! html
8639 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8640 </p>
8641 !! end
8642
8643 !! article
8644 Mótmælendatrú
8645 !! text
8646 Test.
8647 !! endarticle
8648
8649 !! test
8650 Internal link with is link trail and link prefix
8651 !! options
8652 language=is
8653 !! wikitext
8654 [[mótmælendatrú|xxx]]ar
8655 [[mótmælendatrú]]ar
8656 mótmælenda[[söfnuður]]
8657 mótmælenda[[söfnuður|söfnuðir]]
8658 mótmælenda[[söfnuður|söfnuðir]]xxx
8659 !! html
8660 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8661 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8662 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8663 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8664 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8665 </p>
8666 !! end
8667
8668 !! test
8669 Parsoid link trail escaping
8670 !! options
8671 parsoid=html2wt,html2html
8672 !! html/parsoid
8673 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8674 !! wikitext
8675 [[apple]]<nowiki/>s
8676 !! end
8677
8678 !! test
8679 Parsoid link prefix escaping
8680 !! options
8681 language=is
8682 parsoid=html2wt,html2html
8683 !! html/parsoid
8684 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8685 !! wikitext
8686 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8687 !! end
8688
8689 !! test
8690 Parsoid link bracket escaping
8691 !! options
8692 parsoid=html2wt,html2html
8693 !! html/parsoid
8694 <p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
8695 <p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
8696 <p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
8697 <p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
8698 <p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
8699 <p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
8700 !! wikitext
8701 [[Test]]
8702
8703 [<nowiki/>[[Test]]]
8704
8705 [[[[Test]]]]
8706
8707 [[[<nowiki/>[[Test]]]]]
8708
8709 [[[[[[Test]]]]]]
8710
8711 [[[[[<nowiki/>[[Test]]]]]]]
8712 !! end
8713
8714 !! test
8715 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8716 !! wikitext
8717 [[Foo| bar]]
8718
8719 [[Foo| ''bar'']]
8720
8721 [http://wp.org foo]
8722
8723 [http://wp.org ''foo'']
8724 !! html
8725 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8726 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8727 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8728 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8729 </p>
8730 !! end
8731
8732 !! test
8733 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8734 !! wikitext
8735 [[Foo|{{echo|a}} b {{echo|c}}]]
8736 !! html/parsoid
8737 <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>
8738 !! end
8739
8740 !! test
8741 Link with angle bracket after anchor
8742 !! config
8743 wgFragmentMode=[ 'html5', 'legacy' ]
8744 !! wikitext
8745 [[Foo#<bar>]]
8746 !! html/php
8747 <p><a href="/wiki/Foo#&lt;bar&gt;" title="Foo">Foo#&lt;bar&gt;</a>
8748 </p>
8749 !! html/parsoid
8750 <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>
8751 !! end
8752
8753 !! test
8754 Link with angle bracket after anchor (legacy)
8755 !! config
8756 wgFragmentMode=[ 'legacy' ]
8757 !! wikitext
8758 [[Foo#<bar>]]
8759 !! html/php
8760 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8761 </p>
8762 !! end
8763
8764 ###
8765 ### Interwiki links (see maintenance/interwiki.sql)
8766 ###
8767
8768 !! test
8769 Inline interwiki link
8770 !! options
8771 parsoid=wt2html,wt2wt,html2html
8772 !! wikitext
8773 [[MeatBall:SoftSecurity]]
8774 !! html/php
8775 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8776 </p>
8777 !! html/parsoid
8778 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8779 !! end
8780
8781 !! test
8782 Inline interwiki link with empty title (T4372)
8783 !! options
8784 parsoid=wt2html,wt2wt,html2html
8785 !! wikitext
8786 [[MeatBall:]]
8787 !! html/php
8788 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8789 </p>
8790 !! html/parsoid
8791 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8792 !! end
8793
8794 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8795 !! test
8796 Interwiki link encoding conversion (T3636)
8797 !! options
8798 parsoid=wt2html,wt2wt
8799 !! wikitext
8800 *[[Wikipedia:ro:Olteni&#0355;a]]
8801 *[[Wikipedia:ro:Olteni&#355;a]]
8802 !! html/php
8803 <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>
8804 <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>
8805
8806 !! html/php+tidy
8807 <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>
8808 <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>
8809 !! html/parsoid
8810 <ul>
8811 <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>
8812 <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>
8813 </ul>
8814 !! end
8815
8816 !! test
8817 Interwiki link with fragment (T4130)
8818 !! wikitext
8819 [[MeatBall:SoftSecurity#foo]]
8820 !! html
8821 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8822 </p>
8823 !! end
8824
8825 !! test
8826 Link scenarios with escaped fragments
8827 !! options
8828 title=[[Main Page]]
8829 !! config
8830 wgFragmentMode=[ 'html5', 'legacy' ]
8831 !! wikitext
8832 [[#Is this great?]]
8833 [[Foo#Is this great?]]
8834 [[meatball:Foo#Is this great?]]
8835 !! html/php
8836 <p><a href="#Is_this_great?">#Is this great?</a>
8837 <a href="/wiki/Foo#Is_this_great?" title="Foo">Foo#Is this great?</a>
8838 <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>
8839 </p>
8840 !! html/parsoid
8841 <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>
8842 <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>
8843 <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>
8844 !! end
8845
8846 !! test
8847 Link scenarios with escaped fragments (legacy)
8848 !! config
8849 wgFragmentMode=[ 'legacy' ]
8850 !! wikitext
8851 [[#Is this great?]]
8852 [[Foo#Is this great?]]
8853 [[meatball:Foo#Is this great?]]
8854 !! html/php
8855 <p><a href="#Is_this_great.3F">#Is this great?</a>
8856 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8857 <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>
8858 </p>
8859 !! end
8860
8861 # Ideally the wikipedia: prefix here should be proto-relative too
8862 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8863 # define the 'en' prefix, and originally the test used 'wikipedia',
8864 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8865 # article.
8866 !! test
8867 Different interwiki prefixes mapping to the same URL
8868 !! wikitext
8869 [[:en:Foo]]
8870
8871 [[:en:Foo|Foo]]
8872
8873 [[wikipedia:Foo]]
8874
8875 [[:wikipedia:Foo|Foo]]
8876
8877 [[wikipedia:en:Foo]]
8878
8879 [[:wikipedia:en:Foo]]
8880
8881 [[ wikiPEdia :Foo]]
8882 !! html/parsoid
8883 <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>
8884
8885 <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>
8886
8887 <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>
8888
8889 <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>
8890
8891 <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>
8892
8893 <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>
8894
8895 <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>
8896 !! end
8897
8898 !! test
8899 Interwiki links that cannot be represented in wiki syntax
8900 !! wikitext
8901 [[meatball:ok]]
8902 [[meatball:ok#foo|ok with fragment]]
8903 [[meatball:ok_as_well?|ok ending with ? mark]]
8904 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8905 [http://de.wikipedia.org/wiki/#foo is just fragment]
8906
8907 !! html/php
8908 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8909 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8910 <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>
8911 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8912 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8913 </p>
8914 !! html/parsoid
8915 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8916 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8917 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok_as_well%3F" title="meatball:ok as well?">ok ending with ? mark</a>
8918 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8919 <a rel="mw:ExtLink" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8920 !! end
8921
8922 !! test
8923 Interwiki links: trail
8924 !! wikitext
8925 [[wikipedia:Foo|Ba]]r
8926 !! html/php
8927 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8928 </p>
8929 !! html/parsoid
8930 <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>
8931 !! end
8932
8933 !! test
8934 Local interwiki link
8935 !! options
8936 parsoid=wt2html,wt2wt,html2html
8937 !! wikitext
8938 [[local:Template:Foo]]
8939 !! html/php
8940 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8941 </p>
8942 !! html/parsoid
8943 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8944 !! end
8945
8946 # Parsoid does not mark self-links, by design.
8947 !! test
8948 Local interwiki link: self-link to current page
8949 !! options
8950 title=[[Main Page]]
8951 parsoid=wt2html,wt2wt,html2html
8952 !! wikitext
8953 [[local:Main Page]]
8954 !! html/php
8955 <p><a class="mw-selflink selflink">local:Main Page</a>
8956 </p>
8957 !! html/parsoid
8958 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8959 !! end
8960
8961 !! test
8962 Local interwiki link: prefix only (T66167)
8963 !! options
8964 parsoid=wt2html,wt2wt,html2html
8965 !! wikitext
8966 [[local:]]
8967 !! html/php
8968 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8969 </p>
8970 !! html/parsoid
8971 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8972 !! end
8973
8974 !! test
8975 Local interwiki link: with additional interwiki prefix (T63357)
8976 !! options
8977 parsoid=wt2html,wt2wt,html2html
8978 !! wikitext
8979 [[local:meatball:Hello]]
8980 !! html/php
8981 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8982 </p>
8983 !! html/parsoid
8984 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8985 !! end
8986
8987 !! test
8988 Multiple local interwiki link prefixes
8989 !! wikitext
8990 [[local:local:local:local:mi:local:Foo]]
8991 !! options
8992 parsoid=wt2html,wt2wt,html2html
8993 !! html/php
8994 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8995 </p>
8996 !! html/parsoid
8997 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8998 !! end
8999
9000 !! test
9001 Interwiki link with percent encoded target
9002 !! wikitext
9003 [[:es:Nueva Guip%C3%BAzcoa|Nueva Guipúzcoa]]
9004 !! html/php
9005 <p><a href="http://es.wikipedia.org/wiki/Nueva_Guip%C3%BAzcoa" class="extiw" title="es:Nueva Guipúzcoa">Nueva Guipúzcoa</a>
9006 </p>
9007 !! html/parsoid
9008 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Nueva%20Guipúzcoa" title="es:Nueva Guipúzcoa" data-parsoid='{"stx":"piped","a":{"href":"http://es.wikipedia.org/wiki/Nueva%20Guipúzcoa"},"sa":{"href":":es:Nueva Guip%C3%BAzcoa"},"isIW":true}'>Nueva Guipúzcoa</a></p>
9009 !! end
9010
9011 ###
9012 ### Interlanguage links
9013 ### Language links (so that searching for '### language' matches..)
9014 ###
9015
9016 !! test
9017 Interlanguage link
9018 !! wikitext
9019 Blah blah blah
9020 [[zh:Chinese]]
9021 !! html/php
9022 <p>Blah blah blah
9023 </p>
9024 !! html/parsoid
9025 <p>Blah blah blah</p>
9026 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9027 !! end
9028
9029 ## parsoid html2wt will lose the space variations
9030 !! test
9031 Interlanguage link with spacing
9032 !! options
9033 parsoid=wt2html,wt2wt,html2html
9034 !! wikitext
9035 Blah blah blah
9036 [[ zh : Chinese ]]
9037 !! html/php
9038 <p>Blah blah blah
9039 </p>
9040 !! html/parsoid
9041 <p>Blah blah blah</p>
9042 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9043 !! end
9044
9045 !! test
9046 Double interlanguage link
9047 !! wikitext
9048 Blah blah blah
9049 [[es:Spanish]]
9050 [[zh:Chinese]]
9051 !! html/php
9052 <p>Blah blah blah
9053 </p>
9054 !! html/parsoid
9055 <p>Blah blah blah</p>
9056 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
9057 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9058 !! end
9059
9060 ## parsoid html2wt will lose the space variations
9061 !! test
9062 Interlanguage link variations
9063 !! options
9064 parsoid=wt2html,wt2wt,html2html
9065 !! wikitext
9066 Blah blah blah
9067 [[ es :Spanish]]
9068 [[ ZH :Chinese]]
9069 [[es:Foo_bar]]
9070 !! html/php
9071 <p>Blah blah blah
9072 </p>
9073 !! html/parsoid
9074 <p>Blah blah blah</p>
9075 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
9076 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
9077 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
9078 !! end
9079
9080 !! test
9081 Escaping of interlanguage links (T129218, T156308)
9082 !! wikitext
9083 Blah blah blah
9084 [[:es:Spanish]]
9085 [[ : zh : Chinese ]]
9086 !! html/php
9087 <p>Blah blah blah
9088 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
9089 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
9090 </p>
9091 !! html/parsoid
9092 <p>Blah blah blah
9093 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
9094 <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
9095 !! end
9096
9097 !! test
9098 Multiple colons escaping interlanguage links
9099 !! options
9100 parsoid=wt2html
9101 !! wikitext
9102 [[:es:Spanish]]
9103 [[::es:Spanish]]
9104 [[:::es:Spanish]]
9105 !! html/php
9106 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
9107 [[::es:Spanish]]
9108 [[:::es:Spanish]]
9109 </p>
9110 !! html/parsoid
9111 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
9112 [[::es:Spanish]]
9113 [[:::es:Spanish]]</p>
9114 !! end
9115
9116 ## parsoid html2wt will normalize the space to _
9117 !! test
9118 Space and question mark encoding in interlanguage links (T95473)
9119 !! options
9120 parsoid=wt2html,wt2wt,html2html
9121 !! wikitext
9122 Blah blah blah
9123 [[es:Foo bar?]]
9124 !! html/php
9125 <p>Blah blah blah
9126 </p>
9127 !! html/parsoid
9128 <p>Blah blah blah</p>
9129 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
9130 !! end
9131
9132 !! test
9133 Interlanguage link, with prefix links
9134 !! options
9135 language=ln
9136 !! wikitext
9137 Blah blah blah
9138 [[zh:Chinese]]
9139 !! html/php
9140 <p>Blah blah blah
9141 </p>
9142 !! html/parsoid
9143 <p>Blah blah blah</p>
9144 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9145 !! end
9146
9147 !! test
9148 Double interlanguage link, with prefix links (T10897)
9149 !! options
9150 language=ln
9151 !! wikitext
9152 Blah blah blah
9153 [[es:Spanish]]
9154 [[zh:Chinese]]
9155 !! html/php
9156 <p>Blah blah blah
9157 </p>
9158 !! html/parsoid
9159 <p>Blah blah blah</p>
9160 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
9161 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9162 !! end
9163
9164 !! test
9165 "Extra" interlanguage links (T34189 / gerrit 111390)
9166 !! wikitext
9167 Blah blah blah
9168 [[mul:Article]]
9169 !! html/php
9170 <p>Blah blah blah
9171 </p>
9172 !! html/parsoid
9173 <p>Blah blah blah</p>
9174 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
9175 !! end
9176
9177 ## PHP parser tests script needs an update
9178 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9179 !! test
9180 Language links render as inline links if $wgInterwikiMagic=false
9181 !! options
9182 wgInterwikiMagic=false
9183 parsoid=wt2html,wt2wt,html2html
9184 !! wikitext
9185 Blah blah blah
9186 [[zh:Chinese]]
9187 !! html/parsoid
9188 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9189 !! end
9190
9191 ## PHP parser tests script needs an update
9192 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9193 !! test
9194 Language links render as inline links in the Talk namespace
9195 !! options
9196 title=Talk:Foo
9197 parsoid=wt2html,wt2wt,html2html
9198 !! wikitext
9199 Blah blah blah
9200 [[zh:Chinese]]
9201 !! html/parsoid
9202 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9203 !! end
9204
9205 !! test
9206 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
9207 !! options
9208 language=ln
9209 !! wikitext
9210 [[WW&nbsp;II]]
9211 !! html
9212 <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>
9213 </p>
9214 !! end
9215
9216 !! test
9217 Parsoid T55221: Wikilinks should be properly entity-escaped
9218 !! options
9219 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
9220 !! html/parsoid
9221 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9222 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9223 !! wikitext
9224 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
9225
9226 He&amp;nbsp;llo He&amp;nbsp;llo
9227 !! html/php
9228 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
9229 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
9230 </p>
9231 !! end
9232
9233 # html2wt will fail because of title normalization without data-parsoid
9234 !! test
9235 Parsoid: handle constructor well
9236 !! options
9237 parsoid=wt2html,wt2wt
9238 !! wikitext
9239 [[constructor]]
9240
9241 [[constructor:foo]]
9242 !! html/php
9243 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
9244 </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>
9245 </p>
9246 !! html/parsoid
9247 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
9248
9249 <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>
9250 !! end
9251
9252 !! test
9253 Template parameter named "constructor"
9254 !! wikitext
9255 {{echo| constructor = |hi}}
9256 !! html/parsoid
9257 <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"constructor","named":true,"spc":[" "," ",""," "]},{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"},"constructor":{"wt":""}},"i":0}}]}'>hi</p>
9258 !! end
9259
9260 !! article
9261 ko:
9262 !! text
9263 Test.
9264 !! endarticle
9265
9266 # Note that `ko` isn't a known interlanguage prefix
9267 !! test
9268 Parsoid: recognize interlanguage links without a target page
9269 !! options
9270 ill
9271 !! wikitext
9272 [[es:]]
9273
9274 [[ko:]]
9275 !! html/php
9276 es:
9277 !! html/parsoid
9278 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
9279
9280 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9281 !! end
9282
9283 # Note that `ko` isn't a known interwiki prefix
9284 !! test
9285 Parsoid: recognize interwiki links without a target page
9286 !! options
9287 parsoid=wt2html,wt2wt,html2html
9288 !! wikitext
9289 [[:es:]]
9290
9291 [[:ko:]]
9292 !! html/php
9293 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9294 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9295 </p>
9296 !! html/parsoid
9297 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9298 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9299 !! end
9300
9301 !! test
9302 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9303 !! wikitext
9304 [[mi:Foo]]
9305 !! html/php
9306 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9307 </p>
9308 !! html/parsoid
9309 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9310 !! end
9311
9312 !! test
9313 Interlanguage link with preceding local interwiki link (T70085)
9314 !! options
9315 parsoid=wt2html,wt2wt,html2html
9316 !! wikitext
9317 Blah blah blah
9318 [[local:es:Spanish]]
9319 !! html/php
9320 <p>Blah blah blah
9321 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9322 </p>
9323 !! html/parsoid
9324 <p>Blah blah blah
9325 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9326 !! end
9327
9328 !! test
9329 Looks like an interlanguage link, but is actually a local interwiki
9330 !! options
9331 parsoid=wt2html,wt2wt,html2html
9332 !! wikitext
9333 Blah blah blah
9334 [[mi:Template:Foo]]
9335 !! html/php
9336 <p>Blah blah blah
9337 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9338 </p>
9339 !! html/parsoid
9340 <p>Blah blah blah
9341 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9342 !! end
9343
9344 ###
9345 ### Redirects, Parsoid-only
9346 ###
9347
9348 !! test
9349 1. Simple redirect to page
9350 !! wikitext
9351 #REDIRECT [[Main Page]]
9352 !! html/parsoid
9353 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9354 !! end
9355
9356 !! test
9357 2. Other redirect variants
9358 !! wikitext
9359 #REDIRECT [[Main_Page]]
9360 !! html/parsoid
9361 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9362 !! end
9363
9364 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9365 # This tests the Parsoid bail-out code.
9366 !! test
9367 3. Other redirect variants
9368 !! options
9369 parsoid=wt2html
9370 !! wikitext
9371 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9372 !! html/parsoid
9373 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
9374 !! end
9375
9376 !! test
9377 4. Redirect to a templated destination
9378 !! wikitext
9379 #REDIRECT [[{{echo|Foo}}bar]]
9380 !! html/parsoid
9381 <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"}]]}'/>
9382 !! end
9383
9384 !! test
9385 Empty redirect
9386 !! options
9387 parsoid=wt2html,wt2wt
9388 !! wikitext
9389 #REDIRECT [[]]
9390 !! html/parsoid
9391 <ol>
9392 <li>REDIRECT [[]]</li></ol>
9393 !! end
9394
9395 !! test
9396 Optional colon in #REDIRECT
9397 !! options
9398 # the colon is archaic syntax. we support it for wt2html, but we
9399 # don't care that it roundtrips back to the modern syntax.
9400 parsoid=wt2html,html2html
9401 !! wikitext
9402 #REDIRECT:[[Main Page]]
9403 !! html/parsoid
9404 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9405 !! end
9406
9407 !! test
9408 Whitespace in #REDIRECT with optional colon
9409 !! options
9410 # the colon and gratuitous whitespace is archaic syntax. we support
9411 # it for wt2html, but we don't care that it roundtrips back to the
9412 # modern syntax (without extra whitespace)
9413 parsoid=wt2html,html2html
9414 !! wikitext
9415
9416 #REDIRECT
9417 :
9418 [[Main Page]]
9419 !! html/parsoid
9420 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9421 !! end
9422
9423 !! test
9424 Piped link in #REDIRECT
9425 !! options
9426 # content after piped link is ignored. we support this syntax,
9427 # but don't care that the piped link is lost when we roundtrip this.
9428 parsoid=wt2html
9429 !! wikitext
9430 #REDIRECT [[Main Page|bar]]
9431 !! html/parsoid
9432 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9433 !! end
9434
9435 !! test
9436 Redirect to category (T104502)
9437 !! options
9438 parsoid=wt2html,wt2wt
9439 !! wikitext
9440 #REDIRECT [[Category:Foo]]
9441 !! html/parsoid
9442 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9443 !! end
9444
9445 !! test
9446 Redirect to category with URL encoding (T104502)
9447 !! options
9448 parsoid=wt2html
9449 !! wikitext
9450 #REDIRECT [[Category%3AFoo]]
9451 !! html/parsoid
9452 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9453 !! end
9454
9455 !! test
9456 Redirect to category page
9457 !! wikitext
9458 #REDIRECT [[:Category:Foo]]
9459 !! html/parsoid
9460 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9461 !! end
9462
9463 !! test
9464 Redirect to image page (1)
9465 !! wikitext
9466 #REDIRECT [[File:Wiki.png]]
9467 !! html/parsoid
9468 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9469 !! end
9470
9471 !! test
9472 Redirect to image page (2)
9473 !! wikitext
9474 #REDIRECT [[Image:Wiki.png]]
9475 !! html/parsoid
9476 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9477 !! end
9478
9479 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9480 # Next test confirms this.
9481 !! test
9482 Redirect to language (1) (T104918)
9483 !! options
9484 parsoid=wt2html,wt2wt,html2html
9485 !! wikitext
9486 #REDIRECT [[en:File:Wiki.png]]
9487 !! html/parsoid
9488 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9489 !! end
9490
9491 !! test
9492 Redirect to language (2) (T104918)
9493 !! wikitext
9494 #REDIRECT [[:en:File:Wiki.png]]
9495 !! html/parsoid
9496 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9497 !! end
9498
9499 !! test
9500 Redirect to interwiki (T104918)
9501 !! wikitext
9502 #REDIRECT [[meatball:File:Wiki.png]]
9503 !! html/parsoid
9504 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9505 !! end
9506
9507 !! test
9508 Non-English #REDIRECT
9509 !! options
9510 language=is
9511 !! wikitext
9512 #TILVÍSUN [[Main Page]]
9513 !! html/parsoid
9514 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9515 !! end
9516
9517 !! test
9518 Redirect syntax under text isn't considered a redirect
9519 !! wikitext
9520 some text
9521
9522 #redirect [[Main Page]]
9523 !! html/parsoid
9524 <p>some text</p>
9525 <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>
9526 !! end
9527
9528 !! test
9529 New redirect
9530 !! options
9531 parsoid=html2wt
9532 !! html/parsoid
9533 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9534 !! wikitext
9535 #REDIRECT [[Foo]]
9536 Foo
9537 !! end
9538
9539 !! test
9540 Redirect followed by block on the same line
9541 !! options
9542 parsoid=wt2html
9543 !! wikitext
9544 #REDIRECT [[Main Page]]<!-- haha -->==hi==
9545 !! html/parsoid
9546 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi">hi</h2>
9547 !! end
9548
9549 !! test
9550 Redirect followed by a newline
9551 !! wikitext
9552 #REDIRECT [[Main Page]]
9553 A newline
9554 !! html/parsoid
9555 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9556 <p>A newline</p>
9557 !! end
9558
9559 !! test
9560 Redirect followed by multiple newlines
9561 !! wikitext
9562 #REDIRECT [[Main Page]]
9563
9564
9565 A newline
9566 !! html/parsoid
9567 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9568
9569 <p><br/>
9570 A newline</p>
9571 !! end
9572
9573 !! test
9574 Drop duplicate redirects
9575 !! options
9576 parsoid=html2wt
9577 !! html/parsoid
9578 <link rel="mw:PageProp/redirect" href="./Foo"/>
9579 <link rel="mw:PageProp/redirect" href="./Bar"/>
9580 <link rel="mw:PageProp/redirect" href="./Baz"/>
9581 !! wikitext
9582 #REDIRECT [[Foo]]
9583 !! end
9584
9585 ##
9586 ## XHTML tidiness
9587 ###
9588
9589 !! test
9590 <br> to <br />
9591 !! wikitext
9592 1<br>2<br />3
9593 !! html
9594 <p>1<br />2<br />3
9595 </p>
9596 !! end
9597
9598 !! test
9599 Broken br tag sanitization
9600 !! wikitext
9601 </br>
9602 !! html/php
9603 <p>&lt;/br&gt;
9604 </p>
9605 !! end
9606
9607 # TODO: Fix html2html mode (T53055)!
9608 !! test
9609 Parsoid: Broken br tag recognition
9610 !! options
9611 parsoid=wt2html
9612 !! wikitext
9613 </br>
9614
9615 <br/ >
9616 !! html+tidy
9617 <p><br />
9618 </p><p><br />
9619 </p>
9620 !! end
9621
9622 !! test
9623 Incorrecly removing closing slashes from correctly formed XHTML
9624 !! wikitext
9625 <br style="clear:both;" />
9626 !! html
9627 <p><br style="clear:both;" />
9628 </p>
9629 !! end
9630
9631 !! test
9632 Failing to transform badly formed HTML into correct XHTML
9633 !! wikitext
9634 <br style="clear: left;">
9635 <br style="clear: right;">
9636 <br style="clear: both;">
9637 !! html
9638 <p><br style="clear: left;" />
9639 <br style="clear: right;" />
9640 <br style="clear: both;" />
9641 </p>
9642 !!end
9643
9644 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9645 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9646 !! test
9647 Handling html with a div self-closing tag
9648 !! wikitext
9649 <div title />
9650 <div title/>
9651 <div title/ >
9652 <div title=bar />
9653 <div title=bar/>
9654 <div title=bar/ >
9655 !! html/php
9656 <p>&lt;div title /&gt;
9657 &lt;div title/&gt;
9658 </p>
9659 <div>
9660 <p>&lt;div title=bar /&gt;
9661 &lt;div title=bar/&gt;
9662 </p>
9663 <div title="bar/"></div>
9664 </div>
9665
9666 !! html/parsoid
9667 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9668 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9669 <div title="" data-parsoid='{"stx":"html","autoInsertedEnd":true}'>
9670 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9671 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9672 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div></div>
9673 !! end
9674
9675 !! test
9676 Elements with solidus in various attribute positions
9677 !! options
9678 parsoid=wt2html,html2html
9679 !! wikitext
9680 <div cla/ss="123">ha</div>
9681
9682 <div / class="123">ha</div>
9683
9684 <div class= / "123">ha</div>
9685 !! html/php+tidy
9686 <div>ha</div>
9687 <div class="123">ha</div>
9688 <div class="/">ha</div>
9689 !! html/parsoid
9690 <div data-parsoid='{"stx":"html","a":{"cla":null,"ss":null},"sa":{"cla":"","ss":"123"}}'>ha</div>
9691
9692 <div class="123" data-parsoid='{"stx":"html"}'>ha</div>
9693
9694 <div class="/" data-parsoid='{"stx":"html","a":{"\"123\"":null},"sa":{"\"123\"":""}}'>ha</div>
9695 !! end
9696
9697 !! test
9698 Handling html with a br self-closing tag
9699 !! wikitext
9700 <br title />
9701 <br title/>
9702 <br title/ >
9703 <br title=bar />
9704 <br title=bar/>
9705 <br title=bar/ >
9706 !! html/php
9707 <p><br title="" />
9708 <br title="" />
9709 <br />
9710 <br title="bar" />
9711 <br title="bar" />
9712 <br title="bar/" />
9713 </p>
9714 !! html/parsoid
9715 <p><br title="" />
9716 <br title="" />
9717 <br title="" />
9718 <br title="bar" />
9719 <br title="bar" />
9720 <br title="bar/" />
9721 </p>
9722 !! end
9723
9724 !! test
9725 Horizontal ruler (should it add that extra space?)
9726 !! wikitext
9727 <hr>
9728 <hr >
9729 foo <hr
9730 > bar
9731 !! html+tidy
9732 <hr />
9733 <hr /><p>
9734 foo </p><hr /><p> bar
9735 </p>
9736 !! end
9737
9738 !! test
9739 Horizontal ruler -- 4+ dashes render hr
9740 !! wikitext
9741 ----
9742 !! html
9743 <hr />
9744
9745 !! end
9746
9747 !! test
9748 Horizontal ruler -- eats additional dashes on the same line
9749 !! wikitext
9750 ---------
9751 !! html
9752 <hr />
9753
9754 !! end
9755
9756 !! test
9757 Horizontal ruler -- does not collapse dashes on consecutive lines
9758 !! wikitext
9759 ----
9760 ----
9761 !! html
9762 <hr />
9763 <hr />
9764
9765 !! end
9766
9767 !! test
9768 Horizontal ruler -- <4 dashes render as plain text
9769 !! wikitext
9770 ---
9771 !! html
9772 <p>---
9773 </p>
9774 !! end
9775
9776 !! test
9777 Horizontal ruler -- Supports content following dashes on same line
9778 !! wikitext
9779 ---- Foo
9780 !! html
9781 <hr /> Foo
9782
9783 !! html+tidy
9784 <hr /><p> Foo
9785 </p>
9786 !! end
9787
9788 ###
9789 ### Block-level elements
9790 ###
9791 !! test
9792 Common list
9793 !! wikitext
9794 *Common list
9795 *item 2
9796 *item 3
9797 !! html
9798 <ul><li>Common list</li>
9799 <li>item 2</li>
9800 <li>item 3</li></ul>
9801
9802 !! end
9803
9804 !! test
9805 Numbered list
9806 !! wikitext
9807 #Numbered list
9808 #item 2
9809 #item 3
9810 !! html
9811 <ol><li>Numbered list</li>
9812 <li>item 2</li>
9813 <li>item 3</li></ol>
9814
9815 !! end
9816
9817 # the switch from level 3 to ordered should not introduce a newline between
9818 !! test
9819 Mixed list
9820 !! wikitext
9821 *Mixed list
9822 *#with numbers
9823 **and bullets
9824 *#and numbers
9825 *bullets again
9826 **bullet level 2
9827 ***bullet level 3
9828 ***#Number on level 4
9829 **bullet level 2
9830 **#Number on level 3
9831 **#Number on level 3
9832 *#number level 2
9833 *Level 1
9834 ***Level 3
9835 #**Level 3, but ordered
9836 !! html
9837 <ul><li>Mixed list
9838 <ol><li>with numbers</li></ol>
9839 <ul><li>and bullets</li></ul>
9840 <ol><li>and numbers</li></ol></li>
9841 <li>bullets again
9842 <ul><li>bullet level 2
9843 <ul><li>bullet level 3
9844 <ol><li>Number on level 4</li></ol></li></ul></li>
9845 <li>bullet level 2
9846 <ol><li>Number on level 3</li>
9847 <li>Number on level 3</li></ol></li></ul>
9848 <ol><li>number level 2</li></ol></li>
9849 <li>Level 1
9850 <ul><li><ul><li>Level 3</li></ul></li></ul></li></ul>
9851 <ol><li><ul><li><ul><li>Level 3, but ordered</li></ul></li></ul></li></ol>
9852
9853 !! end
9854
9855 !! test
9856 1. Nested mixed wikitext and html list
9857 !! wikitext
9858 *hi
9859 *<ul><li>ho</li></ul>
9860 *hi
9861 **ho
9862 !! html/php
9863 <ul><li>hi</li>
9864 <li><ul><li>ho</li></ul></li>
9865 <li>hi
9866 <ul><li>ho</li></ul></li></ul>
9867
9868 !! html/parsoid
9869 <ul><li>hi</li>
9870 <li><ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9871 <li>hi
9872 <ul><li>ho</li></ul></li></ul>
9873 !! end
9874
9875 !! test
9876 2. Nested mixed wikitext and html list (incompatible)
9877 !! wikitext
9878 ;hi
9879 :{{echo|<li>ho</li>}}
9880 !! html/php
9881 <dl><dt>hi</dt>
9882 <dd><li>ho</li></dd></dl>
9883
9884 !! html/parsoid
9885 <dl><dt>hi</dt>
9886 <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>
9887 !! end
9888
9889 !! test
9890 Nested lists 1
9891 !! wikitext
9892 *foo
9893 **bar
9894 !! html
9895 <ul><li>foo
9896 <ul><li>bar</li></ul></li></ul>
9897
9898 !! end
9899
9900 !! test
9901 Nested lists 2
9902 !! wikitext
9903 **foo
9904 *bar
9905 !! html
9906 <ul><li><ul><li>foo</li></ul></li>
9907 <li>bar</li></ul>
9908
9909 !! end
9910
9911 !! test
9912 Nested lists 3 (first element empty)
9913 !! wikitext
9914 *
9915 **bar
9916 !! html
9917 <ul><li>
9918 <ul><li>bar</li></ul></li></ul>
9919
9920 !! end
9921
9922 !! test
9923 Nested lists 4 (first element empty)
9924 !! wikitext
9925 **
9926 *bar
9927 !! html
9928 <ul><li><ul><li></li></ul></li>
9929 <li>bar</li></ul>
9930
9931 !! end
9932
9933 !! test
9934 Nested lists 5 (both elements empty)
9935 !! wikitext
9936 **
9937 *
9938 !! html
9939 <ul><li><ul><li></li></ul></li>
9940 <li></li></ul>
9941
9942 !! end
9943
9944 !! test
9945 Nested lists 6 (both elements empty)
9946 !! wikitext
9947 *
9948 **
9949 !! html
9950 <ul><li>
9951 <ul><li></li></ul></li></ul>
9952
9953 !! end
9954
9955 !! test
9956 Nested lists 7 (skip initial nesting levels)
9957 !! wikitext
9958 ***foo
9959 !! html
9960 <ul><li><ul><li><ul><li>foo</li></ul></li></ul></li></ul>
9961
9962 !! end
9963
9964 !! test
9965 Nested lists 8 (multiple nesting transitions)
9966 !! wikitext
9967 *foo
9968 ***bar
9969 **baz
9970 *boo
9971 !! html
9972 <ul><li>foo
9973 <ul><li><ul><li>bar</li></ul></li>
9974 <li>baz</li></ul></li>
9975 <li>boo</li></ul>
9976
9977 !! end
9978
9979 # XXX this test should be moved to citeParserTests, since it depends
9980 # on the Cite extension, which is "built in" to Parsoid.
9981 !! test
9982 Nested lists 9 (extension interaction)
9983 !! wikitext
9984 *<references />
9985 !! html/php+tidy-DISABLED
9986 <ul><li class="mw-empty-elt"></li></ul>
9987 !! html/parsoid
9988 <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>
9989 !! end
9990
9991 !! test
9992 1. Lists with start-of-line-transparent tokens before bullets: Comments
9993 !! wikitext
9994 *foo
9995 *<!--cmt-->bar
9996 <!--cmt-->*baz
9997 !! html
9998 <ul><li>foo</li>
9999 <li>bar</li>
10000 <li>baz</li></ul>
10001
10002 !! end
10003
10004 !! test
10005 Nested lists 10 (list and span siblings: wt2wt regression)
10006 !! wikitext
10007 *a <span>x</span>
10008 **b <span>y</span>
10009 !! html/parsoid
10010 <ul><li>a <span>x</span>
10011 <ul><li>b <span>y</span></li></ul></li></ul>
10012 !! end
10013
10014 !! test
10015 2. Lists with start-of-line-transparent tokens before bullets: Template close
10016 !! wikitext
10017 *foo {{echo|bar
10018 }}*baz
10019 !! html
10020 <ul><li>foo bar</li>
10021 <li>baz</li></ul>
10022
10023 !! end
10024
10025 !! test
10026 List items are not parsed correctly following a <pre> block (T2785)
10027 !! wikitext
10028 *<pre>foo</pre>
10029 *<pre>bar</pre>
10030 *zar
10031 !! html/php
10032 <ul><li><pre>foo</pre></li>
10033 <li><pre>bar</pre></li>
10034 <li>zar</li></ul>
10035
10036 !! html/parsoid
10037 <ul><li><pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
10038 <li><pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
10039 <li>zar</li></ul>
10040 !! end
10041
10042 # FIXME: Might benefit from a html/parsoid since this has a template
10043 !! test
10044 List items from template
10045 !! wikitext
10046
10047 {{inner list}}
10048 *item 2
10049
10050 *item 0
10051 {{inner list}}
10052 *item 2
10053
10054 *item 0
10055 *notSOL{{inner list}}
10056 *item 2
10057 !! html
10058 <ul><li>item 1</li>
10059 <li>item 2</li></ul>
10060 <ul><li>item 0</li>
10061 <li>item 1</li>
10062 <li>item 2</li></ul>
10063 <ul><li>item 0</li>
10064 <li>notSOL</li>
10065 <li>item 1</li>
10066 <li>item 2</li></ul>
10067
10068 !! end
10069
10070 !! test
10071 List interrupted by empty line or heading
10072 !! wikitext
10073 *foo
10074
10075 **bar
10076 ==A heading==
10077 *Another list item
10078 !! html
10079 <ul><li>foo</li></ul>
10080 <ul><li><ul><li>bar</li></ul></li></ul>
10081 <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>
10082 <ul><li>Another list item</li></ul>
10083
10084 !!end
10085
10086 !! test
10087 Multiple list tags generated by templates
10088 !! wikitext
10089 {{echo|<li>}}a
10090 {{echo|<li>}}b
10091 {{echo|<li>}}c
10092 !! html
10093 <li>a
10094 <li>b
10095 <li>c</li>
10096 </li>
10097 </li>
10098
10099
10100 !! html+tidy
10101 <li>a
10102 </li><li>b
10103 </li><li>c
10104 </li>
10105 !! html/parsoid
10106 <li about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;li>"}},"i":0}},"a"]}'>a</li>
10107 <li about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;li>"}},"i":0}},"b"]}'>b</li>
10108 <li about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;li>"}},"i":0}},"c"]}'>c</li>
10109 !! end
10110
10111 !! test
10112 Multiple newlines in between HTML list items don't induce paragraph wrapping
10113 !! wikitext
10114 <ul>
10115 <li>hi</li>
10116
10117
10118
10119
10120 <li>ho</li>
10121 </ul>
10122
10123 <dl>
10124 <dt>hi</dt>
10125 <dd>ho<div>123</div>
10126 </dd>
10127
10128
10129 </dl>
10130 !! html/php+tidy
10131 <ul>
10132 <li>hi</li>
10133
10134
10135
10136
10137 <li>ho</li>
10138 </ul>
10139 <dl>
10140 <dt>hi</dt>
10141 <dd>ho<div>123</div>
10142 </dd>
10143
10144
10145 </dl>
10146 !! end
10147
10148 !!test
10149 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
10150 !! wikitext
10151 *a
10152 <!--This line will NOT split the list-->
10153 *b
10154 <!--This line will NOT split the list either-->
10155 *c
10156 <!--foo--> <!----> <!--This line NOT split the list either-->
10157 *d
10158 !! html
10159 <ul><li>a</li>
10160 <li>b</li>
10161 <li>c</li>
10162 <li>d</li></ul>
10163
10164 !!end
10165
10166 !!test
10167 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
10168 !! wikitext
10169 *a
10170 <!--This line will NOT split the list-->
10171 *b
10172 <!--This line will NOT split the list either-->
10173 *c
10174 <!--foo--> <!----> <!--This line NOT split the list
10175 either-->
10176 *d
10177 !! html
10178 <ul><li>a</li>
10179 <li>b</li>
10180 <li>c</li>
10181 <li>d</li></ul>
10182
10183 !!end
10184
10185 # FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack
10186 # That pass could possibly be removed.
10187 !!test
10188 Test the li-hack (a hack from Tidy days, but doesn't work as advertised with Remex)
10189 !!options
10190 parsoid=wt2html,wt2wt
10191 !! wikitext
10192 *foo
10193 *<li>li-hack
10194 *{{echo|<li>templated li-hack}}
10195 *<!--foo--><li> unsupported li-hack with preceding comments
10196
10197 <ul>
10198 <li><li>not a li-hack
10199 </li>
10200 </ul>
10201 !! html+tidy
10202 <ul><li>foo</li>
10203 <li class="mw-empty-elt"></li><li>li-hack</li>
10204 <li class="mw-empty-elt"></li><li>templated li-hack</li>
10205 <li class="mw-empty-elt"></li><li> unsupported li-hack with preceding comments</li></ul>
10206 <ul>
10207 <li class="mw-empty-elt"></li><li>not a li-hack
10208 </li>
10209 </ul>
10210 !! html/parsoid
10211 <ul><li> foo</li>
10212 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"*"}'>li-hack</li>
10213 <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>
10214 <li data-parsoid='{"autoInsertedEnd":true}'><!--foo--></li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>unsupported li-hack with preceding comments</li></ul>
10215
10216 <ul data-parsoid='{"stx":"html"}'>
10217 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
10218 </li>
10219 </ul>
10220
10221 !!end
10222
10223 !! test
10224 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
10225 !! wikitext
10226 #foo
10227 ##bar
10228
10229 *foo
10230 **bar
10231
10232 :foo
10233 ::bar
10234 !! html/php+tidy
10235 <ol><li>foo
10236 <ol><li>bar</li></ol></li></ol>
10237 <ul><li>foo
10238 <ul><li>bar</li></ul></li></ul>
10239 <dl><dd>foo
10240 <dl><dd>bar</dd></dl></dd></dl>
10241 !! html/parsoid
10242 <ol>
10243 <li>foo<ol>
10244 <li>bar</li>
10245 </ol></li>
10246 </ol><ul>
10247 <li>foo<ul>
10248 <li>bar</li>
10249 </ul></li>
10250 </ul><dl>
10251 <dd>foo<dl>
10252 <dd>bar</dd>
10253 </dl></dd>
10254 </dl>
10255 !! end
10256
10257 !! test
10258 Parsoid: Test of whitespace serialization with Templated bullets
10259 !! options
10260 parsoid=wt2html
10261 !! wikitext
10262 * {{bullet}}
10263 !! html/parsoid
10264 <ul>
10265 <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>
10266 </ul>
10267 !! end
10268
10269 # ------------------------------------------------------------------------
10270 # The next set of tests are about Parsoid's ability to handle badly nested
10271 # tags (parse, minimize scope of fixup, and roundtrip back)
10272 # ------------------------------------------------------------------------
10273
10274 # Remex and Parsoid output stems from list handling diffs because Parsoid & PHP parser.
10275 # Parsoid's list handling is more aware of block structure.
10276 !! test
10277 Unbalanced closing block tags break a list
10278 !! wikitext
10279 <div>
10280 *a</div><div>
10281 *b</div>
10282 !! html+tidy
10283 <div>
10284 <ul><li>a</li></ul></div><div>
10285 <li>b</li></div>
10286 !! html/parsoid
10287 <div><ul>
10288 <li>a</li>
10289 </ul></div>
10290 <div><ul>
10291 <li>b</li>
10292 </ul></div>
10293 !! end
10294
10295 !! test
10296 Unbalanced closing non-block tags don't break a list
10297 !! options
10298 parsoid=wt2html,html2html
10299 !! wikitext
10300 <span>
10301 *a</span><span>
10302 *b</span>
10303 !! html/php+tidy
10304 <p><span>
10305 </span></p>
10306 <ul><li>a<span></span></li>
10307 <li>b</li></ul>
10308 !! html/parsoid
10309 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'></span></p>
10310 <ul><li>a<span data-parsoid='{"stx":"html","autoInsertedEnd":true}'></span></li>
10311 <li>b</li></ul>
10312 !! end
10313
10314 # Parsoid does some post-dom-building cleanup
10315 # which is why its output differs from Remex.
10316 !! test
10317 Unclosed formatting tags that straddle lists are closed and reopened
10318 !! options
10319 parsoid=wt2html,wt2wt,html2html
10320 !! wikitext
10321 #<s> a
10322 #b </s>
10323 !! html/php+tidy
10324 <ol><li><s> a</s></li><s>
10325 </s><li><s>b </s></li></ol>
10326 !! html/parsoid
10327 <ol><li><s> a</s></li>
10328 <li><s>b </s></li></ol>
10329 !! end
10330
10331 # Output is ugly because of all the misnested tag fixups.
10332 !! test
10333 1. List embedded in a formatting tag
10334 !! wikitext
10335 <small>
10336 *foo
10337 </small>
10338 !! html/php+tidy
10339 <p><small>
10340 </small></p><small><ul><li>foo</li></ul></small><small></small><p><small></small>
10341 </p>
10342 !! html/parsoid
10343 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
10344 <ul><li data-parsoid='{}'>foo</li></ul></small>
10345 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p>
10346 !! end
10347
10348 # Output is ugly because of all the misnested tag fixups.
10349 !! test
10350 2. List embedded in a formatting tag in a misnested way
10351 !! wikitext
10352 <small>
10353 *a
10354 *b</small>
10355 !! html/php+tidy
10356 <p><small>
10357 </small></p><small></small><ul><small><li>a</li>
10358 </small><li><small>b</small></li></ul>
10359 !! html/parsoid
10360 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p>
10361 <ul><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'><li>a</li></small>
10362 <li><small data-parsoid='{"stx":"html","autoInsertedStart":true}'>b</small></li></ul>
10363 !! end
10364
10365 # Output is ugly because of all the misnested tag fixups.
10366 !! test
10367 3. List embedded in a formatting tag in a misnested way
10368 !! wikitext
10369 <small>
10370
10371 ** 123</small>
10372 !! html/php+tidy
10373 <p><small>
10374 </small></p><small></small><ul><small></small><li><small></small><ul><small></small><li><small>123</small></li></ul></li></ul>
10375 !! html/parsoid
10376 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p>
10377
10378 <ul><li><ul><li data-parsoid='{}'><small data-parsoid='{"stx":"html","autoInsertedStart":true}'> 123</small></li></ul></li></ul>
10379 !! end
10380
10381 ###
10382 ### Magic Words
10383 ###
10384
10385 # Note that the current date is hard-coded as
10386 # 1970-01-01T00:02:03Z (a Thursday)
10387 # when running parser tests. The timezone is also fixed to GMT, so
10388 # local date will be identical to current date.
10389
10390 !! test
10391 Magic Word: {{CURRENTDAY}}
10392 !! wikitext
10393 {{CURRENTDAY}}
10394 !! html
10395 <p>1
10396 </p>
10397 !! end
10398
10399 !! test
10400 Magic Word: {{CURRENTDAY2}}
10401 !! wikitext
10402 {{CURRENTDAY2}}
10403 !! html
10404 <p>01
10405 </p>
10406 !! end
10407
10408 !! test
10409 Magic Word: {{CURRENTDAYNAME}}
10410 !! wikitext
10411 {{CURRENTDAYNAME}}
10412 !! html
10413 <p>Thursday
10414 </p>
10415 !! end
10416
10417 !! test
10418 Magic Word: {{CURRENTDOW}}
10419 !! wikitext
10420 {{CURRENTDOW}}
10421 !! html
10422 <p>4
10423 </p>
10424 !! end
10425
10426 !! test
10427 Magic Word: {{CURRENTMONTH}}
10428 !! wikitext
10429 {{CURRENTMONTH}}
10430 !! html
10431 <p>01
10432 </p>
10433 !! end
10434
10435 !! test
10436 Magic Word: {{CURRENTMONTH1}}
10437 !! wikitext
10438 {{CURRENTMONTH1}}
10439 !! html
10440 <p>1
10441 </p>
10442 !! end
10443
10444 !! test
10445 Magic Word: {{CURRENTMONTHABBREV}}
10446 !! wikitext
10447 {{CURRENTMONTHABBREV}}
10448 !! html
10449 <p>Jan
10450 </p>
10451 !! end
10452
10453 !! test
10454 Magic Word: {{CURRENTMONTHNAME}}
10455 !! wikitext
10456 {{CURRENTMONTHNAME}}
10457 !! html
10458 <p>January
10459 </p>
10460 !! end
10461
10462 !! test
10463 Magic Word: {{CURRENTMONTHNAMEGEN}}
10464 !! wikitext
10465 {{CURRENTMONTHNAMEGEN}}
10466 !! html
10467 <p>January
10468 </p>
10469 !! end
10470
10471 !! test
10472 Magic Word: {{CURRENTTIME}}
10473 !! wikitext
10474 {{CURRENTTIME}}
10475 !! html
10476 <p>00:02
10477 </p>
10478 !! end
10479
10480 !! test
10481 Magic Word: {{CURRENTHOUR}}
10482 !! wikitext
10483 {{CURRENTHOUR}}
10484 !! html
10485 <p>00
10486 </p>
10487 !! end
10488
10489 !! test
10490 Magic Word: {{CURRENTWEEK}} (T6594)
10491 !! wikitext
10492 {{CURRENTWEEK}}
10493 !! html
10494 <p>1
10495 </p>
10496 !! end
10497
10498 !! test
10499 Magic Word: {{CURRENTYEAR}}
10500 !! wikitext
10501 {{CURRENTYEAR}}
10502 !! html
10503 <p>1970
10504 </p>
10505 !! end
10506
10507 !! test
10508 Magic Word: {{CURRENTTIMESTAMP}}
10509 !! wikitext
10510 {{CURRENTTIMESTAMP}}
10511 !! html
10512 <p>19700101000203
10513 </p>
10514 !! end
10515
10516 !! test
10517 Magic Words LOCAL (UTC)
10518 !! wikitext
10519 *{{LOCALMONTH}}
10520 *{{LOCALMONTH1}}
10521 *{{LOCALMONTHNAME}}
10522 *{{LOCALMONTHNAMEGEN}}
10523 *{{LOCALMONTHABBREV}}
10524 *{{LOCALDAY}}
10525 *{{LOCALDAY2}}
10526 *{{LOCALDAYNAME}}
10527 *{{LOCALYEAR}}
10528 *{{LOCALTIME}}
10529 *{{LOCALHOUR}}
10530 *{{LOCALWEEK}}
10531 *{{LOCALDOW}}
10532 *{{LOCALTIMESTAMP}}
10533 !! html
10534 <ul><li>01</li>
10535 <li>1</li>
10536 <li>January</li>
10537 <li>January</li>
10538 <li>Jan</li>
10539 <li>1</li>
10540 <li>01</li>
10541 <li>Thursday</li>
10542 <li>1970</li>
10543 <li>00:02</li>
10544 <li>00</li>
10545 <li>1</li>
10546 <li>4</li>
10547 <li>19700101000203</li></ul>
10548
10549 !! end
10550
10551 !! test
10552 Magic Word: {{FULLPAGENAME}}
10553 !! options
10554 title=[[User:Ævar Arnfjörð Bjarmason]]
10555 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10556 !! wikitext
10557 {{FULLPAGENAME}}
10558 !! html/*
10559 <p>User:Ævar Arnfjörð Bjarmason
10560 </p>
10561 !! end
10562
10563 !! test
10564 Magic Word: {{FULLPAGENAMEE}}
10565 !! options
10566 title=[[User:Ævar Arnfjörð Bjarmason]]
10567 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10568 !! wikitext
10569 {{FULLPAGENAMEE}}
10570 !! html/*
10571 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10572 </p>
10573 !! end
10574
10575 !! test
10576 Magic Word: {{TALKSPACE}}
10577 !! options
10578 title=[[User:Ævar Arnfjörð Bjarmason]]
10579 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10580 !! wikitext
10581 {{TALKSPACE}}
10582 !! html/*
10583 <p>User talk
10584 </p>
10585 !! end
10586
10587 !! test
10588 Magic Word: {{TALKSPACE}}, same namespace
10589 !! options
10590 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10591 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10592 !! wikitext
10593 {{TALKSPACE}}
10594 !! html/*
10595 <p>User talk
10596 </p>
10597 !! end
10598
10599 !! test
10600 Magic Word: {{TALKSPACE}}, main namespace
10601 !! options
10602 title=[[Parser Test]]
10603 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10604 !! wikitext
10605 {{TALKSPACE}}
10606 !! html/*
10607 <p>Talk
10608 </p>
10609 !! end
10610
10611 !! test
10612 Magic Word: {{TALKSPACEE}}
10613 !! options
10614 title=[[User:Ævar Arnfjörð Bjarmason]]
10615 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10616 !! wikitext
10617 {{TALKSPACEE}}
10618 !! html/*
10619 <p>User_talk
10620 </p>
10621 !! end
10622
10623 !! test
10624 Magic Word: {{SUBJECTSPACE}}
10625 !! options
10626 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10627 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10628 !! wikitext
10629 {{SUBJECTSPACE}}
10630 !! html/*
10631 <p>User
10632 </p>
10633 !! end
10634
10635 !! test
10636 Magic Word: {{SUBJECTSPACE}}, same namespace
10637 !! options
10638 title=[[User:Ævar Arnfjörð Bjarmason]]
10639 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10640 !! wikitext
10641 {{SUBJECTSPACE}}
10642 !! html/*
10643 <p>User
10644 </p>
10645 !! end
10646
10647 !! test
10648 Magic Word: {{SUBJECTSPACE}}, main namespace
10649 !! options
10650 title=[[Parser Test]]
10651 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10652 !! wikitext
10653 {{SUBJECTSPACE}}
10654 !! html/*
10655
10656 !! end
10657
10658 !! test
10659 Magic Word: {{SUBJECTSPACEE}}
10660 !! options
10661 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10662 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10663 !! wikitext
10664 {{SUBJECTSPACEE}}
10665 !! html/*
10666 <p>User
10667 </p>
10668 !! end
10669
10670 !! test
10671 Magic Word: {{NAMESPACE}}
10672 !! options
10673 title=[[User:Ævar Arnfjörð Bjarmason]]
10674 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10675 !! wikitext
10676 {{NAMESPACE}}
10677 !! html/*
10678 <p>User
10679 </p>
10680 !! end
10681
10682 !! test
10683 Magic Word: {{NAMESPACEE}}
10684 !! options
10685 title=[[User:Ævar Arnfjörð Bjarmason]]
10686 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10687 !! wikitext
10688 {{NAMESPACEE}}
10689 !! html/*
10690 <p>User
10691 </p>
10692 !! end
10693
10694 !! test
10695 Magic Word: {{NAMESPACENUMBER}}
10696 !! options
10697 title=[[User:Ævar Arnfjörð Bjarmason]]
10698 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10699 !! wikitext
10700 {{NAMESPACENUMBER}}
10701 !! html/*
10702 <p>2
10703 </p>
10704 !! end
10705
10706 !! test
10707 Magic Word: {{SUBPAGENAME}}
10708 !! options
10709 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10710 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10711 !! wikitext
10712 {{SUBPAGENAME}}
10713 !! html/*
10714 <p>sub ö
10715 </p>
10716 !! end
10717
10718 !! test
10719 Magic Word: {{SUBPAGENAMEE}}
10720 !! options
10721 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10722 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10723 !! wikitext
10724 {{SUBPAGENAMEE}}
10725 !! html/*
10726 <p>sub_%C3%B6
10727 </p>
10728 !! end
10729
10730 !! test
10731 Magic Word: {{ROOTPAGENAME}}
10732 !! options
10733 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10734 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10735 !! wikitext
10736 {{ROOTPAGENAME}}
10737 !! html/*
10738 <p>Ævar Arnfjörð Bjarmason
10739 </p>
10740 !! end
10741
10742 !! test
10743 Magic Word: {{ROOTPAGENAMEE}}
10744 !! options
10745 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10746 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10747 !! wikitext
10748 {{ROOTPAGENAMEE}}
10749 !! html/*
10750 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10751 </p>
10752 !! end
10753
10754 !! test
10755 Magic Word: {{BASEPAGENAME}}
10756 !! options
10757 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10758 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10759 !! wikitext
10760 {{BASEPAGENAME}}
10761 !! html/*
10762 <p>Ævar Arnfjörð Bjarmason
10763 </p>
10764 !! end
10765
10766 !! test
10767 Magic Word: {{BASEPAGENAMEE}}
10768 !! options
10769 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10770 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10771 !! wikitext
10772 {{BASEPAGENAMEE}}
10773 !! html/*
10774 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10775 </p>
10776 !! end
10777
10778 !! test
10779 Magic Word: {{TALKPAGENAME}}
10780 !! options
10781 title=[[User:Ævar Arnfjörð Bjarmason]]
10782 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10783 !! wikitext
10784 {{TALKPAGENAME}}
10785 !! html/*
10786 <p>User talk:Ævar Arnfjörð Bjarmason
10787 </p>
10788 !! end
10789
10790 !! test
10791 Magic Word: {{TALKPAGENAMEE}}
10792 !! options
10793 title=[[User:Ævar Arnfjörð Bjarmason]]
10794 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10795 !! wikitext
10796 {{TALKPAGENAMEE}}
10797 !! html/*
10798 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10799 </p>
10800 !! end
10801
10802 !! test
10803 Magic Word: {{SUBJECTPAGENAME}}
10804 !! options
10805 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10806 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10807 !! wikitext
10808 {{SUBJECTPAGENAME}}
10809 !! html/*
10810 <p>User:Ævar Arnfjörð Bjarmason
10811 </p>
10812 !! end
10813
10814 !! test
10815 Magic Word: {{SUBJECTPAGENAMEE}}
10816 !! options
10817 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10818 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10819 !! wikitext
10820 {{SUBJECTPAGENAMEE}}
10821 !! html/*
10822 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10823 </p>
10824 !! end
10825
10826 !! test
10827 Magic Word: {{NUMBEROFFILES}}
10828 !! options
10829 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10830 !! wikitext
10831 {{NUMBEROFFILES}}
10832 !! html/*
10833 <p>7
10834 </p>
10835 !! end
10836
10837 !! test
10838 Magic Word: {{PAGENAME}}
10839 !! options
10840 title=[[User:Ævar Arnfjörð Bjarmason]]
10841 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10842 !! wikitext
10843 {{PAGENAME}}
10844 !! html/*
10845 <p>Ævar Arnfjörð Bjarmason
10846 </p>
10847 !! end
10848
10849 !! test
10850 Magic Word: {{PAGENAME}} with metacharacters
10851 !! options
10852 title=[['foo & bar = baz']]
10853 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10854 !! wikitext
10855 ''{{PAGENAME}}''
10856 !! html+tidy
10857 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10858 </p>
10859 !! end
10860
10861 !! test
10862 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10863 !! options
10864 title=[[*RFC 1234 http://example.com/]]
10865 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10866 !! wikitext
10867 {{PAGENAME}}
10868 !! html+tidy
10869 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10870 </p>
10871 !! end
10872
10873 !! test
10874 Magic Word: {{PAGENAMEE}}
10875 !! options
10876 title=[[User:Ævar Arnfjörð Bjarmason]]
10877 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10878 !! wikitext
10879 {{PAGENAMEE}}
10880 !! html/*
10881 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10882 </p>
10883 !! end
10884
10885 !! test
10886 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10887 !! options
10888 title=[[*RFC 1234 http://example.com/]]
10889 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10890 !! wikitext
10891 {{PAGENAMEE}}
10892 !! html+tidy
10893 <p>&#42;RFC_1234_http&#58;//example.com/
10894 </p>
10895 !! end
10896
10897 !! test
10898 Magic Word: {{REVISIONID}}
10899 !! options
10900 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10901 showflags
10902 !! wikitext
10903 {{REVISIONID}}
10904 !! html/*
10905 <p>1337
10906 </p>
10907 flags=vary-revision-id
10908 !! end
10909
10910 !! test
10911 Magic Word: {{SCRIPTPATH}}
10912 !! options
10913 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10914 !! wikitext
10915 {{SCRIPTPATH}}
10916 !! html/*
10917
10918 !! end
10919
10920 !! test
10921 Magic Word: {{STYLEPATH}}
10922 !! options
10923 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10924 !! wikitext
10925 {{STYLEPATH}}
10926 !! html/*
10927 <p>/skins
10928 </p>
10929 !! end
10930
10931 !! test
10932 Magic Word: {{SERVER}}
10933 !! options
10934 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10935 !! wikitext
10936 {{SERVER}}
10937 !! html/*
10938 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10939 </p>
10940 !! end
10941
10942 !! test
10943 Magic Word: {{SERVERNAME}}
10944 !! options
10945 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10946 !! wikitext
10947 {{SERVERNAME}}
10948 !! html/*
10949 <p>example.org
10950 </p>
10951 !! end
10952
10953 !! test
10954 Magic Word: {{SITENAME}}
10955 !! options
10956 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10957 !! wikitext
10958 {{SITENAME}}
10959 !! html/*
10960 <p>MediaWiki
10961 </p>
10962 !! end
10963
10964 !! test
10965 Magic Word: {{PAGELANGUAGE}}
10966 !! options
10967 language=fr
10968 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10969 !! wikitext
10970 {{PAGELANGUAGE}}
10971 !! html/*
10972 <p>fr
10973 </p>
10974 !! end
10975
10976 !! test
10977 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10978 !! options
10979 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10980 !! wikitext
10981 {{PAGELANGUAGE}}
10982 !! html/*
10983 <p>en
10984 </p>
10985 !! end
10986
10987 !! test
10988 Case-sensitive magic words, when cased differently, should just be template transclusions
10989 !! wikitext
10990 {{CurrentMonth}}
10991 {{currentday}}
10992 {{cURreNTweEK}}
10993 {{currentHour}}
10994 !! html
10995 <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>
10996 <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>
10997 <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>
10998 <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>
10999 </p>
11000 !! end
11001
11002 !! test
11003 Case-insensitive magic words should still work with weird casing.
11004 !! wikitext
11005 {{sErVeRNaMe}}
11006 {{LCFirst:AOEU}}
11007 {{ucFIRST:aoeu}}
11008 {{SERver}}
11009 !! html
11010 <p>example.org
11011 aOEU
11012 Aoeu
11013 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
11014 </p>
11015 !! end
11016
11017 # From plwiki:PLOS_ONE
11018 !! test
11019 Parsoid: Page property magic word with magic word contents
11020 !! options
11021 showtitle
11022 !! config
11023 wgAllowDisplayTitle=true
11024 wgRestrictDisplayTitle=false
11025 !! wikitext
11026 {{DISPLAYTITLE:''{{PAGENAME}}''}}
11027 !! html/php+tidy
11028 <i>Parser test</i>
11029
11030 !! html/parsoid
11031 <meta property="mw:PageProp/displaytitle" content="Parser test" 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;>Parser test&lt;/span>&lt;/i>"}]]}'/>
11032 !! end
11033
11034 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
11035 # But, this is a limitation of our representation and is documented in
11036 # TemplateHandler.js in processSpecialMagicWord
11037 !! test
11038 Parsoid: Template-generated DISPLAYTITLE
11039 !! wikitext
11040 {{{{echo|DISPLAYTITLE}}:Foo}}
11041 !! options
11042 showtitle
11043 !! config
11044 wgAllowDisplayTitle=true
11045 wgRestrictDisplayTitle=false
11046 !! html/php
11047 Foo
11048
11049 !! html/parsoid
11050 <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"}]]}'/>
11051 !! end
11052
11053 !! test
11054 Namespace 1 {{ns:1}}
11055 !! wikitext
11056 {{ns:1}}
11057 !! html
11058 <p>Talk
11059 </p>
11060 !! end
11061
11062 !! test
11063 Namespace 1 {{ns:01}}
11064 !! wikitext
11065 {{ns:01}}
11066 !! html
11067 <p>Talk
11068 </p>
11069 !! end
11070
11071 !! test
11072 Namespace 0 {{ns:0}} (T6783)
11073 !! wikitext
11074 {{ns:0}}
11075 !! html
11076
11077 !! end
11078
11079 !! test
11080 Namespace 0 {{ns:00}} (T6783)
11081 !! wikitext
11082 {{ns:00}}
11083 !! html
11084
11085 !! end
11086
11087 !! test
11088 Namespace -1 {{ns:-1}}
11089 !! wikitext
11090 {{ns:-1}}
11091 !! html
11092 <p>Special
11093 </p>
11094 !! end
11095
11096 !! test
11097 Namespace User {{ns:User}}
11098 !! wikitext
11099 {{ns:User}}
11100 !! html
11101 <p>User
11102 </p>
11103 !! end
11104
11105 !! test
11106 Namespace User talk {{ns:User_talk}}
11107 !! wikitext
11108 {{ns:User_talk}}
11109 !! html
11110 <p>User talk
11111 </p>
11112 !! end
11113
11114 !! test
11115 Namespace User talk {{ns:uSeR tAlK}}
11116 !! wikitext
11117 {{ns:uSeR tAlK}}
11118 !! html
11119 <p>User talk
11120 </p>
11121 !! end
11122
11123 !! test
11124 Namespace File {{ns:File}}
11125 !! wikitext
11126 {{ns:File}}
11127 !! html
11128 <p>File
11129 </p>
11130 !! end
11131
11132 !! test
11133 Namespace File {{ns:Image}}
11134 !! wikitext
11135 {{ns:Image}}
11136 !! html
11137 <p>File
11138 </p>
11139 !! end
11140
11141 !! test
11142 Namespace (lang=de) Benutzer {{ns:User}}
11143 !! options
11144 language=de
11145 !! wikitext
11146 {{ns:User}}
11147 !! html
11148 <p>Benutzer
11149 </p>
11150 !! end
11151
11152 !! test
11153 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
11154 !! options
11155 language=de
11156 !! wikitext
11157 {{ns:3}}
11158 !! html
11159 <p>Benutzer Diskussion
11160 </p>
11161 !! end
11162
11163 !! test
11164 Urlencode
11165 !! wikitext
11166 {{urlencode:hi world?!}}
11167 {{urlencode:hi world?!|WIKI}}
11168 {{urlencode:hi world?!|PATH}}
11169 {{urlencode:hi world?!|QUERY}}
11170 !! html/php
11171 <p>hi+world%3F%21
11172 hi_world%3F!
11173 hi%20world%3F%21
11174 hi+world%3F%21
11175 </p>
11176 !! end
11177
11178 !! test
11179 Magic Word: prioritize type info over data-parsoid
11180 !! options
11181 parsoid=html2wt
11182 !! html/parsoid
11183 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
11184 !! wikitext
11185 __FORCETOC__
11186 !! end
11187
11188 !! test
11189 Magic Word: serialize on separate line (parsoid)
11190 !! options
11191 parsoid=wt2wt,html2wt
11192 !! wikitext
11193 foo
11194 __NOTOC__
11195 bar
11196 !! html/parsoid
11197 foo<meta property="mw:PageProp/notoc"/>bar
11198 !! end
11199
11200 !! test
11201 Magic Word: rt non-english wikis
11202 !! options
11203 parsoid=wt2wt
11204 language=de
11205 !! wikitext
11206 __NOEDITSECTION__
11207 !! html/parsoid
11208 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
11209 !! end
11210
11211 !!test
11212 __proto__ is treated as normal wikitext (T105997)
11213 !!wikitext
11214 __proto__
11215 !!html
11216 <p>__proto__
11217 </p>
11218 !!end
11219
11220 ###
11221 ### Magic links
11222 ###
11223 !! test
11224 Magic links: internal link to RFC (T2479)
11225 !! wikitext
11226 [[RFC 123]]
11227 !! html/php
11228 <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>
11229 </p>
11230 !! html/parsoid
11231 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
11232 !! end
11233
11234 !! test
11235 Magic links: RFC (T2479)
11236 !! wikitext
11237 RFC 822
11238 !! html/php
11239 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11240 </p>
11241 !! html/parsoid
11242 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">RFC 822</a></p>
11243 !! end
11244
11245 !! test
11246 Magic links: RFC (T67278)
11247 !! wikitext
11248 This is RFC 822 but thisRFC 822 is not RFC 822linked.
11249 !! html/php
11250 <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.
11251 </p>
11252 !! html/parsoid
11253 <p>This is <a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
11254 !! end
11255
11256 !! test
11257 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
11258 !! wikitext
11259 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
11260 RFC
11261 822
11262 !! html/php
11263 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11264 RFC
11265 822
11266 </p>
11267 !! html/parsoid
11268 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink" class="external mw-magiclink">RFC <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 822</a>
11269 RFC
11270 822</p>
11271 !! end
11272
11273 !! test
11274 Magic links: ISBN (T3937)
11275 !! wikitext
11276 ISBN 0-306-40615-2
11277 !! html/php
11278 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
11279 </p>
11280 !! html/parsoid
11281 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
11282 !! end
11283
11284 !! test
11285 Magic links: ISBN (T67278)
11286 !! wikitext
11287 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
11288 !! html/php
11289 <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.
11290 </p>
11291 !! html/parsoid
11292 <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>
11293 !! end
11294
11295 !! test
11296 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
11297 !! wikitext
11298 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
11299 ISBN
11300 9780316098113
11301 ISBN 978
11302 0316098113
11303 !! html/php
11304 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
11305 ISBN
11306 9780316098113
11307 ISBN 978
11308 0316098113
11309 </p>
11310 !! html/parsoid
11311 <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>
11312 ISBN
11313 9780316098113
11314 ISBN 978
11315 0316098113</p>
11316 !! end
11317
11318 !! test
11319 Magic links: PMID incorrectly converts space to underscore
11320 !! wikitext
11321 PMID 1234
11322 !! html/php
11323 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11324 </p>
11325 !! html/parsoid
11326 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID 1234</a></p>
11327 !! end
11328
11329 !! test
11330 Magic links: PMID (T67278)
11331 !! wikitext
11332 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
11333 !! html/php
11334 <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.
11335 </p>
11336 !! html/parsoid
11337 <p>This is <a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID 1234</a> but thisPMID 1234 is not PMID 1234linked.</p>
11338 !! end
11339
11340 !! test
11341 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
11342 !! wikitext
11343 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
11344 PMID
11345 1234
11346 !! html/php
11347 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11348 PMID
11349 1234
11350 </p>
11351 !! html/parsoid
11352 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID <span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#0160;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#xA0;","srcContent":" "}'> </span><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#Xa0;","srcContent":" "}'> </span> 1234</a>
11353 PMID
11354 1234</p>
11355 !! end
11356
11357 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
11358 # since these are ExtLinkText, not MagicLinkText
11359 !! test
11360 Magic links: use appropriate serialization for "almost" magic links.
11361 !! wikitext
11362 X[[Special:BookSources/0978739256|foo]]
11363
11364 X[https://tools.ietf.org/html/rfc1234 foo]
11365 !! html/php
11366 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
11367 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
11368 </p>
11369 !! html/parsoid
11370 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11371 <p>X<a rel="mw:ExtLink" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
11372 !! end
11373
11374 !! test
11375 Magic links: All disabled (T47942)
11376 !! options
11377 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11378 !! wikitext
11379 ISBN 0-306-40615-2
11380 PMID 1234
11381 RFC 4321
11382 !! html/php
11383 <p>ISBN 0-306-40615-2
11384 PMID 1234
11385 RFC 4321
11386 </p>
11387 !! end
11388
11389 ###
11390 ### Templates
11391 ####
11392
11393 !! test
11394 Nonexistent template
11395 !! wikitext
11396 {{thistemplatedoesnotexist}}
11397 !! html
11398 <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>
11399 </p>
11400 !! end
11401
11402 !! test
11403 Template with invalid target containing tags
11404 !! wikitext
11405 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11406 !! html
11407 <p>{{a<b>b</b>|foo|a=b|a = b}}
11408 </p>
11409 !! end
11410
11411 !! test
11412 Template with invalid target containing unclosed tag
11413 !! wikitext
11414 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11415 !! html
11416 <p>{{a<b>|foo|a=b|a = b}}</b>
11417 </p>
11418 !! end
11419
11420 !! test
11421 Template with invalid target containing wikilink
11422 !! wikitext
11423 {{[[Main Page]]}}
11424 !! html/php
11425 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11426 </p>
11427 !! html/parsoid
11428 <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>
11429 !! end
11430
11431 !! test
11432 Template with just whitespace in it, T70421
11433 !! wikitext
11434 {{echo|{{ }}}}
11435 !! html/parsoid
11436 <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>
11437 !! end
11438
11439 !! article
11440 Template:test
11441 !! text
11442 This is a test template
11443 !! endarticle
11444
11445 !! test
11446 Simple template
11447 !! wikitext
11448 {{test}}
11449 !! html
11450 <p>This is a test template
11451 </p>
11452 !! end
11453
11454 !! test
11455 Template with explicit namespace
11456 !! wikitext
11457 {{Template:test}}
11458 !! html
11459 <p>This is a test template
11460 </p>
11461 !! end
11462
11463
11464 !! article
11465 Template:paramtest
11466 !! text
11467 This is a test template with parameter {{{param}}}
11468 !! endarticle
11469
11470 !! test
11471 Template parameter
11472 !! wikitext
11473 {{paramtest|param=foo}}
11474 !! html
11475 <p>This is a test template with parameter foo
11476 </p>
11477 !! end
11478
11479 !! article
11480 Template:paramtestnum
11481 !! text
11482 [[{{{1}}}|{{{2}}}]]
11483 !! endarticle
11484
11485 !! test
11486 Template unnamed parameter
11487 !! wikitext
11488 {{paramtestnum|Main Page|the main page}}
11489 !! html
11490 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11491 </p>
11492 !! end
11493
11494 !! article
11495 Template:templatesimple
11496 !! text
11497 (test)
11498 !! endarticle
11499
11500 !! article
11501 Template:templateredirect
11502 !! text
11503 #redirect [[Template:templatesimple]]
11504 !! endarticle
11505
11506 !! article
11507 Template:templateasargtestnum
11508 !! text
11509 {{{{{1}}}}}
11510 !! endarticle
11511
11512 !! article
11513 Template:templateasargtest
11514 !! text
11515 {{template{{{templ}}}}}
11516 !! endarticle
11517
11518 !! article
11519 Template:templateasargtest2
11520 !! text
11521 {{{{{templ}}}}}
11522 !! endarticle
11523
11524 !! test
11525 Template with template name as unnamed argument
11526 !! wikitext
11527 {{templateasargtestnum|templatesimple}}
11528 !! html
11529 <p>(test)
11530 </p>
11531 !! end
11532
11533 !! test
11534 Template with template name as argument
11535 !! wikitext
11536 {{templateasargtest|templ=simple}}
11537 !! html
11538 <p>(test)
11539 </p>
11540 !! end
11541
11542 !! test
11543 Template with template name as argument (2)
11544 !! wikitext
11545 {{templateasargtest2|templ=templatesimple}}
11546 !! html
11547 <p>(test)
11548 </p>
11549 !! end
11550
11551 !! article
11552 Template:templateasargtestdefault
11553 !! text
11554 {{{{{templ|templatesimple}}}}}
11555 !! endarticle
11556
11557 !! article
11558 Template:templa
11559 !! text
11560 '''templ'''
11561 !! endarticle
11562
11563 !! test
11564 Template with default value
11565 !! wikitext
11566 {{templateasargtestdefault}}
11567 !! html
11568 <p>(test)
11569 </p>
11570 !! end
11571
11572 !! test
11573 Template with default value (value set)
11574 !! wikitext
11575 {{templateasargtestdefault|templ=templa}}
11576 !! html
11577 <p><b>templ</b>
11578 </p>
11579 !! end
11580
11581 !! test
11582 Template redirect
11583 !! wikitext
11584 {{templateredirect}}
11585 !! html/php
11586 <p>(test)
11587 </p>
11588 !! html/parsoid
11589 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11590 !! end
11591
11592 !! test
11593 Template with argument in separate line
11594 !! wikitext
11595 {{ templateasargtest |
11596 templ = simple }}
11597 !! html
11598 <p>(test)
11599 </p>
11600 !! end
11601
11602 !! test
11603 Template with complex template as argument
11604 !! wikitext
11605 {{paramtest|
11606 param ={{ templateasargtest |
11607 templ = simple }}}}
11608 !! html
11609 <p>This is a test template with parameter (test)
11610 </p>
11611 !! end
11612
11613 !! test
11614 Templates with templated name
11615 !! wikitext
11616 {{{{echo|echo}}|foo}}
11617 {{{{echo|inner list}} }}
11618 !! html
11619 <p>foo
11620 </p>
11621 <ul><li>item 1</li></ul>
11622
11623 !! html/parsoid
11624 <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>
11625 <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>
11626 !! end
11627
11628 ## Regression test; the output here isn't really that interesting.
11629 !! test
11630 Templates with templated name and top level template args
11631 !! wikitext
11632 {{1{{2{{{3}}}|4=5}}}}
11633 !! html/parsoid
11634 <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>
11635 !! end
11636
11637 # Parsoid markup is deliberate "broken". This is an edge case.
11638 # See long comment in TemplateHandler.js:convertAttribsToString.
11639 !! test
11640 Templates with invalid templated targets
11641 !! wikitext
11642 {{echo
11643 {{echo|foo}}
11644 }}
11645 !! html/php
11646 <p>{{echo
11647 foo
11648 }}
11649 </p>
11650 !! html/parsoid
11651 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11652 foo }}</p>
11653 !! end
11654
11655 !! test
11656 Template with thumb image (with link in description)
11657 !! wikitext
11658 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11659 !! html/php
11660 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>
11661
11662 !! html+tidy
11663 <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>
11664 !! html/parsoid
11665 <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>
11666 !! end
11667
11668 !! article
11669 Template:complextemplate
11670 !! text
11671 {{{1}}} {{paramtest|
11672 param ={{{param}}}}}
11673 !! endarticle
11674
11675 !! test
11676 Template with complex arguments
11677 !! wikitext
11678 {{complextemplate|
11679 param ={{ templateasargtest |
11680 templ = simple }}|[[Template:complextemplate|link]]}}
11681 !! html
11682 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11683 </p>
11684 !! end
11685
11686 !! test
11687 T2553: link with two variables in a piped link
11688 !! wikitext
11689 {|
11690 |[[{{{1}}}|{{{2}}}]]
11691 |}
11692 !! html/php
11693 <table>
11694 <tr>
11695 <td>[[{{{1}}}|{{{2}}}]]
11696 </td></tr></table>
11697
11698 !! html/parsoid
11699 <table>
11700 <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>
11701 </tbody></table>
11702 !! end
11703
11704 # See: T2553
11705 !! test
11706 Abort table cell attribute parsing on wikilink
11707 !! wikitext
11708 {|
11709 |testing [[one|two]] |three||four
11710 |testing one two |three||four
11711 |testing="[[one|two]]" |three||four
11712 |}
11713 !! html/php
11714 <table>
11715 <tr>
11716 <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>
11717 <td>four
11718 </td>
11719 <td>three</td>
11720 <td>four
11721 </td>
11722 <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>
11723 <td>four
11724 </td></tr></table>
11725
11726 !! html/parsoid
11727 <table>
11728 <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>
11729 <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>
11730 <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>
11731 </tbody></table>
11732 !! end
11733
11734 !! test
11735 Don't abort table cell attribute parsing if wikilink is found in template arg
11736 !! wikitext
11737 {|
11738 |Test {{#tag:ref|One two "[[three]]" four}}
11739 |}
11740 !! html/parsoid
11741 <table>
11742 <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>
11743 </tbody></table>
11744 !! end
11745
11746 !! test
11747 Magic variable as template parameter
11748 !! wikitext
11749 {{paramtest|param={{SITENAME}}}}
11750 !! html
11751 <p>This is a test template with parameter MediaWiki
11752 </p>
11753 !! end
11754
11755 !! article
11756 Template:linktest
11757 !! text
11758 [[{{{param}}}|link]]
11759 !! endarticle
11760
11761 !! test
11762 Template parameter as link source
11763 !! wikitext
11764 {{linktest|param=Main Page}}
11765 !! html
11766 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11767 </p>
11768 !! end
11769
11770 !!article
11771 Template:paramtest2
11772 !! text
11773 including another template, {{paramtest|param={{{arg}}}}}
11774 !! endarticle
11775
11776 !! test
11777 Template passing argument to another template
11778 !! wikitext
11779 {{paramtest2|arg='hmm'}}
11780 !! html
11781 <p>including another template, This is a test template with parameter 'hmm'
11782 </p>
11783 !! end
11784
11785 !! article
11786 Template:Linktest2
11787 !! text
11788 Main Page
11789 !! endarticle
11790
11791 !! test
11792 Template as link source
11793 !! wikitext
11794 [[{{linktest2}}]]
11795
11796 [[{{linktest2}}|Main Page]]
11797
11798 [[{{linktest2}}]]Page
11799 !! html
11800 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11801 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11802 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11803 </p>
11804 !! end
11805
11806
11807 !! article
11808 Template:loop1
11809 !! text
11810 {{loop2}}
11811 !! endarticle
11812
11813 !! article
11814 Template:loop2
11815 !! text
11816 {{loop1}}
11817 !! endarticle
11818
11819 !! test
11820 Template infinite loop
11821 !! wikitext
11822 {{loop1}}
11823 !! html
11824 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11825 </p>
11826 !! end
11827
11828 !! test
11829 Template from main namespace
11830 !! wikitext
11831 {{:Main Page}}
11832 !! html
11833 <p>blah blah
11834 </p>
11835 !! end
11836
11837 !! test
11838 Template from non-includable namespace
11839 !! options
11840 wgNonincludableNamespaces=10
11841 !! wikitext
11842 {{echo|uh oh!}}
11843 !! html
11844 <p><a href="/wiki/Template:Echo" title="Template:Echo">Template:Echo</a>
11845 </p>
11846 !! end
11847
11848 !! article
11849 Template:table
11850 !! text
11851 {|
11852 | 1 || 2
11853 |-
11854 | 3 || 4
11855 |}
11856 !! endarticle
11857
11858 !! test
11859 T2529: Template with table, not included at beginning of line
11860 !! wikitext
11861 foo {{table}}
11862 !! html
11863 <p>foo
11864 </p>
11865 <table>
11866 <tr>
11867 <td>1</td>
11868 <td>2
11869 </td></tr>
11870 <tr>
11871 <td>3</td>
11872 <td>4
11873 </td></tr></table>
11874
11875 !! end
11876
11877 !! test
11878 T2523: Template shouldn't eat newline (or add an extra one before table)
11879 !! wikitext
11880 foo
11881 {{table}}
11882 !! html
11883 <p>foo
11884 </p>
11885 <table>
11886 <tr>
11887 <td>1</td>
11888 <td>2
11889 </td></tr>
11890 <tr>
11891 <td>3</td>
11892 <td>4
11893 </td></tr></table>
11894
11895 !! end
11896
11897 !! test
11898 T2041: Template parameters shown as broken links
11899 !! wikitext
11900 {{{parameter}}}
11901 !! html
11902 <p>{{{parameter}}}
11903 </p>
11904 !! end
11905
11906 !! test
11907 Template with targets containing wikilinks
11908 !! options
11909 parsoid=wt2html
11910 !! wikitext
11911 {{[[foo]]}}
11912
11913 {{[[{{echo|foo}}]]}}
11914
11915 {{{{echo|[[foo}}]]}}
11916 !! html/php
11917 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11918 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11919 </p><p>{{[[foo}}]]
11920 </p>
11921 !! html/parsoid
11922 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11923 <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>
11924 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11925 !! end
11926
11927 !! article
11928 Template:''
11929 !! text
11930 bar
11931 !! endarticle
11932
11933 !! test
11934 Templates: Double quotes as template target
11935 !! wikitext
11936 foo {{''}} baz
11937 !! html/php
11938 <p>foo bar baz
11939 </p>
11940 !! html/parsoid
11941 <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
11942 </p>
11943 !! end
11944
11945 ## This test is about making sure Parsoid's data-mw is well formed in the
11946 ## face of multiple templates with intersecting and overlapping ranges. The
11947 ## wikitext itself is wretched.
11948 !! test
11949 Templates with intersecting and overlapping ranges
11950 !! wikitext
11951 {|{{echo|
11952 <p>ha</p>}}
11953 {|{{echo|
11954 <p>ho</p>}}
11955 {{echo|{{!}}hi}}
11956 |}
11957 !! html/php+tidy
11958 <p>ha</p><table>
11959
11960 </table><p>ho</p><table>
11961
11962 <tbody><tr>
11963 <td>hi
11964 </td></tr></tbody></table>
11965 !! html/parsoid
11966 <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":""}]]}'>
11967
11968 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11969
11970 <tbody><tr><td>hi</td></tr>
11971 </tbody></table>
11972 !! end
11973
11974 !! article
11975 Template:MSGNW test
11976 !! text
11977 ''None'' of '''this''' should be
11978 * interpreted
11979 but rather passed unmodified
11980 {{test}}
11981 <gallery>
11982 File:Foobar.jpg
11983 </gallery>
11984 <!-- comment -->
11985 !! endarticle
11986
11987 # hmm, fix this or just deprecate msgnw and document its behavior?
11988 !! test
11989 msgnw keyword
11990 !! wikitext
11991 {{msgnw:MSGNW test}}
11992 !! html/php
11993 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11994 &#42; interpreted
11995 &#32;but rather passed unmodified
11996 &#123;&#123;test&#125;&#125;
11997 &#60;gallery&#62;
11998 File:Foobar.jpg
11999 &#60;/gallery&#62;
12000 &#60;!-- comment --&#62;
12001 </p>
12002 !! end
12003
12004 !! test
12005 int keyword
12006 !! wikitext
12007 {{int:youhavenewmessages|lots of money|not!}}
12008 !! html
12009 <p>You have lots of money (not!).
12010 </p>
12011 !! end
12012
12013 !! test
12014 int keyword - non-existing message
12015 !! wikitext
12016 {{int:var}}
12017 !! html
12018 <p>⧼var⧽
12019 </p>
12020 !! end
12021
12022 !! article
12023 Template:Includes
12024 !! text
12025 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
12026 !! endarticle
12027
12028 !! test
12029 <includeonly> and <noinclude> being included
12030 !! wikitext
12031 {{Includes}}
12032 !! html
12033 <p>Foobar
12034 </p>
12035 !! end
12036
12037 !! article
12038 Template:Includes2
12039 !! text
12040 <onlyinclude>Foo</onlyinclude>bar
12041 !! endarticle
12042
12043 !! test
12044 <onlyinclude> being included
12045 !! wikitext
12046 {{Includes2}}
12047 !! html
12048 <p>Foo
12049 </p>
12050 !! end
12051
12052
12053 !! article
12054 Template:Includes3
12055 !! text
12056 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
12057 !! endarticle
12058
12059 !! test
12060 <onlyinclude> and <includeonly> being included
12061 !! wikitext
12062 {{Includes3}}
12063 !! html
12064 <p>Foo
12065 </p>
12066 !! end
12067
12068 !! test
12069 <includeonly> and <noinclude> on a page
12070 !! wikitext
12071 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
12072 !! html
12073 <p>Foozar
12074 </p>
12075 !! end
12076
12077 !! test
12078 Un-closed <noinclude>
12079 !! wikitext
12080 <noinclude>
12081 !! html
12082 !! end
12083
12084 !! test
12085 <onlyinclude> on a page
12086 !! wikitext
12087 <onlyinclude>Foo</onlyinclude>bar
12088 !! html
12089 <p>Foobar
12090 </p>
12091 !! end
12092
12093 !! test
12094 Un-closed <onlyinclude>
12095 !! wikitext
12096 <onlyinclude>
12097 !! html
12098 !! end
12099
12100 !!test
12101 Self-closed noinclude, includeonly, onlyinclude tags
12102 !! wikitext
12103 <noinclude />
12104 <includeonly />
12105 <onlyinclude />
12106 !! html
12107 <p><br />
12108 </p>
12109 !!end
12110
12111 !!test
12112 Unbalanced includeonly and noinclude tags
12113 !! wikitext
12114 {|
12115 |a</noinclude>
12116 |b</noinclude></noinclude>
12117 |c</noinclude></includeonly>
12118 |d</includeonly></includeonly>
12119 |}
12120 !! html
12121 <table>
12122 <tr>
12123 <td>a
12124 </td>
12125 <td>b
12126 </td>
12127 <td>c&lt;/includeonly&gt;
12128 </td>
12129 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
12130 </td></tr></table>
12131
12132 !!end
12133
12134 !! article
12135 Template:Includeonly section
12136 !! text
12137 <includeonly>
12138 ==Includeonly section==
12139 </includeonly>
12140 ==Section T-1==
12141 !!endarticle
12142
12143 !! test
12144 T8563: Edit link generation for section shown by <includeonly>
12145 !! wikitext
12146 {{includeonly section}}
12147 !! html
12148 <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>
12149 <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>
12150
12151 !! end
12152
12153 # Uses same input as the contents of [[Template:Includeonly section]]
12154 !! test
12155 T8563: Section extraction for section shown by <includeonly>
12156 !! options
12157 section=T-2
12158 !! wikitext
12159 <includeonly>
12160 ==Includeonly section==
12161 </includeonly>
12162 ==Section T-2==
12163 !! html
12164 ==Section T-2==
12165 !! end
12166
12167 !! test
12168 T8563: Edit link generation for section suppressed by <includeonly>
12169 !! wikitext
12170 <includeonly>
12171 ==Includeonly section==
12172 </includeonly>
12173 ==Section 1==
12174 !! html
12175 <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>
12176
12177 !! end
12178
12179 !! test
12180 T8563: Section extraction for section suppressed by <includeonly>
12181 !! options
12182 section=1
12183 !! wikitext
12184 <includeonly>
12185 ==Includeonly section==
12186 </includeonly>
12187 ==Section 1==
12188 !! html
12189 ==Section 1==
12190 !! end
12191
12192 !! test
12193 Un-closed <includeonly>
12194 !! wikitext
12195 <includeonly>
12196 !! html/php
12197 !! html/parsoid
12198 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}' data-mw='{"src":"&lt;includeonly>"}'/>
12199 !! end
12200
12201 ## We used to, but no longer wt2wt this test since the default serializer
12202 ## will normalize the include directives to serialize on their own line.
12203 ## Selser will take care of preserving formatting in scenarios where they
12204 ## intermingled with other wikitext.
12205 !! test
12206 Includes and comments at SOL
12207 !! options
12208 parsoid=wt2html,html2html
12209 !! wikitext
12210 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->==hu==
12211
12212 <noinclude>
12213 some
12214 </noinclude>*stuff
12215 *here
12216
12217 <noinclude>
12218 some</noinclude>* stuff
12219 * here
12220
12221 <includeonly>can have stuff</includeonly>===here===
12222
12223 !! html/php
12224 <h2><span class="mw-headline" id="hu">hu</span></h2>
12225 <p>some
12226 </p>
12227 <ul><li>stuff</li>
12228 <li>here</li></ul>
12229 <p><br />
12230 some* stuff
12231 </p>
12232 <ul><li>here</li></ul>
12233 <h3><span class="mw-headline" id="here">here</span></h3>
12234
12235 !! html/parsoid
12236 <!-- 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>
12237
12238 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12239 <p>some</p>
12240 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li>stuff</li>
12241 <li>here</li></ul>
12242
12243 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12244 <p>some<meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/>* stuff</p>
12245 <ul><li>here</li></ul>
12246
12247 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>can have stuff&lt;/includeonly>"}' data-mw='{"src":"&lt;includeonly>can have stuff&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><h3 id="here">here</h3>
12248
12249 !! end
12250
12251 # TODO: test with DOM fragment reuse!
12252 !! test
12253 Parsoid: DOM fragment reuse
12254 !! options
12255 parsoid=wt2wt,wt2html
12256 !! wikitext
12257 a{{echo|b<table></table>c}}d
12258
12259 a{{echo|b
12260 <table></table>
12261 c}}d
12262
12263 {{echo|a
12264
12265 <table></table>
12266
12267 b}}
12268 !! html/php+tidy
12269 <p>ab</p><table></table><p>cd
12270 </p><p>ab
12271 </p>
12272 <table></table>
12273 <p>cd
12274 </p><p>a
12275 </p>
12276 <table></table>
12277 <p>b
12278 </p>
12279 !! html/parsoid
12280 <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>
12281
12282 <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">
12283 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
12284 </span><p about="#mwt2">cd</p>
12285
12286 <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">
12287
12288 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
12289
12290 </span><p about="#mwt3">b</p>
12291 !! end
12292
12293 !! test
12294 Parsoid: Merge double tds (T52603)
12295 !! wikitext
12296 {|
12297 |{{echo|{{!}} foo}}
12298 |}
12299 !! html/php+tidy
12300 <table>
12301 <tbody><tr>
12302 <td>foo
12303 </td></tr></tbody></table>
12304 !! html/parsoid
12305 <table><tbody>
12306 <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>
12307 </tbody></table>
12308 !! end
12309
12310 !! test
12311 Parsoid: Merge double tds in nested transclusion content (T52603)
12312 !! wikitext
12313 {{echo|<div>}}
12314 {|
12315 |{{echo|{{!}} foo}}
12316 |}
12317 {{echo|</div>}}
12318 !! html/php+tidy
12319 <div>
12320 <table>
12321 <tbody><tr>
12322 <td>foo
12323 </td></tr></tbody></table>
12324 </div>
12325 !! html/parsoid
12326 <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}}]}'>
12327 <table><tbody>
12328 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
12329 </tbody></table>
12330 </div>
12331 !! end
12332
12333 ###
12334 ### <includeonly> and <noinclude> in attributes
12335 ###
12336 !!test
12337 0. includeonly around the entire attribute
12338 !! wikitext
12339 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
12340 !! html
12341 <p><span id="v2">bar</span>
12342 </p>
12343 !!end
12344
12345 !!test
12346 1. includeonly in html attr key
12347 !! wikitext
12348 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
12349 !! html
12350 <p><span id="foo">bar</span>
12351 </p>
12352 !!end
12353
12354 !!test
12355 2. includeonly in html attr value
12356 !! wikitext
12357 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
12358 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
12359 !! html
12360 <p><span id="v1">bar</span>
12361 <span id="v1">bar</span>
12362 </p>
12363 !!end
12364
12365 !!test
12366 3. includeonly in part of an attr value
12367 !! wikitext
12368 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
12369 !! html
12370 <p><span style="color:red;">bar</span>
12371 </p>
12372 !!end
12373
12374 !!test
12375 4. includeonly in table attributes
12376 !! wikitext
12377 {|
12378 |- <noinclude>
12379 |-
12380 |a
12381 </noinclude>
12382 |- <includeonly>
12383 |-
12384 |b
12385 </includeonly>
12386 |}
12387 !! html
12388 <table>
12389
12390
12391 <tr>
12392 <td>a
12393 </td></tr>
12394 </table>
12395
12396 !!end
12397
12398 ###
12399 ### Preprocessor precedence tests
12400 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
12401 ###
12402 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
12403 !! test
12404 Preprocessor precedence 1: link is rightmost opening
12405 !! options
12406 parsoid=wt2html
12407 !! wikitext
12408 {{[[Foo|bar}}]]
12409
12410 But close-brace is not a valid character in a link title:
12411 {{[[Foo}}|bar]]
12412
12413 However, we can still tell this was handled as a link in the preprocessor:
12414 {{echo|[[Foo}}|bar]]|bat}}
12415 !! html/php
12416 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12417 </p><p>But close-brace is not a valid character in a link title:
12418 {{[[Foo}}|bar]]
12419 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12420 [[Foo}}|bar]]
12421 </p>
12422 !! html/parsoid
12423 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12424 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12425 <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>
12426 !! end
12427
12428 !! test
12429 Preprocessor precedence 2: template is rightmost opening
12430 !! options
12431 language=zh
12432 !! wikitext
12433 -{{echo|foo}-}}-
12434 !! html/php
12435 <p>-foo}--
12436 </p>
12437 !! html/parsoid
12438 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12439 !! end
12440
12441 !! test
12442 Preprocessor precedence 3: language converter is rightmost opening
12443 !! options
12444 language=zh
12445 parsoid=wt2html
12446 !! wikitext
12447 {{echo|hi}}
12448
12449 {{-{R|echo|hi}}}-
12450
12451 [[-{R|raw]]}-
12452 !! html/php
12453 <p>hi
12454 </p><p>{{echo|hi}}
12455 </p><p>[[raw]]
12456 </p>
12457 !! html/parsoid
12458 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12459 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12460 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12461 !! end
12462
12463 !! test
12464 Preprocessor precedence 4: left-most angle bracket
12465 !! options
12466 language=zh
12467 !! wikitext
12468 <!--{raw}-->
12469 !! html/php
12470 !! html/parsoid
12471 <!--{raw}-->
12472 !! end
12473
12474 !! article
12475 Template:Precedence5
12476 !! text
12477 {{{{{1}}}}}
12478 !! endarticle
12479
12480 !! test
12481 Preprocessor precedence 5: tplarg takes precedence over template
12482 !! wikitext
12483 {{Precedence5|Bullet}}
12484 !! html/php
12485 <ul><li>Bar</li></ul>
12486
12487 !! html/parsoid
12488 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li>Bar</li></ul>
12489 !! end
12490
12491 !! test
12492 Preprocessor precedence 6: broken link is rightmost opening
12493 !! options
12494 parsoid=wt2html
12495 !! wikitext
12496 {{echo|[[Foo}}
12497
12498 {{echo|[[Foo|bar|bat=baz}}
12499 !! html/php
12500 <p>{{echo|[[Foo}}
12501 </p><p>{{echo|[[Foo|bar|bat=baz}}
12502 </p>
12503 !! html/parsoid
12504 <p>{{echo|[[Foo}}</p>
12505 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12506 !! end
12507
12508 # This next test exposes a difference between PHP and Parsoid:
12509 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12510 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12511 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12512 # outer `[[Foo` extends until the `y]]`
12513 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12514 # intermediate result (after template expansion), and link processing
12515 # happens on this intermediate result, which moves the wikilink
12516 # boundary leftward to `[[Foo|Bar]]`
12517 # 2b) Parsoid works in a single step, so it's going to keep the
12518 # wikilink as extending to the `y]]`
12519 # 3a) Then PHP does linktrail processing which slurps up the trailing
12520 # `xy` inside the link.
12521 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12522 # `z` inside the link.
12523 # This is "correct" behavior. Parsoid's basic worldview is that the
12524 # `]]` inside the template shouldn't be allowed to leak out to affect
12525 # the surrounding wikilink. PHP may match Parsoid (in the future)
12526 # if you use {{#balance}} (T114445).
12527
12528 !! test
12529 Preprocessor precedence 7: broken template is rightmost opening
12530 !! options
12531 parsoid=wt2html
12532 !! wikitext
12533 [[Foo|{{echo|Bar]]
12534
12535 [[Foo|{{echo|Bar]]-x}}-y]]-z
12536
12537 Careful: linktrails can move the end of the wikilink:
12538 [[Foo|{{echo|y']]a}}l]]l
12539 !! html/php
12540 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12541 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12542 </p><p>Careful: linktrails can move the end of the wikilink:
12543 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12544 </p>
12545 !! html/parsoid
12546 <p>[[Foo|{{echo|Bar]]</p>
12547 <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>
12548 <p>Careful: linktrails can move the end of the wikilink:
12549 <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>
12550 !! end
12551
12552 !! test
12553 Preprocessor precedence 8: broken language converter is rightmost opening
12554 !! options
12555 language=zh
12556 !! wikitext
12557 [[Foo-{R|raw]]
12558 !! html
12559 <p>[[Foo-{R|raw]]
12560 </p>
12561 !! end
12562
12563 !! article
12564 Template:Preprocessor_precedence_9
12565 !! text
12566 ;4: {{{{1}}}}
12567 ;5: {{{{{2}}}}}
12568 ;6: {{{{{{3}}}}}}
12569 ;7: {{{{{{{4}}}}}}}
12570 !! endarticle
12571
12572 !! test
12573 Preprocessor precedence 9: groups of braces
12574 !! wikitext
12575 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12576 !! html/php
12577 <dl><dt>4</dt>
12578 <dd>{Four}</dd>
12579 <dt>5</dt>
12580 <dd></dd></dl>
12581 <ul><li>Bar</li></ul>
12582 <dl><dt>6</dt>
12583 <dd>Four</dd>
12584 <dt>7</dt>
12585 <dd>{Bullet}</dd></dl>
12586
12587 !! html/parsoid
12588 <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}}]}'>
12589 <dt>4</dt>
12590 <dd>{Four}</dd>
12591 <dt>5</dt>
12592 <dd></dd>
12593 </dl><ul about="#mwt1">
12594 <li>Bar</li>
12595 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12596 <dt>6</dt>
12597 <dd>Four</dd>
12598 <dt>7</dt>
12599 <dd>{Bullet}</dd>
12600 </dl>
12601 !! end
12602
12603 !! article
12604 Template:Preprocessor_precedence_10
12605 !! text
12606 ;1: -{R|raw}-
12607 ;2: -{{Bullet}}-
12608 ;3: -{{{1}}}-
12609 ;4: -{{{{2}}}}-
12610 ;5: -{{{{{3}}}}}-
12611 ;6: -{{{{{{4}}}}}}-
12612 ;7: -{{{{{{{5}}}}}}}-
12613 !! endarticle
12614
12615 !! test
12616 Preprocessor precedence 10: groups of braces with leading dash
12617 !! options
12618 language=zh
12619 !! wikitext
12620 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12621 !! html/php
12622 <dl><dt>1</dt>
12623 <dd>raw</dd>
12624 <dt>2</dt>
12625 <dd>-</dd></dl>
12626 <ul><li>Bar-</li></ul>
12627 <dl><dt>3</dt>
12628 <dd>-Three-</dd>
12629 <dt>4</dt>
12630 <dd>raw2</dd>
12631 <dt>5</dt>
12632 <dd>-</dd></dl>
12633 <ul><li>Bar-</li></ul>
12634 <dl><dt>6</dt>
12635 <dd>-Three-</dd>
12636 <dt>7</dt>
12637 <dd>raw2</dd></dl>
12638
12639 !! html/parsoid
12640 <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}}]}'>
12641 <dt>1</dt>
12642 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12643 <dt>2</dt>
12644 <dd>-</dd>
12645 </dl><ul about="#mwt1">
12646 <li>Bar-</li>
12647 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12648 <dt>3</dt>
12649 <dd>-Three-</dd>
12650 <dt>4</dt>
12651 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12652 <dt>5</dt>
12653 <dd>-</dd>
12654 </dl><ul about="#mwt1">
12655 <li>Bar-</li>
12656 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12657 <dt>6</dt>
12658 <dd>-Three-</dd>
12659 <dt>7</dt>
12660 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12661 </dl>
12662 !! end
12663
12664 !! test
12665 Preprocessor precedence 11: found during visual diff testing
12666 !! wikitext
12667 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12668
12669 {{echo|-{{echo|-{{echo|x}}}}}}
12670
12671 {{echo|-{{echo|x}}}}
12672 !! html/php
12673 <p><span>-<span>-x</span></span>
12674 </p><p>--x
12675 </p><p>-x
12676 </p>
12677 !! html/parsoid
12678 <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>
12679
12680 <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>
12681
12682 <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>
12683 !! end
12684
12685 !! test
12686 Preprocessor precedence 12: broken language converter closed by brace.
12687 !! options
12688 parsoid=wt2html
12689 !! wikitext
12690 This form breaks the template, which is unfortunate:
12691 *{{echo|foo-{bar}bat}}
12692
12693 But if the broken language converter markup is inside an extension
12694 tag, nothing bad happens:
12695 *<nowiki>foo-{bar}bat</nowiki>
12696 *{{echo|<nowiki>foo-{bar}bat</nowiki>}}
12697 *<pre>foo-{bar}bat</pre>
12698 *{{echo|<pre>foo-{bar}bat</pre>}}
12699
12700 <tag>foo-{bar}bat</tag>
12701 {{echo|<tag>foo-{bar}bat</tag>}}
12702
12703 !! html/php+tidy
12704 <p>This form breaks the template, which is unfortunate:
12705 </p>
12706 <ul><li>{{echo|foo-{bar}bat}}</li></ul>
12707 <p>But if the broken language converter markup is inside an extension
12708 tag, nothing bad happens:
12709 </p>
12710 <ul><li>foo-&#123;bar}bat</li>
12711 <li>foo-&#123;bar}bat</li>
12712 <li><pre>foo-{bar}bat</pre></li>
12713 <li><pre>foo-{bar}bat</pre></li></ul>
12714 <pre>'foo-{bar}bat'
12715 array (
12716 )
12717 </pre>
12718 <pre>'foo-{bar}bat'
12719 array (
12720 )
12721 </pre>
12722 !! html/parsoid
12723 <p>This form breaks the template, which is unfortunate:</p>
12724 <ul>
12725 <li>{{echo|foo-{bar}bat}}</li>
12726 </ul>
12727 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12728 <ul>
12729 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12730 <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>
12731 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12732 <li><pre typeof="mw:Extension/pre mw:Transclusion" 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>
12733 </ul>
12734 <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>
12735 !! end
12736
12737 !! test
12738 Preprocessor precedence 13: broken language converter in external link
12739 !! options
12740 parsoid=wt2html
12741 !! wikitext
12742 *[http://example.com/-{foo Example in URL]
12743 *[http://example.com Example in -{link} description]
12744 *{{echo|[http://example.com/-{foo Breaks template, however]}}
12745 !! html/php+tidy
12746 <ul><li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12747 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12748 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li></ul>
12749 !! html/parsoid
12750 <ul>
12751 <li><a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12752 <li><a rel="mw:ExtLink" class="external text" href="http://example.com">Example in -{link} description</a></li>
12753 <li>{{echo|<a rel="mw:ExtLink" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12754 </ul>
12755 !! end
12756
12757 !! test
12758 Preprocessor precedence 14: broken language converter in comment
12759 !! wikitext
12760 *<!--{{foo}}-->...should be ok
12761 *<!---{{foo}}-->...extra dashes
12762 *{{echo|foo<!-- -{bar} -->bat}}...should be ok
12763 !! html/php+tidy
12764 <ul><li>...should be ok</li>
12765 <li>...extra dashes</li>
12766 <li>foobat...should be ok</li></ul>
12767 !! html/parsoid
12768 <ul>
12769 <li><!--{{foo}}-->...should be ok</li>
12770 <li><!--&#x2D;{{foo}}-->...extra dashes</li>
12771 <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>
12772 </ul>
12773 !! end
12774
12775 !! test
12776 Preprocessor precedence 15: broken brace markup in headings
12777 !! config
12778 wgFragmentMode=[ 'html5', 'legacy' ]
12779 !! options
12780 parsoid=wt2html
12781 !! wikitext
12782 __NOTOC__ __NOEDITSECTION__
12783 ===1 foo[bar 1===
12784 1
12785 ===2 foo[[bar 2===
12786 2
12787 ===3 foo{bar 3===
12788 3
12789 ===4 foo{{bar 4===
12790 4
12791 ===5 foo{{{bar 5===
12792 5
12793 ===6 foo-{bar 6===
12794 6
12795 !! html/php+tidy
12796 <h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3>
12797 <p>1
12798 </p>
12799 <h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3>
12800 <p>2
12801 </p>
12802 <h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3>
12803 <p>3
12804 </p>
12805 <h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3>
12806 <p>4
12807 </p>
12808 <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>
12809 <p>5
12810 </p>
12811 <h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3>
12812 <p>6
12813 </p>
12814 !! html/parsoid
12815 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/>
12816 <h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3>
12817 <p>1</p>
12818 <h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3>
12819 <p>2</p>
12820 <h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3>
12821 <p>3</p>
12822 <h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3>
12823 <p>4</p>
12824 <h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3>
12825 <p>5</p>
12826 <h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3>
12827 <p>6</p>
12828 !! end
12829
12830 !! test
12831 Preprocessor precedence 16: matching closing braces to opening braces
12832 !! options
12833 language=zh
12834 parsoid=wt2html
12835 !! wikitext
12836 -{{{echo|foo}}bar}-
12837 !! html/php
12838 <p>foobar
12839 </p>
12840 !! html/parsoid
12841 <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>
12842 !! end
12843
12844 !! test
12845 Preprocessor precedence 17: template w/o target shouldn't prevent closing
12846 !! options
12847 parsoid=wt2html
12848 !! wikitext
12849 {{echo|hi {{}}}}
12850 !! html/php
12851 <p>hi {{}}
12852 </p>
12853 !! html/parsoid
12854 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p>
12855 !! end
12856
12857 # Ensure we're using a language without variants for this test; even
12858 # if $wgUsePigLatinVariant is true. We've picked `de` arbitrarily.
12859 !! test
12860 Preprocessor precedence 18: another rightmost wins scenario
12861 !! options
12862 parsoid=wt2html
12863 language=de
12864 !! wikitext
12865 {{ -{{{{1|tplarg}}} }} }-
12866 !! html/php
12867 <p>{{ -{tplarg }} }-
12868 </p>
12869 !! html/parsoid
12870 <p>{{ -{<span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"1"},"params":{"1":{"wt":"tplarg"}},"i":0}}]}'>tplarg</span> }} }-</p>
12871 !! end
12872
12873 !! test
12874 Preprocessor precedence 19: break syntax
12875 !! options
12876 parsoid=wt2html
12877 !! wikitext
12878 -{{
12879 !! html/php
12880 <p>-{{
12881 </p>
12882 !! html/parsoid
12883 <p>-{{</p>
12884 !! end
12885
12886 ###
12887 ### Token Stream Patcher tests
12888 ###
12889 ### These tests won't always pass wt2wt and other modes because
12890 ### on serialization, the table will be output on a new line.
12891 ### For now, we are blacklisting them, and using this to test selser.
12892 ###
12893
12894 !!test
12895 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12896 !!options
12897 parsoid=wt2html,wt2wt
12898 !!wikitext
12899 {{echo|}}{| width = '100%'
12900 |foo
12901 |}
12902 !!html/parsoid
12903 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12904 <tbody><tr><td>foo</td></tr>
12905 </tbody></table>
12906 !!end
12907
12908 ## We used to, but no longer wt2wt this test since the default serializer
12909 ## will normalize the include directives to serialize on their own line.
12910 ## Selser will take care of preserving formatting in scenarios where they
12911 ## intermingled with other wikitext.
12912 !!test
12913 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12914 !!options
12915 parsoid=wt2html
12916 !!wikitext
12917 <includeonly>a</includeonly>{| {{{b}}}
12918 |c
12919 |}
12920 !!html/parsoid
12921 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>a&lt;/includeonly>"}' data-mw='{"src":"&lt;includeonly>a&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><table about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"a":{"{{{b}}}":null},"sa":{"{{{b}}}":""}}' data-mw='{"attribs":[[{"txt":"{{{b}}}","html":"&lt;span about=\"#mwt1\" typeof=\"mw:Param\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[31,38,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"templatearg\":{\"target\":{\"wt\":\"b\"},\"params\":{},\"i\":0}}]}&#39;>{{{b}}}&lt;/span>"},{"html":""}]]}'>
12922 <tbody><tr><td>c</td></tr>
12923 </tbody></table>
12924 !!end
12925
12926 !! test
12927 Table wikitext syntax outside wiki-tables
12928 !! wikitext
12929 a
12930 |+ not a caption
12931 ! not a table heading
12932 |- not a table row
12933 | not a table cell
12934 | class="foo bar" | baz
12935 b
12936 |}
12937 |-
12938 c
12939 !! html
12940 <p>a
12941 |+ not a caption
12942 ! not a table heading
12943 |- not a table row
12944 | not a table cell
12945 | class="foo bar" | baz
12946 b
12947 |}
12948 |-
12949 c
12950 </p>
12951 !! end
12952
12953 ###
12954 ### Testing parsing of templates where a template arg
12955 ### has the same name as the template itself.
12956 ###
12957
12958 !! article
12959 Template:quote
12960 !! text
12961 {{{quote|{{{1}}}}}}
12962 !! endarticle
12963
12964 !!test
12965 Templates: Template Name/Arg clash: 1. Use of positional param
12966 !! wikitext
12967 {{quote|foo}}
12968 !! html
12969 <p>foo
12970 </p>
12971 !!end
12972
12973 !!test
12974 Templates: Template Name/Arg clash: 2. Use of named param
12975 !! wikitext
12976 {{quote|quote=foo}}
12977 !! html
12978 <p>foo
12979 </p>
12980 !!end
12981
12982 !!test
12983 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12984 !! wikitext
12985 {{quote|quote}}
12986 !! html
12987 <p>quote
12988 </p>
12989 !!end
12990
12991 ###
12992 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12993 ###
12994
12995 !!test
12996 Templates: 1. Simple use
12997 !! wikitext
12998 {{echo|Foo}}
12999 !! html
13000 <p>Foo
13001 </p>
13002 !!end
13003
13004 !!test
13005 Templates: 2. Inside a block tag
13006 !! wikitext
13007 <div>{{echo|Foo}}</div>
13008 <blockquote>{{echo|Foo}}</blockquote>
13009 !! html
13010 <div>Foo</div>
13011 <blockquote>Foo</blockquote>
13012
13013 !! html+tidy
13014 <div>Foo</div>
13015 <blockquote><p>Foo</p></blockquote>
13016 !!end
13017
13018 !!test
13019 Templates: P-wrapping: 1a. Templates on consecutive lines
13020 !! wikitext
13021 {{echo|Foo}}
13022 {{echo|bar}}
13023 !! html
13024 <p>Foo
13025 bar
13026 </p>
13027 !!end
13028
13029 !!test
13030 Templates: P-wrapping: 1b. Templates on consecutive lines
13031 !! wikitext
13032 Foo
13033
13034 {{echo|bar}}
13035 {{echo|baz}}
13036 !! html
13037 <p>Foo
13038 </p><p>bar
13039 baz
13040 </p>
13041 !!end
13042
13043 !!test
13044 Templates: P-wrapping: 1c. Templates on consecutive lines
13045 !! wikitext
13046 {{echo|Foo}}
13047 {{echo|bar}} <div>baz</div>
13048 !! html
13049 <p>Foo
13050 </p>
13051 bar <div>baz</div>
13052
13053 !! html+tidy
13054 <p>Foo
13055 </p><p>
13056 bar </p><div>baz</div>
13057 !! end
13058
13059 !! test
13060 Templates: P-wrapping: 1d. Template preceded by comment-only line
13061 !! wikitext
13062 <!-- foo -->
13063 {{echo|Bar}}
13064 !! html/php+tidy
13065 <p>Bar
13066 </p>
13067 !! html/parsoid
13068 <!-- foo -->
13069
13070 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
13071 !!end
13072
13073 !! test
13074 Templates: Scopes should not be expanded unnecessarily
13075 !! options
13076 parsoid=wt2html,wt2wt
13077 !! wikitext
13078 {{echo|<div>a</div>}}b{{echo|
13079 <div>c</div>}}
13080 !! html/php+tidy
13081 <div>a</div><p>b
13082 </p><div>c</div>
13083 !! html/parsoid
13084 <div about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;div>a&lt;/div>"}},"i":0}}]}'>a</div><p>b</p><span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"\n&lt;div>c&lt;/div>"}},"i":0}}]}'>
13085 </span><div about="#mwt2">c</div>
13086 !! end
13087
13088 !!test
13089 Templates: Inline Text: 1. Multiple template uses
13090 !! wikitext
13091 {{echo|Foo}}bar{{echo|baz}}
13092 !! html
13093 <p>Foobarbaz
13094 </p>
13095 !!end
13096
13097 !!test
13098 Templates: Inline Text: 2. Back-to-back template uses
13099 !! wikitext
13100 {{echo|Foo}}{{echo|bar}}
13101 !! html
13102 <p>Foobar
13103 </p>
13104 !!end
13105
13106 !!test
13107 Templates: Block Tags: 1. Multiple template uses
13108 !! wikitext
13109 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
13110 !! html
13111 <div>Foo</div><div>bar</div><div>baz</div>
13112
13113 !!end
13114
13115 !!test
13116 Templates: Block Tags: 2. Back-to-back template uses
13117 !! wikitext
13118 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
13119 !! html
13120 <div>Foo</div><div>bar</div>
13121
13122 !!end
13123
13124 ## Parsoid drops empty elements in templates.
13125 !! test
13126 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
13127 !! wikitext
13128 {{echo|a
13129 b</p>}}
13130 !! html/php+tidy
13131 <p>a
13132 </p><p>
13133 b</p><p class="mw-empty-elt"></p>
13134 !! html/parsoid
13135 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\nb&lt;/p>"}},"i":0}}]}'>a</p><span about="#mwt1">
13136 </span><p about="#mwt1">b</p>
13137 !! end
13138
13139 !!test
13140 Templates: Links: 1. Simple example
13141 !! wikitext
13142 {{echo|[[Foo|bar]]}}
13143 !! html
13144 <p><a href="/wiki/Foo" title="Foo">bar</a>
13145 </p>
13146 !!end
13147
13148 !!test
13149 Templates: Links: 2. Generation of link href
13150 !! wikitext
13151 [[{{echo|Foo}}|bar]]
13152 !! html
13153 <p><a href="/wiki/Foo" title="Foo">bar</a>
13154 </p>
13155 !!end
13156
13157 !!test
13158 Templates: Links: 3. Generation of part of a link href
13159 !! wikitext
13160 [[Fo{{echo|o}}|bar]]
13161
13162 [[Foo{{echo|bar}}]]
13163
13164 [[Foo{{echo|bar}}baz]]
13165
13166 [[Foo{{echo|bar}}|bar]]
13167
13168 [[:Foo{{echo|bar}}]]
13169
13170 [[:Foo{{echo|bar}}|bar]]
13171 !! html
13172 <p><a href="/wiki/Foo" title="Foo">bar</a>
13173 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13174 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
13175 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
13176 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13177 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
13178 </p>
13179 !!end
13180
13181 !!test
13182 Templates: Links: 4. Multiple templates generating link href
13183 !! wikitext
13184 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
13185 !! html
13186 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
13187 </p>
13188 !!end
13189
13190 !!test
13191 Templates: Links: 5. Generation of link text
13192 !! wikitext
13193 [[Foo|{{echo|bar}}]]
13194 !! html
13195 <p><a href="/wiki/Foo" title="Foo">bar</a>
13196 </p>
13197 !!end
13198
13199 !!test
13200 Templates: Links: 5. Nested templates (only outermost template should be marked)
13201 !! wikitext
13202 {{echo|[[{{echo|Foo}}|bar]]}}
13203 !! html
13204 <p><a href="/wiki/Foo" title="Foo">bar</a>
13205 </p>
13206 !!end
13207
13208 !!test
13209 Templates: HTML Tag: 1. Generation of HTML attr. key
13210 !! wikitext
13211 <div {{echo|style}}="color:red;">foo</div>
13212 !! html
13213 <div style="color:red;">foo</div>
13214
13215 !!end
13216
13217 !!test
13218 Templates: HTML Tag: 2. Generation of HTML attr. value
13219 !! wikitext
13220 <div style={{echo|'color:red;'}}>foo</div>
13221 !! html
13222 <div style="color:red;">foo</div>
13223
13224 !!end
13225
13226 !!test
13227 Templates: HTML Tag: 3. Generation of HTML attr key and value
13228 !! wikitext
13229 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
13230 !! html
13231 <div style="color:red;">foo</div>
13232
13233 !!end
13234
13235 !!test
13236 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
13237 !! wikitext
13238 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
13239 !! html
13240 <div title="This is a long title with just one piece templated">foo</div>
13241
13242 !!end
13243
13244 !!test
13245 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
13246 !! wikitext
13247 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
13248 !! html
13249 <div title="This is a long title with just one piece templated">foo</div>
13250
13251 !!end
13252
13253 !!test
13254 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
13255 !! wikitext
13256 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
13257 !! html
13258 <div title="This is a long title with just one piece templated">foo</div>
13259
13260 !!end
13261
13262 # SSS FIXME: While it is great we added support for all this,
13263 # do we want to make this part of the spec? Maybe we want to
13264 # deprecate this kind of usage in the future?
13265 !!test
13266 Templates: HTML Tag: 7. Generation of partial attribute key string
13267 !! wikitext
13268 <div st{{echo|yle}}="color:red;">foo</div>
13269 !! html
13270 <div style="color:red;">foo</div>
13271
13272 !!end
13273
13274 !! test
13275 Templates: HTML Tag: 8. Template-generated attribute (k=v)
13276 !! wikitext
13277 <div {{echo|1=id="v1"}}>bar</div>
13278 !! html
13279 <div id="v1">bar</div>
13280
13281 !!end
13282
13283 !! test
13284 Templates: HTML Tag: 9. Multiple template-generated attributes
13285 !! wikitext
13286 <div {{echo|1=id="v1" title="foo"}}>bar</div>
13287 !! html
13288 <div id="v1" title="foo">bar</div>
13289
13290 !!end
13291
13292 !! test
13293 Templates: Support for templates generating attributes and content
13294 !! wikitext
13295 {| {{mixed_attr_content_template}}
13296 |-
13297 |bar
13298 |}
13299 !! html/php
13300 <table style="color:red;" title="T48811">
13301
13302 <tr>
13303 <td>foo
13304 </td></tr>
13305 <tr>
13306 <td>bar
13307 </td></tr></table>
13308
13309 !! html/parsoid
13310 <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|}"]}'>
13311 <tbody><tr>
13312 <td>foo</td></tr>
13313 <tr>
13314 <td>bar</td></tr>
13315 </tbody></table>
13316 !!end
13317
13318 !! article
13319 Template:attribute_from_template
13320 !! text
13321 class="123"
13322 !! endarticle
13323
13324 !! test
13325 Table cell with attribute before expanded attribute
13326 !! wikitext
13327 {|
13328 | align="center" {{attribute_from_template}} |456
13329 |}
13330 !! html/parsoid
13331 <table>
13332 <tbody><tr><td align="center" class="123" about="#mwt2" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"class","html":"&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&apos;{\"pi\":[[]],\"dsr\":[20,47,null,null]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"attribute_from_template\",\"href\":\"./Template:Attribute_from_template\"},\"params\":{},\"i\":0}}]}&apos;>class=\"123\"&lt;/span>"},{"html":""}]]}'>456</td></tr>
13333 </tbody></table>
13334 !! end
13335
13336 !! test
13337 1. Entities and nowikis inside templated attributes should be handled correctly
13338 !! wikitext
13339 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
13340 !! html/php
13341 <div style="background:#f9f9f9;">foo</div>
13342
13343 !! html/parsoid
13344 <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>
13345 !! end
13346
13347 !! test
13348 2. Entities and nowikis inside templated attributes should be handled correctly
13349 !! wikitext
13350 {|
13351 |{{table_attribs_3}}
13352 |}
13353 !! html/php
13354 <table>
13355 <tr>
13356 <td style="background:#f9f9f9;">Foo
13357 </td></tr></table>
13358
13359 !! html/parsoid
13360 <table>
13361 <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>
13362 </tbody></table>
13363 !! end
13364
13365 !! test
13366 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13367 !! wikitext
13368 {{tbl-start}}
13369 |{{table_attribs_3}}
13370 {{tbl-end}}
13371 !! html/php
13372 <table>
13373 <tr>
13374 <td style="background:#f9f9f9;">Foo
13375 </td></tr></table>
13376
13377 !! html/parsoid
13378 <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}}]}'>
13379 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
13380 </tbody></table>
13381 !! end
13382
13383 # T107622
13384 !! test
13385 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13386 !! wikitext
13387 {|
13388 |{{table_attribs_6}} hi
13389 |}
13390 !! html/php
13391 <table>
13392 <tr>
13393 <td style="background: red;">hi
13394 </td></tr></table>
13395
13396 !! html/parsoid
13397 <table>
13398 <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>
13399 </tbody></table>
13400 !! end
13401
13402 !!test
13403 Templates: HTML Tables: 1. Generating start of a HTML table
13404 !! wikitext
13405 {{echo|<table><tr><td>foo</td>}}</tr></table>
13406 !! html
13407 <table><tr><td>foo</td></tr></table>
13408
13409 !!end
13410
13411 !!test
13412 Templates: HTML Tables: 2a. Generating middle of a HTML table
13413 !! wikitext
13414 <table><tr>{{echo|<td>foo</td>}}</tr></table>
13415 !! html
13416 <table><tr><td>foo</td></tr></table>
13417
13418 !!end
13419
13420 !!test
13421 Templates: HTML Tables: 2b. Generating middle of a HTML table
13422 !! wikitext
13423 <table>{{echo|<tr><td>foo</td></tr>}}</table>
13424 !! html
13425 <table><tr><td>foo</td></tr></table>
13426
13427 !!end
13428
13429 !!test
13430 Templates: HTML Tables: 3. Generating end of a HTML table
13431 !! wikitext
13432 <table><tr>{{echo|<td>foo</td></tr></table>}}
13433 !! html
13434 <table><tr><td>foo</td></tr></table>
13435
13436 !!end
13437
13438 !!test
13439 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13440 !! wikitext
13441 {{echo|<table>}}<tr><td>foo</td></tr></table>
13442 !! html
13443 <table><tr><td>foo</td></tr></table>
13444
13445 !!end
13446
13447 !!test
13448 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13449 !! wikitext
13450 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13451 !! html
13452 <table><tr><td>foo</td></tr></table>
13453
13454 !!end
13455
13456 !!test
13457 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13458 !! wikitext
13459 <table><tr>{{echo|<td>}}foo</td></tr></table>
13460 !! html
13461 <table><tr><td>foo</td></tr></table>
13462
13463 !!end
13464
13465 !!test
13466 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13467 !! wikitext
13468 <table><tr><td>foo{{echo|</td>}}</tr></table>
13469 !! html
13470 <table><tr><td>foo</td></tr></table>
13471
13472 !!end
13473
13474 !!test
13475 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13476 !! wikitext
13477 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13478 !! html
13479 <table><tr><td>foo</td></tr></table>
13480
13481 !!end
13482
13483 !!test
13484 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13485 !! wikitext
13486 <table><tr><td>foo</td></tr>{{echo|</table>}}
13487 !! html
13488 <table><tr><td>foo</td></tr></table>
13489
13490 !!end
13491
13492 !!test
13493 Templates: HTML Tables: 5. Proper fostering of categories from inside
13494 !!options
13495 parsoid=wt2html,wt2wt
13496 !! wikitext
13497 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13498 <!--Two categories (T52330)-->
13499 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13500 !! html/php+tidy
13501 <table><tbody><tr><td>foo</td></tr></tbody></table>
13502 <table><tbody><tr><td>foo</td></tr></tbody></table>
13503 !! html/parsoid
13504 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13505 <!--Two categories (T52330)-->
13506 <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>
13507 !!end
13508
13509 ## Remex doesn't account for fostered content.
13510 !! test
13511 Templates: Wiki Tables: 1a. Fostering of entire template content
13512 !! wikitext
13513 {|
13514 {{echo|a}}
13515 |}
13516 !! html/php
13517 <table>
13518 a
13519 <tr><td></td></tr></table>
13520
13521 !! html/php+tidy
13522
13523 a
13524 <table><tbody><tr><td></td></tr></tbody></table>
13525 !! html/parsoid
13526 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE","pi":[[{"k":"1"}]]}' data-mw='{"parts":["{|\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a"}},"i":0}},"\n|}"]}'>a</p><table about="#mwt2">
13527
13528 </table>
13529 !! end
13530
13531 !!test
13532 Templates: Wiki Tables: 1b. Fostering of entire template content
13533 !! wikitext
13534 {|
13535 {{echo|<div>}}
13536 foo
13537 {{echo|</div>}}
13538 |}
13539 !! html
13540 <table>
13541 <div>
13542 <p>foo
13543 </p>
13544 </div>
13545 <tr><td></td></tr></table>
13546
13547 !! html/php+tidy
13548 <div>
13549 <p>foo
13550 </p>
13551 </div><table>
13552
13553 <tbody><tr><td></td></tr></tbody></table>
13554 !! html/parsoid
13555 <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|}"]}'>
13556 <p>foo</p>
13557 </div><table about="#mwt3">
13558
13559 </table>
13560 !! end
13561
13562 ## Remex doesn't account for fostered content.
13563 !! test
13564 Templates: Wiki Tables: 2. Fostering of partial template content
13565 !! wikitext
13566 {|
13567 {{echo|a
13568 <div>b</div>}}
13569 |}
13570 !! html/php
13571 <table>
13572 a
13573 <div>b</div>
13574 <tr><td></td></tr></table>
13575
13576 !! html/php+tidy
13577
13578 a
13579 <div>b</div><table>
13580 <tbody><tr><td></td></tr></tbody></table>
13581 !! html/parsoid
13582 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE","pi":[[{"k":"1"}]]}' data-mw='{"parts":["{|\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n&lt;div>b&lt;/div>"}},"i":0}},"\n|}"]}'>a</p><div about="#mwt2">b</div><table about="#mwt2">
13583
13584
13585 </table>
13586 !! end
13587
13588 !!test
13589 Templates: Wiki Tables: 3. td-content via multiple templates
13590 !! wikitext
13591 {|
13592 {{echo|{{pipe}}a}}{{echo|b}}
13593 |}
13594 !! html
13595 <table>
13596 <tr>
13597 <td>ab
13598 </td></tr></table>
13599
13600 !!end
13601
13602 !!test
13603 Templates: Wiki Tables: 4. Templated tags, no content
13604 !! wikitext
13605 {{tbl-start}}
13606 {{tbl-end}}
13607 !! html
13608 <table>
13609 <tr><td></td></tr></table>
13610
13611 !!end
13612
13613 !!test
13614 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13615 !! wikitext
13616 {{tbl-start}}
13617 |foo
13618 {{tbl-end}}
13619 !! html
13620 <table>
13621 <tr>
13622 <td>foo
13623 </td></tr></table>
13624
13625 !!end
13626
13627 !!test
13628 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13629 !! wikitext
13630 {{tbl-start}}
13631 {{!}}foo
13632 {{tbl-end}}
13633 !! html
13634 <table>
13635 <tr>
13636 <td>foo
13637 </td></tr></table>
13638
13639 !!end
13640
13641 ## This test case is very specific to Parsoid's internals
13642 ## and is hence only tested for Parsoid's code. Parsoid uses
13643 ## a <meta> marker tag for <ref> tags and they are expanded
13644 ## much later. We are verifying that this <meta> tag usage
13645 ## doesn't prevent foster parenting.
13646 !! test
13647 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13648 !! wikitext
13649 {{PartialTable}}<ref>foo</ref>
13650 |}
13651
13652 <references />
13653 !! html/parsoid
13654 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"PartialTable","href":"./Template:PartialTable"},"params":{},"i":0}},"&lt;ref>foo&lt;/ref>\n|}"]}'><sup about="#mwt3" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-1"}}'><a href="./Parser_test#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></p><table about="#mwt2">
13655 <tbody>
13656 </tbody></table>
13657
13658 <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="./Parser_test#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>
13659 !! end
13660
13661 !! test
13662 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13663 !! wikitext
13664 {{echo|
13665 {{{!}}
13666 {{!}}-}}
13667 <onlyinclude>
13668 |foo
13669 </onlyinclude>
13670 {{!}}}
13671 !! html/parsoid
13672 <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{{!}}}"]}'>
13673 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13674 <tbody><tr>
13675
13676 <td>foo
13677 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13678 </tbody></table>
13679 !! end
13680
13681 !!test
13682 Templates: Lists: Multi-line list-items via templates
13683 !! wikitext
13684 *{{echo|a {{nonexistent|
13685 unused}}}}
13686 *{{echo|b {{nonexistent|
13687 unused}}}}
13688 !! html
13689 <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>
13690 <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>
13691
13692 !!end
13693
13694 !!test
13695 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13696 !! wikitext
13697 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13698 !! html
13699 <p><i>ab</i>c<i>d</i>e
13700 </p>
13701 !!end
13702
13703 !!test
13704 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13705 (PHP parser generates misnested html)
13706 !! wikitext
13707 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13708 !! html/parsoid
13709 <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>
13710 !!end
13711
13712 !!test
13713 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13714 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13715 !! options
13716 parsoid=wt2html,wt2wt
13717 !! wikitext
13718 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13719 !! html/php+tidy
13720 <div><i>a</i></div><div><i>b</i>c<i>d</i></div><div>e</div>
13721 !! html/parsoid
13722 <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>
13723 <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>
13724 <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>
13725 !!end
13726
13727 !!test
13728 Templates: Ugly nesting: 4. Divs opened/closed across templates
13729 !! wikitext
13730 a<div>b{{echo|c</div>d}}e
13731 !! html
13732 a<div>bc</div>de
13733
13734 !! html+tidy
13735 <p>a</p><div>bc</div><p>de
13736 </p>
13737 !! end
13738
13739 !! test
13740 Templates: Ugly templates: 3. newline-only template parameter
13741 !! wikitext
13742 foo {{echo|
13743 }}
13744 !! html
13745 <p>foo
13746 </p>
13747 !! end
13748
13749 # This looks like a bug: a single newline triggers p/br for some reason.
13750 !! test
13751 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13752 !! wikitext
13753 {{echo|
13754 }}
13755 !! html
13756 <p><br />
13757 </p>
13758 !! end
13759
13760 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13761 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13762 !! test
13763 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13764 !! wikitext
13765 {{echo|<table>}}
13766 {{echo|<div>foo}}
13767 {{echo|</table>}}
13768 !! html/parsoid
13769 <div about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}],[{"k":"1"}],[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;table>"}},"i":0}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;div>foo"}},"i":1}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;/table>"}},"i":2}}]}'>foo</div><span about="#mwt1">
13770 </span><table about="#mwt1">
13771 </table>
13772 !! end
13773
13774 # T66017 -- ugly wikitext with fostered content generates two template ranges
13775 # that are "identical" and generate nesting cycles in the algorithm
13776 !! test
13777 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13778 !! wikitext
13779 {{echo|<table><tr><td><table>}}
13780 {{echo|<div>}}
13781 {{echo|</div>}}
13782 !! html/parsoid
13783 <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"}'>
13784 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13785 </table></td></tr></tbody></table>
13786 !! end
13787
13788 !! test
13789 Templates: Parameters substituted at the top-level
13790 !! wikitext
13791 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13792
13793 {{{foo|bar|baz}}}
13794 !! html/php
13795 <p><i>who</i> me? <b>never!</b>
13796 </p><p>bar
13797 </p>
13798 !! html/parsoid
13799 <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>
13800
13801 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13802 !! end
13803
13804 !! test
13805 Templates: Param with empty arg in the final position
13806 !! wikitext
13807 {{{hi|}}}
13808 !! html/parsoid
13809 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13810 !! end
13811
13812 !!test
13813 Parser Functions: 1. Simple example
13814 !! wikitext
13815 {{uc:foo}}
13816 !! html
13817 <p>FOO
13818 </p>
13819 !!end
13820
13821 !!test
13822 Parser Functions: 2. Nested use (only outermost should be marked up)
13823 !! wikitext
13824 {{uc:{{lc:FOO}}}}
13825 !! html
13826 <p>FOO
13827 </p>
13828 !!end
13829
13830 ## Note that the templates inside the references are not wrapped
13831 !! test
13832 Template nested in extension tag in template
13833 !! options
13834 title=[[Main Page]]
13835 language=zh
13836 !! wikitext
13837 {{echo|hi<ref>[[ho|{{echo|hi}}]]</ref>}}
13838 {{echo|hi<ref>[http://test.com?q={{echo|ho}}]</ref>}}
13839 {{echo|hi<ref>-{ho|{{echo|hi}}}-</ref>}}
13840 <references />
13841 !! html/parsoid
13842 <p><span about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;ref>[[ho|{{echo|hi}}]]&lt;/ref>"}},"i":0}}]}'>hi</span><sup about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-1"}}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup>
13843 <span about="#mwt8" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;ref>[http://test.com?q={{echo|ho}}]&lt;/ref>"}},"i":0}}]}'>hi</span><sup about="#mwt8" class="mw-ref" id="cite_ref-2" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-2"}}'><a href="./Main_Page#cite_note-2" style="counter-reset: mw-Ref 2;"><span class="mw-reflink-text">[2]</span></a></sup>
13844 <span about="#mwt13" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;ref>-{ho|{{echo|hi}}}-&lt;/ref>"}},"i":0}}]}'>hi</span><sup about="#mwt13" class="mw-ref" id="cite_ref-3" rel="dc:references" typeof="mw:Extension/ref" data-mw='{"name":"ref","attrs":{},"body":{"id":"mw-reference-text-cite_note-3"}}'><a href="./Main_Page#cite_note-3" style="counter-reset: mw-Ref 3;"><span class="mw-reflink-text">[3]</span></a></sup></p>
13845 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt17" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text"><a rel="mw:WikiLink" href="./Ho" title="Ho">hi</a></span></li><li about="#cite_note-2" id="cite_note-2"><a href="./Main_Page#cite_ref-2" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-2" class="mw-reference-text"><a rel="mw:ExtLink" class="external autonumber" href="http://test.com?q=ho"></a></span></li><li about="#cite_note-3" id="cite_note-3"><a href="./Main_Page#cite_ref-3" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-3" class="mw-reference-text"><span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["ho"],"t":"hi"}}'></span></span></li></ol>
13846 !! end
13847
13848 ###
13849 ### Pre-save transform tests
13850 ###
13851
13852 !! test
13853 pre-save transform: subst:
13854 !! options
13855 pst
13856 !! wikitext
13857 {{subst:test}}
13858 !! html/php
13859 This is a test template
13860 !! end
13861
13862 !! test
13863 pre-save transform: normal template
13864 !! options
13865 pst
13866 !! wikitext
13867 {{test}}
13868 !! html/php
13869 {{test}}
13870 !! end
13871
13872 !! test
13873 pre-save transform: nonexistent template
13874 !! options
13875 pst
13876 !! wikitext
13877 {{thistemplatedoesnotexist}}
13878 !! html/php
13879 {{thistemplatedoesnotexist}}
13880 !! end
13881
13882 !! test
13883 pre-save transform: subst magic variables
13884 !! options
13885 pst
13886 !! wikitext
13887 {{subst:SITENAME}}
13888 !! html/php
13889 MediaWiki
13890 !! end
13891
13892 # This is T2089, which I fixed. -- wtm
13893 !! test
13894 pre-save transform: subst: templates with parameters
13895 !! options
13896 pst
13897 !! wikitext
13898 {{subst:paramtest|param="something else"}}
13899 !! html/php
13900 This is a test template with parameter "something else"
13901 !! end
13902
13903 !! article
13904 Template:nowikitest
13905 !! text
13906 <nowiki>'''not wiki'''</nowiki>
13907 !! endarticle
13908
13909 !! test
13910 pre-save transform: nowiki in subst (T3188)
13911 !! options
13912 pst
13913 !! wikitext
13914 {{subst:nowikitest}}
13915 !! html/php
13916 <nowiki>'''not wiki'''</nowiki>
13917 !! end
13918
13919 !! article
13920 Template:commenttest
13921 !! text
13922 This template has <!-- a comment --> in it.
13923 !! endarticle
13924
13925 !! test
13926 pre-save transform: comment in subst (T3936)
13927 !! options
13928 pst
13929 !! wikitext
13930 {{subst:commenttest}}
13931 !! html/php
13932 This template has <!-- a comment --> in it.
13933 !! end
13934
13935 !! test
13936 pre-save transform: unclosed tag
13937 !! options
13938 pst
13939 !! wikitext
13940 <nowiki>'''not wiki'''
13941 !! html/php
13942 <nowiki>'''not wiki'''
13943 !! end
13944
13945 !! test
13946 pre-save transform: mixed tag case
13947 !! options
13948 pst
13949 !! wikitext
13950 <NOwiki>'''not wiki'''</noWIKI>
13951 !! html/php
13952 <NOwiki>'''not wiki'''</noWIKI>
13953 !! end
13954
13955 !! test
13956 pre-save transform: unclosed comment in <nowiki>
13957 !! options
13958 pst
13959 !! wikitext
13960 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13961 !! html/php
13962 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13963 !!end
13964
13965 # Leading @ in this template definition works around a limitation
13966 # in parsoid's parserTests which otherwise strips the <span> from the
13967 # result (confusing it for a template wrapper)
13968 !! article
13969 Template:dangerous
13970 !!text
13971 @<span onmouseover="alert('crap')">Oh no</span>
13972 !!endarticle
13973
13974 !!test
13975 (confirming safety of fix for subst T3936)
13976 !! wikitext
13977 {{Template:dangerous}}
13978 !! html
13979 <p>@<span>Oh no</span>
13980 </p>
13981 !! end
13982
13983 !! test
13984 pre-save transform: comment containing gallery (T7024)
13985 !! options
13986 pst
13987 !! wikitext
13988 <!-- <gallery>data</gallery> -->
13989 !! html/php
13990 <!-- <gallery>data</gallery> -->
13991 !!end
13992
13993 !! test
13994 pre-save transform: comment containing extension
13995 !! options
13996 pst
13997 !! wikitext
13998 <!-- <tag>data</tag> -->
13999 !! html/php
14000 <!-- <tag>data</tag> -->
14001 !!end
14002
14003 !! test
14004 pre-save transform: comment containing nowiki
14005 !! options
14006 pst
14007 !! wikitext
14008 <!-- <nowiki>data</nowiki> -->
14009 !! html/php
14010 <!-- <nowiki>data</nowiki> -->
14011 !!end
14012
14013 !! test
14014 pre-save transform: <noinclude> in subst (T5298)
14015 !! options
14016 pst
14017 !! wikitext
14018 {{subst:Includes}}
14019 !! html/php
14020 Foobar
14021 !! end
14022
14023 !! test
14024 pre-save transform: <onlyinclude> in subst (T5298)
14025 !! options
14026 pst
14027 !! wikitext
14028 {{subst:Includes2}}
14029 !! html/php
14030 Foo
14031 !! end
14032
14033 !! article
14034 Template:SubstTest
14035 !!text
14036 {{<includeonly>subst:</includeonly>Includes}}
14037 !! endarticle
14038
14039 !! article
14040 Template:SafeSubstTest
14041 !! text
14042 {{<includeonly>safesubst:</includeonly>Includes}}
14043 !! endarticle
14044
14045 !! test
14046 T24297: safesubst: works during PST
14047 !! options
14048 pst
14049 !! wikitext
14050 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
14051 !! html/php
14052 FoobarFoobar
14053 !! end
14054
14055 !! test
14056 T24297: safesubst: works during normal parse
14057 !! wikitext
14058 {{SafeSubstTest}}
14059 !! html
14060 <p>Foobar
14061 </p>
14062 !! end
14063
14064 !! test
14065 subst: does not work during normal parse
14066 !! wikitext
14067 {{SubstTest}}
14068 !! html
14069 <p>{{subst:Includes}}
14070 </p>
14071 !! end
14072
14073 !! test
14074 pre-save transform: context links ("pipe trick")
14075 !! options
14076 pst
14077 !! wikitext
14078 [[Article (context)|]]
14079 [[Bar:Article|]]
14080 [[:Bar:Article|]]
14081 [[Bar:Article (context)|]]
14082 [[:Bar:Article (context)|]]
14083 [[|Article]]
14084 [[|Article (context)]]
14085 [[Bar:X (Y) Z|]]
14086 [[:Bar:X (Y) Z|]]
14087 !! html/php
14088 [[Article (context)|Article]]
14089 [[Bar:Article|Article]]
14090 [[:Bar:Article|Article]]
14091 [[Bar:Article (context)|Article]]
14092 [[:Bar:Article (context)|Article]]
14093 [[Article]]
14094 [[Article (context)]]
14095 [[Bar:X (Y) Z|X (Y) Z]]
14096 [[:Bar:X (Y) Z|X (Y) Z]]
14097 !! end
14098
14099 !! test
14100 pre-save transform: context links ("pipe trick") with interwiki prefix
14101 !! options
14102 pst
14103 !! wikitext
14104 [[interwiki:Article|]]
14105 [[:interwiki:Article|]]
14106 [[interwiki:Bar:Article|]]
14107 [[:interwiki:Bar:Article|]]
14108 !! html/php
14109 [[interwiki:Article|Article]]
14110 [[:interwiki:Article|Article]]
14111 [[interwiki:Bar:Article|Bar:Article]]
14112 [[:interwiki:Bar:Article|Bar:Article]]
14113 !! end
14114
14115 !! test
14116 pre-save transform: context links ("pipe trick") with parens in title
14117 !! options
14118 pst title=[[Somearticle (context)]]
14119 !! wikitext
14120 [[|Article]]
14121 !! html/php
14122 [[Article (context)|Article]]
14123 !! end
14124
14125 !! test
14126 pre-save transform: context links ("pipe trick") with comma in title
14127 !! options
14128 pst title=[[Someplace, Somewhere]]
14129 !! wikitext
14130 [[|Otherplace]]
14131 [[Otherplace, Elsewhere|]]
14132 [[Otherplace, Elsewhere, Anywhere|]]
14133 !! html/php
14134 [[Otherplace, Somewhere|Otherplace]]
14135 [[Otherplace, Elsewhere|Otherplace]]
14136 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
14137 !! end
14138
14139 !! test
14140 pre-save transform: context links ("pipe trick") with parens and comma
14141 !! options
14142 pst title=[[Someplace (IGNORED), Somewhere]]
14143 !! wikitext
14144 [[|Otherplace]]
14145 [[Otherplace (place), Elsewhere|]]
14146 !! html/php
14147 [[Otherplace, Somewhere|Otherplace]]
14148 [[Otherplace (place), Elsewhere|Otherplace]]
14149 !! end
14150
14151 !! test
14152 pre-save transform: context links ("pipe trick") with comma and parens
14153 !! options
14154 pst title=[[Who, me? (context)]]
14155 !! wikitext
14156 [[|Yes, you.]]
14157 [[Me, Myself, and I (1937 song)|]]
14158 !! html/php
14159 [[Yes, you. (context)|Yes, you.]]
14160 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
14161 !! end
14162
14163 !! test
14164 pre-save transform: context links ("pipe trick") with namespace
14165 !! options
14166 pst title=[[Ns:Somearticle]]
14167 !! wikitext
14168 [[|Article]]
14169 !! html/php
14170 [[Ns:Article|Article]]
14171 !! end
14172
14173 !! test
14174 pre-save transform: context links ("pipe trick") with namespace and parens
14175 !! options
14176 pst title=[[Ns:Somearticle (context)]]
14177 !! wikitext
14178 [[|Article]]
14179 !! html/php
14180 [[Ns:Article (context)|Article]]
14181 !! end
14182
14183 !! test
14184 pre-save transform: context links ("pipe trick") with namespace and comma
14185 !! options
14186 pst title=[[Ns:Somearticle, Context, Whatever]]
14187 !! wikitext
14188 [[|Article]]
14189 !! html/php
14190 [[Ns:Article, Context, Whatever|Article]]
14191 !! end
14192
14193 !! test
14194 pre-save transform: context links ("pipe trick") with namespace, comma and parens
14195 !! options
14196 pst title=[[Ns:Somearticle, Context (context)]]
14197 !! wikitext
14198 [[|Article]]
14199 !! html/php
14200 [[Ns:Article (context)|Article]]
14201 !! end
14202
14203 !! test
14204 pre-save transform: context links ("pipe trick") with namespace, parens and comma
14205 !! options
14206 pst title=[[Ns:Somearticle (IGNORED), Context]]
14207 !! wikitext
14208 [[|Article]]
14209 !! html/php
14210 [[Ns:Article, Context|Article]]
14211 !! end
14212
14213 !! test
14214 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
14215 !! options
14216 pst
14217 !! wikitext
14218 [[Article(context)|]]
14219 [[Bar:Article(context)|]]
14220 [[:Bar:Article(context)|]]
14221 [[|Article(context)]]
14222 [[Bar:X(Y)Z|]]
14223 [[:Bar:X(Y)Z|]]
14224 !! html/php
14225 [[Article(context)|Article]]
14226 [[Bar:Article(context)|Article]]
14227 [[:Bar:Article(context)|Article]]
14228 [[Article(context)]]
14229 [[Bar:X(Y)Z|X(Y)Z]]
14230 [[:Bar:X(Y)Z|X(Y)Z]]
14231 !! end
14232
14233 !! test
14234 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
14235 !! options
14236 pst
14237 !! wikitext
14238 [[Article (context)|]]
14239 [[Bar:Article (context)|]]
14240 [[:Bar:Article (context)|]]
14241 [[|Article (context)]]
14242 [[Bar:X (Y) Z|]]
14243 [[:Bar:X (Y) Z|]]
14244 !! html/php
14245 [[Article (context)|Article]]
14246 [[Bar:Article (context)|Article]]
14247 [[:Bar:Article (context)|Article]]
14248 [[Article (context)]]
14249 [[Bar:X (Y) Z|X (Y) Z]]
14250 [[:Bar:X (Y) Z|X (Y) Z]]
14251 !! end
14252
14253 !! test
14254 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
14255 !! options
14256 pst
14257 !! wikitext
14258 [[Article(context)|]]
14259 [[Bar:Article(context)|]]
14260 [[:Bar:Article(context)|]]
14261 [[|Article(context)]]
14262 [[Bar:X(Y)Z|]]
14263 [[:Bar:X(Y)Z|]]
14264 !! html/php
14265 [[Article(context)|Article]]
14266 [[Bar:Article(context)|Article]]
14267 [[:Bar:Article(context)|Article]]
14268 [[Article(context)]]
14269 [[Bar:X(Y)Z|X(Y)Z]]
14270 [[:Bar:X(Y)Z|X(Y)Z]]
14271 !! end
14272
14273 !! test
14274 pre-save transform: context links ("pipe trick") with commas (T23660)
14275 !! options
14276 pst
14277 !! wikitext
14278 [[Article (context), context|]]
14279 [[Article (context),context|]]
14280 [[Bar:Article (context), context|]]
14281 [[Bar:Article (context),context|]]
14282 [[:Bar:Article (context), context|]]
14283 [[:Bar:Article (context),context|]]
14284 !! html/php
14285 [[Article (context), context|Article]]
14286 [[Article (context),context|Article]]
14287 [[Bar:Article (context), context|Article]]
14288 [[Bar:Article (context),context|Article]]
14289 [[:Bar:Article (context), context|Article]]
14290 [[:Bar:Article (context),context|Article]]
14291 !! end
14292
14293 !! test
14294 Parsoid: backwards pipe trick
14295 !! wikitext
14296 [[|'''bar''']]
14297 !! html/php
14298 <p>[[|<b>bar</b>]]
14299 </p>
14300 !! html/parsoid
14301 <p>[[|<b>bar</b>]]</p>
14302 !! end
14303
14304 !! test
14305 pre-save transform: trim trailing empty lines
14306 !! options
14307 pst
14308 !! wikitext
14309 Empty lines are trimmed
14310
14311
14312
14313
14314 !! html/php
14315 Empty lines are trimmed
14316 !! end
14317
14318 !! test
14319 pre-save transform: Signature expansion
14320 !! options
14321 pst
14322 !! wikitext
14323 * ~~~
14324 * ~~~~
14325 * ~~~~~
14326 * <noinclude>~~~</noinclude>
14327 * <includeonly>~~~</includeonly>
14328 * <onlyinclude>~~~</onlyinclude>
14329 !! html/php
14330 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
14331 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14332 * 00:02, 1 January 1970 (UTC)
14333 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
14334 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
14335 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
14336 !! end
14337
14338
14339 !! test
14340 ParserOutput flags from signature expansion (T84843)
14341 !! options
14342 pst
14343 showflags
14344 !! wikitext
14345 ~~~~
14346 !! html/php
14347 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14348 flags=user-signature
14349 !! end
14350
14351
14352 !! test
14353 pre-save transform: Signature expansion in nowiki tags (T2093)
14354 !! options
14355 pst disabled
14356 !! wikitext
14357 Shall not expand:
14358
14359 <nowiki>~~~~</nowiki>
14360
14361 <includeonly><nowiki>~~~~</nowiki></includeonly>
14362
14363 <noinclude><nowiki>~~~~</nowiki></noinclude>
14364
14365 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14366
14367 {{subst:Foo}} shall be converted to FOO
14368
14369 As well as inside noinclude/onlyinclude
14370 <noinclude>{{subst:Foo}}</noinclude>
14371 <onlyinclude>{{subst:Foo}}</onlyinclude>
14372
14373 But not inside includeonly
14374 <includeonly>{{subst:Foo}}</includeonly>
14375 !! html/php
14376 Shall not expand:
14377
14378 <nowiki>~~~~</nowiki>
14379
14380 <includeonly><nowiki>~~~~</nowiki></includeonly>
14381
14382 <noinclude><nowiki>~~~~</nowiki></noinclude>
14383
14384 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14385
14386 FOO shall be converted to FOO
14387
14388 As well as inside noinclude/onlyinclude
14389 <noinclude>FOO</noinclude>
14390 <onlyinclude>FOO</onlyinclude>
14391
14392 But not inside includeonly
14393 <includeonly>{{subst:Foo}}</includeonly>
14394 !! end
14395
14396 !! test
14397 Parsoid: Recognize nowiki with trailing space in tags
14398 !! options
14399 parsoid=wt2html
14400 !! wikitext
14401 <nowiki ><div>[[foo]]</nowiki >
14402
14403 a<nowiki / >b
14404
14405 c<nowiki />d
14406
14407 e<nowiki/ >f
14408 !! html/php+tidy
14409 <p>&lt;div&gt;[[foo]]
14410 </p><p>a&lt;nowiki / &gt;b
14411 </p><p>cd
14412 </p><p>e&lt;nowiki/ &gt;f
14413 </p>
14414 !! html/parsoid
14415 <p><span typeof="mw:Nowiki">&lt;div>[[foo]]</span></p>
14416
14417 <p>a&lt;nowiki / >b</p>
14418
14419 <p>c<span typeof="mw:Nowiki"></span>d</p>
14420
14421 <p>e&lt;nowiki/ >f</p>
14422 !! end
14423
14424 !! test
14425 Parsoid: Recognize nowiki with odd capitalization
14426 !! options
14427 parsoid=wt2html
14428 !! wikitext
14429 <noWikI ><div>[[foo]]</Nowiki >
14430 !! html/php+tidy
14431 <p>&lt;div&gt;[[foo]]
14432 </p>
14433 !! html/parsoid
14434 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14435 !! end
14436
14437
14438 !! test
14439 Parsoid: Escape nowiki with trailing space in tags
14440 !! options
14441 parsoid=html2wt
14442 !! html/parsoid
14443 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14444 <p>a&lt;nowiki /&gt;b</p>
14445 <p>c&lt;nowiki/ &gt;d</p>
14446 !! wikitext
14447 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14448
14449 a&lt;nowiki /&gt;b
14450
14451 c&lt;nowiki/ &gt;d
14452 !! end
14453
14454 !! test
14455 Parsoid: Escape weird noWikI capitalizations
14456 !! options
14457 parsoid=html2wt
14458 !! html/parsoid
14459 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14460 !! wikitext
14461 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14462 !! end
14463
14464 ###
14465 ### Message transform tests
14466 ###
14467 !! test
14468 message transform: magic variables
14469 !! options
14470 msg
14471 !! wikitext
14472 {{SITENAME}}
14473 !! html
14474 MediaWiki
14475 !! end
14476
14477 !! test
14478 message transform: should not transform wiki markup
14479 !! options
14480 msg
14481 !! wikitext
14482 ''test''
14483 !! html
14484 ''test''
14485 !! end
14486
14487 !! test
14488 message transform: <noinclude> in transcluded template (T6926)
14489 !! options
14490 msg
14491 !! wikitext
14492 {{Includes}}
14493 !! html
14494 Foobar
14495 !! end
14496
14497 !! test
14498 message transform: <onlyinclude> in transcluded template (T6926)
14499 !! options
14500 msg
14501 !! wikitext
14502 {{Includes2}}
14503 !! html
14504 Foo
14505 !! end
14506
14507 !! test
14508 {{#special:}} page name, known
14509 !! options
14510 msg
14511 !! wikitext
14512 {{#special:Recentchanges}}
14513 !! html
14514 Special:RecentChanges
14515 !! end
14516
14517 !! test
14518 {{#special:}} page name with subpage, known
14519 !! options
14520 msg
14521 !! wikitext
14522 {{#special:Recentchanges/param}}
14523 !! html
14524 Special:RecentChanges/param
14525 !! end
14526
14527 !! test
14528 {{#special:}} page name, unknown
14529 !! options
14530 msg
14531 !! wikitext
14532 {{#special:foobar nonexistent}}
14533 !! html
14534 Special:Foobar nonexistent
14535 !! end
14536
14537 !! test
14538 {{#speciale:}} page name, known
14539 !! options
14540 msg
14541 !! wikitext
14542 {{#speciale:Recentchanges}}
14543 !! html
14544 Special:RecentChanges
14545 !! end
14546
14547 !! test
14548 {{#speciale:}} page name with subpage, known
14549 !! options
14550 msg
14551 !! wikitext
14552 {{#speciale:Recentchanges/param}}
14553 !! html
14554 Special:RecentChanges/param
14555 !! end
14556
14557 !! test
14558 {{#speciale:}} page name, unknown
14559 !! options
14560 msg
14561 !! wikitext
14562 {{#speciale:foobar nonexistent}}
14563 !! html
14564 Special:Foobar_nonexistent
14565 !! end
14566
14567 ###
14568 ### Images
14569 ###
14570 ### For Parsoid-specific tests, see
14571 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14572
14573 !! test
14574 Simple image
14575 !! options
14576 parsoid=wt2html,wt2wt,html2html
14577 !! wikitext
14578 [[Image:foobar.jpg]]
14579 !! html/php
14580 <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>
14581 </p>
14582 !! html/parsoid
14583 <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>
14584 !! end
14585
14586 !! test
14587 Serialize simple image with span wrapper
14588 !! options
14589 parsoid=html2wt
14590 !! html/parsoid
14591 <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>
14592 !! wikitext
14593 [[File:Foobar.jpg]]
14594 !! end
14595
14596 !! test
14597 Simple image (using File: namespace, now canonical)
14598 !! wikitext
14599 [[File:Foobar.jpg]]
14600 !! html/php
14601 <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>
14602 </p>
14603 !! html/parsoid
14604 <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>
14605 !! end
14606
14607 !! test
14608 Right-aligned image
14609 !! wikitext
14610 [[File:Foobar.jpg|right]]
14611 !! html/php
14612 <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>
14613
14614 !! html/parsoid
14615 <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>
14616 !! end
14617
14618 !! test
14619 Image with caption
14620 !! wikitext
14621 [[File:Foobar.jpg|right|Caption text]]
14622 !! html/php
14623 <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>
14624
14625 !! html/parsoid
14626 <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>
14627 !! end
14628
14629 !! test
14630 Image with caption, T55312 #1
14631 !! wikitext
14632 [[File:Foobar.jpg|right|Caption page stuff]]
14633 !! html/php
14634 <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>
14635
14636 !! html/parsoid
14637 <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>
14638 !! end
14639
14640 !! test
14641 Image with caption, T55312 #2
14642 !! wikitext
14643 [[File:Foobar.jpg|right|Caption page=]]
14644 !! html/php
14645 <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>
14646
14647 !! html/parsoid
14648 <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>
14649 !! end
14650
14651 !! test
14652 Image with caption, T55312 #3
14653 !! wikitext
14654 [[File:Foobar.jpg|right|Caption page=stuff]]
14655 !! html/php
14656 <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>
14657
14658 !! html/parsoid
14659 <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>
14660 !! end
14661
14662 !! test
14663 Image caption with pipe entity
14664 !! wikitext
14665 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14666 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14667 !! html/php
14668 <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>
14669 <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>
14670
14671 !! html/parsoid
14672 <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>
14673 <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>
14674 !! end
14675
14676 !! test
14677 Allow empty links in image captions (T62753)
14678 !! options
14679 thumbsize=220
14680 !! wikitext
14681 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14682 [[]]
14683 [[Link2]]
14684 ]]
14685 !! html/php
14686 <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>
14687
14688 !! html/parsoid
14689 <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>
14690 [[]]
14691 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14692 </figcaption></figure>
14693 !! end
14694
14695 !! test
14696 Titles in unlinked images (T23454)
14697 !! wikitext
14698 [[File:Foobar.jpg|link=|stuff]]
14699 !! html/php
14700 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
14701 </p>
14702 !! html/parsoid
14703 <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>
14704 !! end
14705
14706 !! test
14707 Link with empty target
14708 !! wikitext
14709 [[]]
14710 !! html
14711 <p>[[]]
14712 </p>
14713 !! end
14714
14715 !! test
14716 Image with link trail
14717 !! wikitext
14718 Linktrails should not work for images: [[File:Foobar.jpg]]s
14719 !! html/php
14720 <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
14721 </p>
14722 !! html/parsoid
14723 <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>
14724 !! end
14725
14726 !! test
14727 Image with empty attribute
14728 !! options
14729 parsoid=wt2html,wt2wt,html2html
14730 !! wikitext
14731 [[File:Foobar.jpg|right||Caption text]]
14732 !! html/php
14733 <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>
14734
14735 !! html/parsoid
14736 <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>
14737 !! end
14738
14739 !! test
14740 1. Block image with individual attributes from templates
14741 !! wikitext
14742 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14743 !! html/php
14744 <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>
14745
14746 !! html/parsoid
14747 <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>
14748 !! end
14749
14750 !! test
14751 2. Block Image with individual attributes from templates
14752 !! wikitext
14753 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14754 !! html/php
14755 <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>
14756
14757 !! html/parsoid
14758 <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>
14759 !! end
14760
14761 !! test
14762 3. Inline image with individual attributes from templates
14763 !! wikitext
14764 [[File:Foobar.jpg|{{echo|50px}}]]
14765 !! html/php
14766 <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>
14767 </p>
14768 !! html/parsoid
14769 <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>
14770 !! end
14771
14772 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14773 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14774 !! test
14775 Image with multiple attributes from the same template
14776 !! wikitext
14777 [[File:Foobar.jpg|{{image_attribs}}]]
14778 !! html/php
14779 <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>
14780
14781 !! html/parsoid
14782 <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>
14783 !! end
14784
14785 !! test
14786 Image with link tails
14787 !! options
14788 thumbsize=220
14789 !! wikitext
14790 123[[File:Foobar.jpg]]456
14791 123[[File:Foobar.jpg|right]]456
14792 123[[File:Foobar.jpg|thumb]]456
14793 !! html/php
14794 <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
14795 </p>
14796 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
14797 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
14798
14799 !! html/php+tidy
14800 <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
14801 </p><p>
14802 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
14803 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
14804 </p>
14805 !! html/parsoid
14806 <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>
14807 <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
14808 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>
14809 !! end
14810
14811 !! test
14812 Image with multiple captions -- only last one is accepted
14813 !! wikitext
14814 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14815 !! html/php
14816 <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>
14817
14818 !! html/parsoid
14819 <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>
14820 !! end
14821
14822 !! test
14823 Image with multiple widths -- use last
14824 !! wikitext
14825 [[File:Foobar.jpg|200px|300px|caption]]
14826 !! html/php
14827 <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>
14828 </p>
14829 !! html/parsoid
14830 <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>
14831 !! end
14832
14833 !! test
14834 Image with multiple alignments -- use first (T50664)
14835 !! options
14836 thumbsize=220
14837 !! wikitext
14838 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14839
14840 [[File:Foobar.jpg|middle|text-top|caption]]
14841 !! html/php
14842 <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>
14843 <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>
14844 </p>
14845 !! html/parsoid
14846 <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>
14847 <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>
14848 !! end
14849
14850 !! test
14851 Image with width attribute at different positions
14852 !! wikitext
14853 [[File:Foobar.jpg|200px|right|Caption]]
14854 [[File:Foobar.jpg|right|200px|Caption]]
14855 [[File:Foobar.jpg|right|Caption|200px]]
14856 !! html/php
14857 <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>
14858 <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>
14859 <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>
14860
14861 !! html/parsoid
14862 <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>
14863 <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>
14864 <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>
14865 !! end
14866
14867 # a sad bit of backward-compatibility
14868 !! test
14869 Image with size specified with pxpx (T15500, T53628)
14870 !! options
14871 parsoid=wt2html,wt2wt,html2html
14872 !! wikitext
14873 [[File:Foobar.jpg|20pxpx]]
14874 [[File:Foobar.jpg|200x20pxpx]]
14875 !! html/php
14876 <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>
14877 <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>
14878 </p>
14879 !! html/parsoid
14880 <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>
14881 !! end
14882
14883 !! test
14884 Image with link parameter, wiki target
14885 !! wikitext
14886 [[File:Foobar.jpg|link=Main Page]]
14887 !! html/php
14888 <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>
14889 </p>
14890 !! html/parsoid
14891 <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>
14892 !! end
14893
14894 # parsoid T51293 (part 1)
14895 !! test
14896 Image with link parameter, URL target
14897 !! wikitext
14898 [[File:Foobar.jpg|link=http://example.com/]]
14899 !! html/php
14900 <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>
14901 </p>
14902 !! html/parsoid
14903 <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>
14904 !! end
14905
14906 # parsoid T51293 (part 2)
14907 !! test
14908 Image with link parameter, protocol-less URL target
14909 !! wikitext
14910 [[File:Foobar.jpg|link=//example.com/]]
14911 !! html/php
14912 <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>
14913 </p>
14914 !! html/parsoid
14915 <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>
14916 !! end
14917
14918 !! test
14919 Escaping non-block captions (T107435)
14920 !! options
14921 parsoid={
14922 "modes": ["wt2wt"],
14923 "changes": [
14924 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14925 ]
14926 }
14927 !! wikitext
14928 [[Image:Foobar.jpg|caption]]
14929 !! wikitext/edited
14930 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14931 !! end
14932
14933 # wgExternalLinkTarget not supported by Parsoid
14934 !! test
14935 Image with link parameter, wgExternalLinkTarget
14936 !! wikitext
14937 [[Image:foobar.jpg|link=http://example.com/]]
14938 !! config
14939 wgExternalLinkTarget='foobar'
14940 !! html/php
14941 <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>
14942 </p>
14943 !! end
14944
14945 !! test
14946 Image with link parameter, wgNoFollowLinks set to false
14947 !! wikitext
14948 [[Image:foobar.jpg|link=http://example.com/]]
14949 !! config
14950 wgNoFollowLinks=false
14951 !! html/php
14952 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14953 </p>
14954 !! end
14955
14956 !! test
14957 Image with link parameter, wgNoFollowDomainExceptions
14958 !! wikitext
14959 [[Image:foobar.jpg|link=http://example.com/]]
14960 !! config
14961 wgNoFollowDomainExceptions='example.com'
14962 !! html/php
14963 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14964 </p>
14965 !! end
14966
14967 # wgExternalLinkTarget not supported by Parsoid
14968 !! test
14969 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14970 !! wikitext
14971 [[Image:foobar.jpg|link=http://example.com/|Title]]
14972 !! config
14973 wgExternalLinkTarget='foobar'
14974 !! html/php
14975 <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>
14976 </p>
14977 !! end
14978
14979 !! test
14980 Image with empty link parameter
14981 !! wikitext
14982 [[File:Foobar.jpg|link=]]
14983 !! html/php
14984 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14985 </p>
14986 !! html/parsoid
14987 <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>
14988 !! end
14989
14990 !! test
14991 Image with link parameter (wiki target) and unnamed parameter
14992 !! wikitext
14993 [[File:Foobar.jpg|link=Main_Page|Title]]
14994 !! html/php
14995 <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>
14996 </p>
14997 !! html/parsoid
14998 <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>
14999 !! end
15000
15001 !! test
15002 Image with link parameter (URL target) and unnamed parameter
15003 !! wikitext
15004 [[File:Foobar.jpg|link=http://example.com/|Title]]
15005 !! html/php
15006 <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>
15007 </p>
15008 !! html/parsoid
15009 <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>
15010 !! end
15011
15012 !! test
15013 Thumbnail image with link parameter
15014 !! options
15015 thumbsize=220
15016 parsoid=wt2html,wt2wt,html2html
15017 !! wikitext
15018 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
15019 !! html/php
15020 <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>
15021
15022 !! html/parsoid
15023 <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>
15024 !! end
15025
15026 !! test
15027 Manually-specified thumbnail image
15028 !! options
15029 thumbsize=220
15030 !! wikitext
15031 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
15032 !! html/php
15033 <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>
15034
15035 !! html/parsoid
15036 <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>
15037 !! end
15038
15039 !! test
15040 Manually-specified thumbnail image with explicit link to wiki page
15041 !! options
15042 thumbsize=220
15043 parsoid=wt2html,wt2wt,html2html
15044 !! wikitext
15045 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
15046 !! html/php
15047 <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>
15048
15049 !! html/parsoid
15050 <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>
15051 !! end
15052
15053 !! test
15054 Manually-specified thumbnail image with explicit link to url
15055 !! options
15056 thumbsize=220
15057 parsoid=wt2html,wt2wt,html2html
15058 !! wikitext
15059 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
15060 !! html/php
15061 <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>
15062
15063 !! html/parsoid
15064 <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>
15065 !! end
15066
15067 !! test
15068 Manually-specified thumbnail image with explicit no link
15069 !! options
15070 thumbsize=220
15071 parsoid=wt2html,wt2wt,html2html
15072 !! wikitext
15073 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
15074 !! html/php
15075 <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>
15076
15077 !! html/parsoid
15078 <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>
15079 !! end
15080
15081 !! test
15082 Manually-specified thumbnail image with explicit link and alt text
15083 !! options
15084 thumbsize=220
15085 parsoid=wt2html,wt2wt,html2html
15086 !! wikitext
15087 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
15088 !! html/php
15089 <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>
15090
15091 !! html/parsoid
15092 <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>
15093 !! end
15094
15095 !! test
15096 Image with frame and link
15097 !! options
15098 parsoid=wt2html,wt2wt,html2html
15099 !! wikitext
15100 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
15101 !! html/php
15102 <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>
15103
15104 !! html/parsoid
15105 <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>
15106 !! end
15107
15108 !! test
15109 Image with frame and link and explicit alt
15110 !! options
15111 parsoid=wt2html,wt2wt,html2html
15112 !! wikitext
15113 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
15114 !! html/php
15115 <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>
15116
15117 !! html/parsoid
15118 <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>
15119 !! end
15120
15121 !! test
15122 Image with wiki markup in implicit alt
15123 !! wikitext
15124 [[Image:Foobar.jpg|testing '''bold''' in alt]]
15125
15126 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
15127 !! html/php
15128 <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>
15129 </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>
15130 </p>
15131 !! html/parsoid
15132 <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>
15133
15134 <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>
15135 !! end
15136
15137 !! test
15138 Alt image option should handle most kinds of wikitext without barfing
15139 !! wikitext
15140 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
15141 !! html/php
15142 <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>
15143
15144 !! html/parsoid
15145 <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>
15146 !! end
15147
15148 !! test
15149 Ampersand in alt attribute (T206940)
15150 !! options
15151 parsoid = {
15152 "nativeGallery": true
15153 }
15154 !! wikitext
15155 [[File:Foobar.jpg|alt=&amp;amp;]]
15156
15157 <!-- consistency with gallery extension -->
15158 <gallery>
15159 File:Foobar.jpg|alt=&amp;amp;
15160 </gallery>
15161 !! html/php+tidy
15162 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="&amp;amp;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15163 </p>
15164 <ul class="gallery mw-gallery-traditional">
15165 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15166 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="&amp;amp;" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15167 <div class="gallerytext">
15168 </div>
15169 </div></li>
15170 </ul>
15171 !! html/parsoid
15172 <p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="&amp;amp;" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p>
15173
15174 <!-- consistency with gallery extension -->
15175 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15176 <li class="gallerybox">
15177 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="&amp;amp;" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15178 <div class="gallerytext"></div>
15179 </li>
15180 </ul>
15181 !! end
15182
15183 !! test
15184 Italics markup in alt attribute (T206940)
15185 !! wikitext
15186 [[File:Foobar.jpg|alt=''x''|caption]]
15187
15188 <!-- consistency with gallery extension -->
15189 <gallery>
15190 File:Foobar.jpg|alt=''x''|caption
15191 </gallery>
15192 !! html/php+tidy
15193 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="x" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15194 </p>
15195 <ul class="gallery mw-gallery-traditional">
15196 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15197 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="x" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15198 <div class="gallerytext">
15199 <p>caption
15200 </p>
15201 </div>
15202 </div></li>
15203 </ul>
15204 !! html/parsoid
15205 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"alt","ak":"alt=&apos;&apos;x&apos;&apos;"},{"ck":"caption","ak":"caption"}]}' data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img alt="x" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"alt":"x","resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"alt":"alt=&apos;&apos;x&apos;&apos;","resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
15206
15207 <!-- consistency with gallery extension -->
15208 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|alt=&apos;&apos;x&apos;&apos;|caption\n"}}'>
15209 <li class="gallerybox">
15210 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="x" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15211 <div class="gallerytext">caption</div>
15212 </li>
15213 </ul>
15214 !! end
15215
15216 !! test
15217 Nowiki markup in alt attribute (T206940)
15218 !! wikitext
15219 [[File:Foobar.jpg|alt=<nowiki>''</nowiki>x<nowiki>''</nowiki>|caption]]
15220
15221 <!-- consistency with gallery extension -->
15222 <gallery>
15223 File:Foobar.jpg|alt=<nowiki>''</nowiki>x<nowiki>''</nowiki>|caption
15224 </gallery>
15225 !! html/php+tidy
15226 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="&#39;&#39;x&#39;&#39;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15227 </p>
15228 <ul class="gallery mw-gallery-traditional">
15229 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15230 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="&#39;&#39;x&#39;&#39;" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15231 <div class="gallerytext">
15232 <p>caption
15233 </p>
15234 </div>
15235 </div></li>
15236 </ul>
15237 !! html/parsoid
15238 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"alt","ak":"alt=&lt;nowiki>&apos;&apos;&lt;/nowiki>x&lt;nowiki>&apos;&apos;&lt;/nowiki>"},{"ck":"caption","ak":"caption"}],"dsr":[0,71,null,null]}' data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img alt="''x''" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"alt":"&apos;&apos;x&apos;&apos;","resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"alt":"alt=&lt;nowiki>&apos;&apos;&lt;/nowiki>x&lt;nowiki>&apos;&apos;&lt;/nowiki>","resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
15239
15240 <!-- consistency with gallery extension -->
15241 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|alt=&lt;nowiki>&apos;&apos;&lt;/nowiki>x&lt;nowiki>&apos;&apos;&lt;/nowiki>|caption\n"}}'>
15242 <li class="gallerybox">
15243 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="''x''" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15244 <div class="gallerytext">caption</div>
15245 </li>
15246 </ul>
15247 !! end
15248
15249 !! test
15250 Nowiki markup in alt attribute (edited html, no data-parsoid) (T206940)
15251 !! options
15252 parsoid = {
15253 "nativeGallery": true
15254 }
15255 !! wikitext
15256 [[File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption]]
15257
15258 <!-- consistency with gallery extension -->
15259 <gallery>
15260 File:Foobar.jpg|alt=<nowiki>''x''</nowiki>|caption
15261 </gallery>
15262 !! html/php+tidy
15263 <p><a href="/wiki/File:Foobar.jpg" class="image" title="caption"><img alt="&#39;&#39;x&#39;&#39;" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15264 </p>
15265 <ul class="gallery mw-gallery-traditional">
15266 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15267 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="&#39;&#39;x&#39;&#39;" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15268 <div class="gallerytext">
15269 <p>caption
15270 </p>
15271 </div>
15272 </div></li>
15273 </ul>
15274 !! html/parsoid
15275 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./File:Foobar.jpg"><img alt="''x''" resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p>
15276
15277 <!-- consistency with gallery extension -->
15278 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15279 <li class="gallerybox">
15280 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="''x''" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15281 <div class="gallerytext">caption</div>
15282 </li>
15283 </ul>
15284 !! end
15285
15286 !! test
15287 Ampersand in link attribute (T206940)
15288 !! wikitext
15289 [[File:Foobar.jpg|link=Foo &amp; bar]]
15290
15291 <!-- consistency with gallery extension -->
15292 <gallery>
15293 File:Foobar.jpg|link=Foo &amp; bar
15294 </gallery>
15295 !! html/php+tidy
15296 <p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15297 </p>
15298 <ul class="gallery mw-gallery-traditional">
15299 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15300 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Foo_%26_bar"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15301 <div class="gallerytext">
15302 </div>
15303 </div></li>
15304 </ul>
15305 !! html/parsoid
15306 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"link","ak":"link=Foo &amp;amp; bar"}]}'><a href="./Foo_&amp;_bar" data-parsoid='{"a":{"href":"./Foo_&amp;_bar"},"sa":{"href":"link=Foo &amp;amp; bar"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p>
15307
15308 <!-- consistency with gallery extension -->
15309 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|link=Foo &amp;amp; bar\n"}}'>
15310 <li class="gallerybox">
15311 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Foo_&amp;_bar"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15312 <div class="gallerytext"></div>
15313 </li>
15314 </ul>
15315 !! end
15316
15317 !! test
15318 Ampersand in link attribute (edited html, no data-parsoid) (T206940)
15319 !! options
15320 parsoid = {
15321 "nativeGallery": true
15322 }
15323 !! wikitext
15324 [[File:Foobar.jpg|link=Foo_&_bar]]
15325
15326 <!-- consistency with gallery extension -->
15327 <gallery>
15328 File:Foobar.jpg|link=Foo_&_bar
15329 </gallery>
15330 !! html/php+tidy
15331 <p><a href="/wiki/Foo_%26_bar" title="Foo &amp; bar"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15332 </p>
15333 <ul class="gallery mw-gallery-traditional">
15334 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15335 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Foo_%26_bar"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15336 <div class="gallerytext">
15337 </div>
15338 </div></li>
15339 </ul>
15340 !! html/parsoid
15341 <p><figure-inline class="mw-default-size" typeof="mw:Image"><a href="./Foo_&amp;_bar"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p>
15342
15343 <!-- consistency with gallery extension -->
15344 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15345 <li class="gallerybox">
15346 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Foo_&amp;_bar"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15347 <div class="gallerytext"></div>
15348 </li>
15349 </ul>
15350 !! end
15351
15352 !! test
15353 Italics markup in link attribute (T206940)
15354 !! wikitext
15355 [[Foo''s bar''s]]
15356
15357 <!-- Note that "italics" are stripped, even though this is a valid page title -->
15358 [[File:Foobar.jpg|link=Foo''s bar''s|caption1]]
15359
15360 [[File:Foobar.jpg|link=''Main Page''|caption2]]
15361
15362 <!-- consistency with gallery extension -->
15363 <gallery>
15364 File:Foobar.jpg|link=Foo''s bar''s|caption1
15365 File:Foobar.jpg|link=''Main Page''|caption2
15366 </gallery>
15367 !! html/php+tidy
15368 <p><a href="/wiki/Foo%27%27s_bar%27%27s" title="Foo&#39;&#39;s bar&#39;&#39;s">Foo''s bar''s</a>
15369 </p><p><a href="/wiki/Foos_bars" title="caption1"><img alt="caption1" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15370 </p><p><a href="/wiki/Main_Page" title="caption2"><img alt="caption2" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15371 </p>
15372 <ul class="gallery mw-gallery-traditional">
15373 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15374 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Foos_bars"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15375 <div class="gallerytext">
15376 <p>caption1
15377 </p>
15378 </div>
15379 </div></li>
15380 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15381 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Main_Page"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15382 <div class="gallerytext">
15383 <p>caption2
15384 </p>
15385 </div>
15386 </div></li>
15387 </ul>
15388 !! html/parsoid
15389 <p><a rel="mw:WikiLink" href="./Foo''s_bar''s" title="Foo''s bar''s">Foo''s bar''s</a></p>
15390
15391 <!-- Note that "italics" are stripped, even though this is a valid page title -->
15392 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"link","ak":"link=Foo&apos;&apos;s bar&apos;&apos;s"},{"ck":"caption","ak":"caption1"}]}' data-mw='{"caption":"caption1"}'><a href="./Foos_bars" data-parsoid='{"a":{"href":"./Foos_bars"},"sa":{"href":"link=Foo&apos;&apos;s bar&apos;&apos;s"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
15393
15394 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"link","ak":"link=&apos;&apos;Main Page&apos;&apos;"},{"ck":"caption","ak":"caption2"}]}' data-mw='{"caption":"caption2"}'><a href="./Main_Page" data-parsoid='{"a":{"href":"./Main_Page"},"sa":{"href":"link=&apos;&apos;Main Page&apos;&apos;"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
15395
15396 <!-- consistency with gallery extension -->
15397 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|link=Foo&apos;&apos;s bar&apos;&apos;s|caption1\nFile:Foobar.jpg|link=&apos;&apos;Main Page&apos;&apos;|caption2\n"}}'>
15398 <li class="gallerybox">
15399 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Foos_bars"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15400 <div class="gallerytext">caption1</div>
15401 </li>
15402 <li class="gallerybox">
15403 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Main_Page"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15404 <div class="gallerytext">caption2</div>
15405 </li>
15406 </ul>
15407 !! end
15408
15409 !! test
15410 Nowiki markup in link attribute (T206940)
15411 !! wikitext
15412 [[File:Foobar.jpg|link=Foo<nowiki>''</nowiki>s_bar<nowiki>''</nowiki>s|caption]]
15413
15414 <!-- consistency with gallery extension -->
15415 <gallery>
15416 File:Foobar.jpg|link=Foo<nowiki>''</nowiki>s_bar<nowiki>''</nowiki>s|caption
15417 </gallery>
15418 !! html/php+tidy
15419 <p><a href="/wiki/Foo%27%27s_bar%27%27s" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15420 </p>
15421 <ul class="gallery mw-gallery-traditional">
15422 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15423 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Foo%27%27s_bar%27%27s"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15424 <div class="gallerytext">
15425 <p>caption
15426 </p>
15427 </div>
15428 </div></li>
15429 </ul>
15430 !! html/parsoid
15431 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"link","ak":"link=Foo&lt;nowiki>&apos;&apos;&lt;/nowiki>s_bar&lt;nowiki>&apos;&apos;&lt;/nowiki>s"},{"ck":"caption","ak":"caption"}]}' data-mw='{"caption":"caption"}'><a href="./Foo''s_bar''s" data-parsoid='{"a":{"href":"./Foo&apos;&apos;s_bar&apos;&apos;s"},"sa":{"href":"link=Foo&lt;nowiki>&apos;&apos;&lt;/nowiki>s_bar&lt;nowiki>&apos;&apos;&lt;/nowiki>s"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"File:Foobar.jpg"}}'/></a></figure-inline></p>
15432
15433 <!-- consistency with gallery extension -->
15434 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{"extsrc":"\nFile:Foobar.jpg|link=Foo&lt;nowiki>&apos;&apos;&lt;/nowiki>s_bar&lt;nowiki>&apos;&apos;&lt;/nowiki>s|caption\n"}}'>
15435 <li class="gallerybox">
15436 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Foo''s_bar''s"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15437 <div class="gallerytext">caption</div>
15438 </li>
15439 </ul>
15440 !! end
15441
15442 !! test
15443 Nowiki markup in link attribute (edited html, no data-parsoid) (T206940)
15444 !! options
15445 parsoid = {
15446 "nativeGallery": true
15447 }
15448 !! wikitext
15449 [[File:Foobar.jpg|link=Foo<nowiki>''s_bar''</nowiki>s|caption]]
15450
15451 <!-- consistency with gallery extension -->
15452 <gallery>
15453 File:Foobar.jpg|link=Foo<nowiki>''s_bar''</nowiki>s|caption
15454 </gallery>
15455 !! html/php+tidy
15456 <p><a href="/wiki/Foo%27%27s_bar%27%27s" title="caption"><img alt="caption" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
15457 </p>
15458 <ul class="gallery mw-gallery-traditional">
15459 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
15460 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/Foo%27%27s_bar%27%27s"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
15461 <div class="gallerytext">
15462 <p>caption
15463 </p>
15464 </div>
15465 </div></li>
15466 </ul>
15467 !! html/parsoid
15468 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-mw='{"caption":"caption"}'><a href="./Foo''s_bar''s"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure-inline></p>
15469
15470 <!-- consistency with gallery extension -->
15471 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
15472 <li class="gallerybox">
15473 <div class="thumb"><figure-inline typeof="mw:Image"><a href="./Foo''s_bar''s"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div>
15474 <div class="gallerytext">caption</div>
15475 </li>
15476 </ul>
15477 !! end
15478
15479 !! test
15480 Image with table with attributes in caption
15481 !! options
15482 parsoid=wt2html,html2html
15483 !! wikitext
15484 [[File:Foobar.jpg|thumb|
15485 {| class="123" |
15486 |- class="456" |
15487 | ha
15488 |}
15489 ]]
15490 !! html/parsoid
15491 <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>
15492 <table class="123">
15493 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
15494 <td> ha</td></tr>
15495 </tbody></table>
15496 </figcaption></figure>
15497 !! end
15498
15499 !! test
15500 Image with table with rows from templates in caption
15501 !! wikitext
15502 [[File:Foobar.jpg|thumb|
15503 {|
15504 {{echo|{{!}} hi}}
15505 |}
15506 ]]
15507 !! html/parsoid
15508 <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>
15509 <table>
15510 <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>
15511 </tbody></table>
15512 </figcaption></figure>
15513 !! end
15514
15515 !! test
15516 Image with nested tables in caption
15517 !! wikitext
15518 [[File:Foobar.jpg|thumb|Foo<br />
15519 {|
15520 |
15521 {|
15522 |z
15523 |}
15524 |}
15525 ]]
15526 !! html/parsoid
15527 <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}'/>
15528 <table>
15529 <tbody><tr><td>
15530 <table>
15531 <tbody><tr><td>z</td></tr>
15532 </tbody></table></td></tr>
15533 </tbody></table>
15534 </figcaption></figure>
15535 !! end
15536
15537 !! test
15538 Image with heading and horizontal rule in caption
15539 !! wikitext
15540 [[File:Foobar.jpg|thumb|
15541 ===Testing===
15542 123
15543 --------------
15544 ]]
15545 !! html/php
15546 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div><h3><span class="mw-headline" id="Testing">Testing</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Testing">edit</a><span class="mw-editsection-bracket">]</span></span></h3> 123 <hr /></div></div></div>
15547
15548 !! html/parsoid
15549 <figure class="mw-default-size" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"\n=== Testing ===\n123\n--------------\n"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"},"sa":{"href":"File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>
15550 <h3 id="Testing">Testing</h3>
15551 123
15552 <hr data-parsoid='{"extra_dashes":10}'/>
15553 </figcaption></figure>
15554 !! end
15555
15556 ###################
15557 # Conflicting image format options.
15558 # First option specified should 'win'.
15559 # All three cases in each test should be identical.
15560
15561 !! test
15562 Image with 'frameless' first.
15563 !! options
15564 parsoid=wt2html,wt2wt,html2html
15565 !! wikitext
15566 [[File:Foobar.jpg|frameless|caption]]
15567
15568 [[File:Foobar.jpg|frameless|frame|caption]]
15569
15570 [[File:Foobar.jpg|frameless|thumb|caption]]
15571 !! html/php
15572 <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>
15573 </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>
15574 </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>
15575 </p>
15576 !! html/parsoid
15577 <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>
15578 <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>
15579 <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>
15580 !! end
15581
15582 !! test
15583 Image with 'frame' first.
15584 !! options
15585 parsoid=wt2html,wt2wt,html2html
15586 !! wikitext
15587 [[File:Foobar.jpg|frame|caption]]
15588 [[File:Foobar.jpg|frame|frameless|caption]]
15589 [[File:Foobar.jpg|frame|thumb|caption]]
15590 !! html/php
15591 <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>
15592 <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>
15593 <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>
15594
15595 !! html/parsoid
15596 <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>
15597 <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>
15598 <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>
15599 !! end
15600
15601 !! test
15602 Image with 'thumb' first.
15603 !! options
15604 parsoid=wt2html,wt2wt,html2html
15605 !! wikitext
15606 [[File:Foobar.jpg|thumb|caption]]
15607 [[File:Foobar.jpg|thumb|frameless|caption]]
15608 [[File:Foobar.jpg|thumb|frame|caption]]
15609 !! html/php
15610 <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>
15611 <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>
15612 <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>
15613
15614 !! html/parsoid
15615 <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>
15616 <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>
15617 <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>
15618 !! end
15619
15620 ###################
15621 # Image sizing.
15622 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
15623 # and https://phabricator.wikimedia.org/T64258
15624 # Foobar has actual size of 1941x220
15625 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
15626 # a scalable format.
15627 # 2. Framed images always ignore size options; always render at default size.
15628 # 3. "Unspecified format" and border are the only types which can be
15629 # enlarged.
15630
15631 !! test
15632 Image: unspecified format and border enlarge
15633 !! options
15634 parsoid=wt2html,wt2wt,html2html
15635 !! wikitext
15636 [[File:Foobar.jpg|2000px]]
15637
15638 [[File:Foobar.jpg|border|2000px]]
15639 !! html/php
15640 <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>
15641 </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>
15642 </p>
15643 !! html/parsoid
15644 <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>
15645 <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>
15646 !! end
15647
15648 !! test
15649 Image: "unspecified format" and border reduce
15650 !! options
15651 parsoid=wt2html,wt2wt,html2html
15652 !! wikitext
15653 [[File:Foobar.jpg|1000px]]
15654
15655 [[File:Foobar.jpg|border|1000px]]
15656 !! html/php
15657 <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>
15658 </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>
15659 </p>
15660 !! html/parsoid
15661 <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>
15662 <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>
15663 !! end
15664
15665 !! test
15666 Image: thumbs reduce
15667 !! options
15668 parsoid=wt2html,wt2wt,html2html
15669 !! wikitext
15670 [[File:Foobar.jpg|thumb|50px]]
15671 !! html/php
15672 <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>
15673
15674 !! html/parsoid
15675 <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>
15676 !! end
15677
15678 !! test
15679 Image: bitmap thumbs can't be enlarged past original size, but vector can.
15680 !! options
15681 parsoid=wt2html,wt2wt,html2html
15682 !! wikitext
15683 [[File:Foobar.jpg|thumb|2000px]]
15684
15685 [[File:Foobar.svg|thumb|2000px]]
15686 !! html/php
15687 <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>
15688 <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>
15689
15690 !! html/parsoid
15691 <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>
15692 <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>
15693 !! end
15694
15695 !! test
15696 Image: frameless can reduce in size
15697 !! options
15698 parsoid=wt2html,wt2wt,html2html
15699 !! wikitext
15700 [[File:Foobar.jpg|frameless|50px]]
15701 !! html/php
15702 <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>
15703 </p>
15704 !! html/parsoid
15705 <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>
15706 !! end
15707
15708 !! test
15709 Image: bitmap frameless can't be enlarged past original size, but vector can
15710 !! options
15711 parsoid=wt2html,wt2wt,html2html
15712 !! wikitext
15713 [[File:Foobar.jpg|frameless|2000px]]
15714
15715 [[File:Foobar.svg|frameless|2000px]]
15716 !! html/php
15717 <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>
15718 </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>
15719 </p>
15720 !! html/parsoid
15721 <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>
15722 <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>
15723 !! end
15724
15725 !! test
15726 Image: framed images are always unscaled.
15727 !! options
15728 parsoid=wt2html,wt2wt,html2html
15729 !! wikitext
15730 [[File:Foobar.jpg|frame]]
15731
15732 [[File:Foobar.jpg|frame|50px]]
15733
15734 [[File:Foobar.jpg|frame|50x50px]]
15735
15736 [[File:Foobar.jpg|frame|2000px]]
15737 !! html/php
15738 <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>
15739 <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>
15740 <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>
15741 <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>
15742
15743 !! html/parsoid
15744 <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>
15745 <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>
15746 <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>
15747 <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>
15748 !! end
15749
15750 ###################
15751
15752 !! test
15753 Link to image page- image page normally doesn't exists, hence edit link
15754 Add test with existing image page
15755 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
15756 !! wikitext
15757 [[:Image:test]]
15758 !! html
15759 <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>
15760 </p>
15761 !! end
15762
15763 !! test
15764 T20784 Link to non-existent image page with caption should use caption as link text
15765 !! wikitext
15766 [[:Image:test|caption]]
15767 !! html
15768 <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>
15769 </p>
15770 !! end
15771
15772 !! test
15773 Frameless image caption with a free URL
15774 !! wikitext
15775 [[File:Foobar.jpg|http://example.com]]
15776 !! html/php
15777 <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>
15778 </p>
15779 !! html/parsoid
15780 <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>
15781 !! end
15782
15783 !! test
15784 Thumbnail image caption with a free URL
15785 !! options
15786 thumbsize=220
15787 !! wikitext
15788 [[File:Foobar.jpg|thumb|http://example.com]]
15789 !! html/php
15790 <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>
15791
15792 !! html/parsoid
15793 <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>
15794 !! end
15795
15796 !! test
15797 Thumbnail image caption with a free URL and explicit alt
15798 !! options
15799 thumbsize=220
15800 parsoid=wt2html,wt2wt,html2html
15801 !! wikitext
15802 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
15803 !! html/php
15804 <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>
15805
15806 !! html/parsoid
15807 <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>
15808 !! end
15809
15810 !! test
15811 SVG thumbnails with no language set
15812 !! options
15813 !! wikitext
15814 [[File:Foobar.svg|thumb|caption]]
15815 !! html/php
15816 <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>
15817
15818 !! html/parsoid
15819 <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>
15820 !! end
15821
15822 !! test
15823 SVG thumbnails with language de
15824 !! options
15825 parsoid=wt2html,wt2wt,html2html
15826 !! wikitext
15827 [[File:Foobar.svg|thumb|caption|lang=de]]
15828 !! html/php
15829 <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>
15830
15831 !! html/parsoid
15832 <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>
15833 !! end
15834
15835 !! test
15836 SVG thumbnails with invalid language code
15837 !! options
15838 parsoid=wt2html,wt2wt,html2html
15839 !! wikitext
15840 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
15841 !! html/php
15842 <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>
15843
15844 !! html/parsoid
15845 <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>
15846 !! end
15847
15848 !! test
15849 SVG thumbnails in page language
15850 !! options
15851 language=ru
15852 wgMediaInTargetLanguage = true
15853 !! wikitext
15854 [[File:Foobar.svg]] [[File:Foobar.svg|lang=en]]
15855 !! html/php
15856 <p><a href="/wiki/%D0%A4%D0%B0%D0%B9%D0%BB:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/langru-240px-Foobar.svg.png" width="240" height="180" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/langru-360px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/langru-480px-Foobar.svg.png 2x" /></a> <a href="/index.php?title=%D0%A4%D0%B0%D0%B9%D0%BB:Foobar.svg&amp;lang=en" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/240px-Foobar.svg.png" width="240" height="180" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/480px-Foobar.svg.png 2x" /></a>
15857 </p>
15858 !! end
15859
15860 !! test
15861 SVG thumbnails in page language not present in the file
15862 !! options
15863 language=de
15864 wgMediaInTargetLanguage = true
15865 !! wikitext
15866 [[File:Foobar.svg]] [[File:Foobar.svg|lang=ru]]
15867 !! html/php
15868 <p><a href="/wiki/Datei:Foobar.svg" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/240px-Foobar.svg.png" width="240" height="180" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/360px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/480px-Foobar.svg.png 2x" /></a> <a href="/index.php?title=Datei:Foobar.svg&amp;lang=ru" class="image"><img alt="Foobar.svg" src="http://example.com/images/thumb/f/ff/Foobar.svg/langru-240px-Foobar.svg.png" width="240" height="180" srcset="http://example.com/images/thumb/f/ff/Foobar.svg/langru-360px-Foobar.svg.png 1.5x, http://example.com/images/thumb/f/ff/Foobar.svg/langru-480px-Foobar.svg.png 2x" /></a>
15869 </p>
15870 !! end
15871
15872 !! test
15873 T3887: A ISBN with a thumbnail
15874 !! wikitext
15875 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15876 !! html/php
15877 <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>
15878
15879 !! html/parsoid
15880 <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>
15881 !! end
15882
15883 !! test
15884 T3887: A RFC with a thumbnail
15885 !! wikitext
15886 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15887 !! html/php
15888 <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>
15889
15890 !! html/parsoid
15891 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>This is <a href="https://tools.ietf.org/html/rfc12354" rel="mw:ExtLink" class="external mw-magiclink">RFC 12354</a></figcaption></figure>
15892 !! end
15893
15894 !! test
15895 T3887: A mailto link with a thumbnail
15896 !! wikitext
15897 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15898 !! html/php
15899 <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>
15900
15901 !! html/parsoid
15902 <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>
15903 !! end
15904
15905 # Pending resolution to T2368
15906 !! test
15907 T2648: Frameless image caption with a link
15908 !! wikitext
15909 [[File:Foobar.jpg|text with a [[link]] in it]]
15910 !! html/php
15911 <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>
15912 </p>
15913 !! html/parsoid
15914 <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>
15915 !! end
15916
15917 !! test
15918 T2648: Frameless image caption with a link (suffix)
15919 !! wikitext
15920 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15921 !! html/php
15922 <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>
15923 </p>
15924 !! html/parsoid
15925 <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>
15926 !! end
15927
15928 !! test
15929 T2648: Frameless image caption with an interwiki link
15930 !! wikitext
15931 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15932 !! html/php
15933 <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>
15934 </p>
15935 !! html/parsoid
15936 <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>
15937 !! end
15938
15939 !! test
15940 T2648: Frameless image caption with a piped interwiki link
15941 !! wikitext
15942 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15943 !! html/php
15944 <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>
15945 </p>
15946 !! html/parsoid
15947 <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>
15948 !! end
15949
15950 !! test
15951 T107474: Frameless image caption with <nowiki>
15952 !! wikitext
15953 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15954 !! html/parsoid
15955 <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>
15956 !! end
15957
15958 !! test
15959 Escape HTML special chars in image alt text
15960 !! wikitext
15961 [[File:Foobar.jpg|& < > "]]
15962 !! html/php
15963 <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>
15964 </p>
15965 !! html/parsoid
15966 <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>
15967 !! end
15968
15969 !! test
15970 Escape HTML special chars in image alt text with LanguageConverter
15971 !! options
15972 language=zh
15973 !! wikitext
15974 [[File:Foobar.jpg|& < > "]]
15975 !! html/php
15976 <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>
15977 </p>
15978 !! html/parsoid
15979 <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>
15980 !! end
15981
15982 !! test
15983 Entities in file name and attributes
15984 !! wikitext
15985 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
15986 !! html/php
15987 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
15988 </p>
15989 !! html/parsoid
15990 <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>
15991 !! end
15992
15993 !! test
15994 T2499: Alt text should have &#1234;, not &amp;1234;
15995 !! wikitext
15996 [[File:Foobar.jpg|&#9792;]]
15997 !! html/php
15998 <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>
15999 </p>
16000 !! html/parsoid
16001 <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>
16002 !! end
16003
16004 !! test
16005 Broken image caption with link
16006 !! options
16007 parsoid=wt2html,wt2wt,html2html
16008 !! wikitext
16009 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
16010 !! html/php
16011 <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.
16012 </p>
16013 !! html/parsoid
16014 <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>
16015 !! end
16016
16017 !! test
16018 Image caption containing another image
16019 !! wikitext
16020 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
16021 !! html/php
16022 <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>
16023
16024 !! html/parsoid
16025 <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>
16026 !! end
16027
16028 !! test
16029 Image: caption containing a newline
16030 !! wikitext
16031 [[File:Foobar.jpg|This
16032 *is some text]]
16033 !! html/php
16034 <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>
16035 </p>
16036 !! html/parsoid
16037 <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>
16038 !!end
16039
16040 !!test
16041 Image: caption containing leading space
16042 (The leading space should not trigger nowiki escaping in wt2wt mode)
16043 !! wikitext
16044 [[File:Foobar.jpg|thumb| bar]]
16045 !! html/php
16046 <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>
16047
16048 !! html/parsoid
16049 <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>
16050 !!end
16051
16052 # html/php output not have newlines after table, td, th, etc. because
16053 # Linker::makeThumbLink2() replaces the newlines with spaces since
16054 # the table is inside a caption.
16055 # FIXME: Verify if that circa 2004 fix is still required.
16056 !! test
16057 Image: caption containing a table
16058 !! options
16059 parsoid=wt2html,wt2wt,html2html
16060 !! wikitext
16061 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
16062 {|
16063 !Foo!!Bar
16064 |-
16065 |Foo1||Bar1
16066 |}
16067 and some more text.]]
16068 !! html/php
16069 <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>
16070
16071 !! html/parsoid
16072 <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
16073 <table>
16074 <tbody>
16075 <tr><th>Foo</th><th>Bar</th></tr>
16076 <tr>
16077 <td>Foo1</td>
16078 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
16079 !! end
16080
16081 !! test
16082 T5090: External links other than http: in image captions
16083 !! wikitext
16084 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
16085 !! html/php
16086 <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>
16087
16088 !! html/parsoid
16089 <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>
16090 !! end
16091
16092 !! test
16093 Custom class
16094 !! options
16095 parsoid=wt2html,wt2wt,html2html
16096 !! wikitext
16097 [[Image:foobar.jpg|a|class=b]]
16098 !! html/php
16099 <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>
16100 </p>
16101 !! html/parsoid
16102 <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>
16103 !! end
16104
16105 !! test
16106 Localized image handling (1).
16107 !! options
16108 parsoid=wt2html,wt2wt,html2html
16109 language=es
16110 !! wikitext
16111 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
16112 !! html/php
16113 <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>
16114
16115 !! html/parsoid
16116 <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>
16117 !! end
16118
16119 !! test
16120 Localized image handling (2).
16121 !! options
16122 thumbsize=220
16123 parsoid=wt2html,wt2wt,html2html
16124 language=es
16125 !! wikitext
16126 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
16127 !! html/php
16128 <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>
16129
16130 !! html/parsoid
16131 <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>
16132 !! end
16133
16134 !! test
16135 Localized image handling (3).
16136 !! options
16137 language=fa
16138 parsoid=html2wt
16139 !! html/parsoid
16140 <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>
16141 !! wikitext
16142 [[File:Foobar.jpg|بندانگشتی]]
16143 !! end
16144
16145 !! test
16146 "border", "frameless" and "class" attributes on an image.
16147 !! options
16148 thumbsize=220
16149 parsoid=wt2html,wt2wt,html2html
16150 !! wikitext
16151 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
16152 !! html/php
16153 <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>
16154 </p>
16155 !! html/parsoid
16156 <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>
16157 !! end
16158
16159 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
16160 !! test
16161 Invalid image attributes (T64500)
16162 !! options
16163 thumbsize=220
16164 parsoid=wt2html,wt2wt,html2html
16165 !! wikitext
16166 [[File:Foobar.jpg|thumb|float|left|caption]]
16167
16168 [[File:Foobar.jpg|thumb|righ|caption]]
16169
16170 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
16171 !! html/php
16172 <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>
16173 <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>
16174 <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>
16175
16176 !! html/parsoid
16177 <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>
16178 <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>
16179 <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>
16180 !! end
16181
16182 !! article
16183 File:Barfoo.jpg
16184 !! text
16185 #REDIRECT [[File:Barfoo.jpg]]
16186 !! endarticle
16187
16188 # FIXME: Parsoid should run this test -- but we'd need to teach the
16189 # mockAPI about the redirected Barfoo.jpg image.
16190 !! test
16191 Redirected image
16192 !! wikitext
16193 [[Image:Barfoo.jpg]]
16194 !! html/php
16195 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
16196 </p>
16197 !! end
16198
16199 !! test
16200 Missing image with uploads disabled
16201 !! options
16202 wgEnableUploads=0
16203 !! wikitext
16204 [[File:Foobaz.jpg]]
16205 !! html/php
16206 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
16207 </p>
16208 !! html/parsoid
16209 <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>
16210 !! end
16211
16212 # Parsoid-specific testing for images
16213 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
16214 # Currently imperfect due to a flaw in the Parsoid testrunner
16215 # Work in progress
16216 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
16217 # image tests.
16218
16219 !! test
16220 Parsoid-specific image handling - simple image with size and middle alignment
16221 !! wikitext
16222 [[File:Foobar.jpg|middle|50px]]
16223 !! html/parsoid
16224 <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>
16225 !! end
16226
16227 !! test
16228 Parsoid-specific image handling - simple image with size, middle alignment, non-standard namespace alias
16229 !! options
16230 parsoid=wt2wt,wt2html,html2html
16231 !! wikitext
16232 [[Image:Foobar.jpg|middle|50px]]
16233 !! html/parsoid
16234 <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>
16235 !! end
16236
16237 !! test
16238 Parsoid-specific image handling - simple image with size and middle alignment (existing content)
16239 !! wikitext
16240 [[File:Foobar.jpg|50px|middle]]
16241 !! html/parsoid
16242 <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>
16243 !! end
16244
16245 !! test
16246 Parsoid-specific image handling - simple image with size and middle alignment and non-standard namespace name
16247 !! options
16248 parsoid=wt2html,wt2wt,html2html
16249 !! wikitext
16250 [[Image:Foobar.jpg|50px|middle]]
16251 !! html/parsoid
16252 <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>
16253 !! end
16254
16255 !! test
16256 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
16257 !! wikitext
16258 [[File:Foobar.jpg|500x10px|baseline|caption]]
16259 !! html/parsoid
16260 <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>
16261 !! end
16262
16263 !! test
16264 Parsoid-specific image handling - simple image with border and size spec
16265 !! wikitext
16266 [[File:Foobar.jpg|50px|border|caption]]
16267 !! html/parsoid
16268 <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>
16269 !! end
16270
16271 !! test
16272 Parsoid-specific image handling - thumbnail with halign, valign, and caption
16273 !! options
16274 parsoid=wt2html,html2html
16275 !! wikitext
16276 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
16277 !! html/parsoid
16278 <figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption content</figcaption></figure>
16279 !! end
16280
16281 !! test
16282 Parsoid-specific image handling - thumbnail with halign, valign, and caption (existing content)
16283 !! options
16284 parsoid=wt2html,html2html
16285 !! wikitext
16286 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
16287 !! html/parsoid
16288 <figure class="mw-default-size mw-halign-left" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"left","ak":"left"},{"ck":"baseline","ak":"baseline"},{"ck":"caption","ak":"caption content"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>caption content</figcaption></figure>
16289 !! end
16290
16291 !! test
16292 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
16293 !! options
16294 parsoid=wt2html,html2html
16295 !! wikitext
16296 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
16297 !! html/parsoid
16298 <figure class="mw-halign-right" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a><figcaption>caption</figcaption></figure>
16299 !! end
16300
16301 !! test
16302 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption (existing content)
16303 !! options
16304 parsoid=wt2html,html2html
16305 !! wikitext
16306 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
16307 !! html/parsoid
16308 <figure class="mw-halign-right" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"width","ak":"50x50px"},{"ck":"right","ak":"right"},{"ck":"middle","ak":"middle"},{"ck":"caption","ak":"caption"}],"size":"50x50"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"6","width":"50"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>caption</figcaption></figure>
16309 !! end
16310
16311 !! test
16312 Parsoid-specific image handling - framed image with specific size and caption (size is ignored)
16313 !! options
16314 parsoid=wt2html,wt2wt,html2html
16315 !! wikitext
16316 [[File:Foobar.jpg|frame|500x50px|caption]]
16317 !! html/parsoid
16318 <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>
16319 !! end
16320
16321 !! test
16322 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption (size is ignored)
16323 !! options
16324 parsoid=wt2html,html2html
16325 !! wikitext
16326 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
16327 !! html/parsoid
16328 <figure class="mw-halign-left" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure>
16329 !! end
16330
16331 !! test
16332 Parsoid-specific image handling - frameless image with specific size, border, and caption
16333 !! wikitext
16334 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
16335 !! html/parsoid
16336 <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>
16337 !! end
16338
16339 !! test
16340 Parsoid-specific image handling - simple image with a formatted caption
16341 !! wikitext
16342 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
16343 !! html/parsoid
16344 <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>
16345 !! end
16346
16347 !! test
16348 Parsoid-specific image handling - caption with a template in it
16349 !! wikitext
16350 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
16351 !! html/parsoid
16352 <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>
16353 !! end
16354
16355 !! test
16356 Parsoid-specific image handling - caption with unbalanced tags in it
16357 !! options
16358 parsoid=wt2html,wt2wt,html2html
16359 !! wikitext
16360 foo
16361 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
16362 bar
16363 !! html/parsoid
16364 <p>foo</p>
16365 <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>
16366 <p>bar</p>
16367 !! end
16368
16369 !! test
16370 Parsoid-specific image handling - empty caption (1)
16371 !! options
16372 parsoid=wt2html,wt2wt
16373 !! wikitext
16374 [[File:Foobar.jpg|thumb|]]
16375 !! html/parsoid
16376 <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>
16377 !! end
16378
16379 # empty captions don't get serialized unless we're in the "round trip" case
16380 !! test
16381 Parsoid-specific image handling - empty caption (2)
16382 !! options
16383 parsoid=html2wt
16384 !! html/parsoid
16385 <figure class="mw-default-size" typeof="mw:Image/Thumb">
16386 <a href="./File:Foobar.jpg">
16387 <img resource="./File:Foobar.jpg"
16388 src="//example.com/images/3/3a/Foobar.jpg"
16389 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
16390 height="25" width="220"/>
16391 </a>
16392 <figcaption></figcaption>
16393 </figure>
16394 !! wikitext
16395 [[File:Foobar.jpg|thumb]]
16396 !! end
16397
16398 !! test
16399 Parsoid-specific image handling - whitespace caption
16400 !! wikitext
16401 [[File:Foobar.jpg|thumb| ]]
16402 !! html/parsoid
16403 <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>
16404 !! end
16405
16406 !! test
16407 Parsoid-specific image handling - lang option
16408 !! wikitext
16409 foo
16410 [[File:Foobar.svg|lang=de|caption]]
16411 bar
16412 !! html/parsoid
16413 <p>foo
16414 <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>
16415 bar</p>
16416 !! end
16417
16418 ## Edge case bugs in Parsoid from T93580
16419 !! test
16420 T93580: 1. Templated <ref> inside block images
16421 !! wikitext
16422 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
16423
16424 <references />
16425 !! html/parsoid
16426 <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="./Parser_test#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></sup></figcaption></figure>
16427
16428 <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="./Parser_test#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>
16429 !! end
16430
16431 !! test
16432 T93580: 2. <ref> inside inline images
16433 !! wikitext
16434 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
16435
16436 <references />
16437 !! html/parsoid
16438 <p><figure-inline class="mw-default-size" typeof="mw:Image" data-parsoid='{"optList":[{"ck":"caption","ak":"Undisplayed caption in inline image with ref: &lt;ref>foo&lt;/ref>"}]}' data-mw='{"caption":"Undisplayed caption in inline image with ref: &lt;sup about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,78,5,6]}&#39; data-mw=&#39;{\"name\":\"ref\",\"attrs\":{},\"body\":{\"id\":\"mw-reference-text-cite_note-1\"}}&#39;>&lt;a href=\"./Parser_test#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>
16439
16440 <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="./Parser_test#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>
16441 !! end
16442
16443 !! test
16444 T93580: 3. Templated <ref> inside inline images
16445 !! wikitext
16446 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
16447
16448 <references />
16449 !! html/parsoid
16450 <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=\"./Parser_test#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>
16451
16452 <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="./Parser_test#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>
16453 !! end
16454
16455 ###
16456 ### Subpages
16457 ###
16458 !! article
16459 Subpage test/subpage
16460 !! text
16461 foo
16462 !! endarticle
16463
16464 !! test
16465 Subpage link
16466 !! options
16467 subpage title=[[Subpage test]]
16468 !! wikitext
16469 [[/subpage]]
16470 !! html
16471 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
16472 </p>
16473 !! end
16474
16475 !! test
16476 Subpage noslash link
16477 !! options
16478 subpage title=[[Subpage test]]
16479 !! wikitext
16480 [[/subpage/]]
16481 !! html
16482 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
16483 </p>
16484 !! end
16485
16486 !! article
16487 Subpage test/1/2/subpage
16488 !! text
16489 blah
16490 !! endarticle
16491
16492 !! test
16493 Relative subpage noslash link
16494 !! options
16495 parsoid=wt2wt,wt2html,html2html
16496 subpage title=[[Subpage test/1/2/3/4]]
16497 !! wikitext
16498 [[../../subpage/]]
16499
16500 [[../../subpage]]
16501 !! html/php
16502 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
16503 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
16504 </p>
16505 !! html/parsoid
16506 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
16507 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
16508 !! end
16509
16510 !! test
16511 Parsoid: dot-slash prefixed wikilinks
16512 !! wikitext
16513 [[./foo]]
16514
16515 [[././bar]]
16516
16517 [[././baz/]]
16518 !! html/php
16519 <p>[[./foo]]
16520 </p><p>[[././bar]]
16521 </p><p>[[././baz/]]
16522 </p>
16523 !! html/parsoid
16524 <p>[[./foo]]
16525 </p><p>[[././bar]]
16526 </p><p>[[././baz/]]
16527 </p>
16528 !! end
16529
16530 !! test
16531 Render invalid page names as plain text (T53090)
16532 !! wikitext
16533 [[./../foo|bar]]
16534 [[foo�|bar]]
16535 [[foo/.|bar]]
16536 [[foo/..|bar]]
16537 [[foo~~~bar]]
16538 [[foo>bar]]
16539 [[foo[bar]]
16540 [[.]]
16541 [[..]]
16542 [[foo././bar]]
16543 [[foo[http://example.com]xyz]]
16544
16545 [[{{echo|./../foo}}|bar]]
16546 [[{{echo|foo/.}}|bar]]
16547 [[{{echo|foo/..}}|bar]]
16548 [[{{echo|foo~~~~bar}}]]
16549 [[{{echo|foo>bar}}]]
16550 [[{{echo|foo././bar}}]]
16551 [[{{echo|foo{bar}}]]
16552 [[{{echo|foo}bar}}]]
16553 [[{{echo|foo[bar}}]]
16554 [[{{echo|foo]bar}}]]
16555 [[{{echo|foo<bar}}]]
16556 !!html/php
16557 <p>[[./../foo|bar]]
16558 [[foo�|bar]]
16559 [[foo/.|bar]]
16560 [[foo/..|bar]]
16561 [[foo~~~bar]]
16562 [[foo&gt;bar]]
16563 [[foo[bar]]
16564 [[.]]
16565 [[..]]
16566 [[foo././bar]]
16567 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
16568 </p><p>[[./../foo|bar]]
16569 [[foo/.|bar]]
16570 [[foo/..|bar]]
16571 [[foo~~~~bar]]
16572 [[foo&gt;bar]]
16573 [[foo././bar]]
16574 [[foo{bar]]
16575 [[foo}bar]]
16576 [[foo[bar]]
16577 [[foo]bar]]
16578 [[foo&lt;bar]]
16579 </p>
16580 !!html/parsoid
16581 <p>[[./../foo|bar]]
16582 [[foo�|bar]]
16583 [[foo/.|bar]]
16584 [[foo/..|bar]]
16585 [[foo~~~bar]]
16586 [[foo>bar]]
16587 [[foo[bar]]
16588 [[.]]
16589 [[..]]
16590 [[foo././bar]]
16591 [[foo<a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>xyz]]</p>
16592
16593 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
16594 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
16595 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
16596 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
16597 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
16598 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
16599 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
16600 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
16601 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
16602 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
16603 [[<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>
16604 !!end
16605
16606 !! test
16607 Disabled subpages
16608 !! wikitext
16609 [[/subpage]]
16610 !! html
16611 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
16612 </p>
16613 !! end
16614
16615 !! test
16616 T2561: {{/Subpage}}
16617 !! options
16618 subpage title=[[Page]]
16619 !! wikitext
16620 {{/Subpage}}
16621 !! html
16622 <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>
16623 </p>
16624 !! end
16625
16626 ###
16627 ### Categories
16628 ###
16629 !! article
16630 Category:MediaWiki User's Guide
16631 !! text
16632 blah
16633 !! endarticle
16634
16635 !! test
16636 Link to category
16637 !! wikitext
16638 [[:Category:MediaWiki User's Guide]]
16639 !! html
16640 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
16641 </p>
16642 !! end
16643
16644 !! test
16645 Simple category
16646 !! options
16647 cat
16648 !! wikitext
16649 [[Category:MediaWiki User's Guide]]
16650 !! html/php
16651 cat=MediaWiki_User's_Guide sort=
16652 !! html/parsoid
16653 <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"}}'/>
16654 !! end
16655
16656 !! test
16657 PAGESINCATEGORY invalid title fatal (r33546 fix)
16658 !! wikitext
16659 {{PAGESINCATEGORY:<bogus>}}
16660 !! html
16661 <p>0
16662 </p>
16663 !! end
16664
16665 !! test
16666 Category with different sort key
16667 !! options
16668 cat
16669 !! wikitext
16670 [[Category:MediaWiki User's Guide|Foo]]
16671 !! html/php
16672 cat=MediaWiki_User's_Guide sort=Foo
16673 !! html/parsoid
16674 <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"}}'/>
16675 !! end
16676
16677 !! test
16678 Category with identical sort key
16679 !! options
16680 cat
16681 !! wikitext
16682 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16683 !! html/php
16684 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
16685 !! html/parsoid
16686 <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"}}'/>
16687 !! end
16688
16689 !! test
16690 Category with empty sort key
16691 !! options
16692 cat
16693 pst
16694 !! wikitext
16695 [[Category:MediaWiki User's Guide|]]
16696 !! html/php
16697 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16698 !! end
16699
16700 !! test
16701 Category with empty sort key and parentheses
16702 !! options
16703 cat
16704 pst
16705 !! wikitext
16706 [[Category:Foo (bar)|]]
16707 !! html/php
16708 [[Category:Foo (bar)|Foo]]
16709 !! end
16710
16711 !! test
16712 Category with link tail
16713 !! options
16714 cat
16715 pst
16716 !! wikitext
16717 123[[Category:Foo]]456
16718 !! html/php
16719 123[[Category:Foo]]456
16720 !! end
16721
16722 !! test
16723 Category with template
16724 !! options
16725 cat
16726 pst
16727 !! wikitext
16728 [[Category:{{echo|Foo}}]]
16729 !! html/php
16730 [[Category:{{echo|Foo}}]]
16731 !! end
16732
16733 !! test
16734 Category with template in sort key
16735 !! options
16736 cat
16737 pst
16738 !! wikitext
16739 [[Category:Foo|{{echo|Bar}}]]
16740 !! html/php
16741 [[Category:Foo|{{echo|Bar}}]]
16742 !! end
16743
16744 !! test
16745 Category with template in sort key and title
16746 !! options
16747 cat
16748 pst
16749 !! wikitext
16750 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16751 !! html/php
16752 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16753 !! end
16754
16755 ## We used to, but no longer wt2wt this test since the default serializer
16756 ## will normalize all categories to serialize on their own line.
16757 ## This wikitext usage is going to be fairly uncommon in production and
16758 ## selser will take care of preserving formatting in those scenarios.
16759 !! test
16760 Category / paragraph interactions
16761 !! options
16762 parsoid=wt2html
16763 !! wikitext
16764 Foo [[Category:Baz]] Bar
16765
16766 Foo [[Category:Baz]]
16767 Bar
16768
16769 Foo
16770 [[Category:Baz]]
16771 Bar
16772
16773 Foo
16774 [[Category:Baz]] Bar
16775
16776 Foo
16777 [[Category:Baz]]
16778 [[Category:Baz]]
16779 [[Category:Baz]]
16780 Bar
16781
16782 [[Category:Baz]]
16783 [[Category:Baz]]
16784 [[Category:Baz]]
16785
16786 [[Category:Baz]]
16787 {{echo|[[Category:Baz]]}}
16788 [[Category:Baz]]
16789 !! html/php
16790 <p>Foo Bar
16791 </p><p>Foo
16792 Bar
16793 </p><p>Foo
16794 Bar
16795 </p><p>Foo Bar
16796 </p><p>Foo
16797 Bar
16798 </p>
16799 !! html/parsoid
16800 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16801 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16802 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16803 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16804 <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>
16805 <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}}]}'/>
16806 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16807 !! end
16808
16809 ## We used to, but no longer wt2wt this test since the default serializer
16810 ## will normalize all categories to serialize on their own line.
16811 ## This wikitext usage is going to be fairly uncommon in production and
16812 ## selser will take care of preserving formatting in those scenarios.
16813 ##
16814 ## The whitespace on the empty line is part of the test. Please do not delete
16815 !! test
16816 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16817 !! options
16818 parsoid=wt2html
16819 !! wikitext
16820 This
16821
16822 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16823
16824 {{echo|[[Category:Foo]] and so should this!}}
16825 !! html/php
16826 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16827 </p>
16828 !! html/parsoid
16829 <p>This
16830
16831 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16832
16833 <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>
16834 !! end
16835
16836 ## Parsoid will not try to wt2wt this while preserving newlines because
16837 ## it suppresses excess newlines within list items -- and we don't want to
16838 ## introduce a special case just for categories, which is, in reality somewhat
16839 ## odd behavior -- categories are unlikely to be used in list items like this
16840 ## in top-level pages and are only likely to show up in template-generated
16841 ## list items where this RT-ing is a non-issue.
16842 ##
16843 ## The whitespace on the empty line is part of the test. Please do not delete
16844 !! test
16845 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16846 !! options
16847 parsoid=wt2html
16848 !! wikitext
16849 * This
16850
16851 [[Category:Foo]] and this should be part of the same list item
16852 * So should this
16853
16854 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16855 !! html/php+tidy
16856 <ul><li>This and this should be part of the same list item</li>
16857 <li>So should this and this should be part of the same list item</li></ul>
16858 !! html/parsoid
16859 <ul>
16860 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16861 <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>
16862 </ul>
16863 !! end
16864
16865 ## Newlines and categories that follow the last item of a list
16866 ## are treated differently because this (list followed by categories)
16867 ## is an extremely common pattern on wikis.
16868 !! test
16869 3. Categories and newlines: newline suppression for last list item should RT properly
16870 !! wikitext
16871 *a
16872 *b
16873
16874 [[Category:Foo]]
16875
16876 [[Category:Bar]]
16877 [[Category:Baz]]
16878
16879 :c
16880
16881 [[Category:C]]
16882
16883 ;d
16884
16885 [[Category:D]]
16886 !! html/parsoid
16887 <ul><li>a</li>
16888 <li>b</li></ul>
16889
16890 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16891
16892 <link rel="mw:PageProp/Category" href="./Category:Bar"/>
16893 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16894
16895 <dl><dd>c</dd></dl>
16896
16897 <link rel="mw:PageProp/Category" href="./Category:C"/>
16898
16899 <dl><dt>d</dt></dl>
16900
16901 <link rel="mw:PageProp/Category" href="./Category:D"/>
16902 !! end
16903
16904 !! test
16905 4. Categories and newlines: newline suppression for last list item should RT properly
16906 !! wikitext
16907 *a
16908 ****b
16909
16910 [[Category:Foo]]
16911 !! html/parsoid
16912 <ul><li>a
16913 <ul><li><ul><li><ul><li>b</li></ul></li></ul></li></ul></li></ul>
16914
16915 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16916 !! end
16917
16918 ## only wt2html for this to make sure the algo only applies to the rightmost path
16919 !! test
16920 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16921 !! options
16922 parsoid=wt2html
16923 !! wikitext
16924 *a
16925 **b
16926 [[Category:Foo]]
16927 *c
16928 **d
16929 [[Category:Foo]]
16930 !! html/parsoid
16931 <ul><li>a
16932 <ul><li>b
16933 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16934 <li>c
16935 <ul><li>d</li></ul></li></ul>
16936 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16937 !! end
16938
16939 ## We used to, but no longer wt2wt this test since the default serializer
16940 ## will normalize all categories to serialize on their own line.
16941 ## This wikitext usage is going to be fairly uncommon in production and
16942 ## selser will take care of preserving formatting in those scenarios.
16943 !! test
16944 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16945 !! options
16946 parsoid=wt2html
16947 !! wikitext
16948 *a [[Category:Foo]]
16949 !! html/parsoid
16950 <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>
16951 !! end
16952
16953 # This test also demonstrates because of newline+category tunneling
16954 # through the list hander, template wrapping doesn't expand to the
16955 # containing list when the list item swallows the category.
16956 !! test
16957 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16958 !! wikitext
16959 *{{echo|a
16960 [[Category:Foo]]}}
16961 !! html/parsoid
16962 <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
16963 </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>
16964 !! end
16965
16966 !! test
16967 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
16968 !! wikitext
16969 *a
16970
16971 {{echo|[[Category:Foo]]
16972 [[Category:Bar]]}}
16973 [[Category:Baz]]
16974 !! html/parsoid
16975 <ul><li>a</li></ul>
16976
16977 <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">
16978 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16979 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16980 !! end
16981
16982 !! test
16983 Categories and newlines: migrateTrailingCategories dom pass should not get tripped by comments and whitespace
16984 !! wikitext
16985 *a
16986
16987 [[Category:Bar]]<!--boo1--> <!--boo2-->
16988 [[Category:Baz]]<!--boo3--> <!--boo4-->
16989 !! html/parsoid
16990 <ul><li>a</li></ul>
16991
16992 <link rel="mw:PageProp/Category" href="./Category:Bar"/><!--boo1--> <!--boo2-->
16993 <link rel="mw:PageProp/Category" href="./Category:Baz"/><!--boo3--> <!--boo4-->
16994 !! end
16995
16996 !! test
16997 Categories and newlines: should behave properly with linkprefix (T87753)
16998 !! options
16999 language=ar
17000 !! wikitext
17001 foo bar
17002 foo bar
17003 [[تصنيف:Foo]]
17004 [[تصنيف:Bar]]
17005 !! html/php
17006 <p>foo bar
17007 foo bar
17008 </p>
17009 !! html/parsoid
17010 <p>foo bar
17011 foo bar</p>
17012 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
17013 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
17014 !! end
17015
17016 !! test
17017 No regressions on internal links following category (T174639)
17018 !! options
17019 parsoid=wt2html,html2html
17020 !! wikitext
17021 [[Category:Foo]]<div>a
17022
17023 [[Foo]]</div>
17024 !! html/php
17025 <div>a
17026 <a href="/wiki/Foo" title="Foo">Foo</a></div>
17027
17028 !! html/parsoid
17029 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
17030
17031 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
17032 !! end
17033
17034 # Note that Parsoid differs slightly from PHP due to T175421
17035 !! test
17036 11. Special case where only newlines separate links (T175416)
17037 !! options
17038 parsoid=wt2html,html2html
17039 !! wikitext
17040 [[Category:Foo]]
17041
17042 [[Foo]][[es:Alimento]]
17043
17044 [[Foo]]
17045 !! html/php
17046 <p><br />
17047 <a href="/wiki/Foo" title="Foo">Foo</a>
17048 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
17049 </p>
17050 !! html/parsoid
17051 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
17052
17053 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
17054
17055 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
17056 !! end
17057
17058 !! test
17059 Category links with multiple namespaces
17060 !! wikitext
17061 [[Category:Project:Foo]]
17062 !! html/parsoid
17063 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
17064 !! end
17065
17066 !! test
17067 Parsoid: Serialize link to category page with colon escape
17068 !! wikitext
17069
17070 [[:Category:Foo]]
17071 [[:Category:Foo|Bar]]
17072 !! html/php+tidy
17073 <p><a href="/index.php?title=Category:Foo&amp;action=edit&amp;redlink=1" class="new" title="Category:Foo (page does not exist)">Category:Foo</a>
17074 <a href="/index.php?title=Category:Foo&amp;action=edit&amp;redlink=1" class="new" title="Category:Foo (page does not exist)">Bar</a>
17075 </p>
17076 !! html/parsoid
17077 <p>
17078 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
17079 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
17080 </p>
17081 !! end
17082
17083 # We used to, but no longer wt2wt this test since the default serializer
17084 # will normalize all categories to serialize on their own line.
17085 # This wikitext usage is going to be fairly uncommon in production and
17086 # selser will take care of preventing whitespace insertion if this
17087 # occurs in an article.
17088 #
17089 # html2html disabled for the same reason (whitespace insertion between
17090 # x and y).
17091 #
17092 # html2wt disabled because it localizes the "Category" namespace.
17093 !! test
17094 Link prefix/suffixes aren't applied to category links
17095 !! options
17096 parsoid=wt2html
17097 language=is
17098 !! wikitext
17099 x[[Category:Foo]]y
17100 !! html/php
17101 <p>xy
17102 </p>
17103 !! html/parsoid
17104 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
17105 !! end
17106
17107 !! test
17108 Link prefix/suffixes aren't applied to language links
17109 !! options
17110 parsoid=wt2html
17111 language=is
17112 !! wikitext
17113 x[[es:Foo]]y
17114 !! html/php
17115 <p>xy
17116 </p>
17117 !! html/parsoid
17118 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
17119 !! end
17120
17121 !! test
17122 Parsoid: Serialize link to file page with colon escape
17123 !! wikitext
17124
17125 [[:File:Foo.png]]
17126 [[:File:Foo.png|Bar]]
17127 !! html/php+tidy
17128 <p><a href="/index.php?title=File:Foo.png&amp;action=edit&amp;redlink=1" class="new" title="File:Foo.png (page does not exist)">File:Foo.png</a>
17129 <a href="/index.php?title=File:Foo.png&amp;action=edit&amp;redlink=1" class="new" title="File:Foo.png (page does not exist)">Bar</a>
17130 </p>
17131 !! html/parsoid
17132 <p>
17133 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
17134 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
17135 </p>
17136 !! end
17137
17138 !! test
17139 Parsoid: Serialize a genuine category link without colon escape
17140 !! wikitext
17141 [[Category:Foo]]
17142 [[Category:Foo|Bar]]
17143 !! html/php+tidy
17144 !! html/parsoid
17145 <link rel="mw:PageProp/Category" href="./Category:Foo">
17146 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
17147 !! end
17148
17149 !! test
17150 Normalize hrefs properly before testing for invalid link targets (T72894)
17151 !! options
17152 parsoid=html2wt
17153 !! html/parsoid
17154 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
17155 !! wikitext
17156 [[Category:Toxine bactérienne]]
17157 !! end
17158
17159 !! test
17160 Parsoid: Defaultsort
17161 !! wikitext
17162 {{DEFAULTSORT:Foo}}
17163 !! html/parsoid
17164 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
17165 !! end
17166
17167 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
17168 # But, this is a limitation of our representation and is documented in
17169 # TemplateHandler.js in processSpecialMagicWord
17170 !! test
17171 Parsoid: Defaultsort (template-generated)
17172 !! wikitext
17173 {{{{echo|DEFAULTSORT}}:Foo}}
17174 !! html/parsoid
17175 <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"}]]}'/>
17176 !! end
17177
17178 ###
17179 ### Inter-language links
17180 ###
17181 !! test
17182 Interlanguage links
17183 !! options
17184 ill
17185 !! wikitext
17186 [[es:Alimento]]
17187 [[fr:Nourriture]]
17188 [[zh:食品]]
17189 !! html/php
17190 es:Alimento fr:Nourriture zh:食品
17191 !! html/parsoid
17192 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
17193 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
17194 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
17195 !! end
17196
17197 !! test
17198 Duplicate interlanguage links (T26502)
17199 !! options
17200 ill
17201 !! wikitext
17202 [[es:1]]
17203 [[es:2]]
17204 [[fr:1]]
17205 [[fr:2]]
17206 !! html/php
17207 es:1 fr:1
17208 !! html/parsoid
17209 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
17210 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
17211 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
17212 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
17213 !! end
17214
17215 ###
17216 ### Sections
17217 ###
17218 !! test
17219 Basic section headings
17220 !! wikitext
17221 ==Headline 1==
17222 Some text
17223
17224 ==Headline 2==
17225 More
17226 ===Smaller headline===
17227 Blah blah
17228 !! html
17229 <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>
17230 <p>Some text
17231 </p>
17232 <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>
17233 <p>More
17234 </p>
17235 <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>
17236 <p>Blah blah
17237 </p>
17238 !! end
17239
17240 !! test
17241 Section headings with TOC
17242 !! wikitext
17243 ==Headline 1==
17244 ===Subheadline 1===
17245 =====Skipping a level=====
17246 ======Skipping a level======
17247
17248 ==Headline 2==
17249 Some text
17250 ===Another headline===
17251 !! html
17252 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17253 <ul>
17254 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
17255 <ul>
17256 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
17257 <ul>
17258 <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>
17259 <ul>
17260 <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>
17261 </ul>
17262 </li>
17263 </ul>
17264 </li>
17265 </ul>
17266 </li>
17267 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
17268 <ul>
17269 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
17270 </ul>
17271 </li>
17272 </ul>
17273 </div>
17274
17275 <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>
17276 <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>
17277 <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>
17278 <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>
17279 <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>
17280 <p>Some text
17281 </p>
17282 <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>
17283
17284 !! end
17285
17286 !! test
17287 TOC anchors don't collide
17288 !! wikitext
17289 __FORCETOC__
17290 ==Headline 2==
17291 ==Headline==
17292 ==Headline 2==
17293 ==Headline==
17294 !! html/php
17295 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17296 <ul>
17297 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
17298 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
17299 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
17300 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
17301 </ul>
17302 </div>
17303
17304 <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>
17305 <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>
17306 <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>
17307 <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>
17308
17309 !! end
17310
17311 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
17312 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
17313 !! test
17314 Handling of sections up to level 6 and beyond
17315 !! options
17316 parsoid=wt2html
17317 !! wikitext
17318 =Level 1 Heading=
17319 ==Level 2 Heading==
17320 ===Level 3 Heading===
17321 ====Level 4 Heading====
17322 =====Level 5 Heading=====
17323 ======Level 6 Heading======
17324 =======Level 7 Heading=======
17325 ========Level 8 Heading========
17326 =========Level 9 Heading=========
17327 ==========Level 10 Heading==========
17328 !! html/php
17329 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17330 <ul>
17331 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
17332 <ul>
17333 <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>
17334 <ul>
17335 <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>
17336 <ul>
17337 <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>
17338 <ul>
17339 <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>
17340 <ul>
17341 <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>
17342 <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>
17343 <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>
17344 <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>
17345 <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>
17346 </ul>
17347 </li>
17348 </ul>
17349 </li>
17350 </ul>
17351 </li>
17352 </ul>
17353 </li>
17354 </ul>
17355 </li>
17356 </ul>
17357 </div>
17358
17359 <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>
17360 <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>
17361 <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>
17362 <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>
17363 <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>
17364 <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>
17365 <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>
17366 <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>
17367 <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>
17368 <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>
17369
17370 !! html/parsoid
17371 <h1 id="Level_1_Heading" data-parsoid='{}'>Level 1 Heading</h1>
17372 <h2 id="Level_2_Heading" data-parsoid='{}'>Level 2 Heading</h2>
17373 <h3 id="Level_3_Heading" data-parsoid='{}'>Level 3 Heading</h3>
17374 <h4 id="Level_4_Heading" data-parsoid='{}'>Level 4 Heading</h4>
17375 <h5 id="Level_5_Heading" data-parsoid='{}'>Level 5 Heading</h5>
17376 <h6 id="Level_6_Heading" data-parsoid='{}'>Level 6 Heading</h6>
17377 <h6 id="=Level_7_Heading=" data-parsoid='{}'><span id=".3DLevel_7_Heading.3D" typeof="mw:FallbackId"></span>=Level 7 Heading=</h6>
17378 <h6 id="==Level_8_Heading==" data-parsoid='{}'><span id=".3D.3DLevel_8_Heading.3D.3D" typeof="mw:FallbackId"></span>==Level 8 Heading==</h6>
17379 <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>
17380 <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>
17381 !! end
17382
17383 !! test
17384 TOC regression (T11764)
17385 !! wikitext
17386 ==title 1==
17387 ===title 1.1===
17388 ====title 1.1.1====
17389 ===title 1.2===
17390 ==title 2==
17391 ===title 2.1===
17392 !! html
17393 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17394 <ul>
17395 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17396 <ul>
17397 <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>
17398 <ul>
17399 <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>
17400 </ul>
17401 </li>
17402 <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>
17403 </ul>
17404 </li>
17405 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17406 <ul>
17407 <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>
17408 </ul>
17409 </li>
17410 </ul>
17411 </div>
17412
17413 <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>
17414 <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>
17415 <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>
17416 <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>
17417 <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>
17418 <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>
17419
17420 !! end
17421
17422 !! test
17423 TOC for heading containing <span id="..."></span> (T96153)
17424 !! wikitext
17425 __FORCETOC__
17426 ==<span id="old-anchor"></span>New title==
17427 !! html/php
17428 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17429 <ul>
17430 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
17431 </ul>
17432 </div>
17433
17434 <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>
17435
17436 !! end
17437
17438 !! test
17439 TOC with wgMaxTocLevel=3 (T8204)
17440 !! options
17441 wgMaxTocLevel=3
17442 !! wikitext
17443 ==title 1==
17444 ===title 1.1===
17445 ====title 1.1.1====
17446 ===title 1.2===
17447 ==title 2==
17448 ===title 2.1===
17449 !! html
17450 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17451 <ul>
17452 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17453 <ul>
17454 <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>
17455 <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>
17456 </ul>
17457 </li>
17458 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
17459 <ul>
17460 <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>
17461 </ul>
17462 </li>
17463 </ul>
17464 </div>
17465
17466 <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>
17467 <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>
17468 <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>
17469 <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>
17470 <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>
17471 <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>
17472
17473 !! end
17474
17475 !! test
17476 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
17477 !! options
17478 wgMaxTocLevel=3
17479 !! wikitext
17480 ==Section 1==
17481 ===Section 1.1===
17482 ====Section 1.1.1====
17483 ====Section 1.1.1.1====
17484 ==Section 2==
17485 !! html
17486 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17487 <ul>
17488 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
17489 <ul>
17490 <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>
17491 </ul>
17492 </li>
17493 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
17494 </ul>
17495 </div>
17496
17497 <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>
17498 <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>
17499 <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>
17500 <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>
17501 <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>
17502
17503 !! end
17504
17505
17506 !! test
17507 Resolving duplicate section names
17508 !! wikitext
17509 ==Foo bar==
17510 ==Foo bar==
17511 !! html
17512 <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>
17513 <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>
17514
17515 !! end
17516
17517 !! test
17518 Resolving duplicate section names with differing case (T12721)
17519 !! wikitext
17520 ==Foo bar==
17521 ==Foo Bar==
17522 !! html
17523 <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>
17524 <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>
17525
17526 !! end
17527
17528 !! article
17529 Template:sections
17530 !! text
17531 ===Section 1===
17532 ==Section 2==
17533 !! endarticle
17534
17535 !! test
17536 Template with sections, __NOTOC__
17537 !! wikitext
17538 __NOTOC__
17539 ==Section 0==
17540 {{sections}}
17541 ==Section 4==
17542 !! html
17543 <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>
17544 <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>
17545 <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>
17546 <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>
17547
17548 !! end
17549
17550 !! test
17551 __NOEDITSECTION__ keyword
17552 !! wikitext
17553 __NOEDITSECTION__
17554 ==Section 1==
17555 ==Section 2==
17556 !! html
17557 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
17558 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
17559
17560 !! end
17561
17562 !! test
17563 Link inside a section heading
17564 !! wikitext
17565 ==Section with a [[Main Page|link]] in it==
17566 !! html
17567 <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>
17568
17569 !! end
17570
17571 !! test
17572 TOC regression (T14077)
17573 !! wikitext
17574 __TOC__
17575 ==title 1==
17576 ===title 1.1===
17577 ==title 2==
17578 !! html
17579 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17580 <ul>
17581 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
17582 <ul>
17583 <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>
17584 </ul>
17585 </li>
17586 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
17587 </ul>
17588 </div>
17589
17590 <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>
17591 <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>
17592 <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>
17593
17594 !! end
17595
17596 !! test
17597 T3219 URL next to image (good)
17598 !! wikitext
17599 http://example.com [[File:Foobar.jpg]]
17600 !! html/php
17601 <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>
17602 </p>
17603 !! html/parsoid
17604 <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>
17605 !!end
17606
17607 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
17608 !! test
17609 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
17610 !! options
17611 parsoid=wt2html,html2html
17612 !! wikitext
17613 ===
17614 The line above must have a trailing space!
17615 === <!--
17616 --> <!-- -->
17617 But just in case it doesn't...
17618 !! html/php
17619 <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>
17620 <p>The line above must have a trailing space!
17621 </p>
17622 <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>
17623 <p>But just in case it doesn't...
17624 </p>
17625 !! html/parsoid
17626 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
17627 <p>The line above must have a trailing space!</p>
17628 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
17629 --> <!-- -->
17630 <p>But just in case it doesn't...</p>
17631 !! end
17632
17633 !! test
17634 Header with special characters (T27462)
17635 !! wikitext
17636 The tooltips shall not show entities to the user (ie. be double escaped)
17637
17638 ==text > text==
17639 section 1
17640
17641 ==text < text==
17642 section 2
17643
17644 ==text & text==
17645 section 3
17646
17647 ==text ' text==
17648 section 4
17649
17650 ==text " text==
17651 section 5
17652 !! html/php
17653 <p>The tooltips shall not show entities to the user (ie. be double escaped)
17654 </p>
17655 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17656 <ul>
17657 <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>
17658 <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>
17659 <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>
17660 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
17661 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
17662 </ul>
17663 </div>
17664
17665 <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>
17666 <p>section 1
17667 </p>
17668 <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>
17669 <p>section 2
17670 </p>
17671 <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>
17672 <p>section 3
17673 </p>
17674 <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>
17675 <p>section 4
17676 </p>
17677 <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>
17678 <p>section 5
17679 </p>
17680 !! html/parsoid
17681 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
17682
17683 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span>text > text</h2>
17684 <p>section 1</p>
17685
17686 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span>text &lt; text</h2>
17687 <p>section 2</p>
17688
17689 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span>text &amp; text</h2>
17690 <p>section 3</p>
17691
17692 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span>text ' text</h2>
17693 <p>section 4</p>
17694
17695 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span>text " text</h2>
17696 <p>section 5</p>
17697 !! end
17698
17699 !! test
17700 Header with space, plus and underscore as entity
17701 !! wikitext
17702 Id should not contain + for spaces
17703
17704 ==Space between Text==
17705 section 1
17706
17707 ==Space-Entity&#32;between&#32;Text==
17708 section 2
17709
17710 ==Plus+between+Text==
17711 section 3
17712
17713 ==Plus-Entity&#43;between&#43;Text==
17714 section 4
17715
17716 ==Underscore_between_Text==
17717 section 5
17718
17719 ==Underscore-Entity&#95;between&#95;Text==
17720 section 6
17721
17722 [[#Space between Text]]
17723 [[#Space-Entity&#32;between&#32;Text]]
17724 [[#Plus+between+Text]]
17725 [[#Plus-Entity&#43;between&#43;Text]]
17726 [[#Underscore_between_Text]]
17727 [[#Underscore-Entity&#95;between&#95;Text]]
17728 !! html/php
17729 <p>Id should not contain + for spaces
17730 </p>
17731 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17732 <ul>
17733 <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>
17734 <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>
17735 <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>
17736 <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>
17737 <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>
17738 <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>
17739 </ul>
17740 </div>
17741
17742 <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>
17743 <p>section 1
17744 </p>
17745 <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>
17746 <p>section 2
17747 </p>
17748 <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>
17749 <p>section 3
17750 </p>
17751 <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>
17752 <p>section 4
17753 </p>
17754 <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>
17755 <p>section 5
17756 </p>
17757 <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>
17758 <p>section 6
17759 </p><p><a href="#Space_between_Text">#Space between Text</a>
17760 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
17761 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
17762 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
17763 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
17764 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
17765 </p>
17766 !! html/parsoid
17767 <p>Id should not contain + for spaces</p>
17768
17769 <h2 id="Space_between_Text">Space between Text</h2>
17770 <p>section 1</p>
17771
17772 <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>
17773 <p>section 2</p>
17774
17775 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus+between+Text</h2>
17776 <p>section 3</p>
17777
17778 <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>
17779 <p>section 4</p>
17780
17781 <h2 id="Underscore_between_Text">Underscore_between_Text</h2>
17782 <p>section 5</p>
17783
17784 <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>
17785 <p>section 6</p>
17786
17787 <p><a rel="mw:WikiLink" href="./Parser_test#Space_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Space_between_Text"},"sa":{"href":"#Space between Text"}}'>#Space between Text</a>
17788 <a rel="mw:WikiLink" href="./Parser_test#Space-Entity_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Space-Entity_between_Text"},"sa":{"href":"#Space-Entity&amp;#32;between&amp;#32;Text"}}'>#Space-Entity between Text</a>
17789 <a rel="mw:WikiLink" href="./Parser_test#Plus+between+Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Plus+between+Text"},"sa":{"href":"#Plus+between+Text"}}'>#Plus+between+Text</a>
17790 <a rel="mw:WikiLink" href="./Parser_test#Plus-Entity+between+Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Plus-Entity+between+Text"},"sa":{"href":"#Plus-Entity&amp;#43;between&amp;#43;Text"}}'>#Plus-Entity+between+Text</a>
17791 <a rel="mw:WikiLink" href="./Parser_test#Underscore_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Underscore_between_Text"},"sa":{"href":"#Underscore_between_Text"}}'>#Underscore_between_Text</a>
17792 <a rel="mw:WikiLink" href="./Parser_test#Underscore-Entity_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Underscore-Entity_between_Text"},"sa":{"href":"#Underscore-Entity&amp;#95;between&amp;#95;Text"}}'>#Underscore-Entity_between_Text</a></p>
17793 !! end
17794
17795 # Parsoid html2wt disabled because it adds padding spaces around =
17796 !! test
17797 Headers with excess '=' characters
17798 (Are similar tests necessary beyond the 1st level?)
17799 !! options
17800 parsoid=wt2html,wt2wt,html2html
17801 !! wikitext
17802 =foo==
17803 ==foo=
17804 =''italic'' heading==
17805 ==''italic'' heading=
17806 !! html/php
17807 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17808 <ul>
17809 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
17810 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
17811 <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>
17812 <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>
17813 </ul>
17814 </div>
17815
17816 <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>
17817 <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>
17818 <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>
17819 <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>
17820
17821 !! html/parsoid
17822 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
17823 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
17824 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
17825 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
17826 !! end
17827
17828 !! test
17829 HTML headers vs TOC (T25393)
17830 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17831 !! wikitext
17832 <h1>Header 1</h1>
17833 ==Header 1.1==
17834 ==Header 1.2==
17835
17836 <h1>Header 2
17837 </h1>
17838 ==Header 2.1==
17839 ==Header 2.2==
17840 __NOEDITSECTION__
17841 !! html/php
17842 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
17843 <ul>
17844 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17845 <ul>
17846 <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>
17847 <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>
17848 </ul>
17849 </li>
17850 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17851 <ul>
17852 <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>
17853 <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>
17854 </ul>
17855 </li>
17856 </ul>
17857 </div>
17858
17859 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17860 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17861 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17862 <h1><span class="mw-headline" id="Header_2">Header 2
17863 </span></h1>
17864 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17865 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17866
17867 !! html/parsoid
17868 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
17869 <h2 id="Header_1.1" data-parsoid='{}'>Header 1.1</h2>
17870 <h2 id="Header_1.2" data-parsoid='{}'>Header 1.2</h2>
17871
17872 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
17873 </h1>
17874 <h2 id="Header_2.1" data-parsoid='{}'>Header 2.1</h2>
17875 <h2 id="Header_2.2" data-parsoid='{}'>Header 2.2</h2>
17876 <meta property="mw:PageProp/noeditsection"/>
17877 !! end
17878
17879 !! test
17880 Single-line or multiline-comments can follow headings
17881 !! options
17882 parsoid=wt2html,wt2wt
17883 !! wikitext
17884 ==foo==<!---->
17885 ==bar==<!--c1-->
17886 ==baz==<!--
17887 c2
17888 c3-->
17889 !! html/php
17890 <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>
17891 <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>
17892 <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>
17893
17894 !! html/parsoid
17895 <h2 id="foo">foo</h2><!---->
17896 <h2 id="bar">bar</h2><!--c1-->
17897 <h2 id="baz">baz</h2><!--
17898 c2
17899 c3-->
17900 !! end
17901
17902 !! test
17903 T3219 URL next to image (broken)
17904 !! wikitext
17905 http://example.com[[File:Foobar.jpg]]
17906 !! html/php
17907 <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>
17908 </p>
17909 !! html/parsoid
17910 <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>
17911 !!end
17912
17913 !! test
17914 T3186 news: in the middle of text
17915 !! wikitext
17916 http://en.wikinews.org/wiki/Wikinews:Workplace
17917 !! html
17918 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
17919 </p>
17920 !!end
17921
17922
17923 !! test
17924 Namespaced link must have a title
17925 !! wikitext
17926 [[Project:]]
17927 !! html
17928 <p>[[Project:]]
17929 </p>
17930 !!end
17931
17932 !! test
17933 Namespaced link must have a title (bad fragment version)
17934 !! wikitext
17935 [[Project:#fragment]]
17936 !! html
17937 <p>[[Project:#fragment]]
17938 </p>
17939 !!end
17940
17941
17942 ###
17943 ### HTML tags and HTML attributes
17944 ###
17945
17946 !! test
17947 div with no attributes
17948 !! wikitext
17949 <div>HTML rocks</div>
17950 !! html
17951 <div>HTML rocks</div>
17952
17953 !! end
17954
17955 !! test
17956 div with double-quoted attribute
17957 !! wikitext
17958 <div id="rock">HTML rocks</div>
17959 !! html
17960 <div id="rock">HTML rocks</div>
17961
17962 !! end
17963
17964 !! test
17965 div with single-quoted attribute
17966 !! wikitext
17967 <div id='rock'>HTML rocks</div>
17968 !! html
17969 <div id="rock">HTML rocks</div>
17970
17971 !! end
17972
17973 !! test
17974 div with unquoted attribute
17975 !! wikitext
17976 <div id=rock>HTML rocks</div>
17977 !! html
17978 <div id="rock">HTML rocks</div>
17979
17980 !! end
17981
17982 !! test
17983 div with illegal double attributes
17984 !! wikitext
17985 <div id="a" id="b">HTML rocks</div>
17986 !! html
17987 <div id="b">HTML rocks</div>
17988
17989 !!end
17990
17991 !! test
17992 div with empty attribute value, space before equals
17993 !! options
17994 parsoid=wt2html,html2html
17995 !! wikitext
17996 <div class =>HTML rocks</div>
17997 !! html/php
17998 <div class="">HTML rocks</div>
17999
18000 !! html/parsoid
18001 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
18002 !! end
18003
18004 !! test
18005 div with multiple empty attribute values
18006 !! config
18007 wgFragmentMode=[ 'html5', 'legacy' ]
18008 !! options
18009 parsoid=wt2html,html2html
18010 !! wikitext
18011 <div id= title=>HTML rocks</div>
18012 !! html/php
18013 <div id="title=">HTML rocks</div>
18014
18015 !! html/parsoid
18016 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
18017 !! end
18018
18019 # FIXME Parsoid doesn't actually match PHP here.
18020 # Probably we should use the synthetic <foo /> or <indicator>
18021 # extensions for this test, which are enabled when running parser tests.
18022 !! test
18023 Extension tag in attribute value
18024 !! wikitext
18025 <span title="<translate>123</translate>">ok</span>
18026 !! html/php+disabled
18027 <p>&lt;span title="&lt;translate&gt;123&lt;/translate&gt;"&gt;ok&lt;/span&gt;
18028 </p>
18029 !! html/parsoid
18030 <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>
18031 !! end
18032
18033 !! test
18034 table with multiple empty attribute values
18035 !! options
18036 parsoid=wt2html,html2html
18037 !! wikitext
18038 {| title= id=
18039 |hi
18040 |}
18041 !! html/php
18042 <table title="id=">
18043 <tr>
18044 <td>hi
18045 </td></tr></table>
18046
18047 !! html/parsoid
18048 <table title="id=">
18049 <tbody><tr><td>hi</td></tr>
18050 </tbody></table>
18051 !! end
18052
18053 !! test
18054 div with braces in attribute value
18055 !! wikitext
18056 <div title="{}">Foo</div>
18057 !! html/php
18058 <div title="&#123;&#125;">Foo</div>
18059
18060 !! html/parsoid
18061 <div title="{}">Foo</div>
18062 !! end
18063
18064 !! test
18065 div with empty attribute value, no space before equals
18066 !! options
18067 parsoid=wt2html,html2html
18068 !! wikitext
18069 <div class=>HTML rocks</div>
18070 !! html/php
18071 <div class="">HTML rocks</div>
18072
18073 !! html/parsoid
18074 <div class="">HTML rocks</div>
18075 !! end
18076
18077 !! test
18078 HTML multiple attributes correction
18079 !! wikitext
18080 <p class="error" class="awesome">Awesome!</p>
18081 !! html
18082 <p class="awesome">Awesome!</p>
18083
18084 !!end
18085
18086 !! test
18087 Table multiple attributes correction
18088 !! wikitext
18089 {|
18090 !+ class="error" class="awesome"|status
18091 |}
18092 !! html
18093 <table>
18094 <tr>
18095 <th class="awesome">status
18096 </th></tr></table>
18097
18098 !!end
18099
18100 !! test
18101 DIV IN UPPERCASE
18102 !! wikitext
18103 <DIV ID="x">HTML ROCKS</DIV>
18104 !! html
18105 <div id="x">HTML ROCKS</div>
18106
18107 !!end
18108
18109 !! test
18110 Non-ASCII pseudo-tags are rendered as text
18111 !! wikitext
18112 <khyô>
18113 !! html
18114 <p>&lt;khyô&gt;
18115 </p>
18116 !! end
18117
18118 !! test
18119 Pseudo-tag with URL 'name' renders as url link
18120 !! wikitext
18121 <http://example.com/>
18122 !! html
18123 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
18124 </p>
18125 !! end
18126
18127 !! test
18128 text with amp in the middle of nowhere
18129 !! wikitext
18130 Remember AT&T?
18131 !! html
18132 <p>Remember AT&amp;T?
18133 </p>
18134 !! end
18135
18136 !! test
18137 text with character entity: eacute
18138 !! wikitext
18139 I always thought &eacute; was a cute letter.
18140 !! html+tidy
18141 <p>I always thought &#233; was a cute letter.
18142 </p>
18143 !! end
18144
18145 !! test
18146 text with entity-escaped character entity-like string: eacute
18147 !! wikitext
18148 I always thought &amp;eacute; was a cute letter.
18149 !! html
18150 <p>I always thought &amp;eacute; was a cute letter.
18151 </p>
18152 !! end
18153
18154 !! test
18155 text with undefined character entity: xacute
18156 !! wikitext
18157 I always thought &xacute; was a cute letter.
18158 !! html
18159 <p>I always thought &amp;xacute; was a cute letter.
18160 </p>
18161 !! end
18162
18163 !! test
18164 HTML5 tags
18165 !! wikitext
18166 <data value="5">five</data>
18167 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18168 <mark>This highlighted text</mark>
18169 !! html
18170 <p><data value="5">five</data>
18171 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
18172 <mark>This highlighted text</mark>
18173 </p>
18174 !! end
18175
18176 !! test
18177 HTML tag with leading space is parsed as text
18178 !! wikitext
18179 < div>foo< /div>
18180 !! html
18181 <p>&lt; div&gt;foo&lt; /div&gt;
18182 </p>
18183 !! end
18184
18185 ## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
18186 ## the HTML5 parsing spec.
18187 !! test
18188 Element with broken attribute syntax
18189 !! options
18190 parsoid=wt2html
18191 !! wikitext
18192 <div style=" style="123">hi</div>
18193 <div =>ho</div>
18194 !! html/php
18195 <div style="123">hi</div>
18196 <div>ho</div>
18197
18198 !! html/parsoid
18199 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
18200 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
18201 !! end
18202
18203 ###
18204 ### Nesting tests (see T43545, T52604, T53081)
18205 ###
18206
18207 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
18208 # Note that html2wt is considerably more difficult if we use <b> in
18209 # the test case, instead of <small>
18210 !! test
18211 Ensure that HTML adoption agency algorithm is properly implemented.
18212 !! wikitext
18213 <small>X<small>Y</small>Z</small>
18214 !! html
18215 <p><small>X<small>Y</small>Z</small>
18216 </p>
18217 !! end
18218
18219 # This was T43545 in the PHP parser.
18220 !! test
18221 Nesting of <kbd>
18222 !! wikitext
18223 <kbd>X<kbd>Y</kbd>Z</kbd>
18224 !! html+tidy
18225 <p><kbd>X<kbd>Y</kbd>Z</kbd>
18226 </p>
18227 !! end
18228
18229 # The following cases were T53081 in the PHP parser.
18230 # Note that there are some other nestable tags (b, i, etc) which are
18231 # not covered; see T53081 for discussion.
18232
18233 !! test
18234 Nesting of <em>
18235 !! wikitext
18236 <em>X<em>Y</em>Z</em>
18237 !! html+tidy
18238 <p><em>X<em>Y</em>Z</em>
18239 </p>
18240 !! end
18241
18242 !! test
18243 Nesting of <strong>
18244 !! wikitext
18245 <strong>X<strong>Y</strong>Z</strong>
18246 !! html+tidy
18247 <p><strong>X<strong>Y</strong>Z</strong>
18248 </p>
18249 !! end
18250
18251 !! test
18252 Nesting of <q>
18253 !! wikitext
18254 <q>X<q>Y</q>Z</q>
18255 !! html+tidy
18256 <p><q>X<q>Y</q>Z</q>
18257 </p>
18258 !! end
18259
18260 !! test
18261 Nesting of <ruby>
18262 !! wikitext
18263 <ruby>X<ruby>Y</ruby>Z</ruby>
18264 !! html
18265 <p><ruby>X<ruby>Y</ruby>Z</ruby>
18266 </p>
18267 !! end
18268
18269 !! test
18270 Nesting of <bdo>
18271 !! wikitext
18272 <bdo>X<bdo>Y</bdo>Z</bdo>
18273 !! html
18274 <p><bdo>X<bdo>Y</bdo>Z</bdo>
18275 </p>
18276 !! end
18277
18278
18279 ###
18280 ### Media links
18281 ###
18282
18283 !! test
18284 Media link
18285 !! wikitext
18286 [[Media:Foobar.jpg]]
18287 [[Media:Video.ogv]]
18288 [[:Media:Video.ogv]]
18289 !! html/php
18290 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
18291 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18292 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
18293 </p>
18294 !! html/parsoid
18295 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
18296 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" resource="./Media:Video.ogv" title="Video.ogv">Media:Video.ogv</a>
18297 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" resource="./Media:Video.ogv" title="Video.ogv" data-parsoid='{"a":{"resource":"./Media:Video.ogv"},"sa":{"resource":":Media:Video.ogv"}}'>Media:Video.ogv</a></p>
18298 !! end
18299
18300 !! test
18301 Media link with text
18302 !! wikitext
18303 [[Media:Foobar.jpg|A neat file to look at]]
18304 !! html/php
18305 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
18306 </p>
18307 !! html/parsoid
18308 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18309 !! end
18310
18311 !! test
18312 Localized media link
18313 !! options
18314 language=is
18315 !! wikitext
18316 [[Miðill:Foobar.jpg]]
18317
18318 [[Miðill:Foobar.jpg|Icelandic]]
18319 !! html/php
18320 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Miðill:Foobar.jpg</a>
18321 </p><p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Icelandic</a>
18322 </p>
18323 !! html/parsoid
18324 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Miðill:Foobar.jpg" title="Foobar.jpg">Miðill:Foobar.jpg</a></p>
18325 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Miðill:Foobar.jpg" title="Foobar.jpg">Icelandic</a></p>
18326 !! end
18327
18328 # FIXME: this is still bad HTML tag nesting
18329 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
18330 # Parsoid & Remex fix the p-wrapping since they operate on the DOM.
18331 !! test
18332 Media link with nasty text
18333 !! options
18334 parsoid=wt2html,html2html
18335 !! wikitext
18336 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
18337 !! html/php
18338 <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>
18339
18340 !! html/php+tidy
18341 <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>
18342 !! html/parsoid
18343 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg">Safe Link</a></p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" resource="./Media:Foobar.jpg" title="Foobar.jpg"><div style="display:none" data-parsoid='{"stx":"html"}'>" onmouseover="alert(document.cookie)" onfoo="</div></a>
18344 !! end
18345
18346 !! test
18347 Media link from missing resource (parsoid-only)
18348 !! options
18349 parsoid=html2wt
18350 !! html/parsoid
18351 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18352 !! wikitext
18353 [[Media:Foobar.jpg|Bat!]]
18354 !! end
18355
18356 !! test
18357 Media link from missing resource, localized (parsoid-only)
18358 !! options
18359 parsoid=html2wt
18360 language=is
18361 !! html/parsoid
18362 <a rel="mw:MediaLink" href="http://example.com/images/3/3a/Foobar.jpg">Bat!</a>
18363 !! wikitext
18364 [[Miðill:Foobar.jpg|Bat!]]
18365 !! end
18366
18367 # This is a sanity test to ensure we don't crash or choke when given
18368 # old cached 1.7.0 HTML for media links; we don't require that the
18369 # result be "valid" because wt2wt was completely broken in 1.7.0
18370 !! test
18371 Media link from old 1.7.0 DOM spec (crash test, parsoid-only) T198511
18372 !! options
18373 parsoid=html2wt
18374 !! html/parsoid
18375 <p>This is what Parsoid would emit (and we still handle this HTML fine):</p>
18376 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18377 <p>But VisualEditor would mangle the rel attribute, and give us back this:</p>
18378 <p><a rel="mw:ExtLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
18379 <p>But at least we don't crash when trying to handle the mangled HTML!</p>
18380 !! wikitext
18381 This is what Parsoid would emit (and we still handle this HTML fine):
18382
18383 [[Media:Foobar.jpg|A neat file to look at]]
18384
18385 But VisualEditor would mangle the rel attribute, and give us back this:
18386
18387 [//example.com/images/3/3a/Foobar.jpg A neat file to look at]
18388
18389 But at least we don't crash when trying to handle the mangled HTML!
18390 !! end
18391
18392 !! test
18393 Media link to nonexistent file (T3702)
18394 !! wikitext
18395 [[Media:No such.jpg]]
18396 [[Media:No_such file.jpg]]
18397 !! html/php
18398 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
18399 <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>
18400 </p>
18401 !! html/parsoid
18402 <p><a rel="mw:MediaLink" href="./Special:FilePath/No_such.jpg" resource="./Media:No_such.jpg" title="No such.jpg" typeof="mw:Error" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' data-parsoid='{"a":{"resource":"./Media:No_such.jpg"},"sa":{"resource":"Media:No such.jpg"}}'>Media:No such.jpg</a>
18403 <a rel="mw:MediaLink" href="./Special:FilePath/No_such_file.jpg" resource="./Media:No_such_file.jpg" title="No such file.jpg" typeof="mw:Error" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' data-parsoid='{"a":{"resource":"./Media:No_such_file.jpg"},"sa":{"resource":"Media:No_such file.jpg"}}'>Media:No_such file.jpg</a></p>
18404 !! end
18405
18406 !! test
18407 Image link to nonexistent file (T3850 - good)
18408 !! wikitext
18409 [[File:No_such.jpg]]
18410 !! html/php
18411 <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>
18412 </p>
18413 !! html/parsoid
18414 <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>
18415 !! end
18416
18417 !! test
18418 :Image link to nonexistent file (T3850 - bad)
18419 !! wikitext
18420 [[:Image:No such.jpg]]
18421 !! html/php
18422 <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>
18423 </p>
18424 !! html/parsoid
18425 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
18426 !! end
18427
18428 !! test
18429 Character reference normalization in link text (T3938)
18430 !! wikitext
18431 [[Main Page|this&that]]
18432 !! html
18433 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
18434 </p>
18435 !!end
18436
18437 !! article
18438 אַ
18439 !! text
18440 Test for unicode normalization
18441
18442 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
18443 !! endarticle
18444
18445 !! test
18446 (T21451) Links should refer to the normalized form.
18447 !! wikitext
18448 [[&#xFB2E;]]
18449 [[&#x5d0;&#x5b7;]]
18450 [[&#x5d0;ַ]]
18451 [[א&#x5b7;]]
18452 [[אַ]]
18453 !! html
18454 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
18455 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
18456 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
18457 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
18458 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
18459 </p>
18460 !! end
18461
18462 !! test
18463 Empty attribute crash test (T4067)
18464 !! wikitext
18465 <font color="">foo</font>
18466 !! html
18467 <p><font color="">foo</font>
18468 </p>
18469 !! end
18470
18471 !! test
18472 Empty attribute crash test single-quotes (T4067)
18473 !! wikitext
18474 <font color=''>foo</font>
18475 !! html
18476 <p><font color="">foo</font>
18477 </p>
18478 !! end
18479
18480 !! test
18481 Attribute test: equals, then nothing
18482 !! options
18483 parsoid=wt2html,html2html
18484 !! wikitext
18485 <font color=>foo</font>
18486 !! html/php
18487 <p><font color="">foo</font>
18488 </p>
18489 !! html/parsoid
18490 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
18491 !! end
18492
18493 !! test
18494 Attribute test: unquoted value
18495 !! options
18496 parsoid=wt2html,html2html
18497 !! wikitext
18498 <font color=x>foo</font>
18499 !! html/php
18500 <p><font color="x">foo</font>
18501 </p>
18502 !! html/parsoid
18503 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
18504 !! end
18505
18506 !! test
18507 Attribute test: unquoted but illegal value (hash)
18508 !! wikitext
18509 <font color=#x>foo</font>
18510 !! html
18511 <p><font color="#x">foo</font>
18512 </p>
18513 !! end
18514
18515 # Parsoid does not serialize to empty attribute syntax,
18516 # so wt2wt and html2wt cases are skipped
18517 !! test
18518 Attribute test: no value (T54330)
18519 !! options
18520 parsoid=wt2html,html2html
18521 !! wikitext
18522 <font color>foo</font>
18523 !! html/php
18524 <p><font color="">foo</font>
18525 </p>
18526 !! html/parsoid
18527 <p><font color="">foo</font></p>
18528 !! end
18529
18530 !! test
18531 T4095: link with three closing brackets
18532 !! wikitext
18533 [[Main Page]]]
18534 !! html/php
18535 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
18536 </p>
18537 !! html/parsoid
18538 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
18539 !! end
18540
18541 !! test
18542 T4095: link with pipe and three closing brackets
18543 !! wikitext
18544 [[Main Page|link]]]
18545 !! html/php
18546 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
18547 </p>
18548 !! html/parsoid
18549 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
18550 !! end
18551
18552 !! test
18553 T4095: link with pipe and three closing brackets, version 2
18554 !! wikitext
18555 [[Main Page|[http://example.com/]]]
18556 !! html/php
18557 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
18558 </p>
18559 !! html/parsoid
18560 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
18561 !! end
18562
18563
18564 ###
18565 ### Safety
18566 ###
18567
18568 !! article
18569 Template:Dangerous attribute
18570 !! text
18571 " onmouseover="alert(document.cookie)
18572 !! endarticle
18573
18574 !! article
18575 Template:Dangerous style attribute
18576 !! text
18577 border-size: expression(alert(document.cookie))
18578 !! endarticle
18579
18580 !! article
18581 Template:Div style
18582 !! text
18583 <div style="float: right; {{{1}}}">Magic div</div>
18584 !! endarticle
18585
18586 !! test
18587 T4304: HTML attribute safety (safe template; regression T4309)
18588 !! wikitext
18589 <div title="{{test}}"></div>
18590 !! html/php
18591 <div title="This is a test template"></div>
18592
18593 !! html/parsoid
18594 <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>
18595 !! end
18596
18597 # Parsoid has enough context to handle this case
18598 !! test
18599 T4304: HTML attribute safety (dangerous template; 2309)
18600 !! wikitext
18601 <div title="{{dangerous attribute}}"></div>
18602 !! html/php
18603 <div title=""></div>
18604
18605 !! html/parsoid
18606 <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>
18607 !! end
18608
18609 !! test
18610 T4304: HTML attribute safety (dangerous style template; 2309)
18611 !! wikitext
18612 <div style="{{dangerous style attribute}}"></div>
18613 !! html/php
18614 <div style="/* insecure input */"></div>
18615
18616 !! html/parsoid
18617 <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>
18618 !! end
18619
18620 !! test
18621 T4304: HTML attribute safety (safe parameter; 2309)
18622 !! wikitext
18623 {{div style|width: 200px}}
18624 !! html/php
18625 <div style="float: right; width: 200px">Magic div</div>
18626
18627 !! html/parsoid
18628 <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>
18629 !! end
18630
18631 !! test
18632 T4304: HTML attribute safety (unsafe parameter; 2309)
18633 !! wikitext
18634 {{div style|width: expression(alert(document.cookie))}}
18635 !! html/php
18636 <div style="/* insecure input */">Magic div</div>
18637
18638 !! html/parsoid
18639 <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>
18640 !! end
18641
18642 ## Parsoid output here differs; needs investigation.
18643 !! test
18644 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
18645 !! wikitext
18646 {{div style|"><script>alert(document.cookie)</script>}}
18647 !! html
18648 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18649
18650 !! end
18651
18652 ## Parsoid output here differs; needs investigation.
18653 !! test
18654 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
18655 !! wikitext
18656 {{div style|" ><script>alert(document.cookie)</script>}}
18657 !! html
18658 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
18659
18660 !! end
18661
18662 !! test
18663 T4304: HTML attribute safety (link)
18664 !! wikitext
18665 <div title="[[Main Page]]"></div>
18666 !! html/php
18667 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
18668
18669 !! html/parsoid
18670 <div title="[[Main Page]]"></div>
18671 !! end
18672
18673 !! test
18674 T4304: HTML attribute safety (italics)
18675 !! wikitext
18676 <div title="''foobar''"></div>
18677 !! html
18678 <div title="&#39;&#39;foobar&#39;&#39;"></div>
18679
18680 !! end
18681
18682 !! test
18683 T4304: HTML attribute safety (bold)
18684 !! wikitext
18685 <div title="'''foobar'''"></div>
18686 !! html
18687 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
18688
18689 !! end
18690
18691 !! test
18692 T4304: HTML attribute safety (ISBN)
18693 !! wikitext
18694 <div title="ISBN 1234567890"></div>
18695 !! html
18696 <div title="&#73;SBN 1234567890"></div>
18697
18698 !! end
18699
18700 !! test
18701 T4304: HTML attribute safety (RFC)
18702 !! wikitext
18703 <div title="RFC 1234"></div>
18704 !! html
18705 <div title="&#82;FC 1234"></div>
18706
18707 !! end
18708
18709 !! test
18710 T4304: HTML attribute safety (PMID)
18711 !! wikitext
18712 <div title="PMID 1234567890"></div>
18713 !! html
18714 <div title="&#80;MID 1234567890"></div>
18715
18716 !! end
18717
18718 !! test
18719 T4304: HTML attribute safety (web link)
18720 !! wikitext
18721 <div title="http://example.com/"></div>
18722 !! html
18723 <div title="http&#58;//example.com/"></div>
18724
18725 !! end
18726
18727 !! test
18728 T4304: HTML attribute safety (named web link)
18729 !! wikitext
18730 <div title="[http://example.com/ link]"></div>
18731 !! html/php
18732 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
18733
18734 !! html/parsoid
18735 <div title="[http://example.com/ link]"></div>
18736 !! end
18737
18738 !! test
18739 T5244: HTML attribute safety (extension; safe)
18740 !! wikitext
18741 <div style="<nowiki>background:blue</nowiki>"></div>
18742 !! html/php
18743 <div style="background:blue"></div>
18744
18745 !! html/parsoid
18746 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
18747 !! end
18748
18749 !! test
18750 T5244: HTML attribute safety (extension; unsafe)
18751 !! wikitext
18752 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
18753 !! html/php
18754 <div style="/* insecure input */"></div>
18755
18756 !! html/parsoid
18757 <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>
18758 !! end
18759
18760 # More MSIE fun discovered by Tom Gilder
18761
18762 !! test
18763 MSIE CSS safety test: spurious slash
18764 !! wikitext
18765 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
18766 !! html/php
18767 <div style="/* insecure input */">evil</div>
18768
18769 !! html/parsoid
18770 <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>
18771 !! end
18772
18773 !! test
18774 MSIE CSS safety test: hex code
18775 !! wikitext
18776 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
18777 !! html/php
18778 <div style="/* insecure input */">evil</div>
18779
18780 !! html/parsoid
18781 <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>
18782 !! end
18783
18784 !! test
18785 MSIE CSS safety test: comment in url
18786 !! wikitext
18787 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
18788 !! html/php
18789 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
18790
18791 !! html/parsoid
18792 <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>
18793 !! end
18794
18795 !! test
18796 MSIE CSS safety test: comment in expression
18797 !! wikitext
18798 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
18799 !! html/php
18800 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
18801
18802 !! html/parsoid
18803 <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>
18804 !! end
18805
18806 !! test
18807 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
18808 !! wikitext
18809 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
18810 !! html/php
18811 <p style="/* invalid control char */">A</p>
18812
18813 !! html/parsoid
18814 <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>
18815 !! end
18816
18817 !! test
18818 MSIE 6 CSS safety test: Fullwidth (T57332)
18819 !! wikitext
18820 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
18821 <div style="top:EXPRESSION(alert())">B</div>
18822 !! html/php
18823 <p style="/* insecure input */">A</p>
18824 <div style="/* insecure input */">B</div>
18825
18826 !! html/parsoid
18827 <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>
18828 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
18829 !! end
18830
18831 !! test
18832 MSIE 6 CSS safety test: IPA extensions (T57332)
18833 !! wikitext
18834 <div style="background-image:uʀʟ(javascript:alert())">A</div>
18835 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
18836 !! html/php
18837 <div style="/* insecure input */">A</div>
18838 <p style="/* insecure input */">B</p>
18839
18840 !! html/parsoid
18841 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
18842 <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>
18843 !! end
18844
18845 !! test
18846 MSIE 6 CSS safety test: sup/sub script (T57332)
18847 !! wikitext
18848 <div style="background-image:url⁽javascript:alert())">A</div>
18849 <div style="background-image:url₍javascript:alert())">B</div>
18850 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
18851 !! html/php
18852 <div style="/* insecure input */">A</div>
18853 <div style="/* insecure input */">B</div>
18854 <p style="/* insecure input */">C</p>
18855
18856 !! html/parsoid
18857 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
18858 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
18859 <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>
18860 !! end
18861
18862 !! test
18863 Opera -o-link CSS
18864 !! options
18865 parsoid=wt2html,html2html
18866 !! wikitext
18867 <div
18868 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;"
18869 style="-o-link:attr(title);-o-link-source:current">X</div>
18870 !! html/php
18871 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
18872
18873 !! html/parsoid
18874 <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>
18875 !! end
18876
18877 !! test
18878 MSIE 6 CSS safety test: Repetition markers (T57332)
18879 !! wikitext
18880 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
18881 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
18882 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
18883 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
18884 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
18885 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
18886 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
18887 !! html/php
18888 <p style="/* insecure input */">A</p>
18889 <p style="/* insecure input */">B</p>
18890 <p style="/* insecure input */">C</p>
18891 <p style="/* insecure input */">D</p>
18892 <p style="/* insecure input */">E</p>
18893 <p style="/* insecure input */">F</p>
18894 <p style="/* insecure input */">G</p>
18895
18896 !! html/parsoid
18897 <p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expres〱ion((title=&#39;XSSed&#39;),&#39;red&#39;)"}}'>A</p>
18898 <p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expresゝion((title=&#39;XSSed&#39;),&#39;red&#39;)"}}'>B</p>
18899 <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>
18900 <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>
18901 <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>
18902 <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>
18903 <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>
18904 !! end
18905
18906 !! test
18907 Table attribute legitimate extension
18908 !! wikitext
18909 {|
18910 !+ style="<nowiki>color:blue</nowiki>"|status
18911 |}
18912 !! html
18913 <table>
18914 <tr>
18915 <th style="color:blue">status
18916 </th></tr></table>
18917
18918 !!end
18919
18920 !! test
18921 Table attribute safety
18922 !! wikitext
18923 {|
18924 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"|status
18925 |}
18926 !! html
18927 <table>
18928 <tr>
18929 <th style="/* insecure input */">status
18930 </th></tr></table>
18931
18932 !! end
18933
18934 !! test
18935 CSS line continuation 1
18936 !! wikitext
18937 <div style="background-image: u\&#10;rl(test.jpg);"></div>
18938 !! html
18939 <div style="/* insecure input */"></div>
18940
18941 !! end
18942
18943 !! test
18944 CSS line continuation 2
18945 !! wikitext
18946 <div style="background-image: u\&#13;rl(test.jpg); "></div>
18947 !! html
18948 <div style="/* invalid control char */"></div>
18949
18950 !! end
18951
18952 !! article
18953 Template:Identity
18954 !! text
18955 {{{1}}}
18956 !! endarticle
18957
18958 !! test
18959 Expansion of multi-line templates in attribute values (T8255)
18960 !! wikitext
18961 <div style="background: {{identity|#00FF00}}">-</div>
18962 !! html
18963 <div style="background: #00FF00">-</div>
18964
18965 !! end
18966
18967 !! test
18968 Expansion of multi-line templates in attribute values (T8255 sanity check)
18969 !! wikitext
18970 <div style="background:
18971 #00FF00">-</div>
18972 !! html/php
18973 <div style="background: #00FF00">-</div>
18974
18975 !! html/parsoid
18976 <div style="background:
18977 #00FF00">-</div>
18978 !! end
18979
18980 !! test
18981 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
18982 !! wikitext
18983 <div style="background: &#10;#00FF00">-</div>
18984 !! html
18985 <div style="background: &#10;#00FF00">-</div>
18986
18987 !! end
18988
18989 !! test
18990 Tags which are hidden from tidiers cannot pass through the Sanitizer
18991 !! wikitext
18992 <mw:toc><script>alert();</script></mw:toc>
18993 !! html+tidy
18994 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;
18995 </p>
18996 !! end
18997
18998 ###
18999 ### Parser hooks (see tests/parser/ParserTestParserHook.php for the <tag> extension)
19000 ###
19001
19002 !! test
19003 Parser hook: empty input
19004 !! wikitext
19005 <tag></tag>
19006 !! html/php
19007 <pre>
19008 ''
19009 array (
19010 )
19011 </pre>
19012
19013 !! html/parsoid
19014 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19015 !! end
19016
19017 ## Don't expect parsoid to rt this form.
19018 !! test
19019 Parser hook: empty input using terminated empty elements
19020 !! options
19021 parsoid=wt2html,html2html
19022 !! wikitext
19023 <tag/>
19024 !! html/php
19025 <pre>
19026 NULL
19027 array (
19028 )
19029 </pre>
19030
19031 !! html/parsoid
19032 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
19033 !! end
19034
19035 !! test
19036 Parser hook: empty input using terminated empty elements (space before)
19037 !! wikitext
19038 <tag />
19039 !! html/php
19040 <pre>
19041 NULL
19042 array (
19043 )
19044 </pre>
19045
19046 !! html/parsoid
19047 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{}}' data-parsoid='{}' about="#mwt2"></pre>
19048 !! end
19049
19050 !! test
19051 Parser hook: basic input
19052 !! wikitext
19053 <tag>input</tag>
19054 !! html/php
19055 <pre>
19056 'input'
19057 array (
19058 )
19059 </pre>
19060
19061 !! html/parsoid
19062 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19063 !! end
19064
19065 ## Don't expect parsoid to rt this form.
19066 !! test
19067 Parser hook: case insensitive
19068 !! options
19069 parsoid=wt2html,html2html
19070 !! wikitext
19071 <TAG>input</TAG>
19072 !! html/php
19073 <pre>
19074 'input'
19075 array (
19076 )
19077 </pre>
19078
19079 !! html/parsoid
19080 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19081 !! end
19082
19083 ## Don't expect parsoid to rt this form.
19084 !! test
19085 Parser hook: case insensitive, redux
19086 !! options
19087 parsoid=wt2html,html2html
19088 !! wikitext
19089 <TaG>input</TAg>
19090 !! html/php
19091 <pre>
19092 'input'
19093 array (
19094 )
19095 </pre>
19096
19097 !! html/parsoid
19098 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
19099 !! end
19100
19101 !! test
19102 Parser hook: nested tags
19103 !! options
19104 parsoid=wt2html
19105 !! wikitext
19106 <tag><tag></tag></tag>
19107 !! html/php
19108 <pre>
19109 '<tag>'
19110 array (
19111 )
19112 </pre>&lt;/tag&gt;
19113
19114 !! html/php+tidy
19115 <pre>'<tag>'
19116 array (
19117 )
19118 </tag></pre><p>&lt;/tag&gt;
19119 </p>
19120 !! html/parsoid
19121 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}'></pre><p>&lt;/tag></p>
19122 !! end
19123
19124 !! test
19125 Parser hook: basic arguments
19126 !! wikitext
19127 <tag width="200" height="100" depth="50" square=""></tag>
19128 !! html/php
19129 <pre>
19130 ''
19131 array (
19132 'width' => '200',
19133 'height' => '100',
19134 'depth' => '50',
19135 'square' => '',
19136 )
19137 </pre>
19138
19139 !! html/parsoid
19140 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19141 !! end
19142
19143 ## Don't expect parsoid to rt this form.
19144 !! test
19145 Parser hook: basic arguments, variations
19146 !! options
19147 parsoid=wt2html,html2html
19148 !! wikitext
19149 <tag width=200 height = "100" depth = '50' square></tag>
19150 !! html/php
19151 <pre>
19152 ''
19153 array (
19154 'width' => '200',
19155 'height' => '100',
19156 'depth' => '50',
19157 'square' => '',
19158 )
19159 </pre>
19160
19161 !! html/parsoid
19162 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19163 !! end
19164
19165 !! test
19166 Parser hook: argument containing a forward slash (T7344)
19167 !! wikitext
19168 <tag filename="/tmp/bla"></tag>
19169 !! html/php
19170 <pre>
19171 ''
19172 array (
19173 'filename' => '/tmp/bla',
19174 )
19175 </pre>
19176
19177 !! html/parsoid
19178 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
19179 !! end
19180
19181 ## Don't expect parsoid to rt this form.
19182 !! test
19183 Parser hook: empty input using terminated empty elements (T4374)
19184 !! options
19185 parsoid=wt2html,html2html
19186 !! wikitext
19187 <tag foo=bar/>text
19188 !! html/php
19189 <pre>
19190 NULL
19191 array (
19192 'foo' => 'bar',
19193 )
19194 </pre>text
19195
19196 !! html/parsoid
19197 <pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{"foo":"bar"}}'></pre><p>text</p>
19198 !! end
19199
19200 ## </tag> should be output literally since there is no matching tag that begins it
19201 ## Don't expect parsoid to rt this form.
19202 !! test
19203 Parser hook: basic arguments using terminated empty elements (T4374)
19204 !! options
19205 parsoid=wt2html
19206 !! wikitext
19207 <tag width=200 height = "100" depth = '50' square/>
19208 other stuff
19209 </tag>
19210 !! html/php
19211 <pre>
19212 NULL
19213 array (
19214 'width' => '200',
19215 'height' => '100',
19216 'depth' => '50',
19217 'square' => '',
19218 )
19219 </pre>
19220 <p>other stuff
19221 &lt;/tag&gt;
19222 </p>
19223 !! html/parsoid
19224 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""}}' about="#mwt2"></pre><p>other stuff
19225 &lt;/tag></p>
19226 !! end
19227
19228 ## Don't expect parsoid to rt this form.
19229 !! test
19230 Parser hook: Don't allow unclosed extension tags
19231 !! options
19232 parsoid=wt2html
19233 !! wikitext
19234 test <tag>123
19235
19236 this is a '''test'''
19237 !! html/php
19238 <p>test &lt;tag&gt;123
19239 </p><p>this is a <b>test</b>
19240 </p>
19241 !! html/parsoid
19242 <p>test &lt;tag>123</p>
19243
19244 <p>this is a <b>test</b></p>
19245 !! end
19246
19247 !! test
19248 Parser hook: horizontal rule inside extension tag that outputs <pre>
19249 !! wikitext
19250 <tag>
19251 Hello
19252 <hr/>
19253 Goodbye
19254 </tag>
19255 !! html/php
19256 <pre>
19257 '
19258 Hello
19259 <hr/>
19260 Goodbye
19261 '
19262 array (
19263 )
19264 </pre>
19265
19266 !! end
19267
19268 ###
19269 ### (see tests/parser/ParserTestParserHook.php for the <statictag> extension)
19270 ###
19271
19272 !! test
19273 Parser hook: static parser hook not inside a comment
19274 !! wikitext
19275 <statictag>hello, world</statictag>
19276
19277 <statictag action="flush" />
19278 !! html/php
19279 <p><br />
19280 hello, world
19281 </p>
19282 !! html/parsoid
19283 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' about="#mwt2"></span></p>
19284 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"}}' about="#mwt4">hello, world</span></p>
19285 !! end
19286
19287 !! test
19288 Parser hook: static parser hook inside a comment
19289 !! wikitext
19290 <!-- <statictag>hello, world</statictag> -->
19291 <statictag action="flush" />
19292 !! html/php
19293 <p><br />
19294 </p>
19295 !! html/parsoid
19296 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
19297 <p><span typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"}}' data-parsoid='{}' about='#mwt2'></span></p>
19298 !! end
19299
19300 # Nested template calls; this case was broken by Parser.php rev 1.506,
19301 # since reverted.
19302
19303 !! article
19304 Template:One-parameter
19305 !! text
19306 (My parameter is: {{{1}}})
19307 !! endarticle
19308
19309 !! article
19310 Template:Map-one-parameter
19311 !! text
19312 {{{{{1}}}|{{{2}}}}}
19313 !! endarticle
19314
19315 !! test
19316 Nested template calls
19317 !! wikitext
19318 {{Map-one-parameter|One-parameter|param}}
19319 !! html
19320 <p>(My parameter is: param)
19321 </p>
19322 !! end
19323
19324
19325 ###
19326 ### Sanitizer
19327 ###
19328
19329 !! test
19330 Sanitizer: Closing of open tags
19331 !! wikitext
19332 <s></s><table></table>
19333 !! html/php+tidy
19334 <p><s></s></p><table></table>
19335 !! html/parsoid
19336 <p><s data-parsoid='{"stx":"html"}'></s></p><table data-parsoid='{"stx":"html"}'></table>
19337 !! end
19338
19339 !! test
19340 Sanitizer: Closing of open but not closed tags
19341 !! wikitext
19342 <s>foo
19343 !! html
19344 <p><s>foo</s>
19345 </p>
19346 !! end
19347
19348 !! test
19349 Sanitizer: Closing of closed but not open tags
19350 !! options
19351 parsoid=wt2html
19352 !! wikitext
19353 </s>
19354 !! html+tidy
19355 <p class="mw-empty-elt">
19356 </p>
19357 !! end
19358
19359 !! test
19360 Sanitizer: Closing of closed but not open table tags
19361 !! options
19362 parsoid=wt2html
19363 !! wikitext
19364 Table not started</td></tr></table>
19365 !! html+tidy
19366 <p>Table not started
19367 </p>
19368 !! end
19369
19370 !! test
19371 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
19372 !! options
19373 title=[[Main Page]]
19374 !! config
19375 wgFragmentMode=[ 'html5', 'legacy' ]
19376 !! wikitext
19377 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19378 !! html/php
19379 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
19380 </p>
19381 !! html/parsoid
19382 <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>
19383 !! end
19384
19385 !! test
19386 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
19387 !! config
19388 wgFragmentMode=[ 'legacy' ]
19389 !! wikitext
19390 <span id="æ: v">byte</span>[[#æ: v|backlink]]
19391 !! html/php
19392 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
19393 </p>
19394 !! end
19395
19396 # In HTML5, the restrictions are that id must contain at least one character,
19397 # and must not contain any space characters.
19398 !! test
19399 Sanitizer: Validating the contents of the id attribute (T6515)
19400 !! options
19401 disabled
19402 !! wikitext
19403 <br id="" /><br id="a space" />
19404 !! html
19405 Something ...
19406 !! end
19407
19408 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
19409 !! test
19410 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
19411 !! options
19412 disabled
19413 !! wikitext
19414 <br id="foo" /><br id="foo" />
19415 !! html
19416 Something need to be done. foo-2 ?
19417 !! end
19418
19419 !! test
19420 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
19421 !! wikitext
19422 <div itemscope>
19423 <meta itemprop="hello" content="world">
19424 <meta http-equiv="refresh" content="5">
19425 <meta itemprop="hello" http-equiv="refresh" content="5">
19426 <link itemprop="hello" href="{{SERVER}}">
19427 <link rel="stylesheet" href="{{SERVER}}">
19428 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
19429 </div>
19430 !! html
19431 <div itemscope="">
19432 <p> <meta itemprop="hello" content="world" />
19433 &lt;meta http-equiv="refresh" content="5"&gt;
19434 <meta itemprop="hello" content="5" />
19435 <link itemprop="hello" href="http&#58;//example.org" />
19436 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
19437 <link itemprop="hello" href="http&#58;//example.org" />
19438 </p>
19439 </div>
19440
19441 !! end
19442
19443 !! test
19444 Sanitizer: Strip comments from CSS attributes
19445 !! options
19446 parsoid=wt2html,wt2wt
19447 !! wikitext
19448 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
19449 !! html/php
19450 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
19451 </p>
19452 !! html/parsoid
19453 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
19454 !! end
19455
19456 !! test
19457 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
19458 !! wikitext
19459 [[meatball:Soft"Security]]
19460 !! html/php
19461 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
19462 </p>
19463 !! html/parsoid
19464 <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>
19465 !! end
19466
19467 !! test
19468 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
19469 !! wikitext
19470 [[meatball:Foo<Bar]]
19471 [[meatball:Foo>Bar]]
19472 [[meatball:Foo&lt;bar]]
19473 [[meatball:Foo&gt;bar]]
19474 !! html/php
19475 <p>[[meatball:Foo&lt;Bar]]
19476 [[meatball:Foo&gt;Bar]]
19477 [[meatball:Foo&lt;bar]]
19478 [[meatball:Foo&gt;bar]]
19479 </p>
19480 !! html/parsoid
19481 <p>[[meatball:Foo&lt;Bar]]
19482 [[meatball:Foo>Bar]]
19483 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
19484 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
19485 !! end
19486
19487 !! test
19488 Language converter: output gets cut off unexpectedly (T7757)
19489 !! options
19490 language=zh
19491 !! wikitext
19492 this bit is safe: }-
19493
19494 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
19495
19496 then we get cut off here: }-
19497
19498 all additional text is vanished
19499 !! html/php
19500 <p>this bit is safe: }-
19501 </p><p>but if we add a conversion instance: xxx
19502 </p><p>then we get cut off here: }-
19503 </p><p>all additional text is vanished
19504 </p>
19505 !! html/parsoid
19506 <p>this bit is safe: }-</p>
19507 <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>
19508 <p>then we get cut off here: }-</p>
19509 <p>all additional text is vanished</p>
19510 !! end
19511
19512 !! test
19513 Language converter glossary rules inside attributes (T119158)
19514 !! options
19515 language=sr variant=sr-el
19516 !! wikitext
19517 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
19518
19519 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
19520 !! html/php
19521 <p>
19522 </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>
19523 </p>
19524 !! html/parsoid
19525 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
19526
19527 <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>
19528 !! end
19529
19530 !! test
19531 Self closed html pairs (T7487)
19532 !! wikitext
19533 <center><font id="bug" />Centered text</center>
19534 <div><font id="bug2" />In div text</div>
19535 !! html+tidy
19536 <center><font id="bug"></font>Centered text</center>
19537 <div><font id="bug2"></font>In div text</div>
19538 !! end
19539
19540 !! test
19541 Punctuation: nbsp before exclamation
19542 !! wikitext
19543 C'est grave !
19544 !! html
19545 <p>C'est grave&#160;!
19546 </p>
19547 !! end
19548
19549 !! test
19550 Punctuation: CSS !important (T13874)
19551 !! wikitext
19552 <div style="width:50% !important">important</div>
19553 !! html
19554 <div style="width:50% !important">important</div>
19555
19556 !!end
19557
19558 !! test
19559 Punctuation: CSS ! important (T13874; with space after)
19560 !! wikitext
19561 <div style="width:50% ! important">important</div>
19562 !! html
19563 <div style="width:50%&#32;! important">important</div>
19564
19565 !!end
19566
19567 !! test
19568 HTML bullet list, closed tags (T7497)
19569 !! wikitext
19570 <ul>
19571 <li>One</li>
19572 <li>Two</li>
19573 </ul>
19574 !! html/php
19575 <ul>
19576 <li>One</li>
19577 <li>Two</li>
19578 </ul>
19579
19580 !! html/parsoid
19581 <ul data-parsoid='{"stx":"html"}'>
19582 <li data-parsoid='{"stx":"html"}'>One</li>
19583 <li data-parsoid='{"stx":"html"}'>Two</li>
19584 </ul>
19585
19586 !! end
19587
19588 !! test
19589 HTML bullet list, unclosed tags (T7497)
19590 !! wikitext
19591 <ul>
19592 <li>One
19593 <li>Two
19594 </ul>
19595 !! html/php+tidy
19596 <ul>
19597 <li>One
19598 </li><li>Two
19599 </li></ul>
19600 !! html/parsoid
19601 <ul data-parsoid='{"stx":"html"}'>
19602 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19603 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19604 </ul>
19605
19606 !! end
19607
19608 !! test
19609 HTML ordered list, closed tags (T7497)
19610 !! wikitext
19611 <ol>
19612 <li>One</li>
19613 <li>Two</li>
19614 </ol>
19615 !! html/php
19616 <ol>
19617 <li>One</li>
19618 <li>Two</li>
19619 </ol>
19620
19621 !! html/parsoid
19622 <ol data-parsoid='{"stx":"html"}'>
19623 <li data-parsoid='{"stx":"html"}'>One</li>
19624 <li data-parsoid='{"stx":"html"}'>Two</li>
19625 </ol>
19626
19627 !! end
19628
19629 !! test
19630 HTML ordered list, unclosed tags (T7497)
19631 !! options
19632 !! wikitext
19633 <ol>
19634 <li>One
19635 <li>Two
19636 </ol>
19637 !! html/php+tidy
19638 <ol>
19639 <li>One
19640 </li><li>Two
19641 </li></ol>
19642 !! html/parsoid
19643 <ol data-parsoid='{"stx":"html"}'>
19644 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
19645 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
19646 </ol>
19647
19648 !! end
19649
19650 !! test
19651 HTML nested bullet list, closed tags (T7497)
19652 !! wikitext
19653 <ul>
19654 <li>One</li>
19655 <li>Two:
19656 <ul>
19657 <li>Sub-one</li>
19658 <li>Sub-two</li>
19659 </ul>
19660 </li>
19661 </ul>
19662 !! html/php
19663 <ul>
19664 <li>One</li>
19665 <li>Two:
19666 <ul>
19667 <li>Sub-one</li>
19668 <li>Sub-two</li>
19669 </ul>
19670 </li>
19671 </ul>
19672
19673 !! html/parsoid
19674 <ul data-parsoid='{"stx":"html"}'>
19675 <li data-parsoid='{"stx":"html"}'>One</li>
19676 <li data-parsoid='{"stx":"html"}'>Two:
19677 <ul data-parsoid='{"stx":"html"}'>
19678 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
19679 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
19680 </ul>
19681 </li>
19682 </ul>
19683 !! end
19684
19685 !! test
19686 HTML nested bullet list, open tags (T7497)
19687 !! wikitext
19688 <ul>
19689 <li>One
19690 <li>Two:
19691 <ul>
19692 <li>Sub-one
19693 <li>Sub-two
19694 </ul>
19695 </ul>
19696 !! html+tidy
19697 <ul>
19698 <li>One
19699 </li><li>Two:
19700 <ul>
19701 <li>Sub-one
19702 </li><li>Sub-two
19703 </li></ul>
19704 </li></ul>
19705 !! end
19706
19707 !! test
19708 HTML nested ordered list, closed tags (T7497)
19709 !! wikitext
19710 <ol>
19711 <li>One</li>
19712 <li>Two:
19713 <ol>
19714 <li>Sub-one</li>
19715 <li>Sub-two</li>
19716 </ol>
19717 </li>
19718 </ol>
19719 !! html
19720 <ol>
19721 <li>One</li>
19722 <li>Two:
19723 <ol>
19724 <li>Sub-one</li>
19725 <li>Sub-two</li>
19726 </ol>
19727 </li>
19728 </ol>
19729
19730 !! end
19731
19732 !! test
19733 HTML nested ordered list, open tags (T7497)
19734 !! wikitext
19735 <ol>
19736 <li>One
19737 <li>Two:
19738 <ol>
19739 <li>Sub-one
19740 <li>Sub-two
19741 </ol>
19742 </ol>
19743 !! html/php
19744 <ol>
19745 <li>One
19746 <li>Two:
19747 <ol>
19748 <li>Sub-one
19749 <li>Sub-two
19750 </ol>
19751 </ol>
19752
19753 !! html/parsoid
19754 <ol>
19755 <li>One
19756 </li>
19757 <li>Two:
19758 <ol>
19759 <li>Sub-one
19760 </li>
19761 <li>Sub-two
19762 </li>
19763 </ol>
19764 </li>
19765 </ol>
19766
19767 !! end
19768
19769 !! test
19770 HTML ordered list item with parameters oddity
19771 !! wikitext
19772 <ol><li id="fragment">One</li>
19773 </ol>
19774 !! html
19775 <ol><li id="fragment">One</li>
19776 </ol>
19777
19778 !! end
19779
19780 # parsoid doesn't explicitly mark autonumbered links, see T55505
19781 !!test
19782 T7918: autonumbering
19783 !! wikitext
19784 [http://first/] [http://second] [ftp://ftp]
19785
19786 ftp://inlineftp
19787
19788 [mailto:enclosed@mail.tld With target]
19789
19790 [mailto:enclosed@mail.tld]
19791
19792 mailto:inline@mail.tld
19793 !! html/php
19794 <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>
19795 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
19796 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
19797 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
19798 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
19799 </p>
19800 !! html/parsoid
19801 <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>
19802 <p><a rel="mw:ExtLink" class="external free" href="ftp://inlineftp">ftp://inlineftp</a></p>
19803 <p><a rel="mw:ExtLink" class="external text" href="mailto:enclosed@mail.tld">With target</a></p>
19804 <p><a rel="mw:ExtLink" class="external autonumber" href="mailto:enclosed@mail.tld"></a></p>
19805 <p><a rel="mw:ExtLink" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
19806 !! end
19807
19808
19809 #
19810 # Security and HTML correctness
19811 # From Nick Jenkins' fuzz testing
19812 #
19813
19814 !! test
19815 Fuzz testing: Parser13
19816 !! wikitext
19817 {|
19818 | http://a|
19819 !! html
19820 <table>
19821 <tr>
19822 <td>
19823 </td>
19824 </tr>
19825 </table>
19826
19827 !! end
19828
19829 # Note that Parsoid output differs from the PHP parser here: the PHP
19830 # parser breaks the URL for the magic word, while in Parsoid the URL
19831 # production takes precedence.
19832 !! test
19833 Fuzz testing: Parser14
19834 !! wikitext
19835 ==onmouseover===
19836 http://__TOC__
19837 !! html/php
19838 <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>
19839 http://<div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
19840 <ul>
19841 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19842 </ul>
19843 </div>
19844
19845
19846 !! html/php+tidy
19847 <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>
19848 http://</p><div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
19849 <ul>
19850 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19851 </ul>
19852 </div>
19853 !! html/parsoid
19854 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span>onmouseover=</h2>
19855 <p><a rel="mw:ExtLink" class="external free" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
19856 !! end
19857
19858 !! test
19859 Fuzz testing: Parser14-table
19860 !! options
19861 parsoid=wt2html,html2html
19862 !! wikitext
19863 ==a==
19864 {| STYLE=__TOC__
19865 !! html/php
19866 <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>
19867 <table style="&#95;_TOC&#95;_">
19868 <tr><td></td></tr>
19869 </table>
19870
19871 !! html/php+tidy
19872 <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>
19873 <table style="&#95;_TOC&#95;_">
19874 <tbody><tr><td></td></tr>
19875 </tbody></table>
19876 !! html/parsoid
19877 <h2 id="a">a</h2>
19878 <table style="__TOC__"></table>
19879 !! end
19880
19881 # Known to produce bogus xml (extra </td>)
19882 # Don't add the html/php section since it generates broken HTML
19883 !! test
19884 Fuzz testing: Parser16
19885 !! wikitext
19886 {|
19887 !https://||||||
19888 !! html+tidy
19889 <table>
19890 <tbody><tr>
19891 <th>https://</th>
19892 <th></th>
19893 <th></th>
19894 <th>
19895
19896 </th></tr>
19897 </tbody></table>
19898 !! end
19899
19900 !! test
19901 Fuzz testing: Parser21
19902 !! wikitext
19903 {|
19904 !irc://{{ftp://a" onmouseover="alert('hello world');"
19905 |
19906 !! html
19907 <table>
19908 <tr>
19909 <th><a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
19910 </th>
19911 <td>
19912 </td>
19913 </tr>
19914 </table>
19915
19916 !! end
19917
19918 !! test
19919 Fuzz testing: Parser22
19920 !! wikitext
19921 http://===r:::https://b
19922
19923 {|
19924 !! html
19925 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
19926 </p>
19927 <table>
19928 <tr><td></td></tr>
19929 </table>
19930
19931 !! end
19932
19933 ## Remex doesn't account for fostered content.
19934 ## Known to produce bad XML for now
19935 !! test
19936 Fuzz testing: Parser24
19937 !! options
19938 parsoid=wt2html
19939 !! wikitext
19940 {|
19941 {{{|
19942 <u CLASS=
19943 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
19944 <br style="onmouseover='alert(document.cookie);' " />
19945
19946 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19947 |
19948 !! html/php
19949 <table>
19950 {{{|
19951 <u class="&#124;">}}}} &gt;
19952 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19953
19954 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19955 <tr>
19956 <td></u>
19957 </td>
19958 </tr>
19959 </table>
19960
19961 !! html/php+tidy
19962
19963 {{{|
19964 <u class="&#124;">}}}} &gt;
19965 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19966
19967 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19968 </u><table><tbody><tr>
19969 <td>
19970 </td>
19971 </tr>
19972 </tbody></table><p><u class="&#124;">
19973 </u></p>
19974 !! html/parsoid
19975 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>
19976 {{{|
19977 <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>"}'/>}}}} >
19978 <br style="onmouseover='alert(document.cookie);' " data-parsoid='{"stx":"html","selfClose":true}'/>
19979
19980 MOVE YOUR MOUSE CURSOR OVER THIS TEXT</u></p>
19981 <table data-parsoid='{"autoInsertedEnd":true}'><tbody><tr data-parsoid='{"autoInsertedStart":true}'><td></td></tr></tbody></table>
19982 !! end
19983
19984 # Note: the current result listed for this is not what the original one was,
19985 # but the original bug was JavaScript injection, which is fixed in any case.
19986 # It's not clear that the original result listed was any more correct than the
19987 # current one. Original result:
19988 # <p>{{{|
19989 # </p>
19990 # <li class="&#124;&#124;">
19991 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19992 !!test
19993 Fuzz testing: Parser25 (T8055)
19994 !! wikitext
19995 {{{
19996 |
19997 <LI CLASS=||
19998 >
19999 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
20000 !! html/php
20001 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
20002 </p>
20003 !! html/parsoid
20004 <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"]}'>
20005 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
20006 !! end
20007
20008 !!test
20009 Fuzz testing: URL adjacent extension (with space, clean)
20010 !! wikitext
20011 http://example.com <nowiki>junk</nowiki>
20012 !! html/php
20013 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
20014 </p>
20015 !! html/parsoid
20016 <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>
20017 !! end
20018
20019 !!test
20020 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
20021 !! wikitext
20022 http://example.com<nowiki>junk</nowiki>
20023 !! html/php
20024 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
20025 </p>
20026 !! html/parsoid
20027 <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>
20028 !! end
20029
20030 !! test
20031 Fuzz testing: URL adjacent extension (no space, dirty; pre)
20032 !! wikitext
20033 http://example.com<pre>junk</pre>
20034 !! html/php
20035 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
20036
20037 !! html/php+tidy
20038 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
20039 !! html/parsoid
20040 <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>
20041 !! end
20042
20043 !! test
20044 Fuzz testing: image with bogus manual thumbnail
20045 !! wikitext
20046 [[Image:foobar.jpg|thumbnail= ]]
20047 !! html/php
20048 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
20049
20050 !! html/parsoid
20051 <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>
20052 !! end
20053
20054 # Parsoid will emit the newline literally in wt2wt; see next test case.
20055 !! test
20056 Fuzz testing: encoded newline in generated HTML replacements (T8577)
20057 !! options
20058 parsoid=wt2html
20059 !! wikitext
20060 <pre dir="&#10;"></pre>
20061 !! html/php
20062 <pre dir="&#10;"></pre>
20063
20064 !! html/parsoid
20065 <pre dir="
20066 " typeof="mw:Extension/pre" about="#mwt2"data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
20067 !! end
20068
20069 !! test
20070 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
20071 !! options
20072 parsoid=html2wt
20073 !! html/parsoid
20074 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
20075 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
20076 !! wikitext
20077 <pre dir="
20078 "></pre>
20079 !! html/php
20080 <pre dir=""></pre>
20081
20082 !! end
20083
20084 !! test
20085 Templates in extension attributes are not expanded
20086 !! wikitext
20087 <pre dir="{{echo|ltr}}"></pre>
20088 !! html/php
20089 <pre dir="{{echo|ltr}}"></pre>
20090
20091 !! html/parsoid
20092 <pre dir="{{echo|ltr}}" typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
20093 !! end
20094
20095 !! test
20096 Parsing optional HTML elements (T8171)
20097 !! options
20098 !! wikitext
20099 <table>
20100 <tr>
20101 <td> Some tabular data</td>
20102 <td> More tabular data ...
20103 <td> And yet som tabular data</td>
20104 </tr>
20105 </table>
20106 !! html
20107 <table>
20108 <tr>
20109 <td> Some tabular data</td>
20110 <td> More tabular data ...
20111 </td><td> And yet som tabular data</td>
20112 </tr>
20113 </table>
20114
20115 !! end
20116
20117 !! test
20118 Correct handling of <td>, <tr> (T8171)
20119 !! options
20120 !! wikitext
20121 <table>
20122 <tr>
20123 <td> Some tabular data</td>
20124 <td> More tabular data ...</td>
20125 <td> And yet som tabular data</td>
20126 </tr>
20127 </table>
20128 !! html
20129 <table>
20130 <tr>
20131 <td> Some tabular data</td>
20132 <td> More tabular data ...</td>
20133 <td> And yet som tabular data</td>
20134 </tr>
20135 </table>
20136
20137 !! end
20138
20139
20140 !! test
20141 Parsing crashing regression (fr:JavaScript)
20142 !! wikitext
20143 </body></x>
20144 !! html
20145 <p>&lt;/body&gt;&lt;/x&gt;
20146 </p>
20147 !! end
20148
20149 !! test
20150 Inline wiki vs wiki block nesting
20151 !! wikitext
20152 '''Bold paragraph
20153
20154 New wiki paragraph
20155 !! html
20156 <p><b>Bold paragraph</b>
20157 </p><p>New wiki paragraph
20158 </p>
20159 !! end
20160
20161 # FIXME: The current php output is documented
20162 # and desired output is the parsoid target.
20163 !! test
20164 Inline HTML vs wiki block nesting
20165 !! wikitext
20166 <b>Bold paragraph
20167
20168 New wiki paragraph
20169 !! html/php
20170 <p><b>Bold paragraph
20171 </p><p>New wiki paragraph</b>
20172 </p>
20173 !! html/php+tidy
20174 <p><b>Bold paragraph
20175 </b></p><p><b>New wiki paragraph
20176 </b></p>
20177 !! html/parsoid
20178 <p><b>Bold paragraph</b>
20179 </p><p>New wiki paragraph
20180 </p>
20181 !! end
20182
20183 # Original result was this:
20184 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
20185 # </p>
20186 # While that might be marginally more intuitive, maybe, the six-apostrophe
20187 # construct is clearly pathological and the result stated here (which is what
20188 # the parser actually does) is about as reasonable as anything.
20189 !!test
20190 Mixing markup for italics and bold
20191 !! options
20192 !! wikitext
20193 '''bold''''''bold''bolditalics'''''
20194 !! html
20195 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
20196 </p>
20197 !! end
20198
20199
20200 !! article
20201 Xyzzyx
20202 !! text
20203 Article for special page transclusion test
20204 !! endarticle
20205
20206 !! test
20207 Special page transclusion
20208 !! options
20209 !! wikitext
20210 {{Special:Prefixindex/Xyzzyx}}
20211 !! html
20212 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20213 </ul>
20214
20215 !! end
20216
20217 !! test
20218 Special page transclusion twice (T7021)
20219 !! options
20220 !! wikitext
20221 {{Special:Prefixindex/Xyzzyx}}
20222 {{Special:Prefixindex/Xyzzyx}}
20223 !! html
20224 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20225 </ul>
20226 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
20227 </ul>
20228
20229 !! end
20230
20231 !! test
20232 Transclusion of default MediaWiki message
20233 !! wikitext
20234 {{MediaWiki:Mainpage}}
20235 !! html
20236 <p>Main Page
20237 </p>
20238 !! end
20239
20240 !! test
20241 Transclusion of nonexistent MediaWiki message
20242 !! wikitext
20243 {{MediaWiki:Mainpagexxx}}
20244 !! html
20245 <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>
20246 </p>
20247 !! end
20248
20249 !! test
20250 Transclusion of MediaWiki message with underscore
20251 !! wikitext
20252 {{MediaWiki:history_short}}
20253 !! html
20254 <p>History
20255 </p>
20256 !! end
20257
20258 !! test
20259 Transclusion of MediaWiki message with space
20260 !! wikitext
20261 {{MediaWiki:history short}}
20262 !! html
20263 <p>History
20264 </p>
20265 !! end
20266
20267 !! test
20268 Invalid header with following text
20269 !! wikitext
20270 = x = y
20271 !! html
20272 <p>= x = y
20273 </p>
20274 !! end
20275
20276
20277 !! test
20278 Section extraction test (section 0)
20279 !! options
20280 section=0
20281 !! wikitext
20282 start
20283 ==a==
20284 ===aa===
20285 ====aaa====
20286 ==b==
20287 ===ba===
20288 ===bb===
20289 ====bba====
20290 ===bc===
20291 ==c==
20292 ===ca===
20293 !! html/php
20294 start
20295 !! end
20296
20297 !! test
20298 Section extraction test (section 1)
20299 !! options
20300 section=1
20301 !! wikitext
20302 start
20303 ==a==
20304 ===aa===
20305 ====aaa====
20306 ==b==
20307 ===ba===
20308 ===bb===
20309 ====bba====
20310 ===bc===
20311 ==c==
20312 ===ca===
20313 !! html/php
20314 ==a==
20315 ===aa===
20316 ====aaa====
20317 !! end
20318
20319 !! test
20320 Section extraction test (section 2)
20321 !! options
20322 section=2
20323 !! wikitext
20324 start
20325 ==a==
20326 ===aa===
20327 ====aaa====
20328 ==b==
20329 ===ba===
20330 ===bb===
20331 ====bba====
20332 ===bc===
20333 ==c==
20334 ===ca===
20335 !! html/php
20336 ===aa===
20337 ====aaa====
20338 !! end
20339
20340 !! test
20341 Section extraction test (section 3)
20342 !! options
20343 section=3
20344 !! wikitext
20345 start
20346 ==a==
20347 ===aa===
20348 ====aaa====
20349 ==b==
20350 ===ba===
20351 ===bb===
20352 ====bba====
20353 ===bc===
20354 ==c==
20355 ===ca===
20356 !! html/php
20357 ====aaa====
20358 !! end
20359
20360 !! test
20361 Section extraction test (section 4)
20362 !! options
20363 section=4
20364 !! wikitext
20365 start
20366 ==a==
20367 ===aa===
20368 ====aaa====
20369 ==b==
20370 ===ba===
20371 ===bb===
20372 ====bba====
20373 ===bc===
20374 ==c==
20375 ===ca===
20376 !! html/php
20377 ==b==
20378 ===ba===
20379 ===bb===
20380 ====bba====
20381 ===bc===
20382 !! end
20383
20384 !! test
20385 Section extraction test (section 5)
20386 !! options
20387 section=5
20388 !! wikitext
20389 start
20390 ==a==
20391 ===aa===
20392 ====aaa====
20393 ==b==
20394 ===ba===
20395 ===bb===
20396 ====bba====
20397 ===bc===
20398 ==c==
20399 ===ca===
20400 !! html/php
20401 ===ba===
20402 !! end
20403
20404 !! test
20405 Section extraction test (section 6)
20406 !! options
20407 section=6
20408 !! wikitext
20409 start
20410 ==a==
20411 ===aa===
20412 ====aaa====
20413 ==b==
20414 ===ba===
20415 ===bb===
20416 ====bba====
20417 ===bc===
20418 ==c==
20419 ===ca===
20420 !! html/php
20421 ===bb===
20422 ====bba====
20423 !! end
20424
20425 !! test
20426 Section extraction test (section 7)
20427 !! options
20428 section=7
20429 !! wikitext
20430 start
20431 ==a==
20432 ===aa===
20433 ====aaa====
20434 ==b==
20435 ===ba===
20436 ===bb===
20437 ====bba====
20438 ===bc===
20439 ==c==
20440 ===ca===
20441 !! html/php
20442 ====bba====
20443 !! end
20444
20445 !! test
20446 Section extraction test (section 8)
20447 !! options
20448 section=8
20449 !! wikitext
20450 start
20451 ==a==
20452 ===aa===
20453 ====aaa====
20454 ==b==
20455 ===ba===
20456 ===bb===
20457 ====bba====
20458 ===bc===
20459 ==c==
20460 ===ca===
20461 !! html/php
20462 ===bc===
20463 !! end
20464
20465 !! test
20466 Section extraction test (section 9)
20467 !! options
20468 section=9
20469 !! wikitext
20470 start
20471 ==a==
20472 ===aa===
20473 ====aaa====
20474 ==b==
20475 ===ba===
20476 ===bb===
20477 ====bba====
20478 ===bc===
20479 ==c==
20480 ===ca===
20481 !! html/php
20482 ==c==
20483 ===ca===
20484 !! end
20485
20486 !! test
20487 Section extraction test (section 10)
20488 !! options
20489 section=10
20490 !! wikitext
20491 start
20492 ==a==
20493 ===aa===
20494 ====aaa====
20495 ==b==
20496 ===ba===
20497 ===bb===
20498 ====bba====
20499 ===bc===
20500 ==c==
20501 ===ca===
20502 !! html/php
20503 ===ca===
20504 !! end
20505
20506 !! test
20507 Section extraction test (nonexistent section 11)
20508 !! options
20509 section=11
20510 !! wikitext
20511 start
20512 ==a==
20513 ===aa===
20514 ====aaa====
20515 ==b==
20516 ===ba===
20517 ===bb===
20518 ====bba====
20519 ===bc===
20520 ==c==
20521 ===ca===
20522 !! html/php
20523 !! end
20524
20525 !! test
20526 Section extraction test with bogus heading (section 1)
20527 !! options
20528 section=1
20529 !! wikitext
20530 ==a==
20531 ==bogus== not a legal section
20532 ==b==
20533 !! html/php
20534 ==a==
20535 ==bogus== not a legal section
20536 !! end
20537
20538 !! test
20539 Section extraction test with bogus heading (section 2)
20540 !! options
20541 section=2
20542 !! wikitext
20543 ==a==
20544 ==bogus== not a legal section
20545 ==b==
20546 !! html/php
20547 ==b==
20548 !! end
20549
20550 !! test
20551 Section extraction test with comment after heading (section 1)
20552 !! options
20553 section=1
20554 !! wikitext
20555 ==a==
20556 ==b== <!-- -->
20557 ==c==
20558 !! html/php
20559 ==a==
20560 !! end
20561
20562 !! test
20563 Section extraction test with comment after heading (section 2)
20564 !! options
20565 section=2
20566 !! wikitext
20567 ==a==
20568 ==b== <!-- -->
20569 ==c==
20570 !! html/php
20571 ==b== <!-- -->
20572 !! end
20573
20574 !! test
20575 Section extraction test with bogus <nowiki> heading (section 1)
20576 !! options
20577 section=1
20578 !! wikitext
20579 ==a==
20580 ==bogus== <nowiki>not a legal section</nowiki>
20581 ==b==
20582 !! html/php
20583 ==a==
20584 ==bogus== <nowiki>not a legal section</nowiki>
20585 !! end
20586
20587 !! test
20588 Section extraction test with bogus <nowiki> heading (section 2)
20589 !! options
20590 section=2
20591 !! wikitext
20592 ==a==
20593 ==bogus== <nowiki>not a legal section</nowiki>
20594 ==b==
20595 !! html/php
20596 ==b==
20597 !! end
20598
20599 # Formerly testing for T4587, now resolved by the use of unmarked sections
20600 # instead of respecting commented sections
20601 !! test
20602 Section extraction prefixed by comment (section 1)
20603 !! options
20604 section=1
20605 !! wikitext
20606 <!-- -->==sec1==
20607 ==sec2==
20608 !! html/php
20609 ==sec2==
20610 !!end
20611
20612 !! test
20613 Section extraction prefixed by comment (section 2)
20614 !! options
20615 section=2
20616 !! wikitext
20617 <!-- -->==sec1==
20618 ==sec2==
20619 !! html/php
20620
20621 !!end
20622
20623 # Formerly testing for T4607, now resolved by the use of unmarked sections
20624 # instead of respecting HTML-style headings
20625 !! test
20626 Section extraction, mixed wiki and html (section 1)
20627 !! options
20628 section=1
20629 !! wikitext
20630 <h2>unmarked</h2>
20631 unmarked
20632 ==1==
20633 one
20634 ==2==
20635 two
20636 !! html/php
20637 ==1==
20638 one
20639 !! end
20640
20641 !! test
20642 Section extraction, mixed wiki and html (section 2)
20643 !! options
20644 section=2
20645 !! wikitext
20646 <h2>unmarked</h2>
20647 unmarked
20648 ==1==
20649 one
20650 ==2==
20651 two
20652 !! html/php
20653 ==2==
20654 two
20655 !! end
20656
20657
20658 # Formerly testing for T5342
20659 !! test
20660 Section extraction, heading surrounded by <noinclude>
20661 !! options
20662 section=1
20663 !! wikitext
20664 <noinclude>==unmarked==</noinclude>
20665 ==marked==
20666 !! html/php
20667 ==marked==
20668 !!end
20669
20670 # Test behavior of T21910
20671 !! test
20672 Sectiion with all-equals
20673 !! options
20674 section=2
20675 !! wikitext
20676 ===
20677 The line above must have a trailing space
20678 === <!--
20679 --> <!-- -->
20680 But just in case it doesn't...
20681 !! html/php
20682 === <!--
20683 --> <!-- -->
20684 But just in case it doesn't...
20685 !! end
20686
20687 !! test
20688 Section replacement test (section 0)
20689 !! options
20690 replace=0,"xxx"
20691 !! wikitext
20692 start
20693 ==a==
20694 ===aa===
20695 ====aaa====
20696 ==b==
20697 ===ba===
20698 ===bb===
20699 ====bba====
20700 ===bc===
20701 ==c==
20702 ===ca===
20703 !! html/php
20704 xxx
20705
20706 ==a==
20707 ===aa===
20708 ====aaa====
20709 ==b==
20710 ===ba===
20711 ===bb===
20712 ====bba====
20713 ===bc===
20714 ==c==
20715 ===ca===
20716 !! end
20717
20718 !! test
20719 Section replacement test (section 1)
20720 !! options
20721 replace=1,"xxx"
20722 !! wikitext
20723 start
20724 ==a==
20725 ===aa===
20726 ====aaa====
20727 ==b==
20728 ===ba===
20729 ===bb===
20730 ====bba====
20731 ===bc===
20732 ==c==
20733 ===ca===
20734 !! html/php
20735 start
20736 xxx
20737
20738 ==b==
20739 ===ba===
20740 ===bb===
20741 ====bba====
20742 ===bc===
20743 ==c==
20744 ===ca===
20745 !! end
20746
20747 !! test
20748 Section replacement test (section 2)
20749 !! options
20750 replace=2,"xxx"
20751 !! wikitext
20752 start
20753 ==a==
20754 ===aa===
20755 ====aaa====
20756 ==b==
20757 ===ba===
20758 ===bb===
20759 ====bba====
20760 ===bc===
20761 ==c==
20762 ===ca===
20763 !! html/php
20764 start
20765 ==a==
20766 xxx
20767
20768 ==b==
20769 ===ba===
20770 ===bb===
20771 ====bba====
20772 ===bc===
20773 ==c==
20774 ===ca===
20775 !! end
20776
20777 !! test
20778 Section replacement test (section 3)
20779 !! options
20780 replace=3,"xxx"
20781 !! wikitext
20782 start
20783 ==a==
20784 ===aa===
20785 ====aaa====
20786 ==b==
20787 ===ba===
20788 ===bb===
20789 ====bba====
20790 ===bc===
20791 ==c==
20792 ===ca===
20793 !! html/php
20794 start
20795 ==a==
20796 ===aa===
20797 xxx
20798
20799 ==b==
20800 ===ba===
20801 ===bb===
20802 ====bba====
20803 ===bc===
20804 ==c==
20805 ===ca===
20806 !! end
20807
20808 !! test
20809 Section replacement test (section 4)
20810 !! options
20811 replace=4,"xxx"
20812 !! wikitext
20813 start
20814 ==a==
20815 ===aa===
20816 ====aaa====
20817 ==b==
20818 ===ba===
20819 ===bb===
20820 ====bba====
20821 ===bc===
20822 ==c==
20823 ===ca===
20824 !! html/php
20825 start
20826 ==a==
20827 ===aa===
20828 ====aaa====
20829 xxx
20830
20831 ==c==
20832 ===ca===
20833 !! end
20834
20835 !! test
20836 Section replacement test (section 5)
20837 !! options
20838 replace=5,"xxx"
20839 !! wikitext
20840 start
20841 ==a==
20842 ===aa===
20843 ====aaa====
20844 ==b==
20845 ===ba===
20846 ===bb===
20847 ====bba====
20848 ===bc===
20849 ==c==
20850 ===ca===
20851 !! html/php
20852 start
20853 ==a==
20854 ===aa===
20855 ====aaa====
20856 ==b==
20857 xxx
20858
20859 ===bb===
20860 ====bba====
20861 ===bc===
20862 ==c==
20863 ===ca===
20864 !! end
20865
20866 !! test
20867 Section replacement test (section 6)
20868 !! options
20869 replace=6,"xxx"
20870 !! wikitext
20871 start
20872 ==a==
20873 ===aa===
20874 ====aaa====
20875 ==b==
20876 ===ba===
20877 ===bb===
20878 ====bba====
20879 ===bc===
20880 ==c==
20881 ===ca===
20882 !! html/php
20883 start
20884 ==a==
20885 ===aa===
20886 ====aaa====
20887 ==b==
20888 ===ba===
20889 xxx
20890
20891 ===bc===
20892 ==c==
20893 ===ca===
20894 !! end
20895
20896 !! test
20897 Section replacement test (section 7)
20898 !! options
20899 replace=7,"xxx"
20900 !! wikitext
20901 start
20902 ==a==
20903 ===aa===
20904 ====aaa====
20905 ==b==
20906 ===ba===
20907 ===bb===
20908 ====bba====
20909 ===bc===
20910 ==c==
20911 ===ca===
20912 !! html/php
20913 start
20914 ==a==
20915 ===aa===
20916 ====aaa====
20917 ==b==
20918 ===ba===
20919 ===bb===
20920 xxx
20921
20922 ===bc===
20923 ==c==
20924 ===ca===
20925 !! end
20926
20927 !! test
20928 Section replacement test (section 8)
20929 !! options
20930 replace=8,"xxx"
20931 !! wikitext
20932 start
20933 ==a==
20934 ===aa===
20935 ====aaa====
20936 ==b==
20937 ===ba===
20938 ===bb===
20939 ====bba====
20940 ===bc===
20941 ==c==
20942 ===ca===
20943 !! html/php
20944 start
20945 ==a==
20946 ===aa===
20947 ====aaa====
20948 ==b==
20949 ===ba===
20950 ===bb===
20951 ====bba====
20952 xxx
20953
20954 ==c==
20955 ===ca===
20956 !!end
20957
20958 !! test
20959 Section replacement test (section 9)
20960 !! options
20961 replace=9,"xxx"
20962 !! wikitext
20963 start
20964 ==a==
20965 ===aa===
20966 ====aaa====
20967 ==b==
20968 ===ba===
20969 ===bb===
20970 ====bba====
20971 ===bc===
20972 ==c==
20973 ===ca===
20974 !! html/php
20975 start
20976 ==a==
20977 ===aa===
20978 ====aaa====
20979 ==b==
20980 ===ba===
20981 ===bb===
20982 ====bba====
20983 ===bc===
20984 xxx
20985 !! end
20986
20987 !! test
20988 Section replacement test (section 10)
20989 !! options
20990 replace=10,"xxx"
20991 !! wikitext
20992 start
20993 ==a==
20994 ===aa===
20995 ====aaa====
20996 ==b==
20997 ===ba===
20998 ===bb===
20999 ====bba====
21000 ===bc===
21001 ==c==
21002 ===ca===
21003 !! html/php
21004 start
21005 ==a==
21006 ===aa===
21007 ====aaa====
21008 ==b==
21009 ===ba===
21010 ===bb===
21011 ====bba====
21012 ===bc===
21013 ==c==
21014 xxx
21015 !! end
21016
21017 !! test
21018 Section replacement test with initial whitespace (T15728)
21019 !! options
21020 replace=2,"xxx"
21021 !! wikitext
21022 Preformatted initial line
21023 ==a==
21024 ===a===
21025 !! html/php
21026 Preformatted initial line
21027 ==a==
21028 xxx
21029 !! end
21030
21031
21032 !! test
21033 Section extraction, heading followed by pre with 20 spaces (T8398)
21034 !! options
21035 section=1
21036 !! wikitext
21037 ==a==
21038 a
21039 !! html/php
21040 ==a==
21041 a
21042 !! end
21043
21044 !! test
21045 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
21046 !! options
21047 section=1
21048 !! wikitext
21049 ==a==
21050 a
21051 !! html/php
21052 ==a==
21053 a
21054 !! end
21055
21056
21057 !! test
21058 Section extraction, <pre> around bogus header (T12309)
21059 !! options
21060 section=2
21061 !! wikitext
21062 == Section One ==
21063 <pre>
21064 =======
21065 </pre>
21066
21067 == Section Two ==
21068 stuff
21069 !! html/php
21070 == Section Two ==
21071 stuff
21072 !! end
21073
21074 !! test
21075 Section replacement, <pre> around bogus header (T12309)
21076 !! options
21077 replace=2,"xxx"
21078 !! wikitext
21079 == Section One ==
21080 <pre>
21081 =======
21082 </pre>
21083
21084 == Section Two ==
21085 stuff
21086 !! html/php
21087 == Section One ==
21088 <pre>
21089 =======
21090 </pre>
21091
21092 xxx
21093 !! end
21094
21095 !! test
21096 Handling of &#x0A; in URLs
21097 !! wikitext
21098 *irc://&#x0A;a
21099 !! html/php
21100 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21101
21102 !! html/parsoid
21103 <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>
21104 !! end
21105
21106 !! test
21107 Handling of %0A in URLs
21108 !! wikitext
21109 *irc://%0Aa
21110 !! html/php
21111 <ul><li><a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21112
21113 !! html/parsoid
21114 <ul><li><a rel="mw:ExtLink" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul>
21115 !! end
21116
21117 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
21118 !! test
21119 5 quotes, code coverage +1 line
21120 !! options
21121 parsoid=wt2html
21122 !! wikitext
21123 '''''
21124 !! html/php
21125 !! html/parsoid
21126 <p><b><i></i></b></p>
21127 !! end
21128
21129 # same html as previous, but wikitext adjusted to match parsoid html2wt
21130 # note that wt2html and html2html will put the <i> before the <b>
21131 !! test
21132 5 quotes, code coverage +1 line w/ nowiki (1)
21133 !! options
21134 parsoid=wt2wt,html2wt
21135 !! wikitext
21136 '''''<nowiki/>'''''
21137 !! html/php
21138 <p><i></i>
21139 </p>
21140 !! html/parsoid
21141 <p><b><i></i></b></p>
21142 !! end
21143
21144 # same as previous, just swapping the <i> and <b>
21145 !! test
21146 5 quotes, code coverage +1 line w/ nowiki (2)
21147 !! wikitext
21148 '''''<nowiki/>'''''
21149 !! html/php
21150 <p><i></i>
21151 </p>
21152 !! html/parsoid
21153 <p><i><b></b></i></p>
21154 !! end
21155
21156 !! test
21157 Special:Search page linking.
21158 !! wikitext
21159 {{Special:search}}
21160 !! html
21161 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
21162 </p>
21163 !! end
21164
21165 !! test
21166 {{!}} is a magic word
21167 !! wikitext
21168 {{!}} is a magic word there and {{!}} is still a magic word here
21169 | is not a magic word here but {{!}} is still a magic word here
21170 !! html/php
21171 <p>| is a magic word there and | is still a magic word here
21172 | is not a magic word here but | is still a magic word here
21173 </p>
21174 !! html/parsoid
21175 <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
21176 | 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>
21177 !! end
21178
21179 !! test
21180 Say the magic word
21181 !! options
21182 title=[[Parser test]]
21183 !! wikitext
21184 *{{PAGENAME}}
21185 *{{PAGENAMEE}}
21186 *{{FULLPAGENAME}}
21187 *{{FULLPAGENAMEE}}
21188 *{{BASEPAGENAME}}
21189 *{{BASEPAGENAMEE}}
21190 *{{SUBPAGENAME}}
21191 *{{SUBPAGENAMEE}}
21192 *{{ROOTPAGENAME}}
21193 *{{ROOTPAGENAMEE}}
21194 *{{TALKPAGENAME}}
21195 *{{TALKPAGENAMEE}}
21196 *{{SUBJECTPAGENAME}}
21197 *{{SUBJECTPAGENAMEE}}
21198 *{{NAMESPACEE}}
21199 *{{NAMESPACE}}
21200 *{{NAMESPACENUMBER}}
21201 *{{TALKSPACE}}
21202 *{{TALKSPACEE}}
21203 *{{SUBJECTSPACE}}
21204 *{{SUBJECTSPACEE}}
21205 *{{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
21206 !! html
21207 <ul><li>Parser test</li>
21208 <li>Parser_test</li>
21209 <li>Parser test</li>
21210 <li>Parser_test</li>
21211 <li>Parser test</li>
21212 <li>Parser_test</li>
21213 <li>Parser test</li>
21214 <li>Parser_test</li>
21215 <li>Parser test</li>
21216 <li>Parser_test</li>
21217 <li>Talk:Parser test</li>
21218 <li>Talk:Parser_test</li>
21219 <li>Parser test</li>
21220 <li>Parser_test</li>
21221 <li></li>
21222 <li></li>
21223 <li>0</li>
21224 <li>Talk</li>
21225 <li>Talk</li>
21226 <li></li>
21227 <li></li>
21228 <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>
21229
21230 !! end
21231 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
21232
21233 !! test
21234 Gallery with valid attributes
21235 !! wikitext
21236 <gallery type="123" summary="345">
21237 File:File:Foobar.jpg
21238 </gallery>
21239 !! html/php
21240 <ul class="gallery mw-gallery-traditional" type="123">
21241 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21242 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
21243 <div class="gallerytext">
21244 </div>
21245 </div></li>
21246 </ul>
21247
21248 !! html/parsoid
21249 <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"}}'>
21250 <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>
21251 </ul>
21252 !! end
21253
21254 ## Parsoid thinks the "centre" here is a property, not a caption.
21255 !! test
21256 Gallery
21257 !! options
21258 parsoid={
21259 "modes": ["wt2html"],
21260 "nativeGallery": true
21261 }
21262 !! wikitext
21263 <gallery>
21264 image1.png |
21265 image2.gif|||||
21266
21267 image3|
21268 image4 |300px| centre
21269 image5.svg| http://///////
21270 [[x|xx]]]]
21271 * image6
21272 </gallery>
21273 !! html/php
21274 <ul class="gallery mw-gallery-traditional">
21275 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21276 <div class="thumb" style="height: 150px;">Image1.png</div>
21277 <div class="gallerytext">
21278 </div>
21279 </div></li>
21280 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21281 <div class="thumb" style="height: 150px;">Image2.gif</div>
21282 <div class="gallerytext">
21283 </div>
21284 </div></li>
21285 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21286 <div class="thumb" style="height: 150px;">Image3</div>
21287 <div class="gallerytext">
21288 </div>
21289 </div></li>
21290 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21291 <div class="thumb" style="height: 150px;">Image4</div>
21292 <div class="gallerytext">
21293 <pre>centre
21294 </pre>
21295 </div>
21296 </div></li>
21297 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21298 <div class="thumb" style="height: 150px;">Image5.svg</div>
21299 <div class="gallerytext">
21300 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
21301 </p>
21302 </div>
21303 </div></li>
21304 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21305 <div class="thumb" style="height: 150px;">* image6</div>
21306 <div class="gallerytext">
21307 </div>
21308 </div></li>
21309 </ul>
21310
21311 !! html/parsoid
21312 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21313 <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>
21314 <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>
21315 <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>
21316 <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>
21317 <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>
21318 <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>
21319 </ul>
21320 !! end
21321
21322 !! test
21323 Gallery (with options, html)
21324 !! options
21325 parsoid={
21326 "modes": ["wt2html", "html2html"],
21327 "nativeGallery": true
21328 }
21329 !! wikitext
21330 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21331 File:Nonexistent.jpg|caption
21332 File:Nonexistent.jpg
21333 image:foobar.jpg|some '''caption''' [[Main Page]]
21334 image:foobar.jpg
21335 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21336 </gallery>
21337 !! html/php
21338 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21339 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21340 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21341 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21342 <div class="gallerytext">
21343 <p>caption
21344 </p>
21345 </div>
21346 </div></li>
21347 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21348 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21349 <div class="gallerytext">
21350 </div>
21351 </div></li>
21352 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21353 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
21354 <div class="gallerytext">
21355 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21356 </p>
21357 </div>
21358 </div></li>
21359 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21360 <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>
21361 <div class="gallerytext">
21362 </div>
21363 </div></li>
21364 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21365 <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>
21366 <div class="gallerytext">
21367 <p>blabla.
21368 </p>
21369 </div>
21370 </div></li>
21371 </ul>
21372
21373 !! html/parsoid
21374 <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":{}}'>
21375 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21376 <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>
21377 <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>
21378 <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>
21379 <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>
21380 <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>
21381 </ul>
21382 !! end
21383
21384 !! test
21385 Gallery (with options, extsrc)
21386 !! options
21387 parsoid={
21388 "nativeGallery": false
21389 }
21390 !! wikitext
21391 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
21392 File:Nonexistent.jpg|caption
21393 File:Nonexistent.jpg
21394 image:foobar.jpg|some '''caption''' [[Main Page]]
21395 image:foobar.jpg
21396 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
21397 </gallery>
21398 !! html/php
21399 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
21400 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
21401 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21402 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21403 <div class="gallerytext">
21404 <p>caption
21405 </p>
21406 </div>
21407 </div></li>
21408 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21409 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
21410 <div class="gallerytext">
21411 </div>
21412 </div></li>
21413 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21414 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/70px-Foobar.jpg" width="70" height="8" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/105px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/140px-Foobar.jpg 2x" /></a></div></div>
21415 <div class="gallerytext">
21416 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21417 </p>
21418 </div>
21419 </div></li>
21420 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21421 <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>
21422 <div class="gallerytext">
21423 </div>
21424 </div></li>
21425 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21426 <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>
21427 <div class="gallerytext">
21428 <p>blabla.
21429 </p>
21430 </div>
21431 </div></li>
21432 </ul>
21433
21434 !! html/parsoid
21435 <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"}}'>
21436 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
21437 <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>
21438 <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>
21439 <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>
21440 <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>
21441 <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>
21442 </ul>
21443 !! end
21444
21445 !! test
21446 Gallery (without px units)
21447 !! wikitext
21448 <gallery widths="70" heights="40">
21449 File:Foobar.jpg
21450 </gallery>
21451 !! html/php
21452 <ul class="gallery mw-gallery-traditional">
21453 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
21454 <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>
21455 <div class="gallerytext">
21456 </div>
21457 </div></li>
21458 </ul>
21459
21460 !! html/parsoid
21461 <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"}}'>
21462 <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>
21463 </ul>
21464 !! end
21465
21466 !! test
21467 Gallery (with invalid units)
21468 !! wikitext
21469 <gallery widths="70em" heights="40em">
21470 File:Foobar.jpg
21471 </gallery>
21472 !! html/php
21473 <ul class="gallery mw-gallery-traditional">
21474 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21475 <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>
21476 <div class="gallerytext">
21477 </div>
21478 </div></li>
21479 </ul>
21480
21481 !! html/parsoid
21482 <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"}}'>
21483 <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>
21484 </ul>
21485 !! end
21486
21487 !! test
21488 Gallery with link that has fragment
21489 !! options
21490 parsoid={
21491 "modes": ["wt2html", "html2html"],
21492 "nativeGallery": true
21493 }
21494 !! wikitext
21495 <gallery>
21496 image:foobar.jpg|link=Main_Page
21497 image:foobar.jpg|link=Main_Page#section
21498 image:foobar.jpg|link=Main Page#section|caption
21499 </gallery>
21500 !! html/php
21501 <ul class="gallery mw-gallery-traditional">
21502 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21503 <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>
21504 <div class="gallerytext">
21505 </div>
21506 </div></li>
21507 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21508 <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>
21509 <div class="gallerytext">
21510 </div>
21511 </div></li>
21512 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21513 <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>
21514 <div class="gallerytext">
21515 <p>caption
21516 </p>
21517 </div>
21518 </div></li>
21519 </ul>
21520
21521 !! html/parsoid
21522 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21523 <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>
21524 <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>
21525 <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>
21526 </ul>
21527 !! end
21528
21529 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
21530 !! test
21531 Gallery with template inside caption
21532 !! options
21533 parsoid={
21534 "nativeGallery": true
21535 }
21536 !! wikitext
21537 <gallery caption="{{echo|hi}}">
21538 File:Foobar.jpg|{{echo|ho}}
21539 </gallery>
21540 !! html/php
21541 <ul class="gallery mw-gallery-traditional">
21542 <li class='gallerycaption'>{{echo|hi}}</li>
21543 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21544 <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>
21545 <div class="gallerytext">
21546 <p>ho
21547 </p>
21548 </div>
21549 </div></li>
21550 </ul>
21551
21552 !! html/parsoid
21553 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21554 <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>
21555 <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>
21556 </ul>
21557 !! end
21558
21559 !! test
21560 Gallery with wikitext inside caption
21561 !! options
21562 parsoid={
21563 "nativeGallery": true
21564 }
21565 !! wikitext
21566 <gallery>
21567 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
21568 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
21569 </gallery>
21570 !! html/php
21571 <ul class="gallery mw-gallery-traditional">
21572 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21573 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="galleryalt" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
21574 <div class="gallerytext">
21575 <p><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>
21576 </p>
21577 </div>
21578 </div></li>
21579 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21580 <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>
21581 <div class="gallerytext">
21582 <p>This is a test template
21583 </p>
21584 </div>
21585 </div></li>
21586 </ul>
21587
21588 !! html/parsoid
21589 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21590 <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>
21591 <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>
21592 </ul>
21593 !! end
21594
21595 !! test
21596 Gallery (with showfilename option)
21597 !! options
21598 parsoid={
21599 "nativeGallery": true
21600 }
21601 !! wikitext
21602 <gallery showfilename="">
21603 File:Nonexistent.jpg|caption
21604 File:Nonexistent.jpg
21605 File:Foobar.jpg|some '''caption''' [[Main Page]]
21606 File:Foobar.jpg
21607 </gallery>
21608 !! html/php
21609 <ul class="gallery mw-gallery-traditional">
21610 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21611 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21612 <div class="gallerytext">
21613 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21614 caption
21615 </p>
21616 </div>
21617 </div></li>
21618 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21619 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21620 <div class="gallerytext">
21621 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
21622 </p>
21623 </div>
21624 </div></li>
21625 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21626 <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>
21627 <div class="gallerytext">
21628 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21629 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21630 </p>
21631 </div>
21632 </div></li>
21633 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21634 <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>
21635 <div class="gallerytext">
21636 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
21637 </p>
21638 </div>
21639 </div></li>
21640 </ul>
21641
21642 !! html/parsoid
21643 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
21644 <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>
21645 <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>
21646 <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>
21647 <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>
21648 </ul>
21649 !! end
21650
21651 ## Should Parsoid be preserving these variations? See T151367
21652 !! test
21653 Gallery (with namespace-less filenames)
21654 !! options
21655 parsoid={
21656 "modes": ["wt2html", "html2html"],
21657 "nativeGallery": true
21658 }
21659 !! wikitext
21660 <gallery>
21661 File:Nonexistent.jpg
21662 Nonexistent.jpg
21663 image:foobar.jpg
21664 foobar.jpg
21665 </gallery>
21666 !! html/php
21667 <ul class="gallery mw-gallery-traditional">
21668 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21669 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21670 <div class="gallerytext">
21671 </div>
21672 </div></li>
21673 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21674 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
21675 <div class="gallerytext">
21676 </div>
21677 </div></li>
21678 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21679 <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>
21680 <div class="gallerytext">
21681 </div>
21682 </div></li>
21683 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21684 <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>
21685 <div class="gallerytext">
21686 </div>
21687 </div></li>
21688 </ul>
21689
21690 !! html/parsoid
21691 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21692 <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>
21693 <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>
21694 <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>
21695 <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>
21696 </ul>
21697 !! end
21698
21699 !! test
21700 Gallery override link with wikilink (T36852)
21701 !! options
21702 parsoid={
21703 "nativeGallery": true
21704 }
21705 !! wikitext
21706 <gallery>
21707 File:Foobar.jpg|alt=galleryalt|link=Wikilink
21708 </gallery>
21709 !! html/php
21710 <ul class="gallery mw-gallery-traditional">
21711 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21712 <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>
21713 <div class="gallerytext">
21714 </div>
21715 </div></li>
21716 </ul>
21717
21718 !! html/parsoid
21719 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21720 <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>
21721 </ul>
21722 !! end
21723
21724 !! test
21725 Gallery override link with absolute external link (T36852)
21726 !! options
21727 parsoid={
21728 "nativeGallery": true
21729 }
21730 !! wikitext
21731 <gallery>
21732 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
21733 </gallery>
21734 !! html/php
21735 <ul class="gallery mw-gallery-traditional">
21736 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21737 <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>
21738 <div class="gallerytext">
21739 </div>
21740 </div></li>
21741 </ul>
21742
21743 !! html/parsoid
21744 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21745 <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>
21746 </ul>
21747 !! end
21748
21749 !! test
21750 Gallery override link with absolute external link with LanguageConverter
21751 !! options
21752 language=zh
21753 !! wikitext
21754 <gallery>
21755 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
21756 </gallery>
21757 !! html/php
21758 <ul class="gallery mw-gallery-traditional">
21759 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21760 <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>
21761 <div class="gallerytext">
21762 <p>caption
21763 </p>
21764 </div>
21765 </div></li>
21766 </ul>
21767
21768 !! html/parsoid
21769 <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"}}'>
21770 <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>
21771 </ul>
21772 !! end
21773
21774 !! test
21775 Gallery override link with malicious javascript (T36852)
21776 !! options
21777 parsoid={
21778 "modes": ["wt2html", "html2html"],
21779 "nativeGallery": true
21780 }
21781 !! wikitext
21782 <gallery>
21783 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
21784 </gallery>
21785 !! html/php
21786 <ul class="gallery mw-gallery-traditional">
21787 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21788 <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>
21789 <div class="gallerytext">
21790 </div>
21791 </div></li>
21792 </ul>
21793
21794 !! html/parsoid
21795 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21796 <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>
21797 </ul>
21798 !! end
21799
21800 # Note that parsoid uses the invalid link as a caption, PHP does not.
21801 !! test
21802 Gallery with invalid title as link (T45964)
21803 !! options
21804 parsoid={
21805 "modes": ["wt2html", "html2html"],
21806 "nativeGallery": true
21807 }
21808 !! wikitext
21809 <gallery>
21810 File:Foobar.jpg|link=<
21811 </gallery>
21812 !! html/php
21813 <ul class="gallery mw-gallery-traditional">
21814 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21815 <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>
21816 <div class="gallerytext">
21817 </div>
21818 </div></li>
21819 </ul>
21820
21821 !! html/parsoid
21822 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21823 <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>
21824 </ul>
21825 !! end
21826
21827 !! test
21828 Serialize gallery without attrs in data-mw
21829 !! options
21830 parsoid={
21831 "modes": ["html2wt"],
21832 "nativeGallery": true
21833 }
21834 !! html/parsoid
21835 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
21836 <li class="gallerycaption">123</li>
21837 <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>
21838 </ul>
21839 !! wikitext
21840 <gallery caption="123">
21841 File:Test.png
21842 </gallery>
21843 !! end
21844
21845 !! test
21846 Gallery with class and style attributes
21847 !! options
21848 parsoid={
21849 "nativeGallery": true
21850 }
21851 !! wikitext
21852 <gallery class="center" style="text-align: center;">
21853 File:Foobar.jpg
21854 </gallery>
21855 !! html/php
21856 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
21857 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21858 <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>
21859 <div class="gallerytext">
21860 </div>
21861 </div></li>
21862 </ul>
21863
21864 !! html/parsoid
21865 <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":{}}'>
21866 <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>
21867 </ul>
21868 !! end
21869
21870 !! test
21871 Gallery in slideshow mode
21872 !! options
21873 parsoid={
21874 "nativeGallery": true
21875 }
21876 !! wikitext
21877 <gallery mode="slideshow" showthumbnails="">
21878 File:Foobar.jpg
21879 </gallery>
21880 !! html/php
21881 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
21882 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21883 <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>
21884 <div class="gallerytext">
21885 </div>
21886 </div></li>
21887 </ul>
21888
21889 !! html/parsoid
21890 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
21891 <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>
21892 </ul>
21893 !! end
21894
21895 !! test
21896 Serialize gallery image captions on a line
21897 !! options
21898 parsoid={
21899 "modes": ["html2wt"],
21900 "nativeGallery": true
21901 }
21902 !! html/parsoid
21903 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21904 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"><p>hi</p><p>ho</p></div></li>
21905 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext">hi<br />ho</div></li>
21906 </ul>
21907 !! wikitext
21908 <gallery>
21909 File:Foobar.jpg| hi ho
21910 File:Foobar.jpg|hi<br />ho
21911 </gallery>
21912 !! end
21913
21914 !! test
21915 HTML Hex character encoding (spells the word "JavaScript")
21916 !! options
21917 parsoid=wt2html,wt2wt,html2html
21918 !! wikitext
21919 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
21920 !! html/php
21921 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
21922 </p>
21923 !! html/parsoid
21924 <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>
21925 !! end
21926
21927 !! test
21928 HTML Hex character encoding bogus encoding (T28437 regression check)
21929 !! wikitext
21930 &#xsee;&#XSEE;
21931 !! html
21932 <p>&amp;#xsee;&amp;#XSEE;
21933 </p>
21934 !! end
21935
21936 !! test
21937 HTML Hex character encoding mixed case
21938 !! options
21939 parsoid=wt2html,wt2wt,html2html
21940 !! wikitext
21941 &#xEE;&#Xee;
21942 !! html/php
21943 <p>&#xee;&#xee;
21944 </p>
21945 !! html/parsoid
21946 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
21947 !! end
21948
21949 # See: https://www.w3.org/TR/html5/syntax.html#character-references
21950 # Note that U+000C (form feed) is not a valid XML character, so
21951 # it is banned even though allowed in HTML5.
21952 !! test
21953 Illegal character references (T106578)
21954 !! wikitext
21955 ; Null: &#00;
21956 ; FF: &#xC;
21957 ; CR: &#xD;
21958 ; Control (low): &#8;
21959 ; Control (high): &#x7F; &#x9F;
21960 ; Surrogate: &#xD83D;&#xDCA9;
21961 ; This is an okay astral character: &#x1F4A9;
21962 !! html+tidy
21963 <dl><dt>Null</dt>
21964 <dd>&amp;#00;</dd>
21965 <dt>FF</dt>
21966 <dd>&amp;#xC;</dd>
21967 <dt>CR</dt>
21968 <dd>&amp;#xD;</dd>
21969 <dt>Control (low)</dt>
21970 <dd>&amp;#8;</dd>
21971 <dt>Control (high)</dt>
21972 <dd>&amp;#x7F; &amp;#x9F;</dd>
21973 <dt>Surrogate</dt>
21974 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
21975 <dt>This is an okay astral character</dt>
21976 <dd>&#x1f4a9;</dd></dl>
21977 !! end
21978
21979 !! test
21980 __FORCETOC__ override
21981 !! wikitext
21982 __NEWSECTIONLINK__
21983 __FORCETOC__
21984 !! html/php
21985 <p><br />
21986 </p>
21987 !! end
21988
21989 !! test
21990 ISBN code coverage
21991 !! wikitext
21992 ISBN 978-0-1234-56&#x20;789
21993 !! html/php
21994 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
21995 </p>
21996 !! html/parsoid
21997 <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>
21998 !! end
21999
22000 !! test
22001 ISBN followed by 5 spaces
22002 !! wikitext
22003 ISBN
22004 !! html
22005 <p>ISBN
22006 </p>
22007 !! end
22008
22009 !! test
22010 Double ISBN
22011 !! wikitext
22012 ISBN ISBN 1234567890
22013 !! html/php
22014 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22015 </p>
22016 !! html/parsoid
22017 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22018 !! end
22019
22020 # Uppercase X and lowercase x as well
22021 !! test
22022 ISBN with an X
22023 !! wikitext
22024 ISBN 3-462-04561-X
22025 ISBN 3-462-04561-x
22026 ISBN 080442957X
22027 ISBN 080442957x
22028 ISBN 978080442957X
22029 ISBN 978080442957x
22030 !! html/php
22031 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
22032 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
22033 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
22034 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
22035 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
22036 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
22037 </p>
22038 !! html/parsoid
22039 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
22040 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
22041 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
22042 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
22043 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
22044 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
22045 !! end
22046
22047 !! test
22048 ISBN with empty prefix (parsoid test)
22049 !! wikitext
22050 ISBN 1234567890
22051 !! html/php
22052 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22053 </p>
22054 !! html/parsoid
22055 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
22056 !! end
22057
22058 !! test
22059 T24905: <abbr> followed by ISBN followed by </a>
22060 !! wikitext
22061 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
22062 !! html/php
22063 <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>
22064 </p>
22065 !! html/parsoid
22066 <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>
22067 !! end
22068
22069 !! test
22070 Double RFC
22071 !! wikitext
22072 RFC RFC 1234
22073 !! html/php
22074 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
22075 </p>
22076 !! html/parsoid
22077 <p>RFC <a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></p>
22078 !! end
22079
22080 !! test
22081 Double RFC with a wiki link
22082 !! wikitext
22083 RFC [[RFC 1234]]
22084 !! html/php
22085 <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>
22086 </p>
22087 !! html/parsoid
22088 <p>RFC <a rel="mw:WikiLink" href="./RFC_1234" title="RFC 1234">RFC 1234</a></p>
22089 !! end
22090
22091 !! test
22092 RFC code coverage
22093 !! wikitext
22094 RFC 983&#x20;987
22095 !! html/php
22096 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
22097 </p>
22098 !! html/parsoid
22099 <p><a href="https://tools.ietf.org/html/rfc983" rel="mw:ExtLink" class="external mw-magiclink" data-parsoid='{"stx":"magiclink"}'>RFC 983</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#x20;","srcContent":" "}'> </span>987</p>
22100 !! end
22101
22102 !! test
22103 Centre-aligned image
22104 !! wikitext
22105 [[Image:foobar.jpg|centre]]
22106 !! html/php
22107 <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>
22108
22109 !! html/parsoid
22110 <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>
22111 !! end
22112
22113 !! test
22114 None-aligned image
22115 !! wikitext
22116 [[Image:foobar.jpg|none]]
22117 !! html/php
22118 <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>
22119
22120 !! html/parsoid
22121 <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>
22122 !! end
22123
22124 !! test
22125 Width + Height sized image (using px) (height is ignored)
22126 !! wikitext
22127 [[Image:foobar.jpg|640x480px]]
22128 !! html/php
22129 <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>
22130 </p>
22131 !! html/parsoid
22132 <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>
22133 !! end
22134
22135 !! test
22136 Width-sized image (using px, no following whitespace)
22137 !! wikitext
22138 [[Image:foobar.jpg|640px]]
22139 !! html/php
22140 <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>
22141 </p>
22142 !! html/parsoid
22143 <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>
22144 !! end
22145
22146 !! test
22147 Width-sized image (using px, with following whitespace - test regression from r39467)
22148 !! wikitext
22149 [[Image:foobar.jpg|640px ]]
22150 !! html/php
22151 <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>
22152 </p>
22153 !! html/parsoid
22154 <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>
22155 !!end
22156
22157 !! test
22158 Width-sized image (using px, with preceding whitespace - test regression from r39467)
22159 !! wikitext
22160 [[Image:foobar.jpg| 640px]]
22161 !! html/php
22162 <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>
22163 </p>
22164 !! html/parsoid
22165 <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>
22166 !! end
22167
22168 !! test
22169 Image with page parameter
22170 !! options
22171 djvu
22172 !! wikitext
22173 [[File:LoremIpsum.djvu|page=2]]
22174 !! html/php
22175 <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>
22176 </p>
22177 !! html/parsoid
22178 <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>
22179 !! end
22180
22181 !! test
22182 Another italics / bold test
22183 !! wikitext
22184 ''' ''x'
22185 !! html
22186 <pre>'<i> </i>x'
22187 </pre>
22188 !!end
22189
22190 # FIXME: The php output seems broken. It's interleaving some open/close tags.
22191 !! test
22192 dt/dd/dl test
22193 !! wikitext
22194 :;;;::
22195 !! html/php
22196 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
22197
22198 !! html/parsoid
22199 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
22200
22201 !!end
22202
22203 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
22204 !! test
22205 Images with the "|" character in the comment
22206 !! wikitext
22207 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
22208 !! html/php
22209 <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>
22210
22211 !! html/parsoid
22212 <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>
22213 !! end
22214
22215 !! test
22216 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
22217 !! wikitext
22218 <html><script>alert(1);</script></html>
22219 !! html
22220 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
22221 </p>
22222 !! end
22223
22224 !! test
22225 HTML with raw HTML ($wgRawHtml==true)
22226 !! options
22227 wgRawHtml=1
22228 !! wikitext
22229 <html><script>alert(1);</script></html>
22230 !! html/php
22231 <p><script>alert(1);</script>
22232 </p>
22233 !! html/parsoid
22234 <p><script typeof="mw:Extension/html" about="#mwt3" data-mw='{"name":"html","attrs":{},"body":{"extsrc":"&lt;script>alert(1);&lt;/script>"}}'>alert(1);</script></p>
22235 !! end
22236
22237 !! test
22238 Parents of subpages, one level up
22239 !! options
22240 subpage title=[[Subpage test/L1/L2/L3]]
22241 !! wikitext
22242 [[../|L2]]
22243 !! html
22244 <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>
22245 </p>
22246 !! end
22247
22248
22249 !! test
22250 Parents of subpages, one level up, not named
22251 !! options
22252 subpage title=[[Subpage test/L1/L2/L3]]
22253 !! wikitext
22254 [[../]]
22255 !! html
22256 <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>
22257 </p>
22258 !! end
22259
22260
22261
22262 !! test
22263 Parents of subpages, two levels up
22264 !! options
22265 subpage title=[[Subpage test/L1/L2/L3]]
22266 !! wikitext
22267 [[../../|L1]]2
22268
22269 [[../../|L1]]l
22270 !! html
22271 <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
22272 </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>
22273 </p>
22274 !! end
22275
22276 !! test
22277 Parents of subpages, two levels up, without trailing slash or name.
22278 !! options
22279 subpage title=[[Subpage test/L1/L2/L3]]
22280 !! wikitext
22281 [[../..]]
22282 !! html
22283 <p>[[../..]]
22284 </p>
22285 !! end
22286
22287 !! test
22288 Parents of subpages, two levels up, with lots of extra trailing slashes.
22289 !! options
22290 subpage title=[[Subpage test/L1/L2/L3]]
22291 !! wikitext
22292 [[../../////]]
22293 !! html
22294 <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>
22295 </p>
22296 !! end
22297
22298 !! article
22299 Subpage test/L1/L2/L3Sibling
22300 !! text
22301 Sibling article
22302 !! endarticle
22303
22304 !! test
22305 Transclusion of a sibling page (one level up)
22306 !! options
22307 subpage title=[[Subpage test/L1/L2/L3]]
22308 !! wikitext
22309 {{../L3Sibling}}
22310 !! html
22311 <p>Sibling article
22312 </p>
22313 !! end
22314
22315 !! test
22316 Transclusion of a child page
22317 !! options
22318 subpage title=[[Subpage test/L1/L2]]
22319 !! wikitext
22320 {{/L3Sibling}}
22321 !! html
22322 <p>Sibling article
22323 </p>
22324 !! end
22325
22326 # This is wt2html only in Parsoid because we add <nowiki>
22327 # because of {{..}} and we don't expect to fix that to
22328 # eliminate the nowikis selective for {{..}} markup.
22329 !! test
22330 Non-transclusion because of too many up levels
22331 !! options
22332 subpage title=[[Subpage test/L1/L2/L3]]
22333 parsoid=wt2html
22334 !! wikitext
22335 {{../../../../More than parent}}
22336 !! html/php
22337 <p>{{../../../../More than parent}}
22338 </p>
22339 !! html/parsoid
22340 <p>{{../../../../More than parent}}</p>
22341 !! end
22342
22343 !! test
22344 Definition list code coverage
22345 !! wikitext
22346 ;title :def
22347 ;title :def
22348 ;title:def
22349 !! html/php
22350 <dl><dt>title</dt>
22351 <dd>def</dd>
22352 <dt>title</dt>
22353 <dd>def</dd>
22354 <dt>title</dt>
22355 <dd>def</dd></dl>
22356
22357 !! html/parsoid
22358 <dl><dt>title </dt><dd>def</dd>
22359 <dt>title </dt><dd>def</dd>
22360 <dt>title</dt><dd>def</dd></dl>
22361 !! end
22362
22363 !! test
22364 Don't fall for the self-closing div
22365 !! wikitext
22366 <div>hello world</div/>
22367 !! html
22368 <div>hello world</div>
22369
22370 !! end
22371
22372 !! test
22373 MSGNW magic word
22374 !! wikitext
22375 {{MSGNW:msg}}
22376 !! html/php
22377 <p>&#91;&#91;:Template:Msg&#93;&#93;
22378 </p>
22379 !! end
22380
22381 !! test
22382 RAW magic word
22383 !! wikitext
22384 {{RAW:QUERTY}}
22385 !! html
22386 <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>
22387 </p>
22388 !! end
22389
22390 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
22391 !! test
22392 Always escape literal '>' in output, not just after '<'
22393 !! wikitext
22394 ><>
22395 !! html
22396 <p>&gt;&lt;&gt;
22397 </p>
22398 !! end
22399
22400 !! test
22401 Template caching
22402 !! wikitext
22403 {{Test}}
22404 {{Test}}
22405 !! html
22406 <p>This is a test template
22407 This is a test template
22408 </p>
22409 !! end
22410
22411
22412 !! article
22413 MediaWiki:Fake
22414 !! text
22415 ==header==
22416 !! endarticle
22417
22418 !! test
22419 Inclusion of !userCanEdit() content
22420 !! wikitext
22421 {{MediaWiki:Fake}}
22422 !! html
22423 <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>
22424
22425 !! end
22426
22427
22428 !! test
22429 Out-of-order TOC heading levels
22430 !! wikitext
22431 ==2==
22432 ======6======
22433 ===3===
22434 =1=
22435 =====5=====
22436 ==2==
22437 !! html
22438 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
22439 <ul>
22440 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
22441 <ul>
22442 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
22443 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
22444 </ul>
22445 </li>
22446 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
22447 <ul>
22448 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
22449 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
22450 </ul>
22451 </li>
22452 </ul>
22453 </div>
22454
22455 <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>
22456 <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>
22457 <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>
22458 <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>
22459 <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>
22460 <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>
22461
22462 !! end
22463
22464
22465 !! test
22466 ISBN with a dummy number
22467 !! wikitext
22468 ISBN ---
22469 !! html
22470 <p>ISBN ---
22471 </p>
22472 !! end
22473
22474
22475 !! test
22476 ISBN with space-delimited number
22477 !! wikitext
22478 ISBN 92 9017 032 8
22479 !! html/php
22480 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
22481 </p>
22482 !! html/parsoid
22483 <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>
22484 !! end
22485
22486
22487 !! test
22488 ISBN with multiple spaces, no number
22489 !! wikitext
22490 ISBN foo
22491 !! html
22492 <p>ISBN foo
22493 </p>
22494 !! end
22495
22496
22497 !! test
22498 ISBN length
22499 !! wikitext
22500 ISBN 123456789
22501
22502 ISBN 1234567890
22503
22504 ISBN 12345678901
22505 !! html/php
22506 <p>ISBN 123456789
22507 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
22508 </p><p>ISBN 12345678901
22509 </p>
22510 !! html/parsoid
22511 <p>ISBN 123456789</p>
22512
22513 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
22514
22515 <p>ISBN 12345678901</p>
22516 !! end
22517
22518
22519 !! test
22520 ISBN with trailing year (T9110)
22521 !! wikitext
22522 ISBN 1-234-56789-0 - 2006
22523
22524 ISBN 1 234 56789 0 - 2006
22525 !! html/php
22526 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
22527 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
22528 </p>
22529 !! html/parsoid
22530 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
22531
22532 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
22533 !! end
22534
22535
22536 !! test
22537 anchorencode
22538 !! config
22539 wgFragmentMode=[ 'html5', 'legacy' ]
22540 !! wikitext
22541 {{anchorencode:foo bar©#%n}}
22542 !! html/php
22543 <p>foo_bar©#%n
22544 </p>
22545 !! html/parsoid
22546 <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>
22547 !! end
22548
22549 !! test
22550 anchorencode (legacy)
22551 !! config
22552 wgFragmentMode=[ 'legacy' ]
22553 !! wikitext
22554 {{anchorencode:foo bar©#%n}}
22555 !! html/php
22556 <p>foo_bar.C2.A9.23.25n
22557 </p>
22558 !! end
22559
22560 !! test
22561 anchorencode trims spaces
22562 !! config
22563 wgFragmentMode=[ 'html5', 'legacy' ]
22564 !! wikitext
22565 {{anchorencode: __pretty__please__}}
22566 !! html/php
22567 <p>pretty_please
22568 </p>
22569 !! html/parsoid
22570 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
22571 !! end
22572
22573 !! test
22574 anchorencode deals with links
22575 !! config
22576 wgFragmentMode=[ 'html5', 'legacy' ]
22577 !! wikitext
22578 {{anchorencode: [[hello|world]] [[hi]]}}
22579 !! html/php
22580 <p>world_hi
22581 </p>
22582 !! html/parsoid
22583 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
22584 !! end
22585
22586 !! test
22587 anchorencode deals with templates
22588 !! config
22589 wgFragmentMode=[ 'html5', 'legacy' ]
22590 !! wikitext
22591 {{anchorencode: {{Foo}} x}}
22592 !! html/php
22593 <p>FOO_x
22594 </p>
22595 !! html/parsoid
22596 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
22597 !! end
22598
22599 !! test
22600 anchorencode encodes like the TOC generator: (T20431)
22601 !! config
22602 wgFragmentMode=[ 'html5', 'legacy' ]
22603 !! wikitext
22604 ===_ +:.3A%3A _ &&amp;]] x===
22605 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
22606 __NOEDITSECTION__
22607 !! html/php
22608 <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>
22609 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
22610 </p>
22611 !! html/parsoid
22612 <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>
22613 <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>
22614 <meta property="mw:PageProp/noeditsection"/>
22615 !! end
22616
22617 !! test
22618 anchorencode encodes like the TOC generator: (T20431) (legacy)
22619 !! config
22620 wgFragmentMode=[ 'legacy' ]
22621 !! wikitext
22622 ===_ +:.3A%3A&&amp;]]===
22623 {{anchorencode: _ +:.3A%3A&&amp;]] }}
22624 __NOEDITSECTION__
22625 !! html/php
22626 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
22627 <p>.2B:.3A.253A.26.26.5D.5D
22628 </p>
22629 !! end
22630
22631 !! test
22632 T8200: blockquotes and paragraph formatting
22633 !! wikitext
22634 <blockquote>
22635 foo
22636 </blockquote>
22637
22638 bar
22639
22640 baz
22641 !! html
22642 <blockquote>
22643 <p>foo
22644 </p>
22645 </blockquote>
22646 <p>bar
22647 </p>
22648 <pre>baz
22649 </pre>
22650 !! end
22651
22652 !! test
22653 T10293: Use of center tag ruins paragraph formatting
22654 !! wikitext
22655 <center>
22656 foo
22657 </center>
22658
22659 bar
22660
22661 baz
22662 !! html
22663 <center>
22664 <p>foo
22665 </p>
22666 </center>
22667 <p>bar
22668 </p>
22669 <pre>baz
22670 </pre>
22671 !! end
22672
22673 !!test
22674 Parsing of overlapping (improperly nested) inline html tags
22675 !! wikitext
22676 <span><s>x</span></s>
22677 !! html/php
22678 <p><span><s>x&lt;/span&gt;</s></span>
22679 </p>
22680 !! html/parsoid
22681 <p><span><s>x</s></span>
22682 </p>
22683 !!end
22684
22685 ###
22686 ### Language variants related tests
22687 ###
22688
22689 # Parsoid does not mark self-links.
22690 # Parsoid does not convert links; PHP will do any necessary redirects.
22691
22692 !! test
22693 Self-link in language variants
22694 !! options
22695 title=[[Dunav]] language=sr
22696 !! wikitext
22697 Both [[Dunav]] and [[Дунав]] are names for this river.
22698 !! html/php
22699 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
22700 </p>
22701 !! html/parsoid
22702 <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>
22703 !! end
22704
22705 !! article
22706 Дуна
22707 !! text
22708 content
22709 !! endarticle
22710
22711 !! test
22712 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
22713 !! options
22714 title=[[Duna]] language=sr
22715 !! wikitext
22716 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
22717 !! html/php
22718 <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.
22719 </p>
22720 !! html/parsoid
22721 <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>
22722 !! end
22723
22724 !! test
22725 Link to a section of a variant of this title shouldn't be parsed as self-link
22726 !! options
22727 title=[[Duna]] language=sr
22728 !! wikitext
22729 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
22730 !! html/php
22731 <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.
22732 </p>
22733 !! html/parsoid
22734 <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>
22735 !! end
22736
22737 !! test
22738 Link to pages in language variants
22739 !! options
22740 language=sr
22741 !! wikitext
22742 Main Page can be written as [[Маин Паге]]
22743 !! html/php
22744 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
22745 </p>
22746 !! html/parsoid
22747 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
22748 !! end
22749
22750
22751 !! test
22752 Multiple links to pages in language variants
22753 !! options
22754 language=sr
22755 !! wikitext
22756 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
22757 !! html/php
22758 <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>.
22759 </p>
22760 !! html/parsoid
22761 <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>
22762 !! end
22763
22764
22765 !! test
22766 Simple template in language variants
22767 !! options
22768 language=sr
22769 !! wikitext
22770 {{тест}}
22771 !! html/php
22772 <p>This is a test template
22773 </p>
22774 !! end
22775
22776
22777 !! test
22778 Template with explicit namespace in language variants
22779 !! options
22780 language=sr
22781 !! wikitext
22782 {{Template:тест}}
22783 !! html/php
22784 <p>This is a test template
22785 </p>
22786 !! end
22787
22788
22789 !! test
22790 Basic test for template parameter in language variants
22791 !! options
22792 language=sr
22793 !! wikitext
22794 {{парамтест|param=foo}}
22795 !! html/php
22796 <p>This is a test template with parameter foo
22797 </p>
22798 !! end
22799
22800 !! test
22801 Simple category in language variants
22802 !! options
22803 language=sr cat
22804 !! wikitext
22805 [[Category:МедиаWики Усер'с Гуиде]]
22806 !! html/php
22807 cat=МедиаWики_Усер'с_Гуиде sort=
22808 !! html/parsoid
22809 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
22810 !! end
22811
22812 !! article
22813 Category:分类
22814 !! text
22815 blah
22816 !! endarticle
22817
22818 !! article
22819 Category:分類
22820 !! text
22821 blah
22822 !! endarticle
22823
22824 ## We used to, but no longer wt2wt this test since the default serializer
22825 ## will normalize all categories to serialize on their own line.
22826 ## This wikitext usage is going to be fairly uncommon in production and
22827 ## selser will take care of preserving formatting in those scenarios.
22828 !! test
22829 Don't convert blue categorylinks to another variant (T35210)
22830 !! options
22831 cat
22832 language=zh
22833 parsoid=wt2html
22834 !! wikitext
22835 [[A]][[Category:分类]]
22836 !! html/php
22837 cat=分类 sort=
22838 !! html/parsoid
22839 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
22840 <link rel="mw:PageProp/Category" href="./Category:分类"/>
22841 !! end
22842
22843 !! test
22844 Stripping -{}- tags (language variants)
22845 !! options
22846 language=sr
22847 !! wikitext
22848 Latin proverb: -{Ne nuntium necare}-
22849 !! html/php
22850 <p>Latin proverb: Ne nuntium necare
22851 </p>
22852 !! html/parsoid
22853 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22854 !! end
22855
22856
22857 !! test
22858 Prevent conversion with -{}- tags (language variants)
22859 !! options
22860 language=sr variant=sr-ec
22861 !! wikitext
22862 Latinski: -{Ne nuntium necare}-
22863 !! html/php
22864 <p>Латински: Ne nuntium necare
22865 </p>
22866 !! html/parsoid
22867 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22868 !! end
22869
22870
22871 !! test
22872 Prevent conversion of text with -{}- tags (language variants)
22873 !! options
22874 language=sr variant=sr-ec
22875 !! wikitext
22876 Latinski: -{Ne nuntium necare}-
22877 !! html/php
22878 <p>Латински: Ne nuntium necare
22879 </p>
22880 !! html/parsoid
22881 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22882 !! end
22883
22884
22885 !! test
22886 Prevent conversion of links with -{}- tags (language variants)
22887 !! options
22888 language=sr variant=sr-ec
22889 !! wikitext
22890 -{[[Main Page]]}-
22891 !! html/php
22892 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22893 </p>
22894 !! html/parsoid
22895 <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>
22896 !! end
22897
22898
22899 !! test
22900 -{}- tags within headlines (within html for parserConvert())
22901 !! config
22902 wgFragmentMode=[ 'html5', 'legacy' ]
22903 !! options
22904 language=sr variant=sr-ec
22905 !! wikitext
22906 ==-{Naslov}-==
22907
22908 Note that even an unprotected headline ID is not affected by language
22909 conversion:
22910
22911 ==Latinski==
22912 !! html/php
22913 <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>
22914 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
22915 цонверсион:
22916 </p>
22917 <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>
22918
22919 !! html/parsoid
22920 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
22921
22922 <p>Note that even an unprotected headline ID is not affected by language
22923 conversion:</p>
22924
22925 <h2 id="Latinski">Latinski</h2>
22926 !! end
22927
22928 !! test
22929 Explicit definition of language variant alternatives
22930 !! options
22931 language=zh variant=zh-tw
22932 !! wikitext
22933 -{zh:China;zh-tw:Taiwan}-, not China
22934 !! html/php
22935 <p>Taiwan, not China
22936 </p>
22937 !! html/parsoid
22938 <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>
22939 !! end
22940
22941 !! test
22942 Filter syntax for language variants
22943 !! options
22944 language=zh variant=zh-tw
22945 !! wikitext
22946 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
22947 !! html/php
22948 <p>fooblog, WEBJOURNAL, WEBLOGquux
22949 </p>
22950 !! html/parsoid
22951 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
22952 !! end
22953
22954 # Note that Parsoid post-processing for language variants needs to
22955 # update the `title` attribute here, based on the mw:ExpandedAttrs property
22956 !! test
22957 Conversion around HTML tags
22958 !! options
22959 language=sr variant=sr-ec
22960 !! wikitext
22961 -{H|span=>sr-ec:script;title=>sr-ec:src}-
22962 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
22963 !! html/php
22964 <p>
22965 <span title="ЛаCтин">ски</span>
22966 </p>
22967 !! html/parsoid
22968 <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"}]}'/>
22969 <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>
22970 !! end
22971
22972 !! test
22973 Explicit session-wise two-way language variant mapping (A flag and - flag)
22974 !! options
22975 language=zh variant=zh-tw
22976 !! wikitext
22977 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
22978
22979 Taiwan is not China.
22980
22981 But -{A|zh:China; zh-tw:Taiwan}- is China,
22982
22983 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
22984
22985 and -{China}- is China.
22986 !! html/php
22987 <p>This is Taiwan, but we'll forget that now.
22988 </p><p>Taiwan is not China.
22989 </p><p>But Taiwan is Taiwan,
22990 </p><p>(This should be stripped!)
22991 </p><p>and China is China.
22992 </p>
22993 !! html/parsoid
22994 <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>
22995 <p>Taiwan is not China.</p>
22996 <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>
22997 <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>
22998 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
22999 !! end
23000
23001 !! test
23002 Explicit session-wise one-way language variant mapping (A flag and - flag)
23003 !! options
23004 language=zh variant=zh-tw
23005 !! wikitext
23006 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
23007
23008 COUNTRY is China or Taiwan.
23009
23010 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
23011
23012 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23013
23014 and -{COUNTRY}- is COUNTRY.
23015 !! html/php
23016 <p>This is Taiwan, but we'll forget that now.
23017 </p><p>COUNTRY is China or Taiwan.
23018 </p><p>But Taiwan is Taiwan,
23019 </p><p>(This should be stripped!)
23020 </p><p>and COUNTRY is COUNTRY.
23021 </p>
23022 !! html/parsoid
23023 <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>
23024 <p>COUNTRY is China or Taiwan.</p>
23025 <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>
23026 <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>
23027 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
23028 !! end
23029
23030 !! test
23031 Explicit session-wise two-way language variant mapping (H flag for hide)
23032 !! options
23033 language=zh variant=zh-tw
23034 !! wikitext
23035 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
23036
23037 Taiwan is China.
23038 !! html/php
23039 <p>(This should be stripped!)
23040 </p><p>Taiwan is Taiwan.
23041 </p>
23042 !! html/parsoid
23043 <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>
23044 <p>Taiwan is China.</p>
23045 !! end
23046
23047 !! test
23048 Explicit session-wise one-way language variant mapping (H flag for hide)
23049 !! options
23050 language=zh variant=zh-tw
23051 !! wikitext
23052 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
23053
23054 COUNTRY is Taiwan or China.
23055 !! html/php
23056 <p>(This should be stripped!)
23057 </p><p>Taiwan is Taiwan or China.
23058 </p>
23059 !! html/parsoid
23060 <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>
23061 <p>COUNTRY is Taiwan or China.</p>
23062 !! end
23063
23064 ## Note that parsoid test runner does not support 'showtitle' option.
23065 !! test
23066 Adding explicit conversion rule for title (T flag)
23067 !! options
23068 language=zh variant=zh-tw showtitle
23069 !! wikitext
23070 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
23071
23072 Taiwan is China.
23073 !! html/php
23074 Taiwan
23075 <p>Should be stripped!
23076 </p><p>Taiwan is China.
23077 </p>
23078 !! html/parsoid
23079 <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>
23080 <p>Taiwan is China.</p>
23081 !! end
23082
23083 !! test
23084 Code coverage: T combined with H flag
23085 !! options
23086 language=zh variant=zh-tw showtitle
23087 !! wikitext
23088 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
23089
23090 Taiwan is China.
23091 !! html/php
23092 Taiwan
23093 <p>Should be stripped!
23094 </p><p>Taiwan is Taiwan.
23095 </p>
23096 !! html/parsoid
23097 <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>
23098 <p>Taiwan is China.</p>
23099 !! end
23100
23101 !! test
23102 Code coverage: T with no variants
23103 !! options
23104 language=zh variant=zh-tw showtitle
23105 !! wikitext
23106 -{H|zh:China; zh-tw:Taiwan}-
23107 Taiwan is China.-{T|Taiwan is China}-
23108 !! html/php
23109 Taiwan is China
23110 <p>
23111 Taiwan is Taiwan.
23112 </p>
23113 !! html/parsoid
23114 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23115 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
23116 !! end
23117
23118 !! test
23119 Code coverage: rules with no variants
23120 !! options
23121 language=zh variant=zh-tw
23122 !! wikitext
23123 -{H|zh:China; zh-tw:Taiwan}-
23124 Taiwan is China.
23125 -{H|China}-
23126 Taiwan is China.
23127 !! html/php
23128 <p>
23129 Taiwan is Taiwan.
23130
23131 Taiwan is China.
23132 </p>
23133 !! html/parsoid
23134 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
23135 Taiwan is China.
23136 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
23137 Taiwan is China.</p>
23138 !! end
23139
23140
23141 !! test
23142 Code coverage: D flag for conversion rule
23143 !! options
23144 language=zh variant=zh-tw
23145 !! wikitext
23146 -{D|zh-cn:XA; zh-tw:YA}-
23147 -{A;D|zh-cn:XB; zh-tw:YB}-
23148 -{D;H|zh-cn:XC; zh-tw:YC}-
23149
23150 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
23151
23152 -{D|0=>zh-tw:1}-
23153 -{A;D|2=>zh-tw:3}-
23154 -{D;H|4=>zh-tw:5}-
23155
23156 XA XB XC YA YB YC FOO BAR BAT 012345
23157 !! html/php
23158 <p>大陆:XA;台灣:YA;
23159
23160 大陆:XC;台灣:YC;
23161 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
23162 </p><p>0⇒台灣:1;
23163
23164 4⇒台灣:5;
23165 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
23166 </p>
23167 !! html/parsoid
23168 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
23169 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
23170 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
23171 <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>
23172 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
23173 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
23174 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
23175 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
23176 !! end
23177
23178 !! test
23179 Code coverage: N flag for conversion rule
23180 !! options
23181 language=zh variant=zh-cn
23182 !! wikitext
23183 -{N|zh-cn}-
23184
23185 -{N|zh-tw}-
23186
23187 -{N|sr-ec}-
23188 !! html/php
23189 <p>大陆
23190 </p><p>台灣
23191 </p><p>српски (ћирилица)‎
23192 </p>
23193 !! html/parsoid
23194 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
23195 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
23196 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
23197 !! end
23198
23199 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
23200 !! test
23201 Code coverage: N flag for conversion rule (wt2html only)
23202 !! options
23203 language=zh variant=zh-cn
23204 parsoid=wt2html,html2html
23205 !! wikitext
23206 -{D;N|en}-
23207 !! html/php
23208 <p>English
23209 </p>
23210 !! html/parsoid
23211 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
23212 !! end
23213
23214 !! test
23215 Testing that changing the language variant here in the tests actually works
23216 !! options
23217 language=zh variant=zh showtitle
23218 !! wikitext
23219 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23220 !! html/php
23221 China
23222 <p>Should be stripped!
23223 </p>
23224 !! html/parsoid
23225 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
23226 !! end
23227
23228 !! test
23229 Recursive conversion of alt and title attrs shouldn't clear converter state
23230 !! options
23231 language=zh variant=zh-cn
23232 showtitle
23233 !! wikitext
23234 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
23235 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
23236 !! html/php
23237 China
23238 <p>
23239 Should be stripped<span title="Exclamation">!</span>
23240 </p>
23241 !! html/parsoid
23242 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
23243 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>
23244 !! end
23245
23246 !! test
23247 T26072: more test on conversion rule for title
23248 !! options
23249 language=zh variant=zh-tw showtitle
23250 !! wikitext
23251 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
23252
23253 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
23254 !! html/php
23255 Taiwan
23256 <p>This should be stripped!
23257 </p><p>This won't take interferes with the title rule.
23258 </p>
23259 !! html/parsoid
23260 <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>
23261 <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>
23262 !! end
23263
23264 !! test
23265 Partly disable title conversion if variant == main language code
23266 !! options
23267 language=zh variant=zh title=[[ZH]] showtitle
23268 !! wikitext
23269 -{T|zh-cn:CN;zh-tw:TW}-
23270 !! html/php
23271 ZH
23272 <p>
23273 </p>
23274 !! html/parsoid
23275 <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>
23276 !! end
23277
23278 !! test
23279 Partly disable title conversion if variant == main language code, more
23280 !! options
23281 language=zh variant=zh title=[[ZH]] showtitle
23282 !! wikitext
23283 -{T|TW}-
23284 !! html/php
23285 ZH
23286 <p>
23287 </p>
23288 !! html/parsoid
23289 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
23290 !! end
23291
23292 !! test
23293 Raw output of variant escape tags (R flag)
23294 !! options
23295 language=zh variant=zh-tw
23296 !! wikitext
23297 Raw: -{R|zh:China;zh-tw:Taiwan}-
23298 !! html/php
23299 <p>Raw: zh:China;zh-tw:Taiwan
23300 </p>
23301 !! html/parsoid
23302 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
23303 !! end
23304
23305 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
23306 !! test
23307 Raw output of variant escape tags (R flag) (wt2html only)
23308 !! options
23309 language=zh variant=zh-tw
23310 parsoid=wt2html,html2html
23311 !! wikitext
23312 -{Variant}- -{D|syntax}- -{D;R|options}-
23313 !! html/php
23314 <p>Variant syntax options
23315 </p>
23316 !! html/parsoid
23317 <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>
23318 !! end
23319
23320 !! test
23321 Nested markup inside raw output of variant escape tags (R flag)
23322 !! options
23323 language=zh variant=zh-tw
23324 !! wikitext
23325 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
23326 !! html/php
23327 <p>Nested raw: nested Taiwan nested
23328 </p>
23329 !! html/parsoid
23330 <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>
23331 !! end
23332
23333 !! test
23334 Nested markup and spaces inside raw output of variant escape tags (R flag)
23335 !! options
23336 language=zh variant=zh-tw
23337 !! wikitext
23338 X-{ outer -{ inner }- outer }-X
23339 !! html/php
23340 <p>X outer inner outer X
23341 </p>
23342 !! html/parsoid
23343 <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>
23344 !! end
23345
23346 !! test
23347 Templates inside raw output of variant escape tags (R flag)
23348 !! options
23349 language=zh variant=zh-tw
23350 !! wikitext
23351 Nested raw: -{R|nested {{echo|hi}} templates}-
23352 !! html/php
23353 <p>Nested raw: nested hi templates
23354 </p>
23355 !! html/parsoid
23356 <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>
23357 !! end
23358
23359 !! test
23360 Strings evaluating false shouldn't be ignored by Language converter (T51072)
23361 !! options
23362 language=zh variant=zh-cn
23363 !! wikitext
23364 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
23365 !! html/php
23366 <p>0
23367 </p>
23368 !! html/parsoid
23369 <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>
23370 !! end
23371
23372 !! test
23373 Conversion rules from [numeric-only string] to [something else] (T48634)
23374 !! options
23375 language=zh variant=zh-cn
23376 !! wikitext
23377 -{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
23378 !! html/php
23379 <p>D12345EE12345
23380 </p>
23381 !! html/parsoid
23382 <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>
23383 !! end
23384
23385 !! test
23386 Two-way converter rule entries with an empty value should be ignored (T53551)
23387 !! options
23388 language=zh variant=zh-cn
23389 !! wikitext
23390 -{H|zh-cn:foo;zh-tw:;}-foobar
23391 !! html/php
23392 <p>foobar
23393 </p>
23394 !! html/parsoid
23395 <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>
23396 !! end
23397
23398 !! test
23399 One-way converter rule entries with an empty "from" string should be ignored (T53551)
23400 !! options
23401 language=zh variant=zh-cn
23402 !! wikitext
23403 -{H|=>zh-cn:foo;}-foobar
23404 !! html/php
23405 <p>foobar
23406 </p>
23407 !! html/parsoid
23408 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
23409 !! end
23410
23411 !! test
23412 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
23413 !! options
23414 language=zh variant=zh-cn
23415 !! wikitext
23416 -{H|}-foobar
23417 !! html/php
23418 <p>foobar
23419 </p>
23420 !! html/parsoid
23421 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
23422 !! end
23423
23424 !! test
23425 Nested using of manual convert syntax
23426 !! options
23427 language=zh variant=zh-hk
23428 !! wikitext
23429 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
23430 !! html/php
23431 <p>Nested: Hello Hong Kong!
23432 </p>
23433 !! html/parsoid
23434 <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>
23435 !! end
23436
23437 !! test
23438 HTML markups with conversion syntax in attribs, nested in other conversion blocks
23439 !! options
23440 language=zh variant=zh-cn
23441 !! wikitext
23442 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
23443 !! html/php
23444 <p><span title="X">A</span>
23445 </p>
23446 !! html/parsoid
23447 <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>
23448 !! end
23449
23450 !! test
23451 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
23452 !! options
23453 language=zh variant=zh-cn
23454 !! wikitext
23455 -{<span title="-{X}-">A</span>}-
23456 !! html/php+disabled
23457 <p><span title="X">A</span>
23458 </p>
23459 !! html/parsoid
23460 <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>
23461 !! end
23462
23463 # Parsoid and PHP disagree on how to parse this example: Parsoid
23464 # insists that the content of a language converter element be a valid
23465 # DOM fragment or attribute string
23466 !! test
23467 Language converter markup with block content
23468 !! options
23469 language=zh variant=zh-cn
23470 !! wikitext
23471 <span>a-{b<div>c}-d
23472
23473 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
23474
23475 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
23476 !! html/php+tidy
23477 <span>ab<div>cd
23478 <span>ab<div>cd
23479 <span>ad
23480 </span></div></span></div></span>
23481 !! html/parsoid
23482 <span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a<div typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"b&lt;div data-parsoid=&apos;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[10,16,5,0]}&apos;>c&lt;/div>"}}'></div>d
23483
23484 <span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a<div typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"b&lt;div data-parsoid=&apos;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[50,56,5,0]}&apos;>c&lt;/div>"}}'></div>d
23485
23486 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-cn","t":"x&lt;span data-parsoid=&apos;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[82,89,6,0]}&apos;>y&lt;/span>"},{"f":"0","l":"zh-tw","t":"b&lt;div data-parsoid=&apos;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[100,106,5,0]}&apos;>c&lt;/div>"}]}'/>d</span></p></span></span>
23487 !! end
23488
23489 !! test
23490 LanguageConverter selser (1)
23491 !! options
23492 language=zh variant=zh-cn
23493 parsoid={
23494 "modes": ["wt2wt", "selser"],
23495 "changes": [
23496 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23497 ]
23498 }
23499 !! wikitext
23500 -{raw}-
23501 !! wikitext/edited
23502 -{edited}-
23503 !! end
23504
23505 !! test
23506 LanguageConverter selser (2)
23507 !! options
23508 language=zh variant=zh-cn
23509 parsoid={
23510 "modes": ["wt2wt", "selser"],
23511 "changes": [
23512 ["span[class='x']", "contents", "text", "-{foo}-"],
23513 ["a", "contents", "text", "-{"],
23514 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
23515 ]
23516 }
23517 !! wikitext
23518 <span class="x">TEXT1</span>
23519 [http://example.com TEXT2]
23520 [[Foo|TEXT3]]
23521 {{echo|TEXT4}}
23522 !! wikitext/edited
23523 <span class="x"><nowiki>-{foo}-</nowiki></span>
23524 [http://example.com -{]
23525 [[Foo|<nowiki>-{</nowiki>]]
23526 {{1x|<nowiki>-{</nowiki>}}
23527 !! end
23528
23529 # Tests LanguageVariantText in ConstrainedText
23530 !! test
23531 LanguageConverter selser (3)
23532 !! options
23533 language=zh variant=zh-cn
23534 parsoid={
23535 "modes": ["wt2wt", "selser"],
23536 "changes": [
23537 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
23538 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
23539 ]
23540 }
23541 !! wikitext
23542 {|
23543 |-
23544 |<span>Foo</span>
23545 |}
23546 !! wikitext/edited
23547 {|
23548 |-
23549 |<nowiki/>-{edited}-
23550 |}
23551 !! end
23552
23553 # Tests LanguageVariantText._fromSelSer
23554 !! test
23555 LanguageConverter selser (4)
23556 !! options
23557 language=zh variant=zh-cn
23558 parsoid={
23559 "modes": ["wt2wt", "selser"],
23560 "changes": [
23561 ["td > span.x", "remove"]
23562 ]
23563 }
23564 !! wikitext
23565 {|
23566 |-
23567 |<span class="x">Foo</span>-{Bar}-
23568 ||<span class="x">Foo</span>-{Bar}-
23569 |}
23570 !! wikitext/edited
23571 {|
23572 |-
23573 |<nowiki/>-{Bar}-
23574 ||-{Bar}-
23575 |}
23576 !! end
23577
23578 # Since Parsoid is starting to emit canonical wikitext for links,
23579 # [http://example.com http://example.com] will not RT back to that
23580 # form anymore.
23581 # Parsoid does not language-convert links (it is done in a
23582 # post-processing step)
23583 !! test
23584 Proper conversion of text in external links
23585 !! options
23586 language=sr variant=sr-ec
23587 parsoid=wt2html
23588 !! wikitext
23589 http://www.google.com
23590 gopher://www.google.com
23591 [http://www.google.com http://www.google.com]
23592 [gopher://www.google.com gopher://www.google.com]
23593 [https://www.google.com irc://www.google.com]
23594 [ftp://www.google.com www.google.com/ftp://dir]
23595 [//www.google.com www.google.com]
23596 !! html/php
23597 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
23598 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23599 <a rel="nofollow" class="external text" href="http://www.google.com">http://www.google.com</a>
23600 <a rel="nofollow" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23601 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
23602 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
23603 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
23604 </p>
23605 !! html/parsoid
23606 <p><a rel="mw:ExtLink" class="external free" href="http://www.google.com">http://www.google.com</a>
23607 <a rel="mw:ExtLink" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
23608 <a rel="mw:ExtLink" class="external text" href="http://www.google.com">http://www.google.com</a>
23609 <a rel="mw:ExtLink" class="external text" href="gopher://www.google.com">gopher://www.google.com</a>
23610 <a rel="mw:ExtLink" class="external text" href="https://www.google.com">irc://www.google.com</a>
23611 <a rel="mw:ExtLink" class="external text" href="ftp://www.google.com">www.google.com/ftp://dir</a>
23612 <a rel="mw:ExtLink" class="external text" href="//www.google.com">www.google.com</a></p>
23613 !! end
23614
23615 !! test
23616 Do not convert roman numbers to language variants
23617 !! options
23618 language=sr variant=sr-ec
23619 !! wikitext
23620 Fridrih IV je car.
23621 !! html/php
23622 <p>Фридрих IV је цар.
23623 </p>
23624 !! html/parsoid
23625 <p>Fridrih IV je car.</p>
23626 !! end
23627
23628 !! test
23629 Unclosed language converter markup "-{"
23630 !! options
23631 language=sr
23632 !! wikitext
23633 -{T|hello
23634 !! html
23635 <p>-{T|hello
23636 </p>
23637 !! end
23638
23639 !! test
23640 Don't convert raw rule "-{R|=&gt;}-" to "=>"
23641 !! options
23642 language=sr
23643 !! wikitext
23644 -{R|=&gt;}-
23645 !! html/php
23646 <p>=&gt;
23647 </p>
23648 !! html/parsoid
23649 <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>
23650 !!end
23651
23652 !! test
23653 Don't break link parsing if language converter markup is in the caption.
23654 !! options
23655 language=sr variant=sr-ec
23656 !! wikitext
23657 [[Main Page|-{R|main page}-]]
23658 !! html/php
23659 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
23660 </p>
23661 !! html/parsoid
23662 <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>
23663 !! end
23664
23665 !! test
23666 T146304: Don't break template parsing if language converter markup is in the parameter.
23667 !! options
23668 language=sr variant=sr-ec
23669 !! wikitext
23670 {{echo|-{R|foo}-}}
23671 !! html/php
23672 <p>foo
23673 </p>
23674 !! html/parsoid
23675 <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>
23676 !! end
23677
23678 !! test
23679 T146305: Don't break image parsing if language converter markup is in the caption.
23680 !! options
23681 language=sr
23682 !! wikitext
23683 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
23684 !! html/php
23685 <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>
23686
23687 !! html/parsoid
23688 <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>
23689 !! end
23690
23691 !! test
23692 T146305: Don't break image parsing if nested language converter markup is in the caption.
23693 !! options
23694 language=zh variant=zh-cn
23695 !! wikitext
23696 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
23697 !! html/php
23698 <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>
23699
23700 !! html/parsoid
23701 <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>
23702 !! end
23703
23704 # XXX html2wt disabled because rich markup in alt is not preserved.
23705 !! test
23706 Don't break gallery if language converter markup is inside.
23707 !! options
23708 language=zh
23709 !! wikitext
23710 <gallery>
23711 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
23712 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
23713 </gallery>
23714 !! html/php
23715 <ul class="gallery mw-gallery-traditional">
23716 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23717 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="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>
23718 <div class="gallerytext">
23719 <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>
23720 </p>
23721 </div>
23722 </div></li>
23723 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
23724 <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>
23725 <div class="gallerytext">
23726 <p>This is a test template
23727 </p>
23728 </div>
23729 </div></li>
23730 </ul>
23731
23732 !! html/parsoid
23733 <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"}}'>
23734 <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>
23735 <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>
23736 </ul>
23737 !! end
23738
23739 !! test
23740 T153135: Don't break list handling if language converter markup is in the item.
23741 !! options
23742 language=zh variant=zh-cn
23743 !! wikitext
23744 ;-{zh-cn:AAA;zh-tw:BBB}-
23745 ;-{R|foo:bar}-
23746 !! html/php
23747 <dl><dt>AAA</dt>
23748 <dt>foo:bar</dt></dl>
23749
23750 !! html/parsoid
23751 <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>
23752 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
23753 </dl>
23754 !! end
23755
23756 // Note that parsoid does not protect colons unless language converter
23757 // markup is properly nested, because it is a backtracking parser.
23758 !! test
23759 T153135: Unclosed markup in definition list (code coverage)
23760 !! options
23761 language=zh variant=zh-cn
23762 !! wikitext
23763 ;<b>foo:bar
23764 ;-{zh-cn:AAA
23765 !! html/php+tidy
23766 <dl><dt><b>foo:bar</b></dt><b>
23767 <dt>-{zh-cn:AAA</dt></b></dl><p><b>
23768 </b></p>
23769 !! html/parsoid
23770 <dl><dt data-parsoid='{}'><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo:bar</b></dt><b data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
23771 <dt data-parsoid='{}'>-{zh-cn</dt><dd data-parsoid='{"stx":"row"}'>AAA</dd></b></dl>
23772 !! end
23773
23774 !! test
23775 T153135: Nested language converter markup in definition list (code coverage)
23776 !! options
23777 language=zh variant=zh-cn
23778 !! wikitext
23779 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
23780 !! html/php
23781 <dl><dt>AAA foo:bar bat:baz</dt>
23782 <dd>def</dd></dl>
23783
23784 !! html/parsoid
23785 <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>
23786 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
23787 </dl>
23788 !! end
23789
23790 # html2wt mode disabled due to <nowiki> insertion.
23791 !! test
23792 T153140: Don't break table handling if language converter markup is in the cell.
23793 !! options
23794 language=sr variant=sr-ec
23795 parsoid=wt2html,wt2wt,html2html
23796 !! wikitext
23797 {|
23798 |-
23799 | -{R|B}-
23800 |}
23801 !! html/php
23802 <table>
23803
23804 <tr>
23805 <td>B
23806 </td></tr></table>
23807
23808 !! html/parsoid
23809 <table>
23810 <tbody>
23811 <tr>
23812 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
23813 </tr>
23814 </tbody>
23815 </table>
23816 !! end
23817
23818 !! test
23819 Language converter tricky html2wt cases (1)
23820 !! options
23821 language=sr
23822 parsoid=html2wt,wt2wt
23823 !! html/parsoid
23824 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
23825 !! wikitext
23826 -{<nowiki>}-</nowiki>}-
23827 !! html/php
23828 <p>&#125;-
23829 </p>
23830 !! end
23831
23832 !! test
23833 Language converter tricky html2wt cases (2)
23834 !! options
23835 language=sr
23836 parsoid=html2wt,wt2wt
23837 !! html/parsoid
23838 <p>-{foo}-</p>
23839 !! wikitext
23840 <nowiki>-{foo}-</nowiki>
23841 !! html/php
23842 <p>-&#123;foo&#125;-
23843 </p>
23844 !! end
23845
23846 !! test
23847 Language converter tricky html2wt cases (3)
23848 !! options
23849 language=sr
23850 parsoid=html2wt,wt2wt
23851 !! html/parsoid
23852 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
23853 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
23854 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
23855 !! wikitext
23856 -{R||}-
23857
23858 -{R|R|raw}-
23859
23860 -{<nowiki>-{foo}-</nowiki>}-
23861 !! html/php
23862 <p>|
23863 </p><p>R|raw
23864 </p><p>-&#123;foo&#125;-
23865 </p>
23866 !! end
23867
23868 !! test
23869 Language converter tricky html2wt cases (4)
23870 !! options
23871 language=sr
23872 parsoid=html2wt,wt2wt
23873 !! html/parsoid
23874 <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>
23875 !! wikitext
23876 -{R|{{echo|hey}}}-
23877 !! html/php
23878 <p>hey
23879 </p>
23880 !! end
23881
23882 # Note that the <nowiki> escaping added by parsoid for source text,
23883 # destination text, and language names only works on the PHP side
23884 # for *destination text*. (HTML entity escaping wouldn't work
23885 # any better.) This is probably a bug, at least for source texts.
23886 # (For language names PHP uses a precise regexp based on the languages
23887 # it currently knows have variants, which is fragile since this set
23888 # can grow/shrink over time.)
23889 !! test
23890 Language converter tricky html2wt cases (5)
23891 !! options
23892 language=zh variant=zh-cn
23893 !! html/parsoid
23894 <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>
23895 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
23896 <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>
23897 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
23898 <p>a:b=>c xyz</p>
23899 !! wikitext
23900 -{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
23901
23902 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
23903
23904 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
23905
23906 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
23907
23908 a:b=>c xyz
23909 !! html/php+disabled
23910 <p>foobat;xyz=&gt;zh-cn:abc
23911 </p><p>A
23912 </p><p>0;zh-tw:bar
23913 </p><p>abc
23914 </p><p>a:b=&gt;c 0;zh-tw:bar
23915 </p>
23916 !! end
23917
23918 !! test
23919 T179579: Nowiki and lc interaction
23920 !! options
23921 parsoid=wt2html
23922 language=sr
23923 !! wikitext
23924 -{</nowiki>123}-
23925
23926 -{123<nowiki>|</nowiki>456}-
23927 !! html/parsoid
23928 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
23929
23930 <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>
23931 !! end
23932
23933 !! test
23934 T2529: Uncovered bullet
23935 !! wikitext
23936 *Foo {{bullet}}
23937 !! html
23938 <ul><li>Foo</li>
23939 <li>Bar</li></ul>
23940
23941 !! end
23942
23943 !! test
23944 T2529: Uncovered bullet in a deeply nested list
23945 !! wikitext
23946 *******Foo {{bullet}}
23947 !! html
23948 <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>
23949 <li>Bar</li></ul>
23950
23951 !! end
23952
23953 !! test
23954 T2529: Uncovered table already at line-start
23955 !! wikitext
23956 x
23957
23958 {{table}}
23959 y
23960 !! html
23961 <p>x
23962 </p>
23963 <table>
23964 <tr>
23965 <td>1</td>
23966 <td>2
23967 </td></tr>
23968 <tr>
23969 <td>3</td>
23970 <td>4
23971 </td></tr></table>
23972 <p>y
23973 </p>
23974 !! end
23975
23976 !! test
23977 T2529: Uncovered bullet in parser function result
23978 !! wikitext
23979 *Foo {{lc:{{bullet}} }}
23980 !! html
23981 <ul><li>Foo</li>
23982 <li>bar</li></ul>
23983
23984 !! end
23985
23986 !! test
23987 T7678: Double-parsed template argument
23988 !! wikitext
23989 {{lc:{{{1}}}|hello}}
23990 !! html
23991 <p>{{{1}}}
23992 </p>
23993 !! end
23994
23995 !! test
23996 T7678: Double-parsed template invocation
23997 !! wikitext
23998 {{lc:{{paramtest {{!}} param = hello }} }}
23999 !! html
24000 <p>{{paramtest | param = hello }}
24001 </p>
24002 !! end
24003
24004 !! test
24005 Case insensitivity of parser functions for non-ASCII characters (T10143)
24006 !! options
24007 language=cs
24008 title=[[Main Page]]
24009 !! wikitext
24010 {{PRVNÍVELKÉ:ěščř}}
24011 {{prvnívelké:ěščř}}
24012 {{PRVNÍMALÉ:ěščř}}
24013 {{prvnímalé:ěščř}}
24014 {{MALÁ:ěščř}}
24015 {{malá:ěščř}}
24016 {{VELKÁ:ěščř}}
24017 {{velká:ěščř}}
24018 !! html
24019 <p>Ěščř
24020 Ěščř
24021 ěščř
24022 ěščř
24023 ěščř
24024 ěščř
24025 ĚŠČŘ
24026 ĚŠČŘ
24027 </p>
24028 !! end
24029
24030 !! test
24031 Morwen/13: Unclosed link followed by heading
24032 !! wikitext
24033 [[link
24034 ==heading==
24035 !! html
24036 <p>[[link
24037 </p>
24038 <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>
24039
24040 !! end
24041
24042 !! test
24043 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
24044 !! wikitext
24045 {{foo|
24046 =heading=
24047 !! html
24048 <p>{{foo|
24049 </p>
24050 <h1><span class="mw-headline" id="heading">heading</span></h1>
24051
24052 !! end
24053
24054 !! test
24055 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
24056 !! wikitext
24057 {{foo|
24058 ==heading==
24059 !! html
24060 <p>{{foo|
24061 </p>
24062 <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>
24063
24064 !! end
24065
24066 !! test
24067 Tildes in comments
24068 !! options
24069 pst
24070 !! wikitext
24071 <!-- ~~~~ -->
24072 !! html/php
24073 <!-- ~~~~ -->
24074 !! end
24075
24076 !! test
24077 Paragraphs inside divs (no extra line breaks)
24078 !! wikitext
24079 <div>Line one
24080
24081 Line two</div>
24082 !! html
24083 <div>Line one
24084 Line two</div>
24085
24086 !! end
24087
24088 !! test
24089 Paragraphs inside divs (extra line break on open)
24090 !! wikitext
24091 <div>
24092 Line one
24093
24094 Line two</div>
24095 !! html
24096 <div>
24097 <p>Line one
24098 </p>
24099 Line two</div>
24100
24101 !! end
24102
24103 !! test
24104 Paragraphs inside divs (extra line break on close)
24105 !! wikitext
24106 <div>Line one
24107
24108 Line two
24109 </div>
24110 !! html
24111 <div>Line one
24112 <p>Line two
24113 </p>
24114 </div>
24115
24116 !! end
24117
24118 !! test
24119 Paragraphs inside divs (extra line break on open and close)
24120 !! wikitext
24121 <div>
24122 Line one
24123
24124 Line two
24125 </div>
24126 !! html
24127 <div>
24128 <p>Line one
24129 </p><p>Line two
24130 </p>
24131 </div>
24132
24133 !! end
24134
24135 # doBlockLevels screws up this output and Remex cleans up as much as it can.
24136 !! test
24137 Nesting tags, paragraphs on lines which begin with <div>
24138 !! wikitext
24139 <div></div><strong>A
24140 B</strong>
24141 !! html/php+tidy
24142 <div></div><p><strong>A
24143 </strong></p><strong></strong><p><strong>B</strong>
24144 </p>
24145 !! html/parsoid
24146 <div data-parsoid='{"stx":"html"}'></div><p><strong data-parsoid='{"stx":"html","autoInsertedEnd":true}'>A</strong></p>
24147 <p><strong data-parsoid='{"stx":"html","autoInsertedStart":true}'>B</strong></p>
24148 !! end
24149
24150 # T8200: <blockquote> should behave like <div> with respect to line breaks
24151 !! test
24152 T8200: paragraphs inside blockquotes (no extra line breaks)
24153 !! wikitext
24154 <blockquote>Line one
24155
24156 Line two</blockquote>
24157 !! html
24158 <blockquote>Line one
24159 Line two</blockquote>
24160
24161 !! html+tidy
24162 <blockquote><p>Line one
24163 Line two</p></blockquote>
24164 !! end
24165
24166 !! test
24167 T8200: paragraphs inside blockquotes (extra line break on open)
24168 !! wikitext
24169 <blockquote>
24170 Line one
24171
24172 Line two</blockquote>
24173 !! html
24174 <blockquote>
24175 <p>Line one
24176 </p>
24177 Line two</blockquote>
24178
24179 !! html+tidy
24180 <blockquote>
24181 <p>Line one
24182 </p><p>
24183 Line two</p></blockquote>
24184 !! end
24185
24186 !! test
24187 T8200: paragraphs inside blockquotes (extra line break on close)
24188 !! wikitext
24189 <blockquote>Line one
24190
24191 Line two
24192 </blockquote>
24193 !! html
24194 <blockquote>Line one
24195 <p>Line two
24196 </p>
24197 </blockquote>
24198
24199 !! html+tidy
24200 <blockquote><p>Line one
24201 </p><p>Line two
24202 </p>
24203 </blockquote>
24204 !! end
24205
24206 !! test
24207 T8200: paragraphs inside blockquotes (extra line break on open and close)
24208 !! wikitext
24209 <blockquote>
24210 Line one
24211
24212 Line two
24213 </blockquote>
24214 !! html
24215 <blockquote>
24216 <p>Line one
24217 </p><p>Line two
24218 </p>
24219 </blockquote>
24220
24221 !! end
24222
24223 ## This is a corner case interaction between the paragraph wrapping in the
24224 ## php parser's BlockLevelPass and Remex. `doBlockLevels` has a notion of
24225 ## some tags which close paragraphs (and thus prevent wrapping on their line),
24226 ## of which "div" is one, but do p-wrapping inside them. These are referred
24227 ## to as "never suppressing". Remex, for its part, doesn't traverse into
24228 ## "div"s to p-wrap. Hence, we only get this partial wrapping.
24229 !! test
24230 Paragraphs inside blockquotes/divs (no extra line breaks)
24231 !! wikitext
24232 <blockquote><div>Line one
24233
24234 Line two</div></blockquote>
24235 !! html
24236 <blockquote><div>Line one
24237 Line two</div></blockquote>
24238
24239 !! end
24240
24241 !! test
24242 Paragraphs inside blockquotes/divs (extra line break on open)
24243 !! wikitext
24244 <blockquote><div>
24245 Line one
24246
24247 Line two</div></blockquote>
24248 !! html
24249 <blockquote><div>
24250 <p>Line one
24251 </p>
24252 Line two</div></blockquote>
24253
24254 !! end
24255
24256 !! test
24257 Paragraphs inside blockquotes/divs (extra line break on close)
24258 !! wikitext
24259 <blockquote><div>Line one
24260
24261 Line two
24262 </div></blockquote>
24263 !! html
24264 <blockquote><div>Line one
24265 <p>Line two
24266 </p>
24267 </div></blockquote>
24268
24269 !! end
24270
24271 !! test
24272 Paragraphs inside blockquotes/divs (extra line break on open and close)
24273 !! wikitext
24274 <blockquote><div>
24275 Line one
24276
24277 Line two
24278 </div></blockquote>
24279 !! html
24280 <blockquote><div>
24281 <p>Line one
24282 </p><p>Line two
24283 </p>
24284 </div></blockquote>
24285
24286 !! end
24287
24288 !! test
24289 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
24290 !! options
24291 wgLinkHolderBatchSize=0
24292 !! wikitext
24293 [[meatball:1]]
24294 [[meatball:2]]
24295 [[meatball:3]]
24296 !! html
24297 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
24298 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
24299 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
24300 </p>
24301 !! end
24302
24303 !! test
24304 Free external link invading image caption
24305 !! wikitext
24306 [[Image:Foobar.jpg|thumb|http://x|hello]]
24307 !! html/php
24308 <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>
24309
24310 !! html/parsoid
24311 <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>
24312 !! end
24313
24314 !! test
24315 T17196: localised external link numbers
24316 !! options
24317 language=fa
24318 !! wikitext
24319 [http://en.wikipedia.org/]
24320 !! html/php
24321 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
24322 </p>
24323 !! html/parsoid
24324 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/"></a></p>
24325 !! end
24326
24327 !! test
24328 Multibyte character in padleft
24329 !! wikitext
24330 {{padleft:-Hello|7|Æ}}
24331 !! html/php
24332 <p>Æ-Hello
24333 </p>
24334 !! html/parsoid
24335 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:-Hello","function":"padleft"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Æ-Hello</p>
24336 !! end
24337
24338 !! test
24339 Multibyte character in padright
24340 !! wikitext
24341 {{padright:Hello-|7|Æ}}
24342 !! html/php
24343 <p>Hello-Æ
24344 </p>
24345 !! html/parsoid
24346 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:Hello-","function":"padright"},"params":{"1":{"wt":"7"},"2":{"wt":"Æ"}},"i":0}}]}'>Hello-Æ</p>
24347 !! end
24348
24349 !!test
24350 formatdate parser function
24351 !! wikitext
24352 {{#formatdate:2009-03-24}}
24353 !! html
24354 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
24355 </p>
24356 !! end
24357
24358 !!test
24359 formatdate parser function, with default format
24360 !! wikitext
24361 {{#formatdate:2009-03-24|mdy}}
24362 !! html
24363 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
24364 </p>
24365 !! end
24366
24367 !! test
24368 Spacing of numbers in formatted dates
24369 !! wikitext
24370 {{#formatdate:January 15}}
24371 !! html
24372 <p><span class="mw-formatted-date" title="01-15">January 15</span>
24373 </p>
24374 !! end
24375
24376 !! test
24377 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
24378 !! options
24379 language=nl title=[[MediaWiki:Common.css]]
24380 !! wikitext
24381 {{#formatdate:2009-03-24|dmy}}
24382 !! html
24383 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
24384 </p>
24385 !! end
24386
24387 #
24388 #
24389 #
24390
24391 #
24392 # Edit comments
24393 #
24394
24395 !! test
24396 Edit comment with link
24397 !! options
24398 comment
24399 !! wikitext
24400 I like the [[Main Page]] a lot
24401 !! html/php
24402 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
24403 !!end
24404
24405 !! test
24406 Edit comment with link and link text
24407 !! options
24408 comment
24409 !! wikitext
24410 I like the [[Main Page|best pages]] a lot
24411 !! html/php
24412 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24413 !!end
24414
24415 !! test
24416 Edit comment with link and link text with suffix
24417 !! options
24418 comment
24419 !! wikitext
24420 I like the [[Main Page|best page]]s a lot
24421 !! html/php
24422 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
24423 !!end
24424
24425 !! test
24426 Edit comment with section link (non-local, eg in history list)
24427 !! options
24428 comment title=[[Main Page]]
24429 !! wikitext
24430 /* External links */ removed bogus entries
24431 !! html/php
24432 <a href="/wiki/Main_Page#External_links" title="Main Page">→External links</a>‎<span dir="auto"><span class="autocomment">: </span> removed bogus entries</span>
24433 !!end
24434
24435 !! test
24436 Edit comment with section link and text before it (non-local, eg in history list)
24437 !! options
24438 comment title=[[Main Page]]
24439 !! wikitext
24440 pre-comment text /* External links */ removed bogus entries
24441 !! html/php
24442 pre-comment text <a href="/wiki/Main_Page#External_links" title="Main Page">→External links</a>‎<span dir="auto"><span class="autocomment">: </span> removed bogus entries</span>
24443 !!end
24444
24445 !! test
24446 Edit comment with section link (local, eg in diff view)
24447 !! options
24448 comment local title=[[Main Page]]
24449 !! wikitext
24450 /* External links */ removed bogus entries
24451 !! html/php
24452 <a href="#External_links">→External links</a>‎<span dir="auto"><span class="autocomment">: </span> removed bogus entries</span>
24453 !!end
24454
24455 !! test
24456 Edit comment with subpage link (T16080)
24457 !! options
24458 comment
24459 subpage
24460 title=[[Subpage test]]
24461 !! wikitext
24462 Poked at a [[/subpage]] here...
24463 !! html/php
24464 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
24465 !!end
24466
24467 !! test
24468 Edit comment with subpage link and link text (T16080)
24469 !! options
24470 comment
24471 subpage
24472 title=[[Subpage test]]
24473 !! wikitext
24474 Poked at a [[/subpage|neat little page]] here...
24475 !! html/php
24476 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
24477 !!end
24478
24479 !! test
24480 Edit comment with bogus subpage link in non-subpage NS (T16080)
24481 !! options
24482 comment
24483 title=[[Subpage test]]
24484 !! wikitext
24485 Poked at a [[/subpage]] here...
24486 !! html/php
24487 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...
24488 !!end
24489
24490 !! test
24491 Edit comment with bare anchor link (local, as on diff)
24492 !! options
24493 comment
24494 local
24495 title=[[Main Page]]
24496 !! wikitext
24497 [[#section]]
24498 !! html/php
24499 <a href="#section">#section</a>
24500 !! end
24501
24502 !! test
24503 Edit comment with bare anchor link (non-local, as on history)
24504 !! options
24505 comment
24506 title=[[Main Page]]
24507 !! wikitext
24508 [[#section]]
24509 !! html/php
24510 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
24511 !! end
24512
24513 !! test
24514 Anchor starting with underscore
24515 !! options
24516 title=[[Foo]]
24517 !! wikitext
24518 [[#_ref|One]]
24519 !! html/php
24520 <p><a href="#_ref">One</a>
24521 </p>
24522 !! html/parsoid
24523 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
24524 !! end
24525
24526 !! test
24527 Id starting with underscore
24528 !! wikitext
24529 <div id="_ref"></div>
24530 !! html/*
24531 <div id="_ref"></div>
24532
24533 !! end
24534
24535 !! test
24536 Edit comment with link with more than one pipe (T99346)
24537 !! options
24538 comment
24539 !! wikitext
24540 [[Main Page|Many|pipes]]
24541 !! html/php
24542 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
24543 !! end
24544
24545 !! test
24546 Complex edit comment with link with more than one pipe (T99346)
24547 !! options
24548 comment
24549 !! wikitext
24550 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
24551 !! html/php
24552 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;
24553 !! end
24554
24555 !! test
24556 Space normalisation on autocomment (T24784)
24557 !! options
24558 comment
24559 title=[[Main Page]]
24560 !! wikitext
24561 /* __hello__world__ */
24562 !! html/php
24563 <a href="/wiki/Main_Page#hello_world" title="Main Page">→__hello__world__</a>‎
24564 !! end
24565
24566 !! test
24567 percent-encoding and + signs in comments (T28410)
24568 !! options
24569 comment
24570 !! wikitext
24571 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
24572 !! html/php
24573 <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>
24574 !! end
24575
24576 # Parsoid doesn't support this yet: see T75581
24577 # but it *should* omit the 'src' attribute if the image is bad.
24578 # PHP side of tests was disabled in
24579 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
24580 # because of issues in the PHP parserTests infrastructure
24581 # (but the output below is indeed what the PHP side emits)
24582 !! test
24583 Bad images - basic functionality
24584 !! wikitext
24585 [[File:Bad.jpg]]
24586 !! html/php+disabled
24587 !! html/parsoid
24588 <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>
24589 !! end
24590
24591 !! test
24592 Bad images - T18039: text after bad image disappears
24593 !! wikitext
24594 Foo bar
24595 [[File:Bad.jpg]]
24596 Bar foo
24597 !! html/php+disabled
24598 <p>Foo bar
24599 </p><p>Bar foo
24600 </p>
24601 !! html/parsoid
24602 <p>Foo bar
24603 <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>
24604 Bar foo</p>
24605 !! end
24606
24607 !! test
24608 Verify that displaytitle works (T24501) no displaytitle
24609 !! options
24610 showtitle
24611 !! config
24612 wgAllowDisplayTitle=true
24613 wgRestrictDisplayTitle=false
24614 !! wikitext
24615 this is not the the title
24616 !! html/php
24617 Parser test
24618 <p>this is not the the title
24619 </p>
24620 !! end
24621
24622 !! test
24623 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
24624 !! options
24625 showtitle
24626 title=[[Screen]]
24627 !! config
24628 wgAllowDisplayTitle=true
24629 wgRestrictDisplayTitle=false
24630 !! wikitext
24631 this is not the the title
24632 {{DISPLAYTITLE:whatever}}
24633 !! html/php
24634 whatever
24635 <p>this is not the the title
24636 </p>
24637 !! end
24638
24639 !! test
24640 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
24641 !! options
24642 showtitle
24643 title=[[Screen]]
24644 !! config
24645 wgAllowDisplayTitle=true
24646 wgRestrictDisplayTitle=true
24647 !! wikitext
24648 this is not the the title
24649 {{DISPLAYTITLE:whatever}}
24650 !! html/php
24651 Screen
24652 <p>this is not the the title
24653 </p>
24654 !! end
24655
24656 !! test
24657 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
24658 !! options
24659 showtitle
24660 title=[[Screen]]
24661 !! config
24662 wgAllowDisplayTitle=true
24663 wgRestrictDisplayTitle=true
24664 !! wikitext
24665 this is not the the title
24666 {{DISPLAYTITLE:screen}}
24667 !! html/php
24668 screen
24669 <p>this is not the the title
24670 </p>
24671 !! end
24672
24673 !! test
24674 Verify that displaytitle works (T24501) AllowDisplayTitle=false
24675 !! options
24676 showtitle
24677 title=[[Screen]]
24678 !! config
24679 wgAllowDisplayTitle=false
24680 !! wikitext
24681 this is not the the title
24682 {{DISPLAYTITLE:screen}}
24683 !! html/php
24684 Screen
24685 <p>this is not the the title
24686 <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>
24687 </p>
24688 !! end
24689
24690 !! test
24691 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
24692 !! options
24693 showtitle
24694 title=[[Screen]]
24695 !! config
24696 wgAllowDisplayTitle=false
24697 !! wikitext
24698 this is not the the title
24699 !! html/php
24700 Screen
24701 <p>this is not the the title
24702 </p>
24703 !! end
24704
24705 !! test
24706 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
24707 !! options
24708 showtitle
24709 title=[[Screen]]
24710 !! config
24711 wgAllowDisplayTitle=true
24712 wgRestrictDisplayTitle=true
24713 !! wikitext
24714 this is not the the title
24715 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
24716 !! html/php
24717 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
24718 <p>this is not the the title
24719 </p>
24720 !! end
24721
24722 !! test
24723 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
24724 !! options
24725 showtitle
24726 title=[[Screen]]
24727 !! config
24728 wgAllowDisplayTitle=true
24729 wgRestrictDisplayTitle=true
24730 !! wikitext
24731 this is not the the title
24732 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
24733 !! html/php
24734 <span style="color: red;">s</span>creen
24735 <p>this is not the the title
24736 </p>
24737 !! end
24738
24739 !! test
24740 Page status indicators: Empty name is invalid
24741 !! options
24742 showindicators
24743 !! wikitext
24744 <indicator name=" "></indicator>
24745 <indicator></indicator>
24746 !! html/php
24747 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24748 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
24749 </p>
24750 !! end
24751
24752 !! test
24753 Page status indicators: Weird syntaxes that are okay
24754 !! options
24755 showindicators
24756 !! wikitext
24757 <indicator name="empty" />
24758 <indicator name="name"></indicator>
24759 !! html/php
24760 empty=
24761 name=
24762 <p><br />
24763 </p>
24764 !! end
24765
24766 !! test
24767 Page status indicators: Torture test
24768 !! options
24769 showindicators
24770 !! wikitext
24771 <indicator name="01">hello world</indicator>
24772 <indicator name="02">[[Main Page]]</indicator>
24773 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
24774 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
24775 <indicator name="05">*foo
24776 *bar</indicator>
24777 <indicator name="06"><nowiki>foo</nowiki></indicator>
24778 <indicator name="07"> Preformatted</indicator>
24779 <indicator name="08"><div>Broken tag</indicator>
24780 <indicator name="09">{| class=wikitable
24781 |cell
24782 |}</indicator>
24783 <indicator name="10">Two
24784
24785 paragraphs</indicator>
24786 !! html/php
24787 01=hello world
24788 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
24789 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" />
24790 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>
24791 05=<ul><li>foo</li>
24792 <li>bar</li></ul>
24793
24794 06=foo
24795 07=<pre>Preformatted
24796 </pre>
24797 08=<div>Broken tag</div>
24798
24799 09=<table class="wikitable">
24800 <tr>
24801 <td>cell
24802 </td></tr></table>
24803
24804 10=<p>Two
24805 </p><p>paragraphs
24806 </p>
24807 <p><br />
24808 </p><p><br />
24809 </p><p><br />
24810 </p><p><br />
24811 </p><p><br />
24812 </p>
24813 !! end
24814
24815 !! test
24816 preload: check <noinclude> and <includeonly>
24817 !! options
24818 preload
24819 !! wikitext
24820 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
24821 !! html/php
24822 Hello kind world.
24823 !! end
24824
24825 !! test
24826 preload: check <onlyinclude>
24827 !! options
24828 preload
24829 !! wikitext
24830 Goodbye <onlyinclude>Hello world</onlyinclude>
24831 !! html/php
24832 Hello world
24833 !! end
24834
24835 !! test
24836 preload: can pass tags through if we want to
24837 !! options
24838 preload
24839 !! wikitext
24840 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
24841 !! html/php
24842 <includeonly>Hello world</includeonly>
24843 !! end
24844
24845 !! test
24846 preload: check that it doesn't try to do tricks
24847 !! options
24848 preload
24849 !! wikitext
24850 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24851 !! html/php
24852 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24853 !! end
24854
24855 !! test
24856 Play a bit with r67090 and T5158
24857 !! wikitext
24858 <div style="width:50% !important">&nbsp;</div>
24859 <div style="width:50%&nbsp;!important">&nbsp;</div>
24860 <div style="width:50%&#160;!important">&nbsp;</div>
24861 <div style="border : solid;">&nbsp;</div>
24862 !! html/php
24863 <div style="width:50% !important">&#160;</div>
24864 <div style="width:50% !important">&#160;</div>
24865 <div style="width:50% !important">&#160;</div>
24866 <div style="border&#32;: solid;">&#160;</div>
24867
24868 !! html/parsoid
24869 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24870 <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>
24871 <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>
24872 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24873
24874 !! end
24875
24876 !! test
24877 French spaces in wikitext
24878 !! wikitext
24879 foo ! bar ? bat 50 % is less than 75 %.
24880
24881 Hello : this ; is « something ‹ else › again »
24882 !! html
24883 <p>foo&#160;! bar&#160;? bat 50&#160;% is less than 75&#160;%.
24884 </p><p>Hello&#160;: this&#160;; is «&#160;something ‹&#160;else&#160;› again&#160;»
24885 </p>
24886 !! end
24887
24888 # It would be reasonable for Parsoid and PHP to differ here.
24889 # The PHP behavior is arguably a bug.
24890 !! test
24891 Corner case: french spaces in definition list
24892 !! wikitext
24893 ;foo : bar
24894 !! html+tidy
24895 <dl><dt>foo&#160;</dt>
24896 <dd>bar</dd></dl>
24897 !! end
24898
24899 !! test
24900 T5158: Test for French spaces in attributes
24901 !! wikitext
24902 <br style=" clear : both ; " />
24903 !! html/php
24904 <p><br style="clear&#32;: both&#32;;" />
24905 </p>
24906 !! end
24907
24908 !! test
24909 HTML5 data attributes
24910 !! wikitext
24911 <span data-foo="bar">Baz</span>
24912 <p data-abc-def_hij="">Quuz</p>
24913 !! html/php
24914 <p><span data-foo="bar">Baz</span>
24915 </p>
24916 <p data-abc-def_hij="">Quuz</p>
24917
24918 !! html/parsoid
24919 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
24920 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
24921 !! end
24922
24923 !! test
24924 Strip reserved data attributes
24925 !! wikitext
24926 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
24927 !! html/php
24928 <div data-ok="fred">d</div>
24929
24930 !! html/parsoid
24931 <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>
24932 !! end
24933
24934 !! test
24935 percent-encoding and + signs in internal links (T28410)
24936 !! wikitext
24937 [[User:+%]] [[Page+title%]]
24938 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
24939 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
24940 [[%33%45]] [[%33%45+]]
24941 !! html/php
24942 <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>
24943 <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>
24944 <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>
24945 <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>
24946 </p>
24947 !! html/parsoid
24948 <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>
24949 <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>
24950 <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>
24951 <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>
24952 !! end
24953
24954 !! test
24955 Special characters in embedded file links (T29679)
24956 !! wikitext
24957 [[File:Contains & ampersand.jpg]]
24958 [[File:Does not exist.jpg|Title with & ampersand]]
24959 !! html/php
24960 <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>
24961 <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>
24962 </p>
24963 !! html/parsoid
24964 <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>
24965 <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>
24966 !! end
24967
24968 !! test
24969 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
24970 !! wikitext
24971 Text&apos;s been normalized?
24972 !! html
24973 <p>Text&#39;s been normalized?
24974 </p>
24975 !! end
24976
24977 !! test
24978 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
24979 !! wikitext
24980 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
24981 !! html
24982 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
24983 </p>
24984 !! end
24985
24986 !! test
24987 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
24988 !! wikitext
24989 [http://www.example.org/ ideograms]
24990 !! html
24991 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
24992 </p>
24993 !! end
24994
24995 !! test
24996 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
24997 !! wikitext
24998 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
24999 !! html
25000 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
25001 </p>
25002 !! end
25003
25004 !! article
25005 Mediawiki:loop1
25006 !! text
25007 {{Identical|A}}
25008 !! endarticle
25009
25010 !! article
25011 Mediawiki:loop2
25012 !! text
25013 {{Identical|B}}
25014 !! endarticle
25015
25016 !! article
25017 Template:Identical
25018 !! text
25019 {{int:loop1}}
25020 {{int:loop2}}
25021 !! endarticle
25022
25023 !! test
25024 T33098 Template which includes system messages which includes the template
25025 !! wikitext
25026 {{Identical}}
25027 !! html
25028 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25029 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
25030 </p>
25031 !! end
25032
25033 !! test
25034 T33490 Turkish: ucfirst 'blah'
25035 !! options
25036 language=tr
25037 !! wikitext
25038 {{ucfirst:blah}}
25039 !! html
25040 <p>Blah
25041 </p>
25042 !! end
25043
25044 !! test
25045 T33490 Turkish: ucfirst 'ix'
25046 !! options
25047 language=tr
25048 !! wikitext
25049 {{ucfirst:ix}}
25050 !! html
25051 <p>İx
25052 </p>
25053 !! end
25054
25055 !! test
25056 T33490 Turkish: lcfirst 'BLAH'
25057 !! options
25058 language=tr
25059 !! wikitext
25060 {{lcfirst:BLAH}}
25061 !! html
25062 <p>bLAH
25063 </p>
25064 !! end
25065
25066 !! test
25067 T33490 Turkish: ucfırst (with a dotless i)
25068 !! options
25069 language=tr
25070 !! wikitext
25071 {{ucfırst:blah}}
25072 !! html
25073 <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>
25074 </p>
25075 !! end
25076
25077 !! test
25078 T33490 ucfırst (with a dotless i) with English language
25079 !! options
25080 language=en
25081 !! wikitext
25082 {{ucfırst:blah}}
25083 !! html
25084 <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>
25085 </p>
25086 !! end
25087
25088 # Note that Parsoid doesn't emit an explicit TOC.
25089 # Note also that the html2wt direction tends to emit an extra newline
25090 # between the __TOC__ magicword and the first heading unless *both*
25091 # the <meta> and the <h2> have a data-parsoid attribute set (even if
25092 # it's "{}").
25093
25094 !! test
25095 T28375: TOC with italics
25096 !! options
25097 title=[[Main Page]]
25098 !! wikitext
25099 __TOC__
25100 ==''Lost'' episodes==
25101 !! html/php
25102 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25103 <ul>
25104 <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>
25105 </ul>
25106 </div>
25107
25108 <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>
25109
25110 !! html/parsoid
25111 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25112 <h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2>
25113 !! end
25114
25115 !! test
25116 T28375: TOC with bold
25117 !! options
25118 title=[[Main Page]]
25119 !! wikitext
25120 __TOC__
25121 =='''should be bold''' then normal text==
25122 !! html/php
25123 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25124 <ul>
25125 <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>
25126 </ul>
25127 </div>
25128
25129 <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>
25130
25131 !! html/parsoid
25132 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25133 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2>
25134 !! end
25135
25136 !! test
25137 T35845: Headings become cursive in TOC when they contain an image
25138 !! options
25139 title=[[Main Page]]
25140 !! wikitext
25141 __TOC__
25142 ==Image [[Image:foobar.jpg]]==
25143 !! html/php
25144 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25145 <ul>
25146 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
25147 </ul>
25148 </div>
25149
25150 <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>
25151
25152 !! html/parsoid
25153 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25154 <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>
25155 !! end
25156
25157 !! test
25158 T35845 (2): Headings become bold in TOC when they contain a blockquote
25159 !! options
25160 title=[[Main Page]]
25161 !! wikitext
25162 __TOC__
25163 ==<blockquote>Quote</blockquote>==
25164 !! html/php
25165 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25166 <ul>
25167 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25168 </ul>
25169 </div>
25170
25171 <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>
25172
25173 !! html/php+tidy
25174 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25175 <ul>
25176 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
25177 </ul>
25178 </div>
25179
25180 <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>
25181 !! html/parsoid
25182 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25183 <h2 id="Quote" data-parsoid='{}'><blockquote><p>Quote</p></blockquote></h2>
25184 !! end
25185
25186 !! test
25187 Unclosed tags in TOC
25188 !! config
25189 wgFragmentMode=[ 'html5', 'legacy' ]
25190 !! options
25191 title=[[Main Page]]
25192 !! wikitext
25193 __TOC__
25194 ==Proof: 2 < 3==
25195 <small>Hanc marginis exiguitas non caperet.</small>
25196 QED
25197 !! html/php
25198 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25199 <ul>
25200 <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>
25201 </ul>
25202 </div>
25203
25204 <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>
25205 <p><small>Hanc marginis exiguitas non caperet.</small>
25206 QED
25207 </p>
25208 !! html/parsoid
25209 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25210 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 &lt; 3</h2>
25211 <p><small>Hanc marginis exiguitas non caperet.</small>
25212 QED</p>
25213 !! end
25214
25215 !! test
25216 Multiple tags in TOC
25217 !! wikitext
25218 __TOC__
25219 ==<i>Foo</i> <b>Bar</b>==
25220
25221 ==<i>Foo</i> <blockquote>Bar</blockquote>==
25222 !! html/php
25223 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25224 <ul>
25225 <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>
25226 <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>
25227 </ul>
25228 </div>
25229
25230 <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>
25231 <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>
25232
25233 !! html/php+tidy
25234 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25235 <ul>
25236 <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>
25237 <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>
25238 </ul>
25239 </div>
25240
25241 <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>
25242 <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>
25243 !! html/parsoid
25244 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25245 <h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2>
25246
25247 <h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote><p>Bar</p></blockquote></h2>
25248 !! end
25249
25250 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
25251 # html5 tag parsing.
25252 !! test
25253 Tags with parameters in TOC
25254 !! options
25255 parsoid=wt2html
25256 !! wikitext
25257 __TOC__
25258 ==<sup class="in-h2">Hello</sup>==
25259
25260 ==<sup class="a > b">Evilbye</sup>==
25261 !! html/php
25262 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25263 <ul>
25264 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
25265 <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>
25266 </ul>
25267 </div>
25268
25269 <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>
25270 <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>
25271
25272 !! html/parsoid
25273 <meta property="mw:PageProp/toc" />
25274 <h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2>
25275
25276 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2>
25277 !! end
25278
25279 !! test
25280 span tags with directionality in TOC
25281 !! wikitext
25282 __TOC__
25283 ==<span dir="ltr">C++</span>==
25284
25285 ==<span dir="rtl">זבנג!</span>==
25286
25287 ==<span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span>==
25288
25289 ==<span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span>==
25290
25291 ==<span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span>==
25292 !! html/php
25293 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25294 <ul>
25295 <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>
25296 <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>
25297 <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>
25298 <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>
25299 <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>
25300 </ul>
25301 </div>
25302
25303 <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>
25304 <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>
25305 <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>
25306 <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>
25307 <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>
25308
25309 !! html/parsoid
25310 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25311 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2>
25312 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2>
25313 <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>
25314 <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>
25315 <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>
25316 !! end
25317
25318 !! test
25319 T74884: bdi element in ToC
25320 !! wikitext
25321 __TOC__
25322 ==<bdi>test</bdi>==
25323 !! html/php
25324 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25325 <ul>
25326 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
25327 </ul>
25328 </div>
25329
25330 <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>
25331
25332 !! html/parsoid
25333 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25334 <h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2>
25335 !! end
25336
25337 !! test
25338 T35715: s/strike element in ToC
25339 !! wikitext
25340 __TOC__
25341 ==<s>test</s> test <strike>test</strike>==
25342 !! html/php
25343 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25344 <ul>
25345 <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>
25346 </ul>
25347 </div>
25348
25349 <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>
25350
25351 !! html/parsoid
25352 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25353 <h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2>
25354 !! end
25355
25356 !! test
25357 T198618: style element in ToC
25358 !! options
25359 styletag=1
25360 !! wikitext
25361 __TOC__
25362 ==<style>.foo {}</style>Style<style>.bar {}</style>==
25363 !! html/php
25364 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25365 <ul>
25366 <li class="toclevel-1 tocsection-1"><a href="#Style"><span class="tocnumber">1</span> <span class="toctext">Style</span></a></li>
25367 </ul>
25368 </div>
25369
25370 <h2><span class="mw-headline" id="Style"><style>.foo {}</style>Style<style>.bar {}</style></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Style">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
25371
25372 !! html/parsoid
25373 <meta property="mw:PageProp/toc" data-parsoid="{}"/>
25374 <h2 id="Style" data-parsoid="{}"><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo {}"}}'>.foo {}</style>Style<style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".bar {}"}}'>.bar {}</style></h2>
25375 !! end
25376
25377 !! test
25378 T198618: script element in ToC
25379 !! options
25380 wgRawHtml=1
25381 !! wikitext
25382 __TOC__
25383 ==<html><script>alert(1);</script></html>Script<html><script>alert(1);</script></html>==
25384 !! html/php
25385 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25386 <ul>
25387 <li class="toclevel-1 tocsection-1"><a href="#Script"><span class="tocnumber">1</span> <span class="toctext">Script</span></a></li>
25388 </ul>
25389 </div>
25390
25391 <h2><span class="mw-headline" id="Script"><script>alert(1);</script>Script<script>alert(1);</script></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: Script">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
25392
25393 !! html/parsoid
25394 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25395 <h2 id="Script" data-parsoid='{}'><script typeof="mw:Extension/html" about="#mwt4" data-mw='{"name":"html","attrs":{},"body":{"extsrc":"&lt;script>alert(1);&lt;/script>"}}'>alert(1);</script>Script<script typeof="mw:Extension/html" about="#mwt6" data-mw='{"name":"html","attrs":{},"body":{"extsrc":"&lt;script>alert(1);&lt;/script>"}}'>alert(1);</script></h2>
25396 !! end
25397
25398 !! test
25399 Empty <p> tag in TOC, removed by Sanitizer (T92892)
25400 !! wikitext
25401 __TOC__
25402 ==x==
25403 !! html/php
25404 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
25405 <ul>
25406 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
25407 </ul>
25408 </div>
25409
25410 <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>
25411
25412 !! html/parsoid
25413 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
25414 <h2 id="x" data-parsoid='{}'>x</h2>
25415 !! end
25416
25417 !! article
25418 MediaWiki:T34057
25419 !! text
25420 == {{int:headline_sample}} ==
25421 !! endarticle
25422
25423 !! test
25424 T34057: Title needed when expanding <h> nodes.
25425 !! options
25426 title=[[Main Page]]
25427 !! wikitext
25428 {{int:T34057}}
25429 !! html
25430 <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>
25431
25432 !! end
25433
25434 !! test
25435 Strip marker in urlencode
25436 !! wikitext
25437 {{urlencode:x<nowiki/>y}}
25438 {{urlencode:x<nowiki/>y|wiki}}
25439 {{urlencode:x<nowiki/>y|path}}
25440 {{urlencode:x<pre id="one">two</pre>y}}
25441 !! html/php
25442 <p>xy
25443 xy
25444 xy
25445 xy
25446 </p>
25447 !! end
25448
25449 !! test
25450 Strip marker in lc
25451 !! wikitext
25452 {{lc:x<nowiki/>y}}
25453 !! html
25454 <p>xy
25455 </p>
25456 !! end
25457
25458 !! test
25459 Strip marker in uc
25460 !! wikitext
25461 {{uc:x<nowiki/>y}}
25462 !! html
25463 <p>XY
25464 </p>
25465 !! end
25466
25467 !! test
25468 Strip marker in formatNum
25469 !! wikitext
25470 {{formatnum:1<nowiki/>2}}
25471 {{formatnum:1<nowiki/>2|R}}
25472 !! html
25473 <p>12
25474 12
25475 </p>
25476 !! end
25477
25478 !! test
25479 Check noCommafy in formatNum
25480 !! options
25481 language=be-tarask
25482 !! wikitext
25483 {{formatnum:123456.78}}
25484 {{formatnum:123456.78|NOSEP}}
25485 !! html
25486 <p>123 456,78
25487 123456.78
25488 </p>
25489 !! end
25490
25491 !! test
25492 Wrong option for formatNum (T58199)
25493 !! wikitext
25494 {{formatnum:1,234.56|Random}}
25495 {{formatnum:1,234.56|EVERYTHING}}
25496 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
25497 !! html
25498 <p>1,234.56
25499 1,234.56
25500 1,234.56
25501 </p>
25502 !! end
25503
25504 !! test
25505 Strip marker in grammar
25506 !! options
25507 language=fi
25508 !! wikitext
25509 {{grammar:elative|foo<nowiki/>bar}}
25510 !! html
25511 <p>foobarista
25512 </p>
25513 !! end
25514
25515 !! test
25516 Strip marker in padleft
25517 !! wikitext
25518 {{padleft:|2|x<nowiki/>y}}
25519 !! html
25520 <p>xy
25521 </p>
25522 !! end
25523
25524 !! test
25525 Strip marker in padright
25526 !! wikitext
25527 {{padright:|2|x<nowiki/>y}}
25528 !! html
25529 <p>xy
25530 </p>
25531 !! end
25532
25533 !! test
25534 Strip marker in anchorencode
25535 !! wikitext
25536 {{anchorencode:x<nowiki/>y}}
25537 !! html/php
25538 <p>xy
25539 </p>
25540 !! html/parsoid
25541 <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>
25542 !! end
25543
25544 !! test
25545 nowiki inside link inside heading (T20295)
25546 !! wikitext
25547 ==[[foo|x<nowiki>y</nowiki>z]]==
25548 !! html
25549 <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>
25550
25551 !! end
25552
25553 !! test
25554 new support for bdi element (T33817)
25555 !! wikitext
25556 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25557 !! html
25558 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
25559
25560 !!end
25561
25562 !! test
25563 Ignore pipe between table row attributes
25564 !! wikitext
25565 {|
25566 |quux
25567 |- id=foo | style='color: red'
25568 |bar
25569 |}
25570 !! html
25571 <table>
25572 <tr>
25573 <td>quux
25574 </td></tr>
25575 <tr id="foo" style="color: red">
25576 <td>bar
25577 </td></tr></table>
25578
25579 !! end
25580
25581 !!test
25582 Language parser function
25583 !! wikitext
25584 {{#language:ar}}
25585 !! html
25586 <p>العربية
25587 </p>
25588 !! end
25589
25590 !!test
25591 Padleft and padright (default 0-padding)
25592 !! wikitext
25593 {{padleft:xyz|5}}
25594 {{padright:xyz|5}}
25595 !! html/php
25596 <p>00xyz
25597 xyz00
25598 </p>
25599 !! html/parsoid
25600 <p><span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padleft:xyz","function":"padleft"},"params":{"1":{"wt":"5"}},"i":0}}]}'>00xyz</span>
25601 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"padright:xyz","function":"padright"},"params":{"1":{"wt":"5"}},"i":0}}]}'>xyz00</span></p>
25602 !! end
25603
25604 !!test
25605 Padleft and padright (partial fill)
25606 !! wikitext
25607 {{padleft:xyz|6|ab}}
25608 {{padright:xyz|6|ab}}
25609 !! html/php
25610 <p>abaxyz
25611 xyzaba
25612 </p>
25613 !! html/parsoid
25614 <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>
25615 <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>
25616 !! end
25617
25618 !!test
25619 Padleft and padright as substr
25620 !! wikitext
25621 {{padleft:|3|abcde}}
25622 {{padright:|3|abcde}}
25623 !! html/php
25624 <p>abc
25625 abc
25626 </p>
25627 !! html/parsoid
25628 <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>
25629 <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>
25630 !! end
25631
25632 !! test
25633 Padleft and padright with non-numerical length (T180403)
25634 !! wikitext
25635 {{padleft:abcdef|junk}}
25636 {{padright:abcdef|junk}}
25637 !! html/php
25638 <p>abcdef
25639 abcdef
25640 </p>
25641 !! end
25642
25643 !!test
25644 Special parser function
25645 !! wikitext
25646 {{#special:RandomPage}}
25647 {{#special:BaDtItLe}}
25648 {{#special:Foobar}}
25649 !! html
25650 <p>Special:Random
25651 Special:Badtitle
25652 Special:Foobar
25653 </p>
25654 !! end
25655
25656 !!test
25657 T36939 - Case insensitive link parsing ([HttP://])
25658 !! wikitext
25659 [HttP://MediaWiki.Org/]
25660 !! html/php
25661 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
25662 </p>
25663 !! html/parsoid
25664 <p><a rel="mw:ExtLink" class="external autonumber" href="HttP://MediaWiki.Org/"></a></p>
25665 !! end
25666
25667 !!test
25668 T36939 - Case insensitive link parsing ([HttP:// title])
25669 !! wikitext
25670 [HttP://MediaWiki.Org/ MediaWiki]
25671 !! html
25672 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
25673 </p>
25674 !! end
25675
25676 !!test
25677 T36939 - Case insensitive link parsing (HttP://)
25678 !! wikitext
25679 HttP://MediaWiki.Org/
25680 !! html/php
25681 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
25682 </p>
25683 !! html/parsoid
25684 <p><a rel="mw:ExtLink" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
25685 !! end
25686
25687 !!test
25688 Disable TOC
25689 !! options
25690 notoc
25691 !! wikitext
25692 Lead
25693 ==Section 1==
25694 ==Section 2==
25695 ==Section 3==
25696 ==Section 4==
25697 ==Section 5==
25698 !! html
25699 <p>Lead
25700 </p>
25701
25702 <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>
25703 <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>
25704 <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>
25705 <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>
25706 <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>
25707
25708 !! end
25709
25710
25711 ###
25712 ### Parsoid-specific tests
25713 ### Parsoid-PHP parser incompatibilities
25714 ###
25715 !!test
25716 1. SOL-sensitive wikitext tokens as template-args
25717 !! options
25718 parsoid=wt2html,wt2wt
25719 !! wikitext
25720 {{echo|*a}}
25721 {{echo|#a}}
25722 {{echo|:a}}
25723 !! html/php+tidy
25724 <ul><li>a</li></ul>
25725 <ol><li>a</li></ol>
25726 <dl><dd>a</dd></dl>
25727 !! html/parsoid
25728 <span about="#mwt1" typeof="mw:Transclusion">
25729 </span><ul about="#mwt1"><li>a</li>
25730 </ul>
25731 <span about="#mwt2" typeof="mw:Transclusion">
25732 </span><ol about="#mwt2"><li>a</li>
25733 </ol>
25734 <span about="#mwt3" typeof="mw:Transclusion">
25735 </span><dl about="#mwt3"><dd>a</dd>
25736 </dl>
25737 !!end
25738
25739 #### -----------------------------------------------------------------
25740 #### Parsoid-specific functionality tests
25741 #### -----------------------------------------------------------------
25742
25743 # T65642/T68749: Formatting elt fixup around images.
25744 # We know wt2wt will fail, but we expect selser to pass.
25745 # Due to the nature of our testing, wt2wt and selser tests will enter the
25746 # blacklist and we'll catch selser regressions based on changes to the
25747 # blacklist entries for selser tests.
25748 !! test
25749 1. Treebuilder fixup of formatting elt
25750 !! options
25751 parsoid=wt2html,wt2wt
25752 !! wikitext
25753 {|
25754 |
25755 <small>
25756 [[Image:Foobar.jpg|right|Test]]
25757 </small>
25758 |}
25759 !! html/php+tidy
25760 <table>
25761 <tbody><tr>
25762 <td>
25763 <p><small>
25764 </small></p><small>
25765 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Test"><img alt="Test" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
25766 </small><p><small></small>
25767 </p>
25768 </td></tr></tbody></table>
25769 !! html/parsoid
25770 <table>
25771 <tbody><tr><td>
25772 <p><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'></small></p><small data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
25773 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Test</figcaption></figure></small>
25774 <p><small data-parsoid='{"stx":"html","autoInsertedStart":true}'></small></p></td></tr>
25775 </tbody></table>
25776 !! end
25777
25778 !! test
25779 2. Treebuilder fixup of formatting elt
25780 !! options
25781 parsoid=wt2html,wt2wt
25782 !! wikitext
25783 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
25784
25785 <small>[[Image:Foobar.jpg|right|300px]]</small>
25786 !! html/php+tidy
25787 <p><b>foo</b></p><b><div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div></b><p><b>bar</b>
25788 </p><small><div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" width="300" height="34" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/450px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/600px-Foobar.jpg 2x" /></a></div></small>
25789 !! html/parsoid
25790 <p><b>foo</b></p><b><figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure></b><p><b>bar</b></p>
25791
25792 <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>
25793 !! end
25794
25795 !! test
25796 3. Treebuilder fixup of formatting elt
25797 !! options
25798 parsoid=wt2html,wt2wt
25799 !! wikitext
25800 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
25801 !! html/php+tidy
25802 <p><small><b>foo</b></small></p><small><b><div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div></b></small><p><small><b>bar</b></small>
25803 </p>
25804 !! html/parsoid
25805 <p><small><b>foo</b></small></p><small><b><figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure></b></small><p><small><b>bar</b></small></p>
25806 !! end
25807
25808 !! test
25809 4. Treebuilder fixup of formatting elt: formatting tags around captionless images
25810 !! options
25811 parsoid=wt2html,wt2wt
25812 !! wikitext
25813 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
25814 !! html/php+tidy
25815 <b><small><div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/300px-Foobar.jpg" width="300" height="34" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/450px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/600px-Foobar.jpg 2x" /></a></div></small></b>
25816 !! html/parsoid
25817 <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>
25818 !! end
25819
25820 #### ----------------------------------------------------------------
25821 #### Parsoid-only testing of Parsoid's impl of LST
25822 #### Not implemented yet, see
25823 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
25824 #### ----------------------------------------------------------------
25825
25826 ## We still need to support serializing the older format while content is stored.
25827 !! test
25828 LST Sections: Backwards compatibility
25829 !! options
25830 parsoid={
25831 "suppressErrors": true,
25832 "modes": ["html2wt"]
25833 }
25834 !! wikitext
25835 <section begin="2011-05-16" />
25836 <section end="2014-04-10 (MW 1.23wmf22)" />
25837 !! html/parsoid
25838 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
25839 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
25840 !! end
25841
25842 !! test
25843 LST Sections: Newfangled approach
25844 !! wikitext
25845 <section begin="2011-05-16" />
25846 <section end="2014-04-10 (MW 1.23wmf22)" />
25847 !! html/parsoid
25848 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"}}'>
25849 </span>
25850 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"}}'>
25851 </span></p>
25852 !! end
25853
25854 #--------- Test stripping of empty nodes in template content ----------
25855
25856 !! test
25857 Empty LI and TR nodes should be stripped from template content
25858 !! wikitext
25859 {{EmptyLITest}}
25860 {{EmptyTRTest}}
25861 !! html/parsoid
25862 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
25863 <li>a</li>
25864 <li>b</li>
25865 </ul>
25866 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
25867 <tbody>
25868 <tr>
25869 <td>foo</td>
25870 </tr>
25871 <tr>
25872 <td>bar</td>
25873 </tr>
25874 </tbody>
25875 </table>
25876 !! end
25877
25878 !! test
25879 Empty LI and TR nodes should not be stripped from top-level content
25880 !! wikitext
25881 *a
25882 *
25883 *b
25884
25885 {|
25886 |-
25887 |-
25888 |foo
25889 |}
25890 !! html/parsoid
25891 <ul>
25892 <li>a</li>
25893 <li class='mw-empty-elt'></li>
25894 <li>b</li>
25895 </ul>
25896 <table>
25897 <tbody>
25898 <tr class='mw-empty-elt'></tr>
25899 <tr>
25900 <td>foo</td>
25901 </tr>
25902 </tbody>
25903 </table>
25904 !! end
25905
25906 !! test
25907 Empty TR nodes should not be stripped if they have any attributes set
25908 !! wikitext
25909 {{EmptyTRWithHTMLAttrTest}}
25910 !! html/parsoid
25911 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
25912 <tr align='center'></tr>
25913 <tr><td>foo</td></tr>
25914 <tr align='center'></tr>
25915 <tr><td>bar</td></tr>
25916 </table>
25917 !! end
25918
25919 #### ----------------------------------------------------------------
25920 #### The following section of tests are primarily to test
25921 #### wikitext escaping capabilities of Parsoid. Given that
25922 #### escaping can be done any number of ways, the wikitext (input)
25923 #### is always adjusted to reflect how Parsoid adds nowiki
25924 #### escape tags.
25925 ####
25926 #### We are marking several tests as parsoid-only since the
25927 #### HTML in the result section is different from what the
25928 #### PHP parser generates for it.
25929 #### ----------------------------------------------------------------
25930
25931
25932 #### --------------- Headings ---------------
25933 #### 0. Unnested
25934 #### 1. Nested inside html <h1>=foo=</h1>
25935 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
25936 #### 3. Nested inside html with wikitext split by html tags
25937 #### 4. No escape needed
25938 #### 5. Empty headings <h1></h1>
25939 #### 6. Heading chars in SOL context
25940 #### ----------------------------------------
25941 !! test
25942 Headings: 0. Unnested
25943 !! options
25944 parsoid=html2wt
25945 !! html/parsoid
25946 <p>=foo=</p>
25947
25948 <p> =foo=
25949 <!--cmt-->
25950 =foo=</p>
25951
25952 <p>=foo<i>a</i>=</p>
25953 !! wikitext
25954 <nowiki>=foo=</nowiki>
25955
25956 <nowiki> </nowiki>=foo=
25957 <!--cmt-->
25958 <nowiki>=foo=</nowiki>
25959
25960 =foo''a''<nowiki>=</nowiki>
25961 !!end
25962
25963 # New headings and existing headings are handled differently
25964 !! test
25965 Headings: 1. Nested inside html
25966 !! options
25967 parsoid=html2wt
25968 !! html/parsoid
25969 <h1>=foo=</h1>
25970 <h2>=foo=</h2>
25971 <h3>=foo=</h3>
25972
25973 <h1 data-parsoid=''>=foo=</h1>
25974 <h2 data-parsoid=''>=foo=</h2>
25975 <h3 data-parsoid=''>=foo=</h3>
25976 <h4 data-parsoid=''>=foo=</h4>
25977 <h5 data-parsoid=''>=foo=</h5>
25978 <h6 data-parsoid=''>=foo=</h6>
25979 !! wikitext
25980 = =foo= =
25981
25982 == =foo= ==
25983
25984 === =foo= ===
25985
25986 =<nowiki>=foo=</nowiki>=
25987 ==<nowiki>=foo=</nowiki>==
25988 ===<nowiki>=foo=</nowiki>===
25989 ====<nowiki>=foo=</nowiki>====
25990 =====<nowiki>=foo=</nowiki>=====
25991 ======<nowiki>=foo=</nowiki>======
25992
25993 !!end
25994
25995 !! test
25996 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
25997 !! options
25998 parsoid=html2wt
25999 !! html/parsoid
26000 <h1>foo</h1>*bar
26001 <h1>foo</h1>=bar
26002 <h1>foo</h1>=bar=
26003 !! wikitext
26004 = foo =
26005 <nowiki>*</nowiki>bar
26006
26007 = foo =
26008 =bar
26009
26010 = foo =
26011 <nowiki>=bar=</nowiki>
26012 !!end
26013
26014 !! test
26015 Headings: 3. Nested inside html with wikitext split by html tags
26016 !! options
26017 parsoid=html2wt
26018 !! html/parsoid
26019 <h1>=<b>bold</b>foo=</h1>
26020 !! wikitext
26021 = ='''bold'''foo= =
26022 !!end
26023
26024 !! test
26025 Headings: 4a. No escaping needed (testing just h1 and h2)
26026 !! options
26027 parsoid=html2wt
26028 !! html/parsoid
26029 <h1>=foo</h1>
26030 <h1>foo=</h1>
26031 <h1> =foo= </h1>
26032 <h1>=foo= bar</h1>
26033 <h2>=foo</h2>
26034 <h2>foo=</h2>
26035 <h1>=</h1>
26036 <h1><i>=</i>foo=</h1>
26037 !! wikitext
26038 = =foo =
26039
26040 = foo= =
26041
26042 = =foo= =
26043
26044 = =foo= bar =
26045
26046 == =foo ==
26047
26048 == foo= ==
26049
26050 = = =
26051
26052 = ''=''foo= =
26053 !!end
26054
26055 !! test
26056 Headings: 4b. No escaping needed (inside p-tags)
26057 !! options
26058 parsoid=html2wt
26059 !! html/parsoid
26060 <p>=foo= x
26061 =foo= <s></s>
26062 </p>
26063 !! wikitext
26064 =foo= x
26065 =foo= <s></s>
26066 !! html/php
26067 <p>=foo= x
26068 =foo= <s></s>
26069 </p>
26070 !!end
26071
26072 !! test
26073 Headings: 4c. Short headings (1)
26074 !! options
26075 parsoid=html2wt
26076 !! html/parsoid
26077 <p>===
26078 </p>
26079 !! wikitext
26080 <nowiki>===</nowiki>
26081 !! html/php
26082 <p>===
26083 </p>
26084 !! end
26085
26086 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
26087 !! test
26088 Headings: 4d. Short headings (2)
26089 !! options
26090 parsoid=wt2html,html2html
26091 !! wikitext
26092 =
26093 ==
26094 ===
26095 ====
26096 =====
26097 !! html/php
26098 <p>=
26099 ==
26100 </p>
26101 <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>
26102 <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>
26103 <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>
26104
26105 !! html/parsoid
26106 <p>=
26107 ==</p>
26108 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
26109 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
26110 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
26111 !! end
26112
26113 !! test
26114 Headings: 5. Empty headings
26115 !! options
26116 parsoid=html2wt
26117 !! html/parsoid
26118 <h1 data-parsoid='{}'></h1>
26119
26120 <h2 data-parsoid='{}'></h2>
26121
26122 <h3 data-parsoid='{}'></h3>
26123
26124 <h4 data-parsoid='{}'></h4>
26125
26126 <h5 data-parsoid='{}'></h5>
26127
26128 <h6 data-parsoid='{}'></h6>
26129 !! wikitext
26130 =<nowiki/>=
26131
26132 ==<nowiki/>==
26133
26134 ===<nowiki/>===
26135
26136 ====<nowiki/>====
26137
26138 =====<nowiki/>=====
26139
26140 ======<nowiki/>======
26141 !!end
26142
26143 !! test
26144 Headings: 6a. Heading chars in SOL context (with trailing spaces)
26145 !! options
26146 parsoid=html2wt
26147 !! html/parsoid
26148 <p>=a=</p>
26149
26150 <p>=a=</p>
26151
26152 <p>=a=</p>
26153 !! wikitext
26154 <nowiki>=a=</nowiki>
26155
26156 <nowiki>=a=</nowiki>
26157
26158 <nowiki>=a=</nowiki>
26159 !!end
26160
26161 !! test
26162 Headings: 6b. Heading chars in SOL context (with trailing newlines)
26163 !! options
26164 parsoid=html2wt
26165 !! html/parsoid
26166 <p>=a=
26167 b</p>
26168
26169 <p>=a=
26170 b</p>
26171
26172 <p>=a=
26173 b</p>
26174 !! wikitext
26175 <nowiki>=a=</nowiki>
26176 b
26177
26178 <nowiki>=a=</nowiki>
26179 b
26180
26181 <nowiki>=a=</nowiki>
26182 b
26183 !!end
26184
26185 !! test
26186 Headings: 6c. Heading chars in SOL context (leading newline break)
26187 !! options
26188 parsoid=html2wt
26189 !! html/parsoid
26190 <p>a
26191 =b=</p>
26192 !! wikitext
26193 a
26194 <nowiki>=b=</nowiki>
26195 !!end
26196
26197 !! test
26198 Headings: 6d. Heading chars in SOL context (with interspersed comments)
26199 !! options
26200 parsoid=html2wt
26201 !! html/parsoid
26202 <!--c0--><p>=a=</p>
26203
26204 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
26205 !! wikitext
26206 <!--c0--><nowiki>=a=</nowiki>
26207
26208 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
26209 !!end
26210
26211 !! test
26212 Headings: 6d. Heading chars in SOL context (No escaping needed)
26213 !! options
26214 parsoid=html2wt
26215 !! html/parsoid
26216 =a=<div>b</div>
26217 !! wikitext
26218 =a=<div>b</div>
26219 !!end
26220
26221 !! test
26222 Headings: 7. Insert a newline between new content and headings
26223 !! options
26224 parsoid=html2wt
26225 !! html/parsoid
26226 <h2>NEW</h2>
26227 <p>new</p>
26228 <h2 data-parsoid='{}'>A</h2>
26229 <p data-parsoid='{}'>a</p>
26230 !! wikitext
26231 == NEW ==
26232 new
26233
26234 ==A==
26235 a
26236
26237 !! end
26238
26239 !! test
26240 Headings: Used as horizontal rule
26241 !! config
26242 wgFragmentMode=[ 'html5', 'legacy' ]
26243 !! options
26244 parsoid=wt2html
26245 !! wikitext
26246 ===============
26247 !! html/php
26248 <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>
26249
26250 !! html/parsoid
26251 <h6 id="==="><span id=".3D.3D.3D" typeof="mw:FallbackId"></span>===</h6>
26252 !! end
26253
26254 #### --------------- Lists ---------------
26255 #### 0. Outside nests (*foo, etc.)
26256 #### 1. Nested inside html <ul><li>*foo</li></ul>
26257 #### 2. Inside definition lists
26258 #### 3. Only bullets at start should be escaped
26259 #### 4. No escapes needed
26260 #### 5. No unnecessary escapes
26261 #### 6. Escape bullets in SOL position
26262 #### 7. Escape bullets in a multi-line context
26263 #### ----------------------------------------
26264
26265 !! test
26266 Lists: 0. Outside nests
26267 !! options
26268 parsoid=html2wt
26269 !! html/parsoid
26270 <p>*foo</p>
26271
26272 <p>#foo</p>
26273
26274 <p>;Foo:bar</p>
26275 !! wikitext
26276 <nowiki>*</nowiki>foo
26277
26278 <nowiki>#</nowiki>foo
26279
26280 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
26281 !!end
26282
26283 ## Making these next 3 tests Parsoid-only since they are html2wt tests
26284 ## to test wikitext escaping, and insignificant whitespace diffs
26285 ## cause PHP parser tests to barf
26286 !! test
26287 Lists: 1. Nested inside html (No unnecessary escapes)
26288 !! options
26289 parsoid=html2wt
26290 !! html/parsoid
26291 <ul>
26292 <li>*foo</li>
26293 <li>#foo</li>
26294 <li>:foo</li>
26295 <li>;foo</li>
26296 <li data-parsoid='{}'>*foo</li>
26297 <li data-parsoid='{}'>#foo</li>
26298 <li data-parsoid='{}'>:foo</li>
26299 <li data-parsoid='{}'>;foo</li>
26300 </ul>
26301
26302 <ol>
26303 <li>*foo</li>
26304 <li>#foo</li>
26305 <li>:foo</li>
26306 <li>;foo</li>
26307 <li data-parsoid='{}'>*foo</li>
26308 <li data-parsoid='{}'>#foo</li>
26309 <li data-parsoid='{}'>:foo</li>
26310 <li data-parsoid='{}'>;foo</li>
26311 </ol>
26312 !! wikitext
26313 * *foo
26314 * #foo
26315 * :foo
26316 * ;foo
26317 *<nowiki>*foo</nowiki>
26318 *<nowiki>#foo</nowiki>
26319 *<nowiki>:foo</nowiki>
26320 *<nowiki>;foo</nowiki>
26321
26322 # *foo
26323 # #foo
26324 # :foo
26325 # ;foo
26326 #<nowiki>*foo</nowiki>
26327 #<nowiki>#foo</nowiki>
26328 #<nowiki>:foo</nowiki>
26329 #<nowiki>;foo</nowiki>
26330 !!end
26331
26332 !! test
26333 Lists: 2. Inside definition lists
26334 !! options
26335 parsoid=html2wt
26336 !! html/parsoid
26337 <dl><dt>;foo</dt></dl>
26338 <dl><dt>:foo</dt></dl>
26339 <dl><dt>:foo</dt>
26340 <dd>bar</dd></dl>
26341 <dl><dd>:foo</dd></dl>
26342 !! wikitext
26343 ; ;foo
26344
26345 ; <nowiki>:foo</nowiki>
26346
26347 ; <nowiki>:foo</nowiki>
26348 : bar
26349
26350 : :foo
26351 !!end
26352
26353 !! test
26354 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
26355 !! options
26356 parsoid=html2wt
26357 !! html/parsoid
26358 <ul>
26359 <li>*foo*bar</li>
26360 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
26361 </ul>
26362 !! wikitext
26363 * *foo*bar
26364 *<nowiki>*foo</nowiki>''it''*bar
26365 !!end
26366
26367 !! test
26368 Lists: 4. No escapes needed
26369 !! options
26370 parsoid=html2wt
26371 !! html/parsoid
26372 <ul>
26373 <li>foo*bar
26374 </li>
26375 </ul>
26376 <ul>
26377 <li><i>foo</i>*bar
26378 </li>
26379 </ul>
26380 <ul>
26381 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
26382 </li>
26383 </ul>
26384 <ul>
26385 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
26386 </li>
26387 </ul>
26388 !! wikitext
26389 *foo*bar
26390
26391 *''foo''*bar
26392
26393 *[[Foo]]: bar
26394
26395 *[[Foo]]*bar
26396 !!end
26397
26398 !! test
26399 Lists: 5. No unnecessary escapes
26400 !! options
26401 parsoid=html2wt
26402 !! html/parsoid
26403 <ul><li> bar <span>[[foo]]</span></li></ul>
26404 <ul><li> =bar <span>[[foo]]</span></li></ul>
26405 <ul><li> [[bar <span>[[foo]]</span></li></ul>
26406 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
26407 <ul><li> =bar <span>foo]]</span>=</li></ul>
26408 <ul><li> <s></s>: a</li></ul>
26409 <ul><li> <i>* foo</i></li></ul>
26410
26411 !! wikitext
26412 * bar <span><nowiki>[[foo]]</nowiki></span>
26413
26414 * =bar <span><nowiki>[[foo]]</nowiki></span>
26415
26416 * [[bar <span><nowiki>[[foo]]</nowiki></span>
26417
26418 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
26419
26420 * =bar <span>foo]]</span>=
26421
26422 * <s></s>: a
26423
26424 * ''* foo''
26425 !!end
26426
26427 !! test
26428 Lists: 6. Escape bullets in SOL position
26429 !! options
26430 parsoid=html2wt
26431 !! html/parsoid
26432 <p><!--cmt-->*foo</p>
26433 !! wikitext
26434 <!--cmt--><nowiki>*</nowiki>foo
26435 !!end
26436
26437 !! test
26438 Lists: 7. Escape bullets in a multi-line context
26439 !! options
26440 parsoid=html2wt
26441 !! html/parsoid
26442 <p>a
26443 *b
26444 </p>
26445 !! wikitext
26446 a
26447 <nowiki>*</nowiki>b
26448 !!end
26449
26450 !! test
26451 Lists: 8. Escape colons only if not present in tags
26452 !! options
26453 parsoid=html2wt
26454 !! html/parsoid
26455 <dl><dt>a:b<i>c:d</i></dt></dl>
26456 !! wikitext
26457 ; <nowiki>a:b</nowiki>''c:d''
26458 !! end
26459
26460 #### --------------- HRs ---------------
26461 #### 1. Single line
26462 #### -----------------------------------
26463
26464 !! test
26465 HRs: 1. Single line
26466 !! options
26467 parsoid=html2wt
26468 !! html/parsoid
26469 <hr />----
26470 <hr />=foo=
26471 <hr />*foo
26472 !! wikitext
26473 ----<nowiki>----</nowiki>
26474 ----=foo=
26475 ----*foo
26476 !! end
26477
26478 #### --------------- Tables ---------------
26479 #### 1a. Simple example
26480 #### 1b. No escaping needed (!foo)
26481 #### 1c. No escaping needed (|foo)
26482 #### 1d. No escaping needed (|}foo)
26483 ####
26484 #### 2a. Nested in td (<td>foo|bar</td>)
26485 #### 2b. Nested in td (<td>foo||bar</td>)
26486 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
26487 ####
26488 #### 3a. Nested in th (<th>foo!bar</th>)
26489 #### 3b. Nested in th (<th>foo!!bar</th>)
26490 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
26491 ####
26492 #### 4a. Escape -
26493 #### 4b. Escape +
26494 #### 4c. No escaping needed
26495 #### --------------------------------------
26496
26497 !! test
26498 Tables: 1a. Simple example
26499 !! options
26500 parsoid=html2wt
26501 !! html/parsoid
26502 <p>{|
26503 |}
26504 </p>
26505 !! wikitext
26506 <nowiki>{|</nowiki>
26507 |}
26508 !! end
26509
26510 !! test
26511 Tables: 1b. No escaping needed
26512 !! options
26513 parsoid=html2wt
26514 !! html/parsoid
26515 <p>!foo
26516 </p>
26517 !! wikitext
26518 !foo
26519 !! end
26520
26521 !! test
26522 Tables: 1c. No escaping needed
26523 !! options
26524 parsoid=html2wt
26525 !! html/parsoid
26526 <p>|foo
26527 </p>
26528 !! wikitext
26529 |foo
26530 !! end
26531
26532 !! test
26533 Tables: 1d. No escaping needed
26534 !! options
26535 parsoid=html2wt
26536 !! html/parsoid
26537 <p>|}foo
26538 </p>
26539 !! wikitext
26540 |}foo
26541 !! end
26542
26543 !! test
26544 Tables: 2a. Nested in td
26545 !! options
26546 parsoid=html2wt
26547 !! html/parsoid
26548 <table><tbody><tr>
26549 <td>foo|bar</td></tr>
26550 <tr><td>x<div>a|b</div></td>
26551 </tbody></table>
26552 !! wikitext
26553 {|
26554 |<nowiki>foo|bar</nowiki>
26555 |-
26556 |x<div><nowiki>a|b</nowiki></div>
26557 |}
26558 !! html/php+tidy
26559 <table>
26560 <tbody><tr>
26561 <td>foo|bar
26562 </td></tr>
26563 <tr>
26564 <td>x<div>a|b</div>
26565 </td></tr></tbody></table>
26566 !! end
26567
26568 !! test
26569 Tables: 2b. Nested in td
26570 !! options
26571 parsoid=html2wt
26572 !! html/parsoid
26573 <table><tbody><tr>
26574 <td>foo||bar</td>
26575 <td>a<i>b||c</i></td>
26576 <td>a<i><div>b||c</div></i></td>
26577 </tr></tbody></table>
26578 !! wikitext
26579 {|
26580 |<nowiki>foo||bar</nowiki>
26581 |a''<nowiki>b||c</nowiki>''
26582 |a''<div><nowiki>b||c</nowiki></div>''
26583 |}
26584 !! html/php
26585 <table>
26586 <tr>
26587 <td>foo||bar
26588 </td>
26589 <td>a<i>b||c</i>
26590 </td>
26591 <td>a<i><div>b||c</div></i>
26592 </td></tr></table>
26593
26594 !! end
26595
26596 !! test
26597 Tables: 2c. Nested in td -- no escaping needed
26598 !! options
26599 parsoid=html2wt
26600 !! html/*
26601 <table>
26602 <tr>
26603 <td>foo!!bar
26604 </td></tr></table>
26605
26606 !! wikitext
26607 {|
26608 |foo!!bar
26609 |}
26610 !! end
26611
26612 !! test
26613 Tables: 3a. Nested in th
26614 !! options
26615 parsoid=html2wt
26616 !! html/*
26617 <table>
26618 <tr>
26619 <th>foo!bar
26620 </th></tr></table>
26621
26622 !! wikitext
26623 {|
26624 !foo!bar
26625 |}
26626 !! end
26627
26628 !! test
26629 Tables: 3b. Nested in th
26630 !! options
26631 parsoid=html2wt
26632 !! html/parsoid
26633 <table><tbody>
26634 <tr><th>foo!!bar</th>
26635 <th><i>foo|bar</i></th>
26636 <th><i>foo!!bar</i></th>
26637 <th><i><span>foo!!bar</span></i></th>
26638 </tr></tbody></table>
26639 !! wikitext
26640 {|
26641 !<nowiki>foo!!bar</nowiki>
26642 !''<nowiki>foo|bar</nowiki>''
26643 !''<nowiki>foo!!bar</nowiki>''
26644 !''<span><nowiki>foo!!bar</nowiki></span>''
26645 |}
26646 !! html/php
26647 <table>
26648 <tr>
26649 <th>foo!!bar
26650 </th>
26651 <th><i>foo|bar</i>
26652 </th>
26653 <th><i>foo!!bar</i>
26654 </th>
26655 <th><i><span>foo!!bar</span></i>
26656 </th></tr></table>
26657
26658 !! end
26659
26660 !! test
26661 Tables: 3c. Nested in th
26662 !! options
26663 parsoid=html2wt
26664 !! html/parsoid
26665 <table><tbody>
26666 <tr><th>foo||bar</th>
26667 <th><span typeof="mw:Nowiki">foo||bar</span></th>
26668 </tr></tbody></table>
26669 !! wikitext
26670 {|
26671 !<nowiki>foo||bar</nowiki>
26672 !<nowiki>foo||bar</nowiki>
26673 |}
26674 !! html/php
26675 <table>
26676 <tr>
26677 <th>foo||bar
26678 </th>
26679 <th>foo||bar
26680 </th></tr></table>
26681
26682 !! end
26683
26684 !! test
26685 Tables: 4a. Escape -
26686 !! options
26687 parsoid=html2wt
26688 !! html/*
26689 <table>
26690 <tr>
26691 <th>-bar
26692 </th></tr>
26693 <tr>
26694 <td>-bar
26695 </td></tr></table>
26696
26697 !! wikitext
26698 {|
26699 !-bar
26700 |-
26701 |<nowiki>-bar</nowiki>
26702 |}
26703 !! end
26704
26705 !! test
26706 Tables: 4b. Escape +
26707 !! options
26708 parsoid=html2wt
26709 !! html/*
26710 <table>
26711 <tr>
26712 <th>+bar
26713 </th></tr>
26714 <tr>
26715 <td>+bar
26716 </td></tr></table>
26717
26718 !! wikitext
26719 {|
26720 !+bar
26721 |-
26722 |<nowiki>+bar</nowiki>
26723 |}
26724 !! end
26725
26726 !! test
26727 Tables: 4c. No escaping needed
26728 !! options
26729 parsoid=html2wt
26730 !! html/parsoid
26731 <table><tbody>
26732 <tr><td>foo-bar</td><td>foo+bar</td></tr>
26733 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
26734 <tr><td>foo
26735 <p>bar|baz
26736 +bar
26737 -bar</p></td></tr>
26738 <tr><td>x
26739 <div>a|b</div></td>
26740 </tbody></table>
26741 !! wikitext
26742 {|
26743 |foo-bar
26744 |foo+bar
26745 |-
26746 |''foo''-bar
26747 |''foo''+bar
26748 |-
26749 |foo
26750 bar|baz
26751 +bar
26752 -bar
26753 |-
26754 |x
26755 <div>a|b</div>
26756 |}
26757 !! html/php
26758 <table>
26759 <tr>
26760 <td>foo-bar
26761 </td>
26762 <td>foo+bar
26763 </td></tr>
26764 <tr>
26765 <td><i>foo</i>-bar
26766 </td>
26767 <td><i>foo</i>+bar
26768 </td></tr>
26769 <tr>
26770 <td>foo
26771 <p>bar|baz
26772 +bar
26773 -bar
26774 </p>
26775 </td></tr>
26776 <tr>
26777 <td>x
26778 <div>a|b</div>
26779 </td></tr></table>
26780
26781 !! end
26782
26783 !! test
26784 Tables: 4d. No escaping needed
26785 !! options
26786 parsoid=html2wt
26787 !! html/parsoid
26788 <table>
26789 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
26790 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
26791 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
26792 </tbody></table>
26793 !! wikitext
26794 {|
26795 |[[Foo]]-bar
26796 ||+1
26797 ||-2
26798 |}
26799 !! html/php
26800 <table>
26801 <tr>
26802 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
26803 </td>
26804 <td>+1
26805 </td>
26806 <td>-2
26807 </td></tr></table>
26808
26809 !! end
26810
26811 !! test
26812 Tables: 4e. Escape }
26813 !! options
26814 parsoid=html2wt
26815 !! html/parsoid
26816 <table>
26817 <tr><td>}</td></tr>
26818 <tr><td>x</td><td data-parsoid='{"stx":"row"}'>}</td></tr></table>
26819 </table>
26820 !! wikitext
26821 {|
26822 |<nowiki>}</nowiki>
26823 |-
26824 |x||}
26825 |}
26826 !! html/php
26827 <table>
26828 <tr>
26829 <td>}
26830 </td></tr>
26831 <tr>
26832 <td>x</td>
26833 <td>}
26834 </td></tr></table>
26835
26836 !! end
26837
26838 !! test
26839 Tables: 5. Empty table cells should get whitespace to avoid need for nowikis
26840 !! options
26841 parsoid=html2wt
26842 !! html/parsoid
26843 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26844
26845 <table><tr><td></td><td align="center"></td><td></td></tr></table>
26846
26847 <table><tr><td></td><td align="center" data-parsoid='{"stx":"row", "startTagSrc":"{{!}}{{!}}"}'></td><td data-parsoid='{"stx":"row"}'></td></tr></table>
26848
26849 <table><tr><th></th><th align="center" data-parsoid='{"stx":"row"}'></th><th data-parsoid='{"stx":"row"}'></th></tr></table>
26850 !! wikitext
26851 {|
26852 | || align="center" | ||
26853 |}
26854
26855 {|
26856 |
26857 | align="center" |
26858 |
26859 |}
26860
26861 {|
26862 | {{!}}{{!}} align="center" | ||
26863 |}
26864
26865 {|
26866 ! !! align="center" | !!
26867 |}
26868 !! html/php+tidy
26869 <table>
26870 <tbody><tr>
26871 <td></td>
26872 <td align="center"></td>
26873 <td>
26874 </td></tr></tbody></table>
26875 <table>
26876 <tbody><tr>
26877 <td>
26878 </td>
26879 <td align="center">
26880 </td>
26881 <td>
26882 </td></tr></tbody></table>
26883 <table>
26884 <tbody><tr>
26885 <td></td>
26886 <td align="center"></td>
26887 <td>
26888 </td></tr></tbody></table>
26889 <table>
26890 <tbody><tr>
26891 <th></th>
26892 <th align="center"></th>
26893 <th>
26894 </th></tr></tbody></table>
26895 !! end
26896
26897 !! test
26898 T97430: Don't emit empty nowiki pairs around marker meta tags
26899 !! options
26900 parsoid=html2wt
26901 !! html/parsoid
26902 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26903 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
26904 !! wikitext
26905 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
26906 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
26907 !! end
26908
26909 !! test
26910 Unclosed xmlish element in table line shouldn't eat end delimiters
26911 !! options
26912 parsoid=html2wt
26913 !! html/parsoid
26914 <table>
26915 <tbody><tr><td> &lt;foo</td>
26916 <td> bar></td></tr>
26917 </tbody></table>
26918 !! wikitext
26919 {|
26920 | <foo
26921 | bar>
26922 |}
26923 !! html/php
26924 <table>
26925 <tr>
26926 <td>&lt;foo
26927 </td>
26928 <td>bar&gt;
26929 </td></tr></table>
26930
26931 !! end
26932
26933 #### --------------- Links ----------------
26934 #### 1. Quote marks in link text
26935 #### 2. Wikilinks: Escapes needed
26936 #### 3. Wikilinks: No escapes needed
26937 #### 4. Extlinks: Escapes needed
26938 #### 5. Extlinks: No escapes needed
26939 #### --------------------------------------
26940 !! test
26941 Links 1. WikiLinks: No escapes needed
26942 !! options
26943 parsoid=html2wt
26944 !! html/parsoid
26945 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
26946 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
26947 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
26948 !! wikitext
26949 [[Foo|Foo''boo'']]
26950 [[Foo|[Foobar]]]
26951 [[Foo|x [Foobar] x]]
26952 !! html/php
26953 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
26954 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
26955 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
26956 </p>
26957 !! end
26958
26959 !! test
26960 Links 2. WikiLinks: Escapes needed
26961 !! options
26962 parsoid=html2wt
26963 !! html/parsoid
26964 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
26965 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
26966 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
26967 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
26968 <a href="Foo" rel="mw:WikiLink">|Bar</a>
26969 <a href="Foo" rel="mw:WikiLink">]]bar</a>
26970 <a href="Foo" rel="mw:WikiLink">[[bar</a>
26971 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
26972 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
26973 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
26974 !! wikitext
26975 [[Foo|<nowiki>Foobar]</nowiki>]]
26976 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
26977 [[Foo|<nowiki>[[Bar]]</nowiki>]]
26978 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
26979 [[Foo|<nowiki>|Bar</nowiki>]]
26980 [[Foo|<nowiki>]]bar</nowiki>]]
26981 [[Foo|<nowiki>[[bar</nowiki>]]
26982 [[Foo|<nowiki>x [[ y</nowiki>]]
26983 [[Foo|<nowiki>x ]] y</nowiki>]]
26984 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
26985 !! html/php
26986 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
26987 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
26988 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
26989 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
26990 <a href="/wiki/Foo" title="Foo">|Bar</a>
26991 <a href="/wiki/Foo" title="Foo">]]bar</a>
26992 <a href="/wiki/Foo" title="Foo">[[bar</a>
26993 <a href="/wiki/Foo" title="Foo">x [[ y</a>
26994 <a href="/wiki/Foo" title="Foo">x ]] y</a>
26995 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
26996 </p>
26997 !! end
26998
26999 !! test
27000 Links 3. WikiLinks: No escapes needed
27001 !! options
27002 parsoid=html2wt
27003 !! html/parsoid
27004 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
27005 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
27006 !! wikitext
27007 [[Foo|[Foobar]]
27008 [[Foo|foo|bar]]
27009 !! html/php
27010 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
27011 <a href="/wiki/Foo" title="Foo">foo|bar</a>
27012 </p>
27013 !! end
27014
27015 !! test
27016 Links 4. ExtLinks: Escapes needed
27017 !! options
27018 parsoid=html2wt
27019 !! html/parsoid
27020 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
27021 <a rel="mw:ExtLink" href="http://google.com">google]</a>
27022 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
27023 <p>[http://google.com]</p>
27024 <p>[http://google.com google]</p>
27025 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
27026 <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>
27027 !! wikitext
27028 [http://google.com <nowiki>[google]</nowiki>]
27029 [http://google.com <nowiki>google]</nowiki>]
27030 [http://google.com <nowiki>goog] le</nowiki>]
27031
27032 <nowiki>[http://google.com]</nowiki>
27033
27034 <nowiki>[http://google.com google]</nowiki>
27035
27036 [http://google.com<nowiki>]</nowiki>
27037
27038 [{{echo|http://google.com}}<nowiki>]</nowiki>
27039 !! html/php
27040 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
27041 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
27042 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
27043 </p><p>[http://google.com]
27044 </p><p>[http://google.com google]
27045 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27046 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
27047 </p>
27048 !! end
27049
27050 !! test
27051 Links 5. ExtLinks: No escapes needed
27052 !! options
27053 parsoid=html2wt
27054 !! html/parsoid
27055 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
27056 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
27057 !! wikitext
27058 [http://google.com [google]
27059
27060 [[http://google.com]]
27061 !! html/php
27062 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
27063 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
27064 </p>
27065 !! end
27066
27067 !! test
27068 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
27069 !! options
27070 parsoid=html2wt
27071 !! html/parsoid
27072 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
27073 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
27074 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
27075 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
27076 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
27077 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
27078 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
27079 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
27080 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
27081 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
27082 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
27083 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
27084 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
27085 </p>
27086 !! wikitext
27087 x<nowiki/>http://example.com<nowiki/>y
27088 http://example.com<nowiki/>?x
27089 http://example.com<nowiki/>&x
27090 http://example.com<nowiki/>'x
27091 http://example.com<nowiki/>,x
27092 http://example.com<nowiki/>.x
27093 http://example.com<nowiki/>;x
27094 http://example.com<nowiki/>:x
27095 http://example.com<nowiki/>;x
27096 http://example.com<nowiki/>!x
27097 http://example.com<nowiki/>=x
27098 http://example.com<nowiki/>(x)
27099 http://example.com(x<nowiki/>)
27100 !! end
27101
27102 !! test
27103 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27104 !! options
27105 parsoid=html2wt
27106 !! html/parsoid
27107 <p>x
27108 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
27109 y
27110 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
27111 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
27112 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
27113 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
27114 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
27115 </p>
27116 !! wikitext
27117 x
27118 http://example.com
27119 y
27120 "http://example.com"
27121 (http://example.com)
27122 (http://example.com) foo
27123 http://example.com,
27124 http://example.com, foo
27125 !! html/php
27126 <p>x
27127 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
27128 y
27129 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
27130 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
27131 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
27132 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
27133 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
27134 </p>
27135 !! end
27136
27137 !! test
27138 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
27139 !! options
27140 parsoid=html2wt
27141 !! html/parsoid
27142 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
27143 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
27144 !! wikitext
27145 http://example.com.,;:!?\
27146 -http://example.com:
27147 !! html/php
27148 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
27149 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
27150 </p>
27151 !! end
27152
27153 !! test
27154 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
27155 !! options
27156 parsoid=html2wt
27157 !! html/parsoid
27158 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
27159 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
27160 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
27161 !! wikitext
27162 RFC 123<nowiki/>4
27163 RFC 123<nowiki/>y
27164 X<nowiki/>RFC 123<nowiki/>y
27165 !! end
27166
27167 !! test
27168 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
27169 !! options
27170 parsoid=html2wt
27171 !! html/parsoid
27172 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
27173 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
27174 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
27175 </p>
27176 !! wikitext
27177 RFC 123?foo
27178 RFC 123&foo
27179 -RFC 123-
27180 !! html/php
27181 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
27182 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
27183 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
27184 </p>
27185 !! end
27186
27187 !! test
27188 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
27189 !! options
27190 parsoid=html2wt
27191 !! html/parsoid
27192 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
27193 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27194 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
27195 !! wikitext
27196 PMID 123<nowiki/>4
27197 PMID 123<nowiki/>y
27198 X<nowiki/>PMID 123<nowiki/>y
27199 !! end
27200
27201 !! test
27202 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
27203 !! options
27204 parsoid=html2wt
27205 !! html/parsoid
27206 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
27207 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
27208 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
27209 </p>
27210 !! wikitext
27211 PMID 123?foo
27212 PMID 123&foo
27213 -PMID 123-
27214 !! html/php
27215 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
27216 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
27217 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
27218 </p>
27219 !! end
27220
27221 !! test
27222 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
27223 !! options
27224 parsoid=html2wt
27225 !! html/parsoid
27226 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
27227 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
27228 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
27229 </p>
27230 !! wikitext
27231 ISBN 1234567890<nowiki/>1
27232 ISBN 1234567890<nowiki/>x
27233 a<nowiki/>ISBN 1234567890<nowiki/>b
27234 !! end
27235
27236 !! test
27237 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
27238 !! options
27239 parsoid=html2wt
27240 !! html/parsoid
27241 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
27242 !! wikitext
27243 -ISBN 1234567890's
27244 !! html/php
27245 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
27246 </p>
27247 !! end
27248
27249 !! test
27250 Links 14. Protect link-like plain text. (Parsoid bug T78425)
27251 !! options
27252 parsoid=html2wt
27253 !! html/*
27254 <p>this is not a link: http://example.com
27255 </p>
27256 !! wikitext
27257 this is not a link: <nowiki>http://example.com</nowiki>
27258 !! end
27259
27260 !! test
27261 Links 15. Link trails can't become link prefixes.
27262 !! options
27263 language=is
27264 parsoid=html2wt
27265 !! html/parsoid
27266 <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>
27267 !! wikitext
27268 [[Söfnuður]]-[[00]]
27269 !! html/php
27270 <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>
27271 </p>
27272 !! end
27273
27274 #### --------------- Quotes ---------------
27275 #### 1. Quotes inside <b> and <i>
27276 #### 2. Link fragments separated by <i> and <b> tags
27277 #### 3. Link fragments inside <i> and <b>
27278 #### 4. No escaping needed
27279 #### --------------------------------------
27280 !! test
27281 1a. Quotes inside <b> and <i>
27282 !! options
27283 parsoid=html2wt
27284 !! html/*
27285 <p><i>'foo'</i>
27286 <i>''foo''</i>
27287 <i>'''foo'''</i>
27288 <i>foo</i>'s
27289 <b>'foo'</b>
27290 <b>''foo''</b>
27291 <b>'''foo'''</b>
27292 <b>foo'<i>bar'</i>baz</b>
27293 <b>foo</b>'s
27294 '<i>foo</i>
27295 <i>foo</i>'
27296 <i>foo'</i>'
27297 '<i>foo</i>'
27298 '<b>foo</b>
27299 <b>foo</b>'
27300 '<b>foo</b>'
27301 <i>fools'<span> errand</span></i>
27302 <i><span>fool</span>'s errand</i>
27303 '<i>foo</i> bar '<i>baz</i>
27304 a|!*#-:;+-~[]{}b'<i>x</i>
27305 </p>
27306 !! wikitext
27307 ''<nowiki/>'foo'''
27308 ''<nowiki>''foo''</nowiki>''
27309 ''<nowiki>'''foo'''</nowiki>''
27310 ''foo''<nowiki/>'s
27311 '''<nowiki/>'foo''''
27312 '''<nowiki>''foo''</nowiki>'''
27313 '''<nowiki>'''foo'''</nowiki>'''
27314 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
27315 '''foo'''<nowiki/>'s
27316 '''foo''
27317 ''foo''<nowiki/>'
27318 ''foo'''<nowiki/>'
27319 '''foo''<nowiki/>'
27320 ''''foo'''
27321 '''foo'''<nowiki/>'
27322 ''''foo'''<nowiki/>'
27323 ''fools'<span> errand</span>''
27324 ''<span>fool</span>'s errand''
27325 '<nowiki/>''foo'' bar '''baz''
27326 a|!*#-:;+-~[]{}b'''x''
27327 !! end
27328
27329 !! test
27330 1b. Quotes inside <b> and <i> with other tags on same line
27331 !! options
27332 parsoid=html2wt
27333 !! html/parsoid
27334 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27335 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
27336 <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>
27337 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
27338 '<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>
27339 '<i>foo</i> <div title="name">test</div>
27340 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
27341 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
27342 <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>
27343 </ol>
27344 !! wikitext
27345 '''a'' foo ''[[bar]]''
27346 ''a''' foo ''[[bar]]''
27347 ''a''' foo '''{{echo|[[bar]]}}'''
27348 [[foo]] x'''[[bar]]''
27349 '''foo'' <ref>test</ref>
27350 '''foo'' <div title="name">test</div>
27351 '''foo'' and <br> bar
27352 <references />
27353 !! end
27354
27355 !! test
27356 2. Link fragments separated by <i> and <b> tags
27357 !! options
27358 parsoid=html2wt
27359 !! html/parsoid
27360 <p>[[<i>foo</i>hello]]</p>
27361 <p>[[<b>foo</b>hello]]</p>
27362 !! wikitext
27363 [[''foo''<nowiki>hello]]</nowiki>
27364
27365 [['''foo'''<nowiki>hello]]</nowiki>
27366 !! end
27367
27368 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
27369 # this is one of the shortcomings of this format
27370 !! test
27371 3. Link fragments inside <i> and <b>
27372 !! options
27373 parsoid=html2wt
27374 !! html/parsoid
27375 <p><i>[[foo</i>]]</p>
27376 <p><b>[[foo</b>]]</p>
27377 !! wikitext
27378 ''[[foo''<nowiki>]]</nowiki>
27379
27380 '''[[foo'''<nowiki>]]</nowiki>
27381 !! end
27382
27383 !! test
27384 4. No escaping needed
27385 !! options
27386 parsoid=html2wt
27387 !! html/parsoid
27388 <p>'<span><i>bar</i></span>'
27389 '<span><b>bar</b></span>'
27390 'a:b'foo
27391 </p>
27392 !! wikitext
27393 '<span>''bar''</span>'
27394 '<span>'''bar'''</span>'
27395 'a:b'foo
27396 !! end
27397
27398 #### ----------- Paragraphs ---------------
27399 #### 1. No unnecessary escapes
27400 #### --------------------------------------
27401
27402 !! test
27403 1. No unnecessary escapes
27404 !! options
27405 parsoid=html2wt
27406 !! html/parsoid
27407 <p>bar <span>[[foo]]</span>
27408 </p><p>=bar <span>[[foo]]</span>
27409 </p><p>[[bar <span>[[foo]]</span>
27410 </p><p>]]bar <span>[[foo]]</span>
27411 </p><p>=bar <span>foo]]</span>=
27412 </p>
27413 !! wikitext
27414 bar <span><nowiki>[[foo]]</nowiki></span>
27415
27416 =bar <span><nowiki>[[foo]]</nowiki></span>
27417
27418 [[bar <span><nowiki>[[foo]]</nowiki></span>
27419
27420 ]]bar <span><nowiki>[[foo]]</nowiki></span>
27421
27422 =bar <span>foo]]</span><nowiki>=</nowiki>
27423 !!end
27424
27425 #### ----------------------- PRE --------------------------
27426 !! test
27427 1. Leading whitespace in SOL context should be escaped
27428 !! options
27429 parsoid=html2wt
27430 !! html/parsoid
27431 <p> a</p>
27432
27433 <p> a</p>
27434
27435 <p> a(tab)</p>
27436
27437 <p> a
27438 <!--cmt-->
27439 a</p>
27440
27441 <p>a
27442 b</p>
27443
27444 <p>a
27445 b</p>
27446
27447 <p>a
27448 b</p>
27449 !! wikitext
27450 <nowiki> </nowiki>a
27451
27452 <nowiki> </nowiki> a
27453
27454 a(tab)
27455
27456 <nowiki> </nowiki> a
27457 <!--cmt-->
27458 <nowiki> </nowiki>a
27459
27460 a
27461 <nowiki> </nowiki>b
27462
27463 a
27464 b
27465
27466 a
27467 b
27468 !! html/php
27469 <p> a
27470 </p><p> a
27471 </p><p> a(tab)
27472 </p><p> a
27473 a
27474 </p><p>a
27475 b
27476 </p><p>a
27477 b
27478 </p><p>a
27479 b
27480 </p>
27481 !! end
27482
27483 !! test
27484 2. Leading whitespace in non-indent-pre contexts should not be escaped
27485 !! options
27486 parsoid=html2wt
27487 !! html/parsoid
27488 <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>
27489 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
27490 <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>
27491 b</span></li>
27492 </ol>
27493 !! wikitext
27494 foo <ref>''a''
27495 b</ref>
27496 <references />
27497 !! end
27498
27499 !! test
27500 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
27501 !! options
27502 parsoid=html2wt
27503 !! html/parsoid
27504 <blockquote>
27505 <p>
27506 a
27507 <span>b</span>
27508 c</p>
27509 </blockquote>
27510 !! wikitext
27511 <blockquote>
27512 a
27513 <span>b</span>
27514 c
27515 </blockquote>
27516 !! end
27517
27518 !! test
27519 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
27520 !! options
27521 parsoid=html2wt
27522 !! html/parsoid
27523 <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>
27524 !! wikitext
27525 [[File:Foobar.jpg|thumb|caption]]
27526 !! end
27527
27528 !! test
27529 5. Nowiki escaping should account for indent-pres
27530 !! options
27531 parsoid=html2wt
27532 !! html/parsoid
27533 <pre>==foo==</pre>
27534 !! wikitext
27535 ==foo==
27536 !! end
27537
27538 !! test
27539 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
27540 !! options
27541 parsoid=html2wt
27542 !! html/parsoid
27543 <pre>
27544 * foo
27545 * bar
27546 </pre>
27547 !! wikitext
27548 * foo
27549 * bar
27550 !! end
27551
27552 !! test
27553 Whitespace scrubbing in SOL position should account for SOL-sensitive wikitext markup
27554 !! options
27555 parsoid = {
27556 "modes": ["html2wt"],
27557 "scrubWikitext": true
27558 }
27559 !! html/parsoid
27560 <p> foo</p>
27561 <p> %foo</p>
27562 <p> *foo</p>
27563 <p> #foo</p>
27564 <p> =foo=</p>
27565 <p><link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}"> *foo</p>
27566 <p> <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid="{}">*foo</p>
27567 <p> <!--boo-->*foo</p>
27568 <p><!--boo--> *foo</p>
27569 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> foo</p>
27570 <p><!--a--> <!--b--> <!--c--> <!--d--> <!--e--> *foo</p>
27571 !! wikitext
27572 foo
27573
27574 %foo
27575
27576 <nowiki/>*foo
27577
27578 <nowiki/>#foo
27579
27580 <nowiki/>=foo=
27581
27582 [[Category:Foo]]
27583 <nowiki/>*foo
27584
27585 [[Category:Foo]]
27586 <nowiki>*</nowiki>foo
27587
27588 <nowiki/><!--boo-->*foo
27589
27590 <!--boo--><nowiki/>*foo
27591
27592 <!--a--><!--b--><!--c--><!--d--><!--e-->foo
27593
27594 <!--a--><nowiki/><!--b--><!--c--><!--d--><!--e-->*foo
27595 !! end
27596
27597 #### --------------- Behavior Switches --------------------
27598
27599 !! test
27600 1. Valid behavior switches should be escaped
27601 !! options
27602 parsoid=html2wt
27603 !! html/parsoid
27604 __TOC__
27605 <i>__TOC__</i>
27606 !! wikitext
27607 <nowiki>__TOC__</nowiki>
27608 ''<nowiki>__TOC__</nowiki>''
27609 !! end
27610
27611 !! test
27612 2. Invalid behavior switches should not be escaped
27613 !! options
27614 parsoid=html2wt
27615 !! html/parsoid
27616 __TOO__
27617 __|__
27618 !! wikitext
27619 __TOO__
27620 __|__
27621 !! end
27622
27623 # We use indent-pre as an indirect way to test for sol-transparent behavior.
27624 !! test
27625 Behavior switches should be SOL-transparent
27626 !! options
27627 parsoid=html2wt
27628 !! html/parsoid
27629 <meta property="mw:PageProp/toc" />
27630
27631 <!-- this one's bogus -->
27632 <pre>__TOO__</pre>
27633
27634 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
27635
27636 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
27637 !! wikitext
27638 __TOC__
27639
27640 <!-- this one's bogus -->
27641 __TOO__
27642
27643 __TOC__ foo
27644
27645 __TOC__
27646 bar
27647 !! end
27648
27649 #### --------------- HTML tags ---------------
27650 #### 1. a tags
27651 #### 2. other tags
27652 #### 3. multi-line html tag
27653 #### 4. extension tags
27654 #### -----------------------------------------
27655 !! test
27656 1. a tags
27657 !! options
27658 parsoid=html2wt
27659 !! html/parsoid
27660 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
27661 !! wikitext
27662 <a href="http://google.com">google</a>
27663 !! end
27664
27665 !! test
27666 2. other tags
27667 !! options
27668 parsoid=html2wt
27669 !! html/parsoid
27670 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
27671 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
27672 <li> &lt;td&gt;</li></ul>
27673
27674 !! wikitext
27675 * <nowiki><div>foo</div></nowiki>
27676 * <nowiki><div style="color:red">foo</div></nowiki>
27677 * <nowiki><td></nowiki>
27678 !! end
27679
27680 !! test
27681 3. multi-line html tag
27682 !! options
27683 parsoid=html2wt
27684 !! html/parsoid
27685 <p>&lt;div
27686 &gt;foo&lt;/div
27687 &gt;
27688 </p>
27689 !! wikitext
27690 <nowiki><div
27691 >foo</div
27692 ></nowiki>
27693 !! end
27694
27695 !! test
27696 4. extension tags
27697 !! options
27698 parsoid=html2wt
27699 !! html/parsoid
27700 <p>&lt;ref&gt;foo&lt;/ref&gt;
27701 </p><p>&lt;ref&gt;bar
27702 </p><p>baz&lt;/ref&gt;
27703 </p>
27704 !! wikitext
27705 <nowiki><ref>foo</ref></nowiki>
27706
27707 <nowiki><ref>bar</nowiki>
27708
27709 baz<nowiki></ref></nowiki>
27710 !! end
27711
27712 !! test
27713 Parsoid: newline inducing block nodes don't suppress <nowiki>
27714 !! options
27715 parsoid=html2wt
27716 !! html/parsoid
27717 a<h1>foo</h1>
27718 !! wikitext
27719 <nowiki> </nowiki>a
27720
27721 = foo =
27722 !! end
27723
27724 #### --------------- Others ---------------
27725 !! test
27726 Escaping nowikis
27727 !! options
27728 parsoid=html2wt
27729 !! html/parsoid
27730 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
27731 </p>
27732 !! wikitext
27733 &lt;nowiki&gt;foo&lt;/nowiki&gt;
27734 !! end
27735
27736 ## The quote-char in the input is necessary for triggering the bug
27737 !! test
27738 (T54035) Nowiki-escaping should not get tripped by " :" in text
27739 !! options
27740 parsoid=html2wt
27741 !! html/parsoid
27742 <p>foo's bar :</p>
27743 !! wikitext
27744 foo's bar :
27745 !! end
27746
27747 #----------- End of wikitext escaping tests --------------
27748
27749 !! test
27750
27751 Tag-like HTML structures are passed through as text
27752 !! wikitext
27753 <x y>
27754
27755 <x.y>
27756
27757 <x-y>
27758
27759 1>2
27760
27761 x<y
27762
27763 a>b
27764
27765 1<d e>f
27766 !! html
27767 <p>&lt;x y&gt;
27768 </p><p>&lt;x.y&gt;
27769 </p><p>&lt;x-y&gt;
27770 </p><p>1&gt;2
27771 </p><p>x&lt;y
27772 </p><p>a&gt;b
27773 </p><p>1&lt;d e&gt;f
27774 </p>
27775 !! end
27776
27777 !! test
27778 HTML tag with necessary entities in attributes
27779 !! wikitext
27780 <span title="&amp;amp;">foo</span>
27781 !! html
27782 <p><span title="&amp;amp;">foo</span>
27783 </p>
27784 !! end
27785
27786 !! test
27787 HTML tag with 'unnecessary' entity encoding in attributes
27788 !! wikitext
27789 <span title="&amp;">foo</span>
27790 !! html
27791 <p><span title="&amp;">foo</span>
27792 </p>
27793 !! end
27794
27795 !! test
27796 HTML tag with broken attribute value quoting
27797 !! options
27798 parsoid=wt2html,html2html
27799 !! wikitext
27800 <span title="Hello world>Foo</span>
27801 !! html/php
27802 <p><span title="Hello world">Foo</span>
27803 </p>
27804 !! html/parsoid
27805 <p><span title="Hello world">Foo</span></p>
27806 !! end
27807
27808 !! test
27809 Self-closed tag with broken attribute value quoting
27810 !! options
27811 parsoid=wt2html,html2html
27812 !! wikitext
27813 <div title="Hello world />Foo
27814 !! html/php+tidy
27815 <div title="Hello world"></div><p>Foo
27816 </p>
27817 !! html/parsoid
27818 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
27819 !! end
27820
27821 !! test
27822 Table with broken attribute value quoting
27823 !! options
27824 parsoid=wt2html,html2html
27825 !! wikitext
27826 {|
27827 | title="Hello world|Foo
27828 |}
27829 !! html/php
27830 <table>
27831 <tr>
27832 <td title="Hello world">Foo
27833 </td></tr></table>
27834
27835 !! html/parsoid
27836 <table>
27837 <tr>
27838 <td title="Hello world">Foo
27839 </td></tr></table>
27840
27841 !! end
27842
27843 !! test
27844 Table with broken attribute value quoting on consecutive lines
27845 !! options
27846 parsoid=wt2html,html2html
27847 !! wikitext
27848 {|
27849 | title="Hello world|Foo
27850 | style="color:red|Bar
27851 |}
27852 !! html/php
27853 <table>
27854 <tr>
27855 <td title="Hello world">Foo
27856 </td>
27857 <td style="color:red">Bar
27858 </td></tr></table>
27859
27860 !! html/parsoid
27861 <table><tbody>
27862 <tr>
27863 <td title="Hello world">Foo
27864 </td><td style="color: red">Bar
27865 </td></tr></tbody></table>
27866
27867 !! end
27868
27869 !!test
27870 Accept empty td cell attribute
27871 !! wikitext
27872 {|
27873 | align="center" |foo|| |
27874 |}
27875 !! html
27876 <table>
27877 <tr>
27878 <td align="center">foo</td>
27879 <td>
27880 </td></tr></table>
27881
27882 !!end
27883
27884 !!test
27885 Non-empty attributes in th-cells
27886 !! wikitext
27887 {|
27888 !Foo!! style="color: red" |Bar
27889 |}
27890 !! html
27891 <table>
27892 <tr>
27893 <th>Foo</th>
27894 <th style="color: red">Bar
27895 </th></tr></table>
27896
27897 !!end
27898
27899 !!test
27900 Accept empty attributes in th-cells
27901 !! wikitext
27902 {|
27903 !|foo!!|bar
27904 |}
27905 !! html
27906 <table>
27907 <tr>
27908 <th>foo</th>
27909 <th>bar
27910 </th></tr></table>
27911
27912 !!end
27913
27914 !!test
27915 Empty table rows go away
27916 !! wikitext
27917 {|
27918 |Hello
27919 |there
27920 |- class="foo"
27921 |-
27922 |}
27923 !! html
27924 <table>
27925 <tr>
27926 <td>Hello
27927 </td>
27928 <td>there
27929 </td></tr>
27930
27931 </table>
27932
27933 !! end
27934
27935 ###
27936 ### Parsoid-centric tests for testing RTing of inter-element separators
27937 ### Edge cases not tested by existing parser tests and specific to
27938 ### Parsoid-specific serialization strategies.
27939 ###
27940
27941 !!test
27942 RT-ed inter-element separators should be valid separators
27943 !! wikitext
27944 {|
27945 |- [[foo]]
27946 |}
27947 !! html/php
27948 <table>
27949
27950 </table>
27951
27952 !! html/parsoid
27953 <table>
27954 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
27955 </tbody></table>
27956 !!end
27957
27958 # Parsoid-only test of a DOM pass
27959 !!test
27960 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
27961 !! wikitext
27962 {|
27963 |<small>foo
27964 bar
27965 |}
27966
27967 {|
27968 |<small>foo<small>
27969 |}
27970 !! html/parsoid
27971 <table>
27972 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
27973 <p>bar</p></small></td></tr>
27974 </tbody></table>
27975
27976 <table>
27977 <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>
27978 </tbody></table>
27979 !!end
27980
27981 # Note that the "style" attribute is really a template parameter here.
27982 # The = would have to be {{=}} if you wanted the literal.
27983 !!test
27984 Empty TD followed by TD with tpl-generated attribute
27985 !! wikitext
27986 {|
27987 |-
27988 |
27989 |{{echo|style='color:red'}}|foo
27990 |}
27991 !! html
27992 <table>
27993
27994 <tr>
27995 <td>
27996 </td>
27997 <td>foo
27998 </td></tr></table>
27999
28000 !!end
28001
28002 !!test
28003 Indented table with an empty td
28004 !! wikitext
28005 {|
28006 |-
28007 |
28008 |foo
28009 |}
28010 !! html
28011 <table>
28012
28013 <tr>
28014 <td>
28015 </td>
28016 <td>foo
28017 </td></tr></table>
28018
28019 !!end
28020
28021 !! test
28022 Indented table with blank lines in between (T85627)
28023 !! wikitext
28024 {|
28025 |foo
28026
28027
28028 |}
28029 !! html/php
28030 <table>
28031 <tr>
28032 <td>foo
28033 <p><br />
28034 </p>
28035 </td></tr></table>
28036
28037 !! html/parsoid
28038 <table>
28039 <tbody><tr><td>foo
28040 <p>
28041 <br /></p></td></tr>
28042 </tbody></table>
28043 !! end
28044
28045 !!test
28046 Indented block & table
28047 !! wikitext
28048 <div>foo</div>
28049 {|
28050 |foo
28051 |}
28052 !! html/php
28053 <div>foo</div>
28054 <table>
28055 <tr>
28056 <td>foo
28057 </td></tr></table>
28058
28059 !! html/parsoid
28060 <div data-parsoid='{"stx":"html"}'>foo</div>
28061 <table><tbody>
28062 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
28063 </tbody></table>
28064 !!end
28065
28066 !! test
28067 Indent and comment before table row
28068 !! wikitext
28069 {|
28070 <!--hi-->|-
28071 |there
28072 |}
28073 !! html/php
28074 <table>
28075
28076 <tr>
28077 <td>there
28078 </td></tr></table>
28079
28080 !! html/parsoid
28081 <table>
28082 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
28083 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
28084 </tbody></table>
28085 !! end
28086
28087 # PHP parser omits empty TR
28088 !!test
28089 Empty TR followed by a template-generated TR
28090 !! wikitext
28091 {|
28092 |-
28093 {{echo|<tr><td>foo</td></tr>}}
28094 |}
28095 !! html/php+tidy
28096 <table>
28097
28098 <tbody><tr><td>foo</td></tr>
28099 </tbody></table>
28100 !! html/parsoid
28101 <table>
28102 <tbody>
28103 <tr class='mw-empty-elt'></tr>
28104 <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}}]}'>
28105 <td>foo</td></tr>
28106 </tbody></table>
28107 !!end
28108
28109 ## PHP and parsoid output differ for this; as usual PHP omits empty
28110 ## elements, and since it strips the comments the TR is empty.
28111 !!test
28112 Empty TR followed by mixed-ws-comment line should RT correctly
28113 !! wikitext
28114 {|
28115 |-
28116 <!--c-->
28117 |-
28118 <!--c--> <!--d-->
28119 |}
28120 !! html/php+tidy
28121 <table>
28122
28123
28124 </table>
28125 !! html/parsoid
28126 <table>
28127 <tbody>
28128 <tr class='mw-empty-elt'></tr>
28129 <!--c-->
28130 <tr>
28131 <!--c--> </tr><!--d-->
28132 </tbody></table>
28133
28134 !!end
28135
28136 !!test
28137 Multi-line image caption generated by templates with/without trailing newlines
28138 !! wikitext
28139 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
28140 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
28141 !! html/parsoid
28142 <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>
28143 <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>
28144 !!end
28145
28146 !! test
28147 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
28148 !! options
28149 parsoid=html2wt
28150 !! html/parsoid
28151 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>foo&lt;/includeonly>"}' data-mw='{"src":"&lt;includeonly>foo&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><p>new para</p>
28152
28153 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
28154 !! wikitext
28155 <includeonly>foo</includeonly>
28156 new para
28157
28158 [[Category:Foo]]
28159
28160 = new heading =
28161 !! end
28162
28163 ## PHP emits broken html for this, and since this is primarily
28164 ## a Parsoid serializer test, marking this Parsoid only
28165 !!test
28166 Improperly nested inline or quotes tags with whitespace in between
28167 !! wikitext
28168 <span> <s>x</span> </s>
28169 ''' ''x''' ''
28170 !! html/parsoid
28171 <p><span> <s>x</s></span><s> </s>
28172 <b> <i>x</i></b><i> </i>
28173 </p>
28174 !!end
28175
28176 !!test
28177 Encapsulate protected attributes from wt
28178 !! wikitext
28179 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
28180
28181 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
28182 |ok
28183 |}
28184 !! html/parsoid
28185 <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>
28186
28187 <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">
28188 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'>ok</td></tr>
28189 </tbody></table>
28190 !!end
28191
28192 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
28193 ## Having nested or stray pre tags results in the attempt to add duplicates,
28194 ## causing an assertion fail. This test tries to prevent that situation.
28195 !! test
28196 Ensure ParagraphWrapper can deal with stray closing pre tags
28197 !! options
28198 parsoid=wt2html
28199 !! wikitext
28200 plain text</pre>
28201 !! html/parsoid
28202 <p>plain text</p>
28203 !! end
28204
28205 ## Remex doesn't account for fostered content.
28206 !! test
28207 1. Ensure fostered text content is wrapped in element nodes
28208 !! options
28209 parsoid=wt2html
28210 !! wikitext
28211 <table>hi</table><table>ho</table>
28212 !! html/php+tidy
28213 hi<table></table>ho<table></table>
28214 !! html/parsoid
28215 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>hi</p><table data-parsoid='{"stx":"html"}'></table><p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'>ho</p><table data-parsoid='{"stx":"html"}'></table>
28216 !! end
28217
28218 ## Remex doesn't account for fostered content.
28219 !! test
28220 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
28221 !! options
28222 parsoid=wt2html,wt2wt
28223 !! wikitext
28224 <table>
28225 <tr> || ||
28226 <td> a
28227 </table>
28228 !! html/php+tidy
28229 || ||
28230 <table>
28231 <tbody><tr><td> a
28232 </td></tr></tbody></table>
28233 !! html/parsoid
28234 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true}'> || ||</p>
28235 <table data-parsoid='{"stx":"html"}'>
28236 <tbody><tr data-parsoid='{"stx":"html","autoInsertedEnd":true}'><td data-parsoid='{"stx":"html","autoInsertedEnd":true}'> a
28237 </td></tr></tbody></table>
28238 !! end
28239
28240 ## Remex doesn't account for fostered content.
28241 !! test
28242 Encapsulation properly handles null DSR information from foster box
28243 !! options
28244 parsoid=wt2html,wt2wt
28245 !! wikitext
28246 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
28247 !! html/parsoid
28248 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;table>foo&lt;tr>&lt;td>bar&lt;/td>&lt;/tr>&lt;/table>"}},"i":0}}]}'>foo</p><table about="#mwt1" data-parsoid='{"stx":"html"}'><tbody><tr><td>bar</td></tr></tbody></table>
28249 !! end
28250
28251 ## Remex doesn't account for fostered content.
28252 !! test
28253 1. Encapsulate foster-parented transclusion content
28254 !! options
28255 parsoid=wt2wt,wt2html
28256 !! wikitext
28257 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
28258 !! html/php+tidy
28259 foo<table><tbody><tr><td>bar</td></tr></tbody></table>
28260 !! html/parsoid
28261 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;tr>&lt;td>bar&lt;/td>&lt;/tr>"}},"i":0}},"&lt;/table>"]}'>foo</p><table about="#mwt2" data-parsoid='{"stx":"html"}'><tbody><tr><td>bar</td></tr></tbody></table>
28262 !! end
28263
28264 !! test
28265 2. Encapsulate foster-parented transclusion content
28266 !! options
28267 parsoid=wt2wt,wt2html
28268 !! wikitext
28269 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
28270 !! html/parsoid
28271 <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>
28272 <table>
28273 <tbody>
28274 <tr>
28275 <td>bar</td>
28276 </tr>
28277 </tbody>
28278 </table>
28279 !! end
28280
28281 !! test
28282 3. Encapsulate foster-parented transclusion content
28283 !! options
28284 parsoid=wt2wt,wt2html
28285 !! wikitext
28286 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28287 !! html/parsoid
28288 <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;]}">
28289 <p>foo</p>
28290 </div>
28291 <table>
28292 <tbody>
28293 <tr>
28294 <td>bar</td>
28295 </tr>
28296 </tbody>
28297 </table>
28298 !! end
28299
28300 !! test
28301 4. Encapsulate foster-parented transclusion content
28302 !! options
28303 parsoid=wt2wt,wt2html
28304 !! wikitext
28305 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
28306 !! html/parsoid
28307 <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;]}">
28308 <p>foo</p>
28309 </div>
28310 <table>
28311 <tbody>
28312 <tr>
28313 <td>bar</td>
28314 </tr>
28315 </tbody>
28316 </table>
28317 !! end
28318
28319 ## Remex doesn't account for fostered content.
28320 !! test
28321 5. Encapsulate foster-parented transclusion content
28322 !!options
28323 parsoid=wt2wt,wt2html
28324 !! wikitext
28325 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
28326 !! html/php+tidy
28327 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
28328 !! html/parsoid
28329 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>&lt;tr>&lt;td>&lt;div>&lt;p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;/p>&lt;/div>&lt;/td>foo"}},"i":0}},"&lt;/tr>&lt;/table>"]}'>foo</p><table about="#mwt2" data-parsoid='{"stx":"html"}'><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table>
28330 !! end
28331
28332 ## Remex doesn't account for fostered content.
28333 !! test
28334 6. Encapsulate foster-parented transclusion content
28335 !! options
28336 parsoid=wt2wt,wt2html
28337 !! wikitext
28338 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
28339 !! html/php+tidy
28340 foo<table><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p>ok</p>
28341 !! html/parsoid
28342 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>&lt;tr>&lt;td>&lt;div>&lt;p>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo&lt;/p>&lt;/div>&lt;/td>foo&lt;/tr>&lt;/table>"}},"i":0}}]}'>foo</p><table about="#mwt2" data-parsoid='{"stx":"html"}'><tbody><tr><td><div><p>foo</p></div></td></tr></tbody></table><p data-parsoid='{"stx":"html"}'>ok</p>
28343 !! end
28344
28345 !! test
28346 7. Encapsulate foster-parented transclusion content
28347 !!options
28348 parsoid=wt2wt,wt2html
28349 !! wikitext
28350 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
28351 !! html/parsoid
28352 <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>
28353 <table>
28354 <tbody>
28355 <tr>
28356 <td>bar</td>
28357 </tr>
28358 </tbody>
28359 </table>
28360 !! end
28361
28362 ## Remex doesn't account for fostered content.
28363 # Note that the wt is broken on purpose: the = should be {{=}} if you
28364 # don't want it to be a template parameter key.
28365 !! test
28366 8. Encapsulate foster-parented transclusion content
28367 !! options
28368 parsoid=wt2wt,wt2html
28369 !! wikitext
28370 {{echo|a
28371 }}{|{{echo|style='color:red'}}
28372 |-
28373 |b
28374 |}
28375 !! html/php+tidy
28376 <p>a
28377 </p>
28378 <table>
28379
28380 <tbody><tr>
28381 <td>b
28382 </td></tr></tbody></table>
28383 !! html/parsoid
28384 <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}'>a</p><span about="#mwt1">
28385 </span><p about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE","pi":[[{"k":"style","named":true}]]}' data-mw='{"parts":["{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"style":{"wt":"&apos;color:red&apos;"}},"i":0}},"\n|-\n|b\n|}"]}'>{{{1}}}</p><table about="#mwt3">
28386 <tbody><tr>
28387 <td>b
28388 </td></tr></tbody></table>
28389 !! end
28390
28391 ## Remex doesn't account for fostered content.
28392 !! test
28393 9. Encapsulate foster-parented transclusion content
28394 !!options
28395 parsoid=wt2wt,wt2html
28396 !! wikitext
28397 <table>{{echo|hi</table>hello}}
28398 !! html/php+tidy
28399 hi<table></table><p>hello
28400 </p>
28401 !! html/parsoid
28402 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;/table>hello"}},"i":0}}]}'>hi</p><table about="#mwt2"></table><p about="#mwt2">hello</p>
28403 !! end
28404
28405 !! test
28406 Table in fosterable position
28407 !!options
28408 parsoid=wt2html
28409 !! wikitext
28410 {{OpenTable}}
28411 <div>
28412 {|
28413 |}
28414 </div>
28415 |}
28416 !! html/parsoid
28417 <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">
28418 </span>
28419 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
28420
28421 <table>
28422 </table>
28423 !! end
28424
28425 # Parsoid only for T66747
28426 !! test
28427 Properly encapsulate empty-content transclusions in fosterable positions
28428 !! wikitext
28429 <table>
28430 {{#if:|
28431 <td>foo</td>
28432 }}
28433 </table>
28434 !! html/parsoid
28435 <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"}]]}'>
28436
28437 </table>
28438 !! end
28439
28440 ## No longer captures its original intention
28441 !! test
28442 Always encapsulate foster box when template range is expanded to table
28443 !! options
28444 disabled
28445 parsoid=wt2wt
28446 !! wikitext
28447 {|
28448 hello
28449 {{OpenTable}}
28450 |}
28451 !! html/parsoid
28452
28453 !! end
28454
28455 !! test
28456 T115289: Unclosed table
28457 !! wikitext
28458 {{echo|<table>}}<!--c-->[[Category:Two]]
28459 !! html/parsoid
28460 <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>
28461 !! end
28462
28463 !! test
28464 T115289: Don't migrate newlines out of tables with fostered content
28465 !! wikitext
28466 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
28467 !! html/parsoid
28468 <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>
28469 !! end
28470
28471 !! test
28472 T73074: More fostering fun
28473 !! wikitext
28474 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
28475 !! html/parsoid
28476 <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>
28477 !! end
28478
28479 !!test
28480 Support <object> element with .data attribute
28481 !!options
28482 parsoid=html2wt
28483 !! html/parsoid
28484 <object data="test.swf"></object>
28485 !! wikitext
28486 <object data="test.swf"></object>
28487 !!end
28488
28489 !! test
28490 Don't block XML namespace declaration
28491 !! wikitext
28492 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28493 !! html/php
28494 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
28495 </p>
28496 !! html/parsoid
28497 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
28498 !! end
28499
28500 # -----------------------------------------------------------------
28501 # The following section of tests are primarily to spec requirements
28502 # around Parsoid's serialization (old, new, edited content)
28503 #
28504 # All these tests are marked Parsoid html2wt and html2html only
28505 # ----------------------------------------------------------------
28506
28507 !! test
28508 Ignore rel attribute in a-tags during serialization to url-links
28509 !! options
28510 parsoid=html2wt
28511 !! html/parsoid
28512 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
28513 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
28514 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
28515 !! wikitext
28516 http://en.wikipedia.org/wiki/Foobar
28517 http://en.wikipedia.org/wiki/Foobar
28518 http://en.wikipedia.org/wiki/Foobar
28519 !! end
28520
28521 # 'mi' is a localinterwiki prefix as well as a language
28522 !! test
28523 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
28524 !! options
28525 parsoid=html2wt
28526 !! html/parsoid
28527 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
28528 !! wikitext
28529 [[Foo]]
28530 !! end
28531
28532 !! test
28533 Parsoid should accept interwiki shortcuts
28534 !! options
28535 parsoid=html2wt
28536 !! html/parsoid
28537 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
28538 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
28539 <a href='./fr:Foo'>Foo</a></p>
28540 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
28541 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
28542 <a href='fr%3AFoo'>Foo</a></p>
28543 <p><a href='FR%3AFoo'>Foo</a>
28544 <a href='./FR:Foo'>Foo</a></p>
28545 !! wikitext
28546 [[:fr:Foo|Foo]]
28547 [[:fr:Foo|Foo]]
28548 [[:fr:Foo|Foo]]
28549
28550 [[:fr:Foo|Foo]]
28551 [[:fr:Foo|Foo]]
28552 [[:fr:Foo|Foo]]
28553
28554 [[:fr:Foo|Foo]]
28555 [[:fr:Foo|Foo]]
28556 !! end
28557
28558 !! test
28559 Parsoid should not accept invalid interwiki shortcuts
28560 !! options
28561 parsoid=html2wt
28562 !! html/parsoid
28563 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
28564 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
28565 <a href='news:Foo'>Foo</a></p>
28566 !! wikitext
28567 [news:Foo Foo]
28568 [news:Foo Foo]
28569 [news:Foo Foo]
28570 !! end
28571
28572 # See T93839
28573 !! test
28574 New wikilinks should be serialized properly
28575 !! options
28576 parsoid=html2wt
28577 !! html/parsoid
28578 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
28579 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
28580 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
28581 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
28582 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
28583 !! wikitext
28584 [[Foo]]
28585 [[Foo]]
28586 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
28587 http://en.wikipedia.org/wiki/Foo
28588 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
28589 !! end
28590
28591 !! test
28592 New wiki links (href variations)
28593 !! options
28594 parsoid=html2wt
28595 !! html/parsoid
28596 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28597 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
28598 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
28599 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
28600 !! wikitext
28601 [[Foo_bar]]
28602 [[Foo_bar]]
28603 [[Foo_bar]]
28604 [[Toxine bactérienne]]
28605 !! end
28606
28607 !! test
28608 New wiki links (content string variations)
28609 !! options
28610 parsoid=html2wt
28611 !! html/parsoid
28612 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
28613 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
28614 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
28615 !! wikitext
28616 [[Foo_bar]]
28617 [[Foo bar]]
28618 [[Foo_bar|./Foo_bar]]
28619 !! end
28620
28621 !! test
28622 New category links (href variations)
28623 !! options
28624 parsoid=html2wt
28625 !! html/parsoid
28626 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
28627 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
28628 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
28629 !! wikitext
28630 [[Category:Toxine bactérienne]]
28631 [[Category:Toxine bactérienne]]
28632 [[Category:Toxine bactérienne]]
28633 !! end
28634
28635 !! test
28636 New sol transparent links don't need indent-pre nowiki protection
28637 !! options
28638 parsoid=html2wt
28639 language=de
28640 !! html/parsoid
28641 <link rel="mw:PageProp/redirect" href="./Main_Page">
28642 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
28643 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
28644 !! wikitext
28645 #WEITERLEITUNG [[Main Page]]
28646 <!-- this is good --> [[Category:Good]]
28647 <!-- this is great --> [[Kategorie:Great]]
28648 !! end
28649
28650 !! test
28651 New interlanguage links (href variations)
28652 !! options
28653 parsoid=html2wt
28654 !! html/parsoid
28655 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
28656 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
28657 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
28658 !! wikitext
28659 [[es:Toxine bactérienne]]
28660 [[es:Toxine_bactérienne]]
28661 [[es:Toxine_bactérienne]]
28662 !! end
28663
28664 !! test
28665 Image: Modifying size of an image (1)
28666 !! options
28667 parsoid={
28668 "modes": ["wt2wt"],
28669 "changes": [
28670 ["img[height]", "attr", "height", "22"],
28671 ["img[width]", "attr", "width", "200"]
28672 ]
28673 }
28674 !! wikitext
28675 [[Image:Foobar.jpg|230x230px]]
28676 !! wikitext/edited
28677 [[Image:Foobar.jpg|200x200px]]
28678 !!end
28679
28680 !! test
28681 Image: Modifying size of an image (2)
28682 !! options
28683 parsoid={
28684 "modes": ["wt2wt"],
28685 "changes": [
28686 ["img[height]", "attr", "height", "100"],
28687 ["img[width]", "attr", "width", "500"]
28688 ]
28689 }
28690 !! wikitext
28691 [[Image:Foobar.jpg|230x230px]]
28692 !! wikitext/edited
28693 [[Image:Foobar.jpg|500x500px]]
28694 !!end
28695
28696 # Change in size is ignored so long as class='mw-default-size'
28697 !! test
28698 Image: Modifying size of an image (3)
28699 !! options
28700 parsoid={
28701 "modes": ["wt2wt"],
28702 "changes": [
28703 ["figure[class]", "removeClass", "mw-default-size"],
28704 ["figure img", "attr", "height", "19"],
28705 ["figure img", "attr", "width", "170"]
28706 ]
28707 }
28708 !! wikitext
28709 [[Image:Foobar.jpg|thumb]]
28710 !! wikitext/edited
28711 [[Image:Foobar.jpg|thumb|170x170px]]
28712 !!end
28713
28714 !! test
28715 Image: Modifying alignment of an image (T50665)
28716 !! options
28717 parsoid={
28718 "modes": ["wt2wt"],
28719 "changes": [
28720 ["figure[class]", "removeClass", "mw-halign-right"],
28721 ["figure[class]", "addClass", "mw-halign-left"]
28722 ]
28723 }
28724 !! wikitext
28725 [[Image:Foobar.jpg|thumb|caption|right]]
28726 !! wikitext/edited
28727 [[Image:Foobar.jpg|thumb|caption|left]]
28728 !! end
28729
28730 !! test
28731 Image: Modifying mw-default-size of an frameless image (T64805)
28732 !! options
28733 parsoid={
28734 "modes": ["wt2wt"],
28735 "changes": [
28736 ["figure.mw-default-size", "removeClass", "mw-default-size"]
28737 ]
28738 }
28739 !! wikitext
28740 [[Image:Foobar.jpg|frameless|right]]
28741 !! wikitext/edited
28742 [[Image:Foobar.jpg|frameless|right|220x220px]]
28743 !! end
28744
28745 !! test
28746 Image: Modifying valign of an image (T51221)
28747 !! options
28748 parsoid={
28749 "modes": ["wt2wt"],
28750 "changes": [
28751 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
28752 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
28753 ]
28754 }
28755 !! wikitext
28756 [[File:Foobar.jpg|20px|middle]]
28757 !! wikitext/edited
28758 [[File:Foobar.jpg|20px|text-top]]
28759 !! end
28760
28761 !! test
28762 Image: Modifying alt attribute of an image (T58400)
28763 !! options
28764 parsoid={
28765 "modes": ["wt2wt"],
28766 "changes": [
28767 ["img[alt]", "attr", "alt", "some alternate edited text"]
28768 ]
28769 }
28770 !! wikitext
28771 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
28772 !! wikitext/edited
28773 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
28774 !!end
28775
28776 !! test
28777 Image: Modifying caption of an image
28778 !! options
28779 parsoid={
28780 "modes": ["wt2wt"],
28781 "changes": [
28782 ["figcaption", "text", "new caption"]
28783 ]
28784 }
28785 !! wikitext
28786 [[Image:Foobar.jpg|thumb|original caption]]
28787 !! wikitext/edited
28788 [[Image:Foobar.jpg|thumb|new caption]]
28789 !!end
28790
28791 !! test
28792 Image: empty alt attribute (T50924)
28793 !! wikitext
28794 [[File:Foobar.jpg|thumb|alt=|bar]]
28795 !! html/php+tidy
28796 <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>
28797 !! html/parsoid
28798 <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>
28799 !! end
28800
28801 !! test
28802 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
28803 !! options
28804 parsoid=html2wt
28805 language=ar
28806 disabled
28807 !! html/parsoid
28808 <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>
28809 !! wikitext
28810 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
28811 !! end
28812
28813 !! test
28814 Image: Block level image should have \n before and after
28815 !! wikitext
28816 123
28817 [[File:Foobar.jpg|right|thumb|150x150px]]
28818 456
28819 !! html/parsoid
28820 <p>123</p>
28821 <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>
28822 <p>456</p>
28823 !! end
28824
28825 !! test
28826 Image: New block level image should have \n before and after (existing content)
28827 !! wikitext
28828 123
28829 [[File:Foobar.jpg|right|thumb|150x150px]]
28830 456
28831 !! html/parsoid
28832 <p>123</p>
28833 <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>
28834 <p>456</p>
28835 !! end
28836
28837 !! test
28838 Image: upright option (parsoid)
28839 !! wikitext
28840 [[File:Foobar.jpg|thumb|upright|caption]]
28841 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
28842 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
28843 !! html/parsoid
28844 <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>
28845 <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>
28846 <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>
28847 !! end
28848
28849 !! test
28850 Image: upright option is ignored on inline and frame images (parsoid)
28851 !! wikitext
28852 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
28853 !! html/parsoid
28854 <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>
28855 !! end
28856
28857 !! test
28858 Image: in template parameter with empty parameter
28859 !! wikitext
28860 {{echo|[[File:Foobar.jpg|link=]]}}
28861 !! html/parsoid
28862 <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>
28863 !! end
28864
28865 !! test
28866 Image: from basic HTML (1)
28867 !! options
28868 parsoid=html2wt
28869 !! html/parsoid
28870 <span typeof="mw:Image">
28871 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28872 </span>
28873 !! wikitext
28874 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28875 !! end
28876
28877 !! test
28878 Image: from basic HTML (2)
28879 !! options
28880 parsoid=html2wt
28881 !! html/parsoid
28882 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
28883 !! wikitext
28884 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
28885 !! end
28886
28887 !! test
28888 Image: from basic HTML (3)
28889 !! options
28890 parsoid=html2wt
28891 !! html/parsoid
28892 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
28893 !! wikitext
28894 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
28895 !! end
28896
28897 !! test
28898 Image: from basic HTML (4)
28899 !! options
28900 parsoid=html2wt
28901 !! html/parsoid
28902 <img src="./File:Foobar.jpg">
28903 !! wikitext
28904 [[File:Foobar.jpg|link=]]
28905 !! end
28906
28907 !! test
28908 Image: Invalid title as link
28909 !! wikitext
28910 [[File:Foobar.jpg|link=<]]
28911 !! html/php
28912 <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>
28913 </p>
28914 !! html/parsoid
28915 <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>
28916 !! end
28917
28918 !! test
28919 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
28920 !! options
28921 parsoid=html2wt
28922 !! html/parsoid
28923 <ul>
28924 <li><p>foo</p></li>
28925 </ul>
28926 !! wikitext
28927 * foo
28928 !! end
28929
28930 !! test
28931 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
28932 !! options
28933 parsoid=html2wt
28934 !! html/parsoid
28935 <ul> <li>foo</li></ul>
28936 !! wikitext
28937 * foo
28938 !! end
28939
28940 !! test
28941 Don't strip leading whitespace when handling indent-pre suppressing tags
28942 !! options
28943 parsoid=html2wt
28944 !! html/parsoid
28945 <table>
28946 <tr><td> indented row</td></tr>
28947 </table>
28948 <blockquote><p>
28949 <b>This is very bold of you!</b>
28950 </p>
28951 <table><tr><td>
28952 indented cell (no pre-wrapping!)
28953 </td></tr></table>
28954 </blockquote>
28955 <p>foo</p>
28956 <div>bar</div>
28957 !! wikitext
28958 {|
28959 | indented row
28960 |}
28961 <blockquote>
28962 '''This is very bold of you!'''
28963
28964 {|
28965 |
28966 indented cell (no pre-wrapping!)
28967 |}
28968 </blockquote>
28969 foo
28970 <div>bar</div>
28971 !! end
28972
28973 !! test
28974 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
28975 !! options
28976 parsoid=html2wt
28977 !! html/parsoid
28978 <p>foo</p>
28979 <span>bar</span>
28980
28981 <span>foo2
28982 </span>bar2
28983
28984 <div>foo</div>
28985 <span>bar</span>
28986
28987 <div>
28988 <span>foo</span>
28989 </div>
28990 !! wikitext
28991 foo
28992
28993 <span>bar</span>
28994
28995 <span>foo2
28996 <nowiki> </nowiki></span>bar2
28997
28998 <div>foo</div>
28999 <nowiki> </nowiki><span>bar</span>
29000
29001 <div>
29002 <nowiki> </nowiki><span>foo</span>
29003 </div>
29004 !! end
29005
29006 !! test
29007 Lists: Dont insert newlines in a serialized list item.
29008 !! options
29009 parsoid=html2wt
29010 !! html/parsoid
29011 <ul><li>a<br>b</li><li>c</li></ul>
29012 !! wikitext
29013 * a<br />b
29014 * c
29015 !! end
29016
29017 !! test
29018 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
29019 !! options
29020 parsoid={
29021 "modes": ["html2wt"],
29022 "scrubWikitext": false
29023 }
29024 !! html/parsoid
29025 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
29026 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
29027
29028 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
29029 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
29030
29031 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
29032
29033 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29034 !! wikitext
29035 == hello there [[Category:A1]] ==
29036
29037 == [[Category:A2]] hi pal ==
29038
29039 == <!--foo--> [[Category:A3]] how goes it ==
29040
29041 == it goes well [[Category:A4]] <!--bar--> ==
29042
29043 ==howdy [[Category:A5]]==
29044
29045 == __TOC__ ok ==
29046 !! end
29047
29048 !! test
29049 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
29050 !! options
29051 parsoid={
29052 "modes": ["html2wt"],
29053 "scrubWikitext": true
29054 }
29055 !! html/parsoid
29056 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
29057 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
29058
29059 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
29060 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
29061
29062 <h2><meta property="mw:PageProp/toc" /> ok</h2>
29063 !! wikitext
29064 == hello there ==
29065 [[Category:A1]]
29066 [[Category:A2]]
29067
29068 == hi pal ==
29069
29070 <!--foo-->[[Category:A3]]
29071
29072 == how goes it ==
29073
29074 == it goes well ==
29075 [[Category:A4]] <!--bar-->
29076
29077 __TOC__
29078
29079 == ok ==
29080 !! end
29081
29082 !! test
29083 Headings: Don't hoist metas that come from templates
29084 !! options
29085 parsoid={
29086 "modes": ["html2wt"],
29087 "scrubWikitext": true
29088 }
29089 !! html/parsoid
29090 <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>
29091 !! wikitext
29092 == {{echo|foo [[Category:Foo]]}} ==
29093 !! end
29094
29095 !! test
29096 Headings: Category in ref isn't hoisted
29097 !! options
29098 parsoid={
29099 "modes": ["html2wt"],
29100 "scrubWikitext": true
29101 }
29102 !! html/parsoid
29103 <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>
29104
29105 <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>
29106 !! wikitext
29107 == foo <ref>bar
29108 [[Category:Baz]] </ref> ==
29109
29110 <references />
29111 !! end
29112
29113 !! test
29114 Parsoid: Serialize positional parameters with = in them as named parameter
29115 !! options
29116 parsoid=html2wt
29117 !! html/parsoid
29118 <p about="#mwt1" typeof="mw:Transclusion"
29119 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
29120
29121 <p about="#mwt1" typeof="mw:Transclusion"
29122 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
29123
29124 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29125 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29126 <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>
29127 !! wikitext
29128 {{echo|1=f=oo}}
29129
29130 {{echo|1=f=oo|2=bar}}
29131
29132 <!--Orig params with data-parsoid has heuristics for handling = chars-->
29133 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
29134 {{echo|<nowiki>f=oo</nowiki>|bar}}
29135 !! end
29136
29137 !! test
29138 Parsoid: Serialize positional parameters with = in extlink as named parameter
29139 !! options
29140 parsoid=html2wt
29141 !! html/parsoid
29142 <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>
29143 !! wikitext
29144 {{echo|1=http://stuff?is=ok}}
29145 !! end
29146
29147 !! test
29148 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
29149 !! options
29150 parsoid=html2wt
29151 !! html/parsoid
29152 <div>a<p>b</p></div>
29153 <div>a
29154 <p>b</p></div>
29155 <div>
29156 a
29157 <p>b</p></div>
29158 !! wikitext
29159 <div>a
29160 b
29161 </div>
29162 <div>a
29163 b
29164 </div>
29165 <div>
29166 a
29167
29168 b
29169 </div>
29170 !! end
29171
29172 !! test
29173 Substrings resembling wikitext in hrefs should not get nowiki escapes
29174 !! options
29175 parsoid=html2wt
29176 !! html/parsoid
29177 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
29178 !! wikitext
29179 [[Foo''bar''baz]]
29180 !! end
29181
29182 !! test
29183 Enforce single-line context in the serializer
29184 !! options
29185 parsoid=html2wt
29186 !! html/parsoid
29187 <h2>testing
29188 123</h2>
29189
29190 <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">
29191 </span><span about="#mwt1">you</span> </h2>
29192
29193 <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>
29194
29195 <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
29196 there</span></li></ol>
29197
29198 <ul><li>asd
29199 sdf</li></ul>
29200
29201 <ul><li>foo
29202 bar
29203 baz</li>
29204 <li>foo <b>bar</b>
29205 baz</li></ul>
29206
29207 <dl><dt>hi
29208 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
29209 ho</dd></dl>
29210
29211 <dl><dd> <table>
29212 <tbody><tr><td> ha
29213 ha
29214 ha</td></tr>
29215 </tbody></table></dd></dl>
29216 !! wikitext
29217 == testing 123 ==
29218
29219 == hi {{bogus|there
29220 you}} ==
29221
29222 == foo <ref>hello
29223 there</ref> ==
29224
29225 <references />
29226
29227 * asd sdf
29228
29229 * foo bar baz
29230 * foo '''bar''' baz
29231
29232 ; hi ho : hi ho
29233
29234 : {|
29235 | ha
29236 ha
29237 ha
29238 |}
29239 !! end
29240
29241 !! test
29242 Serialize new placeholder space without spans
29243 !! options
29244 parsoid=html2wt
29245 !! html/parsoid
29246 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
29247
29248 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
29249
29250 <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>
29251 !! wikitext
29252 foo : bar
29253
29254 foo : bar
29255
29256 <ref>foo : bar</ref>ok
29257 !! end
29258
29259
29260 #-----------------------
29261 # Tag minimization tests
29262 #-----------------------
29263
29264 !! test
29265 1. I/B quote minimization: wikitext-only tags should be combined
29266 !! options
29267 parsoid=html2wt
29268 !! html/parsoid
29269 <p><i>A</i><i>B</i></p>
29270 <p><b>A</b><b>B</b></p>
29271 <p><i>A</i><b><i>B</i></b></p>
29272 <p><b>A</b><i><b>B</b></i></p>
29273 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
29274 <p><i><b>A</b></i><i><b>B</b></i></p>
29275 <p><i><b>A</b></i><b><i>B</i></b></p>
29276 <p><b><i>A</i></b><i><b>B</b></i></p>
29277 !! wikitext
29278 ''AB''
29279
29280 '''AB'''
29281
29282 ''A'''B'''''
29283
29284 '''A''B'''''
29285
29286 '''A''BC''D'''
29287
29288 '''''AB'''''
29289
29290 '''''AB'''''
29291
29292 '''''AB'''''
29293 !! end
29294
29295 !! test
29296 2. I/B quote minimization: wikitext and html tags should not be combined
29297 !! options
29298 parsoid=html2wt
29299 !! html/parsoid
29300 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
29301 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
29302 !! wikitext
29303 ''A''<i>B</i>
29304
29305 ''A''<nowiki/>'''<i>B</i>'''
29306 !! end
29307
29308 !! test
29309 3. I/B quote minimization: templated content stops minimization
29310 !! options
29311 parsoid=html2wt
29312 !! html/parsoid
29313 <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>
29314 <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>
29315 !! wikitext
29316 ''A''{{echo|''B''}}
29317
29318 ''A''{{echo|'''''B'''''}}
29319 !! end
29320
29321 !! test
29322 4. I/B quote minimization: new content should be mimimized with adjacent old content
29323 !! options
29324 parsoid=html2wt
29325 !! html/parsoid
29326 <p><i>A</i><i>B</i></p>
29327 <p><b>A</b><b>B</b></p>
29328 <p><i>A</i><b><i>B</i></b></p>
29329 !! wikitext
29330 ''AB''
29331
29332 '''AB'''
29333
29334 ''A'''B'''''
29335 !! end
29336
29337 !! test
29338 5a. Merge adjacent quote nodes if they've been edited
29339 !! options
29340 parsoid={
29341 "modes": ["wt2wt", "selser"],
29342 "changes": [
29343 ["p", "contents", "remove", ":contains('b')"]
29344 ]
29345 }
29346 !! wikitext
29347 ''a''b''c''
29348 !! wikitext/edited
29349 ''ac''
29350 !! end
29351
29352 !! test
29353 5b. Merge adjacent quote nodes if they've been edited
29354 !! options
29355 parsoid={
29356 "modes": ["wt2wt", "selser"],
29357 "changes": [
29358 ["#x", "remove"]
29359 ]
29360 }
29361 !! wikitext
29362 ''a''<span id="x">b</span>''c''
29363 !! wikitext/edited
29364 ''ac''
29365 !! end
29366
29367 !! test
29368 1. Merge adjacent link nodes as long as at least one element is new
29369 !! options
29370 parsoid={
29371 "modes": ["html2wt"],
29372 "scrubWikitext": true
29373 }
29374 !! html/parsoid
29375 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29376 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29377 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
29378 !! wikitext
29379 [[Football]]
29380 [[Football]]
29381 [[Football|Foot]][[Football|ball]]
29382 !! end
29383
29384 !! test
29385 2. Merge adjacent link nodes and enable additional normalizations
29386 !! options
29387 parsoid={
29388 "modes": ["html2wt"],
29389 "scrubWikitext": true
29390 }
29391 !! html/parsoid
29392 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
29393 !! wikitext
29394 ''[[Football]]''
29395 !! end
29396
29397 !! test
29398 3. Don't merge adjacent link nodes if scrubWikitext is false
29399 !! options
29400 parsoid={
29401 "modes": ["html2wt"],
29402 "scrubWikitext": false
29403 }
29404 !! html/parsoid
29405 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
29406 !! wikitext
29407 [[Football|Foot]][[Football|ball]]
29408 !! end
29409
29410 !! test
29411 1. Move format tags outside of WikiLink
29412 !! options
29413 parsoid={
29414 "modes": ["html2wt"],
29415 "scrubWikitext": true
29416 }
29417 !! html/parsoid
29418 <a rel="mw:WikiLink" href="./Football"><i>Football</i></a>
29419 <a rel="mw:WikiLink" href="./Football"><i><b>Football</b></i></a>
29420 <a rel="mw:WikiLink" href="./Football"><u><i><b>Football</b></i></u></a>
29421 !! wikitext
29422 ''[[Football]]''
29423 '''''[[Football]]'''''
29424 <u>'''''[[Football]]'''''</u>
29425 !! end
29426
29427 !! test
29428 2. Move format tags outside of WikiLink with mergable A tags
29429 !! options
29430 parsoid={
29431 "modes": ["html2wt"],
29432 "scrubWikitext": true
29433 }
29434 !! html/parsoid
29435 <a rel="mw:WikiLink" href="./Football"><i><b>Foot</b></i></a><a rel="mw:WikiLink" href="./Football"><i><b>ball</b></i></a>
29436 !! wikitext
29437 '''''[[Football]]'''''
29438 !! end
29439
29440 !! test
29441 3. Move format tags outside of WikiLink while preserving formats already outside WikiLink
29442 !! options
29443 parsoid={
29444 "modes": ["html2wt"],
29445 "scrubWikitext": true
29446 }
29447 !! html/parsoid
29448 <font color="red"><a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><u><b>Foo</b></u></a></font>
29449 !! wikitext
29450 <font color="red"><u>'''[[Foo]]'''</u></font>
29451 !! end
29452
29453 !! test
29454 4. Do not move format tags outside of WikiLink which includes attributes color, style and class
29455 !! options
29456 parsoid={
29457 "modes": ["html2wt"],
29458 "scrubWikitext": true
29459 }
29460 !! html/parsoid
29461 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><font color="red">Foo</font></a>
29462 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span style="color: blue; font-size: 46px;">Foo></span></a>
29463 <a rel="mw:WikiLink" href="./Foo" title="Foo" class="mw-redirect"><span class="Bar">Foo</span></a>
29464 !! wikitext
29465 [[Foo|<font color="red">Foo</font>]]
29466 [[Foo|<span style="color: blue; font-size: 46px;">Foo></span>]]
29467 [[Foo|<span class="Bar">Foo</span>]]
29468 !! end
29469
29470 !! test
29471 5. T194083 Regression test: Manual edit test that also enables scrubWikitext to move format tags outside wikilinks
29472 !! options
29473 parsoid={
29474 "modes": ["selser"],
29475 "scrubWikitext": true,
29476 "changes": [
29477 ["a", "html", "<i>Foo</i>"]
29478 ]
29479 }
29480 !! wikitext
29481 [[Foo]]
29482 !! wikitext/edited
29483 ''[[Foo]]''
29484 !! end
29485
29486 !! test
29487 6. Regression test: Manual edit test to ensure diff markers are not lost
29488 !! options
29489 parsoid={
29490 "modes": ["selser"],
29491 "scrubWikitext": true,
29492 "changes": [
29493 ["i", "wrap", "<a href='./Foo' rel='mw:WikiLink'></a>"]
29494 ]
29495 }
29496 !! wikitext
29497 ''Foo''
29498 !! wikitext/edited
29499 ''[[Foo]]''
29500 !! end
29501
29502 !! test
29503 7. T194083 Regression test: Manual edit test to ensure nested diff markers aren't inserted
29504 !! options
29505 parsoid={
29506 "modes": ["selser"],
29507 "scrubWikitext": true,
29508 "changes": [
29509 ["div", "after", "\n<p><a href='./Foo' rel='mw:WikiLink'>Foo </a>, placeholder</p>"]
29510 ]
29511 }
29512 !! wikitext
29513 <div>placeholder</div>
29514 !! wikitext/edited
29515 <div>placeholder</div>
29516 [[Foo]] , placeholder
29517 !! end
29518
29519 #------------------------------
29520 # End of tag minimization tests
29521 #------------------------------
29522
29523 !!test
29524 T56262: New entities
29525 !! options
29526 parsoid=html2wt
29527 !! html/parsoid
29528 <span typeof="mw:Entity">&nbsp;</span>
29529 !! wikitext
29530 &nbsp;
29531 !! end
29532
29533 ## Note that there is no wikitext output for 'unknownproperty' ##
29534 ## Unknown magic words are silently dropped ##
29535
29536 !! test
29537 Magic words
29538 !! options
29539 parsoid=html2wt
29540 !! html/parsoid
29541 <meta property='mw:PageProp/toc' />
29542 <meta property='mw:PageProp/notoc' />
29543 <meta property='mw:PageProp/forcetoc' />
29544 <meta property='mw:PageProp/index' />
29545 <meta property='mw:PageProp/noindex' />
29546 <meta property='mw:PageProp/nogallery' />
29547 <meta property='mw:PageProp/noeditsection' />
29548 <meta property='mw:PageProp/notitleconvert' />
29549 <meta property='mw:PageProp/nocontentconvert' />
29550 <meta property='mw:PageProp/unknownproperty' />
29551 !! wikitext
29552 __TOC__
29553 __NOTOC__
29554 __FORCETOC__
29555 __INDEX__
29556 __NOINDEX__
29557 __NOGALLERY__
29558 __NOEDITSECTION__
29559 __NOTITLECONVERT__
29560 __NOCONTENTCONVERT__
29561 !! end
29562
29563 !! test
29564 Consecutive <pre>s should not get merged
29565 !! options
29566 parsoid=html2wt,html2html
29567 !! html/parsoid
29568 <pre>a</pre><pre>b</pre>
29569
29570 <pre>c
29571 </pre><pre>
29572 d</pre>
29573
29574 <pre>e
29575
29576 </pre><pre>
29577
29578 f</pre>
29579 !! wikitext
29580 a
29581
29582 b
29583
29584 c
29585
29586 d
29587
29588 e
29589
29590
29591
29592 f
29593 !! end
29594
29595 !! test
29596 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
29597 !! options
29598 parsoid=html2wt
29599 !! html/parsoid
29600 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
29601 !! wikitext
29602 [[Special:BookSources/1234567890|ISBN 1234567895]]
29603 !! end
29604
29605 !! test
29606 Edited RFC links not serializable as RFC links should serialize as extlinks
29607 !! options
29608 parsoid=html2wt
29609 !! html/parsoid
29610 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
29611 !! wikitext
29612 [https://tools.ietf.org/html/rfc123 New RFC]
29613 !! end
29614
29615 !! test
29616 Edited PMID links not serializable as PMID links should serialize as extlinks
29617 !! options
29618 parsoid=html2wt
29619 !! html/parsoid
29620 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
29621 !! wikitext
29622 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
29623 !! end
29624
29625 !! test
29626 WTS of autolinks with trailing/surrounding context
29627 !! options
29628 parsoid=html2wt
29629 !! html/parsoid
29630 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
29631 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
29632 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
29633 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
29634 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
29635 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
29636 !! wikitext
29637 http://cscott.net'''foo'''
29638
29639 http://cscott.net<b>foo</b>
29640
29641 '''http://cscott.net'''
29642
29643 '''http://cscott.net '''
29644
29645 '''http://cscott.net<nowiki/>x'''
29646
29647 http://cscott.net<nowiki/>x
29648 !! end
29649
29650 !! test
29651 WTS of autolinks with nowikis (round-trip)
29652 !! wikitext
29653 x<nowiki/>http://cscott.net<nowiki/>x
29654 !! html/parsoid
29655 <p>x<a rel="mw:ExtLink" class="external free" href="http://cscott.net">http://cscott.net</a>x</p>
29656 !! end
29657
29658 # this is the "easy" test because it leaves in place all the
29659 # data-parsoid information indicating this is an autolink
29660 !! test
29661 WTS of autolinks with escapes (editing)
29662 !! options
29663 parsoid={
29664 "modes": ["wt2wt"],
29665 "changes": [
29666 [ "span", "remove" ]
29667 ]
29668 }
29669 !! wikitext
29670 x<nowiki/>http://cscott.net<nowiki/>x
29671 !! wikitext/edited
29672 x<nowiki/>http://cscott.net<nowiki/>x
29673 !! end
29674
29675 !! test
29676 WTS of edited autolink-like text (T103364)
29677 !! options
29678 parsoid={
29679 "modes": ["wt2wt"],
29680 "changes": [
29681 [ "span[typeof]", "removeAttr", "typeof" ]
29682 ]
29683 }
29684 !! wikitext
29685 Not a link: <nowiki>http://example.com</nowiki>.
29686 !! wikitext/edited
29687 Not a link: <span><nowiki>http://example.com</nowiki></span>.
29688 !! end
29689
29690 !! test
29691 WTS of newly-authored autolink-like text (T103364)
29692 !! options
29693 parsoid=html2wt
29694 !! html/parsoid
29695 <p>http://example.com is not a link.</p>
29696 !! wikitext
29697 <nowiki>http://example.com</nowiki> is not a link.
29698 !! end
29699
29700 !! test
29701 WTS of autolink-like text after an autolink (T108563)
29702 !! options
29703 parsoid=html2wt
29704 !! html/parsoid
29705 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
29706 !! wikitext
29707 http://example.com <nowiki>http://example.com</nowiki> is not a link.
29708 !! end
29709
29710 !! test
29711 Magic links inside links (not autolinked)
29712 !! wikitext
29713 [[Foo|http://example.com]]
29714 [[Foo|RFC 1234]]
29715 [[Foo|PMID 1234]]
29716 [[Foo|ISBN 123456789x]]
29717
29718 [http://foo.com http://example.com]
29719 [http://foo.com RFC 1234]
29720 [http://foo.com PMID 1234]
29721 [http://foo.com ISBN 123456789x]
29722 !! html+tidy
29723 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
29724 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
29725 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
29726 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
29727 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
29728 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
29729 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
29730 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
29731 </p>
29732 !! html/parsoid
29733 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
29734 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
29735 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
29736 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
29737
29738 <p><a rel="mw:ExtLink" class="external text" href="http://foo.com">http://example.com</a>
29739 <a rel="mw:ExtLink" class="external text" href="http://foo.com">RFC 1234</a>
29740 <a rel="mw:ExtLink" class="external text" href="http://foo.com">PMID 1234</a>
29741 <a rel="mw:ExtLink" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
29742 !! end
29743
29744 !! test
29745 Magic links inside image captions (autolinked)
29746 !! wikitext
29747 [[File:Foobar.jpg|thumb|http://example.com]]
29748 [[File:Foobar.jpg|thumb|RFC 1234]]
29749 [[File:Foobar.jpg|thumb|PMID 1234]]
29750 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
29751 !! html+tidy
29752 <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>
29753 <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>
29754 <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>
29755 <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>
29756 !! html/parsoid
29757 <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>
29758 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="https://tools.ietf.org/html/rfc1234" rel="mw:ExtLink" class="external mw-magiclink">RFC 1234</a></figcaption></figure>
29759 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink" class="external mw-magiclink">PMID 1234</a></figcaption></figure>
29760 <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>
29761 !! end
29762
29763 !! test
29764 WTS of magic word text (T109371)
29765 !! options
29766 parsoid=html2wt
29767 !! html/parsoid
29768 <p>RFC 1234</p>
29769 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
29770 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
29771 !! wikitext
29772 <nowiki>RFC 1234</nowiki>
29773
29774 [http://foo.com RFC 1234]
29775
29776 [[Foo|RFC 1234]]
29777 !! end
29778
29779 !! test
29780 Edited Redirect link should emit a non-piped wikitext link
29781 !! options
29782 parsoid=html2wt
29783 !! html/parsoid
29784 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
29785 !! wikitext
29786 #REDIRECT [[Bar]]
29787 !! end
29788
29789 !! test
29790 T75121: Infer extension name from typeOf if data-mw is not present
29791 !! options
29792 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29793 !! html/parsoid
29794 <div typeOf="mw:Extension/foo"></div>
29795 !! wikitext
29796 <foo />
29797 !! end
29798
29799 # Note that the <p> wrapping isn't present in PHP parser output
29800 # The important thing for this test is that P-wrapping doesn't
29801 # interfere with the <nowiki> protection for leading - in <td>
29802 # (which isn't necessary for <th>).
29803 !! test
29804 T88318: p-wrapped dash in table.
29805 !! options
29806 parsoid=html2wt,wt2wt
29807 !! html/parsoid
29808 <table><tbody>
29809 <tr><th><p>-</p></th><th><p>- </p></th></tr>
29810 <tr><td><p>-</p></td><td><p>- </p></td></tr>
29811 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
29812 </tbody></table>
29813 !! wikitext
29814 {|
29815 !-
29816 !-
29817 |-
29818 |<nowiki>-</nowiki>
29819 |<nowiki>- </nowiki>
29820 |-
29821 |<small>-</small>
29822 |<br />
29823 -
29824 |<br />-
29825 |}
29826 !! html/php+tidy
29827 <table>
29828 <tbody><tr>
29829 <th>-
29830 </th>
29831 <th>-
29832 </th></tr>
29833 <tr>
29834 <td>-
29835 </td>
29836 <td>-
29837 </td></tr>
29838 <tr>
29839 <td><small>-</small>
29840 </td>
29841 <td><br />
29842 <p>-
29843 </p>
29844 </td>
29845 <td><br />-
29846 </td></tr></tbody></table>
29847 !! end
29848
29849 !! test
29850 T149209: WTS: Handle newlines in table cells properly
29851 !! options
29852 parsoid=html2wt
29853 !! html/parsoid
29854 <table>
29855 <tbody>
29856 <tr><td>a
29857 b
29858 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
29859 <tr><td><p>x</p>
29860 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
29861 </tbody></table>
29862 <table>
29863 <tbody>
29864 <tr><th>a
29865 b
29866 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
29867 <tr><th><p>x</h>
29868 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
29869 </tbody></table>
29870 !! wikitext
29871 {|
29872 |a
29873 b
29874 |c
29875 |-
29876 |x
29877 {{!}}y
29878 |}
29879 {|
29880 !a
29881 b
29882 !c
29883 |-
29884 !x
29885 !y
29886 |}
29887 !! end
29888
29889 !! test
29890 T149209: Selser: Handle newlines in table cells properly
29891 !! options
29892 parsoid={
29893 "modes": ["selser"],
29894 "changes": [
29895 [ "#h1", "html", "a\nb\n" ],
29896 [ "#h2", "html", "a\nb\n" ],
29897 [ "#c1", "html", "a\nb\n" ],
29898 [ "#c2", "html", "<p>a</p>" ],
29899 [ "#c3", "html", "<p>a</p>" ],
29900 [ "#c4", "html", "edit-me<p>a</p>" ]
29901 ]
29902 }
29903 !! wikitext
29904 {|
29905 ! id="h1" |edit-me!!1
29906 |-
29907 ! id="h2" |edit-me||2
29908 |-
29909 | id="c1" |edit-me||3
29910 |-
29911 | id="c2" |edit-me||4
29912 |-
29913 | id="c3" |edit-me||p||q||r
29914 |-
29915 | id="c4" |edit-me||p||q||r
29916 |}
29917 !! wikitext/edited
29918 {|
29919 ! id="h1" |a
29920 b
29921 !1
29922 |-
29923 ! id="h2" |a
29924 b
29925 !2
29926 |-
29927 | id="c1" |a
29928 b
29929 |3
29930 |-
29931 | id="c2" |a
29932 |4
29933 |-
29934 | id="c3" |a
29935 |p||q||r
29936 |-
29937 | id="c4" |edit-me
29938 a
29939 |p||q||r
29940 |}
29941 !! end
29942
29943 !! test
29944 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
29945 !! options
29946 parsoid=html2wt
29947 !! html/parsoid
29948 <table id='mwAb'>
29949 <td id='mwAc'>foo</td>
29950 <td id='serialize-this'>bar</td>
29951 </table>
29952 !! wikitext
29953 {|
29954 |foo
29955 | id="serialize-this" |bar
29956 |}
29957 !! end
29958
29959 !! test
29960 Parsoid-like element ids should not be serialized to wikitext unless shadowed
29961 !! options
29962 parsoid=html2wt
29963 !! html/parsoid
29964 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
29965 !! wikitext
29966 <div id="hello">ok</div>
29967 !! end
29968
29969 !! test
29970 Testing serialization after deletion in references
29971 !! options
29972 parsoid={
29973 "modes": ["wt2wt"],
29974 "changes": [
29975 ["#x", "remove"]
29976 ]
29977 }
29978 !! wikitext
29979 hi <ref><div id="x">ho</div></ref>
29980
29981 <references />
29982 !! wikitext/edited
29983 hi <ref></ref>
29984
29985 <references />
29986 !! end
29987
29988 !!test
29989 Testing serialization after deletion of table cells
29990 !!options
29991 parsoid={
29992 "modes": ["wt2wt", "selser"],
29993 "changes": [
29994 ["#x", "remove"]
29995 ]
29996 }
29997 !!wikitext
29998 {|
29999 !h1 !!h2 !!h3
30000 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
30001 |}
30002 !! wikitext/edited
30003 {|
30004 !h1!!h2!!h3
30005 |c2|||c3
30006 |}
30007 !!end
30008
30009 !! test
30010 Testing selser after addition of new row before first row (T125419)
30011 !! options
30012 parsoid={
30013 "modes": ["wt2wt", "selser"],
30014 "changes": [
30015 [ "tr", "before", "<tr><td>X</td></tr>" ]
30016 ]
30017 }
30018 !! wikitext
30019 {|
30020 |a
30021 |}
30022 !! wikitext/edited
30023 {|
30024 |X
30025 |-
30026 |a
30027 |}
30028 !! end
30029
30030 !! test
30031 Serialize new table rows in a HTML table using HTML tags
30032 !! options
30033 parsoid={
30034 "modes": ["wt2wt", "selser"],
30035 "changes": [
30036 [ "tr", "before", "<tr><td>X</td></tr>" ]
30037 ]
30038 }
30039 !! wikitext
30040 <table><tr><td>a</td></tr></table>
30041 !! wikitext/edited
30042 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
30043 !! end
30044
30045 !! test
30046 Serialize new table cells in a HTML row using HTML tags
30047 !! options
30048 parsoid={
30049 "modes": ["wt2wt", "selser"],
30050 "changes": [
30051 [ "td", "before", "<td>X</td>" ]
30052 ]
30053 }
30054 !! wikitext
30055 <table><tr><td>a</td></tr></table>
30056 !! wikitext/edited
30057 <table><tr><td>X</td><td>a</td></tr></table>
30058 !! end
30059
30060 !! test
30061 Serialize wikitext list items as HTML list items when embedded in a HTML list
30062 !! options
30063 parsoid=html2wt
30064 !! html/parsoid
30065 <ul data-parsoid='{"stx": "html"}'>
30066 <li data-parsoid='{}'>a</li>
30067 <li>b</li>
30068 </ul>
30069 !! wikitext
30070 <ul>
30071 <li>a</li>
30072 <li>b</li>
30073 </ul>
30074 !! html/php+tidy
30075 <ul>
30076 <li>a</li>
30077 <li>b</li>
30078 </ul>
30079 !! end
30080
30081 # Nested list should be inside <li>, that is
30082 # <ul><li>foo<ul>..</ul></li></ul> instead of
30083 # <ul><li>foo</li><ul>..</ul></ul>
30084 # See https://stackoverflow.com/questions/5899337/proper-way-to-make-html-nested-list
30085 !! test
30086 Wikitext lists can be nested inside HTML lists
30087 !! options
30088 parsoid=html2wt
30089 !! html/parsoid
30090 <ul data-parsoid='{"stx": "html"}'>
30091 <li data-parsoid='{"stx": "html"}'>a
30092 <ul><li>b</li></ul>
30093 </li>
30094 </ul>
30095
30096 <ul data-parsoid='{"stx": "html"}'>
30097 <li>x
30098 <ul><li>y</li></ul>
30099 </li>
30100 </ul>
30101 !! wikitext
30102 <ul>
30103 <li>a
30104 * b
30105 </li>
30106 </ul>
30107
30108 <ul>
30109 <li>x
30110 * y
30111 </li>
30112 </ul>
30113 !! html/php+tidy
30114 <ul>
30115 <li>a
30116 <ul><li>b</li></ul>
30117 </li>
30118 </ul>
30119 <ul>
30120 <li>x
30121 <ul><li>y</li></ul>
30122 </li>
30123 </ul>
30124 !! end
30125
30126 !! test
30127 WTS change modes
30128 !! options
30129 parsoid={
30130 "modes": ["wt2wt"],
30131 "changes": [
30132 [ "#xyz", "before", "<b>before</b> stuff " ],
30133 [ "#xyz", "after", " stuff <i>after</i>" ],
30134 [ "#xyz", "html", "x <b>y</b> z" ]
30135 ]
30136 }
30137 !! wikitext
30138 <span id="xyz">hello</span>
30139 !! wikitext/edited
30140 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
30141 !! end
30142
30143 !! test
30144 Never serialize a-tag as html, regardless of what data-parsoid has to say
30145 !! options
30146 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30147 !! html/parsoid
30148 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
30149 !! wikitext
30150 [[Foo]]
30151 !! end
30152
30153 ## SSS FIXME: This is broken output nevertheless.
30154 ## What might be a reasonable non-broken output for this?
30155 ## This is an edge case unlikely to be seen in production
30156 ## that I am not wasting more time on this right now.
30157 !! test
30158 Never serialize a-tag as html, no matter what attributes it has
30159 !! options
30160 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
30161 !! html/parsoid
30162 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
30163 !! wikitext
30164 [http://boo.org http://boohoo.org]
30165 !! end
30166
30167 # Misnested is an indication that selser can reuse the source but these have
30168 # shown to sneak through on occasion. See T101768.
30169 # The original wikitext here is: [http://test.com [[one]] two three]
30170 !! test
30171 Strip span tags added to mark misnested links
30172 !! options
30173 parsoid=html2wt
30174 !! html/parsoid
30175 <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>
30176 !! wikitext
30177 [http://test.com][[one]] two three
30178 !! end
30179
30180 !! test
30181 Catch regression when unpacking misnested links
30182 !! options
30183 parsoid=wt2html
30184 !! wikitext
30185 {{echo|hi}}[http://example.com [[ho]]]
30186 !! html/parsoid
30187 <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>
30188 !! end
30189
30190 !! test
30191 Catch regression when unpacking with trailing content
30192 !! wikitext
30193 {{echo|Foo <references/> bar}}
30194 !! html/parsoid
30195 <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>
30196 !! end
30197
30198 !! test
30199 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
30200 !! options
30201 parsoid=html2wt
30202 !! html/parsoid
30203 <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|}"]}'>
30204 <tbody><tr><td>d
30205 </td></tr>
30206 </tbody></table>
30207 !! wikitext
30208 {{echo|a}}
30209 {|{{echo|c
30210 {{!}}d
30211 }}
30212 |}
30213 !! end
30214
30215 ## This test verifies the presence and computation of this attribute indirectly
30216 ## by making an edit and ensuring that the serialization is correct (which it would be
30217 ## only if firstWikitextNode is properly set).
30218 !! test
30219 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
30220 !! options
30221 parsoid= {
30222 "modes": ["wt2wt"],
30223 "changes": [
30224 [ "div#x", "remove" ],
30225 [ "div", "before", "<div>new</div>" ]
30226 ]
30227 }
30228 !! wikitext
30229 <div id="x">foo</div>
30230 {|
30231 {{echo|<div>boo</div>
30232 {{!}}b}}
30233 |c
30234 |}
30235 !! wikitext/edited
30236
30237 <div>new</div>
30238 {|
30239 {{echo|<div>boo</div>
30240 {{!}}b}}
30241 |c
30242 |}
30243 !! end
30244
30245 # --------------------------------------------
30246 # Tests spec'ing wikitext serialization norms |
30247 # --------------------------------------------
30248
30249 !! test
30250 Serialize multi-line indent-pre starting with wikitext syntax
30251 !! options
30252 parsoid=html2wt
30253 !! html/parsoid
30254 <pre>* 1
30255 ** 2
30256 * 3</pre>
30257 !! wikitext
30258 * 1
30259 ** 2
30260 * 3
30261 !! end
30262
30263 !! test
30264 1. Categories should always be serialized on their own line
30265 !! options
30266 parsoid=html2wt
30267 !! html/parsoid
30268 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
30269 !! wikitext
30270 foo
30271 [[Category:Foo]]
30272 bar
30273 !! end
30274
30275 !! test
30276 2. Categories that are part of templates should not introduce a line break
30277 !! wikitext
30278 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
30279 !! html/parsoid
30280 <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>
30281 !! end
30282
30283 # Careful while editing these next 2 tests. There are \u200f characters
30284 # before and after the <link> tags in the HTML and following some
30285 # of the categories in wikitext
30286 # Do not remove these characters in edits.
30287 #
30288 # As part of the serialization, these bidi characters will get stripped.
30289 !! test
30290 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
30291 !! options
30292 parsoid={
30293 "modes": ["html2wt"],
30294 "scrubWikitext": true
30295 }
30296 !! html/parsoid
30297 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
30298 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
30299 !! wikitext
30300 [[קטגוריה:טקסים]]
30301 [[קטגוריה: שיטות משפט]]
30302 !! end
30303
30304 !! test
30305 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
30306 !! options
30307 parsoid={
30308 "modes": ["html2wt"],
30309 "scrubWikitext": true
30310 }
30311 !! html/parsoid
30312 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
30313 !! wikitext
30314 [[קטגוריה:טקסים]]
30315 ‏y
30316 !! end
30317
30318 !! test
30319 Lists: Add space after bullets
30320 !! options
30321 parsoid=html2wt
30322 !! html/parsoid
30323 <ul>
30324 <li>foo</li>
30325 <li> bar</li>
30326 <li><span> baz</span></li>
30327 </ul>
30328 !! wikitext
30329 * foo
30330 * bar
30331 * <span> baz</span>
30332 !! end
30333
30334 !! test
30335 1. Headings: Add space before/after == (T53744)
30336 !! options
30337 parsoid=html2wt
30338 !! html/parsoid
30339 <h2>foo</h2>
30340 <h2> bar</h2>
30341 <h2>baz </h2>
30342 <h2><span> baz</span></h2>
30343 !! wikitext
30344 == foo ==
30345
30346 == bar ==
30347
30348 == baz ==
30349
30350 == <span> baz</span> ==
30351 !! end
30352
30353 !! test
30354 2. Headings: Add space before/after == even after hoisted content
30355 !! options
30356 parsoid={
30357 "modes": ["html2wt"],
30358 "scrubWikitext": true
30359 }
30360 !! html/parsoid
30361 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
30362 !! wikitext
30363 [[Category:A2]]
30364
30365 == ok ==
30366 !! end
30367
30368 !! test
30369 1. Headings: suppress newly created empty headings
30370 !! options
30371 parsoid={
30372 "modes": ["html2wt"],
30373 "scrubWikitext": true
30374 }
30375 !! html/parsoid
30376 <h2></h2>
30377 !! wikitext
30378 !! end
30379
30380 !! test
30381 2. Headings: don't suppress empty headings if scrubWikitext is false
30382 !! options
30383 parsoid=html2wt
30384 !! html/parsoid
30385 <h2></h2>
30386 !! wikitext
30387 ==<nowiki/>==
30388 !! end
30389
30390 !! test
30391 3. Headings: suppress empty headings on edits
30392 !! options
30393 parsoid={
30394 "modes": ["selser"],
30395 "scrubWikitext": true,
30396 "changes": [
30397 [ "#x", "remove"]
30398 ]
30399 }
30400 !! wikitext
30401 ==<span id="x">foo</span>==
30402 !! wikitext/edited
30403 !! end
30404
30405 !! test
30406 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
30407 !! options
30408 parsoid={
30409 "modes": ["html2wt"],
30410 "scrubWikitext": true
30411 }
30412 !! html/parsoid
30413 <h2>foo<br/>bar</h2>
30414 <h2>foo <span><br/>bar</span> baz</h2>
30415 !! wikitext
30416 == foo bar ==
30417
30418 == foo <span> bar</span> baz ==
30419 !! end
30420
30421 !! test
30422 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
30423 !! options
30424 parsoid={
30425 "modes": ["html2wt"],
30426 "scrubWikitext": false
30427 }
30428 !! html/parsoid
30429 <h2>foo<br/>bar</h2>
30430 !! wikitext
30431 == foo<br />bar ==
30432 !! end
30433
30434 !! test
30435 1. WT Quote Tags: suppress newly created empty style tags
30436 !! options
30437 parsoid={
30438 "modes": ["html2wt"],
30439 "scrubWikitext": true
30440 }
30441 !! html/parsoid
30442 <i></i><b></b>
30443 !! wikitext
30444 !! end
30445
30446 !! test
30447 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
30448 !! options
30449 parsoid=html2wt
30450 !! html/parsoid
30451 <i></i><b></b>
30452 !! wikitext
30453 ''<nowiki/>'''''<nowiki/>'''
30454 !! end
30455
30456 !! test
30457 3. WT Quote Tags: suppress empty style tags on edits
30458 !! options
30459 parsoid={
30460 "modes": ["selser"],
30461 "scrubWikitext": true,
30462 "changes": [
30463 [ "#x", "remove"]
30464 ]
30465 }
30466 !! wikitext
30467 '''<span id="x">foo</span>'''
30468 !! wikitext/edited
30469 !! end
30470
30471 !! test
30472 1. Anchors: suppress newly created empty anchors
30473 !! options
30474 parsoid={
30475 "modes": ["html2wt"],
30476 "scrubWikitext": true
30477 }
30478 !! html/parsoid
30479 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30480 !! wikitext
30481 !! end
30482
30483 !! test
30484 2. Anchors: don't suppress empty anchors if scrubWikitext is false
30485 !! options
30486 parsoid={
30487 "modes": ["html2wt"],
30488 "scrubWikitext": false
30489 }
30490 !! html/parsoid
30491 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
30492 !! wikitext
30493 [[Test|<nowiki/>]]
30494 !! end
30495
30496 !! test
30497 3. Anchors: suppress empty anchors on edits
30498 !! options
30499 parsoid={
30500 "modes": ["selser"],
30501 "scrubWikitext": true,
30502 "changes": [
30503 [ "#x", "remove"]
30504 ]
30505 }
30506 !! wikitext
30507 [[Test|<span id="x">foo</span>]]
30508 !! wikitext/edited
30509 !! end
30510
30511 !! test
30512 3a. Anchors: do not suppress numbered extlinks
30513 !! options
30514 parsoid={
30515 "modes": ["wt2wt"],
30516 "scrubWikitext": true
30517 }
30518 !! wikitext
30519 [http://foo.com]
30520 !! html/parsoid
30521 <a rel="mw:ExtLink" href="http://foo.com"></a>
30522 !! end
30523
30524 !! test
30525 3b. Anchors: do not suppress numbered extlinks
30526 !! options
30527 parsoid={
30528 "modes": ["wt2wt"],
30529 "scrubWikitext": true,
30530 "changes": [
30531 [ "#x", "remove"]
30532 ]
30533 }
30534 !! wikitext
30535 [http://foo.com <span id="x">foo</span>]
30536 !! wikitext/edited
30537 [http://foo.com]
30538 !! end
30539
30540 !!test
30541 Normalizations should be restricted to edited content
30542 !!options
30543 parsoid={
30544 "modes": ["selser"],
30545 "scrubWikitext": true,
30546 "changes": [
30547 [ "h1", "before", "<i></i>"]
30548 ]
30549 }
30550 !!wikitext
30551 a
30552 = =
30553 b
30554 !!wikitext/edited
30555 a
30556 = =
30557 b
30558 !!end
30559
30560 !! test
30561 1. Multiple normalizations (html2wt)
30562 !! options
30563 parsoid={
30564 "modes": ["html2wt"],
30565 "scrubWikitext": true
30566 }
30567 !! html/parsoid
30568 <h2><i></i></h2>
30569 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
30570 </a><b><i></i></b>x</p>
30571 !! wikitext
30572
30573 [[foo]]
30574 x
30575
30576 !! end
30577
30578 !! test
30579 2. Multiple normalizations (selser)
30580 !! options
30581 parsoid={
30582 "modes": ["selser"],
30583 "scrubWikitext": true,
30584 "changes": [
30585 [ "#x", "after", "<h1><i></i></h1>\n<p> bar<b></b></p>"]
30586 ]
30587 }
30588 !! wikitext
30589 <div id="x">foo</div>
30590 !! wikitext/edited
30591 <div id="x">foo</div>
30592 bar
30593 !! end
30594
30595 !! test
30596 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
30597 !! options
30598 parsoid={
30599 "modes": ["html2wt"],
30600 "scrubWikitext": true
30601 }
30602 !! html/parsoid
30603 <p> hi</p>
30604 <p> hello</p>
30605 !! wikitext
30606 hi
30607
30608 hello
30609 !! end
30610
30611 !! test
30612 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
30613 !! options
30614 parsoid=html2wt
30615 !! html/parsoid
30616 <p> hi</p>
30617 <p> hello</p>
30618 !! wikitext
30619 <nowiki> </nowiki>hi
30620
30621 <nowiki> </nowiki> hello
30622 !! end
30623
30624 !! test
30625 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
30626 !! options
30627 parsoid={
30628 "modes": ["html2wt"],
30629 "scrubWikitext": true
30630 }
30631 !! html/parsoid
30632 <p>Foo
30633 bar
30634 baz</p>
30635
30636 <table><tr><td>Foo
30637 bar
30638 baz bang</td></tr></table>
30639
30640 <p><!--boo--> foo
30641 bar</p>
30642
30643 <p> foo
30644 bar<span>boo</span></p>
30645 !! wikitext
30646 Foo
30647 bar
30648 baz
30649
30650 {|
30651 |Foo
30652 bar
30653 baz bang
30654 |}
30655
30656 <!--boo-->foo
30657 bar
30658
30659 foo
30660 bar<span>boo</span>
30661 !! end
30662
30663 !! test
30664 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
30665 !! options
30666 parsoid={
30667 "modes": ["selser"],
30668 "scrubWikitext": true,
30669 "changes": [
30670 [ "p", "html", " a\n b" ]
30671 ]
30672 }
30673 !! wikitext
30674 xyz
30675 !! wikitext/edited
30676 a
30677 b
30678 !! end
30679
30680 !! test
30681 1. New links that end in spaces
30682 !! options
30683 parsoid={
30684 "modes": ["html2wt"],
30685 "scrubWikitext": false
30686 }
30687 !! html/parsoid
30688 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30689 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30690 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30691 !! wikitext
30692 [[Berlin ]]<nowiki/>is the capital of Germany.
30693
30694 [[Foo ]]'''bar'''
30695
30696 [[Boston ]] is a city.
30697 !! end
30698
30699 !! test
30700 2. New links that end in spaces
30701 !! options
30702 parsoid={
30703 "modes": ["html2wt"],
30704 "scrubWikitext": true
30705 }
30706 !! html/parsoid
30707 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
30708 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
30709 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
30710 !! wikitext
30711 [[Berlin]] is the capital of Germany.
30712
30713 [[Foo]] '''bar'''
30714
30715 [[Boston]] is a city.
30716 !! end
30717
30718 !! test
30719 1. Table cells with escapable prefixes
30720 !! options
30721 parsoid={
30722 "modes": ["html2wt"],
30723 "scrubWikitext": false
30724 }
30725 !! html/parsoid
30726 <table>
30727 <tr><td>a</td></tr>
30728 <tr><td>-</td></tr>
30729 <tr><td>+</td></tr>
30730 <tr><td>}</td></tr>
30731 </table>
30732 !! wikitext
30733 {|
30734 |a
30735 |-
30736 |<nowiki>-</nowiki>
30737 |-
30738 |<nowiki>+</nowiki>
30739 |-
30740 |<nowiki>}</nowiki>
30741 |}
30742 !! end
30743
30744 !! test
30745 2. Table cells with escapable prefixes
30746 !! options
30747 parsoid={
30748 "modes": ["html2wt"],
30749 "scrubWikitext": true
30750 }
30751 !! html/parsoid
30752 <table>
30753 <tr><td>a</td></tr>
30754 <tr><td>-</td></tr>
30755 <tr><td>+</td></tr>
30756 <tr><td>}</td></tr>
30757 </table>
30758 !! wikitext
30759 {|
30760 |a
30761 |-
30762 | -
30763 |-
30764 | +
30765 |-
30766 | }
30767 |}
30768 !! end
30769
30770 !! test
30771 3a. Table cells with escapable prefixes after edits
30772 !! options
30773 parsoid={
30774 "modes": ["selser"],
30775 "scrubWikitext": true,
30776 "changes": [
30777 [ "table tbody tr:first-child td:first-child", "remove"]
30778 ]
30779 }
30780 !! wikitext
30781 {|
30782 |a||-
30783 |}
30784 !! wikitext/edited
30785 {|
30786 | -
30787 |}
30788 !! end
30789
30790 !! test
30791 3b. Table cells with escapable prefixes after edits
30792 !! options
30793 parsoid={
30794 "modes": ["selser"],
30795 "scrubWikitext": true,
30796 "changes": [
30797 [ "table tbody tr:first-child td:first-child", "html", "-" ],
30798 [ "#x", "remove" ]
30799 ]
30800 }
30801 !! wikitext
30802 {|
30803 |pqr
30804 |<span id="x">foo</span>+
30805 |}
30806 !! wikitext/edited
30807 {|
30808 | -
30809 | +
30810 |}
30811 !! end
30812
30813 # FIXME: This test will fail because
30814 # normalization doesn't realize that the id attribute
30815 # will eliminate the escapable scenario
30816 !! test
30817 4a. Table cells without escapable prefixes after edits
30818 !! options
30819 parsoid={
30820 "modes": ["selser"],
30821 "scrubWikitext": true,
30822 "changes": [
30823 [ "#x", "html", "-" ]
30824 ]
30825 }
30826 !! wikitext
30827 {|
30828 | id="x" |abcd
30829 |}
30830 !! wikitext/edited
30831 {|
30832 | id="x" |-
30833 |}
30834 !! end
30835
30836 ## This tests normalizer's ability to discriminate between
30837 ## cells having identical content.
30838 !! test
30839 4b. Table cells without escapable prefixes after edits
30840 !! options
30841 parsoid={
30842 "modes": ["selser"],
30843 "scrubWikitext": true,
30844 "changes": [
30845 [ "td", "html", "-" ]
30846 ]
30847 }
30848 !! wikitext
30849 {|
30850 |a||b
30851 |}
30852 !! wikitext/edited
30853 {|
30854 | -||-
30855 |}
30856 !! end
30857
30858 ## This tests normalizer's ability to not be tripped by
30859 ## comments (and whitespace)
30860 !! test
30861 4c. Table cells without escapable prefixes after edits
30862 !! options
30863 parsoid={
30864 "modes": ["selser"],
30865 "scrubWikitext": true,
30866 "changes": [
30867 [ "table tbody tr td:first-child", "remove" ]
30868 ]
30869 }
30870 !! wikitext
30871 {|
30872 |-
30873 <!--foo--> |a||-
30874 |}
30875 !! wikitext/edited
30876 {|
30877 |-
30878 <!--foo--> | -
30879 |}
30880 !! end
30881
30882 ## This tests normalizer's ability to handle HTML cells
30883 !! test
30884 4d. Table cells without escapable prefixes after edits
30885 !! options
30886 parsoid={
30887 "modes": ["selser"],
30888 "scrubWikitext": true,
30889 "changes": [
30890 [ "td", "html", "-" ]
30891 ]
30892 }
30893 !! wikitext
30894 <table>
30895 <tr><td>a</td></tr>
30896 </table>
30897 !! wikitext/edited
30898 <table>
30899 <tr><td>-</td></tr>
30900 </table>
30901 !! end
30902
30903 ## T111151 Remove font elements without attributes
30904 !! test
30905 5a. font tags without attributes should be dropped in scrubWikitext mode
30906 !! options
30907 parsoid={
30908 "modes": ["html2wt"],
30909 "scrubWikitext": true
30910 }
30911 !! html/parsoid
30912 <font>foo</font>
30913 <font><font>bar</font></font>
30914 <font class="x">boo</font>
30915 !! wikitext
30916 foo
30917 bar
30918 <font class="x">boo</font>
30919 !! end
30920
30921 !! test
30922 5b. font tags should not be dropped without scrubWikitext being enabled
30923 !! options
30924 parsoid={
30925 "modes": ["html2wt"],
30926 "scrubWikitext": false
30927 }
30928 !! html/parsoid
30929 <font>foo</font>
30930 !! wikitext
30931 <font>foo</font>
30932 !! end
30933
30934 !! test
30935 Escape nowiki DOM elements
30936 !! options
30937 parsoid=html2wt
30938 !! html/parsoid
30939 <nowiki><i>foo</i></nowiki>
30940 !! wikitext
30941 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
30942 !! end
30943
30944 # This is meant to be an interim fix while we go about figuring out
30945 # how to not introduce these trailing <nowiki/>s in the first place.
30946 !! test
30947 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
30948 !! options
30949 parsoid=html2wt
30950 !! html/parsoid
30951 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
30952 y</p>
30953 <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>
30954 <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>
30955 !! wikitext
30956 x
30957 y
30958
30959 {{echo|
30960 1 = <nowiki/>}}
30961
30962 {{echo|
30963 1 = <nowiki/>
30964 }}
30965 !! end
30966
30967 !! test
30968 New list is serialized on newlines
30969 !! options
30970 parsoid=html2wt
30971 !! html/parsoid
30972 <p>The quick brown fox jumps over the lazy dog.</p><ul>
30973 <li>Yesterday</li>
30974 <li>Today</li>
30975 <li>Tomorrow</li>
30976 </ul><p>The quick onyx goblin jumps over the lazy dwarf.</p>
30977 !! wikitext
30978 The quick brown fox jumps over the lazy dog.
30979
30980 * Yesterday
30981 * Today
30982 * Tomorrow
30983
30984 The quick onyx goblin jumps over the lazy dwarf.
30985 !! end
30986
30987 !! test
30988 New lists in formatting elements serialized w/o newlines
30989 !! options
30990 parsoid=html2wt
30991 !! html/parsoid
30992 <small>
30993
30994 <ul>
30995 <li>123</li>
30996 </ul>
30997
30998 </small>
30999
31000 <small><ul><li>hi</li></ul></small>
31001 !! wikitext
31002 <small>
31003 * 123
31004 </small>
31005
31006 <small>
31007 * hi
31008 </small>
31009 !! end
31010
31011 !! test
31012 New list in table doesn't need newlines
31013 !! options
31014 parsoid=html2wt
31015 !! html/parsoid
31016 <table><tr><td><ul><li>test</li><li>123</li></td></tr></table>
31017 !! wikitext
31018 {|
31019 |
31020 * test
31021 * 123
31022 |}
31023 !! end
31024
31025 # ---------------------------------------------------
31026 # End of tests spec'ing wikitext serialization norms |
31027 # ---------------------------------------------------
31028
31029 # T104032
31030 !! test
31031 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
31032 !! options
31033 parsoid=html2wt
31034 !! html/parsoid
31035 a<p>b</p>
31036 <b>c</b><p>d</p>
31037 <table><tr>
31038 <td>a<p>b</p></td>
31039 <td><b>c</b><p>d</p></td>
31040 </tr></table>
31041 !! wikitext
31042 a
31043
31044 b
31045
31046 '''c'''
31047
31048 d
31049 {|
31050 |a
31051 b
31052 |'''c'''
31053 d
31054 |}
31055 !! end
31056
31057 !! test
31058 Anchor without href scenarios
31059 !! options
31060 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
31061 !! html/parsoid
31062 <a class="bc"></a>
31063 <a class="no">dice</a>
31064 <a name="foo"></a>
31065 !! wikitext
31066
31067 dice
31068 <span name="foo"></span>
31069 !! end
31070
31071 !! test
31072 New transclusion added after a list should be serialized after the list
31073 !! options
31074 parsoid=html2wt
31075 !! html/parsoid
31076 <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>
31077 !! wikitext
31078 * a
31079 {{echo|foo}}
31080 !! end
31081
31082 # -----------------------------------------------------------------
31083 # End of section for Parsoid-only html2wt tests for serialization
31084 # of new content
31085 # -----------------------------------------------------------------
31086
31087 # -----------------------------------------------------------------
31088 # The following section of tests are primarily to spec behavior of
31089 # the selective serializer. All these tests have manual selser
31090 # changes. The automated selser changes for all tests handle the
31091 # wide variation of changes, but these tests here capture specs
31092 # deterministically.
31093 # ----------------------------------------------------------------
31094
31095 ## T90517
31096 !! test
31097 Selser: New comments should not be lost
31098 !! options
31099 parsoid={
31100 "modes": ["selser"],
31101 "changes": [
31102 [ "#a", "after", "<!--c1-->" ],
31103 [ "#b", "before", "<!--c2-->" ]
31104 ]
31105 }
31106 !! wikitext
31107 <span id="a">a</span>
31108
31109 <span id="b">b</span>
31110 !! wikitext/edited
31111 <span id="a">a</span><!--c1-->
31112
31113 <!--c2--><span id="b">b</span>
31114 !! end
31115
31116 ## T89383
31117 !! test
31118 Selser: Check for validity of DSR before using it
31119 !! options
31120 parsoid={
31121 "modes": ["selser"],
31122 "changes": [
31123 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
31124 ]
31125 }
31126 !! wikitext
31127 <span id="a">a</span>
31128 !! wikitext/edited
31129 {{DISPLAYTITLE:foo}}
31130 <span id="a">a</span>
31131 !! end
31132
31133 !! test
31134 1. DOMDiff: Changes to <ref> content should be looked up using id
31135 !! options
31136 parsoid={
31137 "modes": ["selser"],
31138 "changes": [
31139 ["#X", "after", "bar"],
31140 ["#Y", "after", "baz"]
31141 ]
31142 }
31143 !! wikitext
31144 X <ref><span id="X">foo</span></ref>
31145 Y <ref name="a" />
31146 <references>
31147 <ref name="a"><span id="Y">foo</span></ref>
31148 </references>
31149 !! wikitext/edited
31150 X <ref><span id="X">foo</span>bar</ref>
31151 Y <ref name="a" />
31152 <references>
31153 <ref name="a"><span id="Y">foo</span>baz</ref>
31154 </references>
31155 !! end
31156
31157 !! test
31158 2. DOMDiff: Changes to <ref> content should be looked up using id
31159 !! options
31160 parsoid={
31161 "modes": ["selser"],
31162 "changes": [
31163 ["#Z", "after", "bar"]
31164 ]
31165 }
31166 !! wikitext
31167 A <ref>foo bar for a</ref>
31168 B <ref group="X" name="b" />
31169
31170 <references />
31171
31172 <references group="X">
31173 <ref name="b"><span id="Z">foo</span></ref>
31174 </references>
31175 !! wikitext/edited
31176 A <ref>foo bar for a</ref>
31177 B <ref group="X" name="b" />
31178
31179 <references />
31180
31181 <references group="X">
31182 <ref name="b"><span id="Z">foo</span>bar</ref>
31183 </references>
31184 !! end
31185
31186 !! test
31187 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
31188 !! options
31189 parsoid={
31190 "modes": ["selser"],
31191 "changes": [
31192 [ "div:first-child", "text", "bar" ]
31193 ]
31194 }
31195 !! wikitext
31196 <div style="{{1x|color:red;}}%">foo</div>
31197 !! wikitext/edited
31198 <div style="{{1x|color:red;}}%">bar</div>
31199 !! end
31200
31201 !! test
31202 Empty LI (T49673)
31203 !! wikitext
31204 *a
31205 *
31206 *
31207 *b
31208 !! html+tidy
31209 <ul><li>a</li>
31210 <li class="mw-empty-elt"></li>
31211 <li class="mw-empty-elt"></li>
31212 <li>b</li></ul>
31213 !! end
31214
31215 !! test
31216 Thumbnail output
31217 !! wikitext
31218 [[File:Thumb.png|thumb]]
31219 !! html/php+tidy
31220 <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>
31221 !! html/parsoid
31222 <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>
31223 !! end
31224
31225 !! test
31226 unclosed internal link XSS (T137264)
31227 !! wikitext
31228 [[#%3Cscript%3Ealert(1)%3C/script%3E|
31229 !! html/php
31230 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
31231 </p>
31232 !! html/parsoid
31233 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
31234 !! end
31235
31236 !! test
31237 Validating that <style> isn't eaten by tidy (T167349)
31238 !! options
31239 styletag=1
31240 !! wikitext
31241 <div class="foo">
31242 <style>.foo::before { content: "<foo>"; }</style>
31243 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31244 </div>
31245 !! html/php+tidy
31246 <div class="foo">
31247 <style>.foo::before { content: "<foo>"; }</style>
31248 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
31249 </div>
31250 !! html/parsoid
31251 <div class="foo">
31252 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31253 <style data-x-data-mw-foobar="baz" typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{"data-x-data-mw-foobar":"baz"},"body":{"extsrc":".foo::after { content: \"&lt;bar>\"; }"}}'>.foo::after { content: "<bar>"; }</style>
31254 </div>
31255 !! end
31256
31257 ## Right now, Parsoid doesn't de-duplicate style tags.
31258 ## So, we shouldn't see link tags that need to bypass the sanitizer.
31259 ## In a followup patch, when we de-duplicate style tags and
31260 ## introduce link tags, we'll add a hook for link tags in
31261 ## the parser test runner script.
31262 !! test
31263 Validating that <style> isn't wrapped in a paragraph (T186965)
31264 !! options
31265 styletag=1
31266 !! wikitext
31267 A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31268
31269 <style>.foo::before { content: "<foo>"; }</style>
31270
31271 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31272
31273 But if it's on a line with other content, let it be wrapped.
31274
31275 <style>.foo::before { content: "<foo>"; }</style> bar
31276
31277 foo <style>.foo::before { content: "<foo>"; }</style>
31278
31279 foo <style>.foo::before { content: "<foo>"; }</style> bar
31280
31281 And the same if we have non-paragraph-breaking whitespace
31282
31283 foo
31284 <style>.foo::before { content: "<foo>"; }</style>
31285 bar
31286 !! html/php
31287 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31288 </p>
31289 <style>.foo::before { content: "<foo>"; }</style>
31290 <style>.foo::before { content: "<foo>"; }</style> <link rel="foo" href="bar"/><style>.foo::before { content: "<foo>"; }</style>
31291 <p>But if it's on a line with other content, let it be wrapped.
31292 </p><p><style>.foo::before { content: "<foo>"; }</style> bar
31293 </p><p>foo <style>.foo::before { content: "<foo>"; }</style>
31294 </p><p>foo <style>.foo::before { content: "<foo>"; }</style> bar
31295 </p><p>And the same if we have non-paragraph-breaking whitespace
31296 </p><p>foo
31297 <style>.foo::before { content: "<foo>"; }</style>
31298 bar
31299 </p>
31300 !! html/parsoid
31301 <p>A style tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph</p>
31302
31303 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31304
31305 <p><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style> &lt;link rel="foo" href="bar"/><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style></p>
31306
31307 <p>But if it's on a line with other content, let it be wrapped.</p>
31308
31309 <p><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style> bar</p>
31310
31311 <p>foo <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style></p>
31312
31313 <p>foo <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style> bar</p>
31314
31315 <p>And the same if we have non-paragraph-breaking whitespace</p>
31316
31317 <p>foo
31318 <style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo::before { content: \"&lt;foo>\"; }"}}'>.foo::before { content: "<foo>"; }</style>
31319 bar</p>
31320 !! end
31321
31322 !! test
31323 Validating that <link> isn't wrapped in a paragraph (T186965)
31324 !! options
31325 styletag=1
31326 !! wikitext
31327 A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31328
31329 <link rel="foo" href="bar"/>
31330
31331 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31332
31333 But if it's on a line with other content, let it be wrapped.
31334
31335 <link rel="foo" href="bar"/> bar
31336
31337 foo <link rel="foo" href="bar"/>
31338
31339 foo <link rel="foo" href="bar"/> bar
31340
31341 And the same if we have non-paragraph-breaking whitespace
31342
31343 foo
31344 <link rel="foo" href="bar"/>
31345 bar
31346 !! html/php
31347 <p>A link tag, by itself or with other style/link tags, shouldn't be wrapped in a paragraph
31348 </p>
31349 <link rel="foo" href="bar"/>
31350 <link rel="foo" href="bar"/> <style>.foo::before { content: "<foo>"; }</style><link rel="foo" href="bar"/>
31351 <p>But if it's on a line with other content, let it be wrapped.
31352 </p><p><link rel="foo" href="bar"/> bar
31353 </p><p>foo <link rel="foo" href="bar"/>
31354 </p><p>foo <link rel="foo" href="bar"/> bar
31355 </p><p>And the same if we have non-paragraph-breaking whitespace
31356 </p><p>foo
31357 <link rel="foo" href="bar"/>
31358 bar
31359 </p>
31360 !! end
31361
31362 !! test
31363 Extension returning multiple nodes starting with a style tag roundtrips
31364 !! options
31365 wgRawHtml=1
31366 !! wikitext
31367 <table>
31368 {{echo|<html><style>.hi { color: red; }</style>
31369 </html>}}
31370 <tr><td class="hi">ho</td></tr>
31371 </table>
31372 !! html/parsoid
31373 <p about="#mwt5" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"firstWikitextNode":"TABLE_html","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&lt;table>\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;html>&lt;style>.hi { color: red; }&lt;/style>\n&lt;/html>"}},"i":0}},"\n&lt;tr>&lt;td class=\"hi\">ho&lt;/td>&lt;/tr>\n&lt;/table>"]}'><style typeof="mw:Extension/html" about="#mwt4" data-mw='{"name":"html","attrs":{},"body":{"extsrc":"&lt;style>.hi { color: red; }&lt;/style>\n"}}'>.hi { color: red; }</style><span about="#mwt4">
31374 </span></p><table about="#mwt5" data-parsoid='{"stx":"html"}'>
31375
31376 <tbody><tr><td class="hi">ho</td></tr>
31377 </tbody></table>
31378 !! end
31379
31380 !! test
31381 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
31382 !! config
31383 wgFragmentMode=[ 'html5', 'legacy' ]
31384 !! wikitext
31385 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31386 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31387 !! html/php
31388 <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>
31389 <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>
31390 </p>
31391 !! html/parsoid
31392 <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>
31393 <p><a rel="mw:WikiLink" href="./Parser_test#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#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>
31394 !! end
31395
31396 !! test
31397 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
31398 !! config
31399 wgFragmentMode=[ 'legacy' ]
31400 !! wikitext
31401 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
31402 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
31403 !! html/php
31404 <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>
31405 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
31406 </p>
31407 !! end
31408
31409 !! test
31410 Decoding of HTML entities in embedded HTML tags
31411 !! wikitext
31412 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31413 !! html/php
31414 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
31415
31416 !! html/parsoid
31417 <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>
31418 !! end
31419
31420 !! test
31421 Decoding of HTML entities in indicator names for IDs (T104196)
31422 !! options
31423 parsoid=wt2html,html2html
31424 showindicators
31425 !! wikitext
31426 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31427 !! html/php
31428 1&2&3&amp;4&amp;amp;5=Indicator
31429
31430 !! html/parsoid
31431 <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>
31432 !! end
31433
31434 # this version of the test strips out the ambiguity so Parsoid rts cleanly
31435 !! test
31436 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
31437 !! options
31438 showindicators
31439 !! wikitext
31440 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
31441 !! html/php
31442 1&2&3&amp;4&amp;amp;5=Indicator
31443
31444 !! html/parsoid
31445 <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>
31446 !! end
31447
31448 # This fragment mode is what Parsoid supports.
31449 !! test
31450 HTML5 ids: fallback to legacy
31451 !! config
31452 wgFragmentMode=[ 'html5', 'legacy' ]
31453 !! wikitext
31454 ==Foo bar==
31455
31456 ==foo Bar==
31457
31458 ==Тест==
31459
31460 ==Тест==
31461
31462 ==тест==
31463
31464 ==Hey < # " > % : '==
31465 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31466
31467 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31468
31469 <!-- These two links should produce identical HTML -->
31470 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31471
31472 !! html/php
31473 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
31474 <ul>
31475 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31476 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31477 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31478 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31479 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31480 <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>
31481 </ul>
31482 </div>
31483
31484 <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>
31485 <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>
31486 <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>
31487 <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>
31488 <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>
31489 <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>
31490 <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>
31491 </p><p>💩 <span id="💩"></span>
31492 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31493 </p>
31494 !! html/parsoid
31495 <h2 id="Foo_bar">Foo bar</h2>
31496
31497 <h2 id="foo_Bar_2">foo Bar</h2>
31498
31499 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2>
31500
31501 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2>
31502
31503 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>
31504
31505 <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>
31506 <p><a rel="mw:WikiLink" href="./Parser_test#Foo_bar">#Foo bar</a> <a rel="mw:WikiLink" href="./Parser_test#foo_Bar">#foo Bar</a> <a rel="mw:WikiLink" href="./Parser_test#Тест">#Тест</a> <a rel="mw:WikiLink" href="./Parser_test#тест">#тест</a> <a rel="mw:WikiLink" href="./Parser_test#Hey_&lt;_#_&quot;_>_%_:_'" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Hey_&lt;_#_\"_>_%_:_&#39;"},"sa":{"href":"#Hey &lt; # \" > % : &#39;"}}'>#Hey &lt; # " > % : '</a></p>
31507
31508 <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>
31509
31510 <!-- These two links should produce identical HTML -->
31511 <p><a rel="mw:WikiLink" href="./Parser_test#啤酒">#啤酒</a> <a rel="mw:WikiLink" href="./Parser_test#啤酒" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#啤酒"},"sa":{"href":"#%E5%95%A4%E9%85%92"}}'>#啤酒</a></p>
31512 !! end
31513
31514 # Parsoid doesn't support this mode
31515 !! test
31516 HTML5 ids: legacy with a fallback to modern
31517 !! config
31518 wgFragmentMode=[ 'legacy', 'html5' ]
31519 !! wikitext
31520 ==Foo bar==
31521
31522 ==foo Bar==
31523
31524 ==Тест==
31525
31526 ==Тест==
31527
31528 ==тест==
31529
31530 ==Hey < # " > % : '==
31531 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31532
31533 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31534
31535 <!-- These two links should produce identical HTML -->
31536 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31537
31538 !! html/php
31539 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
31540 <ul>
31541 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31542 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31543 <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>
31544 <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>
31545 <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>
31546 <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>
31547 </ul>
31548 </div>
31549
31550 <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>
31551 <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>
31552 <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>
31553 <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>
31554 <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>
31555 <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>
31556 <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>
31557 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
31558 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
31559 </p>
31560 !! end
31561
31562 # Parsoid doesn't support this mode.
31563 !! test
31564 HTML5 ids: no legacy
31565 !! config
31566 wgFragmentMode=[ 'html5' ]
31567 !! wikitext
31568 ==Foo bar==
31569
31570 ==foo Bar==
31571
31572 ==Тест==
31573
31574 ==Тест==
31575
31576 ==тест==
31577
31578 ==Hey < # " > % : '==
31579 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
31580
31581 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
31582
31583 <!-- These two links should produce identical HTML -->
31584 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
31585
31586 !! html/php
31587 <div id="toc" class="toc"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none"/><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
31588 <ul>
31589 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
31590 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
31591 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
31592 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
31593 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
31594 <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>
31595 </ul>
31596 </div>
31597
31598 <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>
31599 <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>
31600 <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>
31601 <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>
31602 <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>
31603 <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>
31604 <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>
31605 </p><p>💩 <span id="💩"></span>
31606 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
31607 </p>
31608 !! end
31609
31610 !! test
31611 T90902: Normalize weird characters in section IDs
31612 !! config
31613 wgFragmentMode=[ 'html5', 'legacy' ]
31614 !! wikitext
31615 ==Foo&nbsp;bar==
31616 [[#Foo&nbsp;bar]]
31617
31618 !! html/php
31619 <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>
31620 <p><a href="#Foo_bar">#Foo&#160;bar</a>
31621 </p>
31622 !! html/parsoid
31623 <h2 id="Foo_bar"> Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>bar </h2>
31624 <p><a rel="mw:WikiLink" href="./Parser_test#Foo_bar" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Foo_bar"},"sa":{"href":"#Foo&amp;nbsp;bar"}}'>#Foo bar</a></p>
31625 !! end
31626
31627 !! test
31628 T51672: Test for brackets in attributes of elements in external link texts
31629 !! wikitext
31630 [http://example.com/ link <span title="title with [brackets]">span</span>]
31631 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
31632
31633 !! html/php
31634 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31635 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
31636 </p>
31637 !! html/parsoid
31638 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
31639 <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>
31640 !! end
31641
31642 !! test
31643 T72875: Test for brackets in attributes of elements in internal link texts
31644 !! wikitext
31645 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
31646 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
31647
31648 !! html/php
31649 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31650 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
31651 </p>
31652 !! html/parsoid
31653 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
31654 <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>
31655 !! end
31656
31657 !! test
31658 T199926: html arrow wt: Parsoid sometimes trips up on verticalbar chars in hrefs
31659 !! options
31660 parsoid={
31661 "modes": ["html2wt"]
31662 }
31663 !! html/parsoid
31664 <a href="https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total">9</a>
31665 <a href="https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal%7Cmap%7C2-Year~2016060100~2018071100%7C~total">10</a>
31666 !! wikitext
31667 [https://stats.wikimedia.org/v2/#/fr.wikipedia.org/reading/page-views-by-country/normal|map|2-Year~2016060100~2018071100|~total 9]
31668 [[stats:v2/#/fr.wikipedia.org/reading/page-views-by-country/normal%7Cmap%7C2-Year~2016060100~2018071100%7C~total|10]]
31669 !! end
31670
31671 !! test
31672 T179544: {{anchorencode:}} output should be always usable in links
31673 !! config
31674 wgFragmentMode=[ 'html5' ]
31675 !! wikitext
31676 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
31677 !! html/php
31678 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
31679 </p>
31680 !! html/parsoid
31681 <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="./Parser_test#[foo]" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#[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>
31682 !! end
31683
31684 ## ------------------------------
31685 ## Parsoid section-wrapping tests
31686 ## ------------------------------
31687 !! test
31688 Section wrapping for well-nested sections (no leading content)
31689 !! options
31690 parsoid={
31691 "wrapSections": true
31692 }
31693 !! wikitext
31694 =1=
31695 a
31696
31697 =2=
31698 b
31699
31700 ==2.1==
31701 c
31702
31703 ==2.2==
31704 d
31705
31706 ===2.2.1===
31707 e
31708
31709 =3=
31710 f
31711 !! html/parsoid
31712 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31713 <p>a</p>
31714
31715 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
31716 <p>b</p>
31717
31718 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
31719 <p>c</p>
31720
31721 </section><section data-mw-section-id="4"><h2 id="2.2">2.2</h2>
31722 <p>d</p>
31723
31724 <section data-mw-section-id="5"><h3 id="2.2.1">2.2.1</h3>
31725 <p>e</p>
31726
31727 </section></section></section><section data-mw-section-id="6"><h1 id="3">3</h1>
31728 <p>f</p>
31729
31730 </section>
31731 !! end
31732
31733 !! test
31734 Section wrapping for well-nested sections (with leading content)
31735 !! options
31736 parsoid={
31737 "wrapSections": true
31738 }
31739 !! wikitext
31740 Para 1.
31741
31742 Para 2 with a <div>nested in it</div>
31743
31744 Para 3.
31745
31746 =1=
31747 a
31748
31749 =2=
31750 b
31751
31752 ==2.1==
31753 c
31754 !! html/parsoid
31755 <section data-mw-section-id="0"><p>Para 1.</p>
31756
31757 <p>Para 2 with a </p><div>nested in it</div>
31758
31759 <p>Para 3.</p>
31760
31761 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
31762 <p>a</p>
31763
31764 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
31765 <p>b</p>
31766
31767 <section data-mw-section-id="3"><h2 id="2.1">2.1</h2>
31768 <p>c</p>
31769
31770 </section></section>
31771 !! end
31772
31773 !! test
31774 Section wrapping with template-generated sections (good nesting 1)
31775 !! options
31776 parsoid={
31777 "wrapSections": true
31778 }
31779 !! wikitext
31780 =1=
31781 a
31782
31783 {{echo|1=
31784 ==1.1==
31785 b
31786 }}
31787
31788 ==1.2==
31789 c
31790
31791 =2=
31792 d
31793 !! html/parsoid
31794 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31795 <p>a</p>
31796
31797 <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">
31798 </span><p about="#mwt1">b</p>
31799 </section><section data-mw-section-id="3"><h2 id="1.2">1.2</h2>
31800 <p>c</p>
31801
31802 </section></section><section data-mw-section-id="4"><h1 id="2">2</h1>
31803 <p>d</p></section>
31804 !! end
31805
31806 # In this example, the template scope is mildly expanded to incorporate the
31807 # trailing newline after the transclusion since that is part of section 1.1.1
31808 !! test
31809 Section wrapping with template-generated sections (good nesting 2)
31810 !! options
31811 parsoid={
31812 "wrapSections": true,
31813 "modes": ["wt2html", "wt2wt"]
31814 }
31815 !! wikitext
31816 =1=
31817 a
31818
31819 {{echo|1=
31820 ==1.1==
31821 b
31822 ===1.1.1===
31823 d
31824 }}
31825 =2=
31826 e
31827 !! html/parsoid
31828 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31829 <p>a</p>
31830
31831 <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">
31832 </span><p about="#mwt1">b</p><span about="#mwt1">
31833 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1">
31834 </span><p about="#mwt1">d</p><span about="#mwt1">
31835 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2">2</h1>
31836 <p>e</p></section>
31837 !! end
31838
31839 # In this example, the template scope is mildly expanded to incorporate the
31840 # trailing newline after the transclusion since that is part of section 1.2.1
31841 !! test
31842 Section wrapping with template-generated sections (good nesting 3)
31843 !! options
31844 parsoid={
31845 "wrapSections": true,
31846 "modes": ["wt2html", "wt2wt"]
31847 }
31848 !! wikitext
31849 =1=
31850 a
31851
31852 {{echo|1=
31853 x
31854 ==1.1==
31855 b
31856 ==1.2==
31857 c
31858 ===1.2.1===
31859 d
31860 }}
31861 =2=
31862 e
31863 !! html/parsoid
31864 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
31865 <p>a</p>
31866
31867 <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">
31868 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1">
31869 </span><p about="#mwt1">b</p><span about="#mwt1">
31870 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
31871 </span><p about="#mwt1">c</p><span about="#mwt1">
31872 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
31873 </span><p about="#mwt1">d</p><span about="#mwt1">
31874 </span></section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1>
31875 <p>e</p></section>
31876 !! end
31877
31878 # Because of section-wrapping and template-wrapping interactions,
31879 # the scope of the template is expanded so that the template markup
31880 # is valid in the presence of <section> tags.
31881 # This exercises the s1 is null scenario in the wrapSections code
31882 !! test
31883 Section wrapping with template-generated sections (bad nesting 1)
31884 !! options
31885 parsoid={
31886 "wrapSections": true
31887 }
31888 !! wikitext
31889 <div>
31890 a
31891
31892 {{echo|
31893 =1=
31894 b
31895 }}
31896
31897 c
31898 </div>
31899 !! html/parsoid
31900 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
31901 <p>a</p>
31902
31903 <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"]}'>
31904 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1">1</h1><span about="#mwt1">
31905 </span><p about="#mwt1">b
31906 </p><span about="#mwt1">
31907
31908 </span><p about="#mwt1">c</p><span about="#mwt1">
31909 </span></section></div></section>
31910 !! end
31911
31912 # Because of section-wrapping and template-wrapping interactions,
31913 # the scope of the template is expanded so that the template markup
31914 # is valid in the presence of <section> tags.
31915 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
31916 !! test
31917 Section wrapping with template-generated sections (bad nesting 2)
31918 !! options
31919 parsoid={
31920 "wrapSections": true
31921 }
31922 !! wikitext
31923 =1=
31924 a
31925
31926 {{echo|1=
31927 =2=
31928 b
31929 ==2.1==
31930 c
31931 }}
31932
31933 d
31934
31935 =3=
31936 e
31937 !! html/parsoid
31938 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1">1</h1>
31939 <p>a</p>
31940
31941 </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">
31942 </span><p about="#mwt1">b</p><span about="#mwt1">
31943 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1">
31944 </span><p about="#mwt1">c</p><span about="#mwt1">
31945
31946 </span><p about="#mwt1">d</p><span about="#mwt1">
31947
31948 </span></section></section><section data-mw-section-id="4"><h1 id="3">3</h1>
31949 <p>e</p></section>
31950 !! end
31951
31952 # Because of section-wrapping and template-wrapping interactions,
31953 # additional template wrappers are added to <section> tags
31954 # so that template wrapping semantics are valid whether section
31955 # tags are retained or stripped. But, the template scope can expand
31956 # greatly when accounting for section tags.
31957 # This exercises the s1 and s2 are in different subtrees scenario
31958 !! test
31959 Section wrapping with template-generated sections (bad nesting 3)
31960 !! options
31961 parsoid={
31962 "wrapSections": true,
31963 "modes": ["wt2html", "wt2wt"]
31964 }
31965 !! wikitext
31966 =1=
31967 a
31968
31969 {{echo|1=
31970 ==1.2==
31971 b
31972 =2=
31973 c
31974 }}
31975
31976 d
31977
31978 =3=
31979 e
31980 !! html/parsoid
31981 <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>
31982 <p>a</p>
31983
31984 <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">
31985 </span><p about="#mwt1">b</p><span about="#mwt1">
31986 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1">
31987 </span><p about="#mwt1">c</p>
31988
31989 <p>d</p>
31990 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3">3</h1>
31991 <p>e</p></section>
31992 !! end
31993
31994 !! test
31995 Section wrapping with uneditable lead section + div wrapping multiple sections
31996 !! options
31997 parsoid={
31998 "wrapSections": true
31999 }
32000 !! wikitext
32001 foo
32002
32003 <div style="border:1px solid red;">
32004 =1=
32005 a
32006
32007 ==1.1==
32008 b
32009
32010 =2=
32011 c
32012 </div>
32013
32014 =3=
32015 d
32016
32017 ==3.1==
32018 e
32019 !! html/parsoid
32020 <section data-mw-section-id="-1"><p>foo</p>
32021
32022 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
32023 <section data-mw-section-id="1"><h1 id="1">1</h1>
32024 <p>a</p>
32025
32026 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
32027 <p>b</p>
32028
32029 </section></section><section data-mw-section-id="-1"><h1 id="2">2</h1>
32030 <p>c</p>
32031 </section></div>
32032
32033 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
32034 <p>d</p>
32035
32036 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
32037 <p>e</p>
32038 </section></section>
32039 !! end
32040
32041 !! test
32042 Section wrapping with editable lead section + div overlapping multiple sections
32043 !! options
32044 parsoid={
32045 "wrapSections": true
32046 }
32047 !! wikitext
32048 foo
32049
32050 =1=
32051 a
32052 <div style="border:1px solid red;">
32053 b
32054
32055 ==1.1==
32056 c
32057
32058 =2=
32059 d
32060 </div>
32061 e
32062
32063 =3=
32064 f
32065
32066 ==3.1==
32067 g
32068 !! html/parsoid
32069 <section data-mw-section-id="0"><p>foo</p>
32070
32071 </section><section data-mw-section-id="-1"><h1 id="1">1</h1>
32072 <p>a</p>
32073 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
32074 <p>b</p>
32075
32076 <section data-mw-section-id="2"><h2 id="1.1">1.1</h2>
32077 <p>c</p>
32078
32079 </section><section data-mw-section-id="-1"><h1 id="2">2</h1>
32080 <p>d</p>
32081 </section></div>
32082 <p>e</p>
32083
32084 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
32085 <p>f</p>
32086
32087 <section data-mw-section-id="5"><h2 id="3.1">3.1</h2>
32088 <p>g</p>
32089 </section></section>
32090 !! end
32091
32092 !! test
32093 HTML header tags should not be wrapped in section tags
32094 !! options
32095 parsoid={
32096 "wrapSections": true
32097 }
32098 !! wikitext
32099 foo
32100
32101 <h1>a</h1>
32102
32103 =b=
32104
32105 <h1>c</h1>
32106
32107 =d=
32108 !! html/parsoid
32109 <section data-mw-section-id="0"><p>foo</p>
32110
32111 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
32112
32113 </section><section data-mw-section-id="1"><h1 id="b">b</h1>
32114
32115 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
32116
32117 </section><section data-mw-section-id="2"><h1 id="d">d</h1></section>
32118 !! end
32119
32120 !! test
32121 Lead section containing only whitespace and comments.
32122 !! options
32123 parsoid={
32124 "wrapSections": true
32125 }
32126 !! wikitext
32127
32128 <!-- this is a comment, presumably significant to editors -->
32129 =1=
32130 a
32131
32132 =2=
32133 b
32134 !! html/parsoid
32135 <section data-mw-section-id="0" data-parsoid="{}">
32136 <!-- this is a comment, presumably significant to editors -->
32137 </section><section data-mw-section-id="1"><h1 id="1">1</h1>
32138 <p>a</p>
32139
32140 </section><section data-mw-section-id="2"><h1 id="2">2</h1>
32141 <p>b</p></section>
32142 !! end
32143
32144 !! test
32145 Pseudo-sections emitted by templates should have id -2
32146 !! options
32147 parsoid={
32148 "wrapSections": true
32149 }
32150 !! wikitext
32151 foo
32152 {{echo|<div>
32153 ==a==
32154 ==b==
32155 </div>
32156 }}
32157 !! html/parsoid
32158 <section data-mw-section-id="-1"><p>foo</p>
32159 </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}}]}'>
32160 <section data-mw-section-id="-1"><h2 id="a">a</h2>
32161 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
32162 </section></div><span about="#mwt1">
32163 </span></section>
32164 !! end
32165
32166 ##########################################################################
32167 Tests demonstrating white-space insensitivity in input wikitext
32168 for wikitext headings, wikitext list items, and wikitext table captions,
32169 headings, and cells. HTML versions of the same should preserve whitespace.
32170 ##########################################################################
32171 !! test
32172 Trim whitespace in wikitext headings, list items, table captions, headings, and cells
32173 !! options
32174 parsoid={
32175 "modes": ["wt2html"],
32176 "preserveIEW": true
32177 }
32178 !! wikitext
32179 __NOTOC__
32180 == <!--c1--> <!--c2--> Spaces <!--c3--> <!--c4--> ==
32181 == <!--c1--> <!--c2--> Tabs <!--c3--><!--c4--> ==
32182 == <!--Headings with fallback ids--> Личная жизнь ==
32183 * <!--c1--> <!--c2--> List item <!--c3--> <!--c4-->
32184 ; <!--term to define--> term : <!--term's definition--> definition
32185 {|
32186 |+ <!--c1--> <!--c2--> Table Caption <!--c3--> <!--c4-->
32187 |-
32188 ! <!--c1--> <!--c2--> Table Heading 1 <!--c3--> <!--c4--> !! Table Heading 2 <!--c5-->
32189 |-
32190 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32191 |-
32192 | class="foo" || <!--c1--> <!--c2--> Table Cell 3 <!--c3--> <!--c4-->
32193 |-
32194 | <!--c1--> testing [[one|two]] <!--c2--> | <!--c3--> some content
32195 |}
32196 : {|
32197 | <!--c1--> <!--c2--> Table Cell 1 <!--c3--> <!--c4--> || Table Cell 2 <!--c5-->
32198 |} foo <!--c1-->
32199 !! html/php+tidy
32200 <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>
32201 <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>
32202 <h2><span class="mw-headline" id=".D0.9B.D0.B8.D1.87.D0.BD.D0.B0.D1.8F_.D0.B6.D0.B8.D0.B7.D0.BD.D1.8C">Личная жизнь</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: Личная жизнь">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
32203 <ul><li>List item</li></ul>
32204 <dl><dt>term&#160;</dt>
32205 <dd>definition</dd></dl>
32206 <table>
32207 <caption>Table Caption
32208 </caption>
32209 <tbody><tr>
32210 <th>Table Heading 1</th>
32211 <th>Table Heading 2
32212 </th></tr>
32213 <tr>
32214 <td>Table Cell 1</td>
32215 <td>Table Cell 2
32216 </td></tr>
32217 <tr>
32218 <td>class="foo"</td>
32219 <td>Table Cell 3
32220 </td></tr>
32221 <tr>
32222 <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
32223 </td></tr></tbody></table>
32224 <dl><dd><table>
32225 <tbody><tr>
32226 <td>Table Cell 1</td>
32227 <td>Table Cell 2
32228 </td></tr></tbody></table> foo</dd></dl>
32229 !! html/parsoid
32230 <meta property="mw:PageProp/notoc">
32231 <h2 id="Spaces"><!--c1--><!--c2-->Spaces<!--c3--><!--c4--></h2>
32232 <h2 id="Tabs"><!--c1--><!--c2-->Tabs<!--c3--><!--c4--></h2>
32233 <h2 id="Личная_жизнь"><span id=".D0.9B.D0.B8.D1.87.D0.BD.D0.B0.D1.8F_.D0.B6.D0.B8.D0.B7.D0.BD.D1.8C" typeof="mw:FallbackId"></span><!--Headings with fallback ids-->Личная жизнь</h2>
32234 <ul><li><!--c1--><!--c2-->List item<!--c3--><!--c4--></li></ul>
32235 <dl><dt><!--term to define-->term&nbsp;</dt><dd><!--term's definition-->definition</dd></dl>
32236 <table>
32237 <caption><!--c1--><!--c2-->Table Caption<!--c3--><!--c4--></caption>
32238 <tbody><tr>
32239 <th><!--c1--><!--c2-->Table Heading 1<!--c3--><!--c4--></th><th>Table Heading 2<!--c5--></th></tr>
32240 <tr>
32241 <td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32242 <tr>
32243 <td>class="foo"</td><td><!--c1--><!--c2-->Table Cell 3<!--c3--><!--c4--></td></tr>
32244 <tr>
32245 <td><!--c1-->testing <a rel="mw:WikiLink" href="./One" title="One">two</a> <!--c2--> | <!--c3--> some content</td></tr>
32246 </tbody></table>
32247 <dl><dd><table>
32248 <tbody><tr><td><!--c1--><!--c2-->Table Cell 1<!--c3--><!--c4--></td><td>Table Cell 2<!--c5--></td></tr>
32249 </tbody></table> foo<!--c1--></dd></dl>
32250 !! end
32251
32252 # Looks like <caption> is not accepted in HTML
32253 !! test
32254 Do not trim whitespace in HTML headings, list items, table captions, headings, and cells
32255 !! options
32256 parsoid={
32257 "modes": ["wt2html"],
32258 "preserveIEW": true
32259 }
32260 !! wikitext
32261 __NOTOC__
32262 <h2> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32263 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32264 <table>
32265 <tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> <th></tr>
32266 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> <th></tr>
32267 </table>
32268 !! html/php+tidy
32269 <h2><span class="mw-headline" id="Heading"> Heading </span></h2>
32270 <ul><li> List item </li></ul>
32271 <table>
32272 <tbody><tr><th> Table Heading </th><th></th></tr>
32273 <tr><td> Table Cell </td><th></th></tr>
32274 </tbody></table>
32275 !! html/parsoid
32276 <meta property="mw:PageProp/notoc"/>
32277 <h2 id="Heading"> <!--c1--> <!--c2--> Heading <!--c3--> <!--c4--> </h2>
32278 <ul><li> <!--c1--> <!--c2--> List item <!--c3--> <!--c4--> </li></ul>
32279 <table>
32280 <tbody><tr><th> <!--c1--> <!--c2--> Table Heading <!--c3--> <!--c4--> </th><th></th></tr>
32281 <tr><td> <!--c1--> <!--c2--> Table Cell <!--c3--> <!--c4--> </td><th></th></tr>
32282 </tbody></table>
32283 !! end
32284
32285 !! test
32286 Do not trim whitespace in links and quotes
32287 !! options
32288 parsoid={
32289 "modes": ["wt2html"],
32290 "preserveIEW": true
32291 }
32292 !! wikitext
32293 foo '' <!--c1--> italic <!--c2--> '' and ''' <!--c3--> bold <!--c4--> '''
32294 [[Foo| some text ]]
32295 !! html/php+tidy
32296 <p>foo <i> italic </i> and <b> bold </b>
32297 <a href="/wiki/Foo" title="Foo"> some text </a>
32298 </p>
32299 !! html/parsoid
32300 <p>foo <i> <!--c1--> italic <!--c2--> </i> and <b> <!--c3--> bold <!--c4--> </b>
32301 <a rel="mw:WikiLink" href="./Foo" title="Foo"> some text </a></p>
32302 !! end
32303
32304 !! test
32305 Remove p tags surrounding a single element in a figcaption
32306 !! options
32307 parsoid=html2wt
32308 !! wikitext
32309 [[File:Foobar.jpg|right|200x200px|Caption]]
32310 !! html/parsoid
32311 <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>
32312 !! end
32313
32314 !! test
32315 Selser preserves lack of newline before list and allows newline after the list
32316 !! options
32317 parsoid={
32318 "modes": ["selser"],
32319 "scrubWikitext": true,
32320 "changes": [
32321 [ "ul", "after", "<p>footer</p>" ]
32322 ]
32323 }
32324 !! wikitext
32325 header
32326 *foo
32327 *bar
32328 !! wikitext/edited
32329 header
32330 *foo
32331 *bar
32332
32333 footer
32334 !! end
32335
32336
32337 !! test
32338 Selser does not introduce newlines between unedited paragraph preceding the list
32339 !! options
32340 parsoid={
32341 "modes": ["selser"],
32342 "changes": [
32343 [ "table tbody tr td p:last-child", "empty" ]
32344 ]
32345 }
32346 !! wikitext
32347 {|
32348 |
32349 header
32350 *foo
32351 *bar
32352 footer
32353 |}
32354 !! wikitext/edited
32355 {|
32356 |
32357 header
32358 *foo
32359 *bar
32360
32361 |}
32362 !! end
32363
32364 !! test
32365 Selser does not introduce newlines between unedited paragraph following the list
32366 !! options
32367 parsoid={
32368 "modes": ["selser"],
32369 "changes": [
32370 [ "table tbody tr td p:first-child", "empty" ]
32371 ]
32372 }
32373 !! wikitext
32374 {|
32375 |
32376 header
32377 *foo
32378 *bar
32379 footer
32380 |}
32381 !! wikitext/edited
32382 {|
32383 |
32384
32385 *foo
32386 *bar
32387 footer
32388 |}
32389 !! end
32390
32391 !! test
32392 Remove a list item but do not insert newline above list
32393 !! options
32394 parsoid={
32395 "modes": ["selser"],
32396 "changes": [
32397 [ "ul li:last-child", "remove" ]
32398 ]
32399 }
32400 !! wikitext
32401 header
32402 *foo
32403 *bar
32404 footer
32405 !! wikitext/edited
32406 header
32407 *foo
32408 footer
32409 !! end