ad69b9fb9bb18c9236dfc9077a064ac3c7741175
[lhc/web/wiklou.git] / tests / parser / parserTests.txt
1 # MediaWiki Parser test cases
2 # Some taken from https://meta.wikimedia.org/wiki/Parser_testing
3 # All (C) their respective authors and released under the GPL
4 #
5 # The syntax should be fairly self-explanatory.
6 #
7 # Currently supported test options:
8 # One of the following three:
9 #
10 # (default) generate HTML output
11 # pst apply pre-save transform
12 # msg apply message transform
13 #
14 # Plus any combination of these:
15 #
16 # cat add category links
17 # (ignored by Parsoid, since it emits <link>s)
18 # ill add inter-language links
19 # (ignored by Parsoid, since it emits <link>s)
20 # subpage enable subpages (disabled by default)
21 # title=[[XXX]] run test using article title XXX
22 # language=XXX set content language to XXX for this test
23 # variant=XXX set the variant of language for this test (eg zh-tw)
24 # disabled do not run test
25 # parsoid parsoid-specific options (not run by PHP parser unless
26 # the test includes an html/php section)
27 # php php-only test (not run by the parsoid parser unless
28 # the test includes an html/parsoid section)
29 # showtitle make the first line the title
30 # showindicators make the first lines the page status indicators
31 # comment run through Linker::formatComment() instead of main parser
32 # local format section links in edit comment text as local links
33 # notoc disable table of contents
34 # thumbsize=NNN set the default thumb size to NNNpx for this test
35 # wrap include the normal wrapper <div class="mw-parser-output"> (since 1.30)
36 #
37 # You can also set the following parser properties via test options:
38 # wgEnableUploads, wgAllowExternalImages, wgMaxTocLevel,
39 # wgLinkHolderBatchSize, wgRawHtml, wgInterwikiMagic,
40 # wgEnableMagicLinks
41 #
42 # For testing purposes, temporary articles can created:
43 # !!article / NAMESPACE:TITLE / !!text / ARTICLE TEXT / !!endarticle
44 # where '/' denotes a newline.
45
46 # This is the standard article assumed to exist.
47 !! article
48 Main Page
49 !! text
50 blah blah
51 !! endarticle
52
53 !!article
54 Foo
55 !!text
56 FOO
57 !!endarticle
58
59 !!article
60 Template:Foo
61 !!text
62 FOO
63 !!endarticle
64
65 !! article
66 Template:Blank
67 !! text
68 !! endarticle
69
70 !! article
71 Template:pipe
72 !! text
73 |
74 !! endarticle
75
76 !! article
77 Template:=
78 !! text
79 <nowiki>=</nowiki>
80 !! endarticle
81
82 !!article
83 MediaWiki:bad image list
84 !!text
85 * [[File:Bad.jpg]] except [[Nasty page]]
86 !!endarticle
87
88 !! article
89 Template:inner list
90 !! text
91 * item 1
92 !! endarticle
93
94 !! article
95 Template:tbl-start
96 !! text
97 {|
98 !! endarticle
99
100 !! article
101 Template:tbl-end
102 !! text
103 |}
104 !! endarticle
105
106 !! article
107 Template:echo
108 !! text
109 {{{1}}}
110 !! endarticle
111
112 // For Serbian; localize Template namespace
113 !! article
114 Шаблон:Echo
115 !! text
116 {{{1}}}
117 !! endarticle
118
119 !! article
120 Template:echo_with_span
121 !! text
122 <span>{{{1}}}</span>
123 !! endarticle
124
125 !! article
126 Template:echo_with_div
127 !! text
128 <div>{{{1}}}</div>
129 !! endarticle
130
131 !! article
132 Template:blank_param
133 !! text
134 {{{1}}}
135 {{{}}}
136 !! endarticle
137
138 !! article
139 Template:table_attribs
140 !! text
141 <noinclude>
142 |</noinclude>style="color:red;"|Foo
143 !! endarticle
144
145 !! article
146 Template:table_attribs_2
147 !! text
148 <noinclude>
149 |</noinclude>style="color:red;"|Foo
150 |Bar||Baz
151 !! endarticle
152
153 !! article
154 Template:table_attribs_3
155 !! text
156 <noinclude>
157 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo
158 !! endarticle
159
160 !! article
161 Template:table_attribs_4
162 !! text
163 | style="background-color:#DC241f;" width="10px" |
164 !! endarticle
165
166 !! article
167 Template:table_attribs_5
168 !! text
169 <noinclude>
170 |</noinclude>style="color:red;"||Bar
171 !! endarticle
172
173 !! article
174 Template:table_attribs_6
175 !! text
176 style="background: <nowiki>
177
178
179 red;</nowiki>" |
180 !! endarticle
181
182 !! article
183 Template:table_attribs_7
184 !! text
185 <noinclude>
186 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
187 !! endarticle
188
189 !! article
190 Template:table_header_cells
191 !! text
192 {{table_attribs}}!!style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
193 !! endarticle
194
195 !! article
196 Template:table_cells
197 !! text
198 {{table_attribs}}||style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
199 !! endarticle
200
201 !! article
202 Template:PartialTable
203 !! text
204 {|
205 |-
206 !! endarticle
207
208 !! article
209 Template:image_attribs
210 !! text
211 <noinclude>
212 [[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
213 !! endarticle
214
215 ## See T48811 for details
216 !! article
217 Template:mixed_attr_content_template
218 !! text
219 style="color:red;" title="T48811"
220 |-
221 |foo
222 !! endarticle
223
224 !! article
225 Template:definition_list
226 !! text
227 one
228 ::two
229 !! endarticle
230
231 !! article
232 A?b
233 !! text
234 Weirdo titles!
235 !! endarticle
236
237 !!article
238 Template:Bullet
239 !!text
240 * Bar
241 !!endarticle
242
243 !!article
244 Template:OpenTable
245 !!text
246 {|
247 !!endarticle
248
249 !!article
250 Template:EmptyLITest
251 !!text
252 *a
253 *
254 *
255 *b
256 !!endarticle
257
258 !!article
259 Template:EmptyTRTest
260 !!text
261 {|
262 |-
263 |-
264 |foo
265 |-
266 |-
267 |bar
268 |}
269 !!endarticle
270
271 !!article
272 Template:EmptyTRWithHTMLAttrTest
273 !!text
274 <table>
275 <tr align="center"></tr>
276 <tr><td>foo</td></tr>
277 <tr align="center"></tr>
278 <tr><td>bar</td></tr>
279 </table>
280 !!endarticle
281
282 !! article
283 Template:CircularRef
284 !! text
285 <ref>{{CircularRef}}</ref>
286 !! endarticle
287
288 !! article
289 Template:With: Colon
290 !! text
291 Template with colon
292 !! endarticle
293
294 ###
295 ### Basic tests
296 ###
297 !! test
298 Blank input
299 !! wikitext
300 !! html
301 !! end
302
303 !! test
304 CircularRef
305 !! wikitext
306 {{CircularRef}}
307 <references />
308 !! html/parsoid
309 <p><span about="#mwt1" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"CircularRef","href":"./Template:CircularRef"},"params":{},"i":0}}]}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></p>
310 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">Error: Expansion loop detected at <a data-parsoid='{"a":{"href":null},"sa":{"href":"Template:CircularRef"}}'>Template:CircularRef</a></span></li></ol>
311 !! end
312
313 !! test
314 Simple paragraph
315 !! wikitext
316 This is a simple paragraph.
317 !! html
318 <p>This is a simple paragraph.
319 </p>
320 !! end
321
322 !! test
323 Paragraphs with extra newline spacing
324 !! wikitext
325 foo
326
327 bar
328
329
330 baz
331
332
333
334 booz
335 !! html
336 <p>foo
337 </p><p>bar
338 </p><p><br />
339 baz
340 </p><p><br />
341 </p><p>booz
342 </p>
343 !! end
344
345 !! test
346 Paragraphs with newline spacing with comment lines in between
347 !! wikitext
348 ----
349 a
350 <!--foo-->
351 b
352 ----
353 a
354 <!--foo--><!--More than 1 comment, still stripped-->
355 b
356 ----
357 a
358 <!--foo--> <!----> <!-- bar -->
359 b
360 ----
361 a
362 <!--foo-->
363
364 b
365 ----
366 a
367
368 <!--foo-->
369 b
370 ----
371 a
372 <!--foo-->
373
374
375 b
376 ----
377 a
378
379
380 <!--foo-->
381 b
382 ----
383 !! html
384 <hr />
385 <p>a
386 b
387 </p>
388 <hr />
389 <p>a
390 b
391 </p>
392 <hr />
393 <p>a
394 b
395 </p>
396 <hr />
397 <p>a
398 </p><p>b
399 </p>
400 <hr />
401 <p>a
402 </p><p>b
403 </p>
404 <hr />
405 <p>a
406 </p><p><br />
407 b
408 </p>
409 <hr />
410 <p>a
411 </p><p><br />
412 b
413 </p>
414 <hr />
415
416 !! end
417
418 !! test
419 Paragraphs with newline spacing with non-empty white-space lines in between
420 !! wikitext
421 ----
422 a
423
424 b
425 ----
426 a
427
428
429 b
430 ----
431 !! html
432 <hr />
433 <p>a
434 </p><p>b
435 </p>
436 <hr />
437 <p>a
438 </p><p><br />
439 b
440 </p>
441 <hr />
442
443 !! end
444
445 !! test
446 Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
447 !! wikitext
448 ----
449 a
450 <!--foo-->
451 b
452 ----
453 a
454 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
455 b
456 ----
457 a
458
459 <!--foo-->
460 <!--bar-->
461 b
462 ----
463 a
464
465 <!--foo-->
466 <!--bar-->
467
468 b
469 ----
470 !! html
471 <hr />
472 <p>a
473 b
474 </p>
475 <hr />
476 <p>a
477 b
478 </p>
479 <hr />
480 <p>a
481 </p><p>b
482 </p>
483 <hr />
484 <p>a
485 </p><p><br />
486 b
487 </p>
488 <hr />
489
490 !! end
491
492 !! test
493 Extra newlines: More paragraphs with indented comment
494 !! wikitext
495 a
496
497 <!--boo-->
498
499 b
500 !! html
501 <p>a
502 </p><p><br />
503 b
504 </p>
505 !!end
506
507 !! test
508 Extra newlines followed by heading
509 !! wikitext
510 a
511
512
513
514 =b=
515 [[a]]
516
517
518 =b=
519 !! html
520 <p>a
521 </p><p><br />
522 </p>
523 <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>
524 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
525 </p><p><br />
526 </p>
527 <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>
528
529 !! end
530
531 !! test
532 Extra newlines between heading and content are swallowed
533 !! wikitext
534 =b=
535
536
537
538 [[a]]
539 !! html
540 <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>
541 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
542 </p>
543 !! end
544
545 !! test
546 Heading with line break in nowiki
547 !! options
548 parsoid=wt2html
549 !! config
550 wgFragmentMode=[ 'html5', 'legacy' ]
551 !! wikitext
552 == A <nowiki>B
553 C</nowiki> ==
554 !! html/php
555 <h2><span id="A_B.0AC"></span><span class="mw-headline" id="A_B
556 C">A B
557 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>
558
559 !! html/parsoid
560 <h2 id="A_B
561 C"><span id="A_B.0AC" typeof="mw:FallbackId"></span> A <span typeof="mw:Nowiki">B
562 C</span> </h2>
563 !! end
564
565 !! test
566 Parsing an URL
567 !! wikitext
568 http://fr.wikipedia.org/wiki/🍺
569 <!-- EasterEgg we love beer, better be able be able to link to it -->
570 !! html
571 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
572 </p>
573 !! end
574
575 !! test
576 Simple list
577 !! wikitext
578 * Item 1
579 * Item 2
580 !! html
581 <ul><li> Item 1</li>
582 <li> Item 2</li></ul>
583
584 !! end
585
586 !! test
587 Italics and bold
588 !! wikitext
589 * plain
590 * plain''italic''plain
591 * plain''italic''plain''italic''plain
592 * plain'''bold'''plain
593 * plain'''bold'''plain'''bold'''plain
594 * plain''italic''plain'''bold'''plain
595 * plain'''bold'''plain''italic''plain
596 * plain''italic'''bold-italic'''italic''plain
597 * plain'''bold''bold-italic''bold'''plain
598 * plain'''''bold-italic'''italic''plain
599 * plain'''''bold-italic''bold'''plain
600 * plain''italic'''bold-italic'''''plain
601 * plain'''bold''bold-italic'''''plain
602 * plain l'''italic''plain
603 * plain l''''bold''' plain
604 !! html
605 <ul><li> plain</li>
606 <li> plain<i>italic</i>plain</li>
607 <li> plain<i>italic</i>plain<i>italic</i>plain</li>
608 <li> plain<b>bold</b>plain</li>
609 <li> plain<b>bold</b>plain<b>bold</b>plain</li>
610 <li> plain<i>italic</i>plain<b>bold</b>plain</li>
611 <li> plain<b>bold</b>plain<i>italic</i>plain</li>
612 <li> plain<i>italic<b>bold-italic</b>italic</i>plain</li>
613 <li> plain<b>bold<i>bold-italic</i>bold</b>plain</li>
614 <li> plain<i><b>bold-italic</b>italic</i>plain</li>
615 <li> plain<b><i>bold-italic</i>bold</b>plain</li>
616 <li> plain<i>italic<b>bold-italic</b></i>plain</li>
617 <li> plain<b>bold<i>bold-italic</i></b>plain</li>
618 <li> plain l'<i>italic</i>plain</li>
619 <li> plain l'<b>bold</b> plain</li></ul>
620
621 !! end
622
623 # this example taken from the [[simple:Moon]] article (T49326)
624 !! test
625 Italics and possessives (1)
626 !! wikitext
627 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
628 !! html
629 <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
630 </p>
631 !! end
632
633 # this example taken from [[en:Flaming Pie]] (T51926)
634 !! test
635 Italics and possessives (2)
636 !! wikitext
637 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
638 !! html
639 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
640 </p>
641 !! end
642
643 # this example taken from [[en:Dictionary]] (T51926)
644 !! test
645 Italics and possessives (3)
646 !! wikitext
647 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''.
648 !! html
649 <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>.
650 </p>
651 !! end
652
653
654 ###
655 ### 2-quote opening sequence tests
656 ###
657 !! test
658 Italics and bold: 2-quote opening sequence: (2,2)
659 !! wikitext
660 ''foo''
661 !! html
662 <p><i>foo</i>
663 </p>
664 !!end
665
666 !! test
667 Italics and bold: 2-quote opening sequence: (2,3)
668 !! wikitext
669 ''foo'''
670 !! html/*
671 <p><i>foo'</i>
672 </p>
673 !!end
674
675 !! test
676 Italics and bold: 2-quote opening sequence: (2,4)
677 !! options
678 parsoid=wt2html
679 !! wikitext
680 ''foo''''
681 !! html/*
682 <p><i>foo''</i>
683 </p>
684 !!end
685
686 # same html as previous, but wikitext adjusted to match parsoid html2wt
687 !! test
688 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
689 !! wikitext
690 ''foo<nowiki>''</nowiki>''
691 !! html
692 <p><i>foo''</i>
693 </p>
694 !! end
695
696 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
697 !! test
698 Italics and bold: 2-quote opening sequence: (2,5)
699 !! options
700 parsoid=wt2html
701 !! wikitext
702 ''foo'''''
703 !! html/php
704 <p><i>foo</i>
705 </p>
706 !! html/parsoid
707 <p><i>foo</i><b></b>
708 </p>
709 !!end
710
711 # same html as previous, but wikitext adjusted to match parsoid html2wt
712 !! test
713 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
714 !! wikitext
715 ''foo'''''<nowiki/>'''
716 !! html/php
717 <p><i>foo</i>
718 </p>
719 !! html/parsoid
720 <p><i>foo</i><b></b>
721 </p>
722 !! end
723
724
725 ###
726 ### 3-quote opening sequence tests
727 ###
728
729 !! test
730 Italics and bold: 3-quote opening sequence: (3,2)
731 !! wikitext
732 '''foo''
733 !! html/*
734 <p>'<i>foo</i>
735 </p>
736 !!end
737
738 !! test
739 Italics and bold: 3-quote opening sequence: (3,3)
740 !! wikitext
741 '''foo'''
742 !! html
743 <p><b>foo</b>
744 </p>
745 !!end
746
747 !! test
748 Italics and bold: 3-quote opening sequence: (3,4)
749 !! wikitext
750 '''foo''''
751 !! html/*
752 <p><b>foo'</b>
753 </p>
754 !!end
755
756 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
757 !! test
758 Italics and bold: 3-quote opening sequence: (3,5)
759 !! options
760 parsoid=wt2html
761 !! wikitext
762 '''foo'''''
763 !! html/php
764 <p><b>foo</b>
765 </p>
766 !! html/parsoid
767 <p><b>foo</b><i></i>
768 </p>
769 !!end
770
771 # same html as previous, but wikitext adjusted to match parsoid html2wt
772 !! test
773 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
774 !! wikitext
775 '''foo'''''<nowiki/>''
776 !! html/php
777 <p><b>foo</b>
778 </p>
779 !! html/parsoid
780 <p><b>foo</b><i></i>
781 </p>
782 !! end
783
784
785 ###
786 ### 4-quote opening sequence tests
787 ###
788
789 !! test
790 Italics and bold: 4-quote opening sequence: (4,2)
791 !! options
792 parsoid=wt2html
793 !! wikitext
794 ''''foo''
795 !! html/*
796 <p>''<i>foo</i>
797 </p>
798 !!end
799
800 # same html as previous, but wikitext adjusted to match parsoid html2wt
801 !! test
802 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
803 !! wikitext
804 <nowiki>''</nowiki>''foo''
805 !! html
806 <p>''<i>foo</i>
807 </p>
808 !! end
809
810 !! test
811 Italics and bold: 4-quote opening sequence: (4,3)
812 !! wikitext
813 ''''foo'''
814 !! html/*
815 <p>'<b>foo</b>
816 </p>
817 !!end
818
819 !! test
820 Italics and bold: 4-quote opening sequence: (4,4)
821 !! options
822 parsoid=wt2html
823 !! wikitext
824 ''''foo''''
825 !! html/*
826 <p>'<b>foo'</b>
827 </p>
828 !!end
829
830 # same html as previous, but wikitext adjusted to match parsoid html2wt
831 !! test
832 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
833 !! wikitext
834 '<nowiki/>'''foo''''
835 !! html
836 <p>'<b>foo'</b>
837 </p>
838 !! end
839
840 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
841 !! test
842 Italics and bold: 4-quote opening sequence: (4,5)
843 !! options
844 parsoid=wt2html
845 !! wikitext
846 ''''foo'''''
847 !! html/php
848 <p>'<b>foo</b>
849 </p>
850 !! html/parsoid
851 <p>'<b>foo</b><i></i>
852 </p>
853 !!end
854
855 # same html as previous, but wikitext adjusted to match parsoid html2wt
856 !! test
857 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
858 !! wikitext
859 '<nowiki/>'''foo'''''<nowiki/>''
860 !! html/php
861 <p>'<b>foo</b>
862 </p>
863 !! html/parsoid
864 <p>'<b>foo</b><i></i>
865 </p>
866 !! end
867
868
869 ###
870 ### 5-quote opening sequence tests
871 ###
872
873 !! test
874 Italics and bold: 5-quote opening sequence: (5,2)
875 !! options
876 parsoid=wt2html
877 !! wikitext
878 '''''foo''
879 !! html/*
880 <p><b><i>foo</i></b>
881 </p>
882 !!end
883
884 # same html as previous, but wikitext adjusted to match parsoid html2wt
885 !! test
886 Italics and bold: 5-quote opening sequence: (5,2+3)
887 !! wikitext
888 '''''foo'''''
889 !! html/*
890 <p><i><b>foo</b></i>
891 </p>
892 !! end
893
894 !! test
895 Italics and bold: 5-quote opening sequence: (5,3)
896 !! options
897 parsoid=wt2html
898 !! wikitext
899 '''''foo'''
900 !! html/*
901 <p><i><b>foo</b></i>
902 </p>
903 !!end
904
905 # same html as previous, but wikitext adjusted to match parsoid html2wt
906 !! test
907 Italics and bold: 5-quote opening sequence: (5,3+2)
908 !! wikitext
909 '''''foo'''''
910 !! html
911 <p><i><b>foo</b></i>
912 </p>
913 !! end
914
915 !! test
916 Italics and bold: 5-quote opening sequence: (5,4)
917 !! options
918 parsoid=wt2html
919 !! wikitext
920 '''''foo''''
921 !! html/*
922 <p><i><b>foo'</b></i>
923 </p>
924 !!end
925
926 !! test
927 Italics and bold: 5-quote opening sequence: (5,5)
928 !! wikitext
929 '''''foo'''''
930 !! html
931 <p><i><b>foo</b></i>
932 </p>
933 !!end
934
935 !! test
936 Italics and bold: 5-quote opening sequence: (5,6)
937 !! wikitext
938 '''''foo''''''
939 !! html/*
940 <p><i><b>foo'</b></i>
941 </p>
942 !! end
943
944 ###
945 ### multiple quote sequences in a line
946 ###
947
948 !! test
949 Italics and bold: multiple quote sequences: (2,4,2)
950 !! options
951 parsoid=wt2html
952 !! wikitext
953 ''foo''''bar''
954 !! html/*
955 <p><i>foo'<b>bar</b></i>
956 </p>
957 !! end
958
959 # same html as previous, but wikitext adjusted to match parsoid html2wt
960 !! test
961 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
962 !! wikitext
963 ''foo'<nowiki/>'''bar'''''
964 !! html
965 <p><i>foo'<b>bar</b></i>
966 </p>
967 !! end
968
969 !! test
970 Italics and bold: multiple quote sequences: (2,4,3)
971 !! options
972 parsoid=wt2html
973 !! wikitext
974 ''foo''''bar'''
975 !! html/*
976 <p><i>foo'<b>bar</b></i>
977 </p>
978 !! end
979
980 # same html as previous, but wikitext adjusted to match parsoid html2wt
981 !! test
982 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
983 !! wikitext
984 ''foo'<nowiki/>'''bar'''''
985 !! html
986 <p><i>foo'<b>bar</b></i>
987 </p>
988 !! end
989
990 !! test
991 Italics and bold: multiple quote sequences: (2,4,4)
992 !! options
993 parsoid=wt2html
994 !! wikitext
995 ''foo''''bar''''
996 !! html/*
997 <p><i>foo'<b>bar'</b></i>
998 </p>
999 !! end
1000
1001 # same html as previous, but wikitext adjusted to match parsoid html2wt
1002 !! test
1003 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
1004 !! wikitext
1005 ''foo'<nowiki/>'''bar'<nowiki/>'''''
1006 !! html
1007 <p><i>foo'<b>bar'</b></i>
1008 </p>
1009 !! end
1010
1011 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1012 !! test
1013 Italics and bold: multiple quote sequences: (3,4,2)
1014 !! options
1015 parsoid=wt2html
1016 !! wikitext
1017 '''foo''''bar''
1018 !! html/php
1019 <p><b>foo'</b>bar
1020 </p>
1021 !! html/parsoid
1022 <p><b>foo'</b>bar<i></i>
1023 </p>
1024 !! end
1025
1026 # same html as previous, but wikitext adjusted to match parsoid html2wt
1027 !! test
1028 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1029 !! wikitext
1030 '''foo''''bar''<nowiki/>''
1031 !! html/php
1032 <p><b>foo'</b>bar
1033 </p>
1034 !! html/parsoid
1035 <p><b>foo'</b>bar<i></i>
1036 </p>
1037 !! end
1038
1039 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1040 !! test
1041 Italics and bold: multiple quote sequences: (3,4,3)
1042 !! options
1043 parsoid=wt2html
1044 !! wikitext
1045 '''foo''''bar'''
1046 !! html/php
1047 <p><b>foo'</b>bar
1048 </p>
1049 !! html/parsoid
1050 <p><b>foo'</b>bar<b></b>
1051 </p>
1052 !! end
1053
1054 # same html as previous, but wikitext adjusted to match parsoid html2wt
1055 !! test
1056 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1057 !! wikitext
1058 '''foo''''bar'''<nowiki/>'''
1059 !! html/php
1060 <p><b>foo'</b>bar
1061 </p>
1062 !! html/parsoid
1063 <p><b>foo'</b>bar<b></b>
1064 </p>
1065 !! end
1066
1067 ###
1068 ### other quote tests
1069 ###
1070 !! test
1071 Italics and bold: other quote tests: (2,3,5)
1072 !! wikitext
1073 ''this is about '''foo's family'''''
1074 !! html
1075 <p><i>this is about <b>foo's family</b></i>
1076 </p>
1077 !!end
1078
1079
1080 !! test
1081 Italics and bold: other quote tests: (2,(3,3),2)
1082 !! wikitext
1083 ''this is about '''foo's''' family''
1084 !! html
1085 <p><i>this is about <b>foo's</b> family</i>
1086 </p>
1087 !!end
1088
1089
1090 !! test
1091 Italics and bold: other quote tests: (3,2,3,2)
1092 !! options
1093 parsoid=wt2html
1094 !! wikitext
1095 '''this is about ''foo'''s family''
1096 !! html/*
1097 <p><b>this is about <i>foo</i></b><i>s family</i>
1098 </p>
1099 !!end
1100
1101
1102 # same html as previous, but wikitext adjusted to match parsoid html2wt
1103 !! test
1104 Italics and bold: other quote tests: (3,2,3+2+2,2)
1105 !! wikitext
1106 '''this is about ''foo'''''<nowiki/>''s family''
1107 !! html
1108 <p><b>this is about <i>foo</i></b><i>s family</i>
1109 </p>
1110 !! end
1111
1112
1113 !! test
1114 Italics and bold: other quote tests: (3,2,3,3)
1115 !! wikitext
1116 '''this is about ''foo'''s family'''
1117 !! html/*
1118 <p>'<i>this is about </i>foo<b>s family</b>
1119 </p>
1120 !!end
1121
1122
1123 !! test
1124 Italics and bold: other quote tests: (3,(2,2),3)
1125 !! wikitext
1126 '''this is about ''foo's'' family'''
1127 !! html
1128 <p><b>this is about <i>foo's</i> family</b>
1129 </p>
1130 !!end
1131
1132
1133 !! test
1134 Italicized possessive
1135 !! wikitext
1136 The ''[[Main Page]]'''s talk page.
1137 !! html/php
1138 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1139 </p>
1140 !! html/parsoid
1141 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1142 !! end
1143
1144 !! test
1145 Quote balancing context should be restricted to td/th cells on the same wikitext line
1146 !! options
1147 parsoid=wt2html,wt2wt
1148 !! wikitext
1149 {|
1150 !''a!!''b
1151 |''a||''b
1152 |}
1153 !! html+tidy
1154 <table>
1155 <tbody><tr>
1156 <th><i>a</i></th>
1157 <th><i>b</i>
1158 </th>
1159 <td><i>a</i></td>
1160 <td><i>b</i>
1161 </td></tr></tbody></table>
1162 !! end
1163
1164 ###
1165 ### Non-html5 tags
1166 ###
1167
1168 !! test
1169 Non-html5 tags should be accepted
1170 !! wikitext
1171 <center>''foo''</center>
1172 <big>''foo''</big>
1173 <font>''foo''</font>
1174 <strike>''foo''</strike>
1175 <tt>''foo''</tt>
1176 !! html
1177 <center><i>foo</i></center>
1178 <p><big><i>foo</i></big>
1179 <font><i>foo</i></font>
1180 <strike><i>foo</i></strike>
1181 <tt><i>foo</i></tt>
1182 </p>
1183 !! end
1184
1185 !! test
1186 <wbr> is valid wikitext (T54468)
1187 !! wikitext
1188 <wbr>
1189 !! html
1190 <p><wbr />
1191 </p>
1192 !! end
1193
1194 # <strike> is HTML4, <s> is HTML4/5.
1195 !! test
1196 <s> or <strike> for strikethrough
1197 !! wikitext
1198 <strike>strike</strike>
1199
1200 <s>s</s>
1201 !! html
1202 <p><strike>strike</strike>
1203 </p><p><s>s</s>
1204 </p>
1205 !! end
1206
1207 ## a not permitted
1208 ## i,b,br omitted
1209 !! test
1210 Text-level semantic html elements in wikitext
1211 !! wikitext
1212 <em>text</em>
1213 <strong>text</strong>
1214 <small>text</small>
1215 <s>text</s>
1216 <cite>text</cite>
1217 <q>text</q>
1218 <dfn>text</dfn>
1219 <abbr>text</abbr>
1220 <data>text</data>
1221 <time>text</time>
1222 <code>text</code>
1223 <var>text</var>
1224 <samp>text</samp>
1225 <kbd>text</kbd>
1226 <sub>text</sub>
1227 <u>text</u>
1228 <mark>text</mark>
1229 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1230 <bdi>text</bdi>
1231 <bdo>text</bdo>
1232 <span>text</span>
1233 <wbr />
1234 !! html
1235 <p><em>text</em>
1236 <strong>text</strong>
1237 <small>text</small>
1238 <s>text</s>
1239 <cite>text</cite>
1240 <q>text</q>
1241 <dfn>text</dfn>
1242 <abbr>text</abbr>
1243 <data>text</data>
1244 <time>text</time>
1245 <code>text</code>
1246 <var>text</var>
1247 <samp>text</samp>
1248 <kbd>text</kbd>
1249 <sub>text</sub>
1250 <u>text</u>
1251 <mark>text</mark>
1252 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1253 <bdi>text</bdi>
1254 <bdo>text</bdo>
1255 <span>text</span>
1256 <wbr />
1257 </p>
1258 !! end
1259
1260 # test cases taken from
1261 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1262 !! test
1263 Ruby markup (W3C-style)
1264 !! wikitext
1265 ; Mono-ruby for individual base characters
1266 : <ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1267 ; Group ruby
1268 : <ruby>今日<rt>きょう</rt></ruby>
1269 ; Jukugo ruby
1270 : <ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1271 ; Inline ruby
1272 : <ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1273 ; Double-sided ruby
1274 : <ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1275 <ruby>
1276 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1277 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1278 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1279 </ruby>
1280 !! html
1281 <dl><dt> Mono-ruby for individual base characters</dt>
1282 <dd> <ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1283 <dt> Group ruby</dt>
1284 <dd> <ruby>今日<rt>きょう</rt></ruby></dd>
1285 <dt> Jukugo ruby</dt>
1286 <dd> <ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1287 <dt> Inline ruby</dt>
1288 <dd> <ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1289 <dt> Double-sided ruby</dt>
1290 <dd> <ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby></dd></dl>
1291 <p><ruby>
1292 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1293 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1294 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1295 </ruby>
1296 </p>
1297 !! end
1298
1299 # The next two test different paths in the sanitizer.
1300 !! test
1301 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1302 !! wikitext
1303 <blockquote|>a</blockquote>
1304
1305 <b→> doesn't terminate </b→>
1306
1307 <bä> doesn't terminate </bä>
1308
1309 <boo> doesn't terminate </boo>
1310
1311 <s.foo> doesn't terminate </s.foo>
1312
1313 <sub-ID#1>
1314 !! html
1315 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1316 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1317 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1318 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1319 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1320 </p><p>&lt;sub-ID#1&gt;
1321 </p>
1322 !! end
1323
1324 !! test
1325 Non-word characters don't terminate tag names
1326 !! wikitext
1327 <blockquote|>a</blockquote>
1328
1329 <b→> doesn't terminate </b→>
1330
1331 <bä> doesn't terminate </bä>
1332
1333 <boo> doesn't terminate </boo>
1334
1335 <s.foo> doesn't terminate </s.foo>
1336
1337 <sub-ID#1>
1338 !! html+tidy
1339 <p>&lt;blockquote|&gt;a
1340 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1341 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1342 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1343 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1344 </p><p>&lt;sub-ID#1&gt;
1345 </p>
1346 !! end
1347
1348 ###
1349 ### See tests/parser/parserTestsParserHook.php for the <tåg> extension)
1350 ### This checks that HTML5 tags (with non-word characters in the tag
1351 ### name) make it safely through the parser -- the Sanitizer will
1352 ### munge them later, as it should.
1353 ###
1354 !! test
1355 Non-word characters are valid in extension tags (T19663)
1356 !! wikitext
1357 <tåg>tåg</tåg>
1358 !! html/php
1359 <pre>
1360 'tåg'
1361 array (
1362 )
1363 </pre>
1364
1365 !! html/parsoid
1366 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1367 !! end
1368
1369 !! test
1370 Isolated close tags should be treated as literal text (T54760)
1371 !! options
1372 parsoid=wt2html
1373 !! wikitext
1374 </b>
1375
1376 <s.foo>s</s>
1377 !! html/php+tidy
1378 <p class="mw-empty-elt">
1379 </p><p>&lt;s.foo&gt;s
1380 </p>
1381 !! html/parsoid
1382 <p>&lt;s.foo&gt;s</p>
1383 !! end
1384
1385 ###
1386 ### Special characters
1387 ###
1388
1389 !! test
1390 Bare pipe character (T54363)
1391 !! wikitext
1392 |
1393 !! html
1394 <p>|
1395 </p>
1396 !! end
1397
1398 !! test
1399 Bare pipe character from a template (T54363)
1400 !! wikitext
1401 {{pipe}}
1402 !! html
1403 <p>|
1404 </p>
1405 !! end
1406
1407 ###
1408 ### <nowiki> test cases
1409 ###
1410
1411 !! test
1412 <nowiki> unordered list
1413 !! wikitext
1414 <nowiki>* This is not an unordered list item.</nowiki>
1415 !! html/php
1416 <p>* This is not an unordered list item.
1417 </p>
1418 !! html/parsoid
1419 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1420 !! end
1421
1422 !! test
1423 <nowiki> spacing
1424 !! wikitext
1425 <nowiki>Lorem ipsum dolor
1426
1427 sed abit.
1428 sed nullum.
1429
1430 :and a colon
1431 </nowiki>
1432 !! html/php
1433 <p>Lorem ipsum dolor
1434
1435 sed abit.
1436 sed nullum.
1437
1438 :and a colon
1439
1440 </p>
1441 !! html/parsoid
1442 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1443
1444 sed abit.
1445 sed nullum.
1446
1447 :and a colon
1448 </span></p>
1449 !! end
1450
1451 !! test
1452 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1453 !! wikitext
1454 <nowiki><span class="error"></nowiki>
1455 !! html/php
1456 <p>&lt;span class="error"&gt;
1457 </p>
1458 !! html/parsoid
1459 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1460 !! end
1461
1462 !! test
1463 nowiki 3
1464 !! wikitext
1465 :There is not nowiki.
1466 :There is <nowiki>nowiki</nowiki>.
1467
1468 #There is not nowiki.
1469 #There is <nowiki>nowiki</nowiki>.
1470
1471 *There is not nowiki.
1472 *There is <nowiki>nowiki</nowiki>.
1473 !! html/php
1474 <dl><dd>There is not nowiki.</dd>
1475 <dd>There is nowiki.</dd></dl>
1476 <ol><li>There is not nowiki.</li>
1477 <li>There is nowiki.</li></ol>
1478 <ul><li>There is not nowiki.</li>
1479 <li>There is nowiki.</li></ul>
1480
1481 !! html/parsoid
1482 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1483 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1484
1485 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1486 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1487
1488 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1489 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1490 !! end
1491
1492 !! test
1493 Entities inside <nowiki>
1494 !! wikitext
1495 <nowiki>&lt;</nowiki>
1496 !! html/php
1497 <p>&lt;
1498 </p>
1499 !! html/parsoid
1500 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1501 !! end
1502
1503 !! test
1504 Entities inside template parameters
1505 !! wikitext
1506 {{echo|&ndash;}}
1507 !! html/php+tidy
1508 <p>&#8211;
1509 </p>
1510 !! html/parsoid
1511 <p><span typeof="mw:Transclusion mw:Entity" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&amp;ndash;"}},"i":0}}]}'>&ndash;</span></p>
1512 !! end
1513
1514 !! test
1515 Properly escape nowiki when combined with other wiki markup
1516 !! options
1517 parsoid=html2wt
1518 !! html/parsoid
1519 <p>* &lt;/nowiki&gt; tag</p>
1520 !! wikitext
1521 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1522 !! end
1523
1524 !! test
1525 T93824: Put escaped HTML tags inside nowiki
1526 !! options
1527 parsoid=html2wt
1528 !! html/parsoid
1529 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1530 !! wikitext
1531 <nowiki><h2>foo</h2></nowiki>
1532 !! end
1533
1534 !! test
1535 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1536 !! options
1537 parsoid=html2wt
1538 !! html/parsoid
1539 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1540 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1541 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1542 !! wikitext
1543 This text: L'[[Foo]]
1544 This text: L<nowiki>''</nowiki>[[Foo]]
1545 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1546 !! end
1547
1548 # This test fails because wikitext whitespace is not normalized before comparing.
1549 !! test
1550 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1551 !! options
1552 parsoid=html2wt
1553 !! html/parsoid
1554 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1555 </p>
1556 !! wikitext
1557 This text : L<nowiki>''</nowiki>[[Foo]]
1558 !! end
1559
1560 # This test and the next one are html2wt only as they test that incorrect wikitext
1561 # passed in template arguments gets escaped or wrapped in nowikis where required.
1562 !! test
1563 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1564 !! options
1565 parsoid=html2wt
1566 !! html/parsoid
1567 <p><span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo|bar&quot;}},&quot;i&quot;:0}}]}" about="#mwt1"></span>
1568 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo|bar |[[&quot;}},&quot;i&quot;:0}}]}" about="#mwt2"></p>
1569 !! wikitext
1570 {{echo|foo{{!}}bar}}
1571 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1572 !! end
1573
1574 !! test
1575 T53961: Output correct nowikis in template arguments
1576 !! options
1577 parsoid=html2wt
1578 !! html/parsoid
1579 <p><span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a [ b&quot;}},&quot;i&quot;:0}}]}" about="#mwt1"></span>
1580 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a }} b&quot;}},&quot;i&quot;:0}}]}" about="#mwt2"></span>
1581 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a [[ b&quot;}},&quot;i&quot;:0}}]}" about="#mwt3"></span>
1582 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a | {{ ]]&quot;}},&quot;i&quot;:0}}]}" about="#mwt4"></span>
1583 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;a }&quot;}},&quot;i&quot;:0}}]}" about="#mwt5"></span></p>
1584 !! wikitext
1585 {{echo|a [ b}}
1586 {{echo|<nowiki>a }} b</nowiki>}}
1587 {{echo|<nowiki>a [[ b</nowiki>}}
1588 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1589 {{echo|a <nowiki>}</nowiki>}}
1590 !! end
1591
1592 !! test
1593 Cases where "!!" needs nowiki protection
1594 !! options
1595 parsoid=html2wt
1596 !! html/parsoid
1597 <table>
1598 <tr><th>this needs protection !! here</th></tr>
1599 </table>
1600
1601 <table>
1602 <tr><th>this does not need
1603 protection !! here</th></tr>
1604 </table>
1605 !! wikitext
1606 {|
1607 !<nowiki>this needs protection !! here</nowiki>
1608 |}
1609
1610 {|
1611 !this does not need
1612 protection !! here
1613 |}
1614 !! end
1615
1616 ###
1617 ### Comments
1618 ###
1619 !! test
1620 Comments and Indent-Pre
1621 !! wikitext
1622 <!-- comment 1 --> asdf
1623
1624 <!-- comment 1 --> asdf
1625 <!-- comment 2 -->
1626
1627 <!-- comment 1 --> asdf
1628 <!-- comment 2 -->xyz
1629
1630 <!-- comment 1 --> asdf
1631 <!-- comment 2 --> xyz
1632 !! html
1633 <pre>asdf
1634 </pre>
1635 <pre>asdf
1636 </pre>
1637 <pre>asdf
1638 </pre>
1639 <p>xyz
1640 </p>
1641 <pre>asdf
1642 xyz
1643 </pre>
1644 !! end
1645
1646 !! test
1647 Comment test 2a
1648 !! wikitext
1649 asdf
1650 <!-- comment 1 -->
1651 jkl
1652 !! html
1653 <p>asdf
1654 jkl
1655 </p>
1656 !! end
1657
1658 !! test
1659 Comment test 2b
1660 !! wikitext
1661 asdf
1662 <!-- comment 1 -->
1663
1664 jkl
1665 !! html
1666 <p>asdf
1667 </p><p>jkl
1668 </p>
1669 !! end
1670
1671 !! test
1672 Comment test 3
1673 !! wikitext
1674 asdf
1675 <!-- comment 1 -->
1676 <!-- comment 2 -->
1677 jkl
1678 !! html
1679 <p>asdf
1680 jkl
1681 </p>
1682 !! end
1683
1684 !! test
1685 Comment test 4
1686 !! wikitext
1687 asdf<!-- comment 1 -->jkl
1688 !! html
1689 <p>asdfjkl
1690 </p>
1691 !! end
1692
1693 !! test
1694 Comment spacing
1695 !! wikitext
1696 a
1697 <!-- foo --> b <!-- bar -->
1698 c
1699 !! html
1700 <p>a
1701 </p>
1702 <pre> b
1703 </pre>
1704 <p>c
1705 </p>
1706 !! end
1707
1708 !! test
1709 Comment whitespace
1710 !! wikitext
1711 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1712 !! html
1713
1714 !! end
1715
1716 !! test
1717 Comment semantics and delimiters
1718 !! wikitext
1719 <!-- --><!----><!-----><!------>
1720 !! html/php
1721
1722 !! html/parsoid
1723 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1724 !! end
1725
1726 !! test
1727 Comment semantics and delimiters, redux
1728 !! wikitext
1729 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1730 -- foo -- funky huh? ... -->
1731 !! html/php
1732
1733 !! html/parsoid
1734 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1735 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1736 !! end
1737
1738 !! test
1739 Comment semantics and delimiters: directors cut
1740 !! wikitext
1741 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1742 everything starting with < followed by !-- until the first -- and > we see,
1743 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1744 -->-->
1745 !! html/php
1746 <p>--&gt;
1747 </p>
1748 !! html/parsoid
1749 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1750 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1751 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1752 --><p>--></p>
1753 !! end
1754
1755 !! test
1756 Comment semantics: nesting
1757 !! wikitext
1758 <!--<!-- no, we're not going to do anything fancy here -->-->
1759 !! html/php
1760 <p>--&gt;
1761 </p>
1762 !! html/parsoid
1763 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1764 !! end
1765
1766 # Parsoid closes the unclosed comment, even if it means a slight
1767 # round-trip diff.
1768 !! test
1769 Comment semantics: unclosed comment at end
1770 !! options
1771 parsoid=wt2html,html2html
1772 !! wikitext
1773 <!--This comment will run out to the end of the document
1774 !! html/php
1775
1776 !! html/parsoid
1777 <!--This comment will run out to the end of the document-->
1778 !! end
1779
1780 !! test
1781 Comment semantics: normalize comments to play nice with XML and browsers
1782 !! wikitext
1783 <!-- Browsers --!> think this is closed -->
1784 <!--> This would normally be text -->
1785 <!---> As would this -->
1786 <!-- XML doesn't like trailing dashes -------->
1787 <!-- Nor doubled hyphens -- anywhere in the data -->
1788 But this is not a comment.
1789 !! html/php
1790 <p>But this is not a comment.
1791 </p>
1792 !! html/parsoid
1793 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1794 <!--&#x3E; This would normally be text -->
1795 <!--&#x2D;&#x3E; As would this -->
1796 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1797 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1798 <p>But this is not a comment.</p>
1799 !! end
1800
1801 !! test
1802 Comment semantics: round-trip even text which contains encoded -->
1803 !! wikitext
1804 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1805 !! html/parsoid
1806 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1807 !! end
1808
1809 !! test
1810 Comment in template title
1811 !! wikitext
1812 {{f<!---->oo}}
1813 !! html
1814 <p>FOO
1815 </p>
1816 !! end
1817
1818 !! test
1819 Comment on its own line post-expand
1820 !! wikitext
1821 a
1822 {{blank}}<!---->
1823 b
1824 !! html
1825 <p>a
1826 </p><p>b
1827 </p>
1828 !! end
1829
1830 !! test
1831 Comment on its own line post-expand with non-significant whitespace
1832 !! wikitext
1833 a
1834 {{blank}} <!---->
1835 b
1836 !! html
1837 <p>a
1838 </p><p>b
1839 </p>
1840 !! end
1841
1842 !! test
1843 Multiple comments should still parse as SOL-transparent
1844 !! options
1845 parsoid=wt2html,wt2wt
1846 !! wikitext
1847 <!--c1-->*a
1848 <!--c2--><!--c3--><!--c4-->*b
1849 !! html/php
1850 <ul><li>a</li>
1851 <li>b</li></ul>
1852
1853 !! html/parsoid
1854 <!--c1--><ul>
1855 <li>a
1856 </li>
1857 <!--c2--><!--c3--><!--c4-->
1858 <li>b
1859 </li>
1860 </ul>
1861 !! end
1862
1863 ## Make sure ">" gets escaped in comments to avoid XSS
1864 !! test
1865 IE conditional comments
1866 !! wikitext
1867 <!--[if lt IE 9]>
1868 <script>alert('hi');</script>
1869 <![endif]-->
1870 !! html/parsoid
1871 <!--[if lt IE 9]&#x3E;
1872 <script&#x3E;alert('hi');</script&#x3E;
1873 <![endif]-->
1874 !! end
1875
1876 ###
1877 ### paragraph wrapping tests
1878 ###
1879 !! test
1880 No block tags
1881 !! wikitext
1882 a
1883
1884 b
1885 !! html
1886 <p>a
1887 </p><p>b
1888 </p>
1889 !! end
1890
1891 !! test
1892 Block tag on one line (<div>)
1893 !! wikitext
1894 a <div>foo</div>
1895
1896 b
1897 !! html
1898 a <div>foo</div>
1899 <p>b
1900 </p>
1901 !! html+tidy
1902 <p>a </p><div>foo</div>
1903 <p>b
1904 </p>
1905 !! end
1906
1907 # Remex wraps empty tag runs with p-tags.
1908 # Parsoid strips them out during p-wrapping.
1909 !! test
1910 No p-wrappable content
1911 !! wikitext
1912 <span><div>x</div></span>
1913 <span><s><div>x</div></s></span>
1914 <small><em></em></small><span><s><div>x</div></s></span>
1915 !! html/php+tidy
1916 <span><div>x</div></span>
1917 <span><s><div>x</div></s></span>
1918 <p><small><em></em></small></p><span><s><div>x</div></s></span>
1919 !! html/parsoid
1920 <span><div>x</div></span>
1921 <span><s><div>x</div></s></span>
1922 <small><em></em></small><span><s><div>x</div></s></span>
1923 !! end
1924
1925 # T177612: Parsoid-only test
1926 !! test
1927 Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
1928 !! wikitext
1929 {{echo|<span><div>x</div></span>}}
1930 x
1931 !! html/parsoid
1932 <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>
1933 <p>x</p>
1934 !! end
1935
1936 !! test
1937 Block tag on one line (<blockquote>)
1938 !! wikitext
1939 a <blockquote>foo</blockquote>
1940
1941 b
1942 !! html
1943 a <blockquote>foo</blockquote>
1944 <p>b
1945 </p>
1946 !! html+tidy
1947 <p>a </p><blockquote><p>foo</p></blockquote>
1948 <p>b
1949 </p>
1950 !! end
1951
1952 !! test
1953 Block tag on both lines (<div>)
1954 !! wikitext
1955 a <div>foo</div>
1956
1957 b <div>foo</div>
1958 !! html
1959 a <div>foo</div>
1960 b <div>foo</div>
1961
1962 !! html+tidy
1963 <p>a </p><div>foo</div><p>
1964 b </p><div>foo</div>
1965 !! end
1966
1967 !! test
1968 Block tag on both lines (<blockquote>)
1969 !! wikitext
1970 a <blockquote>foo</blockquote>
1971
1972 b <blockquote>foo</blockquote>
1973 !! html
1974 a <blockquote>foo</blockquote>
1975 b <blockquote>foo</blockquote>
1976
1977 !! html+tidy
1978 <p>a </p><blockquote><p>foo</p></blockquote><p>
1979 b </p><blockquote><p>foo</p></blockquote>
1980 !! end
1981
1982 !! test
1983 Multiple lines without block tags
1984 !! wikitext
1985 <div>foo</div> a
1986 b
1987 c
1988 d<!--foo--> e
1989 x <div>foo</div> z
1990 !! html
1991 <div>foo</div> a
1992 <p>b
1993 c
1994 d e
1995 </p>
1996 x <div>foo</div> z
1997
1998 !! html+tidy
1999 <div>foo</div><p> a
2000 </p><p>b
2001 c
2002 d e
2003 </p><p>
2004 x </p><div>foo</div><p> z
2005 </p>
2006 !! end
2007
2008 # The difference between Parsoid & Remex here
2009 # is because of Parsoid's Tidy-emulation code
2010 # for p-wrapping. We'll start work to remove this
2011 # emulation code in Parsoid sooner than later.
2012 # Remex wraps empty tag runs with p-tags.
2013 # Parsoid strips them out in a separate pass.
2014 !! test
2015 Empty lines between lines with block tags
2016 !! wikitext
2017 <div></div>
2018
2019
2020 <div></div>a
2021
2022 b
2023 <div>a</div>b
2024
2025 <div>b</div>d
2026
2027
2028 <div>e</div>
2029 !! html
2030 <div></div>
2031 <p><br />
2032 </p>
2033 <div></div>a
2034 <p>b
2035 </p>
2036 <div>a</div>b
2037 <div>b</div>d
2038 <p><br />
2039 </p>
2040 <div>e</div>
2041
2042 !! html+tidy
2043 <div></div>
2044 <p><br />
2045 </p>
2046 <div></div><p>a
2047 </p><p>b
2048 </p>
2049 <div>a</div><p>b
2050 </p><div>b</div><p>d
2051 </p><p><br />
2052 </p>
2053 <div>e</div>
2054 !! html/parsoid
2055 <div data-parsoid='{"stx":"html"}'></div>
2056
2057 <p><br /></p>
2058 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2059
2060 <p>b</p>
2061 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2062
2063 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2064
2065 <p><br /></p>
2066 <div data-parsoid='{"stx":"html"}'>e</div>
2067 !! end
2068
2069 !! test
2070 Unclosed HTML p-tags should be handled properly
2071 !! wikitext
2072 <div><p>foo</div>
2073 a
2074
2075 b
2076 !! html/php+tidy
2077 <div><p>foo</p></div>
2078 <p>a
2079 </p><p>b
2080 </p>
2081 !! html/parsoid
2082 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2083 <p>a</p>
2084 <p>b</p>
2085 !! end
2086
2087 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2088 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2089 ## them for now.
2090 !! test
2091 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2092 !! options
2093 parsoid=wt2html
2094 !! wikitext
2095 a [[Category:A1]] [[Category:A2]]
2096 [[Category:A3]]
2097 [[Category:A4]]
2098 !! html/parsoid
2099 <p>a</p>
2100 <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"/>
2101 !! end
2102
2103 !! test
2104 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2105 !! options
2106 parsoid=wt2html
2107 !! wikitext
2108 [[Category:A1]]a
2109 !! html/parsoid
2110 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2111 !! end
2112
2113 ###
2114 ### Preformatted text
2115 ###
2116 !! test
2117 Preformatted text
2118 !! wikitext
2119 This is some
2120 Preformatted text
2121 With ''italic''
2122 And '''bold'''
2123 And a [[Main Page|link]]
2124 !! html
2125 <pre>This is some
2126 Preformatted text
2127 With <i>italic</i>
2128 And <b>bold</b>
2129 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2130 </pre>
2131 !! end
2132
2133 !! test
2134 Tabs don't trigger preformatted text
2135 !! wikitext
2136 This is not
2137 preformatted text.
2138 This is preformatted text.
2139 So is this.
2140 !! html/php
2141 <p> This is not
2142 preformatted text.
2143 </p>
2144 <pre>This is preformatted text.
2145 So is this.
2146 </pre>
2147 !! html/parsoid
2148 <p> This is not
2149 preformatted text.</p>
2150 <pre>This is preformatted text.
2151 So is this.</pre>
2152 !! end
2153
2154 !! test
2155 Space before tab needs nowiki pre protection
2156 !! options
2157 parsoid=html2wt
2158 !! html/parsoid
2159 <p> a</p>
2160 !! wikitext
2161 <nowiki> </nowiki> a
2162 !! end
2163
2164 !! test
2165 Ident preformatting with inline content
2166 !! wikitext
2167 a
2168 ''b''
2169 !! html
2170 <pre>a
2171 <i>b</i>
2172 </pre>
2173 !! end
2174
2175 !! test
2176 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2177 !! wikitext
2178 <pre><nowiki>
2179 <b>
2180 <cite>
2181 <em>
2182 </nowiki></pre>
2183 !! html
2184 <pre>
2185 &lt;b&gt;
2186 &lt;cite&gt;
2187 &lt;em&gt;
2188 </pre>
2189
2190 !! end
2191
2192 !! test
2193 Regression with preformatted in <center>
2194 !! wikitext
2195 <center>
2196 Blah
2197 </center>
2198 !! html
2199 <center>
2200 <pre>Blah
2201 </pre>
2202 </center>
2203
2204 !! end
2205
2206 !! test
2207 T54763: Preformatted in <blockquote>
2208 !! wikitext
2209 <blockquote>
2210 Blah
2211 {|
2212 |
2213 indented cell (no pre-wrapping!)
2214 |}
2215 </blockquote>
2216 !! html
2217 <blockquote>
2218 <p> Blah
2219 </p>
2220 <table>
2221 <tr>
2222 <td>
2223 <p> indented cell (no pre-wrapping!)
2224 </p>
2225 </td></tr></table>
2226 </blockquote>
2227
2228 !! end
2229
2230 !! test
2231 T53086: Double newlines in blockquotes should be turned into paragraphs
2232 !! wikitext
2233 <blockquote>
2234 Foo
2235
2236 Bar
2237 </blockquote>
2238 !! html
2239 <blockquote>
2240 <p>Foo
2241 </p><p>Bar
2242 </p>
2243 </blockquote>
2244
2245 !! end
2246
2247 !! test
2248 T17491: <ins>/<del> in blockquote
2249 !! wikitext
2250 <blockquote>
2251 Foo <del>bar</del> <ins>baz</ins> quux
2252 </blockquote>
2253 !! html
2254 <blockquote>
2255 <p>Foo <del>bar</del> <ins>baz</ins> quux
2256 </p>
2257 </blockquote>
2258
2259 !! end
2260
2261 !! test
2262 T17491: <ins>/<del> in blockquote (2)
2263 !! wikitext
2264 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2265 </blockquote>
2266 !! html
2267 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2268 </blockquote>
2269
2270 !! html+tidy
2271 <blockquote><p>Foo </p><del>bar</del> <ins>baz</ins><p> quux
2272 </p></blockquote>
2273 !! end
2274
2275 !! test
2276 <pre> with attributes (T5202)
2277 !! wikitext
2278 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2279 !! html
2280 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2281
2282 !! end
2283
2284 !! test
2285 <pre> with width attribute (T5202)
2286 !! wikitext
2287 <pre width="8">Narrow screen goodies</pre>
2288 !! html
2289 <pre width="8">Narrow screen goodies</pre>
2290
2291 !! end
2292
2293 !! test
2294 <pre> with forbidden attribute (T5202)
2295 !! wikitext
2296 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2297 !! html
2298 <pre width="8">Narrow screen goodies</pre>
2299
2300 !! end
2301
2302 !! test
2303 Entities inside <pre>
2304 !! wikitext
2305 <pre>&lt;</pre>
2306 !! html
2307 <pre>&lt;</pre>
2308
2309 !! end
2310
2311 !! test
2312 <pre> with forbidden attribute values (T5202)
2313 !! wikitext
2314 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2315 !! html
2316 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2317
2318 !! end
2319
2320 !! test
2321 <nowiki> inside <pre> (T15238)
2322 !! wikitext
2323 <pre>
2324 <nowiki>
2325 </pre>
2326 <pre>
2327 <nowiki></nowiki>
2328 </pre>
2329 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2330 !! html
2331 <pre>
2332 &lt;nowiki&gt;
2333 </pre>
2334 <pre>
2335
2336 </pre>
2337 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2338
2339 !! end
2340
2341 !! test
2342 <nowiki> inside of #tag:pre
2343 !! wikitext
2344 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2345 !! html/php
2346 <pre>Foo &#8594;bar</pre>
2347
2348 !! html/parsoid
2349 <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>
2350 !! end
2351
2352 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2353 ## aren't enclosed in nowikis.
2354 !! test
2355 <nowiki> and <pre> preference (first one wins)
2356 !! options
2357 parsoid=wt2html
2358 !! wikitext
2359 <pre>
2360 <nowiki>
2361 </pre>
2362 </nowiki>
2363 </pre>
2364
2365 <nowiki>
2366 <pre>
2367 <nowiki>
2368 </pre>
2369 </nowiki>
2370 </pre>
2371
2372 !! html/php
2373 <pre>
2374 &lt;nowiki&gt;
2375 </pre>
2376 <p>&lt;/nowiki&gt;
2377 &lt;/pre&gt;
2378 </p><p>
2379 &lt;pre&gt;
2380 &lt;nowiki&gt;
2381 &lt;/pre&gt;
2382
2383 &lt;/pre&gt;
2384 </p>
2385 !! html/parsoid
2386 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2387 </pre>
2388 <p>&lt;/nowiki></p>
2389
2390
2391 <p><span typeof="mw:Nowiki">
2392 &lt;pre>
2393 &lt;nowiki>
2394 &lt;/pre>
2395 </span></p>
2396 !! end
2397
2398 !! test
2399 </pre> inside nowiki
2400 !! wikitext
2401 <nowiki></pre></nowiki>
2402 !! html
2403 <p>&lt;/pre&gt;
2404 </p>
2405 !! end
2406
2407 !! test
2408 Empty pre; pre inside other HTML tags (T56946)
2409 !! wikitext
2410 a
2411
2412 <div><pre>
2413 foo
2414 </pre></div>
2415 <pre></pre>
2416 !! html/php+tidy
2417 <p>a
2418 </p>
2419 <div><pre>foo
2420 </pre></div>
2421 <pre></pre>
2422 !! html/parsoid
2423 <p>a</p>
2424
2425 <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
2426 </pre></div>
2427 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2428 !! end
2429
2430 !! test
2431 HTML pre followed by indent-pre
2432 !! wikitext
2433 <pre>foo</pre>
2434 bar
2435 !! html
2436 <pre>foo</pre>
2437 <pre>bar
2438 </pre>
2439 !! end
2440
2441 !! test
2442 Block tag pre
2443 !! wikitext
2444 <p><pre>foo</pre></p>
2445 !! html/php+tidy
2446 <p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p>
2447 !! html/parsoid
2448 <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>
2449 !! end
2450
2451 !!test
2452 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2453 !! wikitext
2454 {{echo|}}
2455 !! html
2456
2457 !!end
2458
2459 !!test
2460 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2461 !! wikitext
2462 {{echo|
2463 foo}}
2464 !! html
2465 <p>foo
2466 </p>
2467 !!end
2468
2469 !! test
2470 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2471 !! wikitext
2472 {{echo|a
2473 b}}
2474 !! html
2475 <pre>a
2476 </pre>
2477 <p>b
2478 </p>
2479 !!end
2480
2481 !! test
2482 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2483 !! wikitext
2484 {{echo|a
2485 b
2486 c
2487 d
2488 e
2489 }}
2490 !! html
2491 <pre>a
2492 </pre>
2493 <p>b
2494 c
2495 </p>
2496 <pre>d
2497 </pre>
2498 <p>e
2499 </p>
2500 !!end
2501
2502 !!test
2503 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2504 !! wikitext
2505 {{echo| foo}}
2506
2507 {{echo| foo}}{{echo| bar}}
2508
2509 {{echo| foo}}
2510 {{echo| bar}}
2511
2512 {{echo|<!--cmt--> foo}}
2513
2514 <!--cmt-->{{echo| foo}}
2515
2516 {{echo|{{echo| }}bar}}
2517 !! html
2518 <pre>foo
2519 </pre>
2520 <pre>foo bar
2521 </pre>
2522 <pre>foo
2523 bar
2524 </pre>
2525 <pre>foo
2526 </pre>
2527 <pre>foo
2528 </pre>
2529 <pre>bar
2530 </pre>
2531 !!end
2532
2533 !! test
2534 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2535 !! wikitext
2536 {{echo| }}a
2537
2538 {{echo|
2539 }}a
2540
2541 {{echo|
2542 b}}
2543
2544 {{echo|a
2545 }}b
2546
2547 {{echo|a
2548 }} b
2549 !! html
2550 <pre>a
2551 </pre>
2552 <p><br />
2553 </p>
2554 <pre>a
2555 </pre>
2556 <p><br />
2557 </p>
2558 <pre>b
2559 </pre>
2560 <p>a
2561 </p>
2562 <pre>b
2563 </pre>
2564 <p>a
2565 </p>
2566 <pre>b
2567 </pre>
2568 !!end
2569
2570 ## Hmm, should Parsoid rt this?
2571 !! test
2572 Pres with newline attributes
2573 !! options
2574 parsoid=wt2html,html2html
2575 !! wikitext
2576 <pre class="one
2577 two">hi</pre>
2578 !! html/php
2579 <pre class="one two">hi</pre>
2580
2581 !! html/parsoid
2582 <pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2583 !! end
2584
2585 !! test
2586 Things that look like <pre> tags aren't treated as such
2587 !! wikitext
2588 Barack Obama <President> of the United States
2589 <President></President>
2590 !! html
2591 <p>Barack Obama &lt;President&gt; of the United States
2592 &lt;President&gt;&lt;/President&gt;
2593 </p>
2594 !! end
2595
2596 !! test
2597 Handle broken pre-like tags (T66025)
2598 !! options
2599 parsoid=wt2html
2600 !! wikitext
2601 {{echo|<pre <pre>x</pre>}}
2602
2603 <table><pre </table>
2604 !! html/php
2605 <pre>x</pre>
2606 <table>&lt;pre </table>
2607
2608 !! html/php+tidy
2609 <pre>x</pre>
2610 &lt;pre <table></table>
2611 !! html/parsoid
2612 <pre about="#mwt1" typeof="mw:Transclusion mw:Extension/pre" data-parsoid='{"a":{"&lt;pre":null},"sa":{"&lt;pre":""},"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre &lt;pre>x&lt;/pre>"}},"i":0}}]}'>x</pre>
2613
2614
2615 <p>&lt;pre </p>
2616
2617 <table></table>
2618 !! end
2619
2620 !! test
2621 Parsoid: handle pre with space after attribute
2622 !! options
2623 parsoid=wt2html
2624 !! wikitext
2625 <pre style="width:50%;" >{{echo|foo}}</pre>
2626 !! html/php
2627 <pre style="width:50%;">{{echo|foo}}</pre>
2628
2629 !! html/parsoid
2630 <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>
2631 !! end
2632
2633 # TODO / maybe: fix wt2wt for this
2634 !! test
2635 Parsoid: Don't paragraph-wrap fosterable content
2636 !! options
2637 parsoid=wt2html
2638 !! wikitext
2639 {|
2640 <td></td>
2641 <td></td>
2642
2643
2644
2645 |}
2646 !! html
2647 <table>
2648
2649 <tbody>
2650 <tr>
2651 <td></td>
2652
2653 <td></td></tr>
2654
2655
2656
2657 </tbody></table>
2658 !! end
2659
2660 !! test
2661 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2662 !! options
2663 parsoid=wt2html
2664 !! wikitext
2665 {|
2666 <td>
2667 <td>
2668 </td>
2669
2670
2671
2672 |}
2673 !! html
2674 <table>
2675
2676 <tbody>
2677 <tr>
2678 <td></td>
2679
2680 <td>
2681 </td></tr>
2682
2683
2684
2685 </tbody></table>
2686 !! end
2687
2688
2689 #--------------------------------------------------------------------
2690 # Transclusion parameter whitespace stripping tests
2691 # Behavior is different for positional and named parameters
2692 #--------------------------------------------------------------------
2693 !! test
2694 Templates: Strip leading and trailing whitespace from named-param values
2695 !! wikitext
2696 {{echo|1= a }}
2697
2698 {{echo|1= {{echo|b}} }}
2699
2700 {{echo| 1 =
2701 c }}
2702
2703 {{echo| 1 =
2704 * d
2705 }}
2706 !! html
2707 <p>a
2708 </p><p>b
2709 </p><p>c
2710 </p>
2711 <ul><li> d</li></ul>
2712
2713 !! end
2714
2715 !! test
2716 Templates: Don't strip whitespace from positional-param values
2717 !! wikitext
2718 {{echo|a }}
2719
2720 {{echo|{{echo|b}} }}
2721
2722 {{echo| c
2723 }}
2724
2725 {{echo| {{echo|d}}
2726 }}
2727
2728 {{echo|
2729 e}}
2730
2731 {{echo|
2732 * f}}
2733
2734 {{echo|
2735 }}g
2736 !! html
2737 <p>a
2738 </p><p>b
2739 </p>
2740 <pre>c
2741 </pre>
2742 <p><br />
2743 </p>
2744 <pre>d
2745 </pre>
2746 <p><br />
2747 </p>
2748 <pre>e
2749 </pre>
2750 <p><br />
2751 </p>
2752 <ul><li> f</li></ul>
2753 <p><br />
2754 </p>
2755 <pre>g
2756 </pre>
2757 !! end
2758
2759 !! test
2760 Templates: Don't recognize targets split by newlines
2761 !! options
2762 parsoid=wt2html
2763 !! wikitext
2764 {{ech
2765 o|foo}}
2766 !! html/php
2767 <p>{{ech
2768 o|foo}}
2769 </p>
2770 !! html/parsoid
2771 <p>{{ech
2772 o|foo}}</p>
2773 !! end
2774
2775 !! test
2776 Templates: Recognize targets when newlines and comments don't split the target
2777 !! options
2778 parsoid=wt2html
2779 !! wikitext
2780 {{
2781 <!--X--> ech<!--X-->o<!--X-->
2782 <!--X--> <!--X-->
2783
2784 |foo}}
2785 !! html/php
2786 <p>foo
2787 </p>
2788 !! html/parsoid
2789 <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>
2790 !! end
2791
2792 !! test
2793 Templates: Handle empty comment-and-ws-only lines correctly
2794 !! wikitext
2795 {{echo|foo
2796 <!--should be ignored-->
2797 <!--should be ignored as well-->
2798 bar}}
2799 !! html/php
2800 <p>foo
2801 bar
2802 </p>
2803 !! html/parsoid
2804 <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>
2805 !! end
2806
2807 !! test
2808 Templates: Handle comments in the target
2809 !! wikitext
2810 {{echo
2811 <!-- should be ignored -->
2812 |foo}}
2813
2814 {{echo
2815 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
2816 |foo}}
2817
2818 {{echo<!-- should be ignored -->
2819 |foo}}
2820
2821 {{echo<!-- should be ignored -->|foo}}
2822
2823 {{<!-- should be ignored -->echo|foo}}
2824 !! html/php
2825 <p>foo
2826 </p><p>foo
2827 </p><p>foo
2828 </p><p>foo
2829 </p><p>foo
2830 </p>
2831 !! html/parsoid
2832 <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>
2833
2834 <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>
2835
2836 <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>
2837
2838 <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>
2839
2840 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
2841 !! end
2842
2843 !! test
2844 Templates: Handle comments in parameter names (T69657)
2845 !! wikitext
2846 {{echo|1
2847 <!-- should be ignored -->
2848 =foo}}
2849
2850 {{echo|
2851 <!-- should be ignored -->
2852 1 = foo}}
2853
2854 {{echo|1<!-- should be ignored -->=foo}}
2855
2856 {{echo|<!-- should be ignored -->1=foo}}
2857 !! html/php
2858 <p>foo
2859 </p><p>foo
2860 </p><p>foo
2861 </p><p>foo
2862 </p>
2863 !! html/parsoid
2864 <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>
2865
2866 <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>
2867
2868 <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>
2869
2870 <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>
2871 !! end
2872
2873 !! test
2874 Templates: Other wikitext in parameter names (T69657)
2875 !! wikitext
2876 {{echo|''1''=foo}}
2877 !! html/php
2878 <p>{{{1}}}
2879 </p>
2880 !! html/parsoid
2881 <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>
2882 !! end
2883
2884 !! test
2885 Templates: With colons
2886 !! wikitext
2887 {{With: Colon}}
2888 !! html/php
2889 <p>Template with colon
2890 </p>
2891 !! html/parsoid
2892 <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>
2893 !! end
2894
2895 #--------------------------------------------------------------------
2896 # Transclusion parameter escaping tests
2897 #--------------------------------------------------------------------
2898
2899 !! test
2900 Templates: Parsoid parameter escaping test 1
2901 !! wikitext
2902 {{echo|[foo]|{{echo|[bar]}}}}
2903 !! html/php+tidy
2904 <p>[foo]
2905 </p>
2906 !! html/parsoid
2907 <p about="#mwt1" typeof="mw:Transclusion"
2908 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
2909 !! end
2910
2911 !! test
2912 Parsoid: Pipes in external links in template parameter
2913 !! wikitext
2914 {{echo|[{{echo|http://example.com}} link]}}
2915 !! html/php+tidy
2916 <p><a rel="nofollow" class="external text" href="http://example.com">link</a>
2917 </p>
2918 !! html/parsoid
2919 <p><a rel="mw:ExtLink" 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>
2920 !! end
2921
2922 !! test
2923 Parsoid: pipe in transclusion parameter
2924 !! wikitext
2925 {{echo|http://foo.com/a&#124;b}}
2926 !! html/php+tidy
2927 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a>
2928 </p>
2929 !! html/parsoid
2930 <p><a rel="mw:ExtLink" href="http://foo.com/a%7Cb" about="#mwt1"
2931 typeof="mw:Transclusion"
2932 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>
2933 !! end
2934
2935 !! test
2936 Parsoid: Pipe in external link target and content in template parameter
2937 !! options
2938 parsoid=html2wt,wt2wt
2939 !! wikitext
2940 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
2941 !! html/php+tidy
2942 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a&#124;b</a>
2943 </p>
2944 !! html/parsoid
2945 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
2946 typeof="mw:Transclusion"
2947 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
2948 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
2949 !! end
2950
2951 !! test
2952 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
2953 !! options
2954 parsoid
2955 !! wikitext
2956 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
2957 !! html
2958 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]"}},"i":0}}]}'>[Main Page bar]</p>
2959 !! end
2960
2961 !! test
2962 Templates: Don't escape already nowiki-escaped text in template parameters
2963 !! options
2964 parsoid=html2wt,wt2wt
2965 !! wikitext
2966 {{echo|foo<nowiki>|</nowiki>bar}}
2967 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
2968 {{echo|<nowiki></nowiki>}}
2969 !! html/php+tidy
2970 <p>foo|bar
2971 &lt;div&gt;
2972
2973 </p>
2974 !! html/parsoid
2975 <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>
2976 <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>
2977 <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>
2978 </p>
2979 !! end
2980
2981 ## T54824
2982 !! test
2983 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
2984 !! options
2985 parsoid=html2wt,wt2wt
2986 !! wikitext
2987 {{echo|{{echo|1=bar}}}}
2988 !! html/php+tidy
2989 <p>bar
2990 </p>
2991 !! html/parsoid
2992 <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>
2993 !! end
2994
2995 ## T58733
2996 !! test
2997 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
2998 !! wikitext
2999 {{echo|a : b}}
3000 !! html/php+tidy
3001 <p>a&#160;: b
3002 </p>
3003 !! html/parsoid
3004 <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>
3005 !! end
3006
3007 ## T73412
3008 !! test
3009 Templates: Preserve blank parameter names
3010 !! wikitext
3011 {{echo|=foo}}
3012 !! html/php+tidy
3013 <p>{{{1}}}
3014 </p>
3015 !! html/parsoid
3016 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3017 !! end
3018
3019 !! test
3020 Templates: Preserve blank parameter names in other positions
3021 !! wikitext
3022 {{blank_param|bar|=foo}}
3023 !! html/php+tidy
3024 <p>bar
3025 foo
3026 </p>
3027 !! html/parsoid
3028 <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
3029 foo</p>
3030 !! end
3031
3032 ###
3033 ### Parsoid-centric tests for testing RT edge cases for pre
3034 ###
3035
3036 !!test
3037 1a. Indent-Pre and Comments
3038 !! wikitext
3039 a
3040 <!--a-->
3041 c
3042 !! html
3043 <pre>a
3044 </pre>
3045 <p>c
3046 </p>
3047 !!end
3048
3049 !!test
3050 1b. Indent-Pre and Comments
3051 !! wikitext
3052 a
3053 <!--a-->
3054 c
3055 !! html
3056 <pre>a
3057 </pre>
3058 <p>c
3059 </p>
3060 !!end
3061
3062 !!test
3063 1c. Indent-Pre and Comments
3064 !! wikitext
3065 <!--a--> a
3066
3067 <!--a--> a
3068 !! html
3069 <pre> a
3070 </pre>
3071 <pre> a
3072 </pre>
3073 !!end
3074
3075 !!test
3076 1d. Indent-Pre and Comments
3077 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3078 !! wikitext
3079 <!--a--> a
3080
3081 <!--b-->b
3082 !! html
3083 <pre>a
3084 </pre>
3085 <pre>b
3086 </pre>
3087 !!end
3088
3089 !!test
3090 2a. Indent-Pre and tables
3091 !! wikitext
3092 {|
3093 |-
3094 !h1!!h2
3095 |foo||bar
3096 |}
3097 !! html
3098 <table>
3099
3100 <tr>
3101 <th>h1</th>
3102 <th>h2
3103 </th>
3104 <td>foo</td>
3105 <td>bar
3106 </td></tr></table>
3107
3108 !!end
3109
3110 !!test
3111 2b. Indent-Pre and tables
3112 !! wikitext
3113 {|
3114 |-
3115 |foo
3116 |}
3117 !! html
3118 <table>
3119
3120 <tr>
3121 <td>foo
3122 </td></tr></table>
3123
3124 !!end
3125
3126 !!test
3127 2c. Indent-Pre and tables (T44252)
3128 !! wikitext
3129 {|
3130 |+ foo
3131 ! | bar
3132 |}
3133 !! html
3134 <table>
3135 <caption> foo
3136 </caption>
3137 <tr>
3138 <th> bar
3139 </th></tr></table>
3140
3141 !!end
3142
3143 !!test
3144 2d. Indent-Pre and tables
3145 !! wikitext
3146 a
3147 {|
3148 | b
3149 |}
3150 !! html/php
3151 <pre>a
3152 </pre>
3153 <table>
3154 <tr>
3155 <td> b
3156 </td></tr></table>
3157
3158 !! html/parsoid
3159 <pre>a</pre>
3160 <table>
3161 <tbody><tr><td> b</td></tr>
3162 </tbody></table>
3163 !!end
3164
3165 !!test
3166 2e. Indent-Pre and table-line syntax
3167 !! wikitext
3168 a
3169 | b
3170 | c
3171 !! html/php
3172 <pre>a
3173 | b
3174 | c
3175 </pre>
3176 !!end
3177
3178 !!test
3179 2f. Indent-pre started by table-line syntax
3180 !! wikitext
3181 a
3182 | b
3183 | c
3184 !! html/php
3185 <p>a
3186 </p>
3187 <pre>| b
3188 | c
3189 </pre>
3190 !! html/parsoid
3191 <p>a</p>
3192 <pre>
3193 | b
3194 | c</pre>
3195 !!end
3196
3197 !! test
3198 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3199 !! wikitext
3200 <table>
3201 <tr>
3202 <td>
3203 Text that should be rendered preformatted
3204 </td>
3205 </tr>
3206 </table>
3207 !! html
3208 <table>
3209 <tr>
3210 <td>
3211 <pre>Text that should be rendered preformatted
3212 </pre>
3213 </td>
3214 </tr>
3215 </table>
3216
3217 !! end
3218
3219 !!test
3220 3a. Indent-Pre and block tags (single-line html)
3221 !! wikitext
3222 a <p> foo </p>
3223 b <div> foo </div>
3224 c <blockquote> foo </blockquote>
3225 <span> foo </span>
3226 !! html
3227 a <p> foo </p>
3228 b <div> foo </div>
3229 c <blockquote> foo </blockquote>
3230 <pre><span> foo </span>
3231 </pre>
3232 !! html/parsoid
3233 <p>a </p><p data-parsoid='{"stx":"html"}'> foo </p>
3234 <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3235 <p>c </p><blockquote data-parsoid='{"stx":"html"}'> foo </blockquote>
3236 <pre><span> foo </span>
3237 </pre>
3238 !! html/php+tidy
3239 <p> a </p><p> foo </p><p>
3240 b </p><div> foo </div><p>
3241 c </p><blockquote><p> foo </p></blockquote>
3242 <pre><span> foo </span>
3243 </pre>
3244 !! end
3245
3246 !!test
3247 3b. Indent-Pre and block tags (multi-line html)
3248 !! wikitext
3249 a <span>foo</span>
3250 b <div> foo </div>
3251 !! html
3252 <pre>a <span>foo</span>
3253 </pre>
3254 b <div> foo </div>
3255
3256 !! html/parsoid
3257 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3258 b <div data-parsoid='{"stx":"html"}'> foo </div>
3259 !! html/php+tidy
3260 <pre>a <span>foo</span>
3261 </pre><p>
3262 b </p><div> foo </div>
3263 !!end
3264
3265 !!test
3266 3c. Indent-Pre and block tags (pre-content on separate line)
3267 !! wikitext
3268 <p>
3269 foo
3270 </p>
3271
3272 <div>
3273 foo
3274 </div>
3275
3276 <center>
3277 foo
3278 </center>
3279
3280 <blockquote>
3281 foo
3282 </blockquote>
3283
3284 <blockquote>
3285 <pre>
3286 foo
3287 </pre>
3288 </blockquote>
3289
3290 <table><tr><td>
3291 foo
3292 </td></tr></table>
3293
3294 <ul><li>
3295 foo
3296 </li></ul>
3297
3298 !! html
3299 <p>
3300 foo
3301 </p>
3302 <div>
3303 <pre>foo
3304 </pre>
3305 </div>
3306 <center>
3307 <pre>foo
3308 </pre>
3309 </center>
3310 <blockquote>
3311 <p> foo
3312 </p>
3313 </blockquote>
3314 <blockquote>
3315 <pre>
3316 foo
3317 </pre>
3318 </blockquote>
3319 <table><tr><td>
3320 <pre>foo
3321 </pre>
3322 </td></tr></table>
3323 <ul><li>
3324 foo
3325 </li></ul>
3326
3327 !!end
3328
3329 !! test
3330 4. Indent-Pre and extension tags
3331 !! wikitext
3332 a <tag />
3333 !! html/php
3334 a <pre>
3335 NULL
3336 array (
3337 )
3338 </pre>
3339
3340 !! html/parsoid
3341 a <pre typeof="mw:Extension/tag" about="#mwt2" data-parsoid='{}' data-mw='{"name":"tag","attrs":{},"body":null}'></pre>
3342 !! end
3343
3344 !! test
3345 5. Indent-Pre and html pre
3346 !! wikitext
3347 <pre class="123">hi</pre>
3348 !! html/php
3349 <pre class="123">hi</pre>
3350
3351 !! html/parsoid
3352 <pre typeof="mw:Extension/pre" about="#mwt2" class="123" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3353 !! end
3354
3355 !!test
3356 Render paragraphs when indent-pre is suppressed in blocklevels
3357 !! wikitext
3358 <blockquote>
3359 foo
3360
3361 bar
3362 </blockquote>
3363 !! html
3364 <blockquote>
3365 <p> foo
3366 </p><p> bar
3367 </p>
3368 </blockquote>
3369
3370 !!end
3371
3372 !!test
3373 4. Multiple spaces at start-of-line
3374 !! wikitext
3375 <p> foo </p>
3376 foo
3377 {|
3378 |foo
3379 |}
3380 !! html
3381 <p> foo </p>
3382 <pre> foo
3383 </pre>
3384 <table>
3385 <tr>
3386 <td>foo
3387 </td></tr></table>
3388
3389 !!end
3390
3391 ## NOTE: the leading white-space chars on empty line are significant
3392 !! test
3393 5a. White-space in indent-pre
3394 !! wikitext
3395 a<br />
3396
3397 b
3398 !! html
3399 <pre>a<br />
3400
3401 b
3402 </pre>
3403 !! end
3404
3405 ## NOTE: the leading white-space chars on empty line are significant
3406 !! test
3407 5b. White-space in indent-pre
3408 !! wikitext
3409 a
3410
3411 b
3412
3413
3414 c
3415 !! html
3416 <pre>a
3417
3418 b
3419
3420
3421 c
3422 </pre>
3423 !! end
3424
3425 !! test
3426 5c. White-space in indent-pre
3427 !! wikitext
3428 ''a''
3429 ''b''
3430 ''c''
3431 !! html
3432 <pre><i>a</i>
3433 <i>b</i>
3434 <i>c</i>
3435 </pre>
3436 !! end
3437
3438 !! test
3439 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3440 !! wikitext
3441 a
3442
3443 <!-- continue -->
3444 b
3445
3446 c
3447
3448 d
3449 !! html
3450 <pre>a
3451
3452 b
3453 </pre>
3454 <pre>c
3455
3456 </pre>
3457 <p>d
3458 </p>
3459 !! end
3460
3461 !! test
3462 7a. Indent-pre and category links
3463 !! options
3464 parsoid=wt2html,wt2wt
3465 !! wikitext
3466 [[Category:foo]] <!-- No pre-wrapping -->
3467 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3468 !! html/php+tidy
3469 !! html/parsoid
3470 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3471 <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 -->
3472 !! end
3473
3474 ## We used to, but no longer wt2wt this test since the default serializer
3475 ## will normalize all categories to serialize on their own line.
3476 ## This wikitext usage is going to be fairly uncommon in production and
3477 ## selser will take care of preserving formatting in those scenarios.
3478 !! test
3479 7b. Indent-pre and category links
3480 !! options
3481 parsoid=wt2html
3482 !! wikitext
3483 [[Category:foo]] a
3484 [[Category:foo]] {{echo|b}}
3485 !! html/parsoid
3486 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3487 <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>
3488 !! end
3489
3490 !! test
3491 Indent-Pre: Newlines in comments shouldn't affect sol state
3492 !! wikitext
3493 a <!--
3494 foo
3495 --> b
3496 !! html/php+tidy
3497 <p>a b
3498 </p>
3499 !! html/parsoid
3500 <p>a <!--
3501 foo
3502 --> b</p>
3503 !! end
3504
3505 ###
3506 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3507 ###
3508
3509 !!test
3510 HTML-pre: 1. embedded newlines
3511 !! wikitext
3512 <pre>foo</pre>
3513
3514 <pre>
3515 foo
3516 </pre>
3517
3518 <pre>
3519
3520 foo
3521 </pre>
3522
3523 <pre>
3524
3525
3526 foo
3527 </pre>
3528 !! html/php+tidy
3529 <pre>foo</pre>
3530 <pre>foo
3531 </pre>
3532 <pre>
3533
3534 foo
3535 </pre>
3536 <pre>
3537
3538
3539 foo
3540 </pre>
3541 !! html/parsoid
3542 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3543
3544 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3545 </pre>
3546
3547 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3548
3549 foo
3550 </pre>
3551
3552 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3553
3554
3555 foo
3556 </pre>
3557 !!end
3558
3559 !! test
3560 HTML-pre: big spaces
3561 !! wikitext
3562 <pre>
3563
3564
3565
3566
3567 haha
3568
3569
3570
3571
3572 haha
3573
3574
3575
3576
3577 </pre>
3578 !! html/php+tidy
3579 <pre>
3580
3581
3582
3583
3584 haha
3585
3586
3587
3588
3589 haha
3590
3591
3592
3593
3594 </pre>
3595 !! html/parsoid
3596 <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"}}'>
3597
3598
3599
3600
3601 haha
3602
3603
3604
3605
3606 haha
3607
3608
3609
3610
3611 </pre>
3612 !! end
3613
3614 !!test
3615 HTML-pre: 2: indented text
3616 !! wikitext
3617 <pre>
3618 foo
3619 </pre>
3620 !! html
3621 <pre>
3622 foo
3623 </pre>
3624
3625 !!end
3626
3627 !!test
3628 HTML-pre: 3: other wikitext
3629 !! wikitext
3630 <pre>
3631 * foo
3632 # bar
3633 = no-h =
3634 '' no-italic ''
3635 [[ NoLink ]]
3636 </pre>
3637 !! html/php
3638 <pre>
3639 * foo
3640 # bar
3641 = no-h =
3642 '' no-italic ''
3643 [[ NoLink ]]
3644 </pre>
3645
3646 !! html/parsoid
3647 <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
3648 # bar
3649 = no-h =
3650 '' no-italic ''
3651 [[ NoLink ]]
3652 </pre>
3653 !!end
3654
3655 ###
3656 ### Definition lists
3657 ###
3658 !! test
3659 Simple definition
3660 !! wikitext
3661 ; name : Definition
3662 !! html
3663 <dl><dt> name&#160;</dt>
3664 <dd> Definition</dd></dl>
3665
3666 !! end
3667
3668 !! test
3669 Definition list for indentation only
3670 !! wikitext
3671 : Indented text
3672 !! html
3673 <dl><dd> Indented text</dd></dl>
3674
3675 !! end
3676
3677 !! test
3678 Definition list with no space
3679 !! wikitext
3680 ;name:Definition
3681 !! html
3682 <dl><dt>name</dt>
3683 <dd>Definition</dd></dl>
3684
3685 !!end
3686
3687 !! test
3688 Definition list with URL link
3689 !! wikitext
3690 ; http://example.com/ : definition
3691 !! html
3692 <dl><dt> <a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&#160;</dt>
3693 <dd> definition</dd></dl>
3694
3695 !! end
3696
3697 !! test
3698 Definition list with bracketed URL link
3699 !! wikitext
3700 ;[http://www.example.com/ Example]:Something about it
3701 !! html
3702 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
3703 <dd>Something about it</dd></dl>
3704
3705 !! end
3706
3707 !! test
3708 Definition list with wikilink containing colon
3709 !! wikitext
3710 ; [[Help:FAQ]]: The least-read page on Wikipedia
3711 !! html
3712 <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>
3713 <dd> The least-read page on Wikipedia</dd></dl>
3714
3715 !! end
3716
3717 # At Brion's and JeLuF's insistence... :)
3718 !! test
3719 Definition list with news link containing colon
3720 !! wikitext
3721 ; news:alt.wikipedia.rox: This isn't even a real newsgroup!
3722 !! html/php
3723 <dl><dt> <a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
3724 <dd> This isn't even a real newsgroup!</dd></dl>
3725
3726 !! html/parsoid
3727 <dl><dt> <a rel="mw:ExtLink" 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>
3728 !! end
3729
3730 !! test
3731 Malformed definition list with colon
3732 !! wikitext
3733 ; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
3734 !! html
3735 <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>
3736
3737 !! end
3738
3739 !! test
3740 Definition lists: colon in external link text
3741 !! wikitext
3742 ; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
3743 !! html
3744 <dl><dt> <a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia&#160;: The Next Generation</a></dt>
3745 <dd> OK, I made that up</dd></dl>
3746
3747 !! end
3748
3749 !! test
3750 Definition lists: colon in HTML attribute
3751 !! wikitext
3752 ;<b style="display: inline">bold</b>
3753 !! html
3754 <dl><dt><b style="display: inline">bold</b></dt></dl>
3755
3756 !! end
3757
3758 !! test
3759 Definition lists: self-closed tag
3760 !! wikitext
3761 ;one<br/>two : two-line fun
3762 !! html
3763 <dl><dt>one<br />two&#160;</dt>
3764 <dd> two-line fun</dd></dl>
3765
3766 !! end
3767
3768 !! test
3769 Definition lists: ignore colons inside tags
3770 !! wikitext
3771 ;one <b>two : tag <i>fun:</i>:</b>: def
3772 !! html
3773 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
3774 <dd> def</dd></dl>
3775
3776 !! end
3777
3778 !! test
3779 Definition lists: excess closed tags
3780 !! wikitext
3781 ;one</b>two : bad tag fun
3782 !! html/php+tidy
3783 <dl><dt>onetwo&#160;</dt>
3784 <dd> bad tag fun</dd></dl>
3785 !! html/parsoid
3786 <dl>
3787 <dt>onetwo</dt>
3788 <dd>bad tag fun</dd>
3789 </dl>
3790 !! end
3791
3792 !! test
3793 T13748: Literal closing tags
3794 !! wikitext
3795 <dl>
3796 <dt>test 1</dt>
3797 <dd>test test test test test</dd>
3798 <dt>test 2</dt>
3799 <dd>test test test test test</dd>
3800 </dl>
3801 !! html
3802 <dl>
3803 <dt>test 1</dt>
3804 <dd>test test test test test</dd>
3805 <dt>test 2</dt>
3806 <dd>test test test test test</dd>
3807 </dl>
3808
3809 !! end
3810
3811 !! test
3812 Definition and unordered list using wiki syntax nested in unordered list using html tags.
3813 !! wikitext
3814 <ul><li>
3815 ; term : description
3816 * unordered
3817 </li></ul>
3818 !! html
3819 <ul><li>
3820 <dl><dt> term&#160;</dt>
3821 <dd> description</dd></dl>
3822 <ul><li> unordered</li></ul>
3823 </li></ul>
3824
3825 !! end
3826
3827 !! test
3828 Definition list with empty definition and following paragraph
3829 !! wikitext
3830 ; term:
3831 Paragraph text
3832 !! html
3833 <dl><dt> term</dt>
3834 <dd></dd></dl>
3835 <p>Paragraph text
3836 </p>
3837 !! end
3838
3839 !! test
3840 Nested definition lists using html syntax
3841 !! wikitext
3842 <dl><dt>x</dt>
3843 <dd>a</dd>
3844 <dd>b</dd></dl>
3845 !! html
3846 <dl><dt>x</dt>
3847 <dd>a</dd>
3848 <dd>b</dd></dl>
3849
3850 !! end
3851
3852 !! test
3853 Definition Lists: No nesting: Multiple dd's
3854 !! wikitext
3855 ;x
3856 :a
3857 :b
3858 !! html
3859 <dl><dt>x</dt>
3860 <dd>a</dd>
3861 <dd>b</dd></dl>
3862
3863 !! end
3864
3865 !! test
3866 Definition Lists: Indentation: Regular
3867 !! wikitext
3868 :i1
3869 ::i2
3870 :::i3
3871 !! html
3872 <dl><dd>i1
3873 <dl><dd>i2
3874 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3875
3876 !! end
3877
3878 !! test
3879 Definition Lists: Indentation: Missing 1st level
3880 !! wikitext
3881 ::i2
3882 :::i3
3883 !! html
3884 <dl><dd><dl><dd>i2
3885 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3886
3887 !! end
3888
3889 !! test
3890 Definition Lists: Indentation: Multi-level indent
3891 !! wikitext
3892 :::i3
3893 !! html
3894 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
3895
3896 !! end
3897
3898 !! test
3899 Definition Lists: Hacky use to indent tables
3900 !! wikitext
3901 ::{|
3902 |foo
3903 |bar
3904 |}
3905 this text
3906 should be left alone
3907 !! html
3908 <dl><dd><dl><dd><table>
3909 <tr>
3910 <td>foo
3911 </td>
3912 <td>bar
3913 </td></tr></table></dd></dl></dd></dl>
3914 <p>this text
3915 should be left alone
3916 </p>
3917 !! end
3918
3919 !! test
3920 Definition Lists: Hacky use to indent tables, with comments (T65979)
3921 !! wikitext
3922 <!-- foo -->
3923 ::{|
3924 |foo
3925 |bar
3926 |}<!-- bar -->
3927 this text
3928 should be left alone
3929 !! html/parsoid
3930 <!-- foo -->
3931 <dl><dd><dl><dd><table><tr>
3932 <td>foo</td>
3933 <td>bar</td>
3934 </tr></table><!-- bar --></dd></dl></dd></dl>
3935 <p>this text
3936 should be left alone</p>
3937 !! end
3938
3939 !! test
3940 Definition Lists: Hacky use to indent tables, with comment before table
3941 !! wikitext
3942 ::<!-- foo -->{|
3943 |foo
3944 |}
3945 !! html/parsoid
3946 <dl><dd><dl><dd><!-- foo --><table><tr>
3947 <td>foo</td>
3948 </tr></table></dd></dl></dd></dl>
3949 !! end
3950
3951 # The trailing whitespace in this test is to catch a regression in
3952 # Parsoid after T54473.
3953 !! test
3954 Definition Lists: Hacky use to indent tables (WS-insensitive)
3955 !! wikitext
3956 : {|
3957 |a
3958 |}
3959 !! html/php
3960 <dl><dd><table>
3961 <tr>
3962 <td>a
3963 </td></tr></table></dd></dl>
3964
3965 !! html/parsoid
3966 <dl><dd> <table>
3967 <tbody><tr><td>a</td></tr>
3968 </tbody></table> </dd></dl>
3969 !! end
3970
3971 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
3972 ## as an empty dt item. It also ignores all but the last ";" when followed
3973 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
3974 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
3975 ## ";"s.
3976 ##
3977 ## Ex: ";;t2 ::d2" is transformed into:
3978 ##
3979 ## <dl>
3980 ## <dt>t2 </dt>
3981 ## <dd>
3982 ## <dl>
3983 ## <dt></dt>
3984 ## <dd>d2</dd>
3985 ## </dl>
3986 ## </dd>
3987 ## </dl>
3988 ##
3989 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
3990 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
3991 ##
3992 ## <dl>
3993 ## <dt>
3994 ## <dl>
3995 ## <dt>t2 </dt>
3996 ## <dd>:d2</dd>
3997 ## </dl>
3998 ## </dt>
3999 ## </dl>
4000 ##
4001 ## All Parsoid only definition list tests have this difference.
4002 ##
4003 ## See also: https://phabricator.wikimedia.org/T8569
4004 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4005
4006 !! test
4007 Table / list interaction: indented table with lists in table contents
4008 !! wikitext
4009 :{|
4010 |-
4011 | a
4012 * b
4013 |-
4014 | c
4015 * d
4016 |}
4017 !! html
4018 <dl><dd><table>
4019
4020 <tr>
4021 <td> a
4022 <ul><li> b</li></ul>
4023 </td></tr>
4024 <tr>
4025 <td> c
4026 <ul><li> d</li></ul>
4027 </td></tr></table></dd></dl>
4028
4029 !! end
4030
4031 !!test
4032 Table / list interaction: lists nested in tables nested in indented lists
4033 !! wikitext
4034 :{|
4035 |
4036 :a
4037 :b
4038 |
4039 *c
4040 *d
4041 |}
4042
4043 *e
4044 *f
4045 !! html
4046 <dl><dd><table>
4047 <tr>
4048 <td>
4049 <dl><dd>a</dd>
4050 <dd>b</dd></dl>
4051 </td>
4052 <td>
4053 <ul><li>c</li>
4054 <li>d</li></ul>
4055 </td></tr></table></dd></dl>
4056 <ul><li>e</li>
4057 <li>f</li></ul>
4058
4059 !!end
4060
4061 !! test
4062 Definition Lists: Nesting: Multi-level (Parsoid only)
4063 !! wikitext
4064 ;t1 :d1
4065 ;;t2 ::d2
4066 ;;;t3 :::d3
4067 !! html/parsoid
4068 <dl>
4069 <dt>t1 </dt>
4070 <dd>d1</dd>
4071 <dt>
4072 <dl>
4073 <dt>t2 </dt>
4074 <dd>:d2</dd>
4075 <dt>
4076 <dl>
4077 <dt>t3 </dt>
4078 <dd>::d3</dd>
4079 </dl>
4080 </dt>
4081 </dl>
4082 </dt>
4083 </dl>
4084
4085
4086 !! end
4087
4088
4089 !! test
4090 Definition Lists: Nesting: Test 2
4091 !! wikitext
4092 ;t1
4093 ::d2
4094 !! html+tidy
4095 <dl><dt>t1</dt>
4096 <dd>
4097 <dl><dd>d2</dd></dl></dd></dl>
4098 !! end
4099
4100
4101 !! test
4102 Definition Lists: Nesting: Test 3
4103 !! wikitext
4104 :;t1
4105 ::::d2
4106 !! html+tidy
4107 <dl><dd><dl><dt>t1</dt>
4108 <dd>
4109 <dl><dd><dl><dd>d2</dd></dl></dd></dl></dd></dl></dd></dl>
4110 !! end
4111
4112
4113 !! test
4114 Definition Lists: Nesting: Test 4
4115 !! wikitext
4116 ::;t3
4117 :::d3
4118 !! html
4119 <dl><dd><dl><dd><dl><dt>t3</dt>
4120 <dd>d3</dd></dl></dd></dl></dd></dl>
4121
4122 !! end
4123
4124
4125 ## The Parsoid team believes the following three test exposes a
4126 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4127 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4128 ## It also exposes a "misfeature" in tidy, which doesn't like
4129 ## <dl> tags with a single <dt> child; it converts the <dt> into
4130 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4131 !! test
4132 Definition Lists: Mixed Lists: Test 1
4133 !! wikitext
4134 :;* foo
4135 ::* bar
4136 :; baz
4137 !! html/php
4138 <dl><dd><dl><dt><ul><li> foo</li>
4139 <li> bar</li></ul></dt></dl>
4140 <dl><dt> baz</dt></dl></dd></dl>
4141
4142 !! html/php+tidy
4143 <dl><dd><dl><dt><ul><li> foo</li>
4144 <li> bar</li></ul></dt></dl>
4145 <dl><dt> baz</dt></dl></dd></dl>
4146 !! html/parsoid
4147 <dl>
4148 <dd><dl>
4149 <dt><ul>
4150 <li> foo
4151 </li>
4152 </ul></dt>
4153 <dd><ul>
4154 <li> bar
4155 </li>
4156 </ul></dd>
4157 <dt> baz</dt>
4158 </dl></dd>
4159 </dl>
4160 !! end
4161
4162 !! test
4163 Definition Lists: Mixed Lists: Test 2
4164 !! wikitext
4165 *: d1
4166 *: d2
4167 !! html
4168 <ul><li><dl><dd> d1</dd>
4169 <dd> d2</dd></dl></li></ul>
4170
4171 !! end
4172
4173
4174 !! test
4175 Definition Lists: Mixed Lists: Test 3
4176 !! wikitext
4177 *::: d1
4178 *::: d2
4179 !! html
4180 <ul><li><dl><dd><dl><dd><dl><dd> d1</dd>
4181 <dd> d2</dd></dl></dd></dl></dd></dl></li></ul>
4182
4183 !! end
4184
4185
4186 !! test
4187 Definition Lists: Mixed Lists: Test 4
4188 !! wikitext
4189 *;d1 :d2
4190 *;d3 :d4
4191 !! html
4192 <ul><li><dl><dt>d1&#160;</dt>
4193 <dd>d2</dd>
4194 <dt>d3&#160;</dt>
4195 <dd>d4</dd></dl></li></ul>
4196
4197 !! end
4198
4199
4200 !! test
4201 Definition Lists: Mixed Lists: Test 5
4202 !! wikitext
4203 *:d1
4204 *:: d2
4205 !! html
4206 <ul><li><dl><dd>d1
4207 <dl><dd> d2</dd></dl></dd></dl></li></ul>
4208
4209 !! end
4210
4211
4212 !! test
4213 Definition Lists: Mixed Lists: Test 6
4214 !! wikitext
4215 #*:d1
4216 #*::: d3
4217 !! html
4218 <ol><li><ul><li><dl><dd>d1
4219 <dl><dd><dl><dd> d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4220
4221 !! end
4222
4223
4224 !! test
4225 Definition Lists: Mixed Lists: Test 7
4226 !! wikitext
4227 :* d1
4228 :* d2
4229 !! html
4230 <dl><dd><ul><li> d1</li>
4231 <li> d2</li></ul></dd></dl>
4232
4233 !! end
4234
4235
4236 !! test
4237 Definition Lists: Mixed Lists: Test 8
4238 !! wikitext
4239 :* d1
4240 ::* d2
4241 !! html
4242 <dl><dd><ul><li> d1</li></ul>
4243 <dl><dd><ul><li> d2</li></ul></dd></dl></dd></dl>
4244
4245 !! end
4246
4247
4248 !! test
4249 Definition Lists: Mixed Lists: Test 9
4250 !! wikitext
4251 *;foo :bar
4252 !! html
4253 <ul><li><dl><dt>foo&#160;</dt>
4254 <dd>bar</dd></dl></li></ul>
4255
4256 !! end
4257
4258
4259 !! test
4260 Definition Lists: Mixed Lists: Test 10
4261 !! wikitext
4262 *#;foo :bar
4263 !! html
4264 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4265 <dd>bar</dd></dl></li></ol></li></ul>
4266
4267 !! end
4268
4269 # The Parsoid team disagrees with the PHP parser's seemingly-random
4270 # rules regarding dd/dt on the next few tests. Parsoid is more
4271 # consistent, and recognizes the shared nesting and keeps the
4272 # still-open tags around until the nesting is complete.
4273
4274 # This is a regression test for T175099
4275 !! test
4276 Definition Lists: Mixed Lists: Test 11
4277 !! wikitext
4278 ;a
4279 :*b
4280 !! html/php
4281 <dl><dt>a</dt>
4282 <dd>
4283 <ul><li>b</li></ul></dd></dl>
4284
4285 !! html/parsoid
4286 <dl><dt>a
4287 <dd><ul><li>b</li></ul></dd></dl>
4288 !! end
4289
4290 # FIXME: Maybe get rid of this test?
4291 !! test
4292 Definition Lists: Mixed Lists: Test 12
4293 !! wikitext
4294 *#*#;*;;foo :bar
4295 *#*#;boo :baz
4296 !! html/php
4297 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4298 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4299 <dl><dt>boo&#160;</dt>
4300 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4301
4302 !! html/php+tidy
4303 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4304 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4305 <dl><dt>boo&#160;</dt>
4306 <dd>baz</dd></dl></li></ol></li></ul>
4307 !! html/parsoid
4308 <ul>
4309 <li>
4310 <ol>
4311 <li>
4312 <ul>
4313 <li>
4314 <ol>
4315 <li>
4316 <dl>
4317 <dt>
4318 <ul>
4319 <li>
4320 <dl>
4321 <dt>
4322 <dl>
4323 <dt>foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4324 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4325 </dl></dt>
4326 </dl></li>
4327 </ul></dt>
4328 <dt>boo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4329 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4330 </dl></li>
4331 </ol></li>
4332 </ul></li>
4333 </ol></li>
4334 </ul>
4335 !! end
4336
4337 # FIXME: Maybe get rid of this test?
4338 # From whitelist:
4339 # * The test is wrong, there are two colons where there should be :;
4340 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4341 !! test
4342 Definition Lists: Weird Ones: Test 1
4343 !! wikitext
4344 *#;*::;; foo : bar (who uses this?)
4345 !! html/php+tidy
4346 <ul><li><ol><li><dl><dt> foo&#160;</dt>
4347 <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>
4348 !! html/parsoid
4349 <ul>
4350 <li>
4351 <ol>
4352 <li>
4353 <dl>
4354 <dt>
4355 <ul>
4356 <li>
4357 <dl>
4358 <dd>
4359 <dl>
4360 <dd>
4361 <dl>
4362 <dt>
4363 <dl>
4364 <dt> foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span></dt>
4365 <dd data-parsoid='{"stx":"row"}'> bar (who uses this?)</dd>
4366 </dl></dt>
4367 </dl></dd>
4368 </dl></dd>
4369 </dl></li>
4370 </ul></dt>
4371 </dl></li>
4372 </ol></li>
4373 </ul>
4374 !! end
4375
4376 !! test
4377 Definition Lists: colons occurring in tags
4378 !! wikitext
4379 ;a:b
4380 ;'''a:b'''
4381 ;<i>a:b</i>
4382 ;<span>a:b</span>
4383 ;<div>a:b</div>
4384 ;<div>a
4385 :b</div>
4386 ;{{echo|a:b}}
4387 ;{{echo|''a:b''}}
4388 ;;;''a:b''
4389 !! html+tidy
4390 <dl><dt>a</dt>
4391 <dd>b</dd>
4392 <dt><b>a:b</b></dt>
4393 <dt><i>a:b</i></dt>
4394 <dt><span>a:b</span></dt>
4395 <dt><div>a:b</div></dt>
4396 <dt><div>a</div></dt>
4397 <dd>b</dd>
4398 <dt>a</dt>
4399 <dd>b</dd>
4400 <dt><i>a:b</i></dt></dl>
4401 <dl><dt><dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4402 !! html/parsoid
4403 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4404 <dt><b>a:b</b></dt>
4405 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4406 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4407 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4408 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4409 <dd>b</dd>
4410 <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>
4411 <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>
4412 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4413 !! end
4414
4415 # Parsoid's output differs here again because it shares
4416 # nesting between the two lists unlike the PHP parser.
4417 # Unsure which is more desirable.
4418 !! test
4419 Definition Lists: colons and tables 1
4420 !! wikitext
4421 :{|
4422 | x
4423 |}
4424 :{|
4425 | y
4426 |}
4427 !! html/php
4428 <dl><dd><table>
4429 <tr>
4430 <td> x
4431 </td></tr></table></dd></dl>
4432 <dl><dd><table>
4433 <tr>
4434 <td> y
4435 </td></tr></table></dd></dl>
4436
4437 !! html/parsoid
4438 <dl><dd><table>
4439 <tr>
4440 <td> x
4441 </td></tr></table></dd>
4442 <dd><table>
4443 <tr>
4444 <td> y
4445 </td></tr></table></dd></dl>
4446 !! end
4447
4448 # FIXME: Does this need a html/php section?
4449 !! test
4450 Definition Lists: template interaction
4451 !! wikitext
4452 ::{{definition_list}}
4453
4454 :one
4455 ::{{definition_list}}
4456 :::two
4457 :::three
4458 ::four
4459 !! html/parsoid
4460 <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">
4461 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4462
4463 <dl><dd data-parsoid='{}'>one
4464 <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">
4465 </span><dd about="#mwt2">two
4466 <dl><dd>two</dd>
4467 <dd>three</dd></dl></dd>
4468 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4469 !! end
4470
4471
4472 ###
4473 ### External links
4474 ###
4475 !! test
4476 External links: non-bracketed
4477 !! wikitext
4478 Non-bracketed: http://example.com
4479 !! html
4480 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4481 </p>
4482 !! end
4483
4484 # parsoid doesn't explicitly mark autonumbered links, see T55505
4485 !! test
4486 External links: numbered
4487 !! wikitext
4488 Numbered: [http://example.com]
4489 Numbered: [http://example.net]
4490 Numbered: [http://example.com]
4491 !! html/php
4492 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4493 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4494 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4495 </p>
4496 !! html/parsoid
4497 <p>Numbered: <a rel="mw:ExtLink" href="http://example.com"></a>
4498 Numbered: <a rel="mw:ExtLink" href="http://example.net"></a>
4499 Numbered: <a rel="mw:ExtLink" href="http://example.com"></a></p>
4500 !!end
4501
4502 !! test
4503 External links: specified text
4504 !! wikitext
4505 Specified text: [http://example.com link]
4506 !! html
4507 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4508 </p>
4509 !!end
4510
4511 !! test
4512 External links: trail
4513 !! wikitext
4514 Linktrails should not work for external links: [http://example.com link]s
4515 !! html
4516 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4517 </p>
4518 !! end
4519
4520 !! test
4521 External links: dollar sign in URL
4522 !! wikitext
4523 http://example.com/1$2345
4524 !! html
4525 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4526 </p>
4527 !! end
4528
4529 # parsoid doesn't explicitly mark autonumbered links, see T55505
4530 !! test
4531 External links: dollar sign in URL (autonumber)
4532 !! wikitext
4533 [http://example.com/1$2345]
4534 !! html/php
4535 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4536 </p>
4537 !! html/parsoid
4538 <p><a rel="mw:ExtLink" href="http://example.com/1$2345"></a></p>
4539 !!end
4540
4541 !! test
4542 External links: open square bracket forbidden in URL (T6377)
4543 !! options
4544 parsoid=wt2html,wt2wt,html2html
4545 !! wikitext
4546 http://example.com/1[2345
4547 !! html/php
4548 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4549 </p>
4550 !! html/parsoid
4551 <p><a rel="mw:ExtLink" href="http://example.com/1">http://example.com/1</a>[2345</p>
4552 !! end
4553
4554 !! test
4555 External links: open square bracket forbidden in URL (named) (T6377)
4556 !! options
4557 parsoid=wt2html,html2html
4558 !! wikitext
4559 [http://example.com/1[2345]
4560 !! html/php
4561 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4562 </p>
4563 !! html/parsoid
4564 <p><a rel="mw:ExtLink" href="http://example.com/1">[2345</a></p>
4565 !!end
4566
4567 # parsoid adds a space before the link name
4568 !! test
4569 External links: open square bracket forbidden in URL (named) (T6377)
4570 Parsoid variant.
4571 !! wikitext
4572 [http://example.com/1 [2345]
4573 !! html
4574 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4575 </p>
4576 !!end
4577
4578 !! test
4579 External links: nowiki in URL link text (T8230)
4580 !! wikitext
4581 [http://example.com/ <nowiki>''example site''</nowiki>]
4582 !! html
4583 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4584 </p>
4585 !! end
4586
4587 !! test
4588 External links: newline forbidden in text (T8230 regression check)
4589 !! wikitext
4590 [http://example.com/ first
4591 second]
4592 !! html
4593 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4594 second]
4595 </p>
4596 !!end
4597
4598 !! test
4599 External links: Pipe char between url and text
4600 !! wikitext
4601 [http://example.com | link]
4602 !! html
4603 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4604 </p>
4605 !!end
4606
4607 !! test
4608 External links: protocol-relative URL in brackets
4609 !! wikitext
4610 [//example.com/ Test]
4611 !! html
4612 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4613 </p>
4614 !! end
4615
4616 # parsoid doesn't explicitly mark autonumbered links, see T55505
4617 !! test
4618 External links: protocol-relative URL in brackets without text
4619 !! wikitext
4620 [//example.com]
4621 !! html/php
4622 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
4623 </p>
4624 !! html/parsoid
4625 <p><a rel="mw:ExtLink" href="//example.com"></a></p>
4626 !! end
4627
4628 !! test
4629 External links: protocol-relative URL in free text is left alone
4630 !! wikitext
4631 //example.com/Foo
4632 !! html
4633 <p>//example.com/Foo
4634 </p>
4635 !!end
4636
4637 !! test
4638 External links: protocol-relative URL in the middle of a word is left alone (T32269)
4639 !! wikitext
4640 foo//example.com/Foo
4641 !! html
4642 <p>foo//example.com/Foo
4643 </p>
4644 !! end
4645
4646 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
4647 !! test
4648 External links: with no contents
4649 !! options
4650 parsoid=wt2html,wt2wt
4651 !! wikitext
4652 [http://en.wikipedia.org/wiki/Foo]
4653
4654 [[wikipedia:Foo|Bar]]
4655
4656 [[wikipedia:Foo|<span>Bar</span>]]
4657 !! html/php
4658 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
4659 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
4660 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
4661 </p>
4662 !! html/parsoid
4663 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo"></a></p>
4664 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
4665 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
4666 !! end
4667
4668 !! test
4669 External links: Free with trailing punctuation
4670 !! wikitext
4671 http://example.com,
4672 http://example.com;
4673 http://example.com\
4674 http://example.com.
4675 http://example.com:
4676 http://example.com!
4677 http://example.com?
4678 http://example.com)
4679 http://example.com/url_with_(brackets)
4680 (http://example.com/url_without_brackets)
4681 http://example.com/url_with_entity&amp;
4682 http://example.com/url_with_entity&#x26;
4683 http://example.com/url_with_entity&#038;
4684 http://example.com/url_with_entity&nbsp;
4685 http://example.com/url_with_entity&#xA0;
4686 http://example.com/url_with_entity&#160;
4687 http://example.com/url_with_entity&lt;
4688 http://example.com/url_with_entity&#x3C;
4689 http://example.com/url_with_entity&#60;
4690 !! html/php
4691 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
4692 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
4693 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
4694 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
4695 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
4696 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
4697 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
4698 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
4699 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4700 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4701 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4702 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4703 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4704 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4705 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
4706 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4707 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
4708 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
4709 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
4710 </p>
4711 !! html/parsoid
4712 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a>,
4713 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>;
4714 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>\
4715 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>.
4716 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:
4717 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>!
4718 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>?
4719 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>)
4720 <a rel="mw:ExtLink" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4721 (<a rel="mw:ExtLink" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4722 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4723 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4724 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4725 <a rel="mw:ExtLink" 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>
4726 <a rel="mw:ExtLink" 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>
4727 <a rel="mw:ExtLink" 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>
4728 <a rel="mw:ExtLink" 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>
4729 <a rel="mw:ExtLink" 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>
4730 <a rel="mw:ExtLink" 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>
4731 !! end
4732
4733 !! test
4734 External links: tricky Parsoid html2html case
4735 !! options
4736 parsoid=wt2html,wt2wt,html2html
4737 !! wikitext
4738 http://example.com/url_with_entity&amp;amp;
4739 !! html/php
4740 <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>;
4741 </p>
4742 !! html/parsoid
4743 <p><a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;amp">http://example.com/url_with_entity&amp;amp</a>;</p>
4744 !! end
4745
4746 !! test
4747 External links: Free with trailing quotes (T113666)
4748 !! wikitext
4749 '''News:''' Stuff here
4750
4751 news:'a'b''c''d e
4752 !! html/php
4753 <p><b>News:</b> Stuff here
4754 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
4755 </p>
4756 !! html/parsoid
4757 <p><b>News:</b> Stuff here</p>
4758 <p><a rel="mw:ExtLink" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
4759 !! end
4760
4761 !! test
4762 External links: with entity
4763 !! wikitext
4764 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
4765 !! html/php
4766 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
4767 </p>
4768 !! html/parsoid
4769 <p><a rel="mw:ExtLink" 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>
4770 !! end
4771
4772 !! test
4773 External links: Lone protocols are never linked (T105697)
4774 !! wikitext
4775 http://
4776 http://;
4777 (http://)
4778 bitcoin:
4779 bitcoin:;
4780 (bitcoin:)
4781 !! html
4782 <p>http://
4783 http://;
4784 (http://)
4785 bitcoin:
4786 bitcoin:;
4787 (bitcoin:)
4788 </p>
4789 !! end
4790
4791 !! test
4792 External links: No preceding word characters allowed (T67278)
4793 !! wikitext
4794 NOPEhttp://example.com
4795 N0http://example.com
4796 ok:http://example.com
4797 ok-http://example.com
4798 !! html
4799 <p>NOPEhttp://example.com
4800 N0http://example.com
4801 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4802 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4803 </p>
4804 !! end
4805
4806 !! test
4807 External links: nofollow domain exception
4808 !! wikitext
4809 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
4810 !! html
4811 <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>.
4812 </p>
4813 !!end
4814
4815 !! test
4816 External image
4817 !! wikitext
4818 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4819 !! html
4820 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
4821 </p>
4822 !! end
4823
4824 !! test
4825 External image from https
4826 !! wikitext
4827 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4828 !! html
4829 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
4830 </p>
4831 !! end
4832
4833 !! test
4834 External image (when not allowed)
4835 !! options
4836 wgAllowExternalImages=0
4837 !! wikitext
4838 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4839 !! html
4840 <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>
4841 </p>
4842 !! end
4843
4844 !! test
4845 Link to non-http image, no img tag
4846 !! wikitext
4847 Link to non-http image, no img tag: ftp://example.com/test.jpg
4848 !! html
4849 <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>
4850 </p>
4851 !! end
4852
4853 !! test
4854 External links: terminating separator
4855 !! wikitext
4856 Terminating separator: http://example.com/thing,
4857 !! html
4858 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
4859 </p>
4860 !! end
4861
4862 !! test
4863 External links: intervening separator
4864 !! wikitext
4865 Intervening separator: http://example.com/1,2,3
4866 !! html
4867 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
4868 </p>
4869 !! end
4870
4871 !! test
4872 External links: old bug with URL in query
4873 !! wikitext
4874 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
4875 !! html
4876 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
4877 </p>
4878 !! end
4879
4880 !! test
4881 External links: old URL-in-URL bug, mixed protocols
4882 !! wikitext
4883 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
4884 !! html
4885 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
4886 </p>
4887 !!end
4888
4889 # Since Parsoid is starting to emit canonical wikitext for links,
4890 # [http://example.com http://example.com] will not RT back to that
4891 # form anymore.
4892 !! test
4893 External links: URL in text
4894 !! options
4895 parsoid=wt2html
4896 !! wikitext
4897 URL in text: [http://example.com http://example.com]
4898 !! html/php
4899 <p>URL in text: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4900 </p>
4901 !! html/parsoid
4902 <p>URL in text: <a rel="mw:ExtLink" href="http://example.com">http://example.com</a></p>
4903 !! end
4904
4905 !! test
4906 External links: Clickable images
4907 !! wikitext
4908 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
4909 !! html/php
4910 <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>
4911 </p>
4912 !! html/parsoid
4913 <p>ja-style clickable images: <a rel="mw:ExtLink" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" data-parsoid='{"type":"extlink"}'/></a></p>
4914 !! end
4915
4916 !! test
4917 External links: raw ampersand
4918 !! wikitext
4919 Old &amp; use: http://x&y
4920 !! html
4921 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
4922 </p>
4923 !! end
4924
4925 !! test
4926 External links: encoded ampersand
4927 !! wikitext
4928 Old &amp; use: http://x&amp;y
4929 !! html/php
4930 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
4931 </p>
4932 !! html/parsoid
4933 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y">http://x&amp;y</a></p>
4934 !! end
4935
4936 !! test
4937 External links: encoded equals (T8102)
4938 !! wikitext
4939 http://example.com/?foo&#61;bar
4940 !! html/php
4941 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
4942 </p>
4943 !! html/parsoid
4944 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
4945 !! end
4946
4947 ##
4948 ## Note that parsoid doesn't explicit mark autonumbered links, nor
4949 ## does it number them. As discussed in T55505, we can identify
4950 ## autonumbered links via CSS.
4951 ##
4952
4953 !! test
4954 External links: [raw ampersand]
4955 !! wikitext
4956 Old &amp; use: [http://x&y]
4957 !! html/php
4958 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
4959 </p>
4960 !! html/parsoid
4961 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y"></a></p>
4962 !! end
4963
4964 # note that parsoid html is identical to [raw ampersand] case; so html2wt
4965 # mode will return the [raw ampersand] wikitext
4966 !! test
4967 External links: [encoded ampersand]
4968 !! options
4969 parsoid=wt2html,wt2wt,html2html
4970 !! wikitext
4971 Old &amp; use: [http://x&amp;y]
4972 !! html/php
4973 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
4974 </p>
4975 !! html/parsoid
4976 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y"></a></p>
4977 !! end
4978
4979 !! test
4980 External links: [raw equals]
4981 !! wikitext
4982 [http://example.com/?foo=bar]
4983 !! html/php
4984 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
4985 </p>
4986 !! html/parsoid
4987 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar"></a></p>
4988 !! end
4989
4990 # note that parsoid html is identical to [raw equals] case; so html2wt
4991 # mode will return the [raw equals] wikitext
4992 !! test
4993 External links: [encoded equals] (T8102)
4994 !! options
4995 parsoid=wt2html,wt2wt,html2html
4996 !! wikitext
4997 [http://example.com/?foo&#61;bar]
4998 !! html/php
4999 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5000 </p>
5001 !! html/parsoid
5002 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar"></a></p>
5003 !! end
5004
5005 # xxx parsoid strips the IDN character, so the round-trip tests will
5006 # obviously fail and are disabled. --cscott
5007 !! test
5008 External links: [IDN ignored character reference in hostname; strip it right off]
5009 !! options
5010 parsoid=wt2html,wt2wt,html2html
5011 !! wikitext
5012 [http://e&zwnj;xample.com/]
5013 !! html/php
5014 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5015 </p>
5016 !! html/parsoid
5017 <p><a rel="mw:ExtLink" href="http://example.com/"></a></p>
5018 !! end
5019
5020 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5021 # Where an external link could easily circumvent the sanitization of the text of
5022 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5023 # test demands a higher standard. That's a bit strange.
5024 #
5025 # Example:
5026 #
5027 # http://e‌xample.com -> [http://example.com|http://example.com]
5028 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5029 #
5030 # The first example is sanitized, but the second is not. Any security benefits
5031 # from this production are trivial to circumvent. Either remove this test and
5032 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5033 # the test accordingly.
5034 #
5035 # All our love,
5036 # The Parsoid team.
5037 # xxx parsoid strips the IDN character, so the round-trip tests will
5038 # obviously fail and are disabled. --cscott
5039 !! test
5040 External links: IDN ignored character reference in hostname; strip it right off
5041 !! options
5042 parsoid=wt2html,html2html
5043 !! wikitext
5044 http://e&zwnj;xample.com/
5045 !! html/php
5046 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5047 </p>
5048 !! html/parsoid
5049 <p><a rel="mw:ExtLink" href="http://example.com/">http://example.com/</a></p>
5050 !! end
5051
5052 !! test
5053 External links: www.jpeg.org (T2554)
5054 !! wikitext
5055 http://www.jpeg.org
5056 !! html
5057 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5058 </p>
5059 !! end
5060
5061 # parsoid doesn't explicitly mark autonumbered links, see T55505
5062 !! test
5063 External links: URL within URL (T2002)
5064 !! wikitext
5065 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5066 !! html/php
5067 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5068 </p>
5069 !! html/parsoid
5070 <p><a rel="mw:ExtLink" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp"></a></p>
5071 !! end
5072
5073 !! test
5074 T2361: URL inside bracketed URL
5075 !! wikitext
5076 [http://www.example.com/foo http://www.example.com/bar]
5077 !! html
5078 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5079 </p>
5080 !! end
5081
5082 !! test
5083 T2361: URL within URL, not bracketed
5084 !! wikitext
5085 http://www.example.com/foo?=http://www.example.com/bar
5086 !! html
5087 <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>
5088 </p>
5089 !! end
5090
5091 !! test
5092 T2289: ">"-token in URL-tail
5093 !! wikitext
5094 http://www.example.com/<hello>
5095 !! html
5096 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5097 </p>
5098 !!end
5099
5100 !! test
5101 T2289: literal ">"-token in URL-tail
5102 !! wikitext
5103 http://www.example.com/<b>html</b>
5104 !! html/php
5105 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5106 </p>
5107 !! html/parsoid
5108 <p><a rel="mw:ExtLink" href="http://www.example.com/" data-parsoid='{"stx":"url"}'>http://www.example.com/</a><b data-parsoid='{"stx":"html"}'>html</b></p>
5109 !! end
5110
5111 !! test
5112 T2289: ">"-token in bracketed URL
5113 !! wikitext
5114 [http://www.example.com/<hello> stuff]
5115 !! html
5116 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5117 </p>
5118 !!end
5119
5120 !! test
5121 T2289: literal ">"-token in bracketed URL
5122 !! wikitext
5123 [http://www.example.com/<b>html</b> stuff]
5124 !! html
5125 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5126 </p>
5127 !!end
5128
5129 !! test
5130 T2289: literal double quote at end of URL
5131 !! wikitext
5132 http://www.example.com/"hello"
5133 !! html
5134 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5135 </p>
5136 !!end
5137
5138 !! test
5139 T2289: literal double quote in bracketed URL
5140 !! wikitext
5141 [http://www.example.com/"hello" stuff]
5142 !! html
5143 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5144 </p>
5145 !!end
5146
5147 !! test
5148 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5149 !! wikitext
5150 [http://www.example.com test]
5151 !! html
5152 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5153 </p>
5154 !! end
5155
5156 !! test
5157 External links: link text with spaces
5158 !! wikitext
5159 [http://www.example.com a b c]
5160 [http://www.example.com ''a'' ''b'']
5161 !! html
5162 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5163 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5164 </p>
5165 !! end
5166
5167 !! test
5168 External links: wiki links within external link (T5695)
5169 !! options
5170 parsoid=wt2html,html2html
5171 !! wikitext
5172 [http://example.com [[wikilink]] embedded in ext link]
5173 !! html/php
5174 <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>
5175 </p>
5176 !! html/parsoid
5177 <p><a rel="mw:ExtLink" href="http://example.com"></a><a rel="mw:WikiLink" href="./Wikilink" title="Wikilink">wikilink</a><span> embedded in ext link</span></p>
5178 !! end
5179
5180 !! test
5181 T2787: Links with one slash after the url protocol are invalid
5182 !! wikitext
5183 http:/example.com
5184
5185 [http:/example.com title]
5186 !! html
5187 <p>http:/example.com
5188 </p><p>[http:/example.com title]
5189 </p>
5190 !! end
5191
5192 !! test
5193 Bracketed external links with template-generated invalid target
5194 !! wikitext
5195 [{{echo|http:/example.com}} title]
5196 !! html
5197 <p>[http:/example.com title]
5198 </p>
5199 !! end
5200
5201 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5202 !! test
5203 Broken wikilinks (but not external links) prevent templates from closing
5204 !! options
5205 parsoid=wt2html
5206 !! wikitext
5207 [http://example.com x
5208
5209 {{echo|[http://example.com x}}
5210
5211 [[Foo
5212
5213 {{echo|[[Foo}}
5214 !! html/php
5215 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5216 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5217 </p><p>[[Foo
5218 </p><p>{{echo|[[Foo}}
5219 </p>
5220 !! html/parsoid
5221 <p>[<a rel="mw:ExtLink" href="http://example.com">http://example.com</a> x</p>
5222 <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" href="http://example.com">http://example.com</a> x</p>
5223 <p>[[Foo</p>
5224 <p>{{echo|[[Foo}}</p>
5225 !! end
5226
5227 !! test
5228 Wikilinks with embedded newlines are not broken
5229 !! wikitext
5230 {{echo|[[ Foo
5231 B
5232 C]]}}
5233 !! html/php
5234 <p>[[ Foo
5235 B
5236 C]]
5237 </p>
5238 !! html/parsoid
5239 <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>
5240 !! end
5241
5242 !! test
5243 Broken templates
5244 !! options
5245 parsoid=wt2html
5246 !! wikitext
5247 {{echo|[[Foo|}}]]
5248
5249 [[Foo|{{echo|]]}}
5250 !! html/php
5251 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5252 </p><p>[[Foo|]]
5253 </p>
5254 !! html/parsoid
5255 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5256 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5257 !! end
5258
5259 !! test
5260 T4702: Mismatched <i>, <b> and <a> tags are invalid
5261 !! wikitext
5262 ''[http://example.com text'']
5263 [http://example.com '''text]'''
5264 ''Something [http://example.com in italic'']
5265 ''Something [http://example.com mixed''''', even bold]'''
5266 '''''Now [http://example.com both''''']
5267 !! html
5268 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5269 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5270 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5271 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5272 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5273 </p>
5274 !! end
5275
5276
5277 !! test
5278 T6781: %26 in URL
5279 !! wikitext
5280 http://www.example.com/?title=AT%26T
5281 !! html/php
5282 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5283 </p>
5284 !! html/parsoid
5285 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a></p>
5286 !! end
5287
5288 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5289 # % is actually legal in HTML5. Any change in output would need testing though.
5290 !! test
5291 T6781, T7267: %25 in URL
5292 !! wikitext
5293 http://www.example.com/?title=100%25_Bran
5294 !! html/php
5295 <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>
5296 </p>
5297 !! html/parsoid
5298 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=100%25_Bran">http://www.example.com/?title=100%25_Bran</a></p>
5299 !! end
5300
5301 !! test
5302 T6781, T7267: %28, %29 in URL
5303 !! wikitext
5304 http://www.example.com/?title=Ben-Hur_%281959_film%29
5305 !! html/php
5306 <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>
5307 </p>
5308 !! html/parsoid
5309 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">http://www.example.com/?title=Ben-Hur_%281959_film%29</a></p>
5310 !! end
5311
5312
5313 !! test
5314 T6781: %26 in autonumber URL
5315 !! wikitext
5316 [http://www.example.com/?title=AT%26T]
5317 !! html/php
5318 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5319 </p>
5320 !! html/parsoid
5321 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T"></a></p>
5322 !! end
5323
5324 !! test
5325 T6781, T7267: %26 in autonumber URL
5326 !! wikitext
5327 [http://www.example.com/?title=100%25_Bran]
5328 !! html/php
5329 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5330 </p>
5331 !! html/parsoid
5332 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=100%25_Bran"></a></p>
5333 !! end
5334
5335 !! test
5336 T6781, T7267: %28, %29 in autonumber URL
5337 !! wikitext
5338 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5339 !! html/php
5340 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5341 </p>
5342 !! html/parsoid
5343 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5344 !! end
5345
5346
5347 !! test
5348 T6781: %26 in bracketed URL
5349 !! wikitext
5350 [http://www.example.com/?title=AT%26T link]
5351 !! html/php
5352 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5353 </p>
5354 !! html/parsoid
5355 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T">link</a></p>
5356 !! end
5357
5358 !! test
5359 T6781, T7267: %25 in bracketed URL
5360 !! wikitext
5361 [http://www.example.com/?title=100%25_Bran link]
5362 !! html
5363 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5364 </p>
5365 !! end
5366
5367 !! test
5368 T6781, T7267: %28, %29 in bracketed URL
5369 !! wikitext
5370 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5371 !! html/php
5372 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5373 </p>
5374 !! html/parsoid
5375 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5376 !! end
5377
5378 !! test
5379 External link containing a period in the anchor. (T65947)
5380 !! wikitext
5381 [//foo.org/bar#baz. bang]
5382
5383 [//foo.org/bar. bang]
5384 !! html/php
5385 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5386 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5387 </p>
5388 !! html/parsoid
5389 <p><a rel="mw:ExtLink" href="//foo.org/bar#baz.">bang</a></p>
5390 <p><a rel="mw:ExtLink" href="//foo.org/bar.">bang</a></p>
5391 !! end
5392
5393 !! test
5394 External link containing a single quote. (T65947)
5395 !! wikitext
5396 [//foo.org/bar'baz]
5397
5398 [//foo.org/bar'baz bang]
5399 !! html/php
5400 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
5401 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
5402 </p>
5403 !! html/parsoid
5404 <p><a rel="mw:ExtLink" href="//foo.org/bar'baz"></a></p>
5405 <p><a rel="mw:ExtLink" href="//foo.org/bar'baz">bang</a></p>
5406 !! end
5407
5408 !! test
5409 External link containing double-single-quotes in text '' (T6598 sanity check)
5410 !! wikitext
5411 Some [http://example.com/ pretty ''italics'' and stuff]!
5412 !! html
5413 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5414 </p>
5415 !! end
5416
5417 !! test
5418 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5419 !! wikitext
5420 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5421 !! html
5422 <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>
5423 </p>
5424 !! end
5425
5426 # Don't add the html/php section since the output is broken and there isn't any reason to spec it
5427 !! test
5428 External link containing double-single-quotes with no space separating the url from text in italics
5429 !! wikitext
5430 [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]].]
5431 !! html/php+tidy
5432 <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>.
5433 </p>
5434 !! html/parsoid
5435 <p><a rel="mw:ExtLink" 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>
5436 !! end
5437
5438 !! test
5439 External link with comments in link text
5440 !! wikitext
5441 [http://www.google.com Google <!-- comment -->]
5442 !! html/php
5443 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5444 </p>
5445 !! html/parsoid
5446 <p><a rel="mw:ExtLink" href="http://www.google.com">Google <!-- comment --></a></p>
5447 !! end
5448
5449 !! test
5450 External link to bare IPv4 address
5451 !! wikitext
5452 [http://192.168.0.1 Link]
5453 !! html/php
5454 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5455 </p>
5456 !! html/parsoid
5457 <p><a rel="mw:ExtLink" href="http://192.168.0.1">Link</a></p>
5458 !! end
5459
5460 !! test
5461 URL-encoding in URL functions (single parameter)
5462 !! wikitext
5463 {{localurl:Some page|amp=&}}
5464 !! html
5465 <p>/index.php?title=Some_page&amp;amp=&amp;
5466 </p>
5467 !! end
5468
5469 !! test
5470 URL-encoding in URL functions (multiple parameters)
5471 !! wikitext
5472 {{localurl:Some page|q=?&amp=&}}
5473 !! html
5474 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5475 </p>
5476 !! end
5477
5478 !! test
5479 Brackets in urls
5480 !! wikitext
5481 http://example.com/index.php?foozoid%5B%5D=bar
5482
5483 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5484 !! html/php
5485 <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>
5486 </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>
5487 </p>
5488 !! html/parsoid
5489 <p><a rel="mw:ExtLink" href="http://example.com/index.php?foozoid%5B%5D=bar">http://example.com/index.php?foozoid%5B%5D=bar</a></p>
5490
5491 <p><a rel="mw:ExtLink" 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>
5492 !! end
5493
5494 !! test
5495 IPv6 urls, autolink format (T23261)
5496 !! wikitext
5497 http://[2404:130:0:1000::187:2]/index.php
5498
5499 Examples from RFC 2373, section 2.2:
5500 * http://[1080::8:800:200C:417A]/unicast
5501 * http://[FF01::101]/multicast
5502 * http://[::1]/loopback
5503 * http://[::]/unspecified
5504 * http://[::13.1.68.3]/ipv4compat
5505 * http://[::FFFF:129.144.52.38]/ipv4compat
5506
5507 Examples from RFC 2732, section 2:
5508 * http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5509 * http://[1080:0:0:0:8:800:200C:417A]/index.html
5510 * http://[3ffe:2a00:100:7031::1]
5511 * http://[1080::8:800:200C:417A]/foo
5512 * http://[::192.9.5.5]/ipng
5513 * http://[::FFFF:129.144.52.38]:80/index.html
5514 * http://[2010:836B:4179::836B:4179]
5515
5516 !! html/php
5517 <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>
5518 </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:
5519 </p>
5520 <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>
5521 <li> <a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5522 <li> <a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5523 <li> <a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5524 <li> <a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5525 <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>
5526 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5527 </p>
5528 <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>
5529 <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>
5530 <li> <a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5531 <li> <a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5532 <li> <a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5533 <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>
5534 <li> <a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5535
5536 !! html/parsoid
5537 <p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php">http://[2404:130:0:1000::187:2]/index.php</a></p>
5538
5539 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
5540 <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
5541 <li> <a rel="mw:ExtLink" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5542 <li> <a rel="mw:ExtLink" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5543 <li> <a rel="mw:ExtLink" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5544 <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5545 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
5546
5547 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
5548 <ul><li> <a rel="mw:ExtLink" 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>
5549 <li> <a rel="mw:ExtLink" 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>
5550 <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5551 <li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5552 <li> <a rel="mw:ExtLink" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5553 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]:80/index.html">http://[::FFFF:129.144.52.38]:80/index.html</a></li>
5554 <li> <a rel="mw:ExtLink" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5555 !! end
5556
5557 !! test
5558 IPv6 urls, bracketed format (T23261)
5559 !! wikitext
5560 [http://[2404:130:0:1000::187:2]/index.php test]
5561
5562 Examples from RFC 2373, section 2.2:
5563 * [http://[1080::8:800:200C:417A] unicast]
5564 * [http://[FF01::101] multicast]
5565 * [http://[::1]/ loopback]
5566 * [http://[::] unspecified]
5567 * [http://[::13.1.68.3] ipv4compat]
5568 * [http://[::FFFF:129.144.52.38] ipv4compat]
5569
5570 Examples from RFC 2732, section 2:
5571 * [http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5572 * [http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5573 * [http://[3ffe:2a00:100:7031::1] 3]
5574 * [http://[1080::8:800:200C:417A]/foo 4]
5575 * [http://[::192.9.5.5]/ipng 5]
5576 * [http://[::FFFF:129.144.52.38]:80/index.html 6]
5577 * [http://[2010:836B:4179::836B:4179] 7]
5578
5579 !! html/php
5580 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5581 </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:
5582 </p>
5583 <ul><li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5584 <li> <a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5585 <li> <a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5586 <li> <a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5587 <li> <a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5588 <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5589 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5590 </p>
5591 <ul><li> <a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5592 <li> <a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5593 <li> <a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5594 <li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5595 <li> <a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5596 <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5597 <li> <a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5598
5599 !! html/parsoid
5600 <p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5601
5602 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
5603 <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5604 <li> <a rel="mw:ExtLink" href="http://[FF01::101]">multicast</a></li>
5605 <li> <a rel="mw:ExtLink" href="http://[::1]/">loopback</a></li>
5606 <li> <a rel="mw:ExtLink" href="http://[::]">unspecified</a></li>
5607 <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]">ipv4compat</a></li>
5608 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5609
5610 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
5611 <ul><li> <a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5612 <li> <a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5613 <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5614 <li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5615 <li> <a rel="mw:ExtLink" href="http://[::192.9.5.5]/ipng">5</a></li>
5616 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5617 <li> <a rel="mw:ExtLink" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5618 !! end
5619
5620 !! test
5621 Non-extlinks in brackets
5622 !! wikitext
5623 [foo]
5624 [foo bar]
5625 [foo ''bar'']
5626 [fool's] errand
5627 [fool's errand]
5628 [{{echo|foo}}]
5629 [{{echo|foo}} bar]
5630 [{{echo|foo}} ''bar'']
5631 [{{echo|foo}}l's] errand
5632 [{{echo|foo}}l's errand]
5633 [url={{echo|foo}}]
5634 [url=http://example.com]
5635 [http:// bare protocols don't count]
5636 !! html/php
5637 <p>[foo]
5638 [foo bar]
5639 [foo <i>bar</i>]
5640 [fool's] errand
5641 [fool's errand]
5642 [foo]
5643 [foo bar]
5644 [foo <i>bar</i>]
5645 [fool's] errand
5646 [fool's errand]
5647 [url=foo]
5648 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
5649 [http:// bare protocols don't count]
5650 </p>
5651 !! html/parsoid
5652 <p>[foo]
5653 [foo bar]
5654 [foo <i>bar</i>]
5655 [fool's] errand
5656 [fool's errand]
5657 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span>]
5658 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span> bar]
5659 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span> <i>bar</i>]
5660 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}l&#39;s"}'>fool's</span>] errand
5661 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}l&#39;s"}'>fool's</span> errand]
5662 [<span typeof="mw:Placeholder" data-parsoid='{"src":"url={{echo|foo}}"}'>url=foo</span>]
5663 [url=<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>]
5664 [http:// bare protocols don't count]</p>
5665 !! end
5666
5667 !! test
5668 Percent encoding in external links
5669 !! wikitext
5670 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
5671 !! html/php
5672 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
5673 </p>
5674 !! html/parsoid
5675 <p><a rel="mw:ExtLink"
5676 href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
5677 !! end
5678
5679 !! test
5680 Use url link syntax for links where the content is equal the link target
5681 !! wikitext
5682 http://example.com
5683 !! html/php
5684 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5685 </p>
5686 !! html/parsoid
5687 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></p>
5688 !! end
5689
5690 !! test
5691 Parenthesis in external links, especially URL links
5692 !! wikitext
5693 http://example.com)
5694
5695 http://example.com/test)
5696
5697 http://example.com/(test)
5698
5699 http://example.com/((test)
5700
5701 (http://example.com/(test))
5702
5703 (http://example.com/(test)))))
5704
5705 http://example.com/a)b
5706
5707 [http://example.com) foo]
5708 !! html/php
5709 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5710 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
5711 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
5712 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
5713 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
5714 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
5715 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
5716 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
5717 </p>
5718 !! html/parsoid
5719 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a>)</p>
5720 <p><a rel="mw:ExtLink" href="http://example.com/test">http://example.com/test</a>)</p>
5721 <p><a rel="mw:ExtLink" href="http://example.com/(test)">http://example.com/(test)</a></p>
5722 <p><a rel="mw:ExtLink" href="http://example.com/((test)">http://example.com/((test)</a></p>
5723 <p>(<a rel="mw:ExtLink" href="http://example.com/(test))">http://example.com/(test))</a></p>
5724 <p>(<a rel="mw:ExtLink" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
5725 <p><a rel="mw:ExtLink" href="http://example.com/a)b">http://example.com/a)b</a></p>
5726 <p><a rel="mw:ExtLink" href="http://example.com)">foo</a></p>
5727 !! end
5728
5729 !! test
5730 Parenthesis in external links, w/ transclusion or comment
5731 !! wikitext
5732 (http://example.com/{{echo|hi}})
5733
5734 (http://example.com<!-- hi -->)
5735 !! html/php
5736 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
5737 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5738 </p>
5739 !! html/parsoid
5740 <p>(<a typeof="mw:ExpandedAttrs" about="#mwt2" rel="mw:ExtLink" 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>
5741
5742 <p>(<a rel="mw:ExtLink" 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>
5743 !! end
5744
5745 !! test
5746 Serialize <a> tags with invalid link targets as plain text
5747 !! options
5748 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
5749 !! html/parsoid
5750 <a rel="mw:WikiLink" href="[[foo]]">text</a>
5751 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
5752 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
5753 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
5754 !! wikitext
5755 text
5756 <nowiki>*</nowiki>text
5757 <nowiki>[[foo]]</nowiki>
5758 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
5759 !! end
5760
5761 !! test
5762 mw:ExtLink -vs- mw:WikiLink (T94723)
5763 !! options
5764 parsoid=html2wt
5765 !! html/parsoid
5766 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
5767 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
5768 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5769 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5770 <p>
5771 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5772 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5773 </p>
5774 !! wikitext
5775 [[Foo|Bar]]
5776 [[Foo|Bar]]
5777 [[:en:Foo|Bar]]
5778 [[:en:Foo|Bar]]
5779
5780 [[:en:European_Robin|European Robin]]
5781 [[:en:European_Robin|European Robin]]
5782 !! end
5783
5784 !! test
5785 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
5786 !! options
5787 parsoid=wt2wt
5788 !! wikitext
5789 [http://en.wikipedia.org/wiki/European_Robin European Robin]
5790 !! html/parsoid
5791 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
5792 !! end
5793
5794
5795 ###
5796 ### Quotes
5797 ###
5798
5799 !! test
5800 Quotes
5801 !! wikitext
5802 Normal text. '''Bold text.''' Normal text. ''Italic text.''
5803
5804 Normal text. '''''Bold italic text.''''' Normal text.
5805 !! html
5806 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
5807 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
5808 </p>
5809 !! end
5810
5811
5812 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
5813 # parser strips. The wikitext contains just the first half of the bold
5814 # quote pair.
5815 !! test
5816 Unclosed and unmatched quotes
5817 !! wikitext
5818 '''''Bold italic text '''with bold deactivated''' in between.'''''
5819
5820 '''''Bold italic text ''with italic deactivated'' in between.'''''
5821
5822 '''Bold text..
5823
5824 ..spanning two paragraphs (should not work).'''
5825
5826 '''Bold tag left open
5827
5828 ''Italic tag left open
5829
5830 Normal text.
5831
5832 <!-- Unmatching number of opening, closing tags: -->
5833 '''This year''''s election ''should'' beat '''last year''''s.
5834
5835 ''Tom'''s car is bigger than ''Susan'''s.
5836
5837 Plain ''italic'''s plain
5838 !! html/php
5839 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
5840 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
5841 </p><p><b>Bold text..</b>
5842 </p><p>..spanning two paragraphs (should not work).
5843 </p><p><b>Bold tag left open</b>
5844 </p><p><i>Italic tag left open</i>
5845 </p><p>Normal text.
5846 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
5847 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
5848 </p><p>Plain <i>italic'</i>s plain
5849 </p>
5850 !! html/parsoid
5851 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
5852 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
5853 </p><p><b>Bold text..</b>
5854 </p><p>..spanning two paragraphs (should not work).<b></b>
5855 </p><p><b>Bold tag left open</b>
5856 </p><p><i>Italic tag left open</i>
5857 </p><p>Normal text.
5858 </p>
5859 <!-- Unmatching number of opening, closing tags: -->
5860 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
5861 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
5862 </p><p>Plain <i>italic'</i>s plain
5863 </p>
5864 !! end
5865
5866 ###
5867 ### Tables
5868 ###
5869 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
5870 ###
5871
5872 # This should not produce <table></table> as <table><tr><td></td></tr></table>
5873 # is the bare minimum required by the spec, see:
5874 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
5875 # Parsoid team replies: empty table tags are legal in HTML5
5876 !! test
5877 A table with no data.
5878 !! options
5879 parsoid=wt2html
5880 !! wikitext
5881 {||}
5882 !! html/php
5883
5884 !! html/parsoid
5885 <table></table>
5886
5887 !! end
5888
5889 !! test
5890 A table with stray table end tags on start tag line (wt2html)
5891 !! options
5892 parsoid=wt2html
5893 !! wikitext
5894 {|style="color: red;"|}
5895
5896 {|style="color: red;" |}
5897 |foo
5898 |}
5899
5900 {|style="color: red;"|} id="foo"
5901 |foo
5902 |}
5903
5904 {|style="color: red;" |} id="foo"
5905 |foo
5906 |}
5907 !! html
5908 <table style="color: red;"></table>
5909
5910 <table style="color: red;">
5911 <tbody><tr>
5912 <td>foo</td>
5913 </tr></tbody>
5914 </table>
5915
5916 <table style="color: red;" id="foo">
5917 <tbody><tr>
5918 <td>foo</td>
5919 </tr></tbody>
5920 </table>
5921
5922 <table style="color: red;" id="foo">
5923 <tbody><tr>
5924 <td>foo</td>
5925 </tr></tbody>
5926 </table>
5927
5928 !! end
5929
5930 !! test
5931 A table with no data (take 2)
5932 !! wikitext
5933 {|
5934 |}
5935 !! html/parsoid
5936 <table></table>
5937 !! end
5938
5939 # A table with nothing but a caption is invalid XHTML, we might want to render
5940 # this as <p>caption</p>
5941 # Parsoid team replies: table with only a caption is legal in HTML5
5942 !! test
5943 A table with nothing but a caption
5944 !! wikitext
5945 {|
5946 |+ caption
5947 |}
5948 !! html/php
5949 <table>
5950 <caption> caption
5951 </caption><tr><td></td></tr></table>
5952
5953 !! html/parsoid
5954 <table><caption> caption</caption></table>
5955 !! end
5956
5957 !! test
5958 A table with caption with default-spaced attributes and a table row
5959 !! wikitext
5960 {|
5961 |+ style="color: red;" | caption1
5962 |-
5963 | foo
5964 |}
5965 !! html
5966 <table>
5967 <caption style="color: red;"> caption1
5968 </caption>
5969 <tr>
5970 <td> foo
5971 </td></tr></table>
5972
5973 !! end
5974
5975 !! test
5976 A table with captions with non-default spaced attributes and a table row
5977 !! wikitext
5978 {|
5979 |+style="color: red;"|caption2
5980 |+ style="color: red;"| caption3
5981 |-
5982 | foo
5983 |}
5984 !! html
5985 <table>
5986 <caption style="color: red;">caption2
5987 </caption>
5988 <caption style="color: red;"> caption3
5989 </caption>
5990 <tr>
5991 <td> foo
5992 </td></tr></table>
5993
5994 !! end
5995
5996 !! test
5997 Table td-cell syntax variations
5998 !! wikitext
5999 {|
6000 | foo bar foo | baz
6001 | foo bar foo || baz
6002 | style='color:red;' | baz
6003 | style='color:red;' || baz
6004 |}
6005 !! html
6006 <table>
6007 <tr>
6008 <td> baz
6009 </td>
6010 <td> foo bar foo </td>
6011 <td> baz
6012 </td>
6013 <td style="color:red;"> baz
6014 </td>
6015 <td> style='color:red;' </td>
6016 <td> baz
6017 </td></tr></table>
6018
6019 !! end
6020
6021 !! test
6022 Simple table
6023 !! wikitext
6024 {|
6025 | 1 || 2
6026 |-
6027 | 3 || 4
6028 |}
6029 !! html
6030 <table>
6031 <tr>
6032 <td> 1 </td>
6033 <td> 2
6034 </td></tr>
6035 <tr>
6036 <td> 3 </td>
6037 <td> 4
6038 </td></tr></table>
6039
6040 !! end
6041
6042 !! test
6043 Simple table but with multiple dashes for row wikitext
6044 !! wikitext
6045 {|
6046 | foo
6047 |-----
6048 | bar
6049 |}
6050 !! html
6051 <table>
6052 <tr>
6053 <td> foo
6054 </td></tr>
6055 <tr>
6056 <td> bar
6057 </td></tr></table>
6058
6059 !! end
6060
6061 !! test
6062 Multiplication table
6063 !! wikitext
6064 {| border="1" cellpadding="2"
6065 |+Multiplication table
6066 |-
6067 ! &times; !! 1 !! 2 !! 3
6068 |-
6069 ! 1
6070 | 1 || 2 || 3
6071 |-
6072 ! 2
6073 | 2 || 4 || 6
6074 |-
6075 ! 3
6076 | 3 || 6 || 9
6077 |-
6078 ! 4
6079 | 4 || 8 || 12
6080 |-
6081 ! 5
6082 | 5 || 10 || 15
6083 |}
6084 !! html
6085 <table border="1" cellpadding="2">
6086 <caption>Multiplication table
6087 </caption>
6088 <tr>
6089 <th> &#215; </th>
6090 <th> 1 </th>
6091 <th> 2 </th>
6092 <th> 3
6093 </th></tr>
6094 <tr>
6095 <th> 1
6096 </th>
6097 <td> 1 </td>
6098 <td> 2 </td>
6099 <td> 3
6100 </td></tr>
6101 <tr>
6102 <th> 2
6103 </th>
6104 <td> 2 </td>
6105 <td> 4 </td>
6106 <td> 6
6107 </td></tr>
6108 <tr>
6109 <th> 3
6110 </th>
6111 <td> 3 </td>
6112 <td> 6 </td>
6113 <td> 9
6114 </td></tr>
6115 <tr>
6116 <th> 4
6117 </th>
6118 <td> 4 </td>
6119 <td> 8 </td>
6120 <td> 12
6121 </td></tr>
6122 <tr>
6123 <th> 5
6124 </th>
6125 <td> 5 </td>
6126 <td> 10 </td>
6127 <td> 15
6128 </td></tr></table>
6129
6130 !! end
6131
6132 !! test
6133 Accept "||" in table headings
6134 !! wikitext
6135 {|
6136 !h1 || h2
6137 |}
6138 !! html
6139 <table>
6140 <tr>
6141 <th>h1 </th>
6142 <th> h2
6143 </th></tr></table>
6144
6145 !! end
6146
6147 !! test
6148 Accept "!!" in table data
6149 !! wikitext
6150 {|
6151 | Foo!! ||
6152 |}
6153 !! html
6154 <table>
6155 <tr>
6156 <td> Foo!! </td>
6157 <td>
6158 </td></tr></table>
6159
6160 !! html/parsoid
6161 <table>
6162 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
6163 </tbody></table>
6164 !! end
6165
6166 !! test
6167 Accept "||" in indented table headings
6168 !! wikitext
6169 :{|
6170 !h1 || h2
6171 |}
6172 !! html
6173 <dl><dd><table>
6174 <tr>
6175 <th>h1 </th>
6176 <th> h2
6177 </th></tr></table></dd></dl>
6178
6179 !! end
6180
6181 !! test
6182 Accept "!!" in templates
6183 !! wikitext
6184 {|
6185 !a {{echo|b!!c}}
6186 |}
6187 !! html/php
6188 <table>
6189 <tr>
6190 <th>a b</th>
6191 <th>c
6192 </th></tr></table>
6193
6194 !! html/parsoid
6195 <table>
6196 <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>
6197 !! end
6198
6199 !! test
6200 Accept "!!" in table headings after newline
6201 !! wikitext
6202 {|
6203 !a
6204 b!!c
6205 |}
6206 !! html/php
6207 <table>
6208 <tr>
6209 <th>a
6210 <p>b!!c
6211 </p>
6212 </th></tr></table>
6213
6214 !! html/parsoid
6215 <table>
6216 <tbody><tr><th>a
6217 <p>b!!c</p></th></tr>
6218 </tbody></table>
6219 !! end
6220
6221 !! test
6222 Accept "!!" in table data of mixed wikitext / html syntax
6223 !! wikitext
6224 {|
6225 !a
6226 <tr><td>b!!c</td></tr>
6227 |}
6228 !! html/php+tidy
6229 <table>
6230 <tbody><tr>
6231 <th>a
6232 </th></tr><tr><td>b!!c</td></tr>
6233 </tbody></table>
6234 !! html/parsoid
6235 <table>
6236 <tbody><tr><th>a</th></tr>
6237 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6238 </tbody></table>
6239 !! end
6240
6241 !! test
6242 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6243 !! wikitext
6244 {|
6245 !| h1
6246 || a
6247 |}
6248 !! html
6249 <table>
6250 <tr>
6251 <th> h1
6252 </th>
6253 <td> a
6254 </td></tr></table>
6255
6256 !! end
6257
6258 !!test
6259 Accept "| !" at start of line in tables (ignore !-attribute)
6260 !! wikitext
6261 {|
6262 |-
6263 | !style="color:red" | bar
6264 |}
6265 !! html
6266 <table>
6267
6268 <tr>
6269 <td> bar
6270 </td></tr></table>
6271
6272 !!end
6273
6274 !!test
6275 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 +/-
6276 !! wikitext
6277 {|
6278 |-
6279 |style='color:red;'|+1
6280 |style='color:blue;'|-1
6281 |-
6282 | 1 || 2 || 3
6283 | 1 ||+2 ||-3
6284 |-
6285 | +1
6286 | -1
6287 |}
6288 !! html
6289 <table>
6290
6291 <tr>
6292 <td style="color:red;">+1
6293 </td>
6294 <td style="color:blue;">-1
6295 </td></tr>
6296 <tr>
6297 <td> 1 </td>
6298 <td> 2 </td>
6299 <td> 3
6300 </td>
6301 <td> 1 </td>
6302 <td>+2 </td>
6303 <td>-3
6304 </td></tr>
6305 <tr>
6306 <td> +1
6307 </td>
6308 <td> -1
6309 </td></tr></table>
6310
6311 !!end
6312
6313 !! test
6314 Table rowspan
6315 !! wikitext
6316 {| border=1
6317 | Cell 1, row 1
6318 |rowspan=2| Cell 2, row 1 (and 2)
6319 | Cell 3, row 1
6320 |-
6321 | Cell 1, row 2
6322 | Cell 3, row 2
6323 |}
6324 !! html
6325 <table border="1">
6326 <tr>
6327 <td> Cell 1, row 1
6328 </td>
6329 <td rowspan="2"> Cell 2, row 1 (and 2)
6330 </td>
6331 <td> Cell 3, row 1
6332 </td></tr>
6333 <tr>
6334 <td> Cell 1, row 2
6335 </td>
6336 <td> Cell 3, row 2
6337 </td></tr></table>
6338
6339 !! end
6340
6341 !! test
6342 Nested table
6343 !! wikitext
6344 {| border=1
6345 | &alpha;
6346 |
6347 {| bgcolor=#ABCDEF border=2
6348 |nested
6349 |-
6350 |table
6351 |}
6352 |the original table again
6353 |}
6354 !! html
6355 <table border="1">
6356 <tr>
6357 <td> &#945;
6358 </td>
6359 <td>
6360 <table bgcolor="#ABCDEF" border="2">
6361 <tr>
6362 <td>nested
6363 </td></tr>
6364 <tr>
6365 <td>table
6366 </td></tr></table>
6367 </td>
6368 <td>the original table again
6369 </td></tr></table>
6370
6371 !! end
6372
6373 !! test
6374 Invalid attributes in table cell (T3830)
6375 !! wikitext
6376 {|
6377 |Cell:|broken
6378 |}
6379 !! html
6380 <table>
6381 <tr>
6382 <td>broken
6383 </td></tr></table>
6384
6385 !! end
6386
6387 !! test
6388 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6389 !! wikitext
6390 {|
6391 | title="foo" |bar
6392 | title="foo<nowiki>|</nowiki>" |bar
6393 | title="foo<nowiki>|</nowiki>" bar
6394 |}
6395 !! html/php
6396 <table>
6397 <tr>
6398 <td title="foo">bar
6399 </td>
6400 <td title="foo&#124;">bar
6401 </td>
6402 <td> title="foo|" bar
6403 </td></tr></table>
6404
6405 !! html/parsoid
6406 <table>
6407 <tbody><tr><td title="foo">bar</td>
6408 <td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
6409 <td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6410 </tbody></table>
6411 !! end
6412
6413 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6414 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6415 # *2wt modes will fail.
6416 !! test
6417 Table security: embedded pipes
6418 !! options
6419 parsoid=wt2html,html2html
6420 !! wikitext
6421 {|
6422 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6423 !! html/php
6424 <table>
6425 <tr>
6426 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6427 <td>]" onmouseover="alert(document.cookie)"&gt;test
6428 </td>
6429 </tr>
6430 </table>
6431
6432 !! html/parsoid
6433 <table><tbody>
6434 <tr>
6435 <td data-parsoid='{"startTagSrc":"| ","attrSepSrc":"|","autoInsertedEnd":true}'>[<a rel="mw:ExtLink" 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>
6436 !! end
6437
6438 !! test
6439 Element attributes with double ! should not be broken up by <th>
6440 !! wikitext
6441 {|
6442 ! hi <div class="!!">ha</div> ho
6443 |}
6444 !! html/php
6445 <table>
6446 <tr>
6447 <th> hi <div class="!!">ha</div> ho
6448 </th></tr></table>
6449
6450 !! html/parsoid
6451 <table>
6452 <tbody><tr><th> hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6453 </tbody></table>
6454 !! end
6455
6456 !! test
6457 ! and || in element attributes should not be parsed as <th>/<td>
6458 !! wikitext
6459 {|
6460 | <div style="color: red !important;" data-contrived="put this here ||">hi</div>
6461 |}
6462 !! html/php
6463 <table>
6464 <tr>
6465 <td> <div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
6466 </td></tr></table>
6467
6468 !! html/parsoid
6469 <table>
6470 <tbody><tr><td> <div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6471 </tbody></table>
6472 !! end
6473
6474 # FIXME: The output seems broken. Filed as T110268.
6475 !! test
6476 ! and || in td attributes should not be parsed as <th>/<td>
6477 !! options
6478 parsoid=wt2html
6479 !! wikitext
6480 {|
6481 | style="color: red !important;" data-contrived="put this here ||" | foo
6482 |}
6483 !! html/php
6484 <table>
6485 <tr>
6486 <td> style="color: red !important;" data-contrived="put this here </td>
6487 <td> foo
6488 </td></tr></table>
6489
6490 !! html/parsoid
6491 <table>
6492 <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>
6493 </tbody></table>
6494 !! end
6495
6496 !! test
6497 Break on | in element attribute in template
6498 !! options
6499 parsoid=wt2html,html2html
6500 !! wikitext
6501 {{echo|1=<div class="hi|ho">ha</div>}}
6502 !! html/php
6503 <p>ho"&gt;ha&lt;/div&gt;
6504 </p>
6505 !! html/parsoid
6506 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"ho\">ha&lt;/div>"}},"i":0}}]}'>ho">ha</span>
6507 !! end
6508
6509 !! test
6510 Break on | in element attribute name in template
6511 !! wikitext
6512 {{echo|<div cla|ss="hiho">ha</div>}}
6513 !! html/parsoid
6514 <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>
6515 !! end
6516
6517 !! test
6518 Don't break on | in extension attribute in template
6519 !! wikitext
6520 {{echo|<ref name="hi|ho">ha</ref>}}
6521
6522 <references />
6523 !! html/parsoid
6524 <p><span about="#mwt2" class="mw-ref" id="cite_ref-hi|ho_1-0" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;ref name=\"hi|ho\">ha&lt;/ref>"}},"i":0}}]}'><a href="./Main_Page#cite_note-hi|ho-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></p>
6525
6526 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-hi|ho-1" id="cite_note-hi|ho-1"><a href="./Main_Page#cite_ref-hi|ho_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-hi|ho-1" class="mw-reference-text">ha</span></li></ol>
6527 !! end
6528
6529 ## We don't support roundtripping of these attributes in Parsoid.
6530 ## Selective serialization takes care of preventing dirty diffs.
6531 ## But, on edits, we dirty-diff the invalid attribute text.
6532 !! test
6533 Invalid text in table attributes should be discarded
6534 !! options
6535 parsoid=wt2html
6536 !! wikitext
6537 {| <span>boo</span> style='border:1px solid black'
6538 | <span>boo</span> style='color:blue' | 1
6539 |<span>boo</span> style='color:blue'| 2
6540 |}
6541 !! html/php
6542 <table style="border:1px solid black">
6543 <tr>
6544 <td style="color:blue"> 1
6545 </td>
6546 <td style="color:blue"> 2
6547 </td></tr></table>
6548
6549 !! html/parsoid
6550 <table style="border:1px solid black">
6551 <tr>
6552 <td style="color:blue"> 1</td>
6553 <td style="color:blue"> 2</td>
6554 </tr>
6555 </table>
6556 !! end
6557
6558 !! test
6559 Invalid text in table attributes should be preserved by selective serializer
6560 !! options
6561 parsoid={
6562 "modes": ["selser"],
6563 "changes": [
6564 ["td:first-child", "text", "abc"],
6565 ["td + td", "text", "xyz"]
6566 ]
6567 }
6568 !! wikitext
6569 {| <span>boo</span> style='border:1px solid black'
6570 | <span>boo</span> style='color:blue' | 1
6571 |<span>boo</span> style='color:blue'| 2
6572 |}
6573 !! wikitext/edited
6574 {| <span>boo</span> style='border:1px solid black'
6575 | <span>boo</span> style='color:blue' |abc
6576 |<span>boo</span> style='color:blue'|xyz
6577 |}
6578 !! end
6579
6580 !! test
6581 1. Template-generated table cell attributes and cell content
6582 !! wikitext
6583 {|
6584 |{{table_attribs}}
6585 | {{table_attribs}}
6586 || {{table_attribs_5}}
6587 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
6588 |align=center {{table_attribs}}
6589 | <!--foo--> align=center <!--bar--> {{table_attribs}}
6590 |}
6591 !! html
6592 <table>
6593 <tr>
6594 <td style="color:red;">Foo
6595 </td>
6596 <td style="color:red;">Foo
6597 </td>
6598 <td> style="color:red;"</td>
6599 <td>Bar
6600 </td>
6601 <td style="color:red;">Foo
6602 </td>
6603 <td align="center" style="color:red;">Foo
6604 </td>
6605 <td align="center" style="color:red;">Foo
6606 </td></tr></table>
6607
6608 !! end
6609
6610 !! test
6611 2. Template-generated table cell attributes and cell content
6612 !! wikitext
6613 {|
6614 |{{table_attribs_2}}
6615 |}
6616 !! html/php
6617 <table>
6618 <tr>
6619 <td style="color:red;">Foo
6620 </td>
6621 <td>Bar</td>
6622 <td>Baz
6623 </td></tr></table>
6624
6625 !! html/parsoid
6626 <table>
6627 <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>
6628 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
6629 </tbody></table>
6630 !! end
6631
6632 !! test
6633 3. Template-generated table cell attributes and cell content
6634 !! wikitext
6635 {|
6636 !align=center {{table_header_cells}}
6637 |-
6638 |align=center {{table_cells}}
6639 |}
6640 !! html/php
6641 <table>
6642 <tr>
6643 <th align="center" style="color:red;">Foo</th>
6644 <th style="color:red;"><i>Bar</i></th>
6645 <th style="color:brown;"><i>Foo</i> and Baz
6646 </th></tr>
6647 <tr>
6648 <td align="center" style="color:red;">Foo</td>
6649 <td style="color:red;"><i>Bar</i></td>
6650 <td style="color:brown;"><i>Foo</i> and Baz
6651 </td></tr></table>
6652
6653 !! html/parsoid
6654 <table>
6655 <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>
6656 <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>
6657 </tbody></table>
6658 !! end
6659
6660 !! test
6661 4. Template-generated table cell attributes and cell content inside a templated table
6662 !! wikitext
6663 {{tbl-start}}
6664 !align=center {{table_header_cells}}
6665 |-
6666 |align=center {{table_cells}}
6667 {{tbl-end}}
6668 !! html/php
6669 <table>
6670 <tr>
6671 <th align="center" style="color:red;">Foo</th>
6672 <th style="color:red;"><i>Bar</i></th>
6673 <th style="color:brown;"><i>Foo</i> and Baz
6674 </th></tr>
6675 <tr>
6676 <td align="center" style="color:red;">Foo</td>
6677 <td style="color:red;"><i>Bar</i></td>
6678 <td style="color:brown;"><i>Foo</i> and Baz
6679 </td></tr></table>
6680
6681 !! html/parsoid
6682 <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}}]}'>
6683 <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>
6684 <tr>
6685 <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>
6686 </tbody></table>
6687 !! end
6688
6689 ## Edge case fix to prevent future regressions
6690 !! test
6691 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
6692 !! wikitext
6693 {|
6694 |{{table_attribs_7}}
6695 |}
6696 <references />
6697 !! html/parsoid
6698 <table>
6699 <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<span class="mw-ref" id="cite_ref-1" rel="dc:references" data-mw='{"name":"ref","body":{"id":"mw-reference-text-cite_note-1"},"attrs":{}}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></td></tr>
6700 </tbody></table>
6701 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
6702 !! end
6703
6704 !! test
6705 Table with row followed by newlines and table heading
6706 !! options
6707 parsoid=wt2html,html2html
6708 !! wikitext
6709 {|
6710 |-
6711
6712 ! foo
6713 |}
6714 !! html/*
6715 <table>
6716
6717
6718 <tr>
6719 <th> foo
6720 </th></tr></table>
6721
6722 !! end
6723
6724 !! test
6725 Table with empty line following the start tag
6726 !! options
6727 parsoid=wt2html,html2html
6728 !! wikitext
6729 {|
6730
6731 |-
6732 | foo
6733 |}
6734 !! html/*
6735 <table>
6736
6737
6738 <tr>
6739 <td> foo
6740 </td></tr></table>
6741
6742 !! end
6743
6744 !! test
6745 Table attributes with empty value
6746 !! options
6747 parsoid=wt2html,html2html
6748 !! wikitext
6749 {|
6750 | style=| hello
6751 |}
6752 !! html/php
6753 <table>
6754 <tr>
6755 <td style=""> hello
6756 </td></tr></table>
6757
6758 !! html/parsoid
6759 <table>
6760 <tbody><tr><td style=""> hello</td></tr>
6761 </tbody></table>
6762 !! end
6763
6764 !! test
6765 Wikitext table with a lot of comments
6766 !! wikitext
6767 {|
6768 <!-- c0 -->
6769 | foo
6770 <!-- c1 -->
6771 |-<!-- c2 -->
6772 <!-- c3 -->
6773 |<!-- c4 -->
6774 <!-- c5 -->
6775 |}
6776 !! html
6777 <table>
6778 <tr>
6779 <td> foo
6780 </td></tr>
6781 <tr>
6782 <td>
6783 </td></tr></table>
6784
6785 !! end
6786
6787 !! test
6788 Wikitext table comments represented in parsoid dom
6789 !! wikitext
6790 {|<!--c1--><!--c2-->
6791 |-<!--c3-->
6792 | x
6793 |}
6794 !! html/php+tidy
6795 <table>
6796
6797 <tbody><tr>
6798 <td> x
6799 </td></tr></tbody></table>
6800 !! html/parsoid
6801 <table><!--c1--><!--c2-->
6802 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
6803 <td data-parsoid='{"autoInsertedEnd":true}'> x</td></tr>
6804 </tbody></table>
6805 !! end
6806
6807 !! test
6808 Wikitext table with double-line table cell
6809 !! wikitext
6810 {|
6811 |a
6812 b
6813 |}
6814 !! html
6815 <table>
6816 <tr>
6817 <td>a
6818 <p>b
6819 </p>
6820 </td></tr></table>
6821
6822 !! end
6823
6824 !! test
6825 Table cell with a single comment
6826 !! wikitext
6827 {|
6828 | <!-- c1 -->
6829 | a
6830 |}
6831 !! html
6832 <table>
6833 <tr>
6834 <td>
6835 </td>
6836 <td> a
6837 </td></tr></table>
6838
6839 !! end
6840
6841 !! test
6842 Table-cell after a comment-only-empty-line
6843 !! wikitext
6844 {|
6845 |a
6846 <!--c1-->
6847 <!--c2-->| b
6848 |}
6849 !! html
6850 <table>
6851 <tr>
6852 <td>a
6853 </td>
6854 <td> b
6855 </td></tr></table>
6856
6857 !! html/parsoid
6858 <table>
6859 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
6860 <!--c1-->
6861 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'> b</td></tr>
6862 </tbody></table>
6863
6864 !! end
6865
6866 !! test
6867 Build table with {{!}}
6868 !! wikitext
6869 {{{!}} class="wikitable"
6870 ! header
6871 ! second header
6872 {{!}}- style="color:red;"
6873 {{!}} data {{!}}{{!}} style="color:red;" {{!}} second data
6874 {{!}}}
6875 !! html
6876 <table class="wikitable">
6877 <tr>
6878 <th> header
6879 </th>
6880 <th> second header
6881 </th></tr>
6882 <tr style="color:red;">
6883 <td> data </td>
6884 <td style="color:red;"> second data
6885 </td></tr></table>
6886
6887 !! end
6888
6889 !! test
6890 Build table with pipe as data
6891 !! wikitext
6892 {| class="wikitable"
6893 ! header
6894 ! second header
6895 |- style="color:red;"
6896 | data || style="color:red;" | second data
6897 |-
6898 | style="color:red;" | data with | || style="color:red;" | second data with |
6899 |-
6900 || data with | ||| second data with |
6901 |}
6902 !! html
6903 <table class="wikitable">
6904 <tr>
6905 <th> header
6906 </th>
6907 <th> second header
6908 </th></tr>
6909 <tr style="color:red;">
6910 <td> data </td>
6911 <td style="color:red;"> second data
6912 </td></tr>
6913 <tr>
6914 <td style="color:red;"> data with | </td>
6915 <td style="color:red;"> second data with |
6916 </td></tr>
6917 <tr>
6918 <td> data with | </td>
6919 <td> second data with |
6920 </td></tr></table>
6921
6922 !! end
6923
6924 !! test
6925 Build table with wikilink
6926 !! wikitext
6927 {| class="wikitable"
6928 ! header || second header
6929 |- style="color:red;"
6930 | data [[Main Page|linktext]] || second data [[Main Page|linktext]]
6931 |-
6932 | data || second data [[Main Page|link|text with pipe]]
6933 |}
6934 !! html
6935 <table class="wikitable">
6936 <tr>
6937 <th> header </th>
6938 <th> second header
6939 </th></tr>
6940 <tr style="color:red;">
6941 <td> data <a href="/wiki/Main_Page" title="Main Page">linktext</a> </td>
6942 <td> second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
6943 </td></tr>
6944 <tr>
6945 <td> data </td>
6946 <td> second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
6947 </td></tr></table>
6948
6949 !! end
6950
6951 # The expected HTML structure in this test is debatable. The PHP parser does
6952 # not parse this kind of table at all. The main focus for Parsoid is on
6953 # round-tripping, so this output is ok for now. TODO: revisit!
6954 !! test
6955 Wikitext table with html-syntax row
6956 !! wikitext
6957 {|
6958 |-
6959 <td>foo</td>
6960 |}
6961 !! html/parsoid
6962 <table>
6963 <tbody>
6964 <tr>
6965 <td>foo</td></tr></tbody></table>
6966 !! end
6967
6968 !! test
6969 Fostered content in tables: Plain text
6970 !! options
6971 parsoid=wt2html,html2html
6972 !! wikitext
6973 {|
6974 |-
6975 a
6976 |}
6977 !! html/php
6978 <table>
6979
6980 a
6981 </table>
6982
6983 !! html/php+tidy
6984
6985
6986 a
6987 <table></table>
6988 !! html/parsoid
6989 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>a</p><table>
6990 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
6991
6992 </tr></tbody></table>
6993 !! end
6994
6995 !! test
6996 Fostered content in tables: Lists
6997 !! options
6998 parsoid=wt2html,html2html
6999 !! wikitext
7000 {|
7001 |-
7002 *a
7003 |}
7004 !! html/php
7005 <table>
7006
7007 <ul><li>a</li></ul>
7008 </table>
7009
7010 !! html/php+tidy
7011 <ul><li>a</li></ul><table>
7012
7013
7014 </table>
7015 !! html/parsoid
7016 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7017 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7018
7019 </tr></tbody></table>
7020 !! end
7021
7022 !! test
7023 Template generated table cell with attributes
7024 !! wikitext
7025 {|
7026 |-
7027 {{table_attribs_4}} || a || b
7028 |}
7029 !! html/php+tidy
7030 <table>
7031
7032 <tbody><tr>
7033 <td style="background-color:#DC241f;" width="10px"> </td>
7034 <td> a </td>
7035 <td> b
7036 </td></tr></tbody></table>
7037 !! html/parsoid
7038 <table>
7039 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7040 <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>
7041 !! end
7042
7043 !! test
7044 Parsoid: Round-trip tables directly followed by content (T53219)
7045 !! options
7046 parsoid=wt2html,wt2wt
7047 !! wikitext
7048 {|
7049 |foo
7050 |} bar
7051
7052 {|
7053 |baz
7054 |}<b>quux</b>
7055 !! html+tidy
7056 <table>
7057 <tbody><tr>
7058 <td>foo
7059 </td></tr></tbody></table><p> bar
7060 </p><table>
7061 <tbody><tr>
7062 <td>baz
7063 </td></tr></tbody></table><p><b>quux</b>
7064 </p>
7065 !! end
7066
7067 !! test
7068 Parsoid: Default to a newline after tables in new content (T53219)
7069 !! options
7070 parsoid=html2wt
7071 !! html/parsoid
7072 <table><tbody>
7073 <tr><td>foo</td></tr></tbody></table> bar
7074 <table><tbody>
7075 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7076 !! wikitext
7077 {|
7078 |foo
7079 |}
7080 <nowiki> </nowiki>bar
7081 {|
7082 |baz
7083 |}
7084 '''quux'''
7085 !! end
7086
7087 !! test
7088 Parsoid: newline inducing block nodes don't suppress <nowiki>
7089 !! options
7090 parsoid=html2wt
7091 !! html/parsoid
7092 a<h1>foo</h1>
7093 !! wikitext
7094 <nowiki> </nowiki>a
7095
7096 = foo =
7097 !! end
7098
7099 !! test
7100 Parsoid: Row-syntax table headings followed by comment & table cells
7101 !! options
7102 parsoid=wt2html,wt2wt
7103 !! wikitext
7104 {|
7105 ! foo || bar
7106 <!-- foo --> || baz || quux
7107 |}
7108 !! html/php
7109 <table>
7110 <tr>
7111 <th> foo </th>
7112 <th> bar
7113 </th>
7114 <td> baz </td>
7115 <td> quux
7116 </td></tr></table>
7117
7118 !! html/parsoid
7119 <table>
7120 <tbody><tr><th> foo </th><th> bar
7121 <!-- foo --> </th><td> baz </td><td> quux</td></tr>
7122 </tbody></table>
7123 !! end
7124
7125 !!test
7126 Parsoid: Recover better from broken table attributes
7127 !!options
7128 parsoid=wt2html
7129 !!wikitext
7130 {| class="foo
7131 | class="bar" |
7132 foo
7133 |}
7134 !!html/php+tidy
7135 <table class="foo">
7136 <tbody><tr>
7137 <td class="bar">
7138 <p>foo
7139 </p>
7140 </td></tr></tbody></table>
7141 !!html/parsoid
7142 <table class="foo">
7143 <tr>
7144 <td class="bar">
7145 <p>foo</p></td></tr>
7146 </tbody></table>
7147 !!end
7148
7149 !! test
7150 Tables: Digest broken attributes on table and tr tag
7151 !! options
7152 parsoid=wt2html
7153 !! wikitext
7154 {| || |} ++
7155 |- || || ++ --
7156 |- > [
7157 |}
7158 !! html
7159 <table>
7160 <tbody>
7161 <tr class='mw-empty-elt'></tr>
7162 <tr class='mw-empty-elt'></tr>
7163 </tbody></table>
7164 !! end
7165
7166 # T137406: Whitespace in the HTML
7167 !! test
7168 1. Generate correct wikitext for tables with thead/tbody/tfoot
7169 !! options
7170 parsoid=html2wt
7171 !! html/parsoid
7172 <table>
7173 <caption>Test</caption>
7174 <thead>
7175 <tr>
7176 <th>Month</th>
7177 <th>Savings</th>
7178 </tr>
7179 </thead>
7180 <tbody>
7181 <tr>
7182 <td>January</td>
7183 <td>$100</td>
7184 </tr>
7185 <tr>
7186 <td>February</td>
7187 <td>$80</td>
7188 </tr>
7189 </tbody>
7190 <tfoot>
7191 <tr>
7192 <td>Sum</td>
7193 <td>$180</td>
7194 </tr>
7195 </tfoot>
7196 </table>
7197 !! wikitext
7198 {|
7199 |+Test
7200 !Month
7201 !Savings
7202 |-
7203 |January
7204 |$100
7205 |-
7206 |February
7207 |$80
7208 |-
7209 |Sum
7210 |$180
7211 |}
7212 !! html/php+tidy
7213 <table>
7214 <caption>Test
7215 </caption>
7216 <tbody><tr>
7217 <th>Month
7218 </th>
7219 <th>Savings
7220 </th></tr>
7221 <tr>
7222 <td>January
7223 </td>
7224 <td>$100
7225 </td></tr>
7226 <tr>
7227 <td>February
7228 </td>
7229 <td>$80
7230 </td></tr>
7231 <tr>
7232 <td>Sum
7233 </td>
7234 <td>$180
7235 </td></tr></tbody></table>
7236 !! end
7237
7238 # T137406: No whitespace in the HTML
7239 !! test
7240 2. Generate correct wikitext for tables with thead/tbody/tfoot
7241 !! options
7242 parsoid=html2wt
7243 !! html/parsoid
7244 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7245 !! wikitext
7246 {|
7247 !heading
7248 |-
7249 |foo
7250 |}
7251 !! end
7252
7253 !! test
7254 Testing serialization after deletion in references
7255 !! options
7256 parsoid={
7257 "modes": ["wt2wt"],
7258 "changes": [
7259 ["#x", "remove"]
7260 ]
7261 }
7262 !! wikitext
7263 hi <ref><div id="x">ho</div></ref>
7264
7265 <references />
7266 !! wikitext/edited
7267 hi <ref></ref>
7268
7269 <references />
7270 !! end
7271
7272 !!test
7273 Testing serialization after deletion of table cells
7274 !!options
7275 parsoid={
7276 "modes": ["wt2wt", "selser"],
7277 "changes": [
7278 ["#x", "remove"]
7279 ]
7280 }
7281 !!wikitext
7282 {|
7283 !h1 !!h2 !!h3
7284 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
7285 |}
7286 !! wikitext/edited
7287 {|
7288 !h1 !!h2 !!h3
7289 |c2 |||c3
7290 |}
7291 !!end
7292
7293 !! test
7294 Testing selser after addition of new row before first row (T125419)
7295 !! options
7296 parsoid={
7297 "modes": ["wt2wt", "selser"],
7298 "changes": [
7299 [ "tr", "before", "<tr><td>X</td></tr>" ]
7300 ]
7301 }
7302 !! wikitext
7303 {|
7304 |a
7305 |}
7306 !! wikitext/edited
7307 {|
7308 |X
7309 |-
7310 |a
7311 |}
7312 !! end
7313
7314 !! test
7315 Serialize new table rows in a HTML table using HTML tags
7316 !! options
7317 parsoid={
7318 "modes": ["wt2wt", "selser"],
7319 "changes": [
7320 [ "tr", "before", "<tr><td>X</td></tr>" ]
7321 ]
7322 }
7323 !! wikitext
7324 <table><tr><td>a</td></tr></table>
7325 !! wikitext/edited
7326 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
7327 !! end
7328
7329 !! test
7330 Serialize new table cells in a HTML row using HTML tags
7331 !! options
7332 parsoid={
7333 "modes": ["wt2wt", "selser"],
7334 "changes": [
7335 [ "td", "before", "<td>X</td>" ]
7336 ]
7337 }
7338 !! wikitext
7339 <table><tr><td>a</td></tr></table>
7340 !! wikitext/edited
7341 <table><tr><td>X</td><td>a</td></tr></table>
7342 !! end
7343
7344 !! test
7345 Wikitext tables can be nested inside HTML tables
7346 !! options
7347 parsoid=html2wt
7348 !! html
7349 <table data-parsoid='{"stx":"html"}'>
7350 <tr><td>
7351 <table>
7352 <tr><td>foo</td></tr>
7353 </table>
7354 </td></tr>
7355 </table>
7356 !! wikitext
7357 <table>
7358 <tr><td>
7359 {|
7360 |foo
7361 |}
7362 </td></tr>
7363 </table>
7364 !! end
7365
7366 !! test
7367 Serialize wikitext list items as HTML list items when embedded in a HTML list
7368 !! options
7369 parsoid=html2wt
7370 !! html
7371 <ul data-parsoid='{"stx": "html"}'>
7372 <li data-parsoid='{}'>a</li>
7373 <li>b</li>
7374 </ul>
7375 !! wikitext
7376 <ul>
7377 <li>a</li>
7378 <li>b</li>
7379 </ul>
7380 !! end
7381
7382 # SSS FIXME: Is this actually a good thing given the
7383 # odd nested list output that is generated by MW?
7384 # <ul><li>foo<ul>..</ul></li></ul> instead of
7385 # <ul><li>foo</li><ul>..</ul></ul>
7386 !! test
7387 Wikitext lists can be nested inside HTML lists
7388 !! options
7389 parsoid=html2wt
7390 !! html
7391 <ul data-parsoid='{"stx": "html"}'>
7392 <li data-parsoid='{"stx": "html"}'>a
7393 <ul><li>b</li></ul>
7394 </li>
7395 </ul>
7396
7397 <ul data-parsoid='{"stx": "html"}'>
7398 <li>x
7399 <ul><li>y</li></ul>
7400 </li>
7401 </ul>
7402 !! wikitext
7403 <ul>
7404 <li>a
7405 * b
7406 </li>
7407 </ul>
7408
7409 <ul>
7410 <li>x
7411 * y
7412 </li>
7413 </ul>
7414 !! end
7415
7416 ###
7417 ### Internal links
7418 ###
7419 !! test
7420 Plain link, capitalized
7421 !! wikitext
7422 [[Main Page]]
7423 !! html
7424 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7425 </p>
7426 !! end
7427
7428 !! test
7429 Plain link, uncapitalized
7430 !! wikitext
7431 [[main Page]]
7432 !! html
7433 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7434 </p>
7435 !! end
7436
7437 !! test
7438 Piped link
7439 !! wikitext
7440 [[Main Page|The Main Page]]
7441 !! html
7442 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7443 </p>
7444 !! end
7445
7446 !! test
7447 Piped link with comment in link text
7448 !! wikitext
7449 [[Main Page|The Main<!--front--> Page]]
7450 !! html
7451 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7452 </p>
7453 !! end
7454
7455 !! test
7456 Piped link with multiple pipe characters in link text
7457 !! wikitext
7458 [[Main Page||The|Main|Page|]]
7459 !! html/php
7460 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7461 </p>
7462 !! html/parsoid
7463 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7464 !! end
7465
7466 !! test
7467 Piped link with no link text
7468 !! wikitext
7469 [[Thomas Bek (bishop of St David's)|]]
7470 !! html/php
7471 <p>[[Thomas Bek (bishop of St David's)|]]
7472 </p>
7473 !! html/parsoid
7474 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7475 !! end
7476
7477 !! test
7478 Piped link with empty link text
7479 !! wikitext
7480 [[Main Page|<nowiki/>]] - empty nowiki
7481 [[Main Page| ]] - empty space
7482 [[Main Page|&nbsp;]] - empty non breaking space
7483 !! html/php
7484 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7485 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7486 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7487 </p>
7488 !! html/parsoid
7489 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7490 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7491 <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>
7492 !! end
7493
7494 !! test
7495 Broken link
7496 !! wikitext
7497 [[Zigzagzogzagzig]]
7498 !! html
7499 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7500 </p>
7501 !! end
7502
7503 !! test
7504 Broken link with fragment
7505 !! wikitext
7506 [[Zigzagzogzagzig#zug]]
7507 !! html
7508 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7509 </p>
7510 !! end
7511
7512 !! test
7513 Special page link with fragment
7514 !! wikitext
7515 [[Special:Version#anchor]]
7516 !! html
7517 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7518 </p>
7519 !! end
7520
7521 !! test
7522 Nonexistent special page link with fragment
7523 !! wikitext
7524 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7525 !! html
7526 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7527 </p>
7528 !! end
7529
7530 !! test
7531 Link with prefix
7532 !! wikitext
7533 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7534 !! html
7535 <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>
7536 </p>
7537 !! end
7538
7539 !! test
7540 Link with suffix
7541 !! wikitext
7542 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7543 !! html
7544 <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>!!!
7545 </p>
7546 !! end
7547
7548 !! article
7549 prefixed article
7550 !! text
7551 Some text
7552 !! endarticle
7553
7554 !! test
7555 T45661: Piped links with identical prefixes
7556 !! wikitext
7557 [[prefixed article|prefixed articles with spaces]]
7558
7559 [[prefixed article|prefixed articlesaoeu]]
7560
7561 [[Main Page|Main Page test]]
7562 !! html
7563 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7564 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7565 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7566 </p>
7567 !! end
7568
7569
7570 !! test
7571 Link with HTML entity in suffix / tail
7572 !! wikitext
7573 [[Main Page]]&quot;, [[Main Page]]&#97;
7574 !! html/php
7575 <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;
7576 </p>
7577 !! html/parsoid
7578 <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>
7579 !! end
7580
7581 !! test
7582 Link with 3 brackets
7583 !! wikitext
7584 [[[Main Page]]]
7585 Foo [[[Main Page]]]
7586 !! html
7587 <p>[[[Main Page]]]
7588 Foo [[[Main Page]]]
7589 </p>
7590 !! end
7591
7592 !! test
7593 Link with 4 brackets
7594 !! wikitext
7595 [[[[Main Page]]]]
7596 !! html
7597 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7598 </p>
7599 !! end
7600
7601 !! test
7602 Piped link with 3 brackets
7603 !! wikitext
7604 [[[main page|the main page]]]
7605 !! html
7606 <p>[[[main page|the main page]]]
7607 </p>
7608 !! end
7609
7610 !! test
7611 Piped link with extlink-like text
7612 !! wikitext
7613 [[Main Page|[bar]]]
7614 [[Main Page|This is a [bar]]]
7615 [[Main Page|[bar]]
7616 !! html/php
7617 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7618 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7619 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7620 </p>
7621 !! html/parsoid
7622 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7623 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7624 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7625 !! end
7626
7627 !! test
7628 Link with multiple pipes
7629 !! wikitext
7630 [[Main Page|The|Main|Page]]
7631 !! html
7632 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7633 </p>
7634 !! end
7635
7636 !! test
7637 Anchor containing a #. (T65430)
7638 !! config
7639 wgFragmentMode=[ 'html5', 'legacy' ]
7640 !! wikitext
7641 [[Main Page#And#Link]]
7642 !! html/php
7643 <p><a href="/wiki/Main_Page#And#Link" title="Main Page">Main Page#And#Link</a>
7644 </p>
7645 !! html/parsoid
7646 <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>
7647 !! end
7648
7649 !! test
7650 Link to namespaces
7651 !! wikitext
7652 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7653 !! html
7654 <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>
7655 </p>
7656 !! end
7657
7658 !! test
7659 Link with space in namespace
7660 !! wikitext
7661 [[User talk:Foo bar]]
7662 !! html
7663 <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>
7664 </p>
7665 !! end
7666
7667 !! article
7668 MemoryAlpha:AlphaTest
7669 !! text
7670 This is an article in the MemoryAlpha namespace
7671 (which shadows the memoryalpha interwiki link).
7672 !! endarticle
7673
7674 !! test
7675 Namespace takes precedence over interwiki link (T53680)
7676 !! wikitext
7677 [[MemoryAlpha:AlphaTest]]
7678 !! html
7679 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7680 </p>
7681 !! end
7682
7683 # The previous test doesn't work correctly in html2*, due to not recognizing the
7684 # link as an internal one. This one checks for the correct behavior.
7685 !! test
7686 Link to namespace preferred over interwiki with correct rel attribute
7687 !! options
7688 parsoid=html2wt,html2html
7689 !! html/parsoid
7690 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7691 !! wikitext
7692 [[MemoryAlpha:AlphaTest]]
7693 !! end
7694
7695 !! test
7696 Piped link to namespace
7697 !! wikitext
7698 [[Meta:Disclaimers|The disclaimers]]
7699 !! html
7700 <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>
7701 </p>
7702 !! end
7703
7704 !! test
7705 Link containing }
7706 !! wikitext
7707 [[Usually caused by a typo (oops}]]
7708 !! html
7709 <p>[[Usually caused by a typo (oops}]]
7710 </p>
7711 !! end
7712
7713 !! article
7714 7% Solution
7715 !! text
7716 Just a test of an article title containing a percent.
7717 !! endarticle
7718
7719 !! test
7720 Link containing % (not as a hex sequence)
7721 !! wikitext
7722 [[7% Solution]]
7723 [[7% Solution|7%25 Solution]]
7724 !! html/php
7725 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7726 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7727 </p>
7728 !! html/parsoid
7729 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7730 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7731 !! end
7732
7733 # note that the parsoid HTML is identical to the previous test output,
7734 # so the previous test ensures that the html2wt mode will generate the
7735 # "not as a hex sequence" wikitext.
7736 !! test
7737 Link containing % as a single hex sequence interpreted to char
7738 !! options
7739 parsoid=wt2wt,wt2html,html2html
7740 !! wikitext
7741 [[7%25 Solution]]
7742 [[7%25 Solution|7%25 Solution]]
7743 !! html/php
7744 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7745 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7746 </p>
7747 !! html/parsoid
7748 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7749 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7750 !!end
7751
7752 !! test
7753 Link containing % as a double hex sequence interpreted to hex sequence
7754 !! wikitext
7755 [[7%2525 Solution]]
7756 !! html
7757 <p>[[7%2525 Solution]]
7758 </p>
7759 !!end
7760
7761 ## Example for such a section: == < ==
7762 !! test
7763 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
7764 !! config
7765 wgFragmentMode=[ 'html5', 'legacy' ]
7766 !! wikitext
7767 [[%23%3c]][[%23%3e]]
7768 !! html/php
7769 <p><a href="#&lt;">#&lt;</a><a href="#&gt;">#&gt;</a>
7770 </p>
7771 !! html/parsoid
7772 <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>
7773 !! end
7774
7775 ## Example for such a section: == < ==
7776 !! test
7777 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy)
7778 !! config
7779 wgFragmentMode=[ 'legacy' ]
7780 !! wikitext
7781 [[%23%3c]][[%23%3e]]
7782 !! html/php
7783 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
7784 </p>
7785 !! end
7786
7787 !! test
7788 Link containing "<#" and ">#" as a hex sequences
7789 !! wikitext
7790 [[%3c%23]][[%3e%23]]
7791 !! html
7792 <p>[[%3c%23]][[%3e%23]]
7793 </p>
7794 !! end
7795
7796 !! test
7797 Link containing an equals sign
7798 !! wikitext
7799 [[Special:BookSources/isbn=4-00-026157-6]]
7800 !! html/php
7801 <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>
7802 </p>
7803 !! html/parsoid
7804 <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>
7805 !! end
7806
7807 !! article
7808 Foo~bar
7809 !! text
7810 Just a test of an article title containing a tilde.
7811 !! endarticle
7812
7813 # note that links containing signatures, like [[Foo~~~~]], are
7814 # massaged by the pre-save transform (PST) and so the tildes are never
7815 # seen by the parser.
7816 !! test
7817 Link containing a tilde
7818 !! wikitext
7819 [[Foo~bar]]
7820 !! html/php
7821 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
7822 </p>
7823 !! html/parsoid
7824 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
7825 !! end
7826
7827 !! test
7828 Link containing double-single-quotes '' (T6598)
7829 !! wikitext
7830 [[Lista d''e paise d''o munno]]
7831 !! html/php
7832 <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>
7833 </p>
7834 !! html/parsoid
7835 <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>
7836 !! end
7837
7838 !! test
7839 Link containing double quotes and spaces
7840 !! wikitext
7841 [[Cool "Gator"]]
7842 !! html/php
7843 <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>
7844 </p>
7845 !! html/parsoid
7846 <p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p>
7847 !! end
7848
7849 !! test
7850 File containing double quotes and spaces
7851 !! wikitext
7852 [[File:Cool "Gator".png]]
7853 !! html/parsoid
7854 <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>
7855 !! end
7856
7857 !! test
7858 Redirect containing double quotes and spaces
7859 !! wikitext
7860 #REDIRECT [[Cool "Gator"]]
7861 !! html/parsoid
7862 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
7863 !! end
7864
7865 !! test
7866 Link containing double-single-quotes '' in text (T6598 sanity check)
7867 !! wikitext
7868 Some [[Link|pretty ''italics'' and stuff]]!
7869 !! html/php
7870 <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>!
7871 </p>
7872 !! html/parsoid
7873 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
7874 !! end
7875
7876 !! test
7877 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
7878 !! wikitext
7879 ''Some [[Link|pretty ''italics'' and stuff]]!''
7880 !! html
7881 <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>
7882 </p>
7883 !! end
7884
7885 !! test
7886 Link with double quotes in title part (literal) and alternate part (interpreted)
7887 !! wikitext
7888 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
7889
7890 [[''Pentecoste'']]
7891
7892 [[''Pentecoste''|Pentecoste]]
7893
7894 [[''Pentecoste''|''Pentecoste'']]
7895 !! html/php
7896 <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>
7897 </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>
7898 </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>
7899 </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>
7900 </p>
7901 !! html/parsoid
7902 <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>
7903 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
7904 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
7905 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
7906 !! end
7907
7908 !! test
7909 Broken image links with HTML captions (T41700)
7910 !! wikitext
7911 [[File:Nonexistent|<script></script>]]
7912 [[File:Nonexistent|100x100px|<script></script>]]
7913 [[File:Nonexistent|&lt;]]
7914 [[File:Nonexistent|a<i>b</i>c]]
7915 !! html/php
7916 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
7917 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
7918 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
7919 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
7920 </p>
7921 !! html/parsoid
7922 <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>
7923 <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>
7924 <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>
7925 <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>
7926 !! end
7927
7928 !! test
7929 Plain link to URL
7930 !! wikitext
7931 [[http://www.example.com]]
7932 !! html/php
7933 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
7934 </p>
7935 !! html/parsoid
7936 <p>[<a rel="mw:ExtLink" href="http://www.example.com"></a>]</p>
7937 !! end
7938
7939 !! test
7940 Plain link to URL with link text
7941 !! wikitext
7942 [[http://www.example.com Link text]]
7943 !! html
7944 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
7945 </p>
7946 !! end
7947
7948 !! test
7949 Plain link to protocol-relative URL
7950 !! wikitext
7951 [[//www.example.com]]
7952 !! html/php
7953 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
7954 </p>
7955 !! html/parsoid
7956 <p>[<a rel="mw:ExtLink" href="//www.example.com"></a>]</p>
7957 !! end
7958
7959 !! test
7960 Plain link to protocol-relative URL with link text
7961 !! wikitext
7962 [[//www.example.com Link text]]
7963 !! html
7964 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
7965 </p>
7966 !! end
7967
7968 !! test
7969 Plain link to page with question mark in title
7970 !! wikitext
7971 [[A?b]]
7972
7973 [[A?b|Baz]]
7974 !! html
7975 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
7976 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
7977 </p>
7978 !! end
7979
7980 # I'm fairly sure the expected result here is wrong.
7981 # We want these to be URL links, not pseudo-pages with URLs for titles....
7982 # However the current output is also pretty screwy.
7983 #
7984 # ----
7985 # I'm changing it to match the current output--it arguably makes more
7986 # sense in the light of the test above. Old expected result was:
7987 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
7988 #</p>
7989 # But I think this test is bordering on "garbage in, garbage out" anyway.
7990 # -- wtm
7991 !! test
7992 Piped link to URL
7993 !! wikitext
7994 Piped link to URL: [[http://www.example.com|an example URL]]
7995 !! html/php
7996 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
7997 </p>
7998 !! html/parsoid
7999 <p>Piped link to URL: [<a rel="mw:ExtLink" 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>
8000 !! end
8001
8002 !! test
8003 Plain link in template argument
8004 !! options
8005 parsoid=wt2html
8006 !! wikitext
8007 {{echo|[http://www.example.com |123]}}
8008
8009 {{echo|[[http://www.example.com |123]]}}
8010
8011 {{echo|[[http://www.example.com |123]}}
8012
8013 {{echo|[http://www.example.com |123]]}}
8014 !! html/php
8015 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8016 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8017 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8018 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8019 </p>
8020 !! html/parsoid
8021 <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" href="http://www.example.com">http://www.example.com</a> </p>
8022
8023 <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" href="http://www.example.com">|123</a>]</p>
8024
8025 <p>{{echo|[<a rel="mw:ExtLink" href="http://www.example.com" data-parsoid='{"targetOff":114,"contentOffsets":[114,118],"dsr":[90,119,24,1]}'>|123</a>}}</p>
8026
8027 <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" href="http://www.example.com">http://www.example.com</a> </p>
8028 !! end
8029
8030 !! test
8031 T2002: [[page|http://url/]] should link to page, not http://url/
8032 !! wikitext
8033 [[Main Page|http://url/]]
8034 !! html/php
8035 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8036 </p>
8037 !! html/parsoid
8038 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8039 !! end
8040
8041 # Parsoid does not mark self-links, by design.
8042 !! test
8043 T2337: Escaped self-links should be bold
8044 !! options
8045 title=[[Bug462]]
8046 !! wikitext
8047 [[Bu&#103;462]] [[Bug462]]
8048 !! html/php+tidy
8049 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8050 </p>
8051 !! html/parsoid
8052 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8053 !! end
8054
8055 !! test
8056 Self-link to section should not be bold
8057 !! options
8058 title=[[Main Page]]
8059 !! wikitext
8060 [[Main Page#section]]
8061 !! html
8062 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8063 </p>
8064 !! end
8065
8066 !! article
8067 00
8068 !! text
8069 This is 00.
8070 !! endarticle
8071
8072 !!test
8073 Self-link to numeric title
8074 !!options
8075 title=[[0]]
8076 !! wikitext
8077 [[0]]
8078 !! html
8079 <p><a class="mw-selflink selflink">0</a>
8080 </p>
8081 !!end
8082
8083 !!test
8084 Link to numeric-equivalent title
8085 !!options
8086 title=[[0]]
8087 !! wikitext
8088 [[00]]
8089 !! html
8090 <p><a href="/wiki/00" title="00">00</a>
8091 </p>
8092 !!end
8093
8094 !! test
8095 <nowiki> inside a link
8096 !! wikitext
8097 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8098 !! html
8099 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8100 </p>
8101 !! end
8102
8103 !! test
8104 Non-breaking spaces in title
8105 !! wikitext
8106 [[&nbsp; Main &nbsp; Page &nbsp;]]
8107 !! html
8108 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8109 </p>
8110 !!end
8111
8112 # Add new article for the test below so that it doesn't red-link
8113 !! article
8114 Foo bar baz
8115 !! text
8116 boo
8117 !! endarticle
8118
8119 !! test
8120 Multiple spaces in titles should normalize to a single underscore
8121 !! options
8122 parsoid=wt2html,wt2wt
8123 !! wikitext
8124 [[Foo bar baz|x]]
8125 [[Foo bar baz|x]]
8126 [[Foo bar baz|x]]
8127 !! html/php
8128 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8129 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8130 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8131 </p>
8132 !! html/parsoid
8133 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8134 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8135 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8136 </p>
8137 !! end
8138
8139 !! test
8140 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8141 !! options
8142 language=ca
8143 !! wikitext
8144 '''[[Main Page]]'''
8145 !! html
8146 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8147 </p>
8148 !! end
8149
8150 !! test
8151 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8152 !! options
8153 language=ca
8154 !! wikitext
8155 ''[[Main Page]]''
8156 !! html
8157 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8158 </p>
8159 !! end
8160
8161 !! test
8162 Internal link with en linktrail: no apostrophes (T29473)
8163 !! options
8164 language=en
8165 !! wikitext
8166 [[Something]]'nice
8167 !! html
8168 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8169 </p>
8170 !! end
8171
8172 !! test
8173 Internal link with ca linktrail with apostrophes (T29473)
8174 !! options
8175 language=ca
8176 !! wikitext
8177 [[Something]]'nice
8178 !! html
8179 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8180 </p>
8181 !! end
8182
8183 !! test
8184 Internal link with kaa linktrail with apostrophes (T29473)
8185 !! options
8186 language=kaa
8187 !! wikitext
8188 [[Something]]'nice
8189 !! html
8190 <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>
8191 </p>
8192 !! end
8193
8194 !! test
8195 Link with multiple ":" in a subpage-supporting namespace (T65636)
8196 !! wikitext
8197 [[User:Foo/Test/63636:Bar|Test]]
8198 !! html/php
8199 <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>
8200 </p>
8201 !! html/parsoid
8202 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8203 !! end
8204
8205 ## Mainly a sanity check for Parsoid
8206 !! test
8207 Handle title parsing for subpages
8208 !! options
8209 title=[[/123123]]
8210 subpage
8211 !! wikitext
8212 123
8213 !! html/php
8214 <p>123
8215 </p>
8216 !! html/parsoid
8217 <p>123</p>
8218 !! end
8219
8220 !! article
8221 User:Test/123
8222 !! text
8223 test 123
8224 !! endarticle
8225
8226 !! test
8227 Link to a subpage from a namespace other than main
8228 !! options
8229 title=[[User:Test]]
8230 subpage
8231 !! wikitext
8232 [[/123]]
8233 !! html/php
8234 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8235 </p>
8236 !! html/parsoid
8237 <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>
8238 !! end
8239
8240 !! test
8241 Ensure that transclusion titles are not url-decoded
8242 !! options
8243 subpage title=[[Test]]
8244 parsoid=wt2html
8245 !! wikitext
8246 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8247 !! html/php
8248 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8249 </p>
8250 !! html/parsoid
8251 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8252 !! end
8253
8254 !! test
8255 Purely hash wikilink
8256 !! options
8257 title=[[User:Test/123]]
8258 subpage
8259 !! wikitext
8260 [[#a|b]]
8261 !! html/php
8262 <p><a href="#a">b</a>
8263 </p>
8264 !! html/parsoid
8265 <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>
8266 !! end
8267
8268 !! test
8269 Serialization of purely hash wikilink
8270 !! options
8271 title=[[User:Test/123]]
8272 subpage
8273 parsoid=html2wt
8274 !! html/parsoid
8275 <p><a href="#a">[[</a></p>
8276 !! wikitext
8277 [[#a|<nowiki>[[</nowiki>]]
8278 !! html/php
8279 <p><a href="#a">[[</a>
8280 </p>
8281 !! end
8282
8283 !! test
8284 1. Interaction of linktrail and template encapsulation
8285 !! wikitext
8286 {{echo|[[Foo]]}}l
8287 !! html/parsoid
8288 <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>
8289 !! end
8290
8291 !! test
8292 2. Interaction of linktrail and template encapsulation
8293 !! options
8294 parsoid
8295 !! wikitext
8296 {{echo|Some [[Fool]]}}s
8297 !! html
8298 <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>
8299 !! end
8300
8301 !! test
8302 3. Interaction of linktrail and template encapsulation
8303 !! options
8304 parsoid
8305 !! wikitext
8306 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8307 !! html
8308 <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>
8309 !! end
8310
8311 !! article
8312 Söfnuður
8313 !! text
8314 Test.
8315 !! endarticle
8316
8317 !! test
8318 Internal link with is link prefix
8319 !! options
8320 language=is
8321 !! wikitext
8322 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8323 !! html
8324 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8325 </p>
8326 !! end
8327
8328 !! article
8329 Mótmælendatrú
8330 !! text
8331 Test.
8332 !! endarticle
8333
8334 !! test
8335 Internal link with is link trail and link prefix
8336 !! options
8337 language=is
8338 !! wikitext
8339 [[mótmælendatrú|xxx]]ar
8340 [[mótmælendatrú]]ar
8341 mótmælenda[[söfnuður]]
8342 mótmælenda[[söfnuður|söfnuðir]]
8343 mótmælenda[[söfnuður|söfnuðir]]xxx
8344 !! html
8345 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8346 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8347 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8348 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8349 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8350 </p>
8351 !! end
8352
8353 !! test
8354 Parsoid link trail escaping
8355 !! options
8356 parsoid=html2wt,html2html
8357 !! html/parsoid
8358 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8359 !! wikitext
8360 [[apple]]<nowiki/>s
8361 !! end
8362
8363 !! test
8364 Parsoid link prefix escaping
8365 !! options
8366 language=is
8367 parsoid=html2wt,html2html
8368 !! html/parsoid
8369 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8370 !! wikitext
8371 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8372 !! end
8373
8374 !! test
8375 Parsoid link bracket escaping
8376 !! options
8377 parsoid=html2wt,html2html
8378 !! html/parsoid
8379 <p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
8380 <p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
8381 <p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
8382 <p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
8383 <p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
8384 <p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
8385 !! wikitext
8386 [[Test]]
8387
8388 [<nowiki/>[[Test]]]
8389
8390 [[[[Test]]]]
8391
8392 [[[<nowiki/>[[Test]]]]]
8393
8394 [[[[[[Test]]]]]]
8395
8396 [[[[[<nowiki/>[[Test]]]]]]]
8397 !! end
8398
8399 !! test
8400 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8401 !! wikitext
8402 [[Foo| bar]]
8403
8404 [[Foo| ''bar'']]
8405
8406 [http://wp.org foo]
8407
8408 [http://wp.org ''foo'']
8409 !! html
8410 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8411 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8412 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8413 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8414 </p>
8415 !! end
8416
8417 !! test
8418 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8419 !! wikitext
8420 [[Foo|{{echo|a}} b {{echo|c}}]]
8421 !! html/parsoid
8422 <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>
8423 !! end
8424
8425 !! test
8426 Link with angle bracket after anchor
8427 !! config
8428 wgFragmentMode=[ 'html5', 'legacy' ]
8429 !! wikitext
8430 [[Foo#<bar>]]
8431 !! html/php
8432 <p><a href="/wiki/Foo#&lt;bar&gt;" title="Foo">Foo#&lt;bar&gt;</a>
8433 </p>
8434 !! html/parsoid
8435 <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>
8436 !! end
8437
8438 !! test
8439 Link with angle bracket after anchor (legacy)
8440 !! config
8441 wgFragmentMode=[ 'legacy' ]
8442 !! wikitext
8443 [[Foo#<bar>]]
8444 !! html/php
8445 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8446 </p>
8447 !! end
8448
8449 ###
8450 ### Interwiki links (see maintenance/interwiki.sql)
8451 ###
8452
8453 !! test
8454 Inline interwiki link
8455 !! options
8456 parsoid=wt2html,wt2wt,html2html
8457 !! wikitext
8458 [[MeatBall:SoftSecurity]]
8459 !! html/php
8460 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8461 </p>
8462 !! html/parsoid
8463 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8464 !! end
8465
8466 !! test
8467 Inline interwiki link with empty title (T4372)
8468 !! options
8469 parsoid=wt2html,wt2wt,html2html
8470 !! wikitext
8471 [[MeatBall:]]
8472 !! html/php
8473 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8474 </p>
8475 !! html/parsoid
8476 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8477 !! end
8478
8479 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8480 !! test
8481 Interwiki link encoding conversion (T3636)
8482 !! options
8483 parsoid=wt2html,wt2wt
8484 !! wikitext
8485 *[[Wikipedia:ro:Olteni&#0355;a]]
8486 *[[Wikipedia:ro:Olteni&#355;a]]
8487 !! html
8488 <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>
8489 <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>
8490
8491 !! html/php+tidy
8492 <ul>
8493 <li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
8494 <li><a href="http://en.wikipedia.org/wiki/ro:Olteni%C5%A3a" class="extiw" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
8495 </ul>
8496 !! html/parsoid
8497 <ul>
8498 <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>
8499 <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>
8500 </ul>
8501 !! end
8502
8503 !! test
8504 Interwiki link with fragment (T4130)
8505 !! wikitext
8506 [[MeatBall:SoftSecurity#foo]]
8507 !! html
8508 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8509 </p>
8510 !! end
8511
8512 !! test
8513 Link scenarios with escaped fragments
8514 !! config
8515 wgFragmentMode=[ 'html5', 'legacy' ]
8516 !! wikitext
8517 [[#Is this great?]]
8518 [[Foo#Is this great?]]
8519 [[meatball:Foo#Is this great?]]
8520 !! html/php
8521 <p><a href="#Is_this_great?">#Is this great?</a>
8522 <a href="/wiki/Foo#Is_this_great?" title="Foo">Foo#Is this great?</a>
8523 <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>
8524 </p>
8525 !! html/parsoid
8526 <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>
8527 <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>
8528 <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>
8529 !! end
8530
8531 !! test
8532 Link scenarios with escaped fragments (legacy)
8533 !! config
8534 wgFragmentMode=[ 'legacy' ]
8535 !! wikitext
8536 [[#Is this great?]]
8537 [[Foo#Is this great?]]
8538 [[meatball:Foo#Is this great?]]
8539 !! html/php
8540 <p><a href="#Is_this_great.3F">#Is this great?</a>
8541 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8542 <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>
8543 </p>
8544 !! end
8545
8546 # Ideally the wikipedia: prefix here should be proto-relative too
8547 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8548 # define the 'en' prefix, and originally the test used 'wikipedia',
8549 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8550 # article.
8551 !! test
8552 Different interwiki prefixes mapping to the same URL
8553 !! wikitext
8554 [[:en:Foo]]
8555
8556 [[:en:Foo|Foo]]
8557
8558 [[wikipedia:Foo]]
8559
8560 [[:wikipedia:Foo|Foo]]
8561
8562 [[wikipedia:en:Foo]]
8563
8564 [[:wikipedia:en:Foo]]
8565
8566 [[ wikiPEdia :Foo]]
8567 !! html/parsoid
8568 <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>
8569
8570 <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>
8571
8572 <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>
8573
8574 <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>
8575
8576 <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>
8577
8578 <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>
8579
8580 <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>
8581 !! end
8582
8583 !! test
8584 Interwiki links that cannot be represented in wiki syntax
8585 !! wikitext
8586 [[meatball:ok]]
8587 [[meatball:ok#foo|ok with fragment]]
8588 [[meatball:ok_as_well?|ok ending with ? mark]]
8589 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8590 [http://de.wikipedia.org/wiki/#foo is just fragment]
8591
8592 !! html/php
8593 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8594 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8595 <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>
8596 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8597 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8598 </p>
8599 !! html/parsoid
8600 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8601 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8602 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok_as_well?" title="meatball:ok as well?">ok ending with ? mark</a>
8603 <a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8604 <a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8605 !! end
8606
8607 !! test
8608 Interwiki links: trail
8609 !! wikitext
8610 [[wikipedia:Foo|Ba]]r
8611 !! html/php
8612 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8613 </p>
8614 !! html/parsoid
8615 <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>
8616 !! end
8617
8618 !! test
8619 Local interwiki link
8620 !! options
8621 parsoid=wt2html,wt2wt,html2html
8622 !! wikitext
8623 [[local:Template:Foo]]
8624 !! html/php
8625 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8626 </p>
8627 !! html/parsoid
8628 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8629 !! end
8630
8631 # Parsoid does not mark self-links, by design.
8632 !! test
8633 Local interwiki link: self-link to current page
8634 !! options
8635 title=[[Main Page]]
8636 parsoid=wt2html,wt2wt,html2html
8637 !! wikitext
8638 [[local:Main Page]]
8639 !! html/php
8640 <p><a class="mw-selflink selflink">local:Main Page</a>
8641 </p>
8642 !! html/parsoid
8643 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8644 !! end
8645
8646 !! test
8647 Local interwiki link: prefix only (T66167)
8648 !! options
8649 parsoid=wt2html,wt2wt,html2html
8650 !! wikitext
8651 [[local:]]
8652 !! html/php
8653 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8654 </p>
8655 !! html/parsoid
8656 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8657 !! end
8658
8659 !! test
8660 Local interwiki link: with additional interwiki prefix (T63357)
8661 !! options
8662 parsoid=wt2html,wt2wt,html2html
8663 !! wikitext
8664 [[local:meatball:Hello]]
8665 !! html/php
8666 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8667 </p>
8668 !! html/parsoid
8669 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8670 !! end
8671
8672 !! test
8673 Multiple local interwiki link prefixes
8674 !! wikitext
8675 [[local:local:local:local:mi:local:Foo]]
8676 !! options
8677 parsoid=wt2html,wt2wt,html2html
8678 !! html/php
8679 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8680 </p>
8681 !! html/parsoid
8682 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8683 !! end
8684
8685 ###
8686 ### Interlanguage links
8687 ### Language links (so that searching for '### language' matches..)
8688 ###
8689
8690 !! test
8691 Interlanguage link
8692 !! wikitext
8693 Blah blah blah
8694 [[zh:Chinese]]
8695 !! html/php
8696 <p>Blah blah blah
8697 </p>
8698 !! html/parsoid
8699 <p>Blah blah blah</p>
8700 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8701 !! end
8702
8703 ## parsoid html2wt will lose the space variations
8704 !! test
8705 Interlanguage link with spacing
8706 !! options
8707 parsoid=wt2html,wt2wt,html2html
8708 !! wikitext
8709 Blah blah blah
8710 [[ zh : Chinese ]]
8711 !! html/php
8712 <p>Blah blah blah
8713 </p>
8714 !! html/parsoid
8715 <p>Blah blah blah</p>
8716 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8717 !! end
8718
8719 !! test
8720 Double interlanguage link
8721 !! wikitext
8722 Blah blah blah
8723 [[es:Spanish]]
8724 [[zh:Chinese]]
8725 !! html/php
8726 <p>Blah blah blah
8727 </p>
8728 !! html/parsoid
8729 <p>Blah blah blah</p>
8730 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8731 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8732 !! end
8733
8734 ## parsoid html2wt will lose the space variations
8735 !! test
8736 Interlanguage link variations
8737 !! options
8738 parsoid=wt2html,wt2wt,html2html
8739 !! wikitext
8740 Blah blah blah
8741 [[ es :Spanish]]
8742 [[ ZH :Chinese]]
8743 [[es:Foo_bar]]
8744 !! html/php
8745 <p>Blah blah blah
8746 </p>
8747 !! html/parsoid
8748 <p>Blah blah blah</p>
8749 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
8750 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
8751 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
8752 !! end
8753
8754 !! test
8755 Escaping of interlanguage links (T129218, T156308)
8756 !! wikitext
8757 Blah blah blah
8758 [[:es:Spanish]]
8759 [[ : zh : Chinese ]]
8760 !! html/php
8761 <p>Blah blah blah
8762 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8763 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
8764 </p>
8765 !! html/parsoid
8766 <p>Blah blah blah
8767 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8768 <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
8769 !! end
8770
8771 !! test
8772 Multiple colons escaping interlanguage links
8773 !! options
8774 parsoid=wt2html
8775 !! wikitext
8776 [[:es:Spanish]]
8777 [[::es:Spanish]]
8778 [[:::es:Spanish]]
8779 !! html/php
8780 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8781 [[::es:Spanish]]
8782 [[:::es:Spanish]]
8783 </p>
8784 !! html/parsoid
8785 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8786 [[::es:Spanish]]
8787 [[:::es:Spanish]]</p>
8788 !! end
8789
8790 ## parsoid html2wt will normalize the space to _
8791 !! test
8792 Space and question mark encoding in interlanguage links (T95473)
8793 !! options
8794 parsoid=wt2html,wt2wt,html2html
8795 !! wikitext
8796 Blah blah blah
8797 [[es:Foo bar?]]
8798 !! html/php
8799 <p>Blah blah blah
8800 </p>
8801 !! html/parsoid
8802 <p>Blah blah blah</p>
8803 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
8804 !! end
8805
8806 !! test
8807 Interlanguage link, with prefix links
8808 !! options
8809 language=ln
8810 !! wikitext
8811 Blah blah blah
8812 [[zh:Chinese]]
8813 !! html/php
8814 <p>Blah blah blah
8815 </p>
8816 !! html/parsoid
8817 <p>Blah blah blah</p>
8818 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8819 !! end
8820
8821 !! test
8822 Double interlanguage link, with prefix links (T10897)
8823 !! options
8824 language=ln
8825 !! wikitext
8826 Blah blah blah
8827 [[es:Spanish]]
8828 [[zh:Chinese]]
8829 !! html/php
8830 <p>Blah blah blah
8831 </p>
8832 !! html/parsoid
8833 <p>Blah blah blah</p>
8834 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8835 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8836 !! end
8837
8838 !! test
8839 "Extra" interlanguage links (T34189 / gerrit 111390)
8840 !! wikitext
8841 Blah blah blah
8842 [[mul:Article]]
8843 !! html/php
8844 <p>Blah blah blah
8845 </p>
8846 !! html/parsoid
8847 <p>Blah blah blah</p>
8848 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
8849 !! end
8850
8851 ## PHP parser tests script needs an update
8852 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8853 !! test
8854 Language links render as inline links if $wgInterwikiMagic=false
8855 !! options
8856 wgInterwikiMagic=false
8857 parsoid=wt2html,wt2wt,html2html
8858 !! wikitext
8859 Blah blah blah
8860 [[zh:Chinese]]
8861 !! html/parsoid
8862 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
8863 !! end
8864
8865 ## PHP parser tests script needs an update
8866 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8867 !! test
8868 Language links render as inline links in the Talk namespace
8869 !! options
8870 title=Talk:Foo
8871 parsoid=wt2html,wt2wt,html2html
8872 !! wikitext
8873 Blah blah blah
8874 [[zh:Chinese]]
8875 !! html/parsoid
8876 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
8877 !! end
8878
8879 !! test
8880 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
8881 !! options
8882 language=ln
8883 !! wikitext
8884 [[WW&nbsp;II]]
8885 !! html
8886 <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>
8887 </p>
8888 !! end
8889
8890 !! test
8891 Parsoid T55221: Wikilinks should be properly entity-escaped
8892 !! options
8893 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
8894 !! html/parsoid
8895 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
8896 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
8897 !! wikitext
8898 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
8899
8900 He&amp;nbsp;llo He&amp;nbsp;llo
8901 !! html/php
8902 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
8903 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
8904 </p>
8905 !! end
8906
8907 # html2wt will fail because of title normalization without data-parsoid
8908 !! test
8909 Parsoid: handle constructor well
8910 !! options
8911 parsoid=wt2html,wt2wt
8912 !! wikitext
8913 [[constructor]]
8914
8915 [[constructor:foo]]
8916 !! html/php
8917 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
8918 </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>
8919 </p>
8920 !! html/parsoid
8921 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
8922
8923 <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>
8924 !! end
8925
8926 !! article
8927 ko:
8928 !! text
8929 Test.
8930 !! endarticle
8931
8932 # Note that `ko` isn't a known interlanguage prefix
8933 !! test
8934 Parsoid: recognize interlanguage links without a target page
8935 !! options
8936 ill
8937 !! wikitext
8938 [[es:]]
8939
8940 [[ko:]]
8941 !! html/php
8942 es:
8943 !! html/parsoid
8944 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
8945
8946 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
8947 !! end
8948
8949 # Note that `ko` isn't a known interwiki prefix
8950 !! test
8951 Parsoid: recognize interwiki links without a target page
8952 !! options
8953 parsoid=wt2html,wt2wt,html2html
8954 !! wikitext
8955 [[:es:]]
8956
8957 [[:ko:]]
8958 !! html/php
8959 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
8960 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
8961 </p>
8962 !! html/parsoid
8963 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
8964 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
8965 !! end
8966
8967 !! test
8968 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
8969 !! wikitext
8970 [[mi:Foo]]
8971 !! html/php
8972 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
8973 </p>
8974 !! html/parsoid
8975 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
8976 !! end
8977
8978 !! test
8979 Interlanguage link with preceding local interwiki link (T70085)
8980 !! options
8981 parsoid=wt2html,wt2wt,html2html
8982 !! wikitext
8983 Blah blah blah
8984 [[local:es:Spanish]]
8985 !! html/php
8986 <p>Blah blah blah
8987 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
8988 </p>
8989 !! html/parsoid
8990 <p>Blah blah blah
8991 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
8992 !! end
8993
8994 !! test
8995 Looks like an interlanguage link, but is actually a local interwiki
8996 !! options
8997 parsoid=wt2html,wt2wt,html2html
8998 !! wikitext
8999 Blah blah blah
9000 [[mi:Template:Foo]]
9001 !! html/php
9002 <p>Blah blah blah
9003 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9004 </p>
9005 !! html/parsoid
9006 <p>Blah blah blah
9007 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9008 !! end
9009
9010 ###
9011 ### Redirects, Parsoid-only
9012 ###
9013
9014 !! test
9015 1. Simple redirect to page
9016 !! wikitext
9017 #REDIRECT [[Main Page]]
9018 !! html/parsoid
9019 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9020 !! end
9021
9022 !! test
9023 2. Other redirect variants
9024 !! wikitext
9025 #REDIRECT [[Main_Page]]
9026 !! html/parsoid
9027 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9028 !! end
9029
9030 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9031 # This tests the Parsoid bail-out code.
9032 !! test
9033 3. Other redirect variants
9034 !! options
9035 parsoid=wt2html
9036 !! wikitext
9037 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9038 !! html/parsoid
9039 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
9040 !! end
9041
9042 !! test
9043 4. Redirect to a templated destination
9044 !! wikitext
9045 #REDIRECT [[{{echo|Foo}}bar]]
9046 !! html/parsoid
9047 <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"}]]}'/>
9048 !! end
9049
9050 !! test
9051 Empty redirect
9052 !! options
9053 parsoid=wt2html,wt2wt
9054 !! wikitext
9055 #REDIRECT [[]]
9056 !! html/parsoid
9057 <ol>
9058 <li>REDIRECT [[]]</li></ol>
9059 !! end
9060
9061 !! test
9062 Optional colon in #REDIRECT
9063 !! options
9064 # the colon is archaic syntax. we support it for wt2html, but we
9065 # don't care that it roundtrips back to the modern syntax.
9066 parsoid=wt2html,html2html
9067 !! wikitext
9068 #REDIRECT:[[Main Page]]
9069 !! html/parsoid
9070 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9071 !! end
9072
9073 !! test
9074 Whitespace in #REDIRECT with optional colon
9075 !! options
9076 # the colon and gratuitous whitespace is archaic syntax. we support
9077 # it for wt2html, but we don't care that it roundtrips back to the
9078 # modern syntax (without extra whitespace)
9079 parsoid=wt2html,html2html
9080 !! wikitext
9081
9082 #REDIRECT
9083 :
9084 [[Main Page]]
9085 !! html/parsoid
9086 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9087 !! end
9088
9089 !! test
9090 Piped link in #REDIRECT
9091 !! options
9092 # content after piped link is ignored. we support this syntax,
9093 # but don't care that the piped link is lost when we roundtrip this.
9094 parsoid=wt2html
9095 !! wikitext
9096 #REDIRECT [[Main Page|bar]]
9097 !! html/parsoid
9098 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9099 !! end
9100
9101 !! test
9102 Redirect to category (T104502)
9103 !! options
9104 parsoid=wt2html,wt2wt
9105 !! wikitext
9106 #REDIRECT [[Category:Foo]]
9107 !! html/parsoid
9108 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9109 !! end
9110
9111 !! test
9112 Redirect to category with URL encoding (T104502)
9113 !! options
9114 parsoid=wt2html
9115 !! wikitext
9116 #REDIRECT [[Category%3AFoo]]
9117 !! html/parsoid
9118 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9119 !! end
9120
9121 !! test
9122 Redirect to category page
9123 !! wikitext
9124 #REDIRECT [[:Category:Foo]]
9125 !! html/parsoid
9126 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9127 !! end
9128
9129 !! test
9130 Redirect to image page (1)
9131 !! wikitext
9132 #REDIRECT [[File:Wiki.png]]
9133 !! html/parsoid
9134 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9135 !! end
9136
9137 !! test
9138 Redirect to image page (2)
9139 !! wikitext
9140 #REDIRECT [[Image:Wiki.png]]
9141 !! html/parsoid
9142 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9143 !! end
9144
9145 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9146 # Next test confirms this.
9147 !! test
9148 Redirect to language (1) (T104918)
9149 !! options
9150 parsoid=wt2html,wt2wt,html2html
9151 !! wikitext
9152 #REDIRECT [[en:File:Wiki.png]]
9153 !! html/parsoid
9154 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9155 !! end
9156
9157 !! test
9158 Redirect to language (2) (T104918)
9159 !! wikitext
9160 #REDIRECT [[:en:File:Wiki.png]]
9161 !! html/parsoid
9162 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9163 !! end
9164
9165 !! test
9166 Redirect to interwiki (T104918)
9167 !! wikitext
9168 #REDIRECT [[meatball:File:Wiki.png]]
9169 !! html/parsoid
9170 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9171 !! end
9172
9173 !! test
9174 Non-English #REDIRECT
9175 !! options
9176 language=is
9177 !! wikitext
9178 #TILVÍSUN [[Main Page]]
9179 !! html/parsoid
9180 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9181 !! end
9182
9183 !! test
9184 Redirect syntax under text isn't considered a redirect
9185 !! wikitext
9186 some text
9187 #redirect [[Main Page]]
9188 !! html/parsoid
9189 <p>some text</p>
9190 <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>
9191 !! end
9192
9193 !! test
9194 New redirect
9195 !! options
9196 parsoid=html2wt
9197 !! html/parsoid
9198 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9199 !! wikitext
9200 #REDIRECT [[Foo]]
9201 Foo
9202 !! end
9203
9204 !! test
9205 Redirect followed by block on the same line
9206 !! options
9207 parsoid=wt2html
9208 !! wikitext
9209 #REDIRECT [[Main Page]]<!-- haha -->== hi ==
9210 !! html/parsoid
9211 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi"> hi </h2>
9212 !! end
9213
9214 !! test
9215 Redirect followed by a newline
9216 !! wikitext
9217 #REDIRECT [[Main Page]]
9218 A newline
9219 !! html/parsoid
9220 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9221 <p>A newline</p>
9222 !! end
9223
9224 !! test
9225 Redirect followed by multiple newlines
9226 !! wikitext
9227 #REDIRECT [[Main Page]]
9228
9229
9230 A newline
9231 !! html/parsoid
9232 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9233
9234 <p><br/>
9235 A newline</p>
9236 !! end
9237
9238 !! test
9239 Drop duplicate redirects
9240 !! options
9241 parsoid=html2wt
9242 !! html/parsoid
9243 <link rel="mw:PageProp/redirect" href="./Foo"/>
9244 <link rel="mw:PageProp/redirect" href="./Bar"/>
9245 <link rel="mw:PageProp/redirect" href="./Baz"/>
9246 !! wikitext
9247 #REDIRECT [[Foo]]
9248 !! end
9249
9250 ##
9251 ## XHTML tidiness
9252 ###
9253
9254 !! test
9255 <br> to <br />
9256 !! wikitext
9257 1<br>2<br />3
9258 !! html
9259 <p>1<br />2<br />3
9260 </p>
9261 !! end
9262
9263 !! test
9264 Broken br tag sanitization
9265 !! wikitext
9266 </br>
9267 !! html/php
9268 <p>&lt;/br&gt;
9269 </p>
9270 !! end
9271
9272 # TODO: Fix html2html mode (T53055)!
9273 !! test
9274 Parsoid: Broken br tag recognition
9275 !! options
9276 parsoid=wt2html
9277 !! wikitext
9278 </br>
9279
9280 <br/ >
9281 !! html+tidy
9282 <p><br />
9283 </p><p><br />
9284 </p>
9285 !! end
9286
9287 !! test
9288 Incorrecly removing closing slashes from correctly formed XHTML
9289 !! wikitext
9290 <br style="clear:both;" />
9291 !! html
9292 <p><br style="clear:both;" />
9293 </p>
9294 !! end
9295
9296 !! test
9297 Failing to transform badly formed HTML into correct XHTML
9298 !! wikitext
9299 <br style="clear: left;">
9300 <br style="clear: right;">
9301 <br style="clear: both;">
9302 !! html
9303 <p><br style="clear: left;" />
9304 <br style="clear: right;" />
9305 <br style="clear: both;" />
9306 </p>
9307 !!end
9308
9309 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9310 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9311 !! test
9312 Handling html with a div self-closing tag
9313 !! wikitext
9314 <div title />
9315 <div title/>
9316 <div title/ >
9317 <div title=bar />
9318 <div title=bar/>
9319 <div title=bar/ >
9320 !! html/php
9321 <p>&lt;div title /&gt;
9322 &lt;div title/&gt;
9323 </p>
9324 <div>
9325 <p>&lt;div title=bar /&gt;
9326 &lt;div title=bar/&gt;
9327 </p>
9328 <div title="bar/"></div>
9329 </div>
9330
9331 !! html/parsoid
9332 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9333 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9334 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9335 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9336 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9337 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>
9338 !! end
9339
9340 !! test
9341 Handling html with a br self-closing tag
9342 !! wikitext
9343 <br title />
9344 <br title/>
9345 <br title/ >
9346 <br title=bar />
9347 <br title=bar/>
9348 <br title=bar/ >
9349 !! html/php
9350 <p><br title="" />
9351 <br title="" />
9352 <br />
9353 <br title="bar" />
9354 <br title="bar" />
9355 <br title="bar/" />
9356 </p>
9357 !! html/parsoid
9358 <p><br title="" />
9359 <br title="" />
9360 <br title="" />
9361 <br title="bar" />
9362 <br title="bar" />
9363 <br title="bar/" />
9364 </p>
9365 !! end
9366
9367 !! test
9368 Horizontal ruler (should it add that extra space?)
9369 !! wikitext
9370 <hr>
9371 <hr >
9372 foo <hr
9373 > bar
9374 !! html+tidy
9375 <hr />
9376 <hr /><p>
9377 foo </p><hr /><p> bar
9378 </p>
9379 !! end
9380
9381 !! test
9382 Horizontal ruler -- 4+ dashes render hr
9383 !! wikitext
9384 ----
9385 !! html
9386 <hr />
9387
9388 !! end
9389
9390 !! test
9391 Horizontal ruler -- eats additional dashes on the same line
9392 !! wikitext
9393 ---------
9394 !! html
9395 <hr />
9396
9397 !! end
9398
9399 !! test
9400 Horizontal ruler -- does not collapse dashes on consecutive lines
9401 !! wikitext
9402 ----
9403 ----
9404 !! html
9405 <hr />
9406 <hr />
9407
9408 !! end
9409
9410 !! test
9411 Horizontal ruler -- <4 dashes render as plain text
9412 !! wikitext
9413 ---
9414 !! html
9415 <p>---
9416 </p>
9417 !! end
9418
9419 !! test
9420 Horizontal ruler -- Supports content following dashes on same line
9421 !! wikitext
9422 ---- Foo
9423 !! html
9424 <hr /> Foo
9425
9426 !! html+tidy
9427 <hr /><p> Foo
9428 </p>
9429 !! end
9430
9431 ###
9432 ### Block-level elements
9433 ###
9434 !! test
9435 Common list
9436 !! wikitext
9437 *Common list
9438 * item 2
9439 *item 3
9440 !! html
9441 <ul><li>Common list</li>
9442 <li> item 2</li>
9443 <li>item 3</li></ul>
9444
9445 !! end
9446
9447 !! test
9448 Numbered list
9449 !! wikitext
9450 #Numbered list
9451 #item 2
9452 # item 3
9453 !! html
9454 <ol><li>Numbered list</li>
9455 <li>item 2</li>
9456 <li> item 3</li></ol>
9457
9458 !! end
9459
9460 !! test
9461 Mixed list
9462 !! wikitext
9463 *Mixed list
9464 *# with numbers
9465 ** and bullets
9466 *# and numbers
9467 *bullets again
9468 **bullet level 2
9469 ***bullet level 3
9470 ***#Number on level 4
9471 **bullet level 2
9472 **#Number on level 3
9473 **#Number on level 3
9474 *#number level 2
9475 *Level 1
9476 *** Level 3
9477 #** Level 3, but ordered
9478 !! html
9479 <ul><li>Mixed list
9480 <ol><li> with numbers</li></ol>
9481 <ul><li> and bullets</li></ul>
9482 <ol><li> and numbers</li></ol></li>
9483 <li>bullets again
9484 <ul><li>bullet level 2
9485 <ul><li>bullet level 3
9486 <ol><li>Number on level 4</li></ol></li></ul></li>
9487 <li>bullet level 2
9488 <ol><li>Number on level 3</li>
9489 <li>Number on level 3</li></ol></li></ul>
9490 <ol><li>number level 2</li></ol></li>
9491 <li>Level 1
9492 <ul><li><ul><li> Level 3</li></ul></li></ul></li></ul>
9493 <ol><li><ul><li><ul><li> Level 3, but ordered</li></ul></li></ul></li></ol>
9494
9495 !! end
9496
9497 !! test
9498 1. Nested mixed wikitext and html list
9499 !! wikitext
9500 * hi
9501 * <ul><li>ho</li></ul>
9502 * hi
9503 ** ho
9504 !! html/php
9505 <ul><li> hi</li>
9506 <li> <ul><li>ho</li></ul></li>
9507 <li> hi
9508 <ul><li> ho</li></ul></li></ul>
9509
9510 !! html/parsoid
9511 <ul><li> hi</li>
9512 <li> <ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9513 <li> hi
9514 <ul><li> ho</li></ul></li></ul>
9515 !! end
9516
9517 !! test
9518 2. Nested mixed wikitext and html list (incompatible)
9519 !! wikitext
9520 ; hi
9521 : {{echo|<li>ho</li>}}
9522 !! html/php
9523 <dl><dt> hi</dt>
9524 <dd> <li>ho</li></dd></dl>
9525
9526 !! html/parsoid
9527 <dl><dt> hi</dt>
9528 <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>
9529 !! end
9530
9531 !! test
9532 Nested lists 1
9533 !! wikitext
9534 *foo
9535 **bar
9536 !! html
9537 <ul><li>foo
9538 <ul><li>bar</li></ul></li></ul>
9539
9540 !! end
9541
9542 !! test
9543 Nested lists 2
9544 !! wikitext
9545 **foo
9546 *bar
9547 !! html
9548 <ul><li><ul><li>foo</li></ul></li>
9549 <li>bar</li></ul>
9550
9551 !! end
9552
9553 !! test
9554 Nested lists 3 (first element empty)
9555 !! wikitext
9556 *
9557 **bar
9558 !! html
9559 <ul><li>
9560 <ul><li>bar</li></ul></li></ul>
9561
9562 !! end
9563
9564 !! test
9565 Nested lists 4 (first element empty)
9566 !! wikitext
9567 **
9568 *bar
9569 !! html
9570 <ul><li><ul><li></li></ul></li>
9571 <li>bar</li></ul>
9572
9573 !! end
9574
9575 !! test
9576 Nested lists 5 (both elements empty)
9577 !! wikitext
9578 **
9579 *
9580 !! html
9581 <ul><li><ul><li></li></ul></li>
9582 <li></li></ul>
9583
9584 !! end
9585
9586 !! test
9587 Nested lists 6 (both elements empty)
9588 !! wikitext
9589 *
9590 **
9591 !! html
9592 <ul><li>
9593 <ul><li></li></ul></li></ul>
9594
9595 !! end
9596
9597 !! test
9598 Nested lists 7 (skip initial nesting levels)
9599 !! wikitext
9600 *** foo
9601 !! html
9602 <ul><li><ul><li><ul><li> foo</li></ul></li></ul></li></ul>
9603
9604 !! end
9605
9606 !! test
9607 Nested lists 8 (multiple nesting transitions)
9608 !! wikitext
9609 * foo
9610 *** bar
9611 ** baz
9612 * boo
9613 !! html
9614 <ul><li> foo
9615 <ul><li><ul><li> bar</li></ul></li>
9616 <li> baz</li></ul></li>
9617 <li> boo</li></ul>
9618
9619 !! end
9620
9621 !! test
9622 Nested lists 9 (extension interaction)
9623 !! options
9624 parsoid
9625 !! wikitext
9626 *<references />
9627 !! html/parsoid
9628 <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>
9629 !! end
9630
9631 !! test
9632 1. Lists with start-of-line-transparent tokens before bullets: Comments
9633 !! wikitext
9634 *foo
9635 *<!--cmt-->bar
9636 <!--cmt-->*baz
9637 !! html
9638 <ul><li>foo</li>
9639 <li>bar</li>
9640 <li>baz</li></ul>
9641
9642 !! end
9643
9644 !! test
9645 2. Lists with start-of-line-transparent tokens before bullets: Template close
9646 !! wikitext
9647 *foo {{echo|bar
9648 }}*baz
9649 !! html
9650 <ul><li>foo bar</li>
9651 <li>baz</li></ul>
9652
9653 !! end
9654
9655 !! test
9656 List items are not parsed correctly following a <pre> block (T2785)
9657 !! wikitext
9658 * <pre>foo</pre>
9659 * <pre>bar</pre>
9660 * zar
9661 !! html/php
9662 <ul><li> <pre>foo</pre></li>
9663 <li> <pre>bar</pre></li>
9664 <li> zar</li></ul>
9665
9666 !! html/parsoid
9667 <ul><li> <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
9668 <li> <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
9669 <li> zar</li></ul>
9670 !! end
9671
9672 !! test
9673 List items from template
9674 !! wikitext
9675
9676 {{inner list}}
9677 * item 2
9678
9679 * item 0
9680 {{inner list}}
9681 * item 2
9682
9683 * item 0
9684 * notSOL{{inner list}}
9685 * item 2
9686 !! html
9687 <ul><li> item 1</li>
9688 <li> item 2</li></ul>
9689 <ul><li> item 0</li>
9690 <li> item 1</li>
9691 <li> item 2</li></ul>
9692 <ul><li> item 0</li>
9693 <li> notSOL</li>
9694 <li> item 1</li>
9695 <li> item 2</li></ul>
9696
9697 !! end
9698
9699 !! test
9700 List interrupted by empty line or heading
9701 !! wikitext
9702 * foo
9703
9704 ** bar
9705 == A heading ==
9706 * Another list item
9707 !! html
9708 <ul><li> foo</li></ul>
9709 <ul><li><ul><li> bar</li></ul></li></ul>
9710 <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>
9711 <ul><li> Another list item</li></ul>
9712
9713 !!end
9714
9715 !!test
9716 Multiple list tags generated by templates
9717 !! wikitext
9718 {{echo|<li>}}a
9719 {{echo|<li>}}b
9720 {{echo|<li>}}c
9721 !! html
9722 <li>a
9723 <li>b
9724 <li>c</li>
9725 </li>
9726 </li>
9727
9728 !! html+tidy
9729 <li>a
9730 </li><li>b
9731 </li><li>c
9732 </li>
9733 !!end
9734
9735 !!test
9736 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
9737 !! wikitext
9738 *a
9739 <!--This line will NOT split the list-->
9740 *b
9741 <!--This line will NOT split the list either-->
9742 *c
9743 <!--foo--> <!----> <!--This line NOT split the list either-->
9744 *d
9745 !! html
9746 <ul><li>a</li>
9747 <li>b</li>
9748 <li>c</li>
9749 <li>d</li></ul>
9750
9751 !!end
9752
9753 !!test
9754 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
9755 !! wikitext
9756 *a
9757 <!--This line will NOT split the list-->
9758 *b
9759 <!--This line will NOT split the list either-->
9760 *c
9761 <!--foo--> <!----> <!--This line NOT split the list
9762 either-->
9763 *d
9764 !! html
9765 <ul><li>a</li>
9766 <li>b</li>
9767 <li>c</li>
9768 <li>d</li></ul>
9769
9770 !!end
9771
9772 # FIXME: Parsoid has a dedicated DOM pass to mimic this Tidy-specific li-hack
9773 # That pass could possibly be removed.
9774 !!test
9775 Test the li-hack (a hack from Tidy days, but doesn't work as advertised with Remex)
9776 !!options
9777 parsoid=wt2html,wt2wt
9778 !! wikitext
9779 * foo
9780 * <li>li-hack
9781 * {{echo|<li>templated li-hack}}
9782 * <!--foo--> <li> unsupported li-hack with preceding comments
9783
9784 <ul>
9785 <li><li>not a li-hack
9786 </li>
9787 </ul>
9788 !! html+tidy
9789 <ul><li> foo</li>
9790 <li class="mw-empty-elt"> </li><li>li-hack</li>
9791 <li class="mw-empty-elt"> </li><li>templated li-hack</li>
9792 <li class="mw-empty-elt"> </li><li> unsupported li-hack with preceding comments</li></ul>
9793 <ul>
9794 <li class="mw-empty-elt"></li><li>not a li-hack
9795 </li>
9796 </ul>
9797 !! html/parsoid
9798 <ul><li> foo</li>
9799 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"* "}'>li-hack</li>
9800 <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>
9801 <li data-parsoid='{"autoInsertedEnd":true}'> <!--foo--> </li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'> unsupported li-hack with preceding comments</li></ul>
9802
9803 <ul data-parsoid='{"stx":"html"}'>
9804 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
9805 </li>
9806 </ul>
9807
9808 !!end
9809
9810 !! test
9811 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
9812 !! options
9813 parsoid
9814 !! wikitext
9815 # foo
9816 ## bar
9817 * foo
9818 ** bar
9819 : foo
9820 :: bar
9821 !! html
9822 <ol>
9823 <li> foo<ol>
9824 <li> bar</li>
9825 </ol></li>
9826 </ol><ul>
9827 <li> foo<ul>
9828 <li> bar</li>
9829 </ul></li>
9830 </ul><dl>
9831 <dd> foo<dl>
9832 <dd> bar</dd>
9833 </dl></dd>
9834 </dl>
9835 !! end
9836
9837 !! test
9838 Parsoid: Test of whitespace serialization with Templated bullets
9839 !! options
9840 parsoid
9841 !! wikitext
9842 * {{bullet}}
9843 !! html/parsoid
9844 <ul>
9845 <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>
9846 </ul>
9847 !! end
9848
9849 # ------------------------------------------------------------------------
9850 # The next set of tests are about Parsoid's ability to handle badly nested
9851 # tags (parse, minimize scope of fixup, and roundtrip back)
9852 # ------------------------------------------------------------------------
9853
9854 # Remex and Parsoid output stems from list handling diffs because Parsoid & PHP parser.
9855 # Parsoid's list handling is more aware of block structure.
9856 !! test
9857 Unbalanced closing block tags break a list
9858 !! wikitext
9859 <div>
9860 *a</div><div>
9861 *b</div>
9862 !! html+tidy
9863 <div>
9864 <ul><li>a</li></ul></div><div>
9865 <li>b</li></div>
9866 !! html+parsoid
9867 <div><ul>
9868 <li>a</li>
9869 </ul></div>
9870 <div><ul>
9871 <li>b</li>
9872 </ul></div>
9873 !! end
9874
9875 !! test
9876 Unbalanced closing non-block tags don't break a list
9877 !! wikitext
9878 <span>
9879 *a</span><span>
9880 *b</span>
9881 !! html/php+tidy
9882 <p><span>
9883 </span></p>
9884 <ul><li>a<span></span></li>
9885 <li>b</li></ul>
9886 !! html/parsoid
9887 <span>
9888 <ul>
9889 <li>a<span></span></li>
9890 <li>b</li>
9891 </ul>
9892 </span>
9893 !! end
9894
9895 # Parsoid does some post-dom-building cleanup
9896 # which is why its output differs from Remex.
9897 !! test
9898 Unclosed formatting tags that straddle lists are closed and reopened
9899 !! options
9900 parsoid=wt2html,wt2wt,html2html
9901 !! wikitext
9902 # <s> a
9903 # b </s>
9904 !! html/php+tidy
9905 <ol><li> <s> a</s></li><s>
9906 </s><li><s> b </s></li></ol>
9907 !! html/parsoid
9908 <ol><li> <s> a</s><s></s></li>
9909 <li><s> b </s></li></ol>
9910 !! end
9911
9912 # Output is ugly because of all the misnested tag fixups.
9913 # Remex is wrapping p-tags around empty elements.
9914 # Parsoid has special-case handling of this pattern of
9915 # wrapping lists in formatting tags.
9916 # FIXME: Should we remove this code from Parsoid? Or add
9917 # special support in Remex? If the latter, maybe just wait
9918 # for Parsoid to become the default parser.
9919 # See T70395.
9920 !!test
9921 1. List embedded in a formatting tag
9922 !! wikitext
9923 <small>
9924 * foo
9925 </small>
9926 !! html/php+tidy
9927 <p><small>
9928 </small></p><small><ul><li> foo</li></ul></small><small></small><p><small></small>
9929 </p>
9930 !! html/parsoid
9931 <small>
9932 <ul>
9933 <li> foo</li>
9934 </ul>
9935 </small>
9936 !!end
9937
9938 # Output is ugly because of all the misnested tag fixups
9939 # Remex is wrapping p-tags around empty elements.
9940 # Parsoid has code that strips useless p-tags.
9941 !!test
9942 2. List embedded in a formatting tag in a misnested way
9943 !! wikitext
9944 <small>
9945 *a
9946 *b</small>
9947 !! html/php+tidy
9948 <p><small>
9949 </small></p><small></small><ul><small><li>a</li>
9950 </small><li><small>b</small></li></ul>
9951 !! html/parsoid
9952 <small></small>
9953 <ul><small>
9954 <li>a</li>
9955 </small>
9956 <li><small>b</small></li>
9957 </ul>
9958 !!end
9959
9960 !! test
9961 Table with missing opening <tr> tag
9962 !! options
9963 parsoid=wt2html,wt2wt
9964 !! wikitext
9965 <table>
9966 <td>foo</td>
9967 </tr>
9968 </table>
9969 !! html+tidy
9970 <table>
9971 <tbody><tr><td>foo</td>
9972 </tr>
9973 </tbody></table>
9974 !! end
9975
9976 ###
9977 ### Magic Words
9978 ###
9979
9980 # Note that the current date is hard-coded as
9981 # 1970-01-01T00:02:03Z (a Thursday)
9982 # when running parser tests. The timezone is also fixed to GMT, so
9983 # local date will be identical to current date.
9984
9985 !! test
9986 Magic Word: {{CURRENTDAY}}
9987 !! wikitext
9988 {{CURRENTDAY}}
9989 !! html
9990 <p>1
9991 </p>
9992 !! end
9993
9994 !! test
9995 Magic Word: {{CURRENTDAY2}}
9996 !! wikitext
9997 {{CURRENTDAY2}}
9998 !! html
9999 <p>01
10000 </p>
10001 !! end
10002
10003 !! test
10004 Magic Word: {{CURRENTDAYNAME}}
10005 !! wikitext
10006 {{CURRENTDAYNAME}}
10007 !! html
10008 <p>Thursday
10009 </p>
10010 !! end
10011
10012 !! test
10013 Magic Word: {{CURRENTDOW}}
10014 !! wikitext
10015 {{CURRENTDOW}}
10016 !! html
10017 <p>4
10018 </p>
10019 !! end
10020
10021 !! test
10022 Magic Word: {{CURRENTMONTH}}
10023 !! wikitext
10024 {{CURRENTMONTH}}
10025 !! html
10026 <p>01
10027 </p>
10028 !! end
10029
10030 !! test
10031 Magic Word: {{CURRENTMONTH1}}
10032 !! wikitext
10033 {{CURRENTMONTH1}}
10034 !! html
10035 <p>1
10036 </p>
10037 !! end
10038
10039 !! test
10040 Magic Word: {{CURRENTMONTHABBREV}}
10041 !! wikitext
10042 {{CURRENTMONTHABBREV}}
10043 !! html
10044 <p>Jan
10045 </p>
10046 !! end
10047
10048 !! test
10049 Magic Word: {{CURRENTMONTHNAME}}
10050 !! wikitext
10051 {{CURRENTMONTHNAME}}
10052 !! html
10053 <p>January
10054 </p>
10055 !! end
10056
10057 !! test
10058 Magic Word: {{CURRENTMONTHNAMEGEN}}
10059 !! wikitext
10060 {{CURRENTMONTHNAMEGEN}}
10061 !! html
10062 <p>January
10063 </p>
10064 !! end
10065
10066 !! test
10067 Magic Word: {{CURRENTTIME}}
10068 !! wikitext
10069 {{CURRENTTIME}}
10070 !! html
10071 <p>00:02
10072 </p>
10073 !! end
10074
10075 !! test
10076 Magic Word: {{CURRENTHOUR}}
10077 !! wikitext
10078 {{CURRENTHOUR}}
10079 !! html
10080 <p>00
10081 </p>
10082 !! end
10083
10084 !! test
10085 Magic Word: {{CURRENTWEEK}} (T6594)
10086 !! wikitext
10087 {{CURRENTWEEK}}
10088 !! html
10089 <p>1
10090 </p>
10091 !! end
10092
10093 !! test
10094 Magic Word: {{CURRENTYEAR}}
10095 !! wikitext
10096 {{CURRENTYEAR}}
10097 !! html
10098 <p>1970
10099 </p>
10100 !! end
10101
10102 !! test
10103 Magic Word: {{CURRENTTIMESTAMP}}
10104 !! wikitext
10105 {{CURRENTTIMESTAMP}}
10106 !! html
10107 <p>19700101000203
10108 </p>
10109 !! end
10110
10111 !! test
10112 Magic Words LOCAL (UTC)
10113 !! wikitext
10114 * {{LOCALMONTH}}
10115 * {{LOCALMONTH1}}
10116 * {{LOCALMONTHNAME}}
10117 * {{LOCALMONTHNAMEGEN}}
10118 * {{LOCALMONTHABBREV}}
10119 * {{LOCALDAY}}
10120 * {{LOCALDAY2}}
10121 * {{LOCALDAYNAME}}
10122 * {{LOCALYEAR}}
10123 * {{LOCALTIME}}
10124 * {{LOCALHOUR}}
10125 * {{LOCALWEEK}}
10126 * {{LOCALDOW}}
10127 * {{LOCALTIMESTAMP}}
10128 !! html
10129 <ul><li> 01</li>
10130 <li> 1</li>
10131 <li> January</li>
10132 <li> January</li>
10133 <li> Jan</li>
10134 <li> 1</li>
10135 <li> 01</li>
10136 <li> Thursday</li>
10137 <li> 1970</li>
10138 <li> 00:02</li>
10139 <li> 00</li>
10140 <li> 1</li>
10141 <li> 4</li>
10142 <li> 19700101000203</li></ul>
10143
10144 !! end
10145
10146 !! test
10147 Magic Word: {{FULLPAGENAME}}
10148 !! options
10149 title=[[User:Ævar Arnfjörð Bjarmason]]
10150 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10151 !! wikitext
10152 {{FULLPAGENAME}}
10153 !! html/*
10154 <p>User:Ævar Arnfjörð Bjarmason
10155 </p>
10156 !! end
10157
10158 !! test
10159 Magic Word: {{FULLPAGENAMEE}}
10160 !! options
10161 title=[[User:Ævar Arnfjörð Bjarmason]]
10162 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10163 !! wikitext
10164 {{FULLPAGENAMEE}}
10165 !! html/*
10166 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10167 </p>
10168 !! end
10169
10170 !! test
10171 Magic Word: {{TALKSPACE}}
10172 !! options
10173 title=[[User:Ævar Arnfjörð Bjarmason]]
10174 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10175 !! wikitext
10176 {{TALKSPACE}}
10177 !! html/*
10178 <p>User talk
10179 </p>
10180 !! end
10181
10182 !! test
10183 Magic Word: {{TALKSPACE}}, same namespace
10184 !! options
10185 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10186 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10187 !! wikitext
10188 {{TALKSPACE}}
10189 !! html/*
10190 <p>User talk
10191 </p>
10192 !! end
10193
10194 !! test
10195 Magic Word: {{TALKSPACE}}, main namespace
10196 !! options
10197 title=[[Parser Test]]
10198 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10199 !! wikitext
10200 {{TALKSPACE}}
10201 !! html/*
10202 <p>Talk
10203 </p>
10204 !! end
10205
10206 !! test
10207 Magic Word: {{TALKSPACEE}}
10208 !! options
10209 title=[[User:Ævar Arnfjörð Bjarmason]]
10210 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10211 !! wikitext
10212 {{TALKSPACEE}}
10213 !! html/*
10214 <p>User_talk
10215 </p>
10216 !! end
10217
10218 !! test
10219 Magic Word: {{SUBJECTSPACE}}
10220 !! options
10221 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10222 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10223 !! wikitext
10224 {{SUBJECTSPACE}}
10225 !! html/*
10226 <p>User
10227 </p>
10228 !! end
10229
10230 !! test
10231 Magic Word: {{SUBJECTSPACE}}, same namespace
10232 !! options
10233 title=[[User:Ævar Arnfjörð Bjarmason]]
10234 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10235 !! wikitext
10236 {{SUBJECTSPACE}}
10237 !! html/*
10238 <p>User
10239 </p>
10240 !! end
10241
10242 !! test
10243 Magic Word: {{SUBJECTSPACE}}, main namespace
10244 !! options
10245 title=[[Parser Test]]
10246 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10247 !! wikitext
10248 {{SUBJECTSPACE}}
10249 !! html/*
10250
10251 !! end
10252
10253 !! test
10254 Magic Word: {{SUBJECTSPACEE}}
10255 !! options
10256 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10257 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10258 !! wikitext
10259 {{SUBJECTSPACEE}}
10260 !! html/*
10261 <p>User
10262 </p>
10263 !! end
10264
10265 !! test
10266 Magic Word: {{NAMESPACE}}
10267 !! options
10268 title=[[User:Ævar Arnfjörð Bjarmason]]
10269 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10270 !! wikitext
10271 {{NAMESPACE}}
10272 !! html/*
10273 <p>User
10274 </p>
10275 !! end
10276
10277 !! test
10278 Magic Word: {{NAMESPACEE}}
10279 !! options
10280 title=[[User:Ævar Arnfjörð Bjarmason]]
10281 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10282 !! wikitext
10283 {{NAMESPACEE}}
10284 !! html/*
10285 <p>User
10286 </p>
10287 !! end
10288
10289 !! test
10290 Magic Word: {{NAMESPACENUMBER}}
10291 !! options
10292 title=[[User:Ævar Arnfjörð Bjarmason]]
10293 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10294 !! wikitext
10295 {{NAMESPACENUMBER}}
10296 !! html/*
10297 <p>2
10298 </p>
10299 !! end
10300
10301 !! test
10302 Magic Word: {{SUBPAGENAME}}
10303 !! options
10304 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10305 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10306 !! wikitext
10307 {{SUBPAGENAME}}
10308 !! html/*
10309 <p>sub ö
10310 </p>
10311 !! end
10312
10313 !! test
10314 Magic Word: {{SUBPAGENAMEE}}
10315 !! options
10316 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10317 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10318 !! wikitext
10319 {{SUBPAGENAMEE}}
10320 !! html/*
10321 <p>sub_%C3%B6
10322 </p>
10323 !! end
10324
10325 !! test
10326 Magic Word: {{ROOTPAGENAME}}
10327 !! options
10328 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10329 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10330 !! wikitext
10331 {{ROOTPAGENAME}}
10332 !! html/*
10333 <p>Ævar Arnfjörð Bjarmason
10334 </p>
10335 !! end
10336
10337 !! test
10338 Magic Word: {{ROOTPAGENAMEE}}
10339 !! options
10340 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10341 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10342 !! wikitext
10343 {{ROOTPAGENAMEE}}
10344 !! html/*
10345 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10346 </p>
10347 !! end
10348
10349 !! test
10350 Magic Word: {{BASEPAGENAME}}
10351 !! options
10352 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10353 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10354 !! wikitext
10355 {{BASEPAGENAME}}
10356 !! html/*
10357 <p>Ævar Arnfjörð Bjarmason
10358 </p>
10359 !! end
10360
10361 !! test
10362 Magic Word: {{BASEPAGENAMEE}}
10363 !! options
10364 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10365 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10366 !! wikitext
10367 {{BASEPAGENAMEE}}
10368 !! html/*
10369 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10370 </p>
10371 !! end
10372
10373 !! test
10374 Magic Word: {{TALKPAGENAME}}
10375 !! options
10376 title=[[User:Ævar Arnfjörð Bjarmason]]
10377 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10378 !! wikitext
10379 {{TALKPAGENAME}}
10380 !! html/*
10381 <p>User talk:Ævar Arnfjörð Bjarmason
10382 </p>
10383 !! end
10384
10385 !! test
10386 Magic Word: {{TALKPAGENAMEE}}
10387 !! options
10388 title=[[User:Ævar Arnfjörð Bjarmason]]
10389 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10390 !! wikitext
10391 {{TALKPAGENAMEE}}
10392 !! html/*
10393 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10394 </p>
10395 !! end
10396
10397 !! test
10398 Magic Word: {{SUBJECTPAGENAME}}
10399 !! options
10400 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10401 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10402 !! wikitext
10403 {{SUBJECTPAGENAME}}
10404 !! html/*
10405 <p>User:Ævar Arnfjörð Bjarmason
10406 </p>
10407 !! end
10408
10409 !! test
10410 Magic Word: {{SUBJECTPAGENAMEE}}
10411 !! options
10412 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10413 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10414 !! wikitext
10415 {{SUBJECTPAGENAMEE}}
10416 !! html/*
10417 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10418 </p>
10419 !! end
10420
10421 !! test
10422 Magic Word: {{NUMBEROFFILES}}
10423 !! options
10424 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10425 !! wikitext
10426 {{NUMBEROFFILES}}
10427 !! html/*
10428 <p>7
10429 </p>
10430 !! end
10431
10432 !! test
10433 Magic Word: {{PAGENAME}}
10434 !! options
10435 title=[[User:Ævar Arnfjörð Bjarmason]]
10436 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10437 !! wikitext
10438 {{PAGENAME}}
10439 !! html/*
10440 <p>Ævar Arnfjörð Bjarmason
10441 </p>
10442 !! end
10443
10444 !! test
10445 Magic Word: {{PAGENAME}} with metacharacters
10446 !! options
10447 title=[['foo & bar = baz']]
10448 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10449 !! wikitext
10450 ''{{PAGENAME}}''
10451 !! html+tidy
10452 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10453 </p>
10454 !! end
10455
10456 !! test
10457 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10458 !! options
10459 title=[[*RFC 1234 http://example.com/]]
10460 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10461 !! wikitext
10462 {{PAGENAME}}
10463 !! html+tidy
10464 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10465 </p>
10466 !! end
10467
10468 !! test
10469 Magic Word: {{PAGENAMEE}}
10470 !! options
10471 title=[[User:Ævar Arnfjörð Bjarmason]]
10472 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10473 !! wikitext
10474 {{PAGENAMEE}}
10475 !! html/*
10476 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10477 </p>
10478 !! end
10479
10480 !! test
10481 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10482 !! options
10483 title=[[*RFC 1234 http://example.com/]]
10484 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10485 !! wikitext
10486 {{PAGENAMEE}}
10487 !! html+tidy
10488 <p>&#42;RFC_1234_http&#58;//example.com/
10489 </p>
10490 !! end
10491
10492 !! test
10493 Magic Word: {{REVISIONID}}
10494 !! options
10495 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10496 showflags
10497 !! wikitext
10498 {{REVISIONID}}
10499 !! html/*
10500 <p>1337
10501 </p>
10502 flags=vary-revision-id
10503 !! end
10504
10505 !! test
10506 Magic Word: {{SCRIPTPATH}}
10507 !! options
10508 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10509 !! wikitext
10510 {{SCRIPTPATH}}
10511 !! html/*
10512
10513 !! end
10514
10515 !! test
10516 Magic Word: {{STYLEPATH}}
10517 !! options
10518 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10519 !! wikitext
10520 {{STYLEPATH}}
10521 !! html/*
10522 <p>/skins
10523 </p>
10524 !! end
10525
10526 !! test
10527 Magic Word: {{SERVER}}
10528 !! options
10529 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10530 !! wikitext
10531 {{SERVER}}
10532 !! html/*
10533 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10534 </p>
10535 !! end
10536
10537 !! test
10538 Magic Word: {{SERVERNAME}}
10539 !! options
10540 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10541 !! wikitext
10542 {{SERVERNAME}}
10543 !! html/*
10544 <p>example.org
10545 </p>
10546 !! end
10547
10548 !! test
10549 Magic Word: {{SITENAME}}
10550 !! options
10551 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10552 !! wikitext
10553 {{SITENAME}}
10554 !! html/*
10555 <p>MediaWiki
10556 </p>
10557 !! end
10558
10559 !! test
10560 Magic Word: {{PAGELANGUAGE}}
10561 !! options
10562 language=fr
10563 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10564 !! wikitext
10565 {{PAGELANGUAGE}}
10566 !! html/*
10567 <p>fr
10568 </p>
10569 !! end
10570
10571 !! test
10572 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10573 !! options
10574 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10575 !! wikitext
10576 {{PAGELANGUAGE}}
10577 !! html/*
10578 <p>en
10579 </p>
10580 !! end
10581
10582 !! test
10583 Case-sensitive magic words, when cased differently, should just be template transclusions
10584 !! wikitext
10585 {{CurrentMonth}}
10586 {{currentday}}
10587 {{cURreNTweEK}}
10588 {{currentHour}}
10589 !! html
10590 <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>
10591 <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>
10592 <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>
10593 <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>
10594 </p>
10595 !! end
10596
10597 !! test
10598 Case-insensitive magic words should still work with weird casing.
10599 !! wikitext
10600 {{sErVeRNaMe}}
10601 {{LCFirst:AOEU}}
10602 {{ucFIRST:aoeu}}
10603 {{SERver}}
10604 !! html
10605 <p>example.org
10606 aOEU
10607 Aoeu
10608 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10609 </p>
10610 !! end
10611
10612 # From plwiki:PLOS_ONE
10613 !! test
10614 Parsoid: Page property magic word with magic word contents
10615 !! wikitext
10616 {{DISPLAYTITLE:''{{PAGENAME}}''}}
10617 !! html/parsoid
10618 <meta property="mw:PageProp/displaytitle" content="Main Page" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"src":"{{DISPLAYTITLE:&#39;&#39;{{PAGENAME}}&#39;&#39;}}"}' data-mw='{"attribs":[[{"txt":"content"},{"html":"DISPLAYTITLE:&lt;i data-parsoid=&#39;{\"dsr\":[15,31,2,2]}&#39;>&lt;span about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[17,29,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"PAGENAME\",\"function\":\"pagename\"},\"params\":{},\"i\":0}}]}&#39;>Main Page&lt;/span>&lt;/i>"}]]}'/>
10619 !! end
10620
10621 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
10622 # But, this is a limitation of our representation and is documented in
10623 # TemplateHandler.js in processSpecialMagicWord
10624 !! test
10625 Parsoid: Template-generated DISPLAYTITLE
10626 !! wikitext
10627 {{{{echo|DISPLAYTITLE}}:Foo}}
10628 !! options
10629 showtitle
10630 !! config
10631 wgAllowDisplayTitle=true
10632 wgRestrictDisplayTitle=false
10633 !! html/php
10634 Foo
10635
10636 !! html/parsoid
10637 <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"}]]}'/>
10638 !! end
10639
10640 !! test
10641 Namespace 1 {{ns:1}}
10642 !! wikitext
10643 {{ns:1}}
10644 !! html
10645 <p>Talk
10646 </p>
10647 !! end
10648
10649 !! test
10650 Namespace 1 {{ns:01}}
10651 !! wikitext
10652 {{ns:01}}
10653 !! html
10654 <p>Talk
10655 </p>
10656 !! end
10657
10658 !! test
10659 Namespace 0 {{ns:0}} (T6783)
10660 !! wikitext
10661 {{ns:0}}
10662 !! html
10663
10664 !! end
10665
10666 !! test
10667 Namespace 0 {{ns:00}} (T6783)
10668 !! wikitext
10669 {{ns:00}}
10670 !! html
10671
10672 !! end
10673
10674 !! test
10675 Namespace -1 {{ns:-1}}
10676 !! wikitext
10677 {{ns:-1}}
10678 !! html
10679 <p>Special
10680 </p>
10681 !! end
10682
10683 !! test
10684 Namespace User {{ns:User}}
10685 !! wikitext
10686 {{ns:User}}
10687 !! html
10688 <p>User
10689 </p>
10690 !! end
10691
10692 !! test
10693 Namespace User talk {{ns:User_talk}}
10694 !! wikitext
10695 {{ns:User_talk}}
10696 !! html
10697 <p>User talk
10698 </p>
10699 !! end
10700
10701 !! test
10702 Namespace User talk {{ns:uSeR tAlK}}
10703 !! wikitext
10704 {{ns:uSeR tAlK}}
10705 !! html
10706 <p>User talk
10707 </p>
10708 !! end
10709
10710 !! test
10711 Namespace File {{ns:File}}
10712 !! wikitext
10713 {{ns:File}}
10714 !! html
10715 <p>File
10716 </p>
10717 !! end
10718
10719 !! test
10720 Namespace File {{ns:Image}}
10721 !! wikitext
10722 {{ns:Image}}
10723 !! html
10724 <p>File
10725 </p>
10726 !! end
10727
10728 !! test
10729 Namespace (lang=de) Benutzer {{ns:User}}
10730 !! options
10731 language=de
10732 !! wikitext
10733 {{ns:User}}
10734 !! html
10735 <p>Benutzer
10736 </p>
10737 !! end
10738
10739 !! test
10740 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
10741 !! options
10742 language=de
10743 !! wikitext
10744 {{ns:3}}
10745 !! html
10746 <p>Benutzer Diskussion
10747 </p>
10748 !! end
10749
10750 !! test
10751 Urlencode
10752 !! wikitext
10753 {{urlencode:hi world?!}}
10754 {{urlencode:hi world?!|WIKI}}
10755 {{urlencode:hi world?!|PATH}}
10756 {{urlencode:hi world?!|QUERY}}
10757 !! html/php
10758 <p>hi+world%3F%21
10759 hi_world%3F!
10760 hi%20world%3F%21
10761 hi+world%3F%21
10762 </p>
10763 !! end
10764
10765 !! test
10766 Magic Word: prioritize type info over data-parsoid
10767 !! options
10768 parsoid=html2wt
10769 !! html/parsoid
10770 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
10771 !! wikitext
10772 __FORCETOC__
10773 !! end
10774
10775 !! test
10776 Magic Word: serialize on separate line (parsoid)
10777 !! options
10778 parsoid=wt2wt,html2wt
10779 !! wikitext
10780 foo
10781 __NOTOC__
10782 bar
10783 !! html/parsoid
10784 foo<meta property="mw:PageProp/notoc"/>bar
10785 !! end
10786
10787 !! test
10788 Magic Word: rt non-english wikis
10789 !! options
10790 parsoid=wt2wt
10791 language=de
10792 !! wikitext
10793 __NOEDITSECTION__
10794 !! html/parsoid
10795 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
10796 !! end
10797
10798 !!test
10799 __proto__ is treated as normal wikitext (T105997)
10800 !!wikitext
10801 __proto__
10802 !!html
10803 <p>__proto__
10804 </p>
10805 !!end
10806
10807 ###
10808 ### Magic links
10809 ###
10810 !! test
10811 Magic links: internal link to RFC (T2479)
10812 !! wikitext
10813 [[RFC 123]]
10814 !! html/php
10815 <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>
10816 </p>
10817 !! html/parsoid
10818 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
10819 !! end
10820
10821 !! test
10822 Magic links: RFC (T2479)
10823 !! wikitext
10824 RFC 822
10825 !! html/php
10826 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
10827 </p>
10828 !! html/parsoid
10829 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a></p>
10830 !! end
10831
10832 !! test
10833 Magic links: RFC (T67278)
10834 !! wikitext
10835 This is RFC 822 but thisRFC 822 is not RFC 822linked.
10836 !! html/php
10837 <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.
10838 </p>
10839 !! html/parsoid
10840 <p>This is <a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
10841 !! end
10842
10843 !! test
10844 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
10845 !! wikitext
10846 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
10847 RFC
10848 822
10849 !! html/php
10850 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
10851 RFC
10852 822
10853 </p>
10854 !! html/parsoid
10855 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink">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>
10856 RFC
10857 822</p>
10858 !! end
10859
10860 !! test
10861 Magic links: ISBN (T3937)
10862 !! wikitext
10863 ISBN 0-306-40615-2
10864 !! html/php
10865 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
10866 </p>
10867 !! html/parsoid
10868 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
10869 !! end
10870
10871 !! test
10872 Magic links: ISBN (T67278)
10873 !! wikitext
10874 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
10875 !! html/php
10876 <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.
10877 </p>
10878 !! html/parsoid
10879 <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>
10880 !! end
10881
10882 !! test
10883 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
10884 !! wikitext
10885 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
10886 ISBN
10887 9780316098113
10888 ISBN 978
10889 0316098113
10890 !! html/php
10891 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
10892 ISBN
10893 9780316098113
10894 ISBN 978
10895 0316098113
10896 </p>
10897 !! html/parsoid
10898 <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>
10899 ISBN
10900 9780316098113
10901 ISBN 978
10902 0316098113</p>
10903 !! end
10904
10905 !! test
10906 Magic links: PMID incorrectly converts space to underscore
10907 !! wikitext
10908 PMID 1234
10909 !! html/php
10910 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
10911 </p>
10912 !! html/parsoid
10913 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a></p>
10914 !! end
10915
10916 !! test
10917 Magic links: PMID (T67278)
10918 !! wikitext
10919 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
10920 !! html/php
10921 <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.
10922 </p>
10923 !! html/parsoid
10924 <p>This is <a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a> but thisPMID 1234 is not PMID 1234linked.</p>
10925 !! end
10926
10927 !! test
10928 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
10929 !! wikitext
10930 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
10931 PMID
10932 1234
10933 !! html/php
10934 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
10935 PMID
10936 1234
10937 </p>
10938 !! html/parsoid
10939 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">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>
10940 PMID
10941 1234</p>
10942 !! end
10943
10944 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
10945 # since these are ExtLinkText, not MagicLinkText
10946 !! test
10947 Magic links: use appropriate serialization for "almost" magic links.
10948 !! wikitext
10949 X[[Special:BookSources/0978739256|foo]]
10950
10951 X[https://tools.ietf.org/html/rfc1234 foo]
10952 !! html/php
10953 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
10954 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
10955 </p>
10956 !! html/parsoid
10957 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
10958 <p>X<a rel="mw:ExtLink" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
10959 !! end
10960
10961 !! test
10962 Magic links: All disabled (T47942)
10963 !! options
10964 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
10965 !! wikitext
10966 ISBN 0-306-40615-2
10967 PMID 1234
10968 RFC 4321
10969 !! html/php
10970 <p>ISBN 0-306-40615-2
10971 PMID 1234
10972 RFC 4321
10973 </p>
10974 !! end
10975
10976 ###
10977 ### Templates
10978 ####
10979
10980 !! test
10981 Nonexistent template
10982 !! wikitext
10983 {{thistemplatedoesnotexist}}
10984 !! html
10985 <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>
10986 </p>
10987 !! end
10988
10989 !! test
10990 Template with invalid target containing tags
10991 !! wikitext
10992 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
10993 !! html
10994 <p>{{a<b>b</b>|foo|a=b|a = b}}
10995 </p>
10996 !! end
10997
10998 !! test
10999 Template with invalid target containing unclosed tag
11000 !! wikitext
11001 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11002 !! html
11003 <p>{{a<b>|foo|a=b|a = b}}</b>
11004 </p>
11005 !! end
11006
11007 !! test
11008 Template with invalid target containing wikilink
11009 !! wikitext
11010 {{[[Main Page]]}}
11011 !! html/php
11012 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11013 </p>
11014 !! html/parsoid
11015 <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>
11016 !! end
11017
11018 !! test
11019 Template with just whitespace in it, T70421
11020 !! wikitext
11021 {{echo|{{ }}}}
11022 !! html/parsoid
11023 <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>
11024 !! end
11025
11026 !! article
11027 Template:test
11028 !! text
11029 This is a test template
11030 !! endarticle
11031
11032 !! test
11033 Simple template
11034 !! wikitext
11035 {{test}}
11036 !! html
11037 <p>This is a test template
11038 </p>
11039 !! end
11040
11041 !! test
11042 Template with explicit namespace
11043 !! wikitext
11044 {{Template:test}}
11045 !! html
11046 <p>This is a test template
11047 </p>
11048 !! end
11049
11050
11051 !! article
11052 Template:paramtest
11053 !! text
11054 This is a test template with parameter {{{param}}}
11055 !! endarticle
11056
11057 !! test
11058 Template parameter
11059 !! wikitext
11060 {{paramtest|param=foo}}
11061 !! html
11062 <p>This is a test template with parameter foo
11063 </p>
11064 !! end
11065
11066 !! article
11067 Template:paramtestnum
11068 !! text
11069 [[{{{1}}}|{{{2}}}]]
11070 !! endarticle
11071
11072 !! test
11073 Template unnamed parameter
11074 !! wikitext
11075 {{paramtestnum|Main Page|the main page}}
11076 !! html
11077 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11078 </p>
11079 !! end
11080
11081 !! article
11082 Template:templatesimple
11083 !! text
11084 (test)
11085 !! endarticle
11086
11087 !! article
11088 Template:templateredirect
11089 !! text
11090 #redirect [[Template:templatesimple]]
11091 !! endarticle
11092
11093 !! article
11094 Template:templateasargtestnum
11095 !! text
11096 {{{{{1}}}}}
11097 !! endarticle
11098
11099 !! article
11100 Template:templateasargtest
11101 !! text
11102 {{template{{{templ}}}}}
11103 !! endarticle
11104
11105 !! article
11106 Template:templateasargtest2
11107 !! text
11108 {{{{{templ}}}}}
11109 !! endarticle
11110
11111 !! test
11112 Template with template name as unnamed argument
11113 !! wikitext
11114 {{templateasargtestnum|templatesimple}}
11115 !! html
11116 <p>(test)
11117 </p>
11118 !! end
11119
11120 !! test
11121 Template with template name as argument
11122 !! wikitext
11123 {{templateasargtest|templ=simple}}
11124 !! html
11125 <p>(test)
11126 </p>
11127 !! end
11128
11129 !! test
11130 Template with template name as argument (2)
11131 !! wikitext
11132 {{templateasargtest2|templ=templatesimple}}
11133 !! html
11134 <p>(test)
11135 </p>
11136 !! end
11137
11138 !! article
11139 Template:templateasargtestdefault
11140 !! text
11141 {{{{{templ|templatesimple}}}}}
11142 !! endarticle
11143
11144 !! article
11145 Template:templa
11146 !! text
11147 '''templ'''
11148 !! endarticle
11149
11150 !! test
11151 Template with default value
11152 !! wikitext
11153 {{templateasargtestdefault}}
11154 !! html
11155 <p>(test)
11156 </p>
11157 !! end
11158
11159 !! test
11160 Template with default value (value set)
11161 !! wikitext
11162 {{templateasargtestdefault|templ=templa}}
11163 !! html
11164 <p><b>templ</b>
11165 </p>
11166 !! end
11167
11168 !! test
11169 Template redirect
11170 !! wikitext
11171 {{templateredirect}}
11172 !! html/php
11173 <p>(test)
11174 </p>
11175 !! html/parsoid
11176 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11177 !! end
11178
11179 !! test
11180 Template with argument in separate line
11181 !! wikitext
11182 {{ templateasargtest |
11183 templ = simple }}
11184 !! html
11185 <p>(test)
11186 </p>
11187 !! end
11188
11189 !! test
11190 Template with complex template as argument
11191 !! wikitext
11192 {{paramtest|
11193 param ={{ templateasargtest |
11194 templ = simple }}}}
11195 !! html
11196 <p>This is a test template with parameter (test)
11197 </p>
11198 !! end
11199
11200 !! test
11201 Templates with templated name
11202 !! wikitext
11203 {{{{echo|echo}}|foo}}
11204 {{{{echo|inner list}} }}
11205 !! html
11206 <p>foo
11207 </p>
11208 <ul><li> item 1</li></ul>
11209
11210 !! html/parsoid
11211 <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>
11212 <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>
11213 !! end
11214
11215 ## Regression test; the output here isn't really that interesting.
11216 !! test
11217 Templates with templated name and top level template args
11218 !! wikitext
11219 {{1{{2{{{3}}}|4=5}}}}
11220 !! html/parsoid
11221 <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>
11222 !! end
11223
11224 # Parsoid markup is deliberate "broken". This is an edge case.
11225 # See long comment in TemplateHandler.js:convertAttribsToString.
11226 !! test
11227 Templates with invalid templated targets
11228 !! wikitext
11229 {{echo
11230 {{echo|foo}}
11231 }}
11232 !! html/php
11233 <p>{{echo
11234 foo
11235 }}
11236 </p>
11237 !! html/parsoid
11238 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11239 foo }}</p>
11240 !! end
11241
11242 !! test
11243 Template with thumb image (with link in description)
11244 !! wikitext
11245 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11246 !! html/php
11247 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>
11248
11249 !! html+tidy
11250 <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>
11251 !! html/parsoid
11252 <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>
11253 !! end
11254
11255 !! article
11256 Template:complextemplate
11257 !! text
11258 {{{1}}} {{paramtest|
11259 param ={{{param}}}}}
11260 !! endarticle
11261
11262 !! test
11263 Template with complex arguments
11264 !! wikitext
11265 {{complextemplate|
11266 param ={{ templateasargtest |
11267 templ = simple }}|[[Template:complextemplate|link]]}}
11268 !! html
11269 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11270 </p>
11271 !! end
11272
11273 !! test
11274 T2553: link with two variables in a piped link
11275 !! wikitext
11276 {|
11277 |[[{{{1}}}|{{{2}}}]]
11278 |}
11279 !! html/php
11280 <table>
11281 <tr>
11282 <td>[[{{{1}}}|{{{2}}}]]
11283 </td></tr></table>
11284
11285 !! html/parsoid
11286 <table>
11287 <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>
11288 </tbody></table>
11289 !! end
11290
11291 # See: T2553
11292 !! test
11293 Abort table cell attribute parsing on wikilink
11294 !! wikitext
11295 {|
11296 | testing [[one|two]] | three || four
11297 | testing one two | three || four
11298 | testing="[[one|two]]" | three || four
11299 |}
11300 !! html/php
11301 <table>
11302 <tr>
11303 <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>
11304 <td> four
11305 </td>
11306 <td> three </td>
11307 <td> four
11308 </td>
11309 <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>
11310 <td> four
11311 </td></tr></table>
11312
11313 !! html/parsoid
11314 <table>
11315 <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>
11316 <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>
11317 <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>
11318 </tbody></table>
11319 !! end
11320
11321 !! test
11322 Don't abort table cell attribute parsing if wikilink is found in template arg
11323 !! wikitext
11324 {|
11325 | Test {{#tag:ref|One two "[[three]]" four}}
11326 |}
11327 !! html/parsoid
11328 <table>
11329 <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>
11330 </tbody></table>
11331 !! end
11332
11333 !! test
11334 Magic variable as template parameter
11335 !! wikitext
11336 {{paramtest|param={{SITENAME}}}}
11337 !! html
11338 <p>This is a test template with parameter MediaWiki
11339 </p>
11340 !! end
11341
11342 !! article
11343 Template:linktest
11344 !! text
11345 [[{{{param}}}|link]]
11346 !! endarticle
11347
11348 !! test
11349 Template parameter as link source
11350 !! wikitext
11351 {{linktest|param=Main Page}}
11352 !! html
11353 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11354 </p>
11355 !! end
11356
11357 !!article
11358 Template:paramtest2
11359 !! text
11360 including another template, {{paramtest|param={{{arg}}}}}
11361 !! endarticle
11362
11363 !! test
11364 Template passing argument to another template
11365 !! wikitext
11366 {{paramtest2|arg='hmm'}}
11367 !! html
11368 <p>including another template, This is a test template with parameter 'hmm'
11369 </p>
11370 !! end
11371
11372 !! article
11373 Template:Linktest2
11374 !! text
11375 Main Page
11376 !! endarticle
11377
11378 !! test
11379 Template as link source
11380 !! wikitext
11381 [[{{linktest2}}]]
11382
11383 [[{{linktest2}}|Main Page]]
11384
11385 [[{{linktest2}}]]Page
11386 !! html
11387 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11388 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11389 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11390 </p>
11391 !! end
11392
11393
11394 !! article
11395 Template:loop1
11396 !! text
11397 {{loop2}}
11398 !! endarticle
11399
11400 !! article
11401 Template:loop2
11402 !! text
11403 {{loop1}}
11404 !! endarticle
11405
11406 !! test
11407 Template infinite loop
11408 !! wikitext
11409 {{loop1}}
11410 !! html
11411 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11412 </p>
11413 !! end
11414
11415 !! test
11416 Template from main namespace
11417 !! wikitext
11418 {{:Main Page}}
11419 !! html
11420 <p>blah blah
11421 </p>
11422 !! end
11423
11424 !! article
11425 Template:table
11426 !! text
11427 {|
11428 | 1 || 2
11429 |-
11430 | 3 || 4
11431 |}
11432 !! endarticle
11433
11434 !! test
11435 T2529: Template with table, not included at beginning of line
11436 !! wikitext
11437 foo {{table}}
11438 !! html
11439 <p>foo
11440 </p>
11441 <table>
11442 <tr>
11443 <td> 1 </td>
11444 <td> 2
11445 </td></tr>
11446 <tr>
11447 <td> 3 </td>
11448 <td> 4
11449 </td></tr></table>
11450
11451 !! end
11452
11453 !! test
11454 T2523: Template shouldn't eat newline (or add an extra one before table)
11455 !! wikitext
11456 foo
11457 {{table}}
11458 !! html
11459 <p>foo
11460 </p>
11461 <table>
11462 <tr>
11463 <td> 1 </td>
11464 <td> 2
11465 </td></tr>
11466 <tr>
11467 <td> 3 </td>
11468 <td> 4
11469 </td></tr></table>
11470
11471 !! end
11472
11473 !! test
11474 T2041: Template parameters shown as broken links
11475 !! wikitext
11476 {{{parameter}}}
11477 !! html
11478 <p>{{{parameter}}}
11479 </p>
11480 !! end
11481
11482 !! test
11483 Template with targets containing wikilinks
11484 !! options
11485 parsoid=wt2html
11486 !! wikitext
11487 {{[[foo]]}}
11488
11489 {{[[{{echo|foo}}]]}}
11490
11491 {{{{echo|[[foo}}]]}}
11492 !! html/php
11493 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11494 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11495 </p><p>{{[[foo}}]]
11496 </p>
11497 !! html/parsoid
11498 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11499 <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>
11500 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11501 !! end
11502
11503 !! article
11504 Template:''
11505 !! text
11506 bar
11507 !! endarticle
11508
11509 !! test
11510 Templates: Double quotes as template target
11511 !! wikitext
11512 foo {{''}} baz
11513 !! html/php
11514 <p>foo bar baz
11515 </p>
11516 !! html/parsoid
11517 <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
11518 </p>
11519 !! end
11520
11521 ## This test is about making sure Parsoid's data-mw is well formed in the
11522 ## face of multiple templates with intersecting and overlapping ranges. The
11523 ## wikitext itself is wretched.
11524 !! test
11525 Templates with intersecting and overlapping ranges
11526 !! wikitext
11527 {|{{echo|
11528 <p>ha</p>}}
11529 {|{{echo|
11530 <p>ho</p>}}
11531 {{echo|{{!}}hi}}
11532 |}
11533 !! html/php+tidy
11534 <p>ha</p><table>
11535
11536 </table><p>ho</p><table>
11537
11538 <tbody><tr>
11539 <td>hi
11540 </td></tr></tbody></table>
11541 !! html/parsoid
11542 <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":""}]]}'>
11543
11544 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11545
11546 <tbody><tr><td>hi</td></tr>
11547 </tbody></table>
11548 !! end
11549
11550 !! article
11551 Template:MSGNW test
11552 !! text
11553 ''None'' of '''this''' should be
11554 * interpreted
11555 but rather passed unmodified
11556 {{test}}
11557 <gallery>
11558 File:Foobar.jpg
11559 </gallery>
11560 <!-- comment -->
11561 !! endarticle
11562
11563 # hmm, fix this or just deprecate msgnw and document its behavior?
11564 !! test
11565 msgnw keyword
11566 !! wikitext
11567 {{msgnw:MSGNW test}}
11568 !! html/php
11569 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11570 &#42; interpreted
11571 &#32;but rather passed unmodified
11572 &#123;&#123;test&#125;&#125;
11573 &#60;gallery&#62;
11574 File:Foobar.jpg
11575 &#60;/gallery&#62;
11576 &#60;!-- comment --&#62;
11577 </p>
11578 !! end
11579
11580 !! test
11581 int keyword
11582 !! wikitext
11583 {{int:youhavenewmessages|lots of money|not!}}
11584 !! html
11585 <p>You have lots of money (not!).
11586 </p>
11587 !! end
11588
11589 !! test
11590 int keyword - non-existing message
11591 !! wikitext
11592 {{int:var}}
11593 !! html
11594 <p>⧼var⧽
11595 </p>
11596 !! end
11597
11598 !! article
11599 Template:Includes
11600 !! text
11601 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11602 !! endarticle
11603
11604 !! test
11605 <includeonly> and <noinclude> being included
11606 !! wikitext
11607 {{Includes}}
11608 !! html
11609 <p>Foobar
11610 </p>
11611 !! end
11612
11613 !! article
11614 Template:Includes2
11615 !! text
11616 <onlyinclude>Foo</onlyinclude>bar
11617 !! endarticle
11618
11619 !! test
11620 <onlyinclude> being included
11621 !! wikitext
11622 {{Includes2}}
11623 !! html
11624 <p>Foo
11625 </p>
11626 !! end
11627
11628
11629 !! article
11630 Template:Includes3
11631 !! text
11632 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
11633 !! endarticle
11634
11635 !! test
11636 <onlyinclude> and <includeonly> being included
11637 !! wikitext
11638 {{Includes3}}
11639 !! html
11640 <p>Foo
11641 </p>
11642 !! end
11643
11644 !! test
11645 <includeonly> and <noinclude> on a page
11646 !! wikitext
11647 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11648 !! html
11649 <p>Foozar
11650 </p>
11651 !! end
11652
11653 !! test
11654 Un-closed <noinclude>
11655 !! wikitext
11656 <noinclude>
11657 !! html
11658 !! end
11659
11660 !! test
11661 <onlyinclude> on a page
11662 !! wikitext
11663 <onlyinclude>Foo</onlyinclude>bar
11664 !! html
11665 <p>Foobar
11666 </p>
11667 !! end
11668
11669 !! test
11670 Un-closed <onlyinclude>
11671 !! wikitext
11672 <onlyinclude>
11673 !! html
11674 !! end
11675
11676 !!test
11677 Self-closed noinclude, includeonly, onlyinclude tags
11678 !! wikitext
11679 <noinclude />
11680 <includeonly />
11681 <onlyinclude />
11682 !! html
11683 <p><br />
11684 </p>
11685 !!end
11686
11687 !!test
11688 Unbalanced includeonly and noinclude tags
11689 !! wikitext
11690 {|
11691 |a</noinclude>
11692 |b</noinclude></noinclude>
11693 |c</noinclude></includeonly>
11694 |d</includeonly></includeonly>
11695 |}
11696 !! html
11697 <table>
11698 <tr>
11699 <td>a
11700 </td>
11701 <td>b
11702 </td>
11703 <td>c&lt;/includeonly&gt;
11704 </td>
11705 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
11706 </td></tr></table>
11707
11708 !!end
11709
11710 !! article
11711 Template:Includeonly section
11712 !! text
11713 <includeonly>
11714 ==Includeonly section==
11715 </includeonly>
11716 ==Section T-1==
11717 !!endarticle
11718
11719 !! test
11720 T8563: Edit link generation for section shown by <includeonly>
11721 !! wikitext
11722 {{includeonly section}}
11723 !! html
11724 <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>
11725 <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>
11726
11727 !! end
11728
11729 # Uses same input as the contents of [[Template:Includeonly section]]
11730 !! test
11731 T8563: Section extraction for section shown by <includeonly>
11732 !! options
11733 section=T-2
11734 !! wikitext
11735 <includeonly>
11736 ==Includeonly section==
11737 </includeonly>
11738 ==Section T-2==
11739 !! html
11740 ==Section T-2==
11741 !! end
11742
11743 !! test
11744 T8563: Edit link generation for section suppressed by <includeonly>
11745 !! wikitext
11746 <includeonly>
11747 ==Includeonly section==
11748 </includeonly>
11749 ==Section 1==
11750 !! html
11751 <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>
11752
11753 !! end
11754
11755 !! test
11756 T8563: Section extraction for section suppressed by <includeonly>
11757 !! options
11758 section=1
11759 !! wikitext
11760 <includeonly>
11761 ==Includeonly section==
11762 </includeonly>
11763 ==Section 1==
11764 !! html
11765 ==Section 1==
11766 !! end
11767
11768 !! test
11769 Un-closed <includeonly>
11770 !! wikitext
11771 <includeonly>
11772 !! html/php
11773 !! html/parsoid
11774 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}'/>
11775 !! end
11776
11777 ## We used to, but no longer wt2wt this test since the default serializer
11778 ## will normalize the include directives to serialize on their own line.
11779 ## Selser will take care of preserving formatting in scenarios where they
11780 ## intermingled with other wikitext.
11781 !! test
11782 Includes and comments at SOL
11783 !! options
11784 parsoid=wt2html,html2html
11785 !! wikitext
11786 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->== hu ==
11787
11788 <noinclude>
11789 some
11790 </noinclude>* stuff
11791 * here
11792
11793 <includeonly>can have stuff</includeonly>=== here ===
11794
11795 !! html/php
11796 <h2><span class="mw-headline" id="hu">hu</span></h2>
11797 <p>some
11798 </p>
11799 <ul><li> stuff</li>
11800 <li> here</li></ul>
11801 <h3><span class="mw-headline" id="here">here</span></h3>
11802
11803 !! html/parsoid
11804 <!-- 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>
11805
11806 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
11807 <p>some</p>
11808 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li> stuff</li>
11809 <li> here</li></ul>
11810
11811 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>can have stuff&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><h3 id="here"> here </h3>
11812
11813 !! end
11814
11815 # TODO: test with DOM fragment reuse!
11816 !! test
11817 Parsoid: DOM fragment reuse
11818 !! options
11819 parsoid=wt2wt,wt2html
11820 !! wikitext
11821 a{{echo|b<table></table>c}}d
11822
11823 a{{echo|b
11824 <table></table>
11825 c}}d
11826
11827 {{echo|a
11828
11829 <table></table>
11830
11831 b}}
11832 !! html
11833 <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>
11834
11835 <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">
11836 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
11837 </span><p about="#mwt2">cd</p>
11838
11839 <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">
11840
11841 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
11842
11843 </span><p about="#mwt3">b</p>
11844 !! end
11845
11846 !! test
11847 Parsoid: Merge double tds (T52603)
11848 !! options
11849 parsoid
11850 !! wikitext
11851 {|
11852 |{{echo|{{!}} foo}}
11853 |}
11854 !! html
11855 <table><tbody>
11856 <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>
11857 </tbody></table>
11858 !! end
11859
11860 !! test
11861 Parsoid: Merge double tds in nested transclusion content (T52603)
11862 !! options
11863 parsoid
11864 !! wikitext
11865 {{echo|<div>}}
11866 {|
11867 |{{echo|{{!}} foo}}
11868 |}
11869 {{echo|</div>}}
11870 !! html
11871 <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}}]}'>
11872 <table><tbody>
11873 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
11874 </tbody></table>
11875 </div>
11876 !! end
11877
11878 ###
11879 ### <includeonly> and <noinclude> in attributes
11880 ###
11881 !!test
11882 0. includeonly around the entire attribute
11883 !! wikitext
11884 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
11885 !! html
11886 <p><span id="v2">bar</span>
11887 </p>
11888 !!end
11889
11890 !!test
11891 1. includeonly in html attr key
11892 !! wikitext
11893 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
11894 !! html
11895 <p><span id="foo">bar</span>
11896 </p>
11897 !!end
11898
11899 !!test
11900 2. includeonly in html attr value
11901 !! wikitext
11902 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
11903 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
11904 !! html
11905 <p><span id="v1">bar</span>
11906 <span id="v1">bar</span>
11907 </p>
11908 !!end
11909
11910 !!test
11911 3. includeonly in part of an attr value
11912 !! wikitext
11913 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
11914 !! html
11915 <p><span style="color:red;">bar</span>
11916 </p>
11917 !!end
11918
11919 !!test
11920 4. includeonly in table attributes
11921 !! wikitext
11922 {|
11923 |- <noinclude>
11924 |-
11925 |a
11926 </noinclude>
11927 |- <includeonly>
11928 |-
11929 |b
11930 </includeonly>
11931 |}
11932 !! html
11933 <table>
11934
11935
11936 <tr>
11937 <td>a
11938 </td></tr>
11939 </table>
11940
11941 !!end
11942
11943 ###
11944 ### Preprocessor precedence tests
11945 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
11946 ###
11947 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
11948 !! test
11949 Preprocessor precedence 1: link is rightmost opening
11950 !! options
11951 parsoid=wt2html
11952 !! wikitext
11953 {{[[Foo|bar}}]]
11954
11955 But close-brace is not a valid character in a link title:
11956 {{[[Foo}}|bar]]
11957
11958 However, we can still tell this was handled as a link in the preprocessor:
11959 {{echo|[[Foo}}|bar]]|bat}}
11960 !! html/php
11961 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
11962 </p><p>But close-brace is not a valid character in a link title:
11963 {{[[Foo}}|bar]]
11964 </p><p>However, we can still tell this was handled as a link in the preprocessor:
11965 [[Foo}}|bar]]
11966 </p>
11967 !! html/parsoid
11968 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
11969 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
11970 <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>
11971 !! end
11972
11973 !! test
11974 Preprocessor precedence 2: template is rightmost opening
11975 !! options
11976 language=zh
11977 !! wikitext
11978 -{{echo|foo}-}}-
11979 !! html/php
11980 <p>-foo}--
11981 </p>
11982 !! html/parsoid
11983 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
11984 !! end
11985
11986 !! test
11987 Preprocessor precedence 3: language converter is rightmost opening
11988 !! options
11989 language=zh
11990 parsoid=wt2html
11991 !! wikitext
11992 {{echo|hi}}
11993
11994 {{-{R|echo|hi}}}-
11995
11996 [[-{R|raw]]}-
11997 !! html/php
11998 <p>hi
11999 </p><p>{{echo|hi}}
12000 </p><p>[[raw]]
12001 </p>
12002 !! html/parsoid
12003 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12004 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12005 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12006 !! end
12007
12008 !! test
12009 Preprocessor precedence 4: left-most angle bracket
12010 !! options
12011 language=zh
12012 !! wikitext
12013 <!--{raw}-->
12014 !! html/php
12015 !! html/parsoid
12016 <!--{raw}-->
12017 !! end
12018
12019 !! article
12020 Template:Precedence5
12021 !! text
12022 {{{{{1}}}}}
12023 !! endarticle
12024
12025 !! test
12026 Preprocessor precedence 5: tplarg takes precedence over template
12027 !! wikitext
12028 {{Precedence5|Bullet}}
12029 !! html/php
12030 <ul><li> Bar</li></ul>
12031
12032 !! html/parsoid
12033 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li> Bar</li></ul>
12034 !! end
12035
12036 !! test
12037 Preprocessor precedence 6: broken link is rightmost opening
12038 !! options
12039 parsoid=wt2html
12040 !! wikitext
12041 {{echo|[[Foo}}
12042
12043 {{echo|[[Foo|bar|bat=baz}}
12044 !! html/php
12045 <p>{{echo|[[Foo}}
12046 </p><p>{{echo|[[Foo|bar|bat=baz}}
12047 </p>
12048 !! html/parsoid
12049 <p>{{echo|[[Foo}}</p>
12050 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12051 !! end
12052
12053 # This next test exposes a difference between PHP and Parsoid:
12054 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12055 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12056 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12057 # outer `[[Foo` extends until the `y]]`
12058 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12059 # intermediate result (after template expansion), and link processing
12060 # happens on this intermediate result, which moves the wikilink
12061 # boundary leftward to `[[Foo|Bar]]`
12062 # 2b) Parsoid works in a single step, so it's going to keep the
12063 # wikilink as extending to the `y]]`
12064 # 3a) Then PHP does linktrail processing which slurps up the trailing
12065 # `xy` inside the link.
12066 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12067 # `z` inside the link.
12068 # This is "correct" behavior. Parsoid's basic worldview is that the
12069 # `]]` inside the template shouldn't be allowed to leak out to affect
12070 # the surrounding wikilink. PHP may match Parsoid (in the future)
12071 # if you use {{#balance}} (T114445).
12072
12073 !! test
12074 Preprocessor precedence 7: broken template is rightmost opening
12075 !! options
12076 parsoid=wt2html
12077 !! wikitext
12078 [[Foo|{{echo|Bar]]
12079
12080 [[Foo|{{echo|Bar]]-x}}-y]]-z
12081
12082 Careful: linktrails can move the end of the wikilink:
12083 [[Foo|{{echo|y']]a}}l]]l
12084 !! html/php
12085 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12086 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12087 </p><p>Careful: linktrails can move the end of the wikilink:
12088 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12089 </p>
12090 !! html/parsoid
12091 <p>[[Foo|{{echo|Bar]]</p>
12092 <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>
12093 <p>Careful: linktrails can move the end of the wikilink:
12094 <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>
12095 !! end
12096
12097 !! test
12098 Preprocessor precedence 8: broken language converter is rightmost opening
12099 !! options
12100 language=zh
12101 !! wikitext
12102 [[Foo-{R|raw]]
12103 !! html
12104 <p>[[Foo-{R|raw]]
12105 </p>
12106 !! end
12107
12108 !! article
12109 Template:Preprocessor_precedence_9
12110 !! text
12111 ;4: {{{{1}}}}
12112 ;5: {{{{{2}}}}}
12113 ;6: {{{{{{3}}}}}}
12114 ;7: {{{{{{{4}}}}}}}
12115 !! endarticle
12116
12117 !! test
12118 Preprocessor precedence 9: groups of braces
12119 !! wikitext
12120 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12121 !! html/php
12122 <dl><dt>4</dt>
12123 <dd> {Four}</dd>
12124 <dt>5</dt>
12125 <dd> </dd></dl>
12126 <ul><li> Bar</li></ul>
12127 <dl><dt>6</dt>
12128 <dd> Four</dd>
12129 <dt>7</dt>
12130 <dd> {Bullet}</dd></dl>
12131
12132 !! html/parsoid
12133 <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}}]}'>
12134 <dt>4</dt>
12135 <dd>{Four}</dd>
12136 <dt>5</dt>
12137 <dd></dd>
12138 </dl><ul about="#mwt1">
12139 <li>Bar</li>
12140 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12141 <dt>6</dt>
12142 <dd>Four</dd>
12143 <dt>7</dt>
12144 <dd>{Bullet}</dd>
12145 </dl>
12146 !! end
12147
12148 !! article
12149 Template:Preprocessor_precedence_10
12150 !! text
12151 ;1: -{R|raw}-
12152 ;2: -{{Bullet}}-
12153 ;3: -{{{1}}}-
12154 ;4: -{{{{2}}}}-
12155 ;5: -{{{{{3}}}}}-
12156 ;6: -{{{{{{4}}}}}}-
12157 ;7: -{{{{{{{5}}}}}}}-
12158 !! endarticle
12159
12160 !! test
12161 Preprocessor precedence 10: groups of braces with leading dash
12162 !! options
12163 language=zh
12164 !! wikitext
12165 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12166 !! html/php
12167 <dl><dt>1</dt>
12168 <dd> raw</dd>
12169 <dt>2</dt>
12170 <dd> -</dd></dl>
12171 <ul><li> Bar-</li></ul>
12172 <dl><dt>3</dt>
12173 <dd> -Three-</dd>
12174 <dt>4</dt>
12175 <dd> raw2</dd>
12176 <dt>5</dt>
12177 <dd> -</dd></dl>
12178 <ul><li> Bar-</li></ul>
12179 <dl><dt>6</dt>
12180 <dd> -Three-</dd>
12181 <dt>7</dt>
12182 <dd> raw2</dd></dl>
12183
12184 !! html/parsoid
12185 <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}}]}'>
12186 <dt>1</dt>
12187 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12188 <dt>2</dt>
12189 <dd>-</dd>
12190 </dl><ul about="#mwt1">
12191 <li>Bar-</li>
12192 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12193 <dt>3</dt>
12194 <dd>-Three-</dd>
12195 <dt>4</dt>
12196 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12197 <dt>5</dt>
12198 <dd>-</dd>
12199 </dl><ul about="#mwt1">
12200 <li>Bar-</li>
12201 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12202 <dt>6</dt>
12203 <dd>-Three-</dd>
12204 <dt>7</dt>
12205 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12206 </dl>
12207 !! end
12208
12209 !! test
12210 Preprocessor precedence 11: found during visual diff testing
12211 !! wikitext
12212 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12213
12214 {{echo|-{{echo|-{{echo|x}}}}}}
12215
12216 {{echo|-{{echo|x}}}}
12217 !! html/php
12218 <p><span>-<span>-x</span></span>
12219 </p><p>--x
12220 </p><p>-x
12221 </p>
12222 !! html/parsoid
12223 <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>
12224
12225 <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>
12226
12227 <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>
12228 !! end
12229
12230 !! test
12231 Preprocessor precedence 12: broken language converter closed by brace.
12232 !! options
12233 parsoid=wt2html
12234 !! wikitext
12235 This form breaks the template, which is unfortunate:
12236 * {{echo|foo-{bar}bat}}
12237
12238 But if the broken language converter markup is inside an extension
12239 tag, nothing bad happens:
12240 * <nowiki>foo-{bar}bat</nowiki>
12241 * {{echo|<nowiki>foo-{bar}bat</nowiki>}}
12242 * <pre>foo-{bar}bat</pre>
12243 * {{echo|<pre>foo-{bar}bat</pre>}}
12244
12245 <tag>foo-{bar}bat</tag>
12246 {{echo|<tag>foo-{bar}bat</tag>}}
12247
12248 !! html/php+tidy
12249 <p>This form breaks the template, which is unfortunate:
12250 </p>
12251 <ul><li> {{echo|foo-{bar}bat}}</li></ul>
12252 <p>But if the broken language converter markup is inside an extension
12253 tag, nothing bad happens:
12254 </p>
12255 <ul><li> foo-&#123;bar}bat</li>
12256 <li> foo-&#123;bar}bat</li>
12257 <li> <pre>foo-{bar}bat</pre></li>
12258 <li> <pre>foo-{bar}bat</pre></li></ul>
12259 <pre>'foo-{bar}bat'
12260 array (
12261 )
12262 </pre>
12263 <pre>'foo-{bar}bat'
12264 array (
12265 )
12266 </pre>
12267 !! html/parsoid
12268 <p>This form breaks the template, which is unfortunate:</p>
12269 <ul>
12270 <li>{{echo|foo-{bar}bat}}</li>
12271 </ul>
12272 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12273 <ul>
12274 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12275 <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>
12276 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12277 <li><pre typeof="mw:Transclusion mw:Extension/pre" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;pre>foo-{bar}bat&lt;/pre>"}},"i":0}}]}'>foo-{bar}bat</pre></li>
12278 </ul>
12279 <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>
12280 !! end
12281
12282 !! test
12283 Preprocessor precedence 13: broken language converter in external link
12284 !! options
12285 parsoid=wt2html
12286 !! wikitext
12287 * [http://example.com/-{foo Example in URL]
12288 * [http://example.com Example in -{link} description]
12289 * {{echo|[http://example.com/-{foo Breaks template, however]}}
12290 !! html/php+tidy
12291 <ul><li> <a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12292 <li> <a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12293 <li> {{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li></ul>
12294 !! html/parsoid
12295 <ul>
12296 <li><a rel="mw:ExtLink" href="http://example.com/-{foo">Example in URL</a></li>
12297 <li><a rel="mw:ExtLink" href="http://example.com">Example in -{link} description</a></li>
12298 <li>{{echo|<a rel="mw:ExtLink" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12299 </ul>
12300 !! end
12301
12302 !! test
12303 Preprocessor precedence 14: broken language converter in comment
12304 !! wikitext
12305 * <!--{{foo}}--> ...should be ok
12306 * <!---{{foo}}--> ...extra dashes
12307 * {{echo|foo<!-- -{bar} -->bat}} ...should be ok
12308 !! html/php+tidy
12309 <ul><li> ...should be ok</li>
12310 <li> ...extra dashes</li>
12311 <li> foobat ...should be ok</li></ul>
12312 !! html/parsoid
12313 <ul>
12314 <li><!--{{foo}}--> ...should be ok</li>
12315 <li><!--&#x2D;{{foo}}--> ...extra dashes</li>
12316 <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>
12317 </ul>
12318 !! end
12319
12320 !! test
12321 Preprocessor precedence 15: broken brace markup in headings
12322 !! config
12323 wgFragmentMode=[ 'html5', 'legacy' ]
12324 !! options
12325 parsoid=wt2html
12326 !! wikitext
12327 __NOTOC__ __NOEDITSECTION__
12328 ===1 foo[bar 1===
12329 1
12330 ===2 foo[[bar 2===
12331 2
12332 ===3 foo{bar 3===
12333 3
12334 ===4 foo{{bar 4===
12335 4
12336 ===5 foo{{{bar 5===
12337 5
12338 ===6 foo-{bar 6===
12339 6
12340 !! html/php+tidy
12341 <h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3>
12342 <p>1
12343 </p>
12344 <h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3>
12345 <p>2
12346 </p>
12347 <h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3>
12348 <p>3
12349 </p>
12350 <h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3>
12351 <p>4
12352 </p>
12353 <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>
12354 <p>5
12355 </p>
12356 <h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3>
12357 <p>6
12358 </p>
12359 !! html/parsoid
12360 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/>
12361 <h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3>
12362 <p>1</p>
12363 <h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3>
12364 <p>2</p>
12365 <h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3>
12366 <p>3</p>
12367 <h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3>
12368 <p>4</p>
12369 <h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3>
12370 <p>5</p>
12371 <h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3>
12372 <p>6</p>
12373 !! end
12374
12375 !! test
12376 Preprocessor precedence 16: matching closing braces to opening braces
12377 !! options
12378 language=zh
12379 parsoid=wt2html
12380 !! wikitext
12381 -{{{echo|foo}}bar}-
12382 !! html/php
12383 <p>foobar
12384 </p>
12385 !! html/parsoid
12386 <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>
12387 !! end
12388
12389 !! test
12390 Preprocessor precedence 17: template w/o target shouldn't prevent closing
12391 !! options
12392 parsoid=wt2html
12393 !! wikitext
12394 {{echo|hi {{}}}}
12395 !! html/php
12396 <p>hi {{}}
12397 </p>
12398 !! html/parsoid
12399 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p>
12400 !! end
12401
12402 ###
12403 ### Token Stream Patcher tests
12404 ###
12405 ### These tests won't always pass wt2wt and other modes because
12406 ### on serialization, the table will be output on a new line.
12407 ### For now, we are blacklisting them, and using this to test selser.
12408 ###
12409
12410 !!test
12411 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12412 !!options
12413 parsoid=wt2html,wt2wt
12414 !!wikitext
12415 {{echo|}}{| width = '100%'
12416 |foo
12417 |}
12418 !!html/parsoid
12419 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12420 <tbody><tr><td>foo</td></tr>
12421 </tbody></table>
12422 !!end
12423
12424 ## We used to, but no longer wt2wt this test since the default serializer
12425 ## will normalize the include directives to serialize on their own line.
12426 ## Selser will take care of preserving formatting in scenarios where they
12427 ## intermingled with other wikitext.
12428 !!test
12429 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12430 !!options
12431 parsoid=wt2html
12432 !!wikitext
12433 <includeonly>a</includeonly>{| {{{b}}}
12434 |c
12435 |}
12436 !!html/parsoid
12437 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>a&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><table about="#mwt2" typeof="mw:ExpandedAttrs" data-parsoid='{"a":{"{{{b}}}":null},"sa":{"{{{b}}}":""}}' data-mw='{"attribs":[[{"txt":"{{{b}}}","html":"&lt;span about=\"#mwt1\" typeof=\"mw:Param\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[31,38,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"templatearg\":{\"target\":{\"wt\":\"b\"},\"params\":{},\"i\":0}}]}&#39;>{{{b}}}&lt;/span>"},{"html":""}]]}'>
12438 <tbody><tr><td>c</td></tr>
12439 </tbody></table>
12440 !!end
12441
12442 !! test
12443 Table wikitext syntax outside wiki-tables
12444 !! wikitext
12445 a
12446 |+ not a caption
12447 ! not a table heading
12448 |- not a table row
12449 | not a table cell
12450 | class="foo bar" | baz
12451 b
12452 |}
12453 |-
12454 c
12455 !! html
12456 <p>a
12457 |+ not a caption
12458 ! not a table heading
12459 |- not a table row
12460 | not a table cell
12461 | class="foo bar" | baz
12462 b
12463 |}
12464 |-
12465 c
12466 </p>
12467 !! end
12468
12469 ###
12470 ### Testing parsing of templates where a template arg
12471 ### has the same name as the template itself.
12472 ###
12473
12474 !! article
12475 Template:quote
12476 !! text
12477 {{{quote|{{{1}}}}}}
12478 !! endarticle
12479
12480 !!test
12481 Templates: Template Name/Arg clash: 1. Use of positional param
12482 !! wikitext
12483 {{quote|foo}}
12484 !! html
12485 <p>foo
12486 </p>
12487 !!end
12488
12489 !!test
12490 Templates: Template Name/Arg clash: 2. Use of named param
12491 !! wikitext
12492 {{quote|quote=foo}}
12493 !! html
12494 <p>foo
12495 </p>
12496 !!end
12497
12498 !!test
12499 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12500 !! wikitext
12501 {{quote|quote}}
12502 !! html
12503 <p>quote
12504 </p>
12505 !!end
12506
12507 ###
12508 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12509 ###
12510
12511 !!test
12512 Templates: 1. Simple use
12513 !! wikitext
12514 {{echo|Foo}}
12515 !! html
12516 <p>Foo
12517 </p>
12518 !!end
12519
12520 !!test
12521 Templates: 2. Inside a block tag
12522 !! wikitext
12523 <div>{{echo|Foo}}</div>
12524 <blockquote>{{echo|Foo}}</blockquote>
12525 !! html
12526 <div>Foo</div>
12527 <blockquote>Foo</blockquote>
12528
12529 !! html+tidy
12530 <div>Foo</div>
12531 <blockquote><p>Foo</p></blockquote>
12532 !!end
12533
12534 !!test
12535 Templates: P-wrapping: 1a. Templates on consecutive lines
12536 !! wikitext
12537 {{echo|Foo}}
12538 {{echo|bar}}
12539 !! html
12540 <p>Foo
12541 bar
12542 </p>
12543 !!end
12544
12545 !!test
12546 Templates: P-wrapping: 1b. Templates on consecutive lines
12547 !! wikitext
12548 Foo
12549
12550 {{echo|bar}}
12551 {{echo|baz}}
12552 !! html
12553 <p>Foo
12554 </p><p>bar
12555 baz
12556 </p>
12557 !!end
12558
12559 !!test
12560 Templates: P-wrapping: 1c. Templates on consecutive lines
12561 !! wikitext
12562 {{echo|Foo}}
12563 {{echo|bar}} <div>baz</div>
12564 !! html
12565 <p>Foo
12566 </p>
12567 bar <div>baz</div>
12568
12569 !! html+tidy
12570 <p>Foo
12571 </p><p>
12572 bar </p><div>baz</div>
12573 !! end
12574
12575 !!test
12576 Templates: P-wrapping: 1d. Template preceded by comment-only line
12577 !!options
12578 parsoid
12579 !! wikitext
12580 <!-- foo -->
12581 {{echo|Bar}}
12582 !! html
12583 <!-- foo -->
12584
12585 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
12586 !!end
12587
12588 !!test
12589 Templates: Inline Text: 1. Multiple template uses
12590 !! wikitext
12591 {{echo|Foo}}bar{{echo|baz}}
12592 !! html
12593 <p>Foobarbaz
12594 </p>
12595 !!end
12596
12597 !!test
12598 Templates: Inline Text: 2. Back-to-back template uses
12599 !! wikitext
12600 {{echo|Foo}}{{echo|bar}}
12601 !! html
12602 <p>Foobar
12603 </p>
12604 !!end
12605
12606 !!test
12607 Templates: Block Tags: 1. Multiple template uses
12608 !! wikitext
12609 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
12610 !! html
12611 <div>Foo</div><div>bar</div><div>baz</div>
12612
12613 !!end
12614
12615 !!test
12616 Templates: Block Tags: 2. Back-to-back template uses
12617 !! wikitext
12618 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
12619 !! html
12620 <div>Foo</div><div>bar</div>
12621
12622 !!end
12623
12624 # This is an edge case relating to paragraph wrapping.
12625 !!test
12626 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
12627 !! wikitext
12628 {{echo|a
12629 b</p>}}
12630 !! html/parsoid
12631 <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
12632 b</p>
12633 !!end
12634
12635 !!test
12636 Templates: Links: 1. Simple example
12637 !! wikitext
12638 {{echo|[[Foo|bar]]}}
12639 !! html
12640 <p><a href="/wiki/Foo" title="Foo">bar</a>
12641 </p>
12642 !!end
12643
12644 !!test
12645 Templates: Links: 2. Generation of link href
12646 !! wikitext
12647 [[{{echo|Foo}}|bar]]
12648 !! html
12649 <p><a href="/wiki/Foo" title="Foo">bar</a>
12650 </p>
12651 !!end
12652
12653 !!test
12654 Templates: Links: 3. Generation of part of a link href
12655 !! wikitext
12656 [[Fo{{echo|o}}|bar]]
12657
12658 [[Foo{{echo|bar}}]]
12659
12660 [[Foo{{echo|bar}}baz]]
12661
12662 [[Foo{{echo|bar}}|bar]]
12663
12664 [[:Foo{{echo|bar}}]]
12665
12666 [[:Foo{{echo|bar}}|bar]]
12667 !! html
12668 <p><a href="/wiki/Foo" title="Foo">bar</a>
12669 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12670 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
12671 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12672 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12673 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12674 </p>
12675 !!end
12676
12677 !!test
12678 Templates: Links: 4. Multiple templates generating link href
12679 !! wikitext
12680 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
12681 !! html
12682 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12683 </p>
12684 !!end
12685
12686 !!test
12687 Templates: Links: 5. Generation of link text
12688 !! wikitext
12689 [[Foo|{{echo|bar}}]]
12690 !! html
12691 <p><a href="/wiki/Foo" title="Foo">bar</a>
12692 </p>
12693 !!end
12694
12695 !!test
12696 Templates: Links: 5. Nested templates (only outermost template should be marked)
12697 !! wikitext
12698 {{echo|[[{{echo|Foo}}|bar]]}}
12699 !! html
12700 <p><a href="/wiki/Foo" title="Foo">bar</a>
12701 </p>
12702 !!end
12703
12704 !!test
12705 Templates: HTML Tag: 1. Generation of HTML attr. key
12706 !! wikitext
12707 <div {{echo|style}}="color:red;">foo</div>
12708 !! html
12709 <div style="color:red;">foo</div>
12710
12711 !!end
12712
12713 !!test
12714 Templates: HTML Tag: 2. Generation of HTML attr. value
12715 !! wikitext
12716 <div style={{echo|'color:red;'}}>foo</div>
12717 !! html
12718 <div style="color:red;">foo</div>
12719
12720 !!end
12721
12722 !!test
12723 Templates: HTML Tag: 3. Generation of HTML attr key and value
12724 !! wikitext
12725 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
12726 !! html
12727 <div style="color:red;">foo</div>
12728
12729 !!end
12730
12731 !!test
12732 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
12733 !! wikitext
12734 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
12735 !! html
12736 <div title="This is a long title with just one piece templated">foo</div>
12737
12738 !!end
12739
12740 !!test
12741 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
12742 !! wikitext
12743 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
12744 !! html
12745 <div title="This is a long title with just one piece templated">foo</div>
12746
12747 !!end
12748
12749 !!test
12750 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
12751 !! wikitext
12752 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
12753 !! html
12754 <div title="This is a long title with just one piece templated">foo</div>
12755
12756 !!end
12757
12758 # SSS FIXME: While it is great we added support for all this,
12759 # do we want to make this part of the spec? Maybe we want to
12760 # deprecate this kind of usage in the future?
12761 !!test
12762 Templates: HTML Tag: 7. Generation of partial attribute key string
12763 !! wikitext
12764 <div st{{echo|yle}}="color:red;">foo</div>
12765 !! html
12766 <div style="color:red;">foo</div>
12767
12768 !!end
12769
12770 !! test
12771 Templates: HTML Tag: 8. Template-generated attribute (k=v)
12772 !! wikitext
12773 <div {{echo|1=id="v1"}}>bar</div>
12774 !! html
12775 <div id="v1">bar</div>
12776
12777 !!end
12778
12779 !! test
12780 Templates: HTML Tag: 9. Multiple template-generated attributes
12781 !! wikitext
12782 <div {{echo|1=id="v1" title="foo"}}>bar</div>
12783 !! html
12784 <div id="v1" title="foo">bar</div>
12785
12786 !!end
12787
12788 !! test
12789 Templates: Support for templates generating attributes and content
12790 !! wikitext
12791 {| {{mixed_attr_content_template}}
12792 |-
12793 |bar
12794 |}
12795 !! html/php
12796 <table style="color:red;" title="T48811">
12797
12798 <tr>
12799 <td>foo
12800 </td></tr>
12801 <tr>
12802 <td>bar
12803 </td></tr></table>
12804
12805 !! html/parsoid
12806 <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|}"]}'>
12807 <tbody><tr>
12808 <td>foo</td></tr>
12809 <tr>
12810 <td>bar</td></tr>
12811 </tbody></table>
12812 !!end
12813
12814 !! test
12815 1. Entities and nowikis inside templated attributes should be handled correctly
12816 !! wikitext
12817 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
12818 !! html/php
12819 <div style="background:#f9f9f9;">foo</div>
12820
12821 !! html/parsoid
12822 <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>
12823 !! end
12824
12825 !! test
12826 2. Entities and nowikis inside templated attributes should be handled correctly
12827 !! wikitext
12828 {|
12829 |{{table_attribs_3}}
12830 |}
12831 !! html/php
12832 <table>
12833 <tr>
12834 <td style="background:#f9f9f9;">Foo
12835 </td></tr></table>
12836
12837 !! html/parsoid
12838 <table>
12839 <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>
12840 </tbody></table>
12841 !! end
12842
12843 !! test
12844 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
12845 !! wikitext
12846 {{tbl-start}}
12847 |{{table_attribs_3}}
12848 {{tbl-end}}
12849 !! html/php
12850 <table>
12851 <tr>
12852 <td style="background:#f9f9f9;">Foo
12853 </td></tr></table>
12854
12855 !! html/parsoid
12856 <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}}]}'>
12857 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
12858 </tbody></table>
12859 !! end
12860
12861 # T107622
12862 !! test
12863 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
12864 !! wikitext
12865 {|
12866 | {{table_attribs_6}} hi
12867 |}
12868 !! html/php
12869 <table>
12870 <tr>
12871 <td style="background: red;"> hi
12872 </td></tr></table>
12873
12874 !! html/parsoid
12875 <table>
12876 <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>
12877 </tbody></table>
12878 !! end
12879
12880 !!test
12881 Templates: HTML Tables: 1. Generating start of a HTML table
12882 !! wikitext
12883 {{echo|<table><tr><td>foo</td>}}</tr></table>
12884 !! html
12885 <table><tr><td>foo</td></tr></table>
12886
12887 !!end
12888
12889 !!test
12890 Templates: HTML Tables: 2a. Generating middle of a HTML table
12891 !! wikitext
12892 <table><tr>{{echo|<td>foo</td>}}</tr></table>
12893 !! html
12894 <table><tr><td>foo</td></tr></table>
12895
12896 !!end
12897
12898 !!test
12899 Templates: HTML Tables: 2b. Generating middle of a HTML table
12900 !! wikitext
12901 <table>{{echo|<tr><td>foo</td></tr>}}</table>
12902 !! html
12903 <table><tr><td>foo</td></tr></table>
12904
12905 !!end
12906
12907 !!test
12908 Templates: HTML Tables: 3. Generating end of a HTML table
12909 !! wikitext
12910 <table><tr>{{echo|<td>foo</td></tr></table>}}
12911 !! html
12912 <table><tr><td>foo</td></tr></table>
12913
12914 !!end
12915
12916 !!test
12917 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
12918 !! wikitext
12919 {{echo|<table>}}<tr><td>foo</td></tr></table>
12920 !! html
12921 <table><tr><td>foo</td></tr></table>
12922
12923 !!end
12924
12925 !!test
12926 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
12927 !! wikitext
12928 <table>{{echo|<tr>}}<td>foo</td></tr></table>
12929 !! html
12930 <table><tr><td>foo</td></tr></table>
12931
12932 !!end
12933
12934 !!test
12935 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
12936 !! wikitext
12937 <table><tr>{{echo|<td>}}foo</td></tr></table>
12938 !! html
12939 <table><tr><td>foo</td></tr></table>
12940
12941 !!end
12942
12943 !!test
12944 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
12945 !! wikitext
12946 <table><tr><td>foo{{echo|</td>}}</tr></table>
12947 !! html
12948 <table><tr><td>foo</td></tr></table>
12949
12950 !!end
12951
12952 !!test
12953 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
12954 !! wikitext
12955 <table><tr><td>foo</td>{{echo|</tr>}}</table>
12956 !! html
12957 <table><tr><td>foo</td></tr></table>
12958
12959 !!end
12960
12961 !!test
12962 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
12963 !! wikitext
12964 <table><tr><td>foo</td></tr>{{echo|</table>}}
12965 !! html
12966 <table><tr><td>foo</td></tr></table>
12967
12968 !!end
12969
12970 !!test
12971 Templates: HTML Tables: 5. Proper fostering of categories from inside
12972 !!options
12973 parsoid=wt2html,wt2wt
12974 !! wikitext
12975 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
12976 <!--Two categories (T52330)-->
12977 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
12978 !! html
12979 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
12980 <!--Two categories (T52330)-->
12981 <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>
12982 !!end
12983
12984 !!test
12985 Templates: Wiki Tables: 1a. Fostering of entire template content
12986 !! wikitext
12987 {|
12988 {{echo|a}}
12989 |}
12990 !! html
12991 <table>
12992 a
12993 <tr><td></td></tr></table>
12994
12995 !! html+tidy
12996
12997 a
12998 <table><tbody><tr><td></td></tr></tbody></table>
12999 !! end
13000
13001 !!test
13002 Templates: Wiki Tables: 1b. Fostering of entire template content
13003 !! wikitext
13004 {|
13005 {{echo|<div>}}
13006 foo
13007 {{echo|</div>}}
13008 |}
13009 !! html
13010 <table>
13011 <div>
13012 <p>foo
13013 </p>
13014 </div>
13015 <tr><td></td></tr></table>
13016
13017 !! html/php+tidy
13018 <div>
13019 <p>foo
13020 </p>
13021 </div><table>
13022
13023 <tbody><tr><td></td></tr></tbody></table>
13024 !! html/parsoid
13025 <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|}"]}'>
13026 <p>foo</p>
13027 </div><table about="#mwt3">
13028
13029 </table>
13030 !! end
13031
13032 !!test
13033 Templates: Wiki Tables: 2. Fostering of partial template content
13034 !! wikitext
13035 {|
13036 {{echo|a
13037 <div>b</div>}}
13038 |}
13039 !! html
13040 <table>
13041 a
13042 <div>b</div>
13043 <tr><td></td></tr></table>
13044
13045 !! html/php+tidy
13046
13047 a
13048 <div>b</div><table>
13049 <tbody><tr><td></td></tr></tbody></table>
13050 !! html/parsoid
13051 <p about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"fostered":true,"autoInsertedEnd":true,"firstWikitextNode":"TABLE","pi":[[{"k":"1"}]]}' data-mw='{"parts":["{|\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n&lt;div>b&lt;/div>"}},"i":0}},"\n|}"]}'>a</p><div about="#mwt2">b</div><table about="#mwt2">
13052
13053
13054 </table>
13055 !! end
13056
13057 !!test
13058 Templates: Wiki Tables: 3. td-content via multiple templates
13059 !! wikitext
13060 {|
13061 {{echo|{{pipe}}a}}{{echo|b}}
13062 |}
13063 !! html
13064 <table>
13065 <tr>
13066 <td>ab
13067 </td></tr></table>
13068
13069 !!end
13070
13071 !!test
13072 Templates: Wiki Tables: 4. Templated tags, no content
13073 !! wikitext
13074 {{tbl-start}}
13075 {{tbl-end}}
13076 !! html
13077 <table>
13078 <tr><td></td></tr></table>
13079
13080 !!end
13081
13082 !!test
13083 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13084 !! wikitext
13085 {{tbl-start}}
13086 |foo
13087 {{tbl-end}}
13088 !! html
13089 <table>
13090 <tr>
13091 <td>foo
13092 </td></tr></table>
13093
13094 !!end
13095
13096 !!test
13097 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13098 !! wikitext
13099 {{tbl-start}}
13100 {{!}}foo
13101 {{tbl-end}}
13102 !! html
13103 <table>
13104 <tr>
13105 <td>foo
13106 </td></tr></table>
13107
13108 !!end
13109
13110 ## This test case is very specific to Parsoid's internals
13111 ## and is hence only tested for Parsoid's code. Parsoid uses
13112 ## a <meta> marker tag for <ref> tags and they are expanded
13113 ## much later. We are verifying that this <meta> tag usage
13114 ## doesn't prevent foster parenting.
13115 !!test
13116 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13117 !!wikitext
13118 {{PartialTable}}<ref>foo</ref>
13119 |}
13120
13121 <references />
13122 !!html/parsoid
13123 <span about="#mwt2" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"PartialTable","href":"./Template:PartialTable"},"params":{},"i":0}},"&lt;ref>foo&lt;/ref>\n|}"]}'><a href="./Main_Page#cite_note-1"><span class="mw-reflink-text">[1]</span></a></span><table about="#mwt2">
13124 <tbody>
13125 </tbody></table>
13126
13127 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
13128 !!end
13129
13130 !! test
13131 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13132 !! wikitext
13133 {{echo|
13134 {{{!}}
13135 {{!}}-}}
13136 <onlyinclude>
13137 |foo
13138 </onlyinclude>
13139 {{!}}}
13140 !! html/parsoid
13141 <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{{!}}}"]}'>
13142 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13143 <tbody><tr>
13144
13145 <td>foo
13146 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13147 </tbody></table>
13148 !! end
13149
13150 !!test
13151 Templates: Lists: Multi-line list-items via templates
13152 !! wikitext
13153 *{{echo|a {{nonexistent|
13154 unused}}}}
13155 *{{echo|b {{nonexistent|
13156 unused}}}}
13157 !! html
13158 <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>
13159 <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>
13160
13161 !!end
13162
13163 !!test
13164 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13165 !! wikitext
13166 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13167 !! html
13168 <p><i>ab</i>c<i>d</i>e
13169 </p>
13170 !!end
13171
13172 !!test
13173 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13174 (PHP parser generates misnested html)
13175 !! wikitext
13176 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13177 !! html/parsoid
13178 <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>
13179 !!end
13180
13181 !!test
13182 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13183 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13184 !! options
13185 parsoid=wt2html,wt2wt
13186 !! wikitext
13187 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13188 !! html
13189 <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>
13190 <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>
13191 <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>
13192 !!end
13193
13194 !!test
13195 Templates: Ugly nesting: 4. Divs opened/closed across templates
13196 !! wikitext
13197 a<div>b{{echo|c</div>d}}e
13198 !! html
13199 a<div>bc</div>de
13200
13201 !! html+tidy
13202 <p>a</p><div>bc</div><p>de
13203 </p>
13204 !! end
13205
13206 !!test
13207 Templates: Ugly templates: 1. Navbox template parses badly leading to table misnesting
13208 (Parsoid-centric)
13209 !! options
13210 parsoid
13211 !! wikitext
13212 {|
13213 |{{echo|foo</table>}}
13214 |bar
13215 |}
13216 !! html
13217 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["{|\n|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo</table>"}},"i":0}},"\n|bar\n|}"]}'>
13218
13219 <tbody>
13220 <tr>
13221 <td>foo</td></tr></tbody></table><span about="#mwt1">
13222 </span><span about="#mwt1">|bar</span><span about="#mwt1">
13223 |}</span>
13224 !!end
13225
13226 !!test
13227 Templates: Ugly templates: 2. Navbox template parses badly leading to table misnesting
13228 (Parsoid-centric)
13229 !! options
13230 parsoid
13231 !! wikitext
13232 <table>
13233 <tr>
13234 <td>
13235 <table>
13236 <tr>
13237 <td>1. {{echo|foo </table>}}</td>
13238 <td> bar </td>
13239 <td>2. {{echo|baz </table>}}</td>
13240 </tr>
13241 <tr>
13242 <td>abc</td>
13243 </tr>
13244 </table>
13245 </td>
13246 </tr>
13247 <tr>
13248 <td>xyz</td>
13249 </tr>
13250 </table>
13251 !! html
13252 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":["<table>\n <tr>\n <td>\n <table>\n <tr>\n <td>1. ",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo </table>"}},"i":0}},"</td>\n <td> bar </td>\n <td>2. ",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"baz </table>"}},"i":1}},"</td>\n </tr>\n <tr>\n <td>abc</td>\n </tr>\n </table>\n </td>\n </tr>\n <tr>\n <td>xyz</td>\n </tr>\n</table>"]}'>
13253 <tbody><tr>
13254 <td>
13255 <table>
13256 <tbody><tr>
13257 <td>1. foo </td></tr></tbody></table></td>
13258 <td> bar </td>
13259 <td>2. baz </td></tr></tbody></table><span about="#mwt2">
13260 </span><span about="#mwt2">
13261 </span><span about="#mwt2">
13262 </span><span about="#mwt2">abc</span><span about="#mwt2">
13263 </span><span about="#mwt2">
13264 </span><span about="#mwt2">
13265 </span><span about="#mwt2">
13266 </span><span about="#mwt2">
13267 </span><span about="#mwt2">
13268 </span><span about="#mwt2">xyz</span><span about="#mwt2">
13269 </span><span about="#mwt2">
13270 </span>
13271 !!end
13272
13273 !! test
13274 Templates: Ugly templates: 3. newline-only template parameter
13275 !! wikitext
13276 foo {{echo|
13277 }}
13278 !! html
13279 <p>foo
13280 </p>
13281 !! end
13282
13283 # This looks like a bug: a single newline triggers p/br for some reason.
13284 !! test
13285 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13286 !! wikitext
13287 {{echo|
13288 }}
13289 !! html
13290 <p><br />
13291 </p>
13292 !! end
13293
13294 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13295 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13296 !! test
13297 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13298 !! wikitext
13299 {{echo|<table>}}
13300 {{echo|<div>foo}}
13301 {{echo|</table>}}
13302 !! html/parsoid
13303 <div about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;table>"}},"i":0}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;div>foo"}},"i":1}},"\n",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;/table>"}},"i":2}}]}' data-parsoid='{"stx":"html","autoInsertedEnd":true,"pi":[[{"k":"1"}],[{"k":"1"}],[{"k":"1"}]]}'>foo
13304 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13305 </table>
13306 !! end
13307
13308 # T66017 -- ugly wikitext with fostered content generates two template ranges
13309 # that are "identical" and generate nesting cycles in the algorithm
13310 !! test
13311 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13312 !! wikitext
13313 {{echo|<table><tr><td><table>}}
13314 {{echo|<div>}}
13315 {{echo|</div>}}
13316 !! html/parsoid
13317 <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"}'>
13318 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13319 </table></td></tr></tbody></table>
13320 !! end
13321
13322 !! test
13323 Templates: Parameters substituted at the top-level
13324 !! wikitext
13325 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13326
13327 {{{foo|bar|baz}}}
13328 !! html/php
13329 <p><i>who</i> me? <b>never!</b>
13330 </p><p>bar
13331 </p>
13332 !! html/parsoid
13333 <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>
13334
13335 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13336 !! end
13337
13338 !! test
13339 Templates: Param with empty arg in the final position
13340 !! wikitext
13341 {{{hi|}}}
13342 !! html/parsoid
13343 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13344 !! end
13345
13346 !!test
13347 Parser Functions: 1. Simple example
13348 !! wikitext
13349 {{uc:foo}}
13350 !! html
13351 <p>FOO
13352 </p>
13353 !!end
13354
13355 !!test
13356 Parser Functions: 2. Nested use (only outermost should be marked up)
13357 !! wikitext
13358 {{uc:{{lc:FOO}}}}
13359 !! html
13360 <p>FOO
13361 </p>
13362 !!end
13363
13364 ###
13365 ### Pre-save transform tests
13366 ###
13367 !! test
13368 pre-save transform: subst:
13369 !! options
13370 pst
13371 !! wikitext
13372 {{subst:test}}
13373 !! html/php
13374 This is a test template
13375 !! end
13376
13377 !! test
13378 pre-save transform: normal template
13379 !! options
13380 pst
13381 !! wikitext
13382 {{test}}
13383 !! html/php
13384 {{test}}
13385 !! end
13386
13387 !! test
13388 pre-save transform: nonexistent template
13389 !! options
13390 pst
13391 !! wikitext
13392 {{thistemplatedoesnotexist}}
13393 !! html/php
13394 {{thistemplatedoesnotexist}}
13395 !! end
13396
13397 !! test
13398 pre-save transform: subst magic variables
13399 !! options
13400 pst
13401 !! wikitext
13402 {{subst:SITENAME}}
13403 !! html/php
13404 MediaWiki
13405 !! end
13406
13407 # This is T2089, which I fixed. -- wtm
13408 !! test
13409 pre-save transform: subst: templates with parameters
13410 !! options
13411 pst
13412 !! wikitext
13413 {{subst:paramtest|param="something else"}}
13414 !! html/php
13415 This is a test template with parameter "something else"
13416 !! end
13417
13418 !! article
13419 Template:nowikitest
13420 !! text
13421 <nowiki>'''not wiki'''</nowiki>
13422 !! endarticle
13423
13424 !! test
13425 pre-save transform: nowiki in subst (T3188)
13426 !! options
13427 pst
13428 !! wikitext
13429 {{subst:nowikitest}}
13430 !! html/php
13431 <nowiki>'''not wiki'''</nowiki>
13432 !! end
13433
13434 !! article
13435 Template:commenttest
13436 !! text
13437 This template has <!-- a comment --> in it.
13438 !! endarticle
13439
13440 !! test
13441 pre-save transform: comment in subst (T3936)
13442 !! options
13443 pst
13444 !! wikitext
13445 {{subst:commenttest}}
13446 !! html/php
13447 This template has <!-- a comment --> in it.
13448 !! end
13449
13450 !! test
13451 pre-save transform: unclosed tag
13452 !! options
13453 pst
13454 !! wikitext
13455 <nowiki>'''not wiki'''
13456 !! html/php
13457 <nowiki>'''not wiki'''
13458 !! end
13459
13460 !! test
13461 pre-save transform: mixed tag case
13462 !! options
13463 pst
13464 !! wikitext
13465 <NOwiki>'''not wiki'''</noWIKI>
13466 !! html/php
13467 <NOwiki>'''not wiki'''</noWIKI>
13468 !! end
13469
13470 !! test
13471 pre-save transform: unclosed comment in <nowiki>
13472 !! options
13473 pst
13474 !! wikitext
13475 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13476 !! html/php
13477 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13478 !!end
13479
13480 # Leading @ in this template definition works around a limitation
13481 # in parsoid's parserTests which otherwise strips the <span> from the
13482 # result (confusing it for a template wrapper)
13483 !! article
13484 Template:dangerous
13485 !!text
13486 @<span onmouseover="alert('crap')">Oh no</span>
13487 !!endarticle
13488
13489 !!test
13490 (confirming safety of fix for subst T3936)
13491 !! wikitext
13492 {{Template:dangerous}}
13493 !! html
13494 <p>@<span>Oh no</span>
13495 </p>
13496 !! end
13497
13498 !! test
13499 pre-save transform: comment containing gallery (T7024)
13500 !! options
13501 pst
13502 !! wikitext
13503 <!-- <gallery>data</gallery> -->
13504 !! html/php
13505 <!-- <gallery>data</gallery> -->
13506 !!end
13507
13508 !! test
13509 pre-save transform: comment containing extension
13510 !! options
13511 pst
13512 !! wikitext
13513 <!-- <tag>data</tag> -->
13514 !! html/php
13515 <!-- <tag>data</tag> -->
13516 !!end
13517
13518 !! test
13519 pre-save transform: comment containing nowiki
13520 !! options
13521 pst
13522 !! wikitext
13523 <!-- <nowiki>data</nowiki> -->
13524 !! html/php
13525 <!-- <nowiki>data</nowiki> -->
13526 !!end
13527
13528 !! test
13529 pre-save transform: <noinclude> in subst (T5298)
13530 !! options
13531 pst
13532 !! wikitext
13533 {{subst:Includes}}
13534 !! html/php
13535 Foobar
13536 !! end
13537
13538 !! test
13539 pre-save transform: <onlyinclude> in subst (T5298)
13540 !! options
13541 pst
13542 !! wikitext
13543 {{subst:Includes2}}
13544 !! html/php
13545 Foo
13546 !! end
13547
13548 !! article
13549 Template:SubstTest
13550 !!text
13551 {{<includeonly>subst:</includeonly>Includes}}
13552 !! endarticle
13553
13554 !! article
13555 Template:SafeSubstTest
13556 !! text
13557 {{<includeonly>safesubst:</includeonly>Includes}}
13558 !! endarticle
13559
13560 !! test
13561 T24297: safesubst: works during PST
13562 !! options
13563 pst
13564 !! wikitext
13565 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
13566 !! html/php
13567 FoobarFoobar
13568 !! end
13569
13570 !! test
13571 T24297: safesubst: works during normal parse
13572 !! wikitext
13573 {{SafeSubstTest}}
13574 !! html
13575 <p>Foobar
13576 </p>
13577 !! end
13578
13579 !! test
13580 subst: does not work during normal parse
13581 !! wikitext
13582 {{SubstTest}}
13583 !! html
13584 <p>{{subst:Includes}}
13585 </p>
13586 !! end
13587
13588 !! test
13589 pre-save transform: context links ("pipe trick")
13590 !! options
13591 pst
13592 !! wikitext
13593 [[Article (context)|]]
13594 [[Bar:Article|]]
13595 [[:Bar:Article|]]
13596 [[Bar:Article (context)|]]
13597 [[:Bar:Article (context)|]]
13598 [[|Article]]
13599 [[|Article (context)]]
13600 [[Bar:X (Y) Z|]]
13601 [[:Bar:X (Y) Z|]]
13602 !! html/php
13603 [[Article (context)|Article]]
13604 [[Bar:Article|Article]]
13605 [[:Bar:Article|Article]]
13606 [[Bar:Article (context)|Article]]
13607 [[:Bar:Article (context)|Article]]
13608 [[Article]]
13609 [[Article (context)]]
13610 [[Bar:X (Y) Z|X (Y) Z]]
13611 [[:Bar:X (Y) Z|X (Y) Z]]
13612 !! end
13613
13614 !! test
13615 pre-save transform: context links ("pipe trick") with interwiki prefix
13616 !! options
13617 pst
13618 !! wikitext
13619 [[interwiki:Article|]]
13620 [[:interwiki:Article|]]
13621 [[interwiki:Bar:Article|]]
13622 [[:interwiki:Bar:Article|]]
13623 !! html/php
13624 [[interwiki:Article|Article]]
13625 [[:interwiki:Article|Article]]
13626 [[interwiki:Bar:Article|Bar:Article]]
13627 [[:interwiki:Bar:Article|Bar:Article]]
13628 !! end
13629
13630 !! test
13631 pre-save transform: context links ("pipe trick") with parens in title
13632 !! options
13633 pst title=[[Somearticle (context)]]
13634 !! wikitext
13635 [[|Article]]
13636 !! html/php
13637 [[Article (context)|Article]]
13638 !! end
13639
13640 !! test
13641 pre-save transform: context links ("pipe trick") with comma in title
13642 !! options
13643 pst title=[[Someplace, Somewhere]]
13644 !! wikitext
13645 [[|Otherplace]]
13646 [[Otherplace, Elsewhere|]]
13647 [[Otherplace, Elsewhere, Anywhere|]]
13648 !! html/php
13649 [[Otherplace, Somewhere|Otherplace]]
13650 [[Otherplace, Elsewhere|Otherplace]]
13651 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
13652 !! end
13653
13654 !! test
13655 pre-save transform: context links ("pipe trick") with parens and comma
13656 !! options
13657 pst title=[[Someplace (IGNORED), Somewhere]]
13658 !! wikitext
13659 [[|Otherplace]]
13660 [[Otherplace (place), Elsewhere|]]
13661 !! html/php
13662 [[Otherplace, Somewhere|Otherplace]]
13663 [[Otherplace (place), Elsewhere|Otherplace]]
13664 !! end
13665
13666 !! test
13667 pre-save transform: context links ("pipe trick") with comma and parens
13668 !! options
13669 pst title=[[Who, me? (context)]]
13670 !! wikitext
13671 [[|Yes, you.]]
13672 [[Me, Myself, and I (1937 song)|]]
13673 !! html/php
13674 [[Yes, you. (context)|Yes, you.]]
13675 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
13676 !! end
13677
13678 !! test
13679 pre-save transform: context links ("pipe trick") with namespace
13680 !! options
13681 pst title=[[Ns:Somearticle]]
13682 !! wikitext
13683 [[|Article]]
13684 !! html/php
13685 [[Ns:Article|Article]]
13686 !! end
13687
13688 !! test
13689 pre-save transform: context links ("pipe trick") with namespace and parens
13690 !! options
13691 pst title=[[Ns:Somearticle (context)]]
13692 !! wikitext
13693 [[|Article]]
13694 !! html/php
13695 [[Ns:Article (context)|Article]]
13696 !! end
13697
13698 !! test
13699 pre-save transform: context links ("pipe trick") with namespace and comma
13700 !! options
13701 pst title=[[Ns:Somearticle, Context, Whatever]]
13702 !! wikitext
13703 [[|Article]]
13704 !! html/php
13705 [[Ns:Article, Context, Whatever|Article]]
13706 !! end
13707
13708 !! test
13709 pre-save transform: context links ("pipe trick") with namespace, comma and parens
13710 !! options
13711 pst title=[[Ns:Somearticle, Context (context)]]
13712 !! wikitext
13713 [[|Article]]
13714 !! html/php
13715 [[Ns:Article (context)|Article]]
13716 !! end
13717
13718 !! test
13719 pre-save transform: context links ("pipe trick") with namespace, parens and comma
13720 !! options
13721 pst title=[[Ns:Somearticle (IGNORED), Context]]
13722 !! wikitext
13723 [[|Article]]
13724 !! html/php
13725 [[Ns:Article, Context|Article]]
13726 !! end
13727
13728 !! test
13729 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
13730 !! options
13731 pst
13732 !! wikitext
13733 [[Article(context)|]]
13734 [[Bar:Article(context)|]]
13735 [[:Bar:Article(context)|]]
13736 [[|Article(context)]]
13737 [[Bar:X(Y)Z|]]
13738 [[:Bar:X(Y)Z|]]
13739 !! html/php
13740 [[Article(context)|Article]]
13741 [[Bar:Article(context)|Article]]
13742 [[:Bar:Article(context)|Article]]
13743 [[Article(context)]]
13744 [[Bar:X(Y)Z|X(Y)Z]]
13745 [[:Bar:X(Y)Z|X(Y)Z]]
13746 !! end
13747
13748 !! test
13749 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
13750 !! options
13751 pst
13752 !! wikitext
13753 [[Article (context)|]]
13754 [[Bar:Article (context)|]]
13755 [[:Bar:Article (context)|]]
13756 [[|Article (context)]]
13757 [[Bar:X (Y) Z|]]
13758 [[:Bar:X (Y) Z|]]
13759 !! html/php
13760 [[Article (context)|Article]]
13761 [[Bar:Article (context)|Article]]
13762 [[:Bar:Article (context)|Article]]
13763 [[Article (context)]]
13764 [[Bar:X (Y) Z|X (Y) Z]]
13765 [[:Bar:X (Y) Z|X (Y) Z]]
13766 !! end
13767
13768 !! test
13769 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
13770 !! options
13771 pst
13772 !! wikitext
13773 [[Article(context)|]]
13774 [[Bar:Article(context)|]]
13775 [[:Bar:Article(context)|]]
13776 [[|Article(context)]]
13777 [[Bar:X(Y)Z|]]
13778 [[:Bar:X(Y)Z|]]
13779 !! html/php
13780 [[Article(context)|Article]]
13781 [[Bar:Article(context)|Article]]
13782 [[:Bar:Article(context)|Article]]
13783 [[Article(context)]]
13784 [[Bar:X(Y)Z|X(Y)Z]]
13785 [[:Bar:X(Y)Z|X(Y)Z]]
13786 !! end
13787
13788 !! test
13789 pre-save transform: context links ("pipe trick") with commas (T23660)
13790 !! options
13791 pst
13792 !! wikitext
13793 [[Article (context), context|]]
13794 [[Article (context),context|]]
13795 [[Bar:Article (context), context|]]
13796 [[Bar:Article (context),context|]]
13797 [[:Bar:Article (context), context|]]
13798 [[:Bar:Article (context),context|]]
13799 !! html/php
13800 [[Article (context), context|Article]]
13801 [[Article (context),context|Article]]
13802 [[Bar:Article (context), context|Article]]
13803 [[Bar:Article (context),context|Article]]
13804 [[:Bar:Article (context), context|Article]]
13805 [[:Bar:Article (context),context|Article]]
13806 !! end
13807
13808 !! test
13809 Parsoid: backwards pipe trick
13810 !! wikitext
13811 [[|'''bar''']]
13812 !! html/php
13813 <p>[[|<b>bar</b>]]
13814 </p>
13815 !! html/parsoid
13816 <p>[[|<b>bar</b>]]</p>
13817 !! end
13818
13819 !! test
13820 pre-save transform: trim trailing empty lines
13821 !! options
13822 pst
13823 !! wikitext
13824 Empty lines are trimmed
13825
13826
13827
13828
13829 !! html/php
13830 Empty lines are trimmed
13831 !! end
13832
13833 !! test
13834 pre-save transform: Signature expansion
13835 !! options
13836 pst
13837 !! wikitext
13838 * ~~~
13839 * ~~~~
13840 * ~~~~~
13841 * <noinclude>~~~</noinclude>
13842 * <includeonly>~~~</includeonly>
13843 * <onlyinclude>~~~</onlyinclude>
13844 !! html/php
13845 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
13846 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
13847 * 00:02, 1 January 1970 (UTC)
13848 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
13849 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
13850 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
13851 !! end
13852
13853
13854 !! test
13855 ParserOutput flags from signature expansion (T84843)
13856 !! options
13857 pst
13858 showflags
13859 !! wikitext
13860 ~~~~
13861 !! html/php
13862 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
13863 flags=user-signature
13864 !! end
13865
13866
13867 !! test
13868 pre-save transform: Signature expansion in nowiki tags (T2093)
13869 !! options
13870 pst disabled
13871 !! wikitext
13872 Shall not expand:
13873
13874 <nowiki>~~~~</nowiki>
13875
13876 <includeonly><nowiki>~~~~</nowiki></includeonly>
13877
13878 <noinclude><nowiki>~~~~</nowiki></noinclude>
13879
13880 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13881
13882 {{subst:Foo}} shall be converted to FOO
13883
13884 As well as inside noinclude/onlyinclude
13885 <noinclude>{{subst:Foo}}</noinclude>
13886 <onlyinclude>{{subst:Foo}}</onlyinclude>
13887
13888 But not inside includeonly
13889 <includeonly>{{subst:Foo}}</includeonly>
13890 !! html/php
13891 Shall not expand:
13892
13893 <nowiki>~~~~</nowiki>
13894
13895 <includeonly><nowiki>~~~~</nowiki></includeonly>
13896
13897 <noinclude><nowiki>~~~~</nowiki></noinclude>
13898
13899 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13900
13901 FOO shall be converted to FOO
13902
13903 As well as inside noinclude/onlyinclude
13904 <noinclude>FOO</noinclude>
13905 <onlyinclude>FOO</onlyinclude>
13906
13907 But not inside includeonly
13908 <includeonly>{{subst:Foo}}</includeonly>
13909 !! end
13910
13911 !! test
13912 Parsoid: Recognize nowiki with trailing space in tags
13913 !! options
13914 parsoid=wt2html
13915 !! wikitext
13916 <nowiki ><div>[[foo]]</nowiki >
13917
13918 a<nowiki / >b
13919
13920 c<nowiki />d
13921
13922 e<nowiki/ >f
13923 !! html
13924 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
13925 <p>ab</p>
13926 <p>cd</p>
13927 <p>ef</p>
13928 !! end
13929
13930 !! test
13931 Parsoid: Recognize nowiki with odd capitalization
13932 !! options
13933 parsoid=wt2html
13934 !! wikitext
13935 <noWikI ><div>[[foo]]</Nowiki >
13936 !! html
13937 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
13938 !! end
13939
13940
13941 !! test
13942 Parsoid: Escape nowiki with trailing space in tags
13943 !! options
13944 parsoid=html2wt
13945 !! html/parsoid
13946 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
13947 <p>a&lt;nowiki /&gt;b</p>
13948 <p>c&lt;nowiki/ &gt;d</p>
13949 !! wikitext
13950 &lt;nowiki &gt; foo &lt;/nowiki &gt;
13951
13952 a&lt;nowiki /&gt;b
13953
13954 c&lt;nowiki/ &gt;d
13955 !! end
13956
13957 !! test
13958 Parsoid: Escape weird noWikI capitalizations
13959 !! options
13960 parsoid=html2wt
13961 !! html/parsoid
13962 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
13963 !! wikitext
13964 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
13965 !! end
13966
13967 ###
13968 ### Message transform tests
13969 ###
13970 !! test
13971 message transform: magic variables
13972 !! options
13973 msg
13974 !! wikitext
13975 {{SITENAME}}
13976 !! html
13977 MediaWiki
13978 !! end
13979
13980 !! test
13981 message transform: should not transform wiki markup
13982 !! options
13983 msg
13984 !! wikitext
13985 ''test''
13986 !! html
13987 ''test''
13988 !! end
13989
13990 !! test
13991 message transform: <noinclude> in transcluded template (T6926)
13992 !! options
13993 msg
13994 !! wikitext
13995 {{Includes}}
13996 !! html
13997 Foobar
13998 !! end
13999
14000 !! test
14001 message transform: <onlyinclude> in transcluded template (T6926)
14002 !! options
14003 msg
14004 !! wikitext
14005 {{Includes2}}
14006 !! html
14007 Foo
14008 !! end
14009
14010 !! test
14011 {{#special:}} page name, known
14012 !! options
14013 msg
14014 !! wikitext
14015 {{#special:Recentchanges}}
14016 !! html
14017 Special:RecentChanges
14018 !! end
14019
14020 !! test
14021 {{#special:}} page name with subpage, known
14022 !! options
14023 msg
14024 !! wikitext
14025 {{#special:Recentchanges/param}}
14026 !! html
14027 Special:RecentChanges/param
14028 !! end
14029
14030 !! test
14031 {{#special:}} page name, unknown
14032 !! options
14033 msg
14034 !! wikitext
14035 {{#special:foobar nonexistent}}
14036 !! html
14037 Special:Foobar nonexistent
14038 !! end
14039
14040 !! test
14041 {{#speciale:}} page name, known
14042 !! options
14043 msg
14044 !! wikitext
14045 {{#speciale:Recentchanges}}
14046 !! html
14047 Special:RecentChanges
14048 !! end
14049
14050 !! test
14051 {{#speciale:}} page name with subpage, known
14052 !! options
14053 msg
14054 !! wikitext
14055 {{#speciale:Recentchanges/param}}
14056 !! html
14057 Special:RecentChanges/param
14058 !! end
14059
14060 !! test
14061 {{#speciale:}} page name, unknown
14062 !! options
14063 msg
14064 !! wikitext
14065 {{#speciale:foobar nonexistent}}
14066 !! html
14067 Special:Foobar_nonexistent
14068 !! end
14069
14070 ###
14071 ### Images
14072 ###
14073 ### For Parsoid-specific tests, see
14074 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14075
14076 !! test
14077 Simple image
14078 !! options
14079 parsoid=wt2html,wt2wt,html2html
14080 !! wikitext
14081 [[Image:foobar.jpg]]
14082 !! html/php
14083 <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>
14084 </p>
14085 !! html/parsoid
14086 <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>
14087 !! end
14088
14089 !! test
14090 Serialize simple image with span wrapper
14091 !! options
14092 parsoid=html2wt
14093 !! html/parsoid
14094 <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>
14095 !! wikitext
14096 [[File:Foobar.jpg]]
14097 !! end
14098
14099 !! test
14100 Simple image (using File: namespace, now canonical)
14101 !! wikitext
14102 [[File:Foobar.jpg]]
14103 !! html/php
14104 <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>
14105 </p>
14106 !! html/parsoid
14107 <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>
14108 !! end
14109
14110 !! test
14111 Right-aligned image
14112 !! wikitext
14113 [[File:Foobar.jpg|right]]
14114 !! html/php
14115 <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>
14116
14117 !! html/parsoid
14118 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure>
14119 !! end
14120
14121 !! test
14122 Image with caption
14123 !! wikitext
14124 [[File:Foobar.jpg|right|Caption text]]
14125 !! html/php
14126 <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>
14127
14128 !! html/parsoid
14129 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption text</figcaption></figure>
14130 !! end
14131
14132 !! test
14133 Image with caption, T55312 #1
14134 !! wikitext
14135 [[File:Foobar.jpg|right|Caption page stuff]]
14136 !! html/php
14137 <div class="floatright"><a href="/wiki/File:Foobar.jpg" class="image" title="Caption page stuff"><img alt="Caption page stuff" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a></div>
14138
14139 !! html/parsoid
14140 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption page stuff</figcaption></figure>
14141 !! end
14142
14143 !! test
14144 Image with caption, T55312 #2
14145 !! wikitext
14146 [[File:Foobar.jpg|right|Caption page=]]
14147 !! html/php
14148 <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>
14149
14150 !! html/parsoid
14151 <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>
14152 !! end
14153
14154 !! test
14155 Image with caption, T55312 #3
14156 !! wikitext
14157 [[File:Foobar.jpg|right|Caption page=stuff]]
14158 !! html/php
14159 <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>
14160
14161 !! html/parsoid
14162 <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>
14163 !! end
14164
14165 !! test
14166 Image caption with pipe entity
14167 !! wikitext
14168 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14169 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14170 !! html/php
14171 <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>
14172 <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>
14173
14174 !! html/parsoid
14175 <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>
14176 <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>
14177 !! end
14178
14179 !! test
14180 Allow empty links in image captions (T62753)
14181 !! options
14182 thumbsize=220
14183 !! wikitext
14184 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14185 [[]]
14186 [[Link2]]
14187 ]]
14188 !! html/php
14189 <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>
14190
14191 !! html/parsoid
14192 <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>
14193 [[]]
14194 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14195 </figcaption></figure>
14196 !! end
14197
14198 !! test
14199 Titles in unlinked images (T23454)
14200 !! wikitext
14201 [[File:Foobar.jpg|link=|stuff]]
14202 !! html/php
14203 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
14204 </p>
14205 !! end
14206
14207 !! test
14208 Link with empty target
14209 !! wikitext
14210 [[]]
14211 !! html
14212 <p>[[]]
14213 </p>
14214 !! end
14215
14216 !! test
14217 Image with link trail
14218 !! wikitext
14219 Linktrails should not work for images: [[File:Foobar.jpg]]s
14220 !! html/php
14221 <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
14222 </p>
14223 !! html/parsoid
14224 <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>
14225 !! end
14226
14227 !! test
14228 Image with empty attribute
14229 !! options
14230 parsoid=wt2html,wt2wt,html2html
14231 !! wikitext
14232 [[File:Foobar.jpg|right||Caption text]]
14233 !! html/php
14234 <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>
14235
14236 !! html/parsoid
14237 <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>
14238 !! end
14239
14240 !! test
14241 1. Block image with individual attributes from templates
14242 !! wikitext
14243 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14244 !! html/php
14245 <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>
14246
14247 !! html/parsoid
14248 <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>
14249 !! end
14250
14251 !! test
14252 2. Block Image with individual attributes from templates
14253 !! wikitext
14254 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14255 !! html/php
14256 <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>
14257
14258 !! html/parsoid
14259 <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>
14260 !! end
14261
14262 !! test
14263 3. Inline image with individual attributes from templates
14264 !! wikitext
14265 [[File:Foobar.jpg|{{echo|50px}}]]
14266 !! html/php
14267 <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>
14268 </p>
14269 !! html/parsoid
14270 <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>
14271 !! end
14272
14273 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14274 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14275 !! test
14276 Image with multiple attributes from the same template
14277 !! wikitext
14278 [[File:Foobar.jpg|{{image_attribs}}]]
14279 !! html/php
14280 <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>
14281
14282 !! html/parsoid
14283 <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>
14284 !! end
14285
14286 !! test
14287 Image with link tails
14288 !! options
14289 thumbsize=220
14290 !! wikitext
14291 123[[File:Foobar.jpg]]456
14292 123[[File:Foobar.jpg|right]]456
14293 123[[File:Foobar.jpg|thumb]]456
14294 !! html/php
14295 <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
14296 </p>
14297 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
14298 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
14299
14300 !! html/php+tidy
14301 <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
14302 </p><p>
14303 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
14304 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
14305 </p>
14306 !! html/parsoid
14307 <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>
14308 <p>123</p><figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure><p>456</p>
14309 <p>123</p><figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></figure><p>456</p>
14310 !! end
14311
14312 !! test
14313 Image with multiple captions -- only last one is accepted
14314 !! wikitext
14315 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14316 !! html/php
14317 <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>
14318
14319 !! html/parsoid
14320 <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>
14321 !! end
14322
14323 !! test
14324 Image with multiple widths -- use last
14325 !! wikitext
14326 [[File:Foobar.jpg|200px|300px|caption]]
14327 !! html/php
14328 <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>
14329 </p>
14330 !! html/parsoid
14331 <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>
14332 !! end
14333
14334 !! test
14335 Image with multiple alignments -- use first (T50664)
14336 !! options
14337 thumbsize=220
14338 !! wikitext
14339 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14340
14341 [[File:Foobar.jpg|middle|text-top|caption]]
14342 !! html/php
14343 <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>
14344 <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>
14345 </p>
14346 !! html/parsoid
14347 <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>
14348 <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>
14349 !! end
14350
14351 !! test
14352 Image with width attribute at different positions
14353 !! wikitext
14354 [[File:Foobar.jpg|200px|right|Caption]]
14355 [[File:Foobar.jpg|right|200px|Caption]]
14356 [[File:Foobar.jpg|right|Caption|200px]]
14357 !! html/php
14358 <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>
14359 <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>
14360 <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>
14361
14362 !! html/parsoid
14363 <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>
14364 <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>
14365 <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>
14366 !! end
14367
14368 # a sad bit of backward-compatibility
14369 !! test
14370 Image with size specified with pxpx (T15500, T53628)
14371 !! options
14372 parsoid=wt2html,wt2wt,html2html
14373 !! wikitext
14374 [[File:Foobar.jpg|20pxpx]]
14375 [[File:Foobar.jpg|200x20pxpx]]
14376 !! html/php
14377 <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>
14378 <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>
14379 </p>
14380 !! html/parsoid
14381 <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>
14382 !! end
14383
14384 !! test
14385 Image with link parameter, wiki target
14386 !! wikitext
14387 [[File:Foobar.jpg|link=Main Page]]
14388 !! html/php
14389 <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>
14390 </p>
14391 !! html/parsoid
14392 <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>
14393 !! end
14394
14395 # parsoid T51293 (part 1)
14396 !! test
14397 Image with link parameter, URL target
14398 !! wikitext
14399 [[File:Foobar.jpg|link=http://example.com/]]
14400 !! html/php
14401 <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>
14402 </p>
14403 !! html/parsoid
14404 <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>
14405 !! end
14406
14407 # parsoid T51293 (part 2)
14408 !! test
14409 Image with link parameter, protocol-less URL target
14410 !! wikitext
14411 [[File:Foobar.jpg|link=//example.com/]]
14412 !! html/php
14413 <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>
14414 </p>
14415 !! html/parsoid
14416 <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>
14417 !! end
14418
14419 !! test
14420 Escaping non-block captions (T107435)
14421 !! options
14422 parsoid={
14423 "modes": ["wt2wt"],
14424 "changes": [
14425 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14426 ]
14427 }
14428 !! wikitext
14429 [[Image:Foobar.jpg|caption]]
14430 !! wikitext/edited
14431 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14432 !! end
14433
14434 # wgExternalLinkTarget not supported by Parsoid
14435 !! test
14436 Image with link parameter, wgExternalLinkTarget
14437 !! wikitext
14438 [[Image:foobar.jpg|link=http://example.com/]]
14439 !! config
14440 wgExternalLinkTarget='foobar'
14441 !! html/php
14442 <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>
14443 </p>
14444 !! end
14445
14446 !! test
14447 Image with link parameter, wgNoFollowLinks set to false
14448 !! wikitext
14449 [[Image:foobar.jpg|link=http://example.com/]]
14450 !! config
14451 wgNoFollowLinks=false
14452 !! html
14453 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14454 </p>
14455 !! end
14456
14457 !! test
14458 Image with link parameter, wgNoFollowDomainExceptions
14459 !! wikitext
14460 [[Image:foobar.jpg|link=http://example.com/]]
14461 !! config
14462 wgNoFollowDomainExceptions='example.com'
14463 !! html
14464 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14465 </p>
14466 !! end
14467
14468 # wgExternalLinkTarget not supported by Parsoid
14469 !! test
14470 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14471 !! wikitext
14472 [[Image:foobar.jpg|link=http://example.com/|Title]]
14473 !! config
14474 wgExternalLinkTarget='foobar'
14475 !! html/php
14476 <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>
14477 </p>
14478 !! end
14479
14480 !! test
14481 Image with empty link parameter
14482 !! wikitext
14483 [[File:Foobar.jpg|link=]]
14484 !! html/php
14485 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14486 </p>
14487 !! html/parsoid
14488 <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>
14489 !! end
14490
14491 !! test
14492 Image with link parameter (wiki target) and unnamed parameter
14493 !! wikitext
14494 [[File:Foobar.jpg|link=Main_Page|Title]]
14495 !! html/php
14496 <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>
14497 </p>
14498 !! html/parsoid
14499 <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>
14500 !! end
14501
14502 !! test
14503 Image with link parameter (URL target) and unnamed parameter
14504 !! wikitext
14505 [[File:Foobar.jpg|link=http://example.com/|Title]]
14506 !! html/php
14507 <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>
14508 </p>
14509 !! html/parsoid
14510 <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>
14511 !! end
14512
14513 !! test
14514 Thumbnail image with link parameter
14515 !! options
14516 thumbsize=220
14517 parsoid=wt2html,wt2wt,html2html
14518 !! wikitext
14519 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14520 !! html/php
14521 <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>
14522
14523 !! html/parsoid
14524 <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>
14525 !! end
14526
14527 !! test
14528 Manually-specified thumbnail image
14529 !! options
14530 thumbsize=220
14531 !! wikitext
14532 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14533 !! html/php
14534 <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>
14535
14536 !! html/parsoid
14537 <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>
14538 !! end
14539
14540 !! test
14541 Manually-specified thumbnail image with explicit link to wiki page
14542 !! options
14543 thumbsize=220
14544 parsoid=wt2html,wt2wt,html2html
14545 !! wikitext
14546 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14547 !! html/php
14548 <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>
14549
14550 !! html/parsoid
14551 <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>
14552 !! end
14553
14554 !! test
14555 Manually-specified thumbnail image with explicit link to url
14556 !! options
14557 thumbsize=220
14558 parsoid=wt2html,wt2wt,html2html
14559 !! wikitext
14560 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14561 !! html/php
14562 <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>
14563
14564 !! html/parsoid
14565 <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>
14566 !! end
14567
14568 !! test
14569 Manually-specified thumbnail image with explicit no link
14570 !! options
14571 thumbsize=220
14572 parsoid=wt2html,wt2wt,html2html
14573 !! wikitext
14574 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14575 !! html/php
14576 <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>
14577
14578 !! html/parsoid
14579 <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>
14580 !! end
14581
14582 !! test
14583 Manually-specified thumbnail image with explicit link and alt text
14584 !! options
14585 thumbsize=220
14586 parsoid=wt2html,wt2wt,html2html
14587 !! wikitext
14588 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14589 !! html/php
14590 <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>
14591
14592 !! html/parsoid
14593 <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>
14594 !! end
14595
14596 !! test
14597 Image with frame and link
14598 !! options
14599 parsoid=wt2html,wt2wt,html2html
14600 !! wikitext
14601 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14602 !! html/php
14603 <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>
14604
14605 !! html/parsoid
14606 <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>
14607 !! end
14608
14609 !! test
14610 Image with frame and link and explicit alt
14611 !! options
14612 parsoid=wt2html,wt2wt,html2html
14613 !! wikitext
14614 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
14615 !! html/php
14616 <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>
14617
14618 !! html/parsoid
14619 <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>
14620 !! end
14621
14622 !! test
14623 Image with wiki markup in implicit alt
14624 !! wikitext
14625 [[Image:Foobar.jpg|testing '''bold''' in alt]]
14626
14627 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
14628 !! html/php
14629 <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>
14630 </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>
14631 </p>
14632 !! html/parsoid
14633 <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>
14634
14635 <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>
14636 !! end
14637
14638 !! test
14639 Alt image option should handle most kinds of wikitext without barfing
14640 !! wikitext
14641 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
14642 !! html/php
14643 <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>
14644
14645 !! html/parsoid
14646 <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>
14647 !! end
14648
14649 !! test
14650 Image with table with attributes in caption
14651 !! options
14652 parsoid=wt2html,html2html
14653 !! wikitext
14654 [[File:Foobar.jpg|thumb|
14655 {| class="123" |
14656 |- class="456" |
14657 | ha
14658 |}
14659 ]]
14660 !! html/parsoid
14661 <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>
14662 <table class="123">
14663 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
14664 <td> ha</td></tr>
14665 </tbody></table>
14666 </figcaption></figure>
14667 !! end
14668
14669 !! test
14670 Image with table with rows from templates in caption
14671 !! wikitext
14672 [[File:Foobar.jpg|thumb|
14673 {|
14674 {{echo|{{!}} hi}}
14675 |}
14676 ]]
14677 !! html/parsoid
14678 <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>
14679 <table>
14680 <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>
14681 </tbody></table>
14682 </figcaption></figure>
14683 !! end
14684
14685 !! test
14686 Image with nested tables in caption
14687 !! wikitext
14688 [[File:Foobar.jpg|thumb|Foo<br />
14689 {|
14690 |
14691 {|
14692 |z
14693 |}
14694 |}
14695 ]]
14696 !! html/parsoid
14697 <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}'/>
14698 <table>
14699 <tbody><tr><td>
14700 <table>
14701 <tbody><tr><td>z</td></tr>
14702 </tbody></table></td></tr>
14703 </tbody></table>
14704 </figcaption></figure>
14705 !! end
14706
14707 ###################
14708 # Conflicting image format options.
14709 # First option specified should 'win'.
14710 # All three cases in each test should be identical.
14711
14712 !! test
14713 Image with 'frameless' first.
14714 !! options
14715 parsoid=wt2html,wt2wt,html2html
14716 !! wikitext
14717 [[File:Foobar.jpg|frameless|caption]]
14718
14719 [[File:Foobar.jpg|frameless|frame|caption]]
14720
14721 [[File:Foobar.jpg|frameless|thumb|caption]]
14722 !! html/php
14723 <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>
14724 </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>
14725 </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>
14726 </p>
14727 !! html/parsoid
14728 <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>
14729 <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>
14730 <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>
14731 !! end
14732
14733 !! test
14734 Image with 'frame' first.
14735 !! options
14736 parsoid=wt2html,wt2wt,html2html
14737 !! wikitext
14738 [[File:Foobar.jpg|frame|caption]]
14739 [[File:Foobar.jpg|frame|frameless|caption]]
14740 [[File:Foobar.jpg|frame|thumb|caption]]
14741 !! html/php
14742 <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>
14743 <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>
14744 <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>
14745
14746 !! html/parsoid
14747 <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>
14748 <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>
14749 <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>
14750 !! end
14751
14752 !! test
14753 Image with 'thumb' first.
14754 !! options
14755 parsoid=wt2html,wt2wt,html2html
14756 !! wikitext
14757 [[File:Foobar.jpg|thumb|caption]]
14758 [[File:Foobar.jpg|thumb|frameless|caption]]
14759 [[File:Foobar.jpg|thumb|frame|caption]]
14760 !! html/php
14761 <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>
14762 <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>
14763 <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>
14764
14765 !! html/parsoid
14766 <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>
14767 <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>
14768 <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>
14769 !! end
14770
14771 ###################
14772 # Image sizing.
14773 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
14774 # and https://phabricator.wikimedia.org/T64258
14775 # Foobar has actual size of 1941x220
14776 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
14777 # a scalable format.
14778 # 2. Framed images always ignore size options; always render at default size.
14779 # 3. "Unspecified format" and border are the only types which can be
14780 # enlarged.
14781
14782 !! test
14783 Image: unspecified format and border enlarge
14784 !! options
14785 parsoid=wt2html,wt2wt,html2html
14786 !! wikitext
14787 [[File:Foobar.jpg|2000px]]
14788
14789 [[File:Foobar.jpg|border|2000px]]
14790 !! html/php
14791 <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>
14792 </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>
14793 </p>
14794 !! html/parsoid
14795 <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>
14796 <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>
14797 !! end
14798
14799 !! test
14800 Image: "unspecified format" and border reduce
14801 !! options
14802 parsoid=wt2html,wt2wt,html2html
14803 !! wikitext
14804 [[File:Foobar.jpg|1000px]]
14805
14806 [[File:Foobar.jpg|border|1000px]]
14807 !! html/php
14808 <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>
14809 </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>
14810 </p>
14811 !! html/parsoid
14812 <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>
14813 <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>
14814 !! end
14815
14816 !! test
14817 Image: thumbs reduce
14818 !! options
14819 parsoid=wt2html,wt2wt,html2html
14820 !! wikitext
14821 [[File:Foobar.jpg|thumb|50px]]
14822 !! html/php
14823 <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>
14824
14825 !! html/parsoid
14826 <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>
14827 !! end
14828
14829 !! test
14830 Image: bitmap thumbs can't be enlarged past original size, but vector can.
14831 !! options
14832 parsoid=wt2html,wt2wt,html2html
14833 !! wikitext
14834 [[File:Foobar.jpg|thumb|2000px]]
14835
14836 [[File:Foobar.svg|thumb|2000px]]
14837 !! html/php
14838 <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>
14839 <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>
14840
14841 !! html/parsoid
14842 <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>
14843 <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>
14844 !! end
14845
14846 !! test
14847 Image: frameless can reduce in size
14848 !! options
14849 parsoid=wt2html,wt2wt,html2html
14850 !! wikitext
14851 [[File:Foobar.jpg|frameless|50px]]
14852 !! html/php
14853 <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>
14854 </p>
14855 !! html/parsoid
14856 <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>
14857 !! end
14858
14859 !! test
14860 Image: bitmap frameless can't be enlarged past original size, but vector can
14861 !! options
14862 parsoid=wt2html,wt2wt,html2html
14863 !! wikitext
14864 [[File:Foobar.jpg|frameless|2000px]]
14865
14866 [[File:Foobar.svg|frameless|2000px]]
14867 !! html/php
14868 <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>
14869 </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>
14870 </p>
14871 !! html/parsoid
14872 <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>
14873 <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>
14874 !! end
14875
14876 !! test
14877 Image: framed images are always unscaled.
14878 !! options
14879 parsoid=wt2html,wt2wt,html2html
14880 !! wikitext
14881 [[File:Foobar.jpg|frame]]
14882
14883 [[File:Foobar.jpg|frame|50px]]
14884
14885 [[File:Foobar.jpg|frame|50x50px]]
14886
14887 [[File:Foobar.jpg|frame|2000px]]
14888 !! html/php
14889 <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>
14890 <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>
14891 <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>
14892 <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>
14893
14894 !! html/parsoid
14895 <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>
14896 <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>
14897 <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>
14898 <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>
14899 !! end
14900
14901 ###################
14902
14903 !! test
14904 Link to image page- image page normally doesn't exists, hence edit link
14905 Add test with existing image page
14906 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
14907 !! wikitext
14908 [[:Image:test]]
14909 !! html
14910 <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>
14911 </p>
14912 !! end
14913
14914 !! test
14915 T20784 Link to non-existent image page with caption should use caption as link text
14916 !! wikitext
14917 [[:Image:test|caption]]
14918 !! html
14919 <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>
14920 </p>
14921 !! end
14922
14923 !! test
14924 Frameless image caption with a free URL
14925 !! wikitext
14926 [[File:Foobar.jpg|http://example.com]]
14927 !! html/php
14928 <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>
14929 </p>
14930 !! html/parsoid
14931 <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>
14932 !! end
14933
14934 !! test
14935 Thumbnail image caption with a free URL
14936 !! options
14937 thumbsize=220
14938 !! wikitext
14939 [[File:Foobar.jpg|thumb|http://example.com]]
14940 !! html/php
14941 <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>
14942
14943 !! html/parsoid
14944 <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" href="http://example.com">http://example.com</a></figcaption></figure>
14945 !! end
14946
14947 !! test
14948 Thumbnail image caption with a free URL and explicit alt
14949 !! options
14950 thumbsize=220
14951 parsoid=wt2html,wt2wt,html2html
14952 !! wikitext
14953 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
14954 !! html/php
14955 <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>
14956
14957 !! html/parsoid
14958 <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" href="http://example.com">http://example.com</a></figcaption></figure>
14959 !! end
14960
14961 !! test
14962 SVG thumbnails with no language set
14963 !! options
14964 !! wikitext
14965 [[File:Foobar.svg|thumb|caption]]
14966 !! html/php
14967 <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>
14968
14969 !! html/parsoid
14970 <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>
14971 !! end
14972
14973 !! test
14974 SVG thumbnails with language de
14975 !! options
14976 parsoid=wt2html,wt2wt,html2html
14977 !! wikitext
14978 [[File:Foobar.svg|thumb|caption|lang=de]]
14979 !! html/php
14980 <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>
14981
14982 !! html/parsoid
14983 <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>
14984 !! end
14985
14986 !! test
14987 SVG thumbnails with invalid language code
14988 !! options
14989 parsoid=wt2html,wt2wt,html2html
14990 !! wikitext
14991 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
14992 !! html/php
14993 <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>
14994
14995 !! html/parsoid
14996 <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>
14997 !! end
14998
14999 !! test
15000 T3887: A ISBN with a thumbnail
15001 !! wikitext
15002 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15003 !! html/php
15004 <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>
15005
15006 !! html/parsoid
15007 <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>
15008 !! end
15009
15010 !! test
15011 T3887: A RFC with a thumbnail
15012 !! wikitext
15013 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15014 !! html/php
15015 <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>
15016
15017 !! html/parsoid
15018 <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">RFC 12354</a></figcaption></figure>
15019 !! end
15020
15021 !! test
15022 T3887: A mailto link with a thumbnail
15023 !! wikitext
15024 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15025 !! html/php
15026 <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>
15027
15028 !! html/parsoid
15029 <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" href="mailto:nobody@example.com">mailto:nobody@example.com</a></figcaption></figure>
15030 !! end
15031
15032 # Pending resolution to T2368
15033 !! test
15034 T2648: Frameless image caption with a link
15035 !! wikitext
15036 [[File:Foobar.jpg|text with a [[link]] in it]]
15037 !! html/php
15038 <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>
15039 </p>
15040 !! html/parsoid
15041 <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>
15042 !! end
15043
15044 !! test
15045 T2648: Frameless image caption with a link (suffix)
15046 !! wikitext
15047 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15048 !! html/php
15049 <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>
15050 </p>
15051 !! html/parsoid
15052 <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>
15053 !! end
15054
15055 !! test
15056 T2648: Frameless image caption with an interwiki link
15057 !! wikitext
15058 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15059 !! html/php
15060 <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>
15061 </p>
15062 !! html/parsoid
15063 <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>
15064 !! end
15065
15066 !! test
15067 T2648: Frameless image caption with a piped interwiki link
15068 !! wikitext
15069 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15070 !! html/php
15071 <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>
15072 </p>
15073 !! html/parsoid
15074 <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>
15075 !! end
15076
15077 !! test
15078 T107474: Frameless image caption with <nowiki>
15079 !! wikitext
15080 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15081 !! html/parsoid
15082 <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>
15083 !! end
15084
15085 !! test
15086 Escape HTML special chars in image alt text
15087 !! wikitext
15088 [[File:Foobar.jpg|& < > "]]
15089 !! html/php
15090 <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>
15091 </p>
15092 !! html/parsoid
15093 <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>
15094 !! end
15095
15096 !! test
15097 Escape HTML special chars in image alt text with LanguageConverter
15098 !! options
15099 language=zh
15100 !! wikitext
15101 [[File:Foobar.jpg|& < > "]]
15102 !! html/php
15103 <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>
15104 </p>
15105 !! html/parsoid
15106 <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>
15107 !! end
15108
15109 !! test
15110 Entities in file name and attributes
15111 !! wikitext
15112 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
15113 !! html/php
15114 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
15115 </p>
15116 !! html/parsoid
15117 <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>
15118 !! end
15119
15120 !! test
15121 T2499: Alt text should have &#1234;, not &amp;1234;
15122 !! wikitext
15123 [[File:Foobar.jpg|&#9792;]]
15124 !! html/php
15125 <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>
15126 </p>
15127 !! html/parsoid
15128 <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>
15129 !! end
15130
15131 !! test
15132 Broken image caption with link
15133 !! options
15134 parsoid=wt2html,wt2wt,html2html
15135 !! wikitext
15136 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
15137 !! html/php
15138 <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.
15139 </p>
15140 !! html/parsoid
15141 <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>
15142 !! end
15143
15144 !! test
15145 Image caption containing another image
15146 !! wikitext
15147 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
15148 !! html/php
15149 <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>
15150
15151 !! html/parsoid
15152 <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>
15153 !! end
15154
15155 !! test
15156 Image: caption containing a newline
15157 !! wikitext
15158 [[File:Foobar.jpg|This
15159 *is some text]]
15160 !! html/php
15161 <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>
15162 </p>
15163 !! html/parsoid
15164 <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>
15165 !!end
15166
15167 !!test
15168 Image: caption containing leading space
15169 (The leading space should not trigger nowiki escaping in wt2wt mode)
15170 !! wikitext
15171 [[File:Foobar.jpg|thumb| bar]]
15172 !! html/php
15173 <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>
15174
15175 !! html/parsoid
15176 <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>
15177 !!end
15178
15179 !! test
15180 Image: caption containing a table
15181 !! options
15182 parsoid=wt2html,wt2wt,html2html
15183 !! wikitext
15184 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
15185 {|
15186 ! Foo !! Bar
15187 |-
15188 | Foo1 || Bar1
15189 |}
15190 and some more text.]]
15191 !! html/php
15192 <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>
15193
15194 !! html/parsoid
15195 <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
15196 <table>
15197 <tbody>
15198 <tr><th>Foo </th><th>Bar</th></tr>
15199 <tr>
15200 <td>Foo1 </td>
15201 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
15202 !! end
15203
15204 !! test
15205 T5090: External links other than http: in image captions
15206 !! wikitext
15207 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
15208 !! html/php
15209 <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>
15210
15211 !! html/parsoid
15212 <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" href="irc://example.net">irc</a> and <a rel="mw:ExtLink" href="https://example.com">Secure</a> ext links in it.</figcaption></figure>
15213 !! end
15214
15215 !! test
15216 Custom class
15217 !! options
15218 parsoid=wt2html,wt2wt,html2html
15219 !! wikitext
15220 [[Image:foobar.jpg|a|class=b]]
15221 !! html/php
15222 <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>
15223 </p>
15224 !! html/parsoid
15225 <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>
15226 !! end
15227
15228 !! test
15229 Localized image handling (1).
15230 !! options
15231 parsoid=wt2html,wt2wt,html2html
15232 language=es
15233 !! wikitext
15234 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
15235 !! html/php
15236 <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>
15237
15238 !! html/parsoid
15239 <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>
15240 !! end
15241
15242 !! test
15243 Localized image handling (2).
15244 !! options
15245 thumbsize=220
15246 parsoid=wt2html,wt2wt,html2html
15247 language=es
15248 !! wikitext
15249 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
15250 !! html/php
15251 <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>
15252
15253 !! html/parsoid
15254 <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>
15255 !! end
15256
15257 !! test
15258 Localized image handling (3).
15259 !! options
15260 language=fa
15261 parsoid=html2wt
15262 !! html/parsoid
15263 <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>
15264 !! wikitext
15265 [[File:Foobar.jpg|بندانگشتی]]
15266 !! end
15267
15268 !! test
15269 "border", "frameless" and "class" attributes on an image.
15270 !! options
15271 thumbsize=220
15272 parsoid=wt2html,wt2wt,html2html
15273 !! wikitext
15274 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
15275 !! html/php
15276 <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>
15277 </p>
15278 !! html/parsoid
15279 <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>
15280 !! end
15281
15282 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
15283 !! test
15284 Invalid image attributes (T64500)
15285 !! options
15286 thumbsize=220
15287 parsoid=wt2html,wt2wt,html2html
15288 !! wikitext
15289 [[File:Foobar.jpg|thumb|float|left|caption]]
15290
15291 [[File:Foobar.jpg|thumb|righ|caption]]
15292
15293 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
15294 !! html/php
15295 <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>
15296 <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>
15297 <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>
15298
15299 !! html/parsoid
15300 <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>
15301 <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>
15302 <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>
15303 !! end
15304
15305 !! article
15306 File:Barfoo.jpg
15307 !! text
15308 #REDIRECT [[File:Barfoo.jpg]]
15309 !! endarticle
15310
15311 # FIXME: Parsoid should run this test -- but we'd need to teach the
15312 # mockAPI about the redirected Barfoo.jpg image.
15313 !! test
15314 Redirected image
15315 !! wikitext
15316 [[Image:Barfoo.jpg]]
15317 !! html/php
15318 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
15319 </p>
15320 !! end
15321
15322 !! test
15323 Missing image with uploads disabled
15324 !! options
15325 wgEnableUploads=0
15326 !! wikitext
15327 [[File:Foobaz.jpg]]
15328 !! html/php
15329 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
15330 </p>
15331 !! html/parsoid
15332 <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>
15333 !! end
15334
15335 # Parsoid-specific testing for images
15336 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
15337 # Currently imperfect due to a flaw in the Parsoid testrunner
15338 # Work in progress
15339 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
15340 # image tests.
15341
15342 !! test
15343 Parsoid-specific image handling - simple image with size and middle alignment
15344 !! wikitext
15345 [[File:Foobar.jpg|middle|50px]]
15346 !! html/parsoid
15347 <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>
15348 !! end
15349
15350 !! test
15351 Parsoid-specific image handling - simple image with size, middle alignment,
15352 non-standard namespace alias
15353 !! options
15354 parsoid=wt2wt,wt2html,html2html
15355 !! wikitext
15356 [[Image:Foobar.jpg|middle|50px]]
15357 !! html/parsoid
15358 <p><figure-inline class="mw-valign-middle" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a></figure-inline></p>
15359 !! end
15360
15361 !! test
15362 Parsoid-specific image handling - simple image with size and middle alignment
15363 (existing content)
15364 !! wikitext
15365 [[File:Foobar.jpg|50px|middle]]
15366 !! html/parsoid
15367 <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>
15368 !! end
15369
15370 !! test
15371 Parsoid-specific image handling - simple image with size and middle alignment
15372 and non-standard namespace name
15373 !! options
15374 parsoid=wt2html,wt2wt,html2html
15375 !! wikitext
15376 [[Image:Foobar.jpg|50px|middle]]
15377 !! html/parsoid
15378 <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>
15379 !! end
15380
15381 !! test
15382 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
15383 !! wikitext
15384 [[File:Foobar.jpg|500x10px|baseline|caption]]
15385 !! html/parsoid
15386 <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>
15387 !! end
15388
15389 !! test
15390 Parsoid-specific image handling - simple image with border and size spec
15391 !! wikitext
15392 [[File:Foobar.jpg|50px|border|caption]]
15393 !! html/parsoid
15394 <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>
15395 !! end
15396
15397 !! test
15398 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15399 !! wikitext
15400 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
15401 !! html/parsoid
15402 <figure class="mw-default-size mw-halign-left mw-valign-baseline" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption content</figcaption></figure>
15403 !! end
15404
15405 !! test
15406 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15407 (existing content)
15408 !! wikitext
15409 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
15410 !! html/parsoid
15411 <figure class="mw-default-size mw-halign-left mw-valign-baseline" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"left","ak":"left"},{"ck":"baseline","ak":"baseline"},{"ck":"caption","ak":"caption content"}]}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"25","width":"220"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>caption content</figcaption></figure>
15412 !! end
15413
15414 !! test
15415 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
15416 !! wikitext
15417 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
15418 !! html/parsoid
15419 <figure class="mw-halign-right mw-valign-middle" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50"/></a><figcaption>caption</figcaption></figure>
15420 !! end
15421
15422 !! test
15423 Parsoid-specific image handling - thumbnail with specific size, halign,
15424 valign, and caption (existing content)
15425 !! wikitext
15426 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
15427 !! html/parsoid
15428 <figure class="mw-halign-right mw-valign-middle" typeof="mw:Image/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"width","ak":"50x50px"},{"ck":"right","ak":"right"},{"ck":"middle","ak":"middle"},{"ck":"caption","ak":"caption"}],"size":"50x50"}'><a href="./File:Foobar.jpg" data-parsoid='{"a":{"href":"./File:Foobar.jpg"}}'><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/50px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="6" width="50" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"6","width":"50"},"sa":{"resource":"File:Foobar.jpg"}}'/></a><figcaption>caption</figcaption></figure>
15429 !! end
15430
15431 !! test
15432 Parsoid-specific image handling - framed image with specific size and caption
15433 (size is ignored)
15434 !! options
15435 parsoid=wt2html,wt2wt,html2html
15436 !! wikitext
15437 [[File:Foobar.jpg|frame|500x50px|caption]]
15438 !! html/parsoid
15439 <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>
15440 !! end
15441
15442 !! test
15443 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption
15444 (size is ignored)
15445 !! options
15446 parsoid=wt2html,wt2wt,html2html
15447 !! wikitext
15448 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
15449 !! html/parsoid
15450 <figure class="mw-halign-left mw-valign-baseline" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure>
15451 !! end
15452
15453 !! test
15454 Parsoid-specific image handling - frameless image with specific size, border, and caption
15455 !! wikitext
15456 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
15457 !! html/parsoid
15458 <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>
15459 !! end
15460
15461 !! test
15462 Parsoid-specific image handling - simple image with a formatted caption
15463 !! wikitext
15464 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
15465 !! html/parsoid
15466 <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>
15467 !! end
15468
15469 !! test
15470 Parsoid-specific image handling - caption with a template in it
15471 !! wikitext
15472 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
15473 !! html/parsoid
15474 <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>
15475 !! end
15476
15477 !! test
15478 Parsoid-specific image handling - caption with unbalanced tags in it
15479 !! options
15480 parsoid=wt2html,wt2wt,html2html
15481 !! wikitext
15482 foo
15483 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
15484 bar
15485 !! html/parsoid
15486 <p>foo</p>
15487 <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>
15488 <p>bar</p>
15489 !! end
15490
15491 !! test
15492 Parsoid-specific image handling - empty caption (1)
15493 !! options
15494 parsoid=wt2html,wt2wt
15495 !! wikitext
15496 [[File:Foobar.jpg|thumb|]]
15497 !! html/parsoid
15498 <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>
15499 !! end
15500
15501 # empty captions don't get serialized unless we're in the "round trip" case
15502 !! test
15503 Parsoid-specific image handling - empty caption (2)
15504 !! options
15505 parsoid=html2wt
15506 !! html/parsoid
15507 <figure class="mw-default-size" typeof="mw:Image/Thumb">
15508 <a href="./File:Foobar.jpg">
15509 <img resource="./File:Foobar.jpg"
15510 src="//example.com/images/3/3a/Foobar.jpg"
15511 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
15512 height="25" width="220"/>
15513 </a>
15514 <figcaption></figcaption>
15515 </figure>
15516 !! wikitext
15517 [[File:Foobar.jpg|thumb]]
15518 !! end
15519
15520 !! test
15521 Parsoid-specific image handling - whitespace caption
15522 !! wikitext
15523 [[File:Foobar.jpg|thumb| ]]
15524 !! html/parsoid
15525 <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>
15526 !! end
15527
15528 !! test
15529 Parsoid-specific image handling - lang option
15530 !! wikitext
15531 foo
15532 [[File:Foobar.svg|lang=de|caption]]
15533 bar
15534 !! html/parsoid
15535 <p>foo
15536 <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>
15537 bar</p>
15538 !! end
15539
15540 ## Edge case bugs in Parsoid from T93580
15541 !! test
15542 T93580: 1. Templated <ref> inside block images
15543 !! wikitext
15544 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
15545
15546 <references />
15547 !! html/parsoid
15548 <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: <span about="#mwt5" class="mw-ref" id="cite_ref-1" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;ref>foo&lt;/ref>"}},"i":0}}]}'><a href="./Main_Page#cite_note-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></figcaption></figure>
15549
15550 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text" data-parsoid="{}">foo</span></li></ol>
15551 !! end
15552
15553 !! test
15554 T93580: 2. <ref> inside inline images
15555 !! wikitext
15556 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
15557
15558 <references />
15559 !! html/parsoid
15560 <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;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,78,5,6]}&#39; data-mw=&#39;{\"name\":\"ref\",\"body\":{\"id\":\"mw-reference-text-cite_note-1\"},\"attrs\":{}}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>"}'><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>
15561
15562 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
15563 !! end
15564
15565 !! test
15566 T93580: 3. Templated <ref> inside inline images
15567 !! wikitext
15568 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
15569
15570 <references />
15571 !! html/parsoid
15572 <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;span about=\"#mwt2\" class=\"mw-ref\" id=\"cite_ref-1\" rel=\"dc:references\" typeof=\"mw:Transclusion mw:Extension/ref\" data-parsoid=&#39;{\"dsr\":[64,96,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;lt;ref>{{echo|foo}}&amp;lt;/ref>\"}},\"i\":0}}]}&#39;>&lt;a href=\"./Main_Page#cite_note-1\" style=\"counter-reset: mw-Ref 1;\" data-parsoid=\"{}\">&lt;span class=\"mw-reflink-text\" data-parsoid=\"{}\">[1]&lt;/span>&lt;/a>&lt;/span>"}'><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>
15573
15574 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt6" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-1" id="cite_note-1"><a href="./Main_Page#cite_ref-1" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-1" class="mw-reference-text">foo</span></li></ol>
15575 !! end
15576
15577 ###
15578 ### Subpages
15579 ###
15580 !! article
15581 Subpage test/subpage
15582 !! text
15583 foo
15584 !! endarticle
15585
15586 !! test
15587 Subpage link
15588 !! options
15589 subpage title=[[Subpage test]]
15590 !! wikitext
15591 [[/subpage]]
15592 !! html
15593 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
15594 </p>
15595 !! end
15596
15597 !! test
15598 Subpage noslash link
15599 !! options
15600 subpage title=[[Subpage test]]
15601 !! wikitext
15602 [[/subpage/]]
15603 !! html
15604 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
15605 </p>
15606 !! end
15607
15608 !! article
15609 Subpage test/1/2/subpage
15610 !! text
15611 blah
15612 !! endarticle
15613
15614 !! test
15615 Relative subpage noslash link
15616 !! options
15617 parsoid=wt2wt,wt2html,html2html
15618 subpage title=[[Subpage test/1/2/3/4]]
15619 !! wikitext
15620 [[../../subpage/]]
15621
15622 [[../../subpage]]
15623 !! html/php
15624 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
15625 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
15626 </p>
15627 !! html/parsoid
15628 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
15629 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
15630 !! end
15631
15632 !! test
15633 Parsoid: dot-slash prefixed wikilinks
15634 !! wikitext
15635 [[./foo]]
15636
15637 [[././bar]]
15638
15639 [[././baz/]]
15640 !! html/php
15641 <p>[[./foo]]
15642 </p><p>[[././bar]]
15643 </p><p>[[././baz/]]
15644 </p>
15645 !! html/parsoid
15646 <p>[[./foo]]
15647 </p><p>[[././bar]]
15648 </p><p>[[././baz/]]
15649 </p>
15650 !! end
15651
15652 !! test
15653 Render invalid page names as plain text (T53090)
15654 !! wikitext
15655 [[./../foo|bar]]
15656 [[foo�|bar]]
15657 [[foo/.|bar]]
15658 [[foo/..|bar]]
15659 [[foo~~~bar]]
15660 [[foo>bar]]
15661 [[foo[bar]]
15662 [[.]]
15663 [[..]]
15664 [[foo././bar]]
15665 [[foo[http://example.com]xyz]]
15666
15667 [[{{echo|./../foo}}|bar]]
15668 [[{{echo|foo/.}}|bar]]
15669 [[{{echo|foo/..}}|bar]]
15670 [[{{echo|foo~~~~bar}}]]
15671 [[{{echo|foo>bar}}]]
15672 [[{{echo|foo././bar}}]]
15673 [[{{echo|foo{bar}}]]
15674 [[{{echo|foo}bar}}]]
15675 [[{{echo|foo[bar}}]]
15676 [[{{echo|foo]bar}}]]
15677 [[{{echo|foo<bar}}]]
15678 !!html/php
15679 <p>[[./../foo|bar]]
15680 [[foo�|bar]]
15681 [[foo/.|bar]]
15682 [[foo/..|bar]]
15683 [[foo~~~bar]]
15684 [[foo&gt;bar]]
15685 [[foo[bar]]
15686 [[.]]
15687 [[..]]
15688 [[foo././bar]]
15689 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
15690 </p><p>[[./../foo|bar]]
15691 [[foo/.|bar]]
15692 [[foo/..|bar]]
15693 [[foo~~~~bar]]
15694 [[foo&gt;bar]]
15695 [[foo././bar]]
15696 [[foo{bar]]
15697 [[foo}bar]]
15698 [[foo[bar]]
15699 [[foo]bar]]
15700 [[foo&lt;bar]]
15701 </p>
15702 !!html/parsoid
15703 <p>[[./../foo|bar]]
15704 [[foo�|bar]]
15705 [[foo/.|bar]]
15706 [[foo/..|bar]]
15707 [[foo~~~bar]]
15708 [[foo>bar]]
15709 [[foo[bar]]
15710 [[.]]
15711 [[..]]
15712 [[foo././bar]]
15713 [[foo<a rel="mw:ExtLink" href="http://example.com"></a>xyz]]</p>
15714
15715 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
15716 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
15717 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
15718 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
15719 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
15720 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
15721 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
15722 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
15723 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
15724 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
15725 [[<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>
15726 !!end
15727
15728 !! test
15729 Disabled subpages
15730 !! wikitext
15731 [[/subpage]]
15732 !! html
15733 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
15734 </p>
15735 !! end
15736
15737 !! test
15738 T2561: {{/Subpage}}
15739 !! options
15740 subpage title=[[Page]]
15741 !! wikitext
15742 {{/Subpage}}
15743 !! html
15744 <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>
15745 </p>
15746 !! end
15747
15748 ###
15749 ### Categories
15750 ###
15751 !! article
15752 Category:MediaWiki User's Guide
15753 !! text
15754 blah
15755 !! endarticle
15756
15757 !! test
15758 Link to category
15759 !! wikitext
15760 [[:Category:MediaWiki User's Guide]]
15761 !! html
15762 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
15763 </p>
15764 !! end
15765
15766 !! test
15767 Simple category
15768 !! options
15769 cat
15770 !! wikitext
15771 [[Category:MediaWiki User's Guide]]
15772 !! html/php
15773 cat=MediaWiki_User's_Guide sort=
15774 !! html/parsoid
15775 <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"}}'/>
15776 !! end
15777
15778 !! test
15779 PAGESINCATEGORY invalid title fatal (r33546 fix)
15780 !! wikitext
15781 {{PAGESINCATEGORY:<bogus>}}
15782 !! html
15783 <p>0
15784 </p>
15785 !! end
15786
15787 !! test
15788 Category with different sort key
15789 !! options
15790 cat
15791 !! wikitext
15792 [[Category:MediaWiki User's Guide|Foo]]
15793 !! html/php
15794 cat=MediaWiki_User's_Guide sort=Foo
15795 !! html/parsoid
15796 <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"}}'/>
15797 !! end
15798
15799 !! test
15800 Category with identical sort key
15801 !! options
15802 cat
15803 !! wikitext
15804 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15805 !! html/php
15806 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
15807 !! html/parsoid
15808 <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"}}'/>
15809 !! end
15810
15811 !! test
15812 Category with empty sort key
15813 !! options
15814 cat
15815 pst
15816 !! wikitext
15817 [[Category:MediaWiki User's Guide|]]
15818 !! html/php
15819 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15820 !! end
15821
15822 !! test
15823 Category with empty sort key and parentheses
15824 !! options
15825 cat
15826 pst
15827 !! wikitext
15828 [[Category:Foo (bar)|]]
15829 !! html/php
15830 [[Category:Foo (bar)|Foo]]
15831 !! end
15832
15833 !! test
15834 Category with link tail
15835 !! options
15836 cat
15837 pst
15838 !! wikitext
15839 123[[Category:Foo]]456
15840 !! html/php
15841 123[[Category:Foo]]456
15842 !! end
15843
15844 !! test
15845 Category with template
15846 !! options
15847 cat
15848 pst
15849 !! wikitext
15850 [[Category:{{echo|Foo}}]]
15851 !! html/php
15852 [[Category:{{echo|Foo}}]]
15853 !! end
15854
15855 !! test
15856 Category with template in sort key
15857 !! options
15858 cat
15859 pst
15860 !! wikitext
15861 [[Category:Foo|{{echo|Bar}}]]
15862 !! html/php
15863 [[Category:Foo|{{echo|Bar}}]]
15864 !! end
15865
15866 !! test
15867 Category with template in sort key and title
15868 !! options
15869 cat
15870 pst
15871 !! wikitext
15872 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15873 !! html/php
15874 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15875 !! end
15876
15877 ## We used to, but no longer wt2wt this test since the default serializer
15878 ## will normalize all categories to serialize on their own line.
15879 ## This wikitext usage is going to be fairly uncommon in production and
15880 ## selser will take care of preserving formatting in those scenarios.
15881 !! test
15882 Category / paragraph interactions
15883 !! options
15884 parsoid=wt2html
15885 !! wikitext
15886 Foo [[Category:Baz]] Bar
15887
15888 Foo [[Category:Baz]]
15889 Bar
15890
15891 Foo
15892 [[Category:Baz]]
15893 Bar
15894
15895 Foo
15896 [[Category:Baz]] Bar
15897
15898 Foo
15899 [[Category:Baz]]
15900 [[Category:Baz]]
15901 [[Category:Baz]]
15902 Bar
15903
15904 [[Category:Baz]]
15905 [[Category:Baz]]
15906 [[Category:Baz]]
15907
15908 [[Category:Baz]]
15909 {{echo|[[Category:Baz]]}}
15910 [[Category:Baz]]
15911 !! html/php
15912 <p>Foo Bar
15913 </p><p>Foo
15914 Bar
15915 </p><p>Foo
15916 Bar
15917 </p><p>Foo Bar
15918 </p><p>Foo
15919 Bar
15920 </p>
15921 !! html/parsoid
15922 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15923 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15924 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15925 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15926 <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 <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}}]}'/></p>
15927 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
15928 !! end
15929
15930 ## We used to, but no longer wt2wt this test since the default serializer
15931 ## will normalize all categories to serialize on their own line.
15932 ## This wikitext usage is going to be fairly uncommon in production and
15933 ## selser will take care of preserving formatting in those scenarios.
15934 ##
15935 ## The whitespace on the empty line is part of the test. Please do not delete
15936 !! test
15937 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
15938 !! options
15939 parsoid=wt2html
15940 !! wikitext
15941 This
15942
15943 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
15944
15945 {{echo|[[Category:Foo]] and so should this!}}
15946 !! html/php
15947 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
15948 </p>
15949 !! html/parsoid
15950 <p>This
15951
15952 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
15953
15954 <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>
15955 !! end
15956
15957 ## Parsoid will not try to wt2wt this while preserving newlines because
15958 ## it suppresses excess newlines within list items -- and we don't want to
15959 ## introduce a special case just for categories, which is, in reality somewhat
15960 ## odd behavior -- categories are unlikely to be used in list items like this
15961 ## in top-level pages and are only likely to show up in template-generated
15962 ## list items where this RT-ing is a non-issue.
15963 ##
15964 ## The whitespace on the empty line is part of the test. Please do not delete
15965 !! test
15966 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
15967 !! options
15968 parsoid=wt2html
15969 !! wikitext
15970 * This
15971
15972 [[Category:Foo]] and this should be part of the same list item
15973 * So should this
15974
15975 {{echo|[[Category:Foo]] and this should be part of the same list item}}
15976 !! html
15977 <ul><li>This and this should be part of the same list item</li>
15978 <li>So should this and this should be part of the same list item</li></ul>
15979 !! html/parsoid
15980 <ul>
15981 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
15982 <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>
15983 </ul>
15984 !! end
15985
15986 ## Newlines and categories that follow the last item of a list
15987 ## are treated differently because this (list followed by categories)
15988 ## is an extremely common pattern on wikis.
15989 !! test
15990 3. Categories and newlines: newline suppression for last list item should RT properly
15991 !! wikitext
15992 * a
15993 * b
15994
15995 [[Category:Foo]]
15996
15997 [[Category:Bar]]
15998 [[Category:Baz]]
15999 !! html/parsoid
16000 <ul><li> a</li>
16001 <li> b</li></ul>
16002
16003 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16004
16005 <link rel="mw:PageProp/Category" href="./Category:Bar" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16006 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16007 !! end
16008
16009 !! test
16010 4. Categories and newlines: newline suppression for last list item should RT properly
16011 !! wikitext
16012 * a
16013 **** b
16014
16015 [[Category:Foo]]
16016 !! html/parsoid
16017 <ul><li> a
16018 <ul><li><ul><li><ul><li> b</li></ul></li></ul></li></ul></li></ul>
16019
16020 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16021 !! end
16022
16023 ## only wt2html for this to make sure the algo only applies to the rightmost path
16024 !! test
16025 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16026 !! options
16027 parsoid=wt2html
16028 !! wikitext
16029 * a
16030 ** b
16031 [[Category:Foo]]
16032 * c
16033 ** d
16034 [[Category:Foo]]
16035 !! html/parsoid
16036 <ul><li> a
16037 <ul><li> b
16038 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16039 <li> c
16040 <ul><li> d</li></ul></li></ul>
16041 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16042 !! end
16043
16044 ## We used to, but no longer wt2wt this test since the default serializer
16045 ## will normalize all categories to serialize on their own line.
16046 ## This wikitext usage is going to be fairly uncommon in production and
16047 ## selser will take care of preserving formatting in those scenarios.
16048 !! test
16049 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16050 !! options
16051 parsoid=wt2html
16052 !! wikitext
16053 * a [[Category:Foo]]
16054 !! html/parsoid
16055 <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>
16056 !! end
16057
16058 # This test also demonstrates because of newline+category tunneling
16059 # through the list hander, template wrapping doesn't expand to the
16060 # containing list when the list item swallows the category.
16061 !! test
16062 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16063 !! wikitext
16064 * {{echo|a
16065 [[Category:Foo]]}}
16066 !! html/parsoid
16067 <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
16068 </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>
16069 !! end
16070
16071 !! test
16072 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
16073 !! wikitext
16074 * a
16075
16076 {{echo|[[Category:Foo]]
16077 [[Category:Bar]]}}
16078 [[Category:Baz]]
16079 !! html/parsoid
16080 <ul><li> a</li></ul>
16081
16082 <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">
16083 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16084 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16085 !! end
16086
16087 !! test
16088 9. Categories and newlines: should behave properly with linkprefix (T87753)
16089 !! options
16090 language=ar
16091 !! wikitext
16092 foo bar
16093 foo bar
16094 [[تصنيف:Foo]]
16095 [[تصنيف:Bar]]
16096 !! html/php
16097 <p>foo bar
16098 foo bar
16099 </p>
16100 !! html/parsoid
16101 <p>foo bar
16102 foo bar</p>
16103 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
16104 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
16105 !! end
16106
16107 !! test
16108 10. No regressions on internal links following category (T174639)
16109 !! options
16110 parsoid=wt2html,html2html
16111 !! wikitext
16112 [[Category:Foo]]<div>a
16113
16114 [[Foo]]</div>
16115 !! html/php
16116 <div>a
16117 <a href="/wiki/Foo" title="Foo">Foo</a></div>
16118
16119 !! html/parsoid
16120 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
16121
16122 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
16123 !! end
16124
16125 # Note that Parsoid differs slightly from PHP due to T175421
16126 !! test
16127 11. Special case where only newlines separate links (T175416)
16128 !! options
16129 parsoid=wt2html,html2html
16130 !! wikitext
16131 [[Category:Foo]]
16132
16133 [[Foo]][[es:Alimento]]
16134
16135 [[Foo]]
16136 !! html/php
16137 <p><br />
16138 <a href="/wiki/Foo" title="Foo">Foo</a>
16139 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
16140 </p>
16141 !! html/parsoid
16142 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16143
16144 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16145
16146 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
16147 !! end
16148
16149 !! test
16150 Category links with multiple namespaces
16151 !! wikitext
16152 [[Category:Project:Foo]]
16153 !! html/parsoid
16154 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
16155 !! end
16156
16157 !! test
16158 Parsoid: Serialize link to category page with colon escape
16159 !! options
16160 parsoid
16161 !! wikitext
16162
16163 [[:Category:Foo]]
16164 [[:Category:Foo|Bar]]
16165 !! html
16166 <p>
16167 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
16168 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
16169 </p>
16170 !! end
16171
16172 # We used to, but no longer wt2wt this test since the default serializer
16173 # will normalize all categories to serialize on their own line.
16174 # This wikitext usage is going to be fairly uncommon in production and
16175 # selser will take care of preventing whitespace insertion if this
16176 # occurs in an article.
16177 #
16178 # html2html disabled for the same reason (whitespace insertion between
16179 # x and y).
16180 #
16181 # html2wt disabled because it localizes the "Category" namespace.
16182 !! test
16183 Link prefix/suffixes aren't applied to category links
16184 !! options
16185 parsoid=wt2html
16186 language=is
16187 !! wikitext
16188 x[[Category:Foo]]y
16189 !! html/php
16190 <p>xy
16191 </p>
16192 !! html/parsoid
16193 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
16194 !! end
16195
16196 !! test
16197 Link prefix/suffixes aren't applied to language links
16198 !! options
16199 parsoid=wt2html
16200 language=is
16201 !! wikitext
16202 x[[es:Foo]]y
16203 !! html/php
16204 <p>xy
16205 </p>
16206 !! html/parsoid
16207 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
16208 !! end
16209
16210 !! test
16211 Parsoid: Serialize link to file page with colon escape
16212 !! options
16213 parsoid
16214 !! wikitext
16215
16216 [[:File:Foo.png]]
16217 [[:File:Foo.png|Bar]]
16218 !! html
16219 <p>
16220 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
16221 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
16222 </p>
16223 !! end
16224
16225 !! test
16226 Parsoid: Serialize a genuine category link without colon escape
16227 !! options
16228 parsoid
16229 !! wikitext
16230 [[Category:Foo]]
16231 [[Category:Foo|Bar]]
16232 !! html
16233 <link rel="mw:PageProp/Category" href="./Category:Foo">
16234 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
16235 !! end
16236
16237 !! test
16238 Normalize hrefs properly before testing for invalid link targets (T72894)
16239 !! options
16240 parsoid=html2wt
16241 !! html/parsoid
16242 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
16243 !! wikitext
16244 [[Category:Toxine bactérienne]]
16245 !! end
16246
16247 !! test
16248 Parsoid: Defaultsort
16249 !! wikitext
16250 {{DEFAULTSORT:Foo}}
16251 !! html/parsoid
16252 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
16253 !! end
16254
16255 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
16256 # But, this is a limitation of our representation and is documented in
16257 # TemplateHandler.js in processSpecialMagicWord
16258 !! test
16259 Parsoid: Defaultsort (template-generated)
16260 !! wikitext
16261 {{{{echo|DEFAULTSORT}}:Foo}}
16262 !! html/parsoid
16263 <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"}]]}'/>
16264 !! end
16265
16266 ###
16267 ### Inter-language links
16268 ###
16269 !! test
16270 Interlanguage links
16271 !! options
16272 ill
16273 !! wikitext
16274 [[es:Alimento]]
16275 [[fr:Nourriture]]
16276 [[zh:食品]]
16277 !! html/php
16278 es:Alimento fr:Nourriture zh:食品
16279 !! html/parsoid
16280 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16281 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
16282 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
16283 !! end
16284
16285 !! test
16286 Duplicate interlanguage links (T26502)
16287 !! options
16288 ill
16289 !! wikitext
16290 [[es:1]]
16291 [[es:2]]
16292 [[fr:1]]
16293 [[fr:2]]
16294 !! html/php
16295 es:1 fr:1
16296 !! html/parsoid
16297 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
16298 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
16299 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
16300 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
16301 !! end
16302
16303 ###
16304 ### Sections
16305 ###
16306 !! test
16307 Basic section headings
16308 !! wikitext
16309 == Headline 1 ==
16310 Some text
16311
16312 ==Headline 2==
16313 More
16314 ===Smaller headline===
16315 Blah blah
16316 !! html
16317 <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>
16318 <p>Some text
16319 </p>
16320 <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>
16321 <p>More
16322 </p>
16323 <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>
16324 <p>Blah blah
16325 </p>
16326 !! end
16327
16328 !! test
16329 Section headings with TOC
16330 !! wikitext
16331 == Headline 1 ==
16332 === Subheadline 1 ===
16333 ===== Skipping a level =====
16334 ====== Skipping a level ======
16335
16336 == Headline 2 ==
16337 Some text
16338 ===Another headline===
16339 !! html
16340 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16341 <ul>
16342 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
16343 <ul>
16344 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
16345 <ul>
16346 <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>
16347 <ul>
16348 <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>
16349 </ul>
16350 </li>
16351 </ul>
16352 </li>
16353 </ul>
16354 </li>
16355 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
16356 <ul>
16357 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
16358 </ul>
16359 </li>
16360 </ul>
16361 </div>
16362
16363 <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>
16364 <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>
16365 <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>
16366 <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>
16367 <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>
16368 <p>Some text
16369 </p>
16370 <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>
16371
16372 !! end
16373
16374 !! test
16375 TOC anchors don't collide
16376 !! wikitext
16377 __FORCETOC__
16378 == Headline 2 ==
16379 == Headline ==
16380 == Headline 2 ==
16381 == Headline ==
16382 !! html/php
16383 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16384 <ul>
16385 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
16386 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
16387 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
16388 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
16389 </ul>
16390 </div>
16391
16392 <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>
16393 <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>
16394 <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>
16395 <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>
16396
16397 !! end
16398
16399 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
16400 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
16401 !! test
16402 Handling of sections up to level 6 and beyond
16403 !! options
16404 parsoid=wt2html
16405 !! wikitext
16406 = Level 1 Heading=
16407 == Level 2 Heading==
16408 === Level 3 Heading===
16409 ==== Level 4 Heading====
16410 ===== Level 5 Heading=====
16411 ====== Level 6 Heading======
16412 ======= Level 7 Heading=======
16413 ======== Level 8 Heading========
16414 ========= Level 9 Heading=========
16415 ========== Level 10 Heading==========
16416 !! html/php
16417 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16418 <ul>
16419 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
16420 <ul>
16421 <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>
16422 <ul>
16423 <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>
16424 <ul>
16425 <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>
16426 <ul>
16427 <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>
16428 <ul>
16429 <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>
16430 <li class="toclevel-6 tocsection-7"><a href="#.3D_Level_7_Heading.3D"><span class="tocnumber">1.1.1.1.1.2</span> <span class="toctext">= Level 7 Heading=</span></a></li>
16431 <li class="toclevel-6 tocsection-8"><a href="#.3D.3D_Level_8_Heading.3D.3D"><span class="tocnumber">1.1.1.1.1.3</span> <span class="toctext">== Level 8 Heading==</span></a></li>
16432 <li class="toclevel-6 tocsection-9"><a href="#.3D.3D.3D_Level_9_Heading.3D.3D.3D"><span class="tocnumber">1.1.1.1.1.4</span> <span class="toctext">=== Level 9 Heading===</span></a></li>
16433 <li class="toclevel-6 tocsection-10"><a href="#.3D.3D.3D.3D_Level_10_Heading.3D.3D.3D.3D"><span class="tocnumber">1.1.1.1.1.5</span> <span class="toctext">==== Level 10 Heading====</span></a></li>
16434 </ul>
16435 </li>
16436 </ul>
16437 </li>
16438 </ul>
16439 </li>
16440 </ul>
16441 </li>
16442 </ul>
16443 </li>
16444 </ul>
16445 </div>
16446
16447 <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>
16448 <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>
16449 <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>
16450 <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>
16451 <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>
16452 <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>
16453 <h6><span class="mw-headline" id=".3D_Level_7_Heading.3D">= Level 7 Heading=</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=7" title="Edit section: = Level 7 Heading=">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
16454 <h6><span class="mw-headline" id=".3D.3D_Level_8_Heading.3D.3D">== Level 8 Heading==</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=8" title="Edit section: == Level 8 Heading==">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
16455 <h6><span class="mw-headline" id=".3D.3D.3D_Level_9_Heading.3D.3D.3D">=== Level 9 Heading===</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=9" title="Edit section: === Level 9 Heading===">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
16456 <h6><span class="mw-headline" id=".3D.3D.3D.3D_Level_10_Heading.3D.3D.3D.3D">==== Level 10 Heading====</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=10" title="Edit section: ==== Level 10 Heading====">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
16457
16458 !! html/parsoid
16459 <h1 id="Level_1_Heading" data-parsoid='{}'> Level 1 Heading</h1>
16460 <h2 id="Level_2_Heading" data-parsoid='{}'> Level 2 Heading</h2>
16461 <h3 id="Level_3_Heading" data-parsoid='{}'> Level 3 Heading</h3>
16462 <h4 id="Level_4_Heading" data-parsoid='{}'> Level 4 Heading</h4>
16463 <h5 id="Level_5_Heading" data-parsoid='{}'> Level 5 Heading</h5>
16464 <h6 id="Level_6_Heading" data-parsoid='{}'> Level 6 Heading</h6>
16465 <h6 id="=_Level_7_Heading=" data-parsoid='{}'><span id=".3D_Level_7_Heading.3D" typeof="mw:FallbackId"></span>= Level 7 Heading=</h6>
16466 <h6 id="==_Level_8_Heading==" data-parsoid='{}'><span id=".3D.3D_Level_8_Heading.3D.3D" typeof="mw:FallbackId"></span>== Level 8 Heading==</h6>
16467 <h6 id="===_Level_9_Heading===" data-parsoid='{}'><span id=".3D.3D.3D_Level_9_Heading.3D.3D.3D" typeof="mw:FallbackId"></span>=== Level 9 Heading===</h6>
16468 <h6 id="====_Level_10_Heading====" data-parsoid='{}'><span id=".3D.3D.3D.3D_Level_10_Heading.3D.3D.3D.3D" typeof="mw:FallbackId"></span>==== Level 10 Heading====</h6>
16469 !! end
16470
16471 !! test
16472 TOC regression (T11764)
16473 !! wikitext
16474 == title 1 ==
16475 === title 1.1 ===
16476 ==== title 1.1.1 ====
16477 === title 1.2 ===
16478 == title 2 ==
16479 === title 2.1 ===
16480 !! html
16481 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16482 <ul>
16483 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16484 <ul>
16485 <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>
16486 <ul>
16487 <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>
16488 </ul>
16489 </li>
16490 <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>
16491 </ul>
16492 </li>
16493 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16494 <ul>
16495 <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>
16496 </ul>
16497 </li>
16498 </ul>
16499 </div>
16500
16501 <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>
16502 <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>
16503 <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>
16504 <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>
16505 <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>
16506 <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>
16507
16508 !! end
16509
16510 !! test
16511 TOC for heading containing <span id="..."></span> (T96153)
16512 !! wikitext
16513 __FORCETOC__
16514 ==<span id="old-anchor"></span>New title==
16515 !! html/php
16516 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16517 <ul>
16518 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
16519 </ul>
16520 </div>
16521
16522 <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>
16523
16524 !! end
16525
16526 !! test
16527 TOC with wgMaxTocLevel=3 (T8204)
16528 !! options
16529 wgMaxTocLevel=3
16530 !! wikitext
16531 == title 1 ==
16532 === title 1.1 ===
16533 ==== title 1.1.1 ====
16534 === title 1.2 ===
16535 == title 2 ==
16536 === title 2.1 ===
16537 !! html
16538 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16539 <ul>
16540 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16541 <ul>
16542 <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>
16543 <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>
16544 </ul>
16545 </li>
16546 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16547 <ul>
16548 <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>
16549 </ul>
16550 </li>
16551 </ul>
16552 </div>
16553
16554 <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>
16555 <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>
16556 <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>
16557 <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>
16558 <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>
16559 <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>
16560
16561 !! end
16562
16563 !! test
16564 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
16565 !! options
16566 wgMaxTocLevel=3
16567 !! wikitext
16568 ==Section 1==
16569 ===Section 1.1===
16570 ====Section 1.1.1====
16571 ====Section 1.1.1.1====
16572 ==Section 2==
16573 !! html
16574 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16575 <ul>
16576 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
16577 <ul>
16578 <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>
16579 </ul>
16580 </li>
16581 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
16582 </ul>
16583 </div>
16584
16585 <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>
16586 <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>
16587 <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>
16588 <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>
16589 <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>
16590
16591 !! end
16592
16593
16594 !! test
16595 Resolving duplicate section names
16596 !! wikitext
16597 == Foo bar ==
16598 == Foo bar ==
16599 !! html
16600 <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>
16601 <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>
16602
16603 !! end
16604
16605 !! test
16606 Resolving duplicate section names with differing case (T12721)
16607 !! wikitext
16608 == Foo bar ==
16609 == Foo Bar ==
16610 !! html
16611 <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>
16612 <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>
16613
16614 !! end
16615
16616 !! article
16617 Template:sections
16618 !! text
16619 ===Section 1===
16620 ==Section 2==
16621 !! endarticle
16622
16623 !! test
16624 Template with sections, __NOTOC__
16625 !! wikitext
16626 __NOTOC__
16627 ==Section 0==
16628 {{sections}}
16629 ==Section 4==
16630 !! html
16631 <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>
16632 <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>
16633 <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>
16634 <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>
16635
16636 !! end
16637
16638 !! test
16639 __NOEDITSECTION__ keyword
16640 !! wikitext
16641 __NOEDITSECTION__
16642 ==Section 1==
16643 ==Section 2==
16644 !! html
16645 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
16646 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
16647
16648 !! end
16649
16650 !! test
16651 Link inside a section heading
16652 !! wikitext
16653 ==Section with a [[Main Page|link]] in it==
16654 !! html
16655 <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>
16656
16657 !! end
16658
16659 !! test
16660 TOC regression (T14077)
16661 !! wikitext
16662 __TOC__
16663 == title 1 ==
16664 === title 1.1 ===
16665 == title 2 ==
16666 !! html
16667 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16668 <ul>
16669 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16670 <ul>
16671 <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>
16672 </ul>
16673 </li>
16674 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
16675 </ul>
16676 </div>
16677
16678 <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>
16679 <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>
16680 <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>
16681
16682 !! end
16683
16684 !! test
16685 T3219 URL next to image (good)
16686 !! wikitext
16687 http://example.com [[File:Foobar.jpg]]
16688 !! html/php
16689 <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>
16690 </p>
16691 !! html/parsoid
16692 <p><a rel="mw:ExtLink" 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>
16693 !!end
16694
16695 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
16696 !! test
16697 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
16698 !! options
16699 parsoid=wt2html,html2html
16700 !! wikitext
16701 ===
16702 The line above must have a trailing space!
16703 === <!--
16704 --> <!-- -->
16705 But just in case it doesn't...
16706 !! html/php
16707 <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>
16708 <p>The line above must have a trailing space!
16709 </p>
16710 <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>
16711 <p>But just in case it doesn't...
16712 </p>
16713 !! html/parsoid
16714 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
16715 <p>The line above must have a trailing space!</p>
16716 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
16717 --> <!-- -->
16718 <p>But just in case it doesn't...</p>
16719 !! end
16720
16721 !! test
16722 Header with special characters (T27462)
16723 !! wikitext
16724 The tooltips shall not show entities to the user (ie. be double escaped)
16725
16726 == text > text ==
16727 section 1
16728
16729 == text < text ==
16730 section 2
16731
16732 == text & text ==
16733 section 3
16734
16735 == text ' text ==
16736 section 4
16737
16738 == text " text ==
16739 section 5
16740 !! html/php
16741 <p>The tooltips shall not show entities to the user (ie. be double escaped)
16742 </p>
16743 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16744 <ul>
16745 <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>
16746 <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>
16747 <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>
16748 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
16749 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
16750 </ul>
16751 </div>
16752
16753 <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>
16754 <p>section 1
16755 </p>
16756 <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>
16757 <p>section 2
16758 </p>
16759 <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>
16760 <p>section 3
16761 </p>
16762 <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>
16763 <p>section 4
16764 </p>
16765 <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>
16766 <p>section 5
16767 </p>
16768 !! html/parsoid
16769 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
16770
16771 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span> text > text </h2>
16772 <p>section 1</p>
16773
16774 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span> text &lt; text </h2>
16775 <p>section 2</p>
16776
16777 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span> text &amp; text </h2>
16778 <p>section 3</p>
16779
16780 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span> text ' text </h2>
16781 <p>section 4</p>
16782
16783 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span> text " text </h2>
16784 <p>section 5</p>
16785 !! end
16786
16787 !! test
16788 Header with space, plus and underscore as entity
16789 !! wikitext
16790 Id should not contain + for spaces
16791
16792 == Space between Text ==
16793 section 1
16794
16795 == Space-Entity&#32;between&#32;Text ==
16796 section 2
16797
16798 == Plus+between+Text ==
16799 section 3
16800
16801 == Plus-Entity&#43;between&#43;Text ==
16802 section 4
16803
16804 == Underscore_between_Text ==
16805 section 5
16806
16807 == Underscore-Entity&#95;between&#95;Text ==
16808 section 6
16809
16810 [[#Space between Text]]
16811 [[#Space-Entity&#32;between&#32;Text]]
16812 [[#Plus+between+Text]]
16813 [[#Plus-Entity&#43;between&#43;Text]]
16814 [[#Underscore_between_Text]]
16815 [[#Underscore-Entity&#95;between&#95;Text]]
16816 !! html/php
16817 <p>Id should not contain + for spaces
16818 </p>
16819 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16820 <ul>
16821 <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>
16822 <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>
16823 <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>
16824 <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>
16825 <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>
16826 <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>
16827 </ul>
16828 </div>
16829
16830 <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>
16831 <p>section 1
16832 </p>
16833 <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>
16834 <p>section 2
16835 </p>
16836 <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>
16837 <p>section 3
16838 </p>
16839 <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>
16840 <p>section 4
16841 </p>
16842 <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>
16843 <p>section 5
16844 </p>
16845 <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>
16846 <p>section 6
16847 </p><p><a href="#Space_between_Text">#Space between Text</a>
16848 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
16849 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
16850 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
16851 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
16852 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
16853 </p>
16854 !! html/parsoid
16855 <p>Id should not contain + for spaces</p>
16856
16857 <h2 id="Space_between_Text"> Space between Text </h2>
16858 <p>section 1</p>
16859
16860 <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>
16861 <p>section 2</p>
16862
16863 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span> Plus+between+Text </h2>
16864 <p>section 3</p>
16865
16866 <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>
16867 <p>section 4</p>
16868
16869 <h2 id="Underscore_between_Text"> Underscore_between_Text </h2>
16870 <p>section 5</p>
16871
16872 <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>
16873 <p>section 6</p>
16874
16875 <p><a rel="mw:WikiLink" href="./Main_Page#Space_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Space_between_Text"},"sa":{"href":"#Space between Text"}}'>#Space between Text</a>
16876 <a rel="mw:WikiLink" href="./Main_Page#Space-Entity_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Space-Entity_between_Text"},"sa":{"href":"#Space-Entity&amp;#32;between&amp;#32;Text"}}'>#Space-Entity between Text</a>
16877 <a rel="mw:WikiLink" href="./Main_Page#Plus+between+Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Plus+between+Text"},"sa":{"href":"#Plus+between+Text"}}'>#Plus+between+Text</a>
16878 <a rel="mw:WikiLink" href="./Main_Page#Plus-Entity+between+Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Plus-Entity+between+Text"},"sa":{"href":"#Plus-Entity&amp;#43;between&amp;#43;Text"}}'>#Plus-Entity+between+Text</a>
16879 <a rel="mw:WikiLink" href="./Main_Page#Underscore_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Underscore_between_Text"},"sa":{"href":"#Underscore_between_Text"}}'>#Underscore_between_Text</a>
16880 <a rel="mw:WikiLink" href="./Main_Page#Underscore-Entity_between_Text" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Underscore-Entity_between_Text"},"sa":{"href":"#Underscore-Entity&amp;#95;between&amp;#95;Text"}}'>#Underscore-Entity_between_Text</a></p>
16881 !! end
16882
16883 # Parsoid html2wt disabled because it adds padding spaces around =
16884 !! test
16885 Headers with excess '=' characters
16886 (Are similar tests necessary beyond the 1st level?)
16887 !! options
16888 parsoid=wt2html,wt2wt,html2html
16889 !! wikitext
16890 =foo==
16891 ==foo=
16892 =''italic'' heading==
16893 ==''italic'' heading=
16894 !! html/php
16895 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16896 <ul>
16897 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
16898 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
16899 <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>
16900 <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>
16901 </ul>
16902 </div>
16903
16904 <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>
16905 <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>
16906 <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>
16907 <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>
16908
16909 !! html/parsoid
16910 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
16911 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
16912 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
16913 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
16914 !! end
16915
16916 !! test
16917 HTML headers vs TOC (T25393)
16918 (__NOEDITSECTION__ for clearer output, doesn't matter here)
16919 !! wikitext
16920 <h1>Header 1</h1>
16921 == Header 1.1 ==
16922 == Header 1.2 ==
16923
16924 <h1>Header 2
16925 </h1>
16926 == Header 2.1 ==
16927 == Header 2.2 ==
16928 __NOEDITSECTION__
16929 !! html/php
16930 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16931 <ul>
16932 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
16933 <ul>
16934 <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>
16935 <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>
16936 </ul>
16937 </li>
16938 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
16939 <ul>
16940 <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>
16941 <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>
16942 </ul>
16943 </li>
16944 </ul>
16945 </div>
16946
16947 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
16948 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
16949 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
16950 <h1><span class="mw-headline" id="Header_2">Header 2</span></h1>
16951 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
16952 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
16953
16954 !! html/parsoid
16955 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
16956 <h2 id="Header_1.1" data-parsoid='{}'> Header 1.1 </h2>
16957 <h2 id="Header_1.2" data-parsoid='{}'> Header 1.2 </h2>
16958
16959 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
16960 </h1>
16961 <h2 id="Header_2.1" data-parsoid='{}'> Header 2.1 </h2>
16962 <h2 id="Header_2.2" data-parsoid='{}'> Header 2.2 </h2>
16963 <meta property="mw:PageProp/noeditsection"/>
16964 !! end
16965
16966 !! test
16967 Single-line or multiline-comments can follow headings
16968 !! options
16969 parsoid=wt2html,wt2wt
16970 !! wikitext
16971 ==foo==<!---->
16972 ==bar==<!--c1-->
16973 ==baz==<!--
16974 c2
16975 c3-->
16976 !! html/php
16977 <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>
16978 <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>
16979 <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>
16980
16981 !! html/parsoid
16982 <h2 id="foo">foo</h2><!---->
16983 <h2 id="bar">bar</h2><!--c1-->
16984 <h2 id="baz">baz</h2><!--
16985 c2
16986 c3-->
16987 !! end
16988
16989 !! test
16990 T3219 URL next to image (broken)
16991 !! wikitext
16992 http://example.com[[File:Foobar.jpg]]
16993 !! html/php
16994 <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>
16995 </p>
16996 !! html/parsoid
16997 <p><a rel="mw:ExtLink" 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>
16998 !!end
16999
17000 !! test
17001 T3186 news: in the middle of text
17002 !! wikitext
17003 http://en.wikinews.org/wiki/Wikinews:Workplace
17004 !! html
17005 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
17006 </p>
17007 !!end
17008
17009
17010 !! test
17011 Namespaced link must have a title
17012 !! wikitext
17013 [[Project:]]
17014 !! html
17015 <p>[[Project:]]
17016 </p>
17017 !!end
17018
17019 !! test
17020 Namespaced link must have a title (bad fragment version)
17021 !! wikitext
17022 [[Project:#fragment]]
17023 !! html
17024 <p>[[Project:#fragment]]
17025 </p>
17026 !!end
17027
17028
17029 ###
17030 ### HTML tags and HTML attributes
17031 ###
17032
17033 !! test
17034 div with no attributes
17035 !! wikitext
17036 <div>HTML rocks</div>
17037 !! html
17038 <div>HTML rocks</div>
17039
17040 !! end
17041
17042 !! test
17043 div with double-quoted attribute
17044 !! wikitext
17045 <div id="rock">HTML rocks</div>
17046 !! html
17047 <div id="rock">HTML rocks</div>
17048
17049 !! end
17050
17051 !! test
17052 div with single-quoted attribute
17053 !! wikitext
17054 <div id='rock'>HTML rocks</div>
17055 !! html
17056 <div id="rock">HTML rocks</div>
17057
17058 !! end
17059
17060 !! test
17061 div with unquoted attribute
17062 !! wikitext
17063 <div id=rock>HTML rocks</div>
17064 !! html
17065 <div id="rock">HTML rocks</div>
17066
17067 !! end
17068
17069 !! test
17070 div with illegal double attributes
17071 !! wikitext
17072 <div id="a" id="b">HTML rocks</div>
17073 !! html
17074 <div id="b">HTML rocks</div>
17075
17076 !!end
17077
17078 !! test
17079 div with empty attribute value, space before equals
17080 !! options
17081 parsoid=wt2html,html2html
17082 !! wikitext
17083 <div class =>HTML rocks</div>
17084 !! html/php
17085 <div class="">HTML rocks</div>
17086
17087 !! html/parsoid
17088 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17089 !! end
17090
17091 !! test
17092 div with multiple empty attribute values
17093 !! config
17094 wgFragmentMode=[ 'html5', 'legacy' ]
17095 !! options
17096 parsoid=wt2html,html2html
17097 !! wikitext
17098 <div id= title=>HTML rocks</div>
17099 !! html/php
17100 <div id="title=">HTML rocks</div>
17101
17102 !! html/parsoid
17103 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17104 !! end
17105
17106 !! test
17107 table with multiple empty attribute values
17108 !! options
17109 parsoid=wt2html,html2html
17110 !! wikitext
17111 {| title= id=
17112 | hi
17113 |}
17114 !! html/php
17115 <table title="id=">
17116 <tr>
17117 <td> hi
17118 </td></tr></table>
17119
17120 !! html/parsoid
17121 <table title="id=">
17122 <tbody><tr><td> hi</td></tr>
17123 </tbody></table>
17124 !! end
17125
17126 !! test
17127 div with braces in attribute value
17128 !! wikitext
17129 <div title="{}">Foo</div>
17130 !! html/php
17131 <div title="&#123;&#125;">Foo</div>
17132
17133 !! html/parsoid
17134 <div title="{}">Foo</div>
17135 !! end
17136
17137 !! test
17138 div with empty attribute value, no space before equals
17139 !! options
17140 parsoid=wt2html,html2html
17141 !! wikitext
17142 <div class=>HTML rocks</div>
17143 !! html/php
17144 <div class="">HTML rocks</div>
17145
17146 !! html/parsoid
17147 <div class="">HTML rocks</div>
17148 !! end
17149
17150 !! test
17151 HTML multiple attributes correction
17152 !! wikitext
17153 <p class="error" class="awesome">Awesome!</p>
17154 !! html
17155 <p class="awesome">Awesome!</p>
17156
17157 !!end
17158
17159 !! test
17160 Table multiple attributes correction
17161 !! wikitext
17162 {|
17163 !+ class="error" class="awesome"| status
17164 |}
17165 !! html
17166 <table>
17167 <tr>
17168 <th class="awesome"> status
17169 </th></tr></table>
17170
17171 !!end
17172
17173 !! test
17174 DIV IN UPPERCASE
17175 !! wikitext
17176 <DIV ID="x">HTML ROCKS</DIV>
17177 !! html
17178 <div id="x">HTML ROCKS</div>
17179
17180 !!end
17181
17182 !! test
17183 Non-ASCII pseudo-tags are rendered as text
17184 !! wikitext
17185 <khyô>
17186 !! html
17187 <p>&lt;khyô&gt;
17188 </p>
17189 !! end
17190
17191 !! test
17192 Pseudo-tag with URL 'name' renders as url link
17193 !! wikitext
17194 <http://example.com/>
17195 !! html
17196 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
17197 </p>
17198 !! end
17199
17200 !! test
17201 text with amp in the middle of nowhere
17202 !! wikitext
17203 Remember AT&T?
17204 !! html
17205 <p>Remember AT&amp;T?
17206 </p>
17207 !! end
17208
17209 !! test
17210 text with character entity: eacute
17211 !! wikitext
17212 I always thought &eacute; was a cute letter.
17213 !! html+tidy
17214 <p>I always thought &#233; was a cute letter.
17215 </p>
17216 !! end
17217
17218 !! test
17219 text with entity-escaped character entity-like string: eacute
17220 !! wikitext
17221 I always thought &amp;eacute; was a cute letter.
17222 !! html
17223 <p>I always thought &amp;eacute; was a cute letter.
17224 </p>
17225 !! end
17226
17227 !! test
17228 text with undefined character entity: xacute
17229 !! wikitext
17230 I always thought &xacute; was a cute letter.
17231 !! html
17232 <p>I always thought &amp;xacute; was a cute letter.
17233 </p>
17234 !! end
17235
17236 !! test
17237 HTML5 tags
17238 !! wikitext
17239 <data value="5">five</data>
17240 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17241 <mark>This highlighted text</mark>
17242 !! html
17243 <p><data value="5">five</data>
17244 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17245 <mark>This highlighted text</mark>
17246 </p>
17247 !! end
17248
17249 !! test
17250 HTML tag with leading space is parsed as text
17251 !! wikitext
17252 < div>foo< /div>
17253 !! html
17254 <p>&lt; div&gt;foo&lt; /div&gt;
17255 </p>
17256 !! end
17257
17258 ## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
17259 ## the HTML5 parsing spec.
17260 !! test
17261 Element with broken attribute syntax
17262 !! options
17263 parsoid=wt2html
17264 !! wikitext
17265 <div style=" style="123">hi</div>
17266 <div =>ho</div>
17267 !! html/php
17268 <div style="123">hi</div>
17269 <div>ho</div>
17270
17271 !! html/parsoid
17272 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
17273 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
17274 !! end
17275
17276 ###
17277 ### Nesting tests (see T43545, T52604, T53081)
17278 ###
17279
17280 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
17281 # Note that html2wt is considerably more difficult if we use <b> in
17282 # the test case, instead of <small>
17283 !! test
17284 Ensure that HTML adoption agency algorithm is properly implemented.
17285 !! wikitext
17286 <small>X<small>Y</small>Z</small>
17287 !! html
17288 <p><small>X<small>Y</small>Z</small>
17289 </p>
17290 !! end
17291
17292 # This was T43545 in the PHP parser.
17293 !! test
17294 Nesting of <kbd>
17295 !! wikitext
17296 <kbd>X<kbd>Y</kbd>Z</kbd>
17297 !! html+tidy
17298 <p><kbd>X<kbd>Y</kbd>Z</kbd>
17299 </p>
17300 !! end
17301
17302 # The following cases were T53081 in the PHP parser.
17303 # Note that there are some other nestable tags (b, i, etc) which are
17304 # not covered; see T53081 for discussion.
17305
17306 !! test
17307 Nesting of <em>
17308 !! wikitext
17309 <em>X<em>Y</em>Z</em>
17310 !! html+tidy
17311 <p><em>X<em>Y</em>Z</em>
17312 </p>
17313 !! end
17314
17315 !! test
17316 Nesting of <strong>
17317 !! wikitext
17318 <strong>X<strong>Y</strong>Z</strong>
17319 !! html+tidy
17320 <p><strong>X<strong>Y</strong>Z</strong>
17321 </p>
17322 !! end
17323
17324 !! test
17325 Nesting of <q>
17326 !! wikitext
17327 <q>X<q>Y</q>Z</q>
17328 !! html+tidy
17329 <p><q>X<q>Y</q>Z</q>
17330 </p>
17331 !! end
17332
17333 !! test
17334 Nesting of <ruby>
17335 !! wikitext
17336 <ruby>X<ruby>Y</ruby>Z</ruby>
17337 !! html
17338 <p><ruby>X<ruby>Y</ruby>Z</ruby>
17339 </p>
17340 !! end
17341
17342 !! test
17343 Nesting of <bdo>
17344 !! wikitext
17345 <bdo>X<bdo>Y</bdo>Z</bdo>
17346 !! html
17347 <p><bdo>X<bdo>Y</bdo>Z</bdo>
17348 </p>
17349 !! end
17350
17351
17352 ###
17353 ### Media links
17354 ###
17355
17356 !! test
17357 Media link
17358 !! wikitext
17359 [[Media:Foobar.jpg]]
17360 [[Media:Video.ogv]]
17361 [[:Media:Video.ogv]]
17362 !! html/php
17363 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
17364 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17365 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17366 </p>
17367 !! html/parsoid
17368 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
17369 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv">Media:Video.ogv</a>
17370 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv" data-parsoid='{"a":{"namespace":"Media"},"sa":{"namespace":":Media"}}'>Media:Video.ogv</a></p>
17371 !! end
17372
17373 !! test
17374 Media link with text
17375 !! wikitext
17376 [[Media:Foobar.jpg|A neat file to look at]]
17377 !! html/php
17378 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
17379 </p>
17380 !! html/parsoid
17381 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
17382 !! end
17383
17384 # FIXME: this is still bad HTML tag nesting
17385 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
17386 # Parsoid & Remex fix the p-wrapping since they operate on the DOM.
17387 !! test
17388 Media link with nasty text
17389 !! wikitext
17390 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
17391 !! html/php
17392 <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>
17393
17394 !! html+php/tidy
17395 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link</a></p>
17396 <div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div>
17397 !! html/parsoid
17398 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg" data-parsoid='{"autoInsertedEnd":true}'>Safe Link</a></p><div style="display:none" data-parsoid='{"stx":"html"}'><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg" data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'>" onmouseover="alert(document.cookie)" onfoo="</a></div>
17399
17400 !! end
17401
17402 !! test
17403 Media link to nonexistent file (T3702)
17404 !! wikitext
17405 [[Media:No such.jpg]]
17406 [[Media:No_such file.jpg]]
17407 !! html/php
17408 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
17409 <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>
17410 </p>
17411 !! html/parsoid
17412 <p><a rel="mw:MediaLink" href="./Special:FilePath/No_such.jpg" title="No such.jpg" typeof="mw:Error" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' data-parsoid='{"a":{"fileName":"No_such.jpg"},"sa":{"fileName":"No such.jpg"}}'>Media:No such.jpg</a>
17413 <a rel="mw:MediaLink" href="./Special:FilePath/No_such_file.jpg" title="No such file.jpg" typeof="mw:Error" data-mw='{"errors":[{"key":"apierror-filedoesnotexist","message":"This image does not exist."}]}' data-parsoid='{"a":{"fileName":"No_such_file.jpg"},"sa":{"fileName":"No_such file.jpg"}}'>Media:No_such file.jpg</a></p>
17414 !! end
17415
17416 !! test
17417 Image link to nonexistent file (T3850 - good)
17418 !! wikitext
17419 [[File:No_such.jpg]]
17420 !! html/php
17421 <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>
17422 </p>
17423 !! html/parsoid
17424 <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>
17425 !! end
17426
17427 !! test
17428 :Image link to nonexistent file (T3850 - bad)
17429 !! wikitext
17430 [[:Image:No such.jpg]]
17431 !! html/php
17432 <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>
17433 </p>
17434 !! html/parsoid
17435 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
17436 !! end
17437
17438 !! test
17439 Character reference normalization in link text (T3938)
17440 !! wikitext
17441 [[Main Page|this&that]]
17442 !! html
17443 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
17444 </p>
17445 !!end
17446
17447 !! article
17448 אַ
17449 !! text
17450 Test for unicode normalization
17451
17452 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
17453 !! endarticle
17454
17455 !! test
17456 (T21451) Links should refer to the normalized form.
17457 !! wikitext
17458 [[&#xFB2E;]]
17459 [[&#x5d0;&#x5b7;]]
17460 [[&#x5d0;ַ]]
17461 [[א&#x5b7;]]
17462 [[אַ]]
17463 !! html
17464 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
17465 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
17466 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
17467 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
17468 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
17469 </p>
17470 !! end
17471
17472 !! test
17473 Empty attribute crash test (T4067)
17474 !! wikitext
17475 <font color="">foo</font>
17476 !! html
17477 <p><font color="">foo</font>
17478 </p>
17479 !! end
17480
17481 !! test
17482 Empty attribute crash test single-quotes (T4067)
17483 !! wikitext
17484 <font color=''>foo</font>
17485 !! html
17486 <p><font color="">foo</font>
17487 </p>
17488 !! end
17489
17490 !! test
17491 Attribute test: equals, then nothing
17492 !! options
17493 parsoid=wt2html,html2html
17494 !! wikitext
17495 <font color=>foo</font>
17496 !! html/php
17497 <p><font color="">foo</font>
17498 </p>
17499 !! html/parsoid
17500 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
17501 !! end
17502
17503 !! test
17504 Attribute test: unquoted value
17505 !! options
17506 parsoid=wt2html,html2html
17507 !! wikitext
17508 <font color=x>foo</font>
17509 !! html/php
17510 <p><font color="x">foo</font>
17511 </p>
17512 !! html/parsoid
17513 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
17514 !! end
17515
17516 !! test
17517 Attribute test: unquoted but illegal value (hash)
17518 !! wikitext
17519 <font color=#x>foo</font>
17520 !! html
17521 <p><font color="#x">foo</font>
17522 </p>
17523 !! end
17524
17525 # Parsoid does not serialize to empty attribute syntax,
17526 # so wt2wt and html2wt cases are skipped
17527 !! test
17528 Attribute test: no value (T54330)
17529 !! options
17530 parsoid=wt2html,html2html
17531 !! wikitext
17532 <font color>foo</font>
17533 !! html/php
17534 <p><font color="">foo</font>
17535 </p>
17536 !! html/parsoid
17537 <p><font color="">foo</font></p>
17538 !! end
17539
17540 !! test
17541 T4095: link with three closing brackets
17542 !! wikitext
17543 [[Main Page]]]
17544 !! html/php
17545 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
17546 </p>
17547 !! html/parsoid
17548 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
17549 !! end
17550
17551 !! test
17552 T4095: link with pipe and three closing brackets
17553 !! wikitext
17554 [[Main Page|link]]]
17555 !! html/php
17556 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
17557 </p>
17558 !! html/parsoid
17559 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
17560 !! end
17561
17562 !! test
17563 T4095: link with pipe and three closing brackets, version 2
17564 !! wikitext
17565 [[Main Page|[http://example.com/]]]
17566 !! html/php
17567 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
17568 </p>
17569 !! html/parsoid
17570 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
17571 !! end
17572
17573
17574 ###
17575 ### Safety
17576 ###
17577
17578 !! article
17579 Template:Dangerous attribute
17580 !! text
17581 " onmouseover="alert(document.cookie)
17582 !! endarticle
17583
17584 !! article
17585 Template:Dangerous style attribute
17586 !! text
17587 border-size: expression(alert(document.cookie))
17588 !! endarticle
17589
17590 !! article
17591 Template:Div style
17592 !! text
17593 <div style="float: right; {{{1}}}">Magic div</div>
17594 !! endarticle
17595
17596 !! test
17597 T4304: HTML attribute safety (safe template; regression T4309)
17598 !! wikitext
17599 <div title="{{test}}"></div>
17600 !! html/php
17601 <div title="This is a test template"></div>
17602
17603 !! html/parsoid
17604 <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>
17605 !! end
17606
17607 # Parsoid has enough context to handle this case
17608 !! test
17609 T4304: HTML attribute safety (dangerous template; 2309)
17610 !! wikitext
17611 <div title="{{dangerous attribute}}"></div>
17612 !! html/php
17613 <div title=""></div>
17614
17615 !! html/parsoid
17616 <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>
17617 !! end
17618
17619 !! test
17620 T4304: HTML attribute safety (dangerous style template; 2309)
17621 !! wikitext
17622 <div style="{{dangerous style attribute}}"></div>
17623 !! html/php
17624 <div style="/* insecure input */"></div>
17625
17626 !! html/parsoid
17627 <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>
17628 !! end
17629
17630 !! test
17631 T4304: HTML attribute safety (safe parameter; 2309)
17632 !! wikitext
17633 {{div style|width: 200px}}
17634 !! html/php
17635 <div style="float: right; width: 200px">Magic div</div>
17636
17637 !! html/parsoid
17638 <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>
17639 !! end
17640
17641 !! test
17642 T4304: HTML attribute safety (unsafe parameter; 2309)
17643 !! wikitext
17644 {{div style|width: expression(alert(document.cookie))}}
17645 !! html/php
17646 <div style="/* insecure input */">Magic div</div>
17647
17648 !! html/parsoid
17649 <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>
17650 !! end
17651
17652 ## Parsoid output here differs; needs investigation.
17653 !! test
17654 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
17655 !! wikitext
17656 {{div style|"><script>alert(document.cookie)</script>}}
17657 !! html
17658 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17659
17660 !! end
17661
17662 ## Parsoid output here differs; needs investigation.
17663 !! test
17664 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
17665 !! wikitext
17666 {{div style|" ><script>alert(document.cookie)</script>}}
17667 !! html
17668 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17669
17670 !! end
17671
17672 !! test
17673 T4304: HTML attribute safety (link)
17674 !! wikitext
17675 <div title="[[Main Page]]"></div>
17676 !! html/php
17677 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
17678
17679 !! html/parsoid
17680 <div title="[[Main Page]]"></div>
17681 !! end
17682
17683 !! test
17684 T4304: HTML attribute safety (italics)
17685 !! wikitext
17686 <div title="''foobar''"></div>
17687 !! html
17688 <div title="&#39;&#39;foobar&#39;&#39;"></div>
17689
17690 !! end
17691
17692 !! test
17693 T4304: HTML attribute safety (bold)
17694 !! wikitext
17695 <div title="'''foobar'''"></div>
17696 !! html
17697 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
17698
17699 !! end
17700
17701 !! test
17702 T4304: HTML attribute safety (ISBN)
17703 !! wikitext
17704 <div title="ISBN 1234567890"></div>
17705 !! html
17706 <div title="&#73;SBN 1234567890"></div>
17707
17708 !! end
17709
17710 !! test
17711 T4304: HTML attribute safety (RFC)
17712 !! wikitext
17713 <div title="RFC 1234"></div>
17714 !! html
17715 <div title="&#82;FC 1234"></div>
17716
17717 !! end
17718
17719 !! test
17720 T4304: HTML attribute safety (PMID)
17721 !! wikitext
17722 <div title="PMID 1234567890"></div>
17723 !! html
17724 <div title="&#80;MID 1234567890"></div>
17725
17726 !! end
17727
17728 !! test
17729 T4304: HTML attribute safety (web link)
17730 !! wikitext
17731 <div title="http://example.com/"></div>
17732 !! html
17733 <div title="http&#58;//example.com/"></div>
17734
17735 !! end
17736
17737 !! test
17738 T4304: HTML attribute safety (named web link)
17739 !! wikitext
17740 <div title="[http://example.com/ link]"></div>
17741 !! html/php
17742 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
17743
17744 !! html/parsoid
17745 <div title="[http://example.com/ link]"></div>
17746 !! end
17747
17748 !! test
17749 T5244: HTML attribute safety (extension; safe)
17750 !! wikitext
17751 <div style="<nowiki>background:blue</nowiki>"></div>
17752 !! html/php
17753 <div style="background:blue"></div>
17754
17755 !! html/parsoid
17756 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
17757 !! end
17758
17759 !! test
17760 T5244: HTML attribute safety (extension; unsafe)
17761 !! wikitext
17762 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
17763 !! html/php
17764 <div style="/* insecure input */"></div>
17765
17766 !! html/parsoid
17767 <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>
17768 !! end
17769
17770 # More MSIE fun discovered by Tom Gilder
17771
17772 !! test
17773 MSIE CSS safety test: spurious slash
17774 !! wikitext
17775 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
17776 !! html/php
17777 <div style="/* insecure input */">evil</div>
17778
17779 !! html/parsoid
17780 <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>
17781 !! end
17782
17783 !! test
17784 MSIE CSS safety test: hex code
17785 !! wikitext
17786 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
17787 !! html/php
17788 <div style="/* insecure input */">evil</div>
17789
17790 !! html/parsoid
17791 <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>
17792 !! end
17793
17794 !! test
17795 MSIE CSS safety test: comment in url
17796 !! wikitext
17797 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
17798 !! html/php
17799 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
17800
17801 !! html/parsoid
17802 <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>
17803 !! end
17804
17805 !! test
17806 MSIE CSS safety test: comment in expression
17807 !! wikitext
17808 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
17809 !! html/php
17810 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
17811
17812 !! html/parsoid
17813 <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>
17814 !! end
17815
17816 !! test
17817 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
17818 !! wikitext
17819 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
17820 !! html/php
17821 <p style="/* invalid control char */">A</p>
17822
17823 !! html/parsoid
17824 <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>
17825 !! end
17826
17827 !! test
17828 MSIE 6 CSS safety test: Fullwidth (T57332)
17829 !! wikitext
17830 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
17831 <div style="top:EXPRESSION(alert())">B</div>
17832 !! html/php
17833 <p style="/* insecure input */">A</p>
17834 <div style="/* insecure input */">B</div>
17835
17836 !! html/parsoid
17837 <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>
17838 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
17839 !! end
17840
17841 !! test
17842 MSIE 6 CSS safety test: IPA extensions (T57332)
17843 !! wikitext
17844 <div style="background-image:uʀʟ(javascript:alert())">A</div>
17845 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
17846 !! html/php
17847 <div style="/* insecure input */">A</div>
17848 <p style="/* insecure input */">B</p>
17849
17850 !! html/parsoid
17851 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
17852 <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>
17853 !! end
17854
17855 !! test
17856 MSIE 6 CSS safety test: sup/sub script (T57332)
17857 !! wikitext
17858 <div style="background-image:url⁽javascript:alert())">A</div>
17859 <div style="background-image:url₍javascript:alert())">B</div>
17860 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
17861 !! html/php
17862 <div style="/* insecure input */">A</div>
17863 <div style="/* insecure input */">B</div>
17864 <p style="/* insecure input */">C</p>
17865
17866 !! html/parsoid
17867 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
17868 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
17869 <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>
17870 !! end
17871
17872 !! test
17873 Opera -o-link CSS
17874 !! options
17875 parsoid=wt2html,html2html
17876 !! wikitext
17877 <div
17878 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;"
17879 style="-o-link:attr(title);-o-link-source:current">X</div>
17880 !! html/php
17881 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
17882
17883 !! html/parsoid
17884 <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>
17885 !! end
17886
17887 !! test
17888 MSIE 6 CSS safety test: Repetition markers (T57332)
17889 !! wikitext
17890 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
17891 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
17892 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
17893 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
17894 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
17895 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
17896 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
17897 !! html/php
17898 <p style="/* insecure input */">A</p>
17899 <p style="/* insecure input */">B</p>
17900 <p style="/* insecure input */">C</p>
17901 <p style="/* insecure input */">D</p>
17902 <p style="/* insecure input */">E</p>
17903 <p style="/* insecure input */">F</p>
17904 <p style="/* insecure input */">G</p>
17905
17906 !! html/parsoid
17907 <p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expres〱ion((title=&#39;XSSed&#39;),&#39;red&#39;)"}}'>A</p>
17908 <p style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"font-size: 100px; color: expresゝion((title=&#39;XSSed&#39;),&#39;red&#39;)"}}'>B</p>
17909 <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>
17910 <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>
17911 <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>
17912 <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>
17913 <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>
17914 !! end
17915
17916 !! test
17917 Table attribute legitimate extension
17918 !! wikitext
17919 {|
17920 !+ style="<nowiki>color:blue</nowiki>"| status
17921 |}
17922 !! html
17923 <table>
17924 <tr>
17925 <th style="color:blue"> status
17926 </th></tr></table>
17927
17928 !!end
17929
17930 !! test
17931 Table attribute safety
17932 !! wikitext
17933 {|
17934 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
17935 |}
17936 !! html
17937 <table>
17938 <tr>
17939 <th style="/* insecure input */"> status
17940 </th></tr></table>
17941
17942 !! end
17943
17944 !! test
17945 CSS line continuation 1
17946 !! wikitext
17947 <div style="background-image: u\&#10;rl(test.jpg);"></div>
17948 !! html
17949 <div style="/* insecure input */"></div>
17950
17951 !! end
17952
17953 !! test
17954 CSS line continuation 2
17955 !! wikitext
17956 <div style="background-image: u\&#13;rl(test.jpg); "></div>
17957 !! html
17958 <div style="/* invalid control char */"></div>
17959
17960 !! end
17961
17962 !! article
17963 Template:Identity
17964 !! text
17965 {{{1}}}
17966 !! endarticle
17967
17968 !! test
17969 Expansion of multi-line templates in attribute values (T8255)
17970 !! wikitext
17971 <div style="background: {{identity|#00FF00}}">-</div>
17972 !! html
17973 <div style="background: #00FF00">-</div>
17974
17975 !! end
17976
17977 !! test
17978 Expansion of multi-line templates in attribute values (T8255 sanity check)
17979 !! wikitext
17980 <div style="background:
17981 #00FF00">-</div>
17982 !! html/php
17983 <div style="background: #00FF00">-</div>
17984
17985 !! html/parsoid
17986 <div style="background:
17987 #00FF00">-</div>
17988 !! end
17989
17990 !! test
17991 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
17992 !! wikitext
17993 <div style="background: &#10;#00FF00">-</div>
17994 !! html
17995 <div style="background: &#10;#00FF00">-</div>
17996
17997 !! end
17998
17999 !! test
18000 Tags which are hidden from tidiers cannot pass through the Sanitizer
18001 !! wikitext
18002 <mw:toc><script>alert();</script></mw:toc>
18003 !! html+tidy
18004 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;
18005 </p>
18006 !! end
18007
18008 ###
18009 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
18010 ###
18011
18012 !! test
18013 Parser hook: empty input
18014 !! wikitext
18015 <tag></tag>
18016 !! html/php
18017 <pre>
18018 ''
18019 array (
18020 )
18021 </pre>
18022
18023 !! html/parsoid
18024 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18025 !! end
18026
18027 ## Don't expect parsoid to rt this form.
18028 !! test
18029 Parser hook: empty input using terminated empty elements
18030 !! options
18031 parsoid=wt2html,html2html
18032 !! wikitext
18033 <tag/>
18034 !! html/php
18035 <pre>
18036 NULL
18037 array (
18038 )
18039 </pre>
18040
18041 !! html/parsoid
18042 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18043 !! end
18044
18045 !! test
18046 Parser hook: empty input using terminated empty elements (space before)
18047 !! wikitext
18048 <tag />
18049 !! html/php
18050 <pre>
18051 NULL
18052 array (
18053 )
18054 </pre>
18055
18056 !! html/parsoid
18057 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18058 !! end
18059
18060 !! test
18061 Parser hook: basic input
18062 !! wikitext
18063 <tag>input</tag>
18064 !! html/php
18065 <pre>
18066 'input'
18067 array (
18068 )
18069 </pre>
18070
18071 !! html/parsoid
18072 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18073 !! end
18074
18075 ## Don't expect parsoid to rt this form.
18076 !! test
18077 Parser hook: case insensitive
18078 !! options
18079 parsoid=wt2html,html2html
18080 !! wikitext
18081 <TAG>input</TAG>
18082 !! html/php
18083 <pre>
18084 'input'
18085 array (
18086 )
18087 </pre>
18088
18089 !! html/parsoid
18090 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18091 !! end
18092
18093 ## Don't expect parsoid to rt this form.
18094 !! test
18095 Parser hook: case insensitive, redux
18096 !! options
18097 parsoid=wt2html,html2html
18098 !! wikitext
18099 <TaG>input</TAg>
18100 !! html/php
18101 <pre>
18102 'input'
18103 array (
18104 )
18105 </pre>
18106
18107 !! html/parsoid
18108 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18109 !! end
18110
18111 !! test
18112 Parser hook: nested tags
18113 !! wikitext
18114 <tag><tag></tag></tag>
18115 !! html/php
18116 <pre>
18117 '<tag>'
18118 array (
18119 )
18120 </pre>&lt;/tag&gt;
18121
18122 !! html/parsoid
18123 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}' data-parsoid='{}' about="#mwt2"></pre>&lt;/tag>
18124 !! end
18125
18126 !! test
18127 Parser hook: basic arguments
18128 !! wikitext
18129 <tag width="200" height="100" depth="50" square=""></tag>
18130 !! html/php
18131 <pre>
18132 ''
18133 array (
18134 'width' => '200',
18135 'height' => '100',
18136 'depth' => '50',
18137 'square' => '',
18138 )
18139 </pre>
18140
18141 !! html/parsoid
18142 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18143 !! end
18144
18145 ## Don't expect parsoid to rt this form.
18146 !! test
18147 Parser hook: basic arguments, variations
18148 !! options
18149 parsoid=wt2html,html2html
18150 !! wikitext
18151 <tag width=200 height = "100" depth = '50' square></tag>
18152 !! html/php
18153 <pre>
18154 ''
18155 array (
18156 'width' => '200',
18157 'height' => '100',
18158 'depth' => '50',
18159 'square' => '',
18160 )
18161 </pre>
18162
18163 !! html/parsoid
18164 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18165 !! end
18166
18167 !! test
18168 Parser hook: argument containing a forward slash (T7344)
18169 !! wikitext
18170 <tag filename="/tmp/bla"></tag>
18171 !! html/php
18172 <pre>
18173 ''
18174 array (
18175 'filename' => '/tmp/bla',
18176 )
18177 </pre>
18178
18179 !! html/parsoid
18180 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18181 !! end
18182
18183 ## Don't expect parsoid to rt this form.
18184 !! test
18185 Parser hook: empty input using terminated empty elements (T4374)
18186 !! options
18187 parsoid=wt2html,html2html
18188 !! wikitext
18189 <tag foo=bar/>text
18190 !! html/php
18191 <pre>
18192 NULL
18193 array (
18194 'foo' => 'bar',
18195 )
18196 </pre>text
18197
18198 !! html/parsoid
18199 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text
18200 !! end
18201
18202 ## </tag> should be output literally since there is no matching tag that begins it
18203 ## Don't expect parsoid to rt this form.
18204 !! test
18205 Parser hook: basic arguments using terminated empty elements (T4374)
18206 !! options
18207 parsoid=wt2html
18208 !! wikitext
18209 <tag width=200 height = "100" depth = '50' square/>
18210 other stuff
18211 </tag>
18212 !! html/php
18213 <pre>
18214 NULL
18215 array (
18216 'width' => '200',
18217 'height' => '100',
18218 'depth' => '50',
18219 'square' => '',
18220 )
18221 </pre>
18222 <p>other stuff
18223 &lt;/tag&gt;
18224 </p>
18225 !! html/parsoid
18226 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":null}' about="#mwt2"></pre><p>other stuff
18227 &lt;/tag></p>
18228 !! end
18229
18230 ## Don't expect parsoid to rt this form.
18231 !! test
18232 Parser hook: Don't allow unclosed extension tags
18233 !! options
18234 parsoid=wt2html
18235 !! wikitext
18236 test <tag>123
18237
18238 this is a '''test'''
18239 !! html/php
18240 <p>test &lt;tag&gt;123
18241 </p><p>this is a <b>test</b>
18242 </p>
18243 !! html/parsoid
18244 <p>test &lt;tag>123</p>
18245
18246 <p>this is a <b>test</b></p>
18247 !! end
18248
18249 ###
18250 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
18251 ###
18252
18253 !! test
18254 Parser hook: static parser hook not inside a comment
18255 !! wikitext
18256 <statictag>hello, world</statictag>
18257
18258 <statictag action="flush" />
18259 !! html/php
18260 <p><br />
18261 hello, world
18262 </p>
18263 !! html/parsoid
18264 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
18265 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p>
18266 !! end
18267
18268 !! test
18269 Parser hook: static parser hook inside a comment
18270 !! wikitext
18271 <!-- <statictag>hello, world</statictag> -->
18272 <statictag action="flush" />
18273 !! html/php
18274 <p><br />
18275 </p>
18276 !! html/parsoid
18277 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
18278 <p typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about='#mwt2'></p>
18279 !! end
18280
18281 # Nested template calls; this case was broken by Parser.php rev 1.506,
18282 # since reverted.
18283
18284 !! article
18285 Template:One-parameter
18286 !! text
18287 (My parameter is: {{{1}}})
18288 !! endarticle
18289
18290 !! article
18291 Template:Map-one-parameter
18292 !! text
18293 {{{{{1}}}|{{{2}}}}}
18294 !! endarticle
18295
18296 !! test
18297 Nested template calls
18298 !! wikitext
18299 {{Map-one-parameter|One-parameter|param}}
18300 !! html
18301 <p>(My parameter is: param)
18302 </p>
18303 !! end
18304
18305
18306 ###
18307 ### Sanitizer
18308 ###
18309
18310 # Remex wraps empty tag runs with p-tags.
18311 # Parsoid strips them out during p-wrapping.
18312 !! test
18313 Sanitizer: Closing of open tags
18314 !! wikitext
18315 <s></s><table></table>
18316 !! html/php+tidy
18317 <p><s></s></p><table></table>
18318 !! html/parsoid
18319 <s></s><table></table>
18320 !! end
18321
18322 !! test
18323 Sanitizer: Closing of open but not closed tags
18324 !! wikitext
18325 <s>foo
18326 !! html
18327 <p><s>foo</s>
18328 </p>
18329 !! end
18330
18331 !! test
18332 Sanitizer: Closing of closed but not open tags
18333 !! options
18334 parsoid=wt2html
18335 !! wikitext
18336 </s>
18337 !! html/php+tidy
18338 <p class="mw-empty-elt">
18339 </p>
18340 !! html/parsoid
18341 !! end
18342
18343 !! test
18344 Sanitizer: Closing of closed but not open table tags
18345 !! options
18346 parsoid=wt2html
18347 !! wikitext
18348 Table not started</td></tr></table>
18349 !! html+tidy
18350 <p>Table not started
18351 </p>
18352 !! end
18353
18354 !! test
18355 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
18356 !! config
18357 wgFragmentMode=[ 'html5', 'legacy' ]
18358 !! wikitext
18359 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18360 !! html/php
18361 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
18362 </p>
18363 !! html/parsoid
18364 <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>
18365 !! end
18366
18367 !! test
18368 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
18369 !! config
18370 wgFragmentMode=[ 'legacy' ]
18371 !! wikitext
18372 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18373 !! html/php
18374 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
18375 </p>
18376 !! end
18377
18378 # In HTML5, the restrictions are that id must contain at least one character,
18379 # and must not contain any space characters.
18380 !! test
18381 Sanitizer: Validating the contents of the id attribute (T6515)
18382 !! options
18383 disabled
18384 !! wikitext
18385 <br id="" /><br id="a space" />
18386 !! html
18387 Something ...
18388 !! end
18389
18390 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
18391 !! test
18392 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
18393 !! options
18394 disabled
18395 !! wikitext
18396 <br id="foo" /><br id="foo" />
18397 !! html
18398 Something need to be done. foo-2 ?
18399 !! end
18400
18401 !! test
18402 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
18403 !! wikitext
18404 <div itemscope>
18405 <meta itemprop="hello" content="world">
18406 <meta http-equiv="refresh" content="5">
18407 <meta itemprop="hello" http-equiv="refresh" content="5">
18408 <link itemprop="hello" href="{{SERVER}}">
18409 <link rel="stylesheet" href="{{SERVER}}">
18410 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
18411 </div>
18412 !! html
18413 <div itemscope="">
18414 <p> <meta itemprop="hello" content="world" />
18415 &lt;meta http-equiv="refresh" content="5"&gt;
18416 <meta itemprop="hello" content="5" />
18417 <link itemprop="hello" href="http&#58;//example.org" />
18418 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
18419 <link itemprop="hello" href="http&#58;//example.org" />
18420 </p>
18421 </div>
18422
18423 !! end
18424
18425 !! test
18426 Sanitizer: Strip comments from CSS attributes
18427 !! options
18428 parsoid=wt2html,wt2wt
18429 !! wikitext
18430 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
18431 !! html/php
18432 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
18433 </p>
18434 !! html/parsoid
18435 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
18436 !! end
18437
18438 !! test
18439 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
18440 !! wikitext
18441 [[meatball:Soft"Security]]
18442 !! html/php
18443 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
18444 </p>
18445 !! html/parsoid
18446 <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>
18447 !! end
18448
18449 !! test
18450 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
18451 !! wikitext
18452 [[meatball:Foo<Bar]]
18453 [[meatball:Foo>Bar]]
18454 [[meatball:Foo&lt;bar]]
18455 [[meatball:Foo&gt;bar]]
18456 !! html/php
18457 <p>[[meatball:Foo&lt;Bar]]
18458 [[meatball:Foo&gt;Bar]]
18459 [[meatball:Foo&lt;bar]]
18460 [[meatball:Foo&gt;bar]]
18461 </p>
18462 !! html/parsoid
18463 <p>[[meatball:Foo&lt;Bar]]
18464 [[meatball:Foo>Bar]]
18465 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
18466 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
18467 !! end
18468
18469 !! test
18470 Language converter: output gets cut off unexpectedly (T7757)
18471 !! options
18472 language=zh
18473 !! wikitext
18474 this bit is safe: }-
18475
18476 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
18477
18478 then we get cut off here: }-
18479
18480 all additional text is vanished
18481 !! html/php
18482 <p>this bit is safe: }-
18483 </p><p>but if we add a conversion instance: xxx
18484 </p><p>then we get cut off here: }-
18485 </p><p>all additional text is vanished
18486 </p>
18487 !! html/parsoid
18488 <p>this bit is safe: }-</p>
18489 <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>
18490 <p>then we get cut off here: }-</p>
18491 <p>all additional text is vanished</p>
18492 !! end
18493
18494 !! test
18495 Language converter glossary rules inside attributes (T119158)
18496 !! options
18497 language=sr variant=sr-el
18498 !! wikitext
18499 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
18500
18501 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
18502 !! html/php
18503 <p>
18504 </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>
18505 </p>
18506 !! html/parsoid
18507 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
18508
18509 <p><span 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></span></p>
18510 !! end
18511
18512 !! test
18513 Self closed html pairs (T7487)
18514 !! wikitext
18515 <center><font id="bug" />Centered text</center>
18516 <div><font id="bug2" />In div text</div>
18517 !! html+tidy
18518 <center><font id="bug"></font>Centered text</center>
18519 <div><font id="bug2"></font>In div text</div>
18520 !! end
18521
18522 !! test
18523 Punctuation: nbsp before exclamation
18524 !! wikitext
18525 C'est grave !
18526 !! html
18527 <p>C'est grave&#160;!
18528 </p>
18529 !! end
18530
18531 !! test
18532 Punctuation: CSS !important (T13874)
18533 !! wikitext
18534 <div style="width:50% !important">important</div>
18535 !! html
18536 <div style="width:50% !important">important</div>
18537
18538 !!end
18539
18540 !! test
18541 Punctuation: CSS ! important (T13874; with space after)
18542 !! wikitext
18543 <div style="width:50% ! important">important</div>
18544 !! html
18545 <div style="width:50% ! important">important</div>
18546
18547 !!end
18548
18549 !! test
18550 HTML bullet list, closed tags (T7497)
18551 !! wikitext
18552 <ul>
18553 <li>One</li>
18554 <li>Two</li>
18555 </ul>
18556 !! html/php
18557 <ul>
18558 <li>One</li>
18559 <li>Two</li>
18560 </ul>
18561
18562 !! html/parsoid
18563 <ul data-parsoid='{"stx":"html"}'>
18564 <li data-parsoid='{"stx":"html"}'>One</li>
18565 <li data-parsoid='{"stx":"html"}'>Two</li>
18566 </ul>
18567
18568 !! end
18569
18570 !! test
18571 HTML bullet list, unclosed tags (T7497)
18572 !! wikitext
18573 <ul>
18574 <li>One
18575 <li>Two
18576 </ul>
18577 !! html/php+tidy
18578 <ul>
18579 <li>One
18580 </li><li>Two
18581 </li></ul>
18582 !! html/parsoid
18583 <ul data-parsoid='{"stx":"html"}'>
18584 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18585 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18586 </ul>
18587
18588 !! end
18589
18590 !! test
18591 HTML ordered list, closed tags (T7497)
18592 !! wikitext
18593 <ol>
18594 <li>One</li>
18595 <li>Two</li>
18596 </ol>
18597 !! html/php
18598 <ol>
18599 <li>One</li>
18600 <li>Two</li>
18601 </ol>
18602
18603 !! html/parsoid
18604 <ol data-parsoid='{"stx":"html"}'>
18605 <li data-parsoid='{"stx":"html"}'>One</li>
18606 <li data-parsoid='{"stx":"html"}'>Two</li>
18607 </ol>
18608
18609 !! end
18610
18611 !! test
18612 HTML ordered list, unclosed tags (T7497)
18613 !! options
18614 !! wikitext
18615 <ol>
18616 <li>One
18617 <li>Two
18618 </ol>
18619 !! html/php+tidy
18620 <ol>
18621 <li>One
18622 </li><li>Two
18623 </li></ol>
18624 !! html/parsoid
18625 <ol data-parsoid='{"stx":"html"}'>
18626 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18627 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18628 </ol>
18629
18630 !! end
18631
18632 !! test
18633 HTML nested bullet list, closed tags (T7497)
18634 !! wikitext
18635 <ul>
18636 <li>One</li>
18637 <li>Two:
18638 <ul>
18639 <li>Sub-one</li>
18640 <li>Sub-two</li>
18641 </ul>
18642 </li>
18643 </ul>
18644 !! html/php
18645 <ul>
18646 <li>One</li>
18647 <li>Two:
18648 <ul>
18649 <li>Sub-one</li>
18650 <li>Sub-two</li>
18651 </ul>
18652 </li>
18653 </ul>
18654
18655 !! html/parsoid
18656 <ul data-parsoid='{"stx":"html"}'>
18657 <li data-parsoid='{"stx":"html"}'>One</li>
18658 <li data-parsoid='{"stx":"html"}'>Two:
18659 <ul data-parsoid='{"stx":"html"}'>
18660 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
18661 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
18662 </ul>
18663 </li>
18664 </ul>
18665 !! end
18666
18667 !! test
18668 HTML nested bullet list, open tags (T7497)
18669 !! wikitext
18670 <ul>
18671 <li>One
18672 <li>Two:
18673 <ul>
18674 <li>Sub-one
18675 <li>Sub-two
18676 </ul>
18677 </ul>
18678 !! html+tidy
18679 <ul>
18680 <li>One
18681 </li><li>Two:
18682 <ul>
18683 <li>Sub-one
18684 </li><li>Sub-two
18685 </li></ul>
18686 </li></ul>
18687 !! end
18688
18689 !! test
18690 HTML nested ordered list, closed tags (T7497)
18691 !! wikitext
18692 <ol>
18693 <li>One</li>
18694 <li>Two:
18695 <ol>
18696 <li>Sub-one</li>
18697 <li>Sub-two</li>
18698 </ol>
18699 </li>
18700 </ol>
18701 !! html
18702 <ol>
18703 <li>One</li>
18704 <li>Two:
18705 <ol>
18706 <li>Sub-one</li>
18707 <li>Sub-two</li>
18708 </ol>
18709 </li>
18710 </ol>
18711
18712 !! end
18713
18714 !! test
18715 HTML nested ordered list, open tags (T7497)
18716 !! wikitext
18717 <ol>
18718 <li>One
18719 <li>Two:
18720 <ol>
18721 <li>Sub-one
18722 <li>Sub-two
18723 </ol>
18724 </ol>
18725 !! html/php
18726 <ol>
18727 <li>One
18728 <li>Two:
18729 <ol>
18730 <li>Sub-one
18731 <li>Sub-two
18732 </ol>
18733 </ol>
18734
18735 !! html/parsoid
18736 <ol>
18737 <li>One
18738 </li>
18739 <li>Two:
18740 <ol>
18741 <li>Sub-one
18742 </li>
18743 <li>Sub-two
18744 </li>
18745 </ol>
18746 </li>
18747 </ol>
18748
18749 !! end
18750
18751 !! test
18752 HTML ordered list item with parameters oddity
18753 !! wikitext
18754 <ol><li id="fragment">One</li>
18755 </ol>
18756 !! html
18757 <ol><li id="fragment">One</li>
18758 </ol>
18759
18760 !! end
18761
18762 # parsoid doesn't explicitly mark autonumbered links, see T55505
18763 !!test
18764 T7918: autonumbering
18765 !! wikitext
18766 [http://first/] [http://second] [ftp://ftp]
18767
18768 ftp://inlineftp
18769
18770 [mailto:enclosed@mail.tld With target]
18771
18772 [mailto:enclosed@mail.tld]
18773
18774 mailto:inline@mail.tld
18775 !! html/php
18776 <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>
18777 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
18778 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
18779 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
18780 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
18781 </p>
18782 !! html/parsoid
18783 <p><a rel="mw:ExtLink" href="http://first/"></a> <a rel="mw:ExtLink" href="http://second"></a> <a rel="mw:ExtLink" href="ftp://ftp"></a></p>
18784 <p><a rel="mw:ExtLink" href="ftp://inlineftp">ftp://inlineftp</a></p>
18785 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld">With target</a></p>
18786 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld"></a></p>
18787 <p><a rel="mw:ExtLink" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
18788 !! end
18789
18790
18791 #
18792 # Security and HTML correctness
18793 # From Nick Jenkins' fuzz testing
18794 #
18795
18796 !! test
18797 Fuzz testing: Parser13
18798 !! wikitext
18799 {|
18800 | http://a|
18801 !! html
18802 <table>
18803 <tr>
18804 <td>
18805 </td>
18806 </tr>
18807 </table>
18808
18809 !! end
18810
18811 # Note that Parsoid output differs from the PHP parser here: the PHP
18812 # parser breaks the URL for the magic word, while in Parsoid the URL
18813 # production takes precedence.
18814 !! test
18815 Fuzz testing: Parser14
18816 !! wikitext
18817 == onmouseover= ==
18818 http://__TOC__
18819 !! html/php
18820 <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>
18821 http://<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
18822 <ul>
18823 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18824 </ul>
18825 </div>
18826
18827
18828 !! html/php+tidy
18829 <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>
18830 http://</p><div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
18831 <ul>
18832 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18833 </ul>
18834 </div>
18835 !! html/parsoid
18836 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span> onmouseover= </h2>
18837 <p><a rel="mw:ExtLink" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
18838 !! end
18839
18840 !! test
18841 Fuzz testing: Parser14-table
18842 !! options
18843 parsoid=wt2html,html2html
18844 !! wikitext
18845 ==a==
18846 {| STYLE=__TOC__
18847 !! html
18848 <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>
18849 <table style="&#95;_TOC&#95;_">
18850 <tr><td></td></tr>
18851 </table>
18852
18853 !! html+tidy
18854 <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>
18855 <table style="__TOC__">
18856 <tr>
18857 <td></td>
18858 </tr>
18859 </table>
18860 !! html/parsoid
18861 <h2 id="a">a</h2>
18862 <table style="__TOC__"></table>
18863 !! end
18864
18865 # Known to produce bogus xml (extra </td>)
18866 # Don't add the html/php section since it generates broken HTML
18867 !! test
18868 Fuzz testing: Parser16
18869 !! wikitext
18870 {|
18871 !https://||||||
18872 !! html+tidy
18873 <table>
18874 <tbody><tr>
18875 <th>https://</th>
18876 <th></th>
18877 <th></th>
18878 <th>
18879
18880 </th></tr>
18881 </tbody></table>
18882 !! end
18883
18884 !! test
18885 Fuzz testing: Parser21
18886 !! wikitext
18887 {|
18888 ! irc://{{ftp://a" onmouseover="alert('hello world');"
18889 |
18890 !! html
18891 <table>
18892 <tr>
18893 <th> <a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
18894 </th>
18895 <td>
18896 </td>
18897 </tr>
18898 </table>
18899
18900 !! end
18901
18902 !! test
18903 Fuzz testing: Parser22
18904 !! wikitext
18905 http://===r:::https://b
18906
18907 {|
18908 !! html
18909 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
18910 </p>
18911 <table>
18912 <tr><td></td></tr>
18913 </table>
18914
18915 !! end
18916
18917 # Known to produce bad XML for now
18918 !! test
18919 Fuzz testing: Parser24
18920 !! options
18921 parsoid=wt2html
18922 !! wikitext
18923 {|
18924 {{{|
18925 <u CLASS=
18926 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
18927 <br style="onmouseover='alert(document.cookie);' " />
18928
18929 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
18930 |
18931 !! html/php
18932 <table>
18933 {{{|
18934 <u class="&#124;">}}}} &gt;
18935 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
18936
18937 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
18938 <tr>
18939 <td></u>
18940 </td>
18941 </tr>
18942 </table>
18943
18944 !! html/parsoid
18945 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
18946 <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>"}'/>}}}} >
18947 <br style="onmouseover='alert(document.cookie);' " data-parsoid='{"stx":"html","selfClose":true}'/></u></p><p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><u class="|" data-parsoid='{"stx":"html","a":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":null},"sa":{"{{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--":""},"autoInsertedEnd":true,"autoInsertedStart":true}'>MOVE YOUR MOUSE CURSOR OVER THIS TEXT</u></p><table data-parsoid='{"autoInsertedEnd":true}'>
18948
18949
18950
18951 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table>
18952 !! end
18953
18954 # Note: the current result listed for this is not what the original one was,
18955 # but the original bug was JavaScript injection, which is fixed in any case.
18956 # It's not clear that the original result listed was any more correct than the
18957 # current one. Original result:
18958 # <p>{{{|
18959 # </p>
18960 # <li class="&#124;&#124;">
18961 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
18962 !!test
18963 Fuzz testing: Parser25 (T8055)
18964 !! wikitext
18965 {{{
18966 |
18967 <LI CLASS=||
18968 >
18969 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
18970 !! html/php
18971 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
18972 </p>
18973 !! html/parsoid
18974 <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"]}'>
18975 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
18976 !! end
18977
18978 !!test
18979 Fuzz testing: URL adjacent extension (with space, clean)
18980 !! wikitext
18981 http://example.com <nowiki>junk</nowiki>
18982 !! html/php
18983 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
18984 </p>
18985 !! html/parsoid
18986 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a> <span typeof="mw:Nowiki">junk</span></p>
18987 !! end
18988
18989 !!test
18990 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
18991 !! wikitext
18992 http://example.com<nowiki>junk</nowiki>
18993 !! html/php
18994 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
18995 </p>
18996 !! html/parsoid
18997 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a><span typeof="mw:Nowiki">junk</span></p>
18998 !! end
18999
19000 !! test
19001 Fuzz testing: URL adjacent extension (no space, dirty; pre)
19002 !! wikitext
19003 http://example.com<pre>junk</pre>
19004 !! html/php
19005 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
19006
19007 !! html/php+tidy
19008 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p><pre>junk</pre>
19009 !! html/parsoid
19010 <p><a rel="mw:ExtLink" 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>
19011 !! end
19012
19013 !! test
19014 Fuzz testing: image with bogus manual thumbnail
19015 !! wikitext
19016 [[Image:foobar.jpg|thumbnail= ]]
19017 !! html/php
19018 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
19019
19020 !! html/parsoid
19021 <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>
19022 !! end
19023
19024 # Parsoid will emit the newline literally in wt2wt; see next test case.
19025 !! test
19026 Fuzz testing: encoded newline in generated HTML replacements (T8577)
19027 !! options
19028 parsoid=wt2html
19029 !! wikitext
19030 <pre dir="&#10;"></pre>
19031 !! html/php
19032 <pre dir="&#10;"></pre>
19033
19034 !! html/parsoid
19035 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19036 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19037 !! end
19038
19039 !! test
19040 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
19041 !! options
19042 parsoid=html2wt
19043 !! html/parsoid
19044 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19045 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19046 !! wikitext
19047 <pre dir="
19048 "></pre>
19049 !! html/php
19050 <pre dir=""></pre>
19051
19052 !! end
19053
19054 !! test
19055 Templates in extension attributes are not expanded
19056 !! wikitext
19057 <pre dir="{{echo|ltr}}"></pre>
19058 !! html/php
19059 <pre dir="{{echo|ltr}}"></pre>
19060
19061 !! html/parsoid
19062 <pre typeof="mw:Extension/pre" about="#mwt2" dir="{{echo|ltr}}" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
19063 !! end
19064
19065 !! test
19066 Parsing optional HTML elements (T8171)
19067 !! options
19068 !! wikitext
19069 <table>
19070 <tr>
19071 <td> Some tabular data</td>
19072 <td> More tabular data ...
19073 <td> And yet som tabular data</td>
19074 </tr>
19075 </table>
19076 !! html
19077 <table>
19078 <tr>
19079 <td> Some tabular data</td>
19080 <td> More tabular data ...
19081 </td><td> And yet som tabular data</td>
19082 </tr>
19083 </table>
19084
19085 !! end
19086
19087 !! test
19088 Correct handling of <td>, <tr> (T8171)
19089 !! options
19090 !! wikitext
19091 <table>
19092 <tr>
19093 <td> Some tabular data</td>
19094 <td> More tabular data ...</td>
19095 <td> And yet som tabular data</td>
19096 </tr>
19097 </table>
19098 !! html
19099 <table>
19100 <tr>
19101 <td> Some tabular data</td>
19102 <td> More tabular data ...</td>
19103 <td> And yet som tabular data</td>
19104 </tr>
19105 </table>
19106
19107 !! end
19108
19109
19110 !! test
19111 Parsing crashing regression (fr:JavaScript)
19112 !! wikitext
19113 </body></x>
19114 !! html
19115 <p>&lt;/body&gt;&lt;/x&gt;
19116 </p>
19117 !! end
19118
19119 !! test
19120 Inline wiki vs wiki block nesting
19121 !! wikitext
19122 '''Bold paragraph
19123
19124 New wiki paragraph
19125 !! html
19126 <p><b>Bold paragraph</b>
19127 </p><p>New wiki paragraph
19128 </p>
19129 !! end
19130
19131 # FIXME: The current php output is documented
19132 # and desired output is the parsoid target.
19133 !! test
19134 Inline HTML vs wiki block nesting
19135 !! wikitext
19136 <b>Bold paragraph
19137
19138 New wiki paragraph
19139 !! html/php
19140 <p><b>Bold paragraph
19141 </p><p>New wiki paragraph</b>
19142 </p>
19143 !! html/parsoid
19144 <p><b>Bold paragraph</b>
19145 </p><p>New wiki paragraph
19146 </p>
19147 !! end
19148
19149 # Original result was this:
19150 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
19151 # </p>
19152 # While that might be marginally more intuitive, maybe, the six-apostrophe
19153 # construct is clearly pathological and the result stated here (which is what
19154 # the parser actually does) is about as reasonable as anything.
19155 !!test
19156 Mixing markup for italics and bold
19157 !! options
19158 !! wikitext
19159 '''bold''''''bold''bolditalics'''''
19160 !! html
19161 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
19162 </p>
19163 !! end
19164
19165
19166 !! article
19167 Xyzzyx
19168 !! text
19169 Article for special page transclusion test
19170 !! endarticle
19171
19172 !! test
19173 Special page transclusion
19174 !! options
19175 !! wikitext
19176 {{Special:Prefixindex/Xyzzyx}}
19177 !! html
19178 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19179 </ul>
19180
19181 !! end
19182
19183 !! test
19184 Special page transclusion twice (T7021)
19185 !! options
19186 !! wikitext
19187 {{Special:Prefixindex/Xyzzyx}}
19188 {{Special:Prefixindex/Xyzzyx}}
19189 !! html
19190 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19191 </ul>
19192 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19193 </ul>
19194
19195 !! end
19196
19197 !! test
19198 Transclusion of default MediaWiki message
19199 !! wikitext
19200 {{MediaWiki:Mainpage}}
19201 !! html
19202 <p>Main Page
19203 </p>
19204 !! end
19205
19206 !! test
19207 Transclusion of nonexistent MediaWiki message
19208 !! wikitext
19209 {{MediaWiki:Mainpagexxx}}
19210 !! html
19211 <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>
19212 </p>
19213 !! end
19214
19215 !! test
19216 Transclusion of MediaWiki message with underscore
19217 !! wikitext
19218 {{MediaWiki:history_short}}
19219 !! html
19220 <p>History
19221 </p>
19222 !! end
19223
19224 !! test
19225 Transclusion of MediaWiki message with space
19226 !! wikitext
19227 {{MediaWiki:history short}}
19228 !! html
19229 <p>History
19230 </p>
19231 !! end
19232
19233 !! test
19234 Invalid header with following text
19235 !! wikitext
19236 = x = y
19237 !! html
19238 <p>= x = y
19239 </p>
19240 !! end
19241
19242
19243 !! test
19244 Section extraction test (section 0)
19245 !! options
19246 section=0
19247 !! wikitext
19248 start
19249 ==a==
19250 ===aa===
19251 ====aaa====
19252 ==b==
19253 ===ba===
19254 ===bb===
19255 ====bba====
19256 ===bc===
19257 ==c==
19258 ===ca===
19259 !! html/php
19260 start
19261 !! end
19262
19263 !! test
19264 Section extraction test (section 1)
19265 !! options
19266 section=1
19267 !! wikitext
19268 start
19269 ==a==
19270 ===aa===
19271 ====aaa====
19272 ==b==
19273 ===ba===
19274 ===bb===
19275 ====bba====
19276 ===bc===
19277 ==c==
19278 ===ca===
19279 !! html/php
19280 ==a==
19281 ===aa===
19282 ====aaa====
19283 !! end
19284
19285 !! test
19286 Section extraction test (section 2)
19287 !! options
19288 section=2
19289 !! wikitext
19290 start
19291 ==a==
19292 ===aa===
19293 ====aaa====
19294 ==b==
19295 ===ba===
19296 ===bb===
19297 ====bba====
19298 ===bc===
19299 ==c==
19300 ===ca===
19301 !! html/php
19302 ===aa===
19303 ====aaa====
19304 !! end
19305
19306 !! test
19307 Section extraction test (section 3)
19308 !! options
19309 section=3
19310 !! wikitext
19311 start
19312 ==a==
19313 ===aa===
19314 ====aaa====
19315 ==b==
19316 ===ba===
19317 ===bb===
19318 ====bba====
19319 ===bc===
19320 ==c==
19321 ===ca===
19322 !! html/php
19323 ====aaa====
19324 !! end
19325
19326 !! test
19327 Section extraction test (section 4)
19328 !! options
19329 section=4
19330 !! wikitext
19331 start
19332 ==a==
19333 ===aa===
19334 ====aaa====
19335 ==b==
19336 ===ba===
19337 ===bb===
19338 ====bba====
19339 ===bc===
19340 ==c==
19341 ===ca===
19342 !! html/php
19343 ==b==
19344 ===ba===
19345 ===bb===
19346 ====bba====
19347 ===bc===
19348 !! end
19349
19350 !! test
19351 Section extraction test (section 5)
19352 !! options
19353 section=5
19354 !! wikitext
19355 start
19356 ==a==
19357 ===aa===
19358 ====aaa====
19359 ==b==
19360 ===ba===
19361 ===bb===
19362 ====bba====
19363 ===bc===
19364 ==c==
19365 ===ca===
19366 !! html/php
19367 ===ba===
19368 !! end
19369
19370 !! test
19371 Section extraction test (section 6)
19372 !! options
19373 section=6
19374 !! wikitext
19375 start
19376 ==a==
19377 ===aa===
19378 ====aaa====
19379 ==b==
19380 ===ba===
19381 ===bb===
19382 ====bba====
19383 ===bc===
19384 ==c==
19385 ===ca===
19386 !! html/php
19387 ===bb===
19388 ====bba====
19389 !! end
19390
19391 !! test
19392 Section extraction test (section 7)
19393 !! options
19394 section=7
19395 !! wikitext
19396 start
19397 ==a==
19398 ===aa===
19399 ====aaa====
19400 ==b==
19401 ===ba===
19402 ===bb===
19403 ====bba====
19404 ===bc===
19405 ==c==
19406 ===ca===
19407 !! html/php
19408 ====bba====
19409 !! end
19410
19411 !! test
19412 Section extraction test (section 8)
19413 !! options
19414 section=8
19415 !! wikitext
19416 start
19417 ==a==
19418 ===aa===
19419 ====aaa====
19420 ==b==
19421 ===ba===
19422 ===bb===
19423 ====bba====
19424 ===bc===
19425 ==c==
19426 ===ca===
19427 !! html/php
19428 ===bc===
19429 !! end
19430
19431 !! test
19432 Section extraction test (section 9)
19433 !! options
19434 section=9
19435 !! wikitext
19436 start
19437 ==a==
19438 ===aa===
19439 ====aaa====
19440 ==b==
19441 ===ba===
19442 ===bb===
19443 ====bba====
19444 ===bc===
19445 ==c==
19446 ===ca===
19447 !! html/php
19448 ==c==
19449 ===ca===
19450 !! end
19451
19452 !! test
19453 Section extraction test (section 10)
19454 !! options
19455 section=10
19456 !! wikitext
19457 start
19458 ==a==
19459 ===aa===
19460 ====aaa====
19461 ==b==
19462 ===ba===
19463 ===bb===
19464 ====bba====
19465 ===bc===
19466 ==c==
19467 ===ca===
19468 !! html/php
19469 ===ca===
19470 !! end
19471
19472 !! test
19473 Section extraction test (nonexistent section 11)
19474 !! options
19475 section=11
19476 !! wikitext
19477 start
19478 ==a==
19479 ===aa===
19480 ====aaa====
19481 ==b==
19482 ===ba===
19483 ===bb===
19484 ====bba====
19485 ===bc===
19486 ==c==
19487 ===ca===
19488 !! html/php
19489 !! end
19490
19491 !! test
19492 Section extraction test with bogus heading (section 1)
19493 !! options
19494 section=1
19495 !! wikitext
19496 ==a==
19497 ==bogus== not a legal section
19498 ==b==
19499 !! html/php
19500 ==a==
19501 ==bogus== not a legal section
19502 !! end
19503
19504 !! test
19505 Section extraction test with bogus heading (section 2)
19506 !! options
19507 section=2
19508 !! wikitext
19509 ==a==
19510 ==bogus== not a legal section
19511 ==b==
19512 !! html/php
19513 ==b==
19514 !! end
19515
19516 !! test
19517 Section extraction test with comment after heading (section 1)
19518 !! options
19519 section=1
19520 !! wikitext
19521 ==a==
19522 ==b== <!-- -->
19523 ==c==
19524 !! html/php
19525 ==a==
19526 !! end
19527
19528 !! test
19529 Section extraction test with comment after heading (section 2)
19530 !! options
19531 section=2
19532 !! wikitext
19533 ==a==
19534 ==b== <!-- -->
19535 ==c==
19536 !! html/php
19537 ==b== <!-- -->
19538 !! end
19539
19540 !! test
19541 Section extraction test with bogus <nowiki> heading (section 1)
19542 !! options
19543 section=1
19544 !! wikitext
19545 ==a==
19546 ==bogus== <nowiki>not a legal section</nowiki>
19547 ==b==
19548 !! html/php
19549 ==a==
19550 ==bogus== <nowiki>not a legal section</nowiki>
19551 !! end
19552
19553 !! test
19554 Section extraction test with bogus <nowiki> heading (section 2)
19555 !! options
19556 section=2
19557 !! wikitext
19558 ==a==
19559 ==bogus== <nowiki>not a legal section</nowiki>
19560 ==b==
19561 !! html/php
19562 ==b==
19563 !! end
19564
19565 # Formerly testing for T4587, now resolved by the use of unmarked sections
19566 # instead of respecting commented sections
19567 !! test
19568 Section extraction prefixed by comment (section 1)
19569 !! options
19570 section=1
19571 !! wikitext
19572 <!-- -->==sec1==
19573 ==sec2==
19574 !! html/php
19575 ==sec2==
19576 !!end
19577
19578 !! test
19579 Section extraction prefixed by comment (section 2)
19580 !! options
19581 section=2
19582 !! wikitext
19583 <!-- -->==sec1==
19584 ==sec2==
19585 !! html/php
19586
19587 !!end
19588
19589 # Formerly testing for T4607, now resolved by the use of unmarked sections
19590 # instead of respecting HTML-style headings
19591 !! test
19592 Section extraction, mixed wiki and html (section 1)
19593 !! options
19594 section=1
19595 !! wikitext
19596 <h2>unmarked</h2>
19597 unmarked
19598 ==1==
19599 one
19600 ==2==
19601 two
19602 !! html/php
19603 ==1==
19604 one
19605 !! end
19606
19607 !! test
19608 Section extraction, mixed wiki and html (section 2)
19609 !! options
19610 section=2
19611 !! wikitext
19612 <h2>unmarked</h2>
19613 unmarked
19614 ==1==
19615 one
19616 ==2==
19617 two
19618 !! html/php
19619 ==2==
19620 two
19621 !! end
19622
19623
19624 # Formerly testing for T5342
19625 !! test
19626 Section extraction, heading surrounded by <noinclude>
19627 !! options
19628 section=1
19629 !! wikitext
19630 <noinclude>==unmarked==</noinclude>
19631 ==marked==
19632 !! html/php
19633 ==marked==
19634 !!end
19635
19636 # Test behavior of T21910
19637 !! test
19638 Sectiion with all-equals
19639 !! options
19640 section=2
19641 !! wikitext
19642 ===
19643 The line above must have a trailing space
19644 === <!--
19645 --> <!-- -->
19646 But just in case it doesn't...
19647 !! html/php
19648 === <!--
19649 --> <!-- -->
19650 But just in case it doesn't...
19651 !! end
19652
19653 !! test
19654 Section replacement test (section 0)
19655 !! options
19656 replace=0,"xxx"
19657 !! wikitext
19658 start
19659 ==a==
19660 ===aa===
19661 ====aaa====
19662 ==b==
19663 ===ba===
19664 ===bb===
19665 ====bba====
19666 ===bc===
19667 ==c==
19668 ===ca===
19669 !! html/php
19670 xxx
19671
19672 ==a==
19673 ===aa===
19674 ====aaa====
19675 ==b==
19676 ===ba===
19677 ===bb===
19678 ====bba====
19679 ===bc===
19680 ==c==
19681 ===ca===
19682 !! end
19683
19684 !! test
19685 Section replacement test (section 1)
19686 !! options
19687 replace=1,"xxx"
19688 !! wikitext
19689 start
19690 ==a==
19691 ===aa===
19692 ====aaa====
19693 ==b==
19694 ===ba===
19695 ===bb===
19696 ====bba====
19697 ===bc===
19698 ==c==
19699 ===ca===
19700 !! html/php
19701 start
19702 xxx
19703
19704 ==b==
19705 ===ba===
19706 ===bb===
19707 ====bba====
19708 ===bc===
19709 ==c==
19710 ===ca===
19711 !! end
19712
19713 !! test
19714 Section replacement test (section 2)
19715 !! options
19716 replace=2,"xxx"
19717 !! wikitext
19718 start
19719 ==a==
19720 ===aa===
19721 ====aaa====
19722 ==b==
19723 ===ba===
19724 ===bb===
19725 ====bba====
19726 ===bc===
19727 ==c==
19728 ===ca===
19729 !! html/php
19730 start
19731 ==a==
19732 xxx
19733
19734 ==b==
19735 ===ba===
19736 ===bb===
19737 ====bba====
19738 ===bc===
19739 ==c==
19740 ===ca===
19741 !! end
19742
19743 !! test
19744 Section replacement test (section 3)
19745 !! options
19746 replace=3,"xxx"
19747 !! wikitext
19748 start
19749 ==a==
19750 ===aa===
19751 ====aaa====
19752 ==b==
19753 ===ba===
19754 ===bb===
19755 ====bba====
19756 ===bc===
19757 ==c==
19758 ===ca===
19759 !! html/php
19760 start
19761 ==a==
19762 ===aa===
19763 xxx
19764
19765 ==b==
19766 ===ba===
19767 ===bb===
19768 ====bba====
19769 ===bc===
19770 ==c==
19771 ===ca===
19772 !! end
19773
19774 !! test
19775 Section replacement test (section 4)
19776 !! options
19777 replace=4,"xxx"
19778 !! wikitext
19779 start
19780 ==a==
19781 ===aa===
19782 ====aaa====
19783 ==b==
19784 ===ba===
19785 ===bb===
19786 ====bba====
19787 ===bc===
19788 ==c==
19789 ===ca===
19790 !! html/php
19791 start
19792 ==a==
19793 ===aa===
19794 ====aaa====
19795 xxx
19796
19797 ==c==
19798 ===ca===
19799 !! end
19800
19801 !! test
19802 Section replacement test (section 5)
19803 !! options
19804 replace=5,"xxx"
19805 !! wikitext
19806 start
19807 ==a==
19808 ===aa===
19809 ====aaa====
19810 ==b==
19811 ===ba===
19812 ===bb===
19813 ====bba====
19814 ===bc===
19815 ==c==
19816 ===ca===
19817 !! html/php
19818 start
19819 ==a==
19820 ===aa===
19821 ====aaa====
19822 ==b==
19823 xxx
19824
19825 ===bb===
19826 ====bba====
19827 ===bc===
19828 ==c==
19829 ===ca===
19830 !! end
19831
19832 !! test
19833 Section replacement test (section 6)
19834 !! options
19835 replace=6,"xxx"
19836 !! wikitext
19837 start
19838 ==a==
19839 ===aa===
19840 ====aaa====
19841 ==b==
19842 ===ba===
19843 ===bb===
19844 ====bba====
19845 ===bc===
19846 ==c==
19847 ===ca===
19848 !! html/php
19849 start
19850 ==a==
19851 ===aa===
19852 ====aaa====
19853 ==b==
19854 ===ba===
19855 xxx
19856
19857 ===bc===
19858 ==c==
19859 ===ca===
19860 !! end
19861
19862 !! test
19863 Section replacement test (section 7)
19864 !! options
19865 replace=7,"xxx"
19866 !! wikitext
19867 start
19868 ==a==
19869 ===aa===
19870 ====aaa====
19871 ==b==
19872 ===ba===
19873 ===bb===
19874 ====bba====
19875 ===bc===
19876 ==c==
19877 ===ca===
19878 !! html/php
19879 start
19880 ==a==
19881 ===aa===
19882 ====aaa====
19883 ==b==
19884 ===ba===
19885 ===bb===
19886 xxx
19887
19888 ===bc===
19889 ==c==
19890 ===ca===
19891 !! end
19892
19893 !! test
19894 Section replacement test (section 8)
19895 !! options
19896 replace=8,"xxx"
19897 !! wikitext
19898 start
19899 ==a==
19900 ===aa===
19901 ====aaa====
19902 ==b==
19903 ===ba===
19904 ===bb===
19905 ====bba====
19906 ===bc===
19907 ==c==
19908 ===ca===
19909 !! html/php
19910 start
19911 ==a==
19912 ===aa===
19913 ====aaa====
19914 ==b==
19915 ===ba===
19916 ===bb===
19917 ====bba====
19918 xxx
19919
19920 ==c==
19921 ===ca===
19922 !!end
19923
19924 !! test
19925 Section replacement test (section 9)
19926 !! options
19927 replace=9,"xxx"
19928 !! wikitext
19929 start
19930 ==a==
19931 ===aa===
19932 ====aaa====
19933 ==b==
19934 ===ba===
19935 ===bb===
19936 ====bba====
19937 ===bc===
19938 ==c==
19939 ===ca===
19940 !! html/php
19941 start
19942 ==a==
19943 ===aa===
19944 ====aaa====
19945 ==b==
19946 ===ba===
19947 ===bb===
19948 ====bba====
19949 ===bc===
19950 xxx
19951 !! end
19952
19953 !! test
19954 Section replacement test (section 10)
19955 !! options
19956 replace=10,"xxx"
19957 !! wikitext
19958 start
19959 ==a==
19960 ===aa===
19961 ====aaa====
19962 ==b==
19963 ===ba===
19964 ===bb===
19965 ====bba====
19966 ===bc===
19967 ==c==
19968 ===ca===
19969 !! html/php
19970 start
19971 ==a==
19972 ===aa===
19973 ====aaa====
19974 ==b==
19975 ===ba===
19976 ===bb===
19977 ====bba====
19978 ===bc===
19979 ==c==
19980 xxx
19981 !! end
19982
19983 !! test
19984 Section replacement test with initial whitespace (T15728)
19985 !! options
19986 replace=2,"xxx"
19987 !! wikitext
19988 Preformatted initial line
19989 ==a==
19990 ===a===
19991 !! html/php
19992 Preformatted initial line
19993 ==a==
19994 xxx
19995 !! end
19996
19997
19998 !! test
19999 Section extraction, heading followed by pre with 20 spaces (T8398)
20000 !! options
20001 section=1
20002 !! wikitext
20003 ==a==
20004 a
20005 !! html/php
20006 ==a==
20007 a
20008 !! end
20009
20010 !! test
20011 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
20012 !! options
20013 section=1
20014 !! wikitext
20015 ==a==
20016 a
20017 !! html/php
20018 ==a==
20019 a
20020 !! end
20021
20022
20023 !! test
20024 Section extraction, <pre> around bogus header (T12309)
20025 !! options
20026 section=2
20027 !! wikitext
20028 == Section One ==
20029 <pre>
20030 =======
20031 </pre>
20032
20033 == Section Two ==
20034 stuff
20035 !! html/php
20036 == Section Two ==
20037 stuff
20038 !! end
20039
20040 !! test
20041 Section replacement, <pre> around bogus header (T12309)
20042 !! options
20043 replace=2,"xxx"
20044 !! wikitext
20045 == Section One ==
20046 <pre>
20047 =======
20048 </pre>
20049
20050 == Section Two ==
20051 stuff
20052 !! html/php
20053 == Section One ==
20054 <pre>
20055 =======
20056 </pre>
20057
20058 xxx
20059 !! end
20060
20061 !! test
20062 Handling of &#x0A; in URLs
20063 !! wikitext
20064 ** irc://&#x0A;a
20065 !! html/php
20066 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
20067
20068 !! html/parsoid
20069 <ul><li><ul><li> <a rel="mw:ExtLink" href="irc://%0Aa" data-parsoid='{"stx":"url","a":{"href":"irc://%0Aa"},"sa":{"href":"irc://&amp;#x0A;a"}}'>irc://%0Aa</a></li></ul></li></ul>
20070 !! end
20071
20072 !! test
20073 Handling of %0A in URLs
20074 !! wikitext
20075 ** irc://%0Aa
20076 !! html/php
20077 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
20078
20079 !! html/parsoid
20080 <ul><li><ul><li> <a rel="mw:ExtLink" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
20081 !! end
20082
20083 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
20084 !! test
20085 5 quotes, code coverage +1 line
20086 !! options
20087 parsoid=wt2html
20088 !! wikitext
20089 '''''
20090 !! html/php
20091 !! html/parsoid
20092 <b><i></i></b>
20093 !! end
20094
20095 # same html as previous, but wikitext adjusted to match parsoid html2wt
20096 # note that wt2html and html2html will put the <i> before the <b>
20097 !! test
20098 5 quotes, code coverage +1 line w/ nowiki (1)
20099 !! options
20100 parsoid=wt2wt,html2wt
20101 !! wikitext
20102 '''''<nowiki/>'''''
20103 !! html/php
20104 <p><i></i>
20105 </p>
20106 !! html/parsoid
20107 <p><b><i></i></b></p>
20108 !! end
20109
20110 # same as previous, just swapping the <i> and <b>
20111 !! test
20112 5 quotes, code coverage +1 line w/ nowiki (2)
20113 !! wikitext
20114 '''''<nowiki/>'''''
20115 !! html/php
20116 <p><i></i>
20117 </p>
20118 !! html/parsoid
20119 <p><i><b></b></i></p>
20120 !! end
20121
20122 !! test
20123 Special:Search page linking.
20124 !! wikitext
20125 {{Special:search}}
20126 !! html
20127 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
20128 </p>
20129 !! end
20130
20131 !! test
20132 {{!}} is a magic word
20133 !! wikitext
20134 {{!}} is a magic word there and {{!}} is still a magic word here
20135 | is not a magic word here but {{!}} is still a magic word here
20136 !! html/php
20137 <p>| is a magic word there and | is still a magic word here
20138 | is not a magic word here but | is still a magic word here
20139 </p>
20140 !! html/parsoid
20141 <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
20142 | 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>
20143 !! end
20144
20145 !! test
20146 Say the magic word
20147 !! options
20148 title=[[Parser test]]
20149 !! wikitext
20150 * {{PAGENAME}}
20151 * {{PAGENAMEE}}
20152 * {{FULLPAGENAME}}
20153 * {{FULLPAGENAMEE}}
20154 * {{BASEPAGENAME}}
20155 * {{BASEPAGENAMEE}}
20156 * {{SUBPAGENAME}}
20157 * {{SUBPAGENAMEE}}
20158 * {{ROOTPAGENAME}}
20159 * {{ROOTPAGENAMEE}}
20160 * {{TALKPAGENAME}}
20161 * {{TALKPAGENAMEE}}
20162 * {{SUBJECTPAGENAME}}
20163 * {{SUBJECTPAGENAMEE}}
20164 * {{NAMESPACEE}}
20165 * {{NAMESPACE}}
20166 * {{NAMESPACENUMBER}}
20167 * {{TALKSPACE}}
20168 * {{TALKSPACEE}}
20169 * {{SUBJECTSPACE}}
20170 * {{SUBJECTSPACEE}}
20171 * {{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
20172 !! html
20173 <ul><li> Parser test</li>
20174 <li> Parser_test</li>
20175 <li> Parser test</li>
20176 <li> Parser_test</li>
20177 <li> Parser test</li>
20178 <li> Parser_test</li>
20179 <li> Parser test</li>
20180 <li> Parser_test</li>
20181 <li> Parser test</li>
20182 <li> Parser_test</li>
20183 <li> Talk:Parser test</li>
20184 <li> Talk:Parser_test</li>
20185 <li> Parser test</li>
20186 <li> Parser_test</li>
20187 <li> </li>
20188 <li> </li>
20189 <li> 0</li>
20190 <li> Talk</li>
20191 <li> Talk</li>
20192 <li> </li>
20193 <li> </li>
20194 <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>
20195
20196 !! end
20197 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
20198
20199 !! test
20200 Gallery with valid attributes
20201 !! wikitext
20202 <gallery type="123" summary="345">
20203 File:File:Foobar.jpg
20204 </gallery>
20205 !! html/php
20206 <ul class="gallery mw-gallery-traditional" type="123">
20207 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20208 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
20209 <div class="gallerytext">
20210 </div>
20211 </div></li>
20212 </ul>
20213
20214 !! html/parsoid
20215 <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"}}'>
20216 <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>
20217 </ul>
20218 !! end
20219
20220 ## Parsoid thinks the "centre" here is a property, not a caption.
20221 !! test
20222 Gallery
20223 !! options
20224 parsoid={
20225 "modes": ["wt2html"],
20226 "nativeGallery": true
20227 }
20228 !! wikitext
20229 <gallery>
20230 image1.png |
20231 image2.gif|||||
20232
20233 image3|
20234 image4 |300px| centre
20235 image5.svg| http://///////
20236 [[x|xx]]]]
20237 * image6
20238 </gallery>
20239 !! html/php
20240 <ul class="gallery mw-gallery-traditional">
20241 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20242 <div class="thumb" style="height: 150px;">Image1.png</div>
20243 <div class="gallerytext">
20244 </div>
20245 </div></li>
20246 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20247 <div class="thumb" style="height: 150px;">Image2.gif</div>
20248 <div class="gallerytext">
20249 </div>
20250 </div></li>
20251 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20252 <div class="thumb" style="height: 150px;">Image3</div>
20253 <div class="gallerytext">
20254 </div>
20255 </div></li>
20256 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20257 <div class="thumb" style="height: 150px;">Image4</div>
20258 <div class="gallerytext">
20259 <pre>centre
20260 </pre>
20261 </div>
20262 </div></li>
20263 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20264 <div class="thumb" style="height: 150px;">Image5.svg</div>
20265 <div class="gallerytext">
20266 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
20267 </p>
20268 </div>
20269 </div></li>
20270 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20271 <div class="thumb" style="height: 150px;">* image6</div>
20272 <div class="gallerytext">
20273 </div>
20274 </div></li>
20275 </ul>
20276
20277 !! html/parsoid
20278 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20279 <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>
20280 <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>
20281 <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>
20282 <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>
20283 <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" href="http://///////">http://///////</a></div></li>
20284 <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>
20285 </ul>
20286 !! end
20287
20288 !! test
20289 Gallery (with options, html)
20290 !! options
20291 parsoid={
20292 "modes": ["wt2html", "html2html"],
20293 "nativeGallery": true
20294 }
20295 !! wikitext
20296 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20297 File:Nonexistent.jpg|caption
20298 File:Nonexistent.jpg
20299 image:foobar.jpg|some '''caption''' [[Main Page]]
20300 image:foobar.jpg
20301 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20302 </gallery>
20303 !! html/php
20304 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20305 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20306 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20307 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20308 <div class="gallerytext">
20309 <p>caption
20310 </p>
20311 </div>
20312 </div></li>
20313 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20314 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20315 <div class="gallerytext">
20316 </div>
20317 </div></li>
20318 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20319 <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>
20320 <div class="gallerytext">
20321 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20322 </p>
20323 </div>
20324 </div></li>
20325 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20326 <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>
20327 <div class="gallerytext">
20328 </div>
20329 </div></li>
20330 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20331 <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>
20332 <div class="gallerytext">
20333 <p>blabla.
20334 </p>
20335 </div>
20336 </div></li>
20337 </ul>
20338
20339 !! html/parsoid
20340 <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":{}}'>
20341 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20342 <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>
20343 <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>
20344 <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>
20345 <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>
20346 <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>
20347 </ul>
20348 !! end
20349
20350 !! test
20351 Gallery (with options, extsrc)
20352 !! options
20353 parsoid={
20354 "nativeGallery": false
20355 }
20356 !! wikitext
20357 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20358 File:Nonexistent.jpg|caption
20359 File:Nonexistent.jpg
20360 image:foobar.jpg|some '''caption''' [[Main Page]]
20361 image:foobar.jpg
20362 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20363 </gallery>
20364 !! html/php
20365 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20366 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20367 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20368 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20369 <div class="gallerytext">
20370 <p>caption
20371 </p>
20372 </div>
20373 </div></li>
20374 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20375 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20376 <div class="gallerytext">
20377 </div>
20378 </div></li>
20379 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20380 <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>
20381 <div class="gallerytext">
20382 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20383 </p>
20384 </div>
20385 </div></li>
20386 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20387 <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>
20388 <div class="gallerytext">
20389 </div>
20390 </div></li>
20391 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20392 <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>
20393 <div class="gallerytext">
20394 <p>blabla.
20395 </p>
20396 </div>
20397 </div></li>
20398 </ul>
20399
20400 !! html/parsoid
20401 <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"}}'>
20402 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20403 <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>
20404 <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>
20405 <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>
20406 <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>
20407 <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>
20408 </ul>
20409 !! end
20410
20411 !! test
20412 Gallery (without px units)
20413 !! wikitext
20414 <gallery widths="70" heights="40">
20415 File:Foobar.jpg
20416 </gallery>
20417 !! html/php
20418 <ul class="gallery mw-gallery-traditional">
20419 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20420 <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>
20421 <div class="gallerytext">
20422 </div>
20423 </div></li>
20424 </ul>
20425
20426 !! html/parsoid
20427 <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"}}'>
20428 <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>
20429 </ul>
20430 !! end
20431
20432 !! test
20433 Gallery (with invalid units)
20434 !! wikitext
20435 <gallery widths="70em" heights="40em">
20436 File:Foobar.jpg
20437 </gallery>
20438 !! html/php
20439 <ul class="gallery mw-gallery-traditional">
20440 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20441 <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>
20442 <div class="gallerytext">
20443 </div>
20444 </div></li>
20445 </ul>
20446
20447 !! html/parsoid
20448 <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"}}'>
20449 <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>
20450 </ul>
20451 !! end
20452
20453 !! test
20454 Gallery with link that has fragment
20455 !! options
20456 parsoid={
20457 "modes": ["wt2html", "html2html"],
20458 "nativeGallery": true
20459 }
20460 !! wikitext
20461 <gallery>
20462 image:foobar.jpg|link=Main_Page
20463 image:foobar.jpg|link=Main_Page#section
20464 image:foobar.jpg|link=Main Page#section|caption
20465 </gallery>
20466 !! html/php
20467 <ul class="gallery mw-gallery-traditional">
20468 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20469 <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>
20470 <div class="gallerytext">
20471 </div>
20472 </div></li>
20473 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20474 <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>
20475 <div class="gallerytext">
20476 </div>
20477 </div></li>
20478 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20479 <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>
20480 <div class="gallerytext">
20481 <p>caption
20482 </p>
20483 </div>
20484 </div></li>
20485 </ul>
20486
20487 !! html/parsoid
20488 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20489 <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>
20490 <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>
20491 <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>
20492 </ul>
20493 !! end
20494
20495 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
20496 !! test
20497 Gallery with template inside caption
20498 !! options
20499 parsoid={
20500 "nativeGallery": true
20501 }
20502 !! wikitext
20503 <gallery caption="{{echo|hi}}">
20504 File:Foobar.jpg|{{echo|ho}}
20505 </gallery>
20506 !! html/php
20507 <ul class="gallery mw-gallery-traditional">
20508 <li class='gallerycaption'>{{echo|hi}}</li>
20509 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20510 <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>
20511 <div class="gallerytext">
20512 <p>ho
20513 </p>
20514 </div>
20515 </div></li>
20516 </ul>
20517
20518 !! html/parsoid
20519 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20520 <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>
20521 <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>
20522 </ul>
20523 !! end
20524
20525 !! test
20526 Gallery with wikitext inside caption
20527 !! options
20528 parsoid={
20529 "nativeGallery": true
20530 }
20531 !! wikitext
20532 <gallery>
20533 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
20534 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
20535 </gallery>
20536 !! html/php
20537 <ul class="gallery mw-gallery-traditional">
20538 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20539 <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>
20540 <div class="gallerytext">
20541 <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>
20542 </p>
20543 </div>
20544 </div></li>
20545 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20546 <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>
20547 <div class="gallerytext">
20548 <p>This is a test template
20549 </p>
20550 </div>
20551 </div></li>
20552 </ul>
20553
20554 !! html/parsoid
20555 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20556 <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>
20557 <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>
20558 </ul>
20559 !! end
20560
20561 !! test
20562 Gallery (with showfilename option)
20563 !! options
20564 parsoid={
20565 "nativeGallery": true
20566 }
20567 !! wikitext
20568 <gallery showfilename="">
20569 File:Nonexistent.jpg|caption
20570 File:Nonexistent.jpg
20571 File:Foobar.jpg|some '''caption''' [[Main Page]]
20572 File:Foobar.jpg
20573 </gallery>
20574 !! html/php
20575 <ul class="gallery mw-gallery-traditional">
20576 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20577 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20578 <div class="gallerytext">
20579 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20580 caption
20581 </p>
20582 </div>
20583 </div></li>
20584 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20585 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20586 <div class="gallerytext">
20587 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20588 </p>
20589 </div>
20590 </div></li>
20591 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20592 <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>
20593 <div class="gallerytext">
20594 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20595 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20596 </p>
20597 </div>
20598 </div></li>
20599 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20600 <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>
20601 <div class="gallerytext">
20602 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20603 </p>
20604 </div>
20605 </div></li>
20606 </ul>
20607
20608 !! html/parsoid
20609 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
20610 <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>
20611 <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>
20612 <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>
20613 <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>
20614 </ul>
20615 !! end
20616
20617 ## Should Parsoid be preserving these variations? See T151367
20618 !! test
20619 Gallery (with namespace-less filenames)
20620 !! options
20621 parsoid={
20622 "modes": ["wt2html", "html2html"],
20623 "nativeGallery": true
20624 }
20625 !! wikitext
20626 <gallery>
20627 File:Nonexistent.jpg
20628 Nonexistent.jpg
20629 image:foobar.jpg
20630 foobar.jpg
20631 </gallery>
20632 !! html/php
20633 <ul class="gallery mw-gallery-traditional">
20634 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20635 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20636 <div class="gallerytext">
20637 </div>
20638 </div></li>
20639 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20640 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20641 <div class="gallerytext">
20642 </div>
20643 </div></li>
20644 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20645 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="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>
20646 <div class="gallerytext">
20647 </div>
20648 </div></li>
20649 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20650 <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>
20651 <div class="gallerytext">
20652 </div>
20653 </div></li>
20654 </ul>
20655
20656 !! html/parsoid
20657 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20658 <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>
20659 <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>
20660 <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>
20661 <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>
20662 </ul>
20663 !! end
20664
20665 !! test
20666 Gallery override link with wikilink (T36852)
20667 !! options
20668 parsoid={
20669 "nativeGallery": true
20670 }
20671 !! wikitext
20672 <gallery>
20673 File:Foobar.jpg|alt=galleryalt|link=Wikilink
20674 </gallery>
20675 !! html/php
20676 <ul class="gallery mw-gallery-traditional">
20677 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20678 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/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>
20679 <div class="gallerytext">
20680 </div>
20681 </div></li>
20682 </ul>
20683
20684 !! html/parsoid
20685 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-parsoid='{"dsr":[0,70,2,2]}' data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20686 <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>
20687 </ul>
20688 !! end
20689
20690 !! test
20691 Gallery override link with absolute external link (T36852)
20692 !! options
20693 parsoid={
20694 "nativeGallery": true
20695 }
20696 !! wikitext
20697 <gallery>
20698 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
20699 </gallery>
20700 !! html/php
20701 <ul class="gallery mw-gallery-traditional">
20702 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20703 <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>
20704 <div class="gallerytext">
20705 </div>
20706 </div></li>
20707 </ul>
20708
20709 !! html/parsoid
20710 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20711 <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>
20712 </ul>
20713 !! end
20714
20715 !! test
20716 Gallery override link with absolute external link with LanguageConverter
20717 !! options
20718 language=zh
20719 !! input
20720 <gallery>
20721 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
20722 </gallery>
20723 !! result
20724 <ul class="gallery mw-gallery-traditional">
20725 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20726 <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>
20727 <div class="gallerytext">
20728 <p>caption
20729 </p>
20730 </div>
20731 </div></li>
20732 </ul>
20733
20734 !! end
20735
20736 !! test
20737 Gallery override link with malicious javascript (T36852)
20738 !! options
20739 parsoid={
20740 "modes": ["wt2html", "html2html"],
20741 "nativeGallery": true
20742 }
20743 !! wikitext
20744 <gallery>
20745 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
20746 </gallery>
20747 !! html/php
20748 <ul class="gallery mw-gallery-traditional">
20749 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20750 <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>
20751 <div class="gallerytext">
20752 </div>
20753 </div></li>
20754 </ul>
20755
20756 !! html/parsoid
20757 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20758 <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>
20759 </ul>
20760 !! end
20761
20762 # Note that parsoid uses the invalid link as a caption, PHP does not.
20763 !! test
20764 Gallery with invalid title as link (T45964)
20765 !! options
20766 parsoid={
20767 "modes": ["wt2html", "html2html"],
20768 "nativeGallery": true
20769 }
20770 !! wikitext
20771 <gallery>
20772 File:Foobar.jpg|link=<
20773 </gallery>
20774 !! html/php
20775 <ul class="gallery mw-gallery-traditional">
20776 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20777 <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>
20778 <div class="gallerytext">
20779 </div>
20780 </div></li>
20781 </ul>
20782
20783 !! html/parsoid
20784 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20785 <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>
20786 </ul>
20787 !! end
20788
20789 !! test
20790 Serialize gallery without attrs in data-mw
20791 !! options
20792 parsoid={
20793 "modes": ["html2wt"],
20794 "nativeGallery": true
20795 }
20796 !! html/parsoid
20797 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
20798 <li class="gallerycaption">123</li>
20799 <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>
20800 </ul>
20801 !! wikitext
20802 <gallery caption="123">
20803 File:Test.png
20804 </gallery>
20805 !! end
20806
20807 !! test
20808 Gallery with class and style attributes
20809 !! options
20810 parsoid={
20811 "nativeGallery": true
20812 }
20813 !! wikitext
20814 <gallery class="center" style="text-align: center;">
20815 File:Foobar.jpg
20816 </gallery>
20817 !! html/php
20818 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
20819 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20820 <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>
20821 <div class="gallerytext">
20822 </div>
20823 </div></li>
20824 </ul>
20825
20826 !! html/parsoid
20827 <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":{}}'>
20828 <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>
20829 </ul>
20830 !! end
20831
20832 !! test
20833 Gallery in slideshow mode
20834 !! options
20835 parsoid={
20836 "nativeGallery": true
20837 }
20838 !! wikitext
20839 <gallery mode="slideshow" showthumbnails="">
20840 File:Foobar.jpg
20841 </gallery>
20842 !! html/php
20843 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
20844 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20845 <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>
20846 <div class="gallerytext">
20847 </div>
20848 </div></li>
20849 </ul>
20850
20851 !! html/parsoid
20852 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
20853 <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>
20854 </ul>
20855 !! end
20856
20857 !! test
20858 HTML Hex character encoding (spells the word "JavaScript")
20859 !! options
20860 parsoid=wt2html,wt2wt,html2html
20861 !! wikitext
20862 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
20863 !! html/php
20864 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
20865 </p>
20866 !! html/parsoid
20867 <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>
20868 !! end
20869
20870 !! test
20871 HTML Hex character encoding bogus encoding (T28437 regression check)
20872 !! wikitext
20873 &#xsee;&#XSEE;
20874 !! html
20875 <p>&amp;#xsee;&amp;#XSEE;
20876 </p>
20877 !! end
20878
20879 !! test
20880 HTML Hex character encoding mixed case
20881 !! options
20882 parsoid=wt2html,wt2wt,html2html
20883 !! wikitext
20884 &#xEE;&#Xee;
20885 !! html/php
20886 <p>&#xee;&#xee;
20887 </p>
20888 !! html/parsoid
20889 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
20890 !! end
20891
20892 # See: https://www.w3.org/TR/html5/syntax.html#character-references
20893 # Note that U+000C (form feed) is not a valid XML character, so
20894 # it is banned even though allowed in HTML5.
20895 !! test
20896 Illegal character references (T106578)
20897 !! wikitext
20898 ; Null: &#00;
20899 ; FF: &#xC;
20900 ; CR: &#xD;
20901 ; Control (low): &#8;
20902 ; Control (high): &#x7F; &#x9F;
20903 ; Surrogate: &#xD83D;&#xDCA9;
20904 ; This is an okay astral character: &#x1F4A9;
20905 !! html+tidy
20906 <dl><dt> Null</dt>
20907 <dd> &amp;#00;</dd>
20908 <dt> FF</dt>
20909 <dd> &amp;#xC;</dd>
20910 <dt> CR</dt>
20911 <dd> &amp;#xD;</dd>
20912 <dt> Control (low)</dt>
20913 <dd> &amp;#8;</dd>
20914 <dt> Control (high)</dt>
20915 <dd> &amp;#x7F; &amp;#x9F;</dd>
20916 <dt> Surrogate</dt>
20917 <dd> &amp;#xD83D;&amp;#xDCA9;</dd>
20918 <dt> This is an okay astral character</dt>
20919 <dd> &#x1f4a9;</dd></dl>
20920 !! end
20921
20922 !! test
20923 __FORCETOC__ override
20924 !! wikitext
20925 __NEWSECTIONLINK__
20926 __FORCETOC__
20927 !! html/php
20928 <p><br />
20929 </p>
20930 !! end
20931
20932 !! test
20933 ISBN code coverage
20934 !! wikitext
20935 ISBN 978-0-1234-56&#x20;789
20936 !! html/php
20937 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
20938 </p>
20939 !! html/parsoid
20940 <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>
20941 !! end
20942
20943 !! test
20944 ISBN followed by 5 spaces
20945 !! wikitext
20946 ISBN
20947 !! html
20948 <p>ISBN
20949 </p>
20950 !! end
20951
20952 !! test
20953 Double ISBN
20954 !! wikitext
20955 ISBN ISBN 1234567890
20956 !! html/php
20957 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20958 </p>
20959 !! html/parsoid
20960 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
20961 !! end
20962
20963 # Uppercase X and lowercase x as well
20964 !! test
20965 ISBN with an X
20966 !! wikitext
20967 ISBN 3-462-04561-X
20968 ISBN 3-462-04561-x
20969 ISBN 080442957X
20970 ISBN 080442957x
20971 ISBN 978080442957X
20972 ISBN 978080442957x
20973 !! html/php
20974 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
20975 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
20976 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
20977 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
20978 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
20979 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
20980 </p>
20981 !! html/parsoid
20982 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
20983 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
20984 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
20985 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
20986 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
20987 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
20988 !! end
20989
20990 !! test
20991 ISBN with empty prefix (parsoid test)
20992 !! wikitext
20993 ISBN 1234567890
20994 !! html/php
20995 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20996 </p>
20997 !! html/parsoid
20998 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
20999 !! end
21000
21001 !! test
21002 T24905: <abbr> followed by ISBN followed by </a>
21003 !! wikitext
21004 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
21005 !! html/php
21006 <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>
21007 </p>
21008 !! html/parsoid
21009 <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" href="http://www.example.com">example.com</a></p>
21010 !! end
21011
21012 !! test
21013 Double RFC
21014 !! wikitext
21015 RFC RFC 1234
21016 !! html
21017 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
21018 </p>
21019 !! end
21020
21021 !! test
21022 Double RFC with a wiki link
21023 !! wikitext
21024 RFC [[RFC 1234]]
21025 !! html
21026 <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>
21027 </p>
21028 !! end
21029
21030 !! test
21031 RFC code coverage
21032 !! wikitext
21033 RFC 983&#x20;987
21034 !! html/php
21035 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
21036 </p>
21037 !! html/parsoid
21038 <p><a href="https://tools.ietf.org/html/rfc983" rel="mw:ExtLink" class="external text" data-parsoid='{"stx":"magiclink"}'>RFC 983</a><span typeof="mw:Entity" data-parsoid='{"src":"&amp;#x20;","srcContent":" "}'> </span>987</p>
21039 !! end
21040
21041 !! test
21042 Centre-aligned image
21043 !! wikitext
21044 [[Image:foobar.jpg|centre]]
21045 !! html
21046 <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>
21047
21048 !!end
21049
21050 !! test
21051 None-aligned image
21052 !! wikitext
21053 [[Image:foobar.jpg|none]]
21054 !! html
21055 <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>
21056
21057 !!end
21058
21059 !! test
21060 Width + Height sized image (using px) (height is ignored)
21061 !! wikitext
21062 [[Image:foobar.jpg|640x480px]]
21063 !! html
21064 <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>
21065 </p>
21066 !!end
21067
21068 !! test
21069 Width-sized image (using px, no following whitespace)
21070 !! wikitext
21071 [[Image:foobar.jpg|640px]]
21072 !! html
21073 <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>
21074 </p>
21075 !!end
21076
21077 !! test
21078 Width-sized image (using px, with following whitespace - test regression from r39467)
21079 !! wikitext
21080 [[Image:foobar.jpg|640px ]]
21081 !! html
21082 <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>
21083 </p>
21084 !!end
21085
21086 !! test
21087 Width-sized image (using px, with preceding whitespace - test regression from r39467)
21088 !! wikitext
21089 [[Image:foobar.jpg| 640px]]
21090 !! html
21091 <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>
21092 </p>
21093 !!end
21094
21095 !! test
21096 Image with page parameter
21097 !! options
21098 djvu
21099 !! wikitext
21100 [[File:LoremIpsum.djvu|page=2]]
21101 !! html/php
21102 <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>
21103 </p>
21104 !! html/parsoid
21105 <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>
21106 !! end
21107
21108 !! test
21109 Another italics / bold test
21110 !! wikitext
21111 ''' ''x'
21112 !! html
21113 <pre>'<i> </i>x'
21114 </pre>
21115 !!end
21116
21117 # FIXME: The php output seems broken. It's interleaving some open/close tags.
21118 !! test
21119 dt/dd/dl test
21120 !! wikitext
21121 :;;;::
21122 !! html/php
21123 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
21124
21125 !! html/parsoid
21126 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
21127
21128 !!end
21129
21130 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
21131 !! test
21132 Images with the "|" character in the comment
21133 !! wikitext
21134 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
21135 !! html/php
21136 <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>
21137
21138 !! html/parsoid
21139 <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" 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>
21140 !! end
21141
21142 !! test
21143 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
21144 !! wikitext
21145 <html><script>alert(1);</script></html>
21146 !! html
21147 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
21148 </p>
21149 !! end
21150
21151 !! test
21152 HTML with raw HTML ($wgRawHtml==true)
21153 !! options
21154 wgRawHtml=1
21155 !! wikitext
21156 <html><script>alert(1);</script></html>
21157 !! html/php
21158 <p><script>alert(1);</script>
21159 </p>
21160 !! end
21161
21162 !! test
21163 Parents of subpages, one level up
21164 !! options
21165 subpage title=[[Subpage test/L1/L2/L3]]
21166 !! wikitext
21167 [[../|L2]]
21168 !! html
21169 <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>
21170 </p>
21171 !! end
21172
21173
21174 !! test
21175 Parents of subpages, one level up, not named
21176 !! options
21177 subpage title=[[Subpage test/L1/L2/L3]]
21178 !! wikitext
21179 [[../]]
21180 !! html
21181 <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>
21182 </p>
21183 !! end
21184
21185
21186
21187 !! test
21188 Parents of subpages, two levels up
21189 !! options
21190 subpage title=[[Subpage test/L1/L2/L3]]
21191 !! wikitext
21192 [[../../|L1]]2
21193
21194 [[../../|L1]]l
21195 !! html
21196 <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
21197 </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>
21198 </p>
21199 !! end
21200
21201 !! test
21202 Parents of subpages, two levels up, without trailing slash or name.
21203 !! options
21204 subpage title=[[Subpage test/L1/L2/L3]]
21205 !! wikitext
21206 [[../..]]
21207 !! html
21208 <p>[[../..]]
21209 </p>
21210 !! end
21211
21212 !! test
21213 Parents of subpages, two levels up, with lots of extra trailing slashes.
21214 !! options
21215 subpage title=[[Subpage test/L1/L2/L3]]
21216 !! wikitext
21217 [[../../////]]
21218 !! html
21219 <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>
21220 </p>
21221 !! end
21222
21223 !! article
21224 Subpage test/L1/L2/L3Sibling
21225 !! text
21226 Sibling article
21227 !! endarticle
21228
21229 !! test
21230 Transclusion of a sibling page (one level up)
21231 !! options
21232 subpage title=[[Subpage test/L1/L2/L3]]
21233 !! wikitext
21234 {{../L3Sibling}}
21235 !! html
21236 <p>Sibling article
21237 </p>
21238 !! end
21239
21240 !! test
21241 Transclusion of a child page
21242 !! options
21243 subpage title=[[Subpage test/L1/L2]]
21244 !! wikitext
21245 {{/L3Sibling}}
21246 !! html
21247 <p>Sibling article
21248 </p>
21249 !! end
21250
21251 # This is wt2html only in Parsoid because we add <nowiki>
21252 # because of {{..}} and we don't expect to fix that to
21253 # eliminate the nowikis selective for {{..}} markup.
21254 !! test
21255 Non-transclusion because of too many up levels
21256 !! options
21257 subpage title=[[Subpage test/L1/L2/L3]]
21258 parsoid=wt2html
21259 !! wikitext
21260 {{../../../../More than parent}}
21261 !! html/php
21262 <p>{{../../../../More than parent}}
21263 </p>
21264 !! html/parsoid
21265 <p>{{../../../../More than parent}}</p>
21266 !! end
21267
21268 !! test
21269 Definition list code coverage
21270 !! wikitext
21271 ; title : def
21272 ; title : def
21273 ;title: def
21274 !! html/php
21275 <dl><dt> title &#160;</dt>
21276 <dd> def</dd>
21277 <dt> title&#160;</dt>
21278 <dd> def</dd>
21279 <dt>title</dt>
21280 <dd> def</dd></dl>
21281
21282 !! html/parsoid
21283 <dl><dt> title <span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21284 <dt> title<span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21285 <dt>title</dt><dd> def</dd></dl>
21286 !! end
21287
21288 !! test
21289 Don't fall for the self-closing div
21290 !! wikitext
21291 <div>hello world</div/>
21292 !! html
21293 <div>hello world</div>
21294
21295 !! end
21296
21297 !! test
21298 MSGNW magic word
21299 !! wikitext
21300 {{MSGNW:msg}}
21301 !! html/php
21302 <p>&#91;&#91;:Template:Msg&#93;&#93;
21303 </p>
21304 !! end
21305
21306 !! test
21307 RAW magic word
21308 !! wikitext
21309 {{RAW:QUERTY}}
21310 !! html
21311 <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>
21312 </p>
21313 !! end
21314
21315 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
21316 !! test
21317 Always escape literal '>' in output, not just after '<'
21318 !! wikitext
21319 ><>
21320 !! html
21321 <p>&gt;&lt;&gt;
21322 </p>
21323 !! end
21324
21325 !! test
21326 Template caching
21327 !! wikitext
21328 {{Test}}
21329 {{Test}}
21330 !! html
21331 <p>This is a test template
21332 This is a test template
21333 </p>
21334 !! end
21335
21336
21337 !! article
21338 MediaWiki:Fake
21339 !! text
21340 ==header==
21341 !! endarticle
21342
21343 !! test
21344 Inclusion of !userCanEdit() content
21345 !! wikitext
21346 {{MediaWiki:Fake}}
21347 !! html
21348 <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>
21349
21350 !! end
21351
21352
21353 !! test
21354 Out-of-order TOC heading levels
21355 !! wikitext
21356 ==2==
21357 ======6======
21358 ===3===
21359 =1=
21360 =====5=====
21361 ==2==
21362 !! html
21363 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
21364 <ul>
21365 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
21366 <ul>
21367 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
21368 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
21369 </ul>
21370 </li>
21371 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
21372 <ul>
21373 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
21374 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
21375 </ul>
21376 </li>
21377 </ul>
21378 </div>
21379
21380 <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>
21381 <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>
21382 <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>
21383 <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>
21384 <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>
21385 <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>
21386
21387 !! end
21388
21389
21390 !! test
21391 ISBN with a dummy number
21392 !! wikitext
21393 ISBN ---
21394 !! html
21395 <p>ISBN ---
21396 </p>
21397 !! end
21398
21399
21400 !! test
21401 ISBN with space-delimited number
21402 !! wikitext
21403 ISBN 92 9017 032 8
21404 !! html/php
21405 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
21406 </p>
21407 !! html/parsoid
21408 <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>
21409 !! end
21410
21411
21412 !! test
21413 ISBN with multiple spaces, no number
21414 !! wikitext
21415 ISBN foo
21416 !! html
21417 <p>ISBN foo
21418 </p>
21419 !! end
21420
21421
21422 !! test
21423 ISBN length
21424 !! wikitext
21425 ISBN 123456789
21426
21427 ISBN 1234567890
21428
21429 ISBN 12345678901
21430 !! html/php
21431 <p>ISBN 123456789
21432 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21433 </p><p>ISBN 12345678901
21434 </p>
21435 !! html/parsoid
21436 <p>ISBN 123456789</p>
21437
21438 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21439
21440 <p>ISBN 12345678901</p>
21441 !! end
21442
21443
21444 !! test
21445 ISBN with trailing year (T9110)
21446 !! wikitext
21447 ISBN 1-234-56789-0 - 2006
21448
21449 ISBN 1 234 56789 0 - 2006
21450 !! html/php
21451 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
21452 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
21453 </p>
21454 !! html/parsoid
21455 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
21456
21457 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
21458 !! end
21459
21460
21461 !! test
21462 anchorencode
21463 !! config
21464 wgFragmentMode=[ 'html5', 'legacy' ]
21465 !! wikitext
21466 {{anchorencode:foo bar©#%n}}
21467 !! html/php
21468 <p>foo_bar©#%n
21469 </p>
21470 !! html/parsoid
21471 <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>
21472 !! end
21473
21474 !! test
21475 anchorencode (legacy)
21476 !! config
21477 wgFragmentMode=[ 'legacy' ]
21478 !! wikitext
21479 {{anchorencode:foo bar©#%n}}
21480 !! html/php
21481 <p>foo_bar.C2.A9.23.25n
21482 </p>
21483 !! end
21484
21485 !! test
21486 anchorencode trims spaces
21487 !! config
21488 wgFragmentMode=[ 'html5', 'legacy' ]
21489 !! wikitext
21490 {{anchorencode: __pretty__please__}}
21491 !! html/php
21492 <p>pretty_please
21493 </p>
21494 !! html/parsoid
21495 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
21496 !! end
21497
21498 !! test
21499 anchorencode deals with links
21500 !! config
21501 wgFragmentMode=[ 'html5', 'legacy' ]
21502 !! wikitext
21503 {{anchorencode: [[hello|world]] [[hi]]}}
21504 !! html/php
21505 <p>world_hi
21506 </p>
21507 !! html/parsoid
21508 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
21509 !! end
21510
21511 !! test
21512 anchorencode deals with templates
21513 !! config
21514 wgFragmentMode=[ 'html5', 'legacy' ]
21515 !! wikitext
21516 {{anchorencode: {{Foo}} x}}
21517 !! html/php
21518 <p>FOO_x
21519 </p>
21520 !! html/parsoid
21521 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
21522 !! end
21523
21524 !! test
21525 anchorencode encodes like the TOC generator: (T20431)
21526 !! config
21527 wgFragmentMode=[ 'html5', 'legacy' ]
21528 !! wikitext
21529 === _ +:.3A%3A _ &&amp;]] x ===
21530 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
21531 __NOEDITSECTION__
21532 !! html/php
21533 <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>
21534 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
21535 </p>
21536 !! html/parsoid
21537 <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>
21538 <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>
21539 <meta property="mw:PageProp/noeditsection"/>
21540 !! end
21541
21542 !! test
21543 anchorencode encodes like the TOC generator: (T20431) (legacy)
21544 !! config
21545 wgFragmentMode=[ 'legacy' ]
21546 !! wikitext
21547 === _ +:.3A%3A&&amp;]] ===
21548 {{anchorencode: _ +:.3A%3A&&amp;]] }}
21549 __NOEDITSECTION__
21550 !! html/php
21551 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
21552 <p>.2B:.3A.253A.26.26.5D.5D
21553 </p>
21554 !! end
21555
21556 !! test
21557 T8200: blockquotes and paragraph formatting
21558 !! wikitext
21559 <blockquote>
21560 foo
21561 </blockquote>
21562
21563 bar
21564
21565 baz
21566 !! html
21567 <blockquote>
21568 <p>foo
21569 </p>
21570 </blockquote>
21571 <p>bar
21572 </p>
21573 <pre>baz
21574 </pre>
21575 !! end
21576
21577 !! test
21578 T10293: Use of center tag ruins paragraph formatting
21579 !! wikitext
21580 <center>
21581 foo
21582 </center>
21583
21584 bar
21585
21586 baz
21587 !! html
21588 <center>
21589 <p>foo
21590 </p>
21591 </center>
21592 <p>bar
21593 </p>
21594 <pre>baz
21595 </pre>
21596 !! end
21597
21598 !!test
21599 Parsing of overlapping (improperly nested) inline html tags
21600 !! wikitext
21601 <span><s>x</span></s>
21602 !! html/php
21603 <p><span><s>x&lt;/span&gt;</s></span>
21604 </p>
21605 !! html/parsoid
21606 <p><span><s>x</s></span>
21607 </p>
21608 !!end
21609
21610 ###
21611 ### Language variants related tests
21612 ###
21613
21614 # Parsoid does not mark self-links.
21615 # Parsoid does not convert links; PHP will do any necessary redirects.
21616
21617 !! test
21618 Self-link in language variants
21619 !! options
21620 title=[[Dunav]] language=sr
21621 !! wikitext
21622 Both [[Dunav]] and [[Дунав]] are names for this river.
21623 !! html/php
21624 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
21625 </p>
21626 !! html/parsoid
21627 <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>
21628 !! end
21629
21630 !! article
21631 Дуна
21632 !! text
21633 content
21634 !! endarticle
21635
21636 !! test
21637 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
21638 !! options
21639 title=[[Duna]] language=sr
21640 !! wikitext
21641 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
21642 !! html/php
21643 <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.
21644 </p>
21645 !! html/parsoid
21646 <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>
21647 !! end
21648
21649 !! test
21650 Link to a section of a variant of this title shouldn't be parsed as self-link
21651 !! options
21652 title=[[Duna]] language=sr
21653 !! wikitext
21654 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
21655 !! html/php
21656 <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.
21657 </p>
21658 !! html/parsoid
21659 <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>
21660 !! end
21661
21662 !! test
21663 Link to pages in language variants
21664 !! options
21665 language=sr
21666 !! wikitext
21667 Main Page can be written as [[Маин Паге]]
21668 !! html/php
21669 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
21670 </p>
21671 !! html/parsoid
21672 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
21673 !! end
21674
21675
21676 !! test
21677 Multiple links to pages in language variants
21678 !! options
21679 language=sr
21680 !! wikitext
21681 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
21682 !! html/php
21683 <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>.
21684 </p>
21685 !! html/parsoid
21686 <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>
21687 !! end
21688
21689
21690 !! test
21691 Simple template in language variants
21692 !! options
21693 language=sr
21694 !! wikitext
21695 {{тест}}
21696 !! html/php
21697 <p>This is a test template
21698 </p>
21699 !! end
21700
21701
21702 !! test
21703 Template with explicit namespace in language variants
21704 !! options
21705 language=sr
21706 !! wikitext
21707 {{Template:тест}}
21708 !! html/php
21709 <p>This is a test template
21710 </p>
21711 !! end
21712
21713
21714 !! test
21715 Basic test for template parameter in language variants
21716 !! options
21717 language=sr
21718 !! wikitext
21719 {{парамтест|param=foo}}
21720 !! html/php
21721 <p>This is a test template with parameter foo
21722 </p>
21723 !! end
21724
21725 !! test
21726 Simple category in language variants
21727 !! options
21728 language=sr cat
21729 !! wikitext
21730 [[Category:МедиаWики Усер'с Гуиде]]
21731 !! html/php
21732 cat=МедиаWики_Усер'с_Гуиде sort=
21733 !! html/parsoid
21734 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
21735 !! end
21736
21737 !! article
21738 Category:分类
21739 !! text
21740 blah
21741 !! endarticle
21742
21743 !! article
21744 Category:分類
21745 !! text
21746 blah
21747 !! endarticle
21748
21749 ## We used to, but no longer wt2wt this test since the default serializer
21750 ## will normalize all categories to serialize on their own line.
21751 ## This wikitext usage is going to be fairly uncommon in production and
21752 ## selser will take care of preserving formatting in those scenarios.
21753 !! test
21754 Don't convert blue categorylinks to another variant (T35210)
21755 !! options
21756 cat
21757 language=zh
21758 parsoid=wt2html
21759 !! wikitext
21760 [[A]][[Category:分类]]
21761 !! html/php
21762 cat=分类 sort=
21763 !! html/parsoid
21764 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
21765 <link rel="mw:PageProp/Category" href="./Category:分类"/>
21766 !! end
21767
21768 !! test
21769 Stripping -{}- tags (language variants)
21770 !! options
21771 language=sr
21772 !! wikitext
21773 Latin proverb: -{Ne nuntium necare}-
21774 !! html/php
21775 <p>Latin proverb: Ne nuntium necare
21776 </p>
21777 !! html/parsoid
21778 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21779 !! end
21780
21781
21782 !! test
21783 Prevent conversion with -{}- tags (language variants)
21784 !! options
21785 language=sr variant=sr-ec
21786 !! wikitext
21787 Latinski: -{Ne nuntium necare}-
21788 !! html/php
21789 <p>Латински: Ne nuntium necare
21790 </p>
21791 !! html/parsoid
21792 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21793 !! end
21794
21795
21796 !! test
21797 Prevent conversion of text with -{}- tags (language variants)
21798 !! options
21799 language=sr variant=sr-ec
21800 !! wikitext
21801 Latinski: -{Ne nuntium necare}-
21802 !! html/php
21803 <p>Латински: Ne nuntium necare
21804 </p>
21805 !! html/parsoid
21806 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21807 !! end
21808
21809
21810 !! test
21811 Prevent conversion of links with -{}- tags (language variants)
21812 !! options
21813 language=sr variant=sr-ec
21814 !! wikitext
21815 -{[[Main Page]]}-
21816 !! html/php
21817 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21818 </p>
21819 !! html/parsoid
21820 <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>
21821 !! end
21822
21823
21824 !! test
21825 -{}- tags within headlines (within html for parserConvert())
21826 !! config
21827 wgFragmentMode=[ 'html5', 'legacy' ]
21828 !! options
21829 language=sr variant=sr-ec
21830 !! wikitext
21831 == -{Naslov}- ==
21832
21833 Note that even an unprotected headline ID is not affected by language
21834 conversion:
21835
21836 == Latinski ==
21837 !! html/php
21838 <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>
21839 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
21840 цонверсион:
21841 </p>
21842 <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>
21843
21844 !! html/parsoid
21845 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span> <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span> </h2>
21846
21847 <p>Note that even an unprotected headline ID is not affected by language
21848 conversion:</p>
21849
21850 <h2 id="Latinski">Latinski</h2>
21851 !! end
21852
21853 !! test
21854 Explicit definition of language variant alternatives
21855 !! options
21856 language=zh variant=zh-tw
21857 !! wikitext
21858 -{zh:China;zh-tw:Taiwan}-, not China
21859 !! html/php
21860 <p>Taiwan, not China
21861 </p>
21862 !! html/parsoid
21863 <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>
21864 !! end
21865
21866 !! test
21867 Filter syntax for language variants
21868 !! options
21869 language=zh variant=zh-tw
21870 !! wikitext
21871 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
21872 !! html/php
21873 <p>fooblog, WEBJOURNAL, WEBLOGquux
21874 </p>
21875 !! html/parsoid
21876 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
21877 !! end
21878
21879 # Note that Parsoid post-processing for language variants needs to
21880 # update the `title` attribute here, based on the mw:ExpandedAttrs property
21881 !! test
21882 Conversion around HTML tags
21883 !! options
21884 language=sr variant=sr-ec
21885 !! wikitext
21886 -{H|span=>sr-ec:script;title=>sr-ec:src}-
21887 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
21888 !! html/php
21889 <p>
21890 <span title="ЛаCтин">ски</span>
21891 </p>
21892 !! html/parsoid
21893 <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"}]}'/>
21894 <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>
21895 !! end
21896
21897 !! test
21898 Explicit session-wise two-way language variant mapping (A flag and - flag)
21899 !! options
21900 language=zh variant=zh-tw
21901 !! wikitext
21902 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
21903
21904 Taiwan is not China.
21905
21906 But -{A|zh:China; zh-tw:Taiwan}- is China,
21907
21908 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
21909
21910 and -{China}- is China.
21911 !! html/php
21912 <p>This is Taiwan, but we'll forget that now.
21913 </p><p>Taiwan is not China.
21914 </p><p>But Taiwan is Taiwan,
21915 </p><p>(This should be stripped!)
21916 </p><p>and China is China.
21917 </p>
21918 !! html/parsoid
21919 <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>
21920 <p>Taiwan is not China.</p>
21921 <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>
21922 <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>
21923 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
21924 !! end
21925
21926 !! test
21927 Explicit session-wise one-way language variant mapping (A flag and - flag)
21928 !! options
21929 language=zh variant=zh-tw
21930 !! wikitext
21931 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
21932
21933 COUNTRY is China or Taiwan.
21934
21935 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
21936
21937 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
21938
21939 and -{COUNTRY}- is COUNTRY.
21940 !! html/php
21941 <p>This is Taiwan, but we'll forget that now.
21942 </p><p>COUNTRY is China or Taiwan.
21943 </p><p>But Taiwan is Taiwan,
21944 </p><p>(This should be stripped!)
21945 </p><p>and COUNTRY is COUNTRY.
21946 </p>
21947 !! html/parsoid
21948 <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>
21949 <p>COUNTRY is China or Taiwan.</p>
21950 <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>
21951 <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>
21952 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
21953 !! end
21954
21955 !! test
21956 Explicit session-wise two-way language variant mapping (H flag for hide)
21957 !! options
21958 language=zh variant=zh-tw
21959 !! wikitext
21960 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
21961
21962 Taiwan is China.
21963 !! html/php
21964 <p>(This should be stripped!)
21965 </p><p>Taiwan is Taiwan.
21966 </p>
21967 !! html/parsoid
21968 <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>
21969 <p>Taiwan is China.</p>
21970 !! end
21971
21972 !! test
21973 Explicit session-wise one-way language variant mapping (H flag for hide)
21974 !! options
21975 language=zh variant=zh-tw
21976 !! wikitext
21977 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
21978
21979 COUNTRY is Taiwan or China.
21980 !! html/php
21981 <p>(This should be stripped!)
21982 </p><p>Taiwan is Taiwan or China.
21983 </p>
21984 !! html/parsoid
21985 <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>
21986 <p>COUNTRY is Taiwan or China.</p>
21987 !! end
21988
21989 ## Note that parsoid test runner does not support 'showtitle' option.
21990 !! test
21991 Adding explicit conversion rule for title (T flag)
21992 !! options
21993 language=zh variant=zh-tw showtitle
21994 !! wikitext
21995 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
21996
21997 Taiwan is China.
21998 !! html/php
21999 Taiwan
22000 <p>Should be stripped!
22001 </p><p>Taiwan is China.
22002 </p>
22003 !! html/parsoid
22004 <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>
22005 <p>Taiwan is China.</p>
22006 !! end
22007
22008 !! test
22009 Code coverage: T combined with H flag
22010 !! options
22011 language=zh variant=zh-tw showtitle
22012 !! wikitext
22013 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
22014
22015 Taiwan is China.
22016 !! html/php
22017 Taiwan
22018 <p>Should be stripped!
22019 </p><p>Taiwan is Taiwan.
22020 </p>
22021 !! html/parsoid
22022 <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>
22023 <p>Taiwan is China.</p>
22024 !! end
22025
22026 !! test
22027 Code coverage: T with no variants
22028 !! options
22029 language=zh variant=zh-tw showtitle
22030 !! wikitext
22031 -{H|zh:China; zh-tw:Taiwan}-
22032 Taiwan is China.-{T|Taiwan is China}-
22033 !! html/php
22034 Taiwan is China
22035 <p>
22036 Taiwan is Taiwan.
22037 </p>
22038 !! html/parsoid
22039 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22040 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
22041 !! end
22042
22043 !! test
22044 Code coverage: rules with no variants
22045 !! options
22046 language=zh variant=zh-tw
22047 !! wikitext
22048 -{H|zh:China; zh-tw:Taiwan}-
22049 Taiwan is China.
22050 -{H|China}-
22051 Taiwan is China.
22052 !! html/php
22053 <p>
22054 Taiwan is Taiwan.
22055
22056 Taiwan is China.
22057 </p>
22058 !! html/parsoid
22059 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22060 Taiwan is China.
22061 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
22062 Taiwan is China.</p>
22063 !! end
22064
22065
22066 !! test
22067 Code coverage: D flag for conversion rule
22068 !! options
22069 language=zh variant=zh-tw
22070 !! wikitext
22071 -{D|zh-cn:XA; zh-tw:YA}-
22072 -{A;D|zh-cn:XB; zh-tw:YB}-
22073 -{D;H|zh-cn:XC; zh-tw:YC}-
22074
22075 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
22076
22077 -{D|0=>zh-tw:1}-
22078 -{A;D|2=>zh-tw:3}-
22079 -{D;H|4=>zh-tw:5}-
22080
22081 XA XB XC YA YB YC FOO BAR BAT 012345
22082 !! html/php
22083 <p>大陆:XA;台灣:YA;
22084
22085 大陆:XC;台灣:YC;
22086 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
22087 </p><p>0⇒台灣:1;
22088
22089 4⇒台灣:5;
22090 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
22091 </p>
22092 !! html/parsoid
22093 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
22094 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
22095 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
22096 <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>
22097 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
22098 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
22099 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
22100 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
22101 !! end
22102
22103 !! test
22104 Code coverage: N flag for conversion rule
22105 !! options
22106 language=zh variant=zh-cn
22107 !! wikitext
22108 -{N|zh-cn}-
22109
22110 -{N|zh-tw}-
22111
22112 -{N|sr-ec}-
22113 !! html/php
22114 <p>大陆
22115 </p><p>台灣
22116 </p><p>српски (ћирилица)‎
22117 </p>
22118 !! html/parsoid
22119 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
22120 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
22121 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
22122 !! end
22123
22124 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
22125 !! test
22126 Code coverage: N flag for conversion rule (wt2html only)
22127 !! options
22128 language=zh variant=zh-cn
22129 parsoid=wt2html,html2html
22130 !! wikitext
22131 -{D;N|en}-
22132 !! html/php
22133 <p>English
22134 </p>
22135 !! html/parsoid
22136 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
22137 !! end
22138
22139 !! test
22140 Testing that changing the language variant here in the tests actually works
22141 !! options
22142 language=zh variant=zh showtitle
22143 !! wikitext
22144 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22145 !! html/php
22146 China
22147 <p>Should be stripped!
22148 </p>
22149 !! html/parsoid
22150 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
22151 !! end
22152
22153 !! test
22154 Recursive conversion of alt and title attrs shouldn't clear converter state
22155 !! options
22156 language=zh variant=zh-cn
22157 showtitle
22158 !! wikitext
22159 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
22160 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
22161 !! html/php
22162 China
22163 <p>
22164 Should be stripped<span title="Exclamation">!</span>
22165 </p>
22166 !! html/parsoid
22167 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
22168 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>
22169 !! end
22170
22171 !! test
22172 T26072: more test on conversion rule for title
22173 !! options
22174 language=zh variant=zh-tw showtitle
22175 !! wikitext
22176 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22177
22178 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
22179 !! html/php
22180 Taiwan
22181 <p>This should be stripped!
22182 </p><p>This won't take interferes with the title rule.
22183 </p>
22184 !! html/parsoid
22185 <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>
22186 <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>
22187 !! end
22188
22189 !! test
22190 Partly disable title conversion if variant == main language code
22191 !! options
22192 language=zh variant=zh title=[[ZH]] showtitle
22193 !! wikitext
22194 -{T|zh-cn:CN;zh-tw:TW}-
22195 !! html/php
22196 ZH
22197 <p>
22198 </p>
22199 !! html/parsoid
22200 <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>
22201 !! end
22202
22203 !! test
22204 Partly disable title conversion if variant == main language code, more
22205 !! options
22206 language=zh variant=zh title=[[ZH]] showtitle
22207 !! wikitext
22208 -{T|TW}-
22209 !! html/php
22210 ZH
22211 <p>
22212 </p>
22213 !! html/parsoid
22214 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
22215 !! end
22216
22217 !! test
22218 Raw output of variant escape tags (R flag)
22219 !! options
22220 language=zh variant=zh-tw
22221 !! wikitext
22222 Raw: -{R|zh:China;zh-tw:Taiwan}-
22223 !! html/php
22224 <p>Raw: zh:China;zh-tw:Taiwan
22225 </p>
22226 !! html/parsoid
22227 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
22228 !! end
22229
22230 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
22231 !! test
22232 Raw output of variant escape tags (R flag) (wt2html only)
22233 !! options
22234 language=zh variant=zh-tw
22235 parsoid=wt2html,html2html
22236 !! wikitext
22237 -{Variant}- -{D|syntax}- -{D;R|options}-
22238 !! html/php
22239 <p>Variant syntax options
22240 </p>
22241 !! html/parsoid
22242 <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>
22243 !! end
22244
22245 !! test
22246 Nested markup inside raw output of variant escape tags (R flag)
22247 !! options
22248 language=zh variant=zh-tw
22249 !! wikitext
22250 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
22251 !! html/php
22252 <p>Nested raw: nested Taiwan nested
22253 </p>
22254 !! html/parsoid
22255 <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>
22256 !! end
22257
22258 !! test
22259 Nested markup and spaces inside raw output of variant escape tags (R flag)
22260 !! options
22261 language=zh variant=zh-tw
22262 !! wikitext
22263 X-{ outer -{ inner }- outer }-X
22264 !! html/php
22265 <p>X outer inner outer X
22266 </p>
22267 !! html/parsoid
22268 <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>
22269 !! end
22270
22271 !! test
22272 Templates inside raw output of variant escape tags (R flag)
22273 !! options
22274 language=zh variant=zh-tw
22275 !! wikitext
22276 Nested raw: -{R|nested {{echo|hi}} templates}-
22277 !! html/php
22278 <p>Nested raw: nested hi templates
22279 </p>
22280 !! html/parsoid
22281 <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>
22282 !! end
22283
22284 !! test
22285 Strings evaluating false shouldn't be ignored by Language converter (T51072)
22286 !! options
22287 language=zh variant=zh-cn
22288 !! input
22289 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
22290 !! html/php
22291 <p>0
22292 </p>
22293 !! html/parsoid
22294 <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>
22295 !! end
22296
22297 !! test
22298 Conversion rules from [numeric-only string] to [something else] (T48634)
22299 !! options
22300 language=zh variant=zh-cn
22301 !! input
22302 -{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
22303 !! html/php
22304 <p>D12345EE12345
22305 </p>
22306 !! html/parsoid
22307 <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>
22308 !! end
22309
22310 !! test
22311 Two-way converter rule entries with an empty value should be ignored (T53551)
22312 !! options
22313 language=zh variant=zh-cn
22314 !! input
22315 -{H|zh-cn:foo;zh-tw:;}-foobar
22316 !! html/php
22317 <p>foobar
22318 </p>
22319 !! html/parsoid
22320 <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>
22321 !! end
22322
22323 !! test
22324 One-way converter rule entries with an empty "from" string should be ignored (T53551)
22325 !! options
22326 language=zh variant=zh-cn
22327 !! input
22328 -{H|=>zh-cn:foo;}-foobar
22329 !! html/php
22330 <p>foobar
22331 </p>
22332 !! html/parsoid
22333 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
22334 !! end
22335
22336 !! test
22337 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
22338 !! options
22339 language=zh variant=zh-cn
22340 !! input
22341 -{H|}-foobar
22342 !! html/php
22343 <p>foobar
22344 </p>
22345 !! html/parsoid
22346 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
22347 !! end
22348
22349 !! test
22350 Nested using of manual convert syntax
22351 !! options
22352 language=zh variant=zh-hk
22353 !! wikitext
22354 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
22355 !! html/php
22356 <p>Nested: Hello Hong Kong!
22357 </p>
22358 !! html/parsoid
22359 <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>
22360 !! end
22361
22362 !! test
22363 HTML markups with conversion syntax in attribs, nested in other conversion blocks
22364 !! options
22365 language=zh variant=zh-cn
22366 !! wikitext
22367 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
22368 !! html/php
22369 <p><span title="X">A</span>
22370 </p>
22371 !! html/parsoid
22372 <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>
22373 !! end
22374
22375 !! test
22376 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
22377 !! options
22378 language=zh variant=zh-cn
22379 !! wikitext
22380 -{<span title="-{X}-">A</span>}-
22381 !! html/php+disabled
22382 <p><span title="X">A</span>
22383 </p>
22384 !! html/parsoid
22385 <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>
22386 !! end
22387
22388 # Parsoid and PHP disagree on how to parse this example: Parsoid
22389 # insists that the content of a language converter element be a valid
22390 # DOM fragment or attribute string
22391 !! test
22392 Language converter markup with block content
22393 !! options
22394 language=zh variant=zh-cn
22395 !! wikitext
22396 <span>a-{b<div>c}-d
22397
22398 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
22399
22400 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
22401 !! html/php+tidy
22402 <span>ab<div>cd
22403 <span>ab<div>cd
22404 <span>ad
22405 </span></div></span></div></span>
22406 !! html/parsoid
22407 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</span></p><div typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"b&lt;div data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[10,16,5,0]}&#39;>c&lt;/div>"}}'></div><p>d</p>
22408
22409 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</span></p><div typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"b&lt;div data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[50,56,5,0]}&#39;>c&lt;/div>"}}'></div><p>d</p>
22410
22411 <p><span data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a<meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"0","l":"zh-cn","t":"x&lt;span data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[82,89,6,0]}&#39;>y&lt;/span>"},{"f":"0","l":"zh-tw","t":"b&lt;div data-parsoid=&#39;{\"stx\":\"html\",\"autoInsertedEnd\":true,\"dsr\":[100,106,5,0]}&#39;>c&lt;/div>"}]}'/>d</span></p>
22412 !! end
22413
22414 !! test
22415 LanguageConverter selser (1)
22416 !! options
22417 language=zh variant=zh-cn
22418 parsoid={
22419 "modes": ["wt2wt", "selser"],
22420 "changes": [
22421 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22422 ]
22423 }
22424 !! wikitext
22425 -{raw}-
22426 !! wikitext/edited
22427 -{edited}-
22428 !! end
22429
22430 !! test
22431 LanguageConverter selser (2)
22432 !! options
22433 language=zh variant=zh-cn
22434 parsoid={
22435 "modes": ["wt2wt", "selser"],
22436 "changes": [
22437 ["span[class='x']", "contents", "text", "-{foo}-"],
22438 ["a", "contents", "text", "-{"],
22439 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
22440 ]
22441 }
22442 !! wikitext
22443 <span class="x">TEXT1</span>
22444 [http://example.com TEXT2]
22445 [[Foo|TEXT3]]
22446 {{echo|TEXT4}}
22447 !! wikitext/edited
22448 <span class="x"><nowiki>-{foo}-</nowiki></span>
22449 [http://example.com -{]
22450 [[Foo|<nowiki>-{</nowiki>]]
22451 {{1x|<nowiki>-{</nowiki>}}
22452 !! end
22453
22454 # Tests LanguageVariantText in ConstrainedText
22455 !! test
22456 LanguageConverter selser (3)
22457 !! options
22458 language=zh variant=zh-cn
22459 parsoid={
22460 "modes": ["wt2wt", "selser"],
22461 "changes": [
22462 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
22463 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22464 ]
22465 }
22466 !! wikitext
22467 {|
22468 |-
22469 |<span>Foo</span>
22470 |}
22471 !! wikitext/edited
22472 {|
22473 |-
22474 |<nowiki/>-{edited}-
22475 |}
22476 !! end
22477
22478 # Tests LanguageVariantText._fromSelSer
22479 !! test
22480 LanguageConverter selser (4)
22481 !! options
22482 language=zh variant=zh-cn
22483 parsoid={
22484 "modes": ["wt2wt", "selser"],
22485 "changes": [
22486 ["td > span.x", "remove"]
22487 ]
22488 }
22489 !! wikitext
22490 {|
22491 |-
22492 |<span class="x">Foo</span>-{Bar}-
22493 ||<span class="x">Foo</span>-{Bar}-
22494 |}
22495 !! wikitext/edited
22496 {|
22497 |-
22498 |<nowiki/>-{Bar}-
22499 ||-{Bar}-
22500 |}
22501 !! end
22502
22503 # Since Parsoid is starting to emit canonical wikitext for links,
22504 # [http://example.com http://example.com] will not RT back to that
22505 # form anymore.
22506 # Parsoid does not language-convert links (it is done in a
22507 # post-processing step)
22508 !! test
22509 Proper conversion of text in external links
22510 !! options
22511 language=sr variant=sr-ec
22512 parsoid=wt2html
22513 !! wikitext
22514 http://www.google.com
22515 gopher://www.google.com
22516 [http://www.google.com http://www.google.com]
22517 [gopher://www.google.com gopher://www.google.com]
22518 [https://www.google.com irc://www.google.com]
22519 [ftp://www.google.com www.google.com/ftp://dir]
22520 [//www.google.com www.google.com]
22521 !! html/php
22522 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22523 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22524 <a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22525 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22526 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
22527 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
22528 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
22529 </p>
22530 !! html/parsoid
22531 <p><a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
22532 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
22533 <a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
22534 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
22535 <a rel="mw:ExtLink" href="https://www.google.com">irc://www.google.com</a>
22536 <a rel="mw:ExtLink" href="ftp://www.google.com">www.google.com/ftp://dir</a>
22537 <a rel="mw:ExtLink" href="//www.google.com">www.google.com</a></p>
22538 !! end
22539
22540 !! test
22541 Do not convert roman numbers to language variants
22542 !! options
22543 language=sr variant=sr-ec
22544 !! wikitext
22545 Fridrih IV je car.
22546 !! html/php
22547 <p>Фридрих IV је цар.
22548 </p>
22549 !! html/parsoid
22550 <p>Fridrih IV je car.</p>
22551 !! end
22552
22553 !! test
22554 Unclosed language converter markup "-{"
22555 !! options
22556 language=sr
22557 !! wikitext
22558 -{T|hello
22559 !! html
22560 <p>-{T|hello
22561 </p>
22562 !! end
22563
22564 !! test
22565 Don't convert raw rule "-{R|=&gt;}-" to "=>"
22566 !! options
22567 language=sr
22568 !! wikitext
22569 -{R|=&gt;}-
22570 !! html/php
22571 <p>=&gt;
22572 </p>
22573 !! html/parsoid
22574 <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>
22575 !!end
22576
22577 !! test
22578 Don't break link parsing if language converter markup is in the caption.
22579 !! options
22580 language=sr variant=sr-ec
22581 !! wikitext
22582 [[Main Page|-{R|main page}-]]
22583 !! html/php
22584 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
22585 </p>
22586 !! html/parsoid
22587 <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>
22588 !! end
22589
22590 !! test
22591 T146304: Don't break template parsing if language converter markup is in the parameter.
22592 !! options
22593 language=sr variant=sr-ec
22594 !! wikitext
22595 {{echo|-{R|foo}-}}
22596 !! html/php
22597 <p>foo
22598 </p>
22599 !! html/parsoid
22600 <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>
22601 !! end
22602
22603 !! test
22604 T146305: Don't break image parsing if language converter markup is in the caption.
22605 !! options
22606 language=sr
22607 !! wikitext
22608 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
22609 !! html/php
22610 <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>
22611
22612 !! html/parsoid
22613 <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>
22614 !! end
22615
22616 !! test
22617 T146305: Don't break image parsing if nested language converter markup is in the caption.
22618 !! options
22619 language=zh variant=zh-cn
22620 !! wikitext
22621 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
22622 !! html/php
22623 <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>
22624
22625 !! html/parsoid
22626 <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>
22627 !! end
22628
22629 # XXX html2wt disabled because rich markup in alt is not preserved.
22630 !! test
22631 Don't break gallery if language converter markup is inside.
22632 !! options
22633 language=zh
22634 !! wikitext
22635 <gallery>
22636 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
22637 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
22638 </gallery>
22639 !! html/php
22640 <ul class="gallery mw-gallery-traditional">
22641 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22642 <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>
22643 <div class="gallerytext">
22644 <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>
22645 </p>
22646 </div>
22647 </div></li>
22648 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22649 <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>
22650 <div class="gallerytext">
22651 <p>This is a test template
22652 </p>
22653 </div>
22654 </div></li>
22655 </ul>
22656
22657 !! html/parsoid
22658 <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"}}'>
22659 <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>
22660 <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>
22661 </ul>
22662 !! end
22663
22664 !! test
22665 T153135: Don't break list handling if language converter markup is in the item.
22666 !! options
22667 language=zh variant=zh-cn
22668 !! wikitext
22669 ;-{zh-cn:AAA;zh-tw:BBB}-
22670 ;-{R|foo:bar}-
22671 !! html/php
22672 <dl><dt>AAA</dt>
22673 <dt>foo:bar</dt></dl>
22674
22675 !! html/parsoid
22676 <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>
22677 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
22678 </dl>
22679 !! end
22680
22681 // Note that parsoid does not protect colons unless language converter
22682 // markup is properly nested, because it is a backtracking parser.
22683 !! test
22684 T153135: Unclosed markup in definition list (code coverage)
22685 !! options
22686 language=zh variant=zh-cn
22687 !! wikitext
22688 ;<b>foo:bar
22689 ;-{zh-cn:AAA
22690 !! html/php+tidy
22691 <dl><dt><b>foo:bar</b></dt><b>
22692 <dt>-{zh-cn:AAA</dt></b></dl><p><b>
22693 </b></p>
22694 !! html/parsoid
22695 <dl><dt data-parsoid='{"dsr":[0,11,1,0]}'><b data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo:bar</b></dt><b data-parsoid='{"stx":"html","autoInsertedEnd":true,"autoInsertedStart":true}'>
22696 <dt data-parsoid='{"dsr":[12,20,1,0]}'>-{zh-cn</dt>
22697 <dd data-parsoid='{"stx":"row","dsr":[20,24,1,0]}'>AAA</dd>
22698 </b></dl>
22699 !! end
22700
22701 !! test
22702 T153135: Nested language converter markup in definition list (code coverage)
22703 !! options
22704 language=zh variant=zh-cn
22705 !! wikitext
22706 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
22707 !! html/php
22708 <dl><dt>AAA foo:bar bat:baz</dt>
22709 <dd>def</dd></dl>
22710
22711 !! html/parsoid
22712 <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>
22713 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
22714 </dl>
22715 !! end
22716
22717 # html2wt mode disabled due to <nowiki> insertion.
22718 !! test
22719 T153140: Don't break table handling if language converter markup is in the cell.
22720 !! options
22721 language=sr variant=sr-ec
22722 parsoid=wt2html,wt2wt,html2html
22723 !! wikitext
22724 {|
22725 |-
22726 | -{R|B}-
22727 |}
22728 !! html/php
22729 <table>
22730
22731 <tr>
22732 <td> B
22733 </td></tr></table>
22734
22735 !! html/parsoid
22736 <table>
22737 <tbody>
22738 <tr>
22739 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
22740 </tr>
22741 </tbody>
22742 </table>
22743 !! end
22744
22745 !! test
22746 Language converter tricky html2wt cases (1)
22747 !! options
22748 language=sr
22749 parsoid=html2wt,wt2wt
22750 !! html/parsoid
22751 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
22752 !! wikitext
22753 -{<nowiki>}-</nowiki>}-
22754 !! html/php
22755 <p>&#125;-
22756 </p>
22757 !! end
22758
22759 !! test
22760 Language converter tricky html2wt cases (2)
22761 !! options
22762 language=sr
22763 parsoid=html2wt,wt2wt
22764 !! html/parsoid
22765 <p>-{foo}-</p>
22766 !! wikitext
22767 <nowiki>-{foo}-</nowiki>
22768 !! html/php
22769 <p>-&#123;foo&#125;-
22770 </p>
22771 !! end
22772
22773 !! test
22774 Language converter tricky html2wt cases (3)
22775 !! options
22776 language=sr
22777 parsoid=html2wt,wt2wt
22778 !! html/parsoid
22779 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
22780 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
22781 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
22782 !! wikitext
22783 -{R||}-
22784
22785 -{R|R|raw}-
22786
22787 -{<nowiki>-{foo}-</nowiki>}-
22788 !! html/php
22789 <p>|
22790 </p><p>R|raw
22791 </p><p>-&#123;foo&#125;-
22792 </p>
22793 !! end
22794
22795 !! test
22796 Language converter tricky html2wt cases (4)
22797 !! options
22798 language=sr
22799 parsoid=html2wt,wt2wt
22800 !! html/parsoid
22801 <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>
22802 !! wikitext
22803 -{R|{{echo|hey}}}-
22804 !! html/php
22805 <p>hey
22806 </p>
22807 !! end
22808
22809 # Note that the <nowiki> escaping added by parsoid for source text,
22810 # destination text, and language names only works on the PHP side
22811 # for *destination text*. (HTML entity escaping wouldn't work
22812 # any better.) This is probably a bug, at least for source texts.
22813 # (For language names PHP uses a precise regexp based on the languages
22814 # it currently knows have variants, which is fragile since this set
22815 # can grow/shrink over time.)
22816 !! test
22817 Language converter tricky html2wt cases (5)
22818 !! options
22819 language=zh variant=zh-cn
22820 !! html/parsoid
22821 <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>
22822 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
22823 <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>
22824 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
22825 <p>a:b=>c xyz</p>
22826 !! wikitext
22827 -{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
22828
22829 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
22830
22831 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
22832
22833 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
22834
22835 a:b=>c xyz
22836 !! html/php+disabled
22837 <p>foobat;xyz=&gt;zh-cn:abc
22838 </p><p>A
22839 </p><p>0;zh-tw:bar
22840 </p><p>abc
22841 </p><p>a:b=&gt;c 0;zh-tw:bar
22842 </p>
22843 !! end
22844
22845 !! test
22846 T179579: Nowiki and lc interaction
22847 !! options
22848 parsoid=wt2html
22849 language=sr
22850 !! wikitext
22851 -{</nowiki>123}-
22852
22853 -{123<nowiki>|</nowiki>456}-
22854 !! html/parsoid
22855 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
22856
22857 <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>
22858 !! end
22859
22860 !! test
22861 T2529: Uncovered bullet
22862 !! wikitext
22863 * Foo {{bullet}}
22864 !! html
22865 <ul><li> Foo </li>
22866 <li> Bar</li></ul>
22867
22868 !! end
22869
22870 !! test
22871 T2529: Uncovered bullet in a deeply nested list
22872 !! wikitext
22873 ******* Foo {{bullet}}
22874 !! html
22875 <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>
22876 <li> Bar</li></ul>
22877
22878 !! end
22879
22880 !! test
22881 T2529: Uncovered table already at line-start
22882 !! wikitext
22883 x
22884
22885 {{table}}
22886 y
22887 !! html
22888 <p>x
22889 </p>
22890 <table>
22891 <tr>
22892 <td> 1 </td>
22893 <td> 2
22894 </td></tr>
22895 <tr>
22896 <td> 3 </td>
22897 <td> 4
22898 </td></tr></table>
22899 <p>y
22900 </p>
22901 !! end
22902
22903 !! test
22904 T2529: Uncovered bullet in parser function result
22905 !! wikitext
22906 * Foo {{lc:{{bullet}} }}
22907 !! html
22908 <ul><li> Foo </li>
22909 <li> bar</li></ul>
22910
22911 !! end
22912
22913 !! test
22914 T7678: Double-parsed template argument
22915 !! wikitext
22916 {{lc:{{{1}}}|hello}}
22917 !! html
22918 <p>{{{1}}}
22919 </p>
22920 !! end
22921
22922 !! test
22923 T7678: Double-parsed template invocation
22924 !! wikitext
22925 {{lc:{{paramtest {{!}} param = hello }} }}
22926 !! html
22927 <p>{{paramtest | param = hello }}
22928 </p>
22929 !! end
22930
22931 !! test
22932 Case insensitivity of parser functions for non-ASCII characters (T10143)
22933 !! options
22934 language=cs
22935 title=[[Main Page]]
22936 !! wikitext
22937 {{PRVNÍVELKÉ:ěščř}}
22938 {{prvnívelké:ěščř}}
22939 {{PRVNÍMALÉ:ěščř}}
22940 {{prvnímalé:ěščř}}
22941 {{MALÁ:ěščř}}
22942 {{malá:ěščř}}
22943 {{VELKÁ:ěščř}}
22944 {{velká:ěščř}}
22945 !! html
22946 <p>Ěščř
22947 Ěščř
22948 ěščř
22949 ěščř
22950 ěščř
22951 ěščř
22952 ĚŠČŘ
22953 ĚŠČŘ
22954 </p>
22955 !! end
22956
22957 !! test
22958 Morwen/13: Unclosed link followed by heading
22959 !! wikitext
22960 [[link
22961 ==heading==
22962 !! html
22963 <p>[[link
22964 </p>
22965 <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>
22966
22967 !! end
22968
22969 !! test
22970 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
22971 !! wikitext
22972 {{foo|
22973 =heading=
22974 !! html
22975 <p>{{foo|
22976 </p>
22977 <h1><span class="mw-headline" id="heading">heading</span></h1>
22978
22979 !! end
22980
22981 !! test
22982 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
22983 !! wikitext
22984 {{foo|
22985 ==heading==
22986 !! html
22987 <p>{{foo|
22988 </p>
22989 <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>
22990
22991 !! end
22992
22993 !! test
22994 Tildes in comments
22995 !! options
22996 pst
22997 !! wikitext
22998 <!-- ~~~~ -->
22999 !! html/php
23000 <!-- ~~~~ -->
23001 !! end
23002
23003 !! test
23004 Paragraphs inside divs (no extra line breaks)
23005 !! wikitext
23006 <div>Line one
23007
23008 Line two</div>
23009 !! html
23010 <div>Line one
23011 Line two</div>
23012
23013 !! end
23014
23015 !! test
23016 Paragraphs inside divs (extra line break on open)
23017 !! wikitext
23018 <div>
23019 Line one
23020
23021 Line two</div>
23022 !! html
23023 <div>
23024 <p>Line one
23025 </p>
23026 Line two</div>
23027
23028 !! end
23029
23030 !! test
23031 Paragraphs inside divs (extra line break on close)
23032 !! wikitext
23033 <div>Line one
23034
23035 Line two
23036 </div>
23037 !! html
23038 <div>Line one
23039 <p>Line two
23040 </p>
23041 </div>
23042
23043 !! end
23044
23045 !! test
23046 Paragraphs inside divs (extra line break on open and close)
23047 !! wikitext
23048 <div>
23049 Line one
23050
23051 Line two
23052 </div>
23053 !! html
23054 <div>
23055 <p>Line one
23056 </p><p>Line two
23057 </p>
23058 </div>
23059
23060 !! end
23061
23062 # doBlockLevels screws up this output and Remex cleans up as much as it can.
23063 # Parsoid seems to do a better job here since its p-wrapper is probably smarter.
23064 !! test
23065 Nesting tags, paragraphs on lines which begin with <div>
23066 !! wikitext
23067 <div></div><strong>A
23068 B</strong>
23069 !! html/php+tidy
23070 <div></div><p><strong>A
23071 </strong></p><strong></strong><p><strong>B</strong>
23072 </p>
23073 !! html/parsoid
23074 <div></div>
23075 <p><strong>A
23076 B</strong>
23077 </p>
23078 !! end
23079
23080 # T8200: <blockquote> should behave like <div> with respect to line breaks
23081 !! test
23082 T8200: paragraphs inside blockquotes (no extra line breaks)
23083 !! wikitext
23084 <blockquote>Line one
23085
23086 Line two</blockquote>
23087 !! html
23088 <blockquote>Line one
23089 Line two</blockquote>
23090
23091 !! html+tidy
23092 <blockquote><p>Line one
23093 Line two</p></blockquote>
23094 !! end
23095
23096 !! test
23097 T8200: paragraphs inside blockquotes (extra line break on open)
23098 !! wikitext
23099 <blockquote>
23100 Line one
23101
23102 Line two</blockquote>
23103 !! html
23104 <blockquote>
23105 <p>Line one
23106 </p>
23107 Line two</blockquote>
23108
23109 !! html+tidy
23110 <blockquote>
23111 <p>Line one
23112 </p><p>
23113 Line two</p></blockquote>
23114 !! end
23115
23116 !! test
23117 T8200: paragraphs inside blockquotes (extra line break on close)
23118 !! wikitext
23119 <blockquote>Line one
23120
23121 Line two
23122 </blockquote>
23123 !! html
23124 <blockquote>Line one
23125 <p>Line two
23126 </p>
23127 </blockquote>
23128
23129 !! html+tidy
23130 <blockquote><p>Line one
23131 </p><p>Line two
23132 </p>
23133 </blockquote>
23134 !! end
23135
23136 !! test
23137 T8200: paragraphs inside blockquotes (extra line break on open and close)
23138 !! wikitext
23139 <blockquote>
23140 Line one
23141
23142 Line two
23143 </blockquote>
23144 !! html
23145 <blockquote>
23146 <p>Line one
23147 </p><p>Line two
23148 </p>
23149 </blockquote>
23150
23151 !! end
23152
23153 # FIXME: Why does/should the blockquote+div combo suppress p-wrapping here?
23154 !! test
23155 Paragraphs inside blockquotes/divs (no extra line breaks)
23156 !! wikitext
23157 <blockquote><div>Line one
23158
23159 Line two</div></blockquote>
23160 !! html
23161 <blockquote><div>Line one
23162 Line two</div></blockquote>
23163
23164 !! end
23165
23166 !! test
23167 Paragraphs inside blockquotes/divs (extra line break on open)
23168 !! wikitext
23169 <blockquote><div>
23170 Line one
23171
23172 Line two</div></blockquote>
23173 !! html
23174 <blockquote><div>
23175 <p>Line one
23176 </p>
23177 Line two</div></blockquote>
23178
23179 !! end
23180
23181 !! test
23182 Paragraphs inside blockquotes/divs (extra line break on close)
23183 !! wikitext
23184 <blockquote><div>Line one
23185
23186 Line two
23187 </div></blockquote>
23188 !! html
23189 <blockquote><div>Line one
23190 <p>Line two
23191 </p>
23192 </div></blockquote>
23193
23194 !! end
23195
23196 !! test
23197 Paragraphs inside blockquotes/divs (extra line break on open and close)
23198 !! wikitext
23199 <blockquote><div>
23200 Line one
23201
23202 Line two
23203 </div></blockquote>
23204 !! html
23205 <blockquote><div>
23206 <p>Line one
23207 </p><p>Line two
23208 </p>
23209 </div></blockquote>
23210
23211 !! end
23212
23213 !! test
23214 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
23215 !! options
23216 wgLinkHolderBatchSize=0
23217 !! wikitext
23218 [[meatball:1]]
23219 [[meatball:2]]
23220 [[meatball:3]]
23221 !! html
23222 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
23223 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
23224 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
23225 </p>
23226 !! end
23227
23228 !! test
23229 Free external link invading image caption
23230 !! wikitext
23231 [[Image:Foobar.jpg|thumb|http://x|hello]]
23232 !! html
23233 <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>
23234
23235 !! end
23236
23237 !! test
23238 T17196: localised external link numbers
23239 !! options
23240 language=fa
23241 !! wikitext
23242 [http://en.wikipedia.org/]
23243 !! html/php
23244 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
23245 </p>
23246 !! html/parsoid
23247 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/"></a></p>
23248 !! end
23249
23250 !! test
23251 Multibyte character in padleft
23252 !! wikitext
23253 {{padleft:-Hello|7|Æ}}
23254 !! html
23255 <p>Æ-Hello
23256 </p>
23257 !! end
23258
23259 !! test
23260 Multibyte character in padright
23261 !! wikitext
23262 {{padright:Hello-|7|Æ}}
23263 !! html
23264 <p>Hello-Æ
23265 </p>
23266 !! end
23267
23268 !!test
23269 formatdate parser function
23270 !! wikitext
23271 {{#formatdate:2009-03-24}}
23272 !! html
23273 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
23274 </p>
23275 !! end
23276
23277 !!test
23278 formatdate parser function, with default format
23279 !! wikitext
23280 {{#formatdate:2009-03-24|mdy}}
23281 !! html
23282 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
23283 </p>
23284 !! end
23285
23286 !! test
23287 Spacing of numbers in formatted dates
23288 !! wikitext
23289 {{#formatdate:January 15}}
23290 !! html
23291 <p><span class="mw-formatted-date" title="01-15">January 15</span>
23292 </p>
23293 !! end
23294
23295 !! test
23296 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
23297 !! options
23298 language=nl title=[[MediaWiki:Common.css]]
23299 !! wikitext
23300 {{#formatdate:2009-03-24|dmy}}
23301 !! html
23302 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
23303 </p>
23304 !! end
23305
23306 #
23307 #
23308 #
23309
23310 #
23311 # Edit comments
23312 #
23313
23314 !! test
23315 Edit comment with link
23316 !! options
23317 comment
23318 !! wikitext
23319 I like the [[Main Page]] a lot
23320 !! html/php
23321 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
23322 !!end
23323
23324 !! test
23325 Edit comment with link and link text
23326 !! options
23327 comment
23328 !! wikitext
23329 I like the [[Main Page|best pages]] a lot
23330 !! html/php
23331 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23332 !!end
23333
23334 !! test
23335 Edit comment with link and link text with suffix
23336 !! options
23337 comment
23338 !! wikitext
23339 I like the [[Main Page|best page]]s a lot
23340 !! html/php
23341 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23342 !!end
23343
23344 !! test
23345 Edit comment with section link (non-local, eg in history list)
23346 !! options
23347 comment title=[[Main Page]]
23348 !! wikitext
23349 /* External links */ removed bogus entries
23350 !! html/php
23351 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23352 !!end
23353
23354 !! test
23355 Edit comment with section link and text before it (non-local, eg in history list)
23356 !! options
23357 comment title=[[Main Page]]
23358 !! wikitext
23359 pre-comment text /* External links */ removed bogus entries
23360 !! html/php
23361 pre-comment text <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23362 !!end
23363
23364 !! test
23365 Edit comment with section link (local, eg in diff view)
23366 !! options
23367 comment local title=[[Main Page]]
23368 !! wikitext
23369 /* External links */ removed bogus entries
23370 !! html/php
23371 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23372 !!end
23373
23374 !! test
23375 Edit comment with subpage link (T16080)
23376 !! options
23377 comment
23378 subpage
23379 title=[[Subpage test]]
23380 !! wikitext
23381 Poked at a [[/subpage]] here...
23382 !! html/php
23383 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
23384 !!end
23385
23386 !! test
23387 Edit comment with subpage link and link text (T16080)
23388 !! options
23389 comment
23390 subpage
23391 title=[[Subpage test]]
23392 !! wikitext
23393 Poked at a [[/subpage|neat little page]] here...
23394 !! html/php
23395 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
23396 !!end
23397
23398 !! test
23399 Edit comment with bogus subpage link in non-subpage NS (T16080)
23400 !! options
23401 comment
23402 title=[[Subpage test]]
23403 !! wikitext
23404 Poked at a [[/subpage]] here...
23405 !! html/php
23406 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...
23407 !!end
23408
23409 !! test
23410 Edit comment with bare anchor link (local, as on diff)
23411 !! options
23412 comment
23413 local
23414 title=[[Main Page]]
23415 !! wikitext
23416 [[#section]]
23417 !! html/php
23418 <a href="#section">#section</a>
23419 !! end
23420
23421 !! test
23422 Edit comment with bare anchor link (non-local, as on history)
23423 !! options
23424 comment
23425 title=[[Main Page]]
23426 !! wikitext
23427 [[#section]]
23428 !! html/php
23429 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
23430 !! end
23431
23432 !! test
23433 Anchor starting with underscore
23434 !! options
23435 title=[[Foo]]
23436 !! wikitext
23437 [[#_ref|One]]
23438 !! html/php
23439 <p><a href="#_ref">One</a>
23440 </p>
23441 !! html/parsoid
23442 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
23443 !! end
23444
23445 !! test
23446 Id starting with underscore
23447 !! wikitext
23448 <div id="_ref"></div>
23449 !! html/*
23450 <div id="_ref"></div>
23451
23452 !! end
23453
23454 !! test
23455 Edit comment with link with more than one pipe (T99346)
23456 !! options
23457 comment
23458 !! wikitext
23459 [[Main Page|Many|pipes]]
23460 !! html/php
23461 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
23462 !! end
23463
23464 !! test
23465 Complex edit comment with link with more than one pipe (T99346)
23466 !! options
23467 comment
23468 !! wikitext
23469 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
23470 !! html/php
23471 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;
23472 !! end
23473
23474 !! test
23475 Space normalisation on autocomment (T24784)
23476 !! options
23477 comment
23478 title=[[Main Page]]
23479 !! wikitext
23480 /* __hello__world__ */
23481 !! html/php
23482 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
23483 !! end
23484
23485 !! test
23486 percent-encoding and + signs in comments (T28410)
23487 !! options
23488 comment
23489 !! wikitext
23490 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
23491 !! html/php
23492 <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>
23493 !! end
23494
23495 # Parsoid doesn't support this yet: see T75581
23496 # but it *should* omit the 'src' attribute if the image is bad.
23497 # PHP side of tests was disabled in
23498 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
23499 # because of issues in the PHP parserTests infrastructure
23500 # (but the output below is indeed what the PHP side emits)
23501 !! test
23502 Bad images - basic functionality
23503 !! wikitext
23504 [[File:Bad.jpg]]
23505 !! DISABLED/html/php
23506 !! html/parsoid
23507 <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>
23508 !! end
23509
23510 !! test
23511 Bad images - T18039: text after bad image disappears
23512 !! wikitext
23513 Foo bar
23514 [[File:Bad.jpg]]
23515 Bar foo
23516 !! DISABLED/html/php
23517 <p>Foo bar
23518 </p><p>Bar foo
23519 </p>
23520 !! html/parsoid
23521 <p>Foo bar
23522 <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>
23523 Bar foo</p>
23524 !! end
23525
23526 !! test
23527 Verify that displaytitle works (T24501) no displaytitle
23528 !! options
23529 showtitle
23530 !! config
23531 wgAllowDisplayTitle=true
23532 wgRestrictDisplayTitle=false
23533 !! wikitext
23534 this is not the the title
23535 !! html/php
23536 Parser test
23537 <p>this is not the the title
23538 </p>
23539 !! end
23540
23541 !! test
23542 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
23543 !! options
23544 showtitle
23545 title=[[Screen]]
23546 !! config
23547 wgAllowDisplayTitle=true
23548 wgRestrictDisplayTitle=false
23549 !! wikitext
23550 this is not the the title
23551 {{DISPLAYTITLE:whatever}}
23552 !! html/php
23553 whatever
23554 <p>this is not the the title
23555 </p>
23556 !! end
23557
23558 !! test
23559 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
23560 !! options
23561 showtitle
23562 title=[[Screen]]
23563 !! config
23564 wgAllowDisplayTitle=true
23565 wgRestrictDisplayTitle=true
23566 !! wikitext
23567 this is not the the title
23568 {{DISPLAYTITLE:whatever}}
23569 !! html/php
23570 Screen
23571 <p>this is not the the title
23572 </p>
23573 !! end
23574
23575 !! test
23576 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
23577 !! options
23578 showtitle
23579 title=[[Screen]]
23580 !! config
23581 wgAllowDisplayTitle=true
23582 wgRestrictDisplayTitle=true
23583 !! wikitext
23584 this is not the the title
23585 {{DISPLAYTITLE:screen}}
23586 !! html/php
23587 screen
23588 <p>this is not the the title
23589 </p>
23590 !! end
23591
23592 !! test
23593 Verify that displaytitle works (T24501) AllowDisplayTitle=false
23594 !! options
23595 showtitle
23596 title=[[Screen]]
23597 !! config
23598 wgAllowDisplayTitle=false
23599 !! wikitext
23600 this is not the the title
23601 {{DISPLAYTITLE:screen}}
23602 !! html/php
23603 Screen
23604 <p>this is not the the title
23605 <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>
23606 </p>
23607 !! end
23608
23609 !! test
23610 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
23611 !! options
23612 showtitle
23613 title=[[Screen]]
23614 !! config
23615 wgAllowDisplayTitle=false
23616 !! wikitext
23617 this is not the the title
23618 !! html/php
23619 Screen
23620 <p>this is not the the title
23621 </p>
23622 !! end
23623
23624 !! test
23625 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
23626 !! options
23627 showtitle
23628 title=[[Screen]]
23629 !! config
23630 wgAllowDisplayTitle=true
23631 wgRestrictDisplayTitle=true
23632 !! wikitext
23633 this is not the the title
23634 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
23635 !! html/php
23636 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
23637 <p>this is not the the title
23638 </p>
23639 !! end
23640
23641 !! test
23642 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
23643 !! options
23644 showtitle
23645 title=[[Screen]]
23646 !! config
23647 wgAllowDisplayTitle=true
23648 wgRestrictDisplayTitle=true
23649 !! wikitext
23650 this is not the the title
23651 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
23652 !! html/php
23653 <span style="color: red;">s</span>creen
23654 <p>this is not the the title
23655 </p>
23656 !! end
23657
23658 !! test
23659 Page status indicators: Empty name is invalid
23660 !! options
23661 showindicators
23662 !! wikitext
23663 <indicator name=" "></indicator>
23664 <indicator></indicator>
23665 !! html/php
23666 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23667 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23668 </p>
23669 !! end
23670
23671 !! test
23672 Page status indicators: Weird syntaxes that are okay
23673 !! options
23674 showindicators
23675 !! wikitext
23676 <indicator name="empty" />
23677 <indicator name="name"></indicator>
23678 !! html/php
23679 empty=
23680 name=
23681 <p><br />
23682 </p>
23683 !! end
23684
23685 !! test
23686 Page status indicators: Torture test
23687 !! options
23688 showindicators
23689 !! wikitext
23690 <indicator name="01">hello world</indicator>
23691 <indicator name="02">[[Main Page]]</indicator>
23692 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
23693 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
23694 <indicator name="05">* foo
23695 * bar</indicator>
23696 <indicator name="06"><nowiki>foo</nowiki></indicator>
23697 <indicator name="07"> Preformatted</indicator>
23698 <indicator name="08"><div>Broken tag</indicator>
23699 <indicator name="09">{| class=wikitable
23700 | cell
23701 |}</indicator>
23702 <indicator name="10">Two
23703
23704 paragraphs</indicator>
23705 !! html/php
23706 01=hello world
23707 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
23708 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" />
23709 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>
23710 05=<ul><li> foo</li>
23711 <li> bar</li></ul>
23712
23713 06=foo
23714 07=<pre>Preformatted
23715 </pre>
23716 08=<div>Broken tag</div>
23717
23718 09=<table class="wikitable">
23719 <tr>
23720 <td> cell
23721 </td></tr></table>
23722
23723 10=<p>Two
23724 </p><p>paragraphs
23725 </p>
23726 <p><br />
23727 </p><p><br />
23728 </p><p><br />
23729 </p><p><br />
23730 </p><p><br />
23731 </p>
23732 !! end
23733
23734 !! test
23735 preload: check <noinclude> and <includeonly>
23736 !! options
23737 preload
23738 !! wikitext
23739 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
23740 !! html/php
23741 Hello kind world.
23742 !! end
23743
23744 !! test
23745 preload: check <onlyinclude>
23746 !! options
23747 preload
23748 !! wikitext
23749 Goodbye <onlyinclude>Hello world</onlyinclude>
23750 !! html/php
23751 Hello world
23752 !! end
23753
23754 !! test
23755 preload: can pass tags through if we want to
23756 !! options
23757 preload
23758 !! wikitext
23759 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
23760 !! html/php
23761 <includeonly>Hello world</includeonly>
23762 !! end
23763
23764 !! test
23765 preload: check that it doesn't try to do tricks
23766 !! options
23767 preload
23768 !! wikitext
23769 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
23770 !! html/php
23771 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
23772 !! end
23773
23774 !! test
23775 Play a bit with r67090 and T5158
23776 !! wikitext
23777 <div style="width:50% !important">&nbsp;</div>
23778 <div style="width:50%&nbsp;!important">&nbsp;</div>
23779 <div style="width:50%&#160;!important">&nbsp;</div>
23780 <div style="border : solid;">&nbsp;</div>
23781 !! html/php
23782 <div style="width:50% !important">&#160;</div>
23783 <div style="width:50% !important">&#160;</div>
23784 <div style="width:50% !important">&#160;</div>
23785 <div style="border&#160;: solid;">&#160;</div>
23786
23787 !! html/parsoid
23788 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
23789 <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>
23790 <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>
23791 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
23792
23793 !! end
23794
23795 !! test
23796 HTML5 data attributes
23797 !! wikitext
23798 <span data-foo="bar">Baz</span>
23799 <p data-abc-def_hij="">Quuz</p>
23800 !! html/php
23801 <p><span data-foo="bar">Baz</span>
23802 </p>
23803 <p data-abc-def_hij="">Quuz</p>
23804
23805 !! html/parsoid
23806 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
23807 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
23808 !! end
23809
23810 !! test
23811 Strip reserved data attributes
23812 !! wikitext
23813 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
23814 !! html/php
23815 <div data-ok="fred">d</div>
23816
23817 !! html/parsoid
23818 <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>
23819 !! end
23820
23821 !! test
23822 percent-encoding and + signs in internal links (T28410)
23823 !! wikitext
23824 [[User:+%]] [[Page+title%]]
23825 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
23826 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
23827 [[%33%45]] [[%33%45+]]
23828 !! html/php
23829 <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>
23830 <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>
23831 <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>
23832 <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>
23833 </p>
23834 !! html/parsoid
23835 <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>
23836 <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>
23837 <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>
23838 <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>
23839 !! end
23840
23841 !! test
23842 Special characters in embedded file links (T29679)
23843 !! wikitext
23844 [[File:Contains & ampersand.jpg]]
23845 [[File:Does not exist.jpg|Title with & ampersand]]
23846 !! html/php
23847 <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>
23848 <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>
23849 </p>
23850 !! html/parsoid
23851 <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>
23852 <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>
23853 !! end
23854
23855 !! test
23856 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
23857 !! wikitext
23858 Text&apos;s been normalized?
23859 !! html
23860 <p>Text&#39;s been normalized?
23861 </p>
23862 !! end
23863
23864 !! test
23865 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
23866 !! wikitext
23867 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
23868 !! html
23869 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
23870 </p>
23871 !! end
23872
23873 !! test
23874 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
23875 !! wikitext
23876 [http://www.example.org/ ideograms]
23877 !! html
23878 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
23879 </p>
23880 !! end
23881
23882 !! test
23883 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
23884 !! wikitext
23885 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
23886 !! html
23887 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
23888 </p>
23889 !! end
23890
23891 !! article
23892 Mediawiki:loop1
23893 !! text
23894 {{Identical|A}}
23895 !! endarticle
23896
23897 !! article
23898 Mediawiki:loop2
23899 !! text
23900 {{Identical|B}}
23901 !! endarticle
23902
23903 !! article
23904 Template:Identical
23905 !! text
23906 {{int:loop1}}
23907 {{int:loop2}}
23908 !! endarticle
23909
23910 !! test
23911 T33098 Template which includes system messages which includes the template
23912 !! wikitext
23913 {{Identical}}
23914 !! html
23915 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
23916 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
23917 </p>
23918 !! end
23919
23920 !! test
23921 T33490 Turkish: ucfirst 'blah'
23922 !! options
23923 language=tr
23924 !! wikitext
23925 {{ucfirst:blah}}
23926 !! html
23927 <p>Blah
23928 </p>
23929 !! end
23930
23931 !! test
23932 T33490 Turkish: ucfirst 'ix'
23933 !! options
23934 language=tr
23935 !! wikitext
23936 {{ucfirst:ix}}
23937 !! html
23938 <p>İx
23939 </p>
23940 !! end
23941
23942 !! test
23943 T33490 Turkish: lcfirst 'BLAH'
23944 !! options
23945 language=tr
23946 !! wikitext
23947 {{lcfirst:BLAH}}
23948 !! html
23949 <p>bLAH
23950 </p>
23951 !! end
23952
23953 !! test
23954 T33490 Turkish: ucfırst (with a dotless i)
23955 !! options
23956 language=tr
23957 !! wikitext
23958 {{ucfırst:blah}}
23959 !! html
23960 <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>
23961 </p>
23962 !! end
23963
23964 !! test
23965 T33490 ucfırst (with a dotless i) with English language
23966 !! options
23967 language=en
23968 !! wikitext
23969 {{ucfırst:blah}}
23970 !! html
23971 <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>
23972 </p>
23973 !! end
23974
23975 # Note that Parsoid doesn't emit an explicit TOC.
23976 # Note also that the html2wt direction tends to emit an extra newline
23977 # between the __TOC__ magicword and the first heading unless *both*
23978 # the <meta> and the <h2> have a data-parsoid attribute set (even if
23979 # it's "{}").
23980
23981 !! test
23982 T28375: TOC with italics
23983 !! options
23984 title=[[Main Page]]
23985 !! wikitext
23986 __TOC__
23987 == ''Lost'' episodes ==
23988 !! html/php
23989 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
23990 <ul>
23991 <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>
23992 </ul>
23993 </div>
23994
23995 <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>
23996
23997 !! html/parsoid
23998 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23999 <h2 id="Lost_episodes" data-parsoid='{}'> <i>Lost</i> episodes </h2>
24000 !! end
24001
24002 !! test
24003 T28375: TOC with bold
24004 !! options
24005 title=[[Main Page]]
24006 !! wikitext
24007 __TOC__
24008 == '''should be bold''' then normal text ==
24009 !! html/php
24010 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24011 <ul>
24012 <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>
24013 </ul>
24014 </div>
24015
24016 <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>
24017
24018 !! html/parsoid
24019 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24020 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'> <b>should be bold</b> then normal text </h2>
24021 !! end
24022
24023 !! test
24024 T35845: Headings become cursive in TOC when they contain an image
24025 !! options
24026 title=[[Main Page]]
24027 !! wikitext
24028 __TOC__
24029 == Image [[Image:foobar.jpg]] ==
24030 !! html/php
24031 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24032 <ul>
24033 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
24034 </ul>
24035 </div>
24036
24037 <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>
24038
24039 !! html/parsoid
24040 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24041 <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>
24042 !! end
24043
24044 !! test
24045 T35845 (2): Headings become bold in TOC when they contain a blockquote
24046 !! options
24047 title=[[Main Page]]
24048 !! wikitext
24049 __TOC__
24050 == <blockquote>Quote</blockquote> ==
24051 !! html/php
24052 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24053 <ul>
24054 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24055 </ul>
24056 </div>
24057
24058 <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>
24059
24060 !! html/php+tidy
24061 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24062 <ul>
24063 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24064 </ul>
24065 </div>
24066
24067 <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>
24068 !! html/parsoid
24069 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24070 <h2 id="Quote" data-parsoid='{}'> <blockquote>Quote</blockquote> </h2>
24071 !! end
24072
24073 !! test
24074 Unclosed tags in TOC
24075 !! config
24076 wgFragmentMode=[ 'html5', 'legacy' ]
24077 !! options
24078 title=[[Main Page]]
24079 !! wikitext
24080 __TOC__
24081 == Proof: 2 < 3 ==
24082 <small>Hanc marginis exiguitas non caperet.</small>
24083 QED
24084 !! html/php
24085 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24086 <ul>
24087 <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>
24088 </ul>
24089 </div>
24090
24091 <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>
24092 <p><small>Hanc marginis exiguitas non caperet.</small>
24093 QED
24094 </p>
24095 !! html/parsoid
24096 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24097 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span> Proof: 2 &lt; 3 </h2>
24098 <p><small>Hanc marginis exiguitas non caperet.</small>
24099 QED</p>
24100 !! end
24101
24102 !! test
24103 Multiple tags in TOC
24104 !! wikitext
24105 __TOC__
24106 == <i>Foo</i> <b>Bar</b> ==
24107
24108 == <i>Foo</i> <blockquote>Bar</blockquote> ==
24109 !! html/php
24110 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24111 <ul>
24112 <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>
24113 <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>
24114 </ul>
24115 </div>
24116
24117 <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>
24118 <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>
24119
24120 !! html/php+tidy
24121 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24122 <ul>
24123 <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>
24124 <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>
24125 </ul>
24126 </div>
24127
24128 <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>
24129 <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>
24130 !! html/parsoid
24131 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24132 <h2 id="Foo_Bar" data-parsoid='{}'> <i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b> </h2>
24133
24134 <h2 id="Foo_Bar_2" data-parsoid='{}'> <i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote> </h2>
24135 !! end
24136
24137 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
24138 # html5 tag parsing.
24139 !! test
24140 Tags with parameters in TOC
24141 !! options
24142 parsoid=wt2html
24143 !! wikitext
24144 __TOC__
24145 == <sup class="in-h2">Hello</sup> ==
24146
24147 == <sup class="a > b">Evilbye</sup> ==
24148 !! html/php
24149 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24150 <ul>
24151 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
24152 <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>
24153 </ul>
24154 </div>
24155
24156 <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>
24157 <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>
24158
24159 !! html/parsoid
24160 <meta property="mw:PageProp/toc" />
24161 <h2 id="Hello"> <sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup> </h2>
24162
24163 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span> <sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup> </h2>
24164 !! end
24165
24166 !! test
24167 span tags with directionality in TOC
24168 !! wikitext
24169 __TOC__
24170 == <span dir="ltr">C++</span> ==
24171
24172 == <span dir="rtl">זבנג!</span> ==
24173
24174 == <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> ==
24175
24176 == <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> ==
24177
24178 == <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> ==
24179 !! html/php
24180 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24181 <ul>
24182 <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>
24183 <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>
24184 <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>
24185 <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>
24186 <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>
24187 </ul>
24188 </div>
24189
24190 <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>
24191 <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>
24192 <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>
24193 <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>
24194 <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>
24195
24196 !! html/parsoid
24197 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24198 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span> <span dir="ltr">C++</span> </h2>
24199 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span> <span dir="rtl">זבנג!</span> </h2>
24200 <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>
24201 <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>
24202 <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>
24203 !! end
24204
24205 !! test
24206 T74884: bdi element in ToC
24207 !! wikitext
24208 __TOC__
24209 == <bdi>test</bdi> ==
24210 !! html/php
24211 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24212 <ul>
24213 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
24214 </ul>
24215 </div>
24216
24217 <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>
24218
24219 !! html/parsoid
24220 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24221 <h2 id="test" data-parsoid='{}'> <bdi>test</bdi> </h2>
24222 !! end
24223
24224 !! test
24225 T35715: s/strike element in ToC
24226 !! wikitext
24227 __TOC__
24228 == <s>test</s> test <strike>test</strike> ==
24229 !! html/php
24230 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24231 <ul>
24232 <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>
24233 </ul>
24234 </div>
24235
24236 <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>
24237
24238 !! html/parsoid
24239 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24240 <h2 id="test_test_test" data-parsoid='{}'> <s>test</s> test <strike>test</strike> </h2>
24241 !! end
24242
24243 !! test
24244 Empty <p> tag in TOC, removed by Sanitizer (T92892)
24245 !! wikitext
24246 __TOC__
24247 == x ==
24248 !! html/php
24249 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24250 <ul>
24251 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
24252 </ul>
24253 </div>
24254
24255 <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>
24256
24257 !! html/parsoid
24258 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24259 <h2 id="x" data-parsoid='{}'> x </h2>
24260 !! end
24261
24262 !! article
24263 MediaWiki:T34057
24264 !! text
24265 == {{int:headline_sample}} ==
24266 !! endarticle
24267
24268 !! test
24269 T34057: Title needed when expanding <h> nodes.
24270 !! options
24271 title=[[Main Page]]
24272 !! wikitext
24273 {{int:T34057}}
24274 !! html
24275 <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>
24276
24277 !! end
24278
24279 !! test
24280 Strip marker in urlencode
24281 !! wikitext
24282 {{urlencode:x<nowiki/>y}}
24283 {{urlencode:x<nowiki/>y|wiki}}
24284 {{urlencode:x<nowiki/>y|path}}
24285 {{urlencode:x<pre id="one">two</pre>y}}
24286 !! html/php
24287 <p>xy
24288 xy
24289 xy
24290 xy
24291 </p>
24292 !! end
24293
24294 !! test
24295 Strip marker in lc
24296 !! wikitext
24297 {{lc:x<nowiki/>y}}
24298 !! html
24299 <p>xy
24300 </p>
24301 !! end
24302
24303 !! test
24304 Strip marker in uc
24305 !! wikitext
24306 {{uc:x<nowiki/>y}}
24307 !! html
24308 <p>XY
24309 </p>
24310 !! end
24311
24312 !! test
24313 Strip marker in formatNum
24314 !! wikitext
24315 {{formatnum:1<nowiki/>2}}
24316 {{formatnum:1<nowiki/>2|R}}
24317 !! html
24318 <p>12
24319 12
24320 </p>
24321 !! end
24322
24323 !! test
24324 Check noCommafy in formatNum
24325 !! options
24326 language=be-tarask
24327 !! wikitext
24328 {{formatnum:123456.78}}
24329 {{formatnum:123456.78|NOSEP}}
24330 !! html
24331 <p>123 456,78
24332 123456.78
24333 </p>
24334 !! end
24335
24336 !! test
24337 Wrong option for formatNum (T58199)
24338 !! wikitext
24339 {{formatnum:1,234.56|Random}}
24340 {{formatnum:1,234.56|EVERYTHING}}
24341 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
24342 !! html
24343 <p>1,234.56
24344 1,234.56
24345 1,234.56
24346 </p>
24347 !! end
24348
24349 !! test
24350 Strip marker in grammar
24351 !! options
24352 language=fi
24353 !! wikitext
24354 {{grammar:elative|foo<nowiki/>bar}}
24355 !! html
24356 <p>foobarista
24357 </p>
24358 !! end
24359
24360 !! test
24361 Strip marker in padleft
24362 !! wikitext
24363 {{padleft:|2|x<nowiki/>y}}
24364 !! html
24365 <p>xy
24366 </p>
24367 !! end
24368
24369 !! test
24370 Strip marker in padright
24371 !! wikitext
24372 {{padright:|2|x<nowiki/>y}}
24373 !! html
24374 <p>xy
24375 </p>
24376 !! end
24377
24378 !! test
24379 Strip marker in anchorencode
24380 !! wikitext
24381 {{anchorencode:x<nowiki/>y}}
24382 !! html/php
24383 <p>xy
24384 </p>
24385 !! html/parsoid
24386 <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>
24387 !! end
24388
24389 !! test
24390 nowiki inside link inside heading (T20295)
24391 !! wikitext
24392 ==[[foo|x<nowiki>y</nowiki>z]]==
24393 !! html
24394 <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>
24395
24396 !! end
24397
24398 !! test
24399 new support for bdi element (T33817)
24400 !! wikitext
24401 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24402 !! html
24403 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24404
24405 !!end
24406
24407 !! test
24408 Ignore pipe between table row attributes
24409 !! wikitext
24410 {|
24411 | quux
24412 |- id=foo | style='color: red'
24413 | bar
24414 |}
24415 !! html
24416 <table>
24417 <tr>
24418 <td> quux
24419 </td></tr>
24420 <tr id="foo" style="color: red">
24421 <td> bar
24422 </td></tr></table>
24423
24424 !! end
24425
24426 !!test
24427 Language parser function
24428 !! wikitext
24429 {{#language:ar}}
24430 !! html
24431 <p>العربية
24432 </p>
24433 !! end
24434
24435 !!test
24436 Padleft and padright as substr
24437 !! wikitext
24438 {{padleft:|3|abcde}}
24439 {{padright:|3|abcde}}
24440 !! html
24441 <p>abc
24442 abc
24443 </p>
24444 !! end
24445
24446 !!test
24447 Special parser function
24448 !! wikitext
24449 {{#special:RandomPage}}
24450 {{#special:BaDtItLe}}
24451 {{#special:Foobar}}
24452 !! html
24453 <p>Special:Random
24454 Special:Badtitle
24455 Special:Foobar
24456 </p>
24457 !! end
24458
24459 !!test
24460 T36939 - Case insensitive link parsing ([HttP://])
24461 !! wikitext
24462 [HttP://MediaWiki.Org/]
24463 !! html/php
24464 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
24465 </p>
24466 !! html/parsoid
24467 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/"></a></p>
24468 !! end
24469
24470 !!test
24471 T36939 - Case insensitive link parsing ([HttP:// title])
24472 !! wikitext
24473 [HttP://MediaWiki.Org/ MediaWiki]
24474 !! html
24475 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
24476 </p>
24477 !! end
24478
24479 !!test
24480 T36939 - Case insensitive link parsing (HttP://)
24481 !! wikitext
24482 HttP://MediaWiki.Org/
24483 !! html/php
24484 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
24485 </p>
24486 !! html/parsoid
24487 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
24488 !! end
24489
24490 !!test
24491 Disable TOC
24492 !! options
24493 notoc
24494 !! wikitext
24495 Lead
24496 == Section 1 ==
24497 == Section 2 ==
24498 == Section 3 ==
24499 == Section 4 ==
24500 == Section 5 ==
24501 !! html
24502 <p>Lead
24503 </p>
24504
24505 <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>
24506 <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>
24507 <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>
24508 <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>
24509 <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>
24510
24511 !! end
24512
24513
24514 ###
24515 ### Parsoid-specific tests
24516 ### Parsoid-PHP parser incompatibilities
24517 ###
24518 !!test
24519 1. SOL-sensitive wikitext tokens as template-args
24520 !!options
24521 parsoid=wt2html,wt2wt
24522 !! wikitext
24523 {{echo|*a}}
24524 {{echo|#a}}
24525 {{echo|:a}}
24526 !! html
24527 <span about="#mwt1" typeof="mw:Transclusion">
24528 </span><ul about="#mwt1"><li>a</li>
24529 </ul>
24530 <span about="#mwt2" typeof="mw:Transclusion">
24531 </span><ol about="#mwt2"><li>a</li>
24532 </ol>
24533 <span about="#mwt3" typeof="mw:Transclusion">
24534 </span><dl about="#mwt3"><dd>a</dd>
24535 </dl>
24536 !!end
24537
24538 #### -----------------------------------------------------------------
24539 #### Parsoid-specific functionality tests
24540 #### -----------------------------------------------------------------
24541
24542 # T65642/T68749: Formatting elt fixup around images is cleaned up.
24543 # We know wt2wt will fail, but we expect selser to pass.
24544 # Due to the nature of our testing, wt2wt and selser tests will enter the
24545 # blacklist and we'll catch selser regressions based on changes to the
24546 # blacklist entries for selser tests.
24547 !! test
24548 1. Bad treebuilder fixup of formatting elt is cleaned up
24549 !! options
24550 parsoid=wt2html,wt2wt
24551 !! wikitext
24552 {|
24553 |
24554 <small>
24555 [[Image:Foobar.jpg|right|Test]]
24556 </small>
24557 |}
24558 !! html/parsoid
24559 <table>
24560 <tbody><tr><td>
24561 <small>
24562 <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>
24563 </small>
24564 </td></tr>
24565 </tbody></table>
24566 !! end
24567
24568 !! test
24569 2. Bad treebuilder fixup of formatting elt is cleaned up
24570 !! options
24571 parsoid=wt2html,wt2wt
24572 !! wikitext
24573 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
24574
24575 <small>[[Image:Foobar.jpg|right|300px]]</small>
24576 !! html/parsoid
24577
24578 <p><b>foo</b></p>
24579 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><b>caption</b></figcaption></figure>
24580 <p><b>bar</b></p>
24581 <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>
24582 !! end
24583
24584 !! test
24585 3. Bad treebuilder fixup of formatting elt is cleaned up
24586 !! options
24587 parsoid=wt2html,wt2wt
24588 !! wikitext
24589 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
24590 !! html/parsoid
24591 <p><small><b>foo</b></small></p>
24592 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption><small><b>caption</b></small></figcaption></figure>
24593 <p><small><b>bar</b></small></p>
24594 !! end
24595
24596 !! test
24597 4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
24598 !! options
24599 parsoid=wt2html,wt2wt
24600 !! wikitext
24601 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
24602 !! html/parsoid
24603 <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>
24604 !! end
24605
24606 #### ----------------------------------------------------------------
24607 #### Parsoid-only testing of Parsoid's impl of LST
24608 #### Not implemented yet, see
24609 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
24610 #### ----------------------------------------------------------------
24611
24612 ## We still need to support serializing the older format while content is stored.
24613 !! test
24614 LST Sections: Backwards compatibility
24615 !! options
24616 parsoid={
24617 "suppressErrors": true,
24618 "modes": ["html2wt"]
24619 }
24620 !! wikitext
24621 <section begin="2011-05-16" />
24622 <section end="2014-04-10 (MW 1.23wmf22)" />
24623 !! html/parsoid
24624 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
24625 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
24626 !! end
24627
24628 !! test
24629 LST Sections: Newfangled approach
24630 !! wikitext
24631 <section begin="2011-05-16" />
24632 <section end="2014-04-10 (MW 1.23wmf22)" />
24633 !! html/parsoid
24634 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'>
24635 </span>
24636 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null}'>
24637 </span></p>
24638 !! end
24639
24640 #--------- Test stripping of empty nodes in template content ----------
24641
24642 !! test
24643 Empty LI and TR nodes should be stripped from template content
24644 !! wikitext
24645 {{EmptyLITest}}
24646 {{EmptyTRTest}}
24647 !! html/parsoid
24648 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
24649 <li>a</li>
24650 <li>b</li>
24651 </ul>
24652 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
24653 <tbody>
24654 <tr>
24655 <td>foo</td>
24656 </tr>
24657 <tr>
24658 <td>bar</td>
24659 </tr>
24660 </tbody>
24661 </table>
24662 !! end
24663
24664 !! test
24665 Empty LI and TR nodes should not be stripped from top-level content
24666 !! wikitext
24667 * a
24668 *
24669 * b
24670 {|
24671 |-
24672 |-
24673 |foo
24674 |}
24675 !! html/parsoid
24676 <ul>
24677 <li> a</li>
24678 <li class='mw-empty-elt'></li>
24679 <li> b</li>
24680 </ul>
24681 <table>
24682 <tbody>
24683 <tr class='mw-empty-elt'></tr>
24684 <tr>
24685 <td>foo</td>
24686 </tr>
24687 </tbody>
24688 </table>
24689 !! end
24690
24691 !! test
24692 Empty TR nodes should not be stripped if they have any attributes set
24693 !! wikitext
24694 {{EmptyTRWithHTMLAttrTest}}
24695 !! html/parsoid
24696 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
24697 <tr align='center'></tr>
24698 <tr><td>foo</td></tr>
24699 <tr align='center'></tr>
24700 <tr><td>bar</td></tr>
24701 </table>
24702 !! end
24703
24704 #### ----------------------------------------------------------------
24705 #### The following section of tests are primarily to test
24706 #### wikitext escaping capabilities of Parsoid. Given that
24707 #### escaping can be done any number of ways, the wikitext (input)
24708 #### is always adjusted to reflect how Parsoid adds nowiki
24709 #### escape tags.
24710 ####
24711 #### We are marking several tests as parsoid-only since the
24712 #### HTML in the result section is different from what the
24713 #### PHP parser generates for it.
24714 #### ----------------------------------------------------------------
24715
24716
24717 #### --------------- Headings ---------------
24718 #### 0. Unnested
24719 #### 1. Nested inside html <h1>=foo=</h1>
24720 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
24721 #### 3. Nested inside html with wikitext split by html tags
24722 #### 4. No escape needed
24723 #### 5. Empty headings <h1></h1>
24724 #### 6. Heading chars in SOL context
24725 #### ----------------------------------------
24726 !! test
24727 Headings: 0. Unnested
24728 !! options
24729 parsoid=html2wt
24730 !! html/parsoid
24731 <p>=foo=</p>
24732
24733 <p> =foo=
24734 <!--cmt-->
24735 =foo=</p>
24736
24737 <p>=foo<i>a</i>=</p>
24738 !! wikitext
24739 <nowiki>=foo=</nowiki>
24740
24741 <nowiki> </nowiki>=foo=
24742 <!--cmt-->
24743 <nowiki>=foo=</nowiki>
24744
24745 =foo''a''<nowiki>=</nowiki>
24746 !!end
24747
24748 # New headings and existing headings are handled differently
24749 !! test
24750 Headings: 1. Nested inside html
24751 !! options
24752 parsoid=html2wt
24753 !! html/parsoid
24754 <h1>=foo=</h1>
24755 <h2>=foo=</h2>
24756 <h3>=foo=</h3>
24757
24758 <h1 data-parsoid=''>=foo=</h1>
24759 <h2 data-parsoid=''>=foo=</h2>
24760 <h3 data-parsoid=''>=foo=</h3>
24761 <h4 data-parsoid=''>=foo=</h4>
24762 <h5 data-parsoid=''>=foo=</h5>
24763 <h6 data-parsoid=''>=foo=</h6>
24764 !! wikitext
24765 = =foo= =
24766
24767 == =foo= ==
24768
24769 === =foo= ===
24770
24771 =<nowiki>=foo=</nowiki>=
24772 ==<nowiki>=foo=</nowiki>==
24773 ===<nowiki>=foo=</nowiki>===
24774 ====<nowiki>=foo=</nowiki>====
24775 =====<nowiki>=foo=</nowiki>=====
24776 ======<nowiki>=foo=</nowiki>======
24777
24778 !!end
24779
24780 !! test
24781 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
24782 !! options
24783 parsoid=html2wt
24784 !! html/parsoid
24785 <h1>foo</h1>*bar
24786 <h1>foo</h1>=bar
24787 <h1>foo</h1>=bar=
24788 !! wikitext
24789 = foo =
24790 <nowiki>*</nowiki>bar
24791
24792 = foo =
24793 =bar
24794
24795 = foo =
24796 <nowiki>=bar=</nowiki>
24797 !!end
24798
24799 !! test
24800 Headings: 3. Nested inside html with wikitext split by html tags
24801 !! options
24802 parsoid=html2wt
24803 !! html/parsoid
24804 <h1>=<b>bold</b>foo=</h1>
24805 !! wikitext
24806 = ='''bold'''foo= =
24807 !!end
24808
24809 !! test
24810 Headings: 4a. No escaping needed (testing just h1 and h2)
24811 !! options
24812 parsoid=html2wt
24813 !! html/parsoid
24814 <h1>=foo</h1>
24815 <h1>foo=</h1>
24816 <h1> =foo= </h1>
24817 <h1>=foo= bar</h1>
24818 <h2>=foo</h2>
24819 <h2>foo=</h2>
24820 <h1>=</h1>
24821 <h1><i>=</i>foo=</h1>
24822 !! wikitext
24823 = =foo =
24824
24825 = foo= =
24826
24827 = =foo= =
24828
24829 = =foo= bar =
24830
24831 == =foo ==
24832
24833 == foo= ==
24834
24835 = = =
24836
24837 = ''=''foo= =
24838 !!end
24839
24840 !! test
24841 Headings: 4b. No escaping needed (inside p-tags)
24842 !! options
24843 parsoid=html2wt
24844 !! html/parsoid
24845 <p>=foo= x
24846 =foo= <s></s>
24847 </p>
24848 !! wikitext
24849 =foo= x
24850 =foo= <s></s>
24851 !! html/php
24852 <p>=foo= x
24853 =foo= <s></s>
24854 </p>
24855 !!end
24856
24857 !! test
24858 Headings: 4c. Short headings (1)
24859 !! options
24860 parsoid=html2wt
24861 !! html/parsoid
24862 <p>===
24863 </p>
24864 !! wikitext
24865 <nowiki>===</nowiki>
24866 !! html/php
24867 <p>===
24868 </p>
24869 !! end
24870
24871 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
24872 !! test
24873 Headings: 4d. Short headings (2)
24874 !! options
24875 parsoid=wt2html,html2html
24876 !! wikitext
24877 =
24878 ==
24879 ===
24880 ====
24881 =====
24882 !! html/php
24883 <p>=
24884 ==
24885 </p>
24886 <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>
24887 <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>
24888 <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>
24889
24890 !! html/parsoid
24891 <p>=
24892 ==</p>
24893 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
24894 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
24895 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
24896 !! end
24897
24898 !! test
24899 Headings: 5. Empty headings
24900 !! options
24901 parsoid=html2wt
24902 !! html/parsoid
24903 <h1 data-parsoid='{}'></h1>
24904
24905 <h2 data-parsoid='{}'></h2>
24906
24907 <h3 data-parsoid='{}'></h3>
24908
24909 <h4 data-parsoid='{}'></h4>
24910
24911 <h5 data-parsoid='{}'></h5>
24912
24913 <h6 data-parsoid='{}'></h6>
24914 !! wikitext
24915 =<nowiki/>=
24916
24917 ==<nowiki/>==
24918
24919 ===<nowiki/>===
24920
24921 ====<nowiki/>====
24922
24923 =====<nowiki/>=====
24924
24925 ======<nowiki/>======
24926 !!end
24927
24928 !! test
24929 Headings: 6a. Heading chars in SOL context (with trailing spaces)
24930 !! options
24931 parsoid=html2wt
24932 !! html/parsoid
24933 <p>=a=</p>
24934
24935 <p>=a=</p>
24936
24937 <p>=a=</p>
24938 !! wikitext
24939 <nowiki>=a=</nowiki>
24940
24941 <nowiki>=a=</nowiki>
24942
24943 <nowiki>=a=</nowiki>
24944 !!end
24945
24946 !! test
24947 Headings: 6b. Heading chars in SOL context (with trailing newlines)
24948 !! options
24949 parsoid=html2wt
24950 !! html/parsoid
24951 <p>=a=
24952 b</p>
24953
24954 <p>=a=
24955 b</p>
24956
24957 <p>=a=
24958 b</p>
24959 !! wikitext
24960 <nowiki>=a=</nowiki>
24961 b
24962
24963 <nowiki>=a=</nowiki>
24964 b
24965
24966 <nowiki>=a=</nowiki>
24967 b
24968 !!end
24969
24970 !! test
24971 Headings: 6c. Heading chars in SOL context (leading newline break)
24972 !! options
24973 parsoid=html2wt
24974 !! html/parsoid
24975 <p>a
24976 =b=</p>
24977 !! wikitext
24978 a
24979 <nowiki>=b=</nowiki>
24980 !!end
24981
24982 !! test
24983 Headings: 6d. Heading chars in SOL context (with interspersed comments)
24984 !! options
24985 parsoid=html2wt
24986 !! html/parsoid
24987 <!--c0--><p>=a=</p>
24988
24989 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
24990 !! wikitext
24991 <!--c0--><nowiki>=a=</nowiki>
24992
24993 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
24994 !!end
24995
24996 !! test
24997 Headings: 6d. Heading chars in SOL context (No escaping needed)
24998 !! options
24999 parsoid=html2wt
25000 !! html/parsoid
25001 =a=<div>b</div>
25002 !! wikitext
25003 =a=<div>b</div>
25004 !!end
25005
25006 !! test
25007 Headings: 7. Insert a newline between new content and headings
25008 !! options
25009 parsoid=html2wt
25010 !! html/parsoid
25011 <h2>NEW</h2>
25012 <p>new</p>
25013 <h2 data-parsoid='{}'>A</h2>
25014 <p data-parsoid='{}'>a</p>
25015 !! wikitext
25016 == NEW ==
25017 new
25018
25019 ==A==
25020 a
25021
25022 !! end
25023
25024 #### --------------- Lists ---------------
25025 #### 0. Outside nests (*foo, etc.)
25026 #### 1. Nested inside html <ul><li>*foo</li></ul>
25027 #### 2. Inside definition lists
25028 #### 3. Only bullets at start should be escaped
25029 #### 4. No escapes needed
25030 #### 5. No unnecessary escapes
25031 #### 6. Escape bullets in SOL position
25032 #### 7. Escape bullets in a multi-line context
25033 #### ----------------------------------------
25034
25035 !! test
25036 Lists: 0. Outside nests
25037 !! options
25038 parsoid=html2wt
25039 !! html/parsoid
25040 <p>*foo</p>
25041
25042 <p>#foo</p>
25043
25044 <p>;Foo:bar</p>
25045 !! wikitext
25046 <nowiki>*</nowiki>foo
25047
25048 <nowiki>#</nowiki>foo
25049
25050 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
25051 !!end
25052
25053 ## Making these next 3 tests Parsoid-only since they are html2wt tests
25054 ## to test wikitext escaping, and insignificant whitespace diffs
25055 ## cause PHP parser tests to barf
25056 !! test
25057 Lists: 1. Nested inside html (No unnecessary escapes)
25058 !! options
25059 parsoid=html2wt
25060 !! html/parsoid
25061 <ul>
25062 <li>*foo</li>
25063 <li>#foo</li>
25064 <li>:foo</li>
25065 <li>;foo</li>
25066 <li data-parsoid='{}'>*foo</li>
25067 <li data-parsoid='{}'>#foo</li>
25068 <li data-parsoid='{}'>:foo</li>
25069 <li data-parsoid='{}'>;foo</li>
25070 </ul>
25071
25072 <ol>
25073 <li>*foo</li>
25074 <li>#foo</li>
25075 <li>:foo</li>
25076 <li>;foo</li>
25077 <li data-parsoid='{}'>*foo</li>
25078 <li data-parsoid='{}'>#foo</li>
25079 <li data-parsoid='{}'>:foo</li>
25080 <li data-parsoid='{}'>;foo</li>
25081 </ol>
25082 !! wikitext
25083 * *foo
25084 * #foo
25085 * :foo
25086 * ;foo
25087 *<nowiki>*foo</nowiki>
25088 *<nowiki>#foo</nowiki>
25089 *<nowiki>:foo</nowiki>
25090 *<nowiki>;foo</nowiki>
25091
25092 # *foo
25093 # #foo
25094 # :foo
25095 # ;foo
25096 #<nowiki>*foo</nowiki>
25097 #<nowiki>#foo</nowiki>
25098 #<nowiki>:foo</nowiki>
25099 #<nowiki>;foo</nowiki>
25100 !!end
25101
25102 !! test
25103 Lists: 2. Inside definition lists
25104 !! options
25105 parsoid=html2wt
25106 !! html/parsoid
25107 <dl><dt>;foo</dt></dl>
25108 <dl><dt>:foo</dt></dl>
25109 <dl><dt>:foo</dt>
25110 <dd>bar</dd></dl>
25111 <dl><dd>:foo</dd></dl>
25112 !! wikitext
25113 ; ;foo
25114
25115 ; <nowiki>:foo</nowiki>
25116
25117 ; <nowiki>:foo</nowiki>
25118 : bar
25119
25120 : :foo
25121 !!end
25122
25123 !! test
25124 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
25125 !! options
25126 parsoid=html2wt
25127 !! html/parsoid
25128 <ul>
25129 <li>*foo*bar</li>
25130 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
25131 </ul>
25132 !! wikitext
25133 * *foo*bar
25134 *<nowiki>*foo</nowiki>''it''*bar
25135 !!end
25136
25137 !! test
25138 Lists: 4. No escapes needed
25139 !! options
25140 parsoid=html2wt
25141 !! html/parsoid
25142 <ul>
25143 <li>foo*bar
25144 </li>
25145 </ul>
25146 <ul>
25147 <li><i>foo</i>*bar
25148 </li>
25149 </ul>
25150 <ul>
25151 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
25152 </li>
25153 </ul>
25154 <ul>
25155 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
25156 </li>
25157 </ul>
25158 !! wikitext
25159 *foo*bar
25160
25161 *''foo''*bar
25162
25163 *[[Foo]]: bar
25164
25165 *[[Foo]]*bar
25166 !!end
25167
25168 !! test
25169 Lists: 5. No unnecessary escapes
25170 !! options
25171 parsoid=html2wt
25172 !! html/parsoid
25173 <ul><li> bar <span>[[foo]]</span></li></ul>
25174 <ul><li> =bar <span>[[foo]]</span></li></ul>
25175 <ul><li> [[bar <span>[[foo]]</span></li></ul>
25176 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
25177 <ul><li> =bar <span>foo]]</span>=</li></ul>
25178 <ul><li> <s></s>: a</li></ul>
25179 <ul><li> <i>* foo</i></li></ul>
25180
25181 !! wikitext
25182 * bar <span><nowiki>[[foo]]</nowiki></span>
25183
25184 * =bar <span><nowiki>[[foo]]</nowiki></span>
25185
25186 * [[bar <span><nowiki>[[foo]]</nowiki></span>
25187
25188 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
25189
25190 * =bar <span>foo]]</span>=
25191
25192 * <s></s>: a
25193
25194 * ''* foo''
25195 !!end
25196
25197 !! test
25198 Lists: 6. Escape bullets in SOL position
25199 !! options
25200 parsoid=html2wt
25201 !! html/parsoid
25202 <p><!--cmt-->*foo</p>
25203 !! wikitext
25204 <!--cmt--><nowiki>*</nowiki>foo
25205 !!end
25206
25207 !! test
25208 Lists: 7. Escape bullets in a multi-line context
25209 !! options
25210 parsoid=html2wt
25211 !! html/parsoid
25212 <p>a
25213 *b
25214 </p>
25215 !! wikitext
25216 a
25217 <nowiki>*</nowiki>b
25218 !!end
25219
25220 !! test
25221 Lists: 8. Escape colons only if not present in tags
25222 !! options
25223 parsoid=html2wt
25224 !! html/parsoid
25225 <dl><dt>a:b<i>c:d</i></dt></dl>
25226 !! wikitext
25227 ; <nowiki>a:b</nowiki>''c:d''
25228 !! end
25229
25230 #### --------------- HRs ---------------
25231 #### 1. Single line
25232 #### -----------------------------------
25233
25234 !! test
25235 HRs: 1. Single line
25236 !! options
25237 parsoid=html2wt
25238 !! html/parsoid
25239 <hr />----
25240 <hr />=foo=
25241 <hr />*foo
25242 !! wikitext
25243 ----<nowiki>----</nowiki>
25244 ----=foo=
25245 ----*foo
25246 !! end
25247
25248 #### --------------- Tables ---------------
25249 #### 1a. Simple example
25250 #### 1b. No escaping needed (!foo)
25251 #### 1c. No escaping needed (|foo)
25252 #### 1d. No escaping needed (|}foo)
25253 ####
25254 #### 2a. Nested in td (<td>foo|bar</td>)
25255 #### 2b. Nested in td (<td>foo||bar</td>)
25256 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
25257 ####
25258 #### 3a. Nested in th (<th>foo!bar</th>)
25259 #### 3b. Nested in th (<th>foo!!bar</th>)
25260 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
25261 ####
25262 #### 4a. Escape -
25263 #### 4b. Escape +
25264 #### 4c. No escaping needed
25265 #### --------------------------------------
25266
25267 !! test
25268 Tables: 1a. Simple example
25269 !! options
25270 parsoid=html2wt
25271 !! html/parsoid
25272 <p>{|
25273 |}
25274 </p>
25275 !! wikitext
25276 <nowiki>{|</nowiki>
25277 |}
25278 !! end
25279
25280 !! test
25281 Tables: 1b. No escaping needed
25282 !! options
25283 parsoid=html2wt
25284 !! html/parsoid
25285 <p>!foo
25286 </p>
25287 !! wikitext
25288 !foo
25289 !! end
25290
25291 !! test
25292 Tables: 1c. No escaping needed
25293 !! options
25294 parsoid=html2wt
25295 !! html/parsoid
25296 <p>|foo
25297 </p>
25298 !! wikitext
25299 |foo
25300 !! end
25301
25302 !! test
25303 Tables: 1d. No escaping needed
25304 !! options
25305 parsoid=html2wt
25306 !! html/parsoid
25307 <p>|}foo
25308 </p>
25309 !! wikitext
25310 |}foo
25311 !! end
25312
25313 !! test
25314 Tables: 2a. Nested in td
25315 !! options
25316 parsoid=html2wt
25317 !! html/parsoid
25318 <table><tbody><tr>
25319 <td>foo|bar</td></tr>
25320 <tr><td>x<div>a|b</div></td>
25321 </tbody></table>
25322 !! wikitext
25323 {|
25324 |<nowiki>foo|bar</nowiki>
25325 |-
25326 |x<div><nowiki>a|b</nowiki></div>
25327 |}
25328 !! html/php+tidy
25329 <table>
25330 <tbody><tr>
25331 <td>foo|bar
25332 </td></tr>
25333 <tr>
25334 <td>x<div>a|b</div>
25335 </td></tr></tbody></table>
25336 !! end
25337
25338 !! test
25339 Tables: 2b. Nested in td
25340 !! options
25341 parsoid=html2wt
25342 !! html/parsoid
25343 <table><tbody><tr>
25344 <td>foo||bar</td>
25345 <td>a<i>b||c</i></td>
25346 <td>a<i><div>b||c</div></i></td>
25347 </tr></tbody></table>
25348 !! wikitext
25349 {|
25350 |<nowiki>foo||bar</nowiki>
25351 |a''<nowiki>b||c</nowiki>''
25352 |a''<div><nowiki>b||c</nowiki></div>''
25353 |}
25354 !! html/php
25355 <table>
25356 <tr>
25357 <td>foo||bar
25358 </td>
25359 <td>a<i>b||c</i>
25360 </td>
25361 <td>a<i><div>b||c</div></i>
25362 </td></tr></table>
25363
25364 !! end
25365
25366 !! test
25367 Tables: 2c. Nested in td -- no escaping needed
25368 !! options
25369 parsoid=html2wt
25370 !! html/*
25371 <table>
25372 <tr>
25373 <td>foo!!bar
25374 </td></tr></table>
25375
25376 !! wikitext
25377 {|
25378 |foo!!bar
25379 |}
25380 !! end
25381
25382 !! test
25383 Tables: 3a. Nested in th
25384 !! options
25385 parsoid=html2wt
25386 !! html/*
25387 <table>
25388 <tr>
25389 <th>foo!bar
25390 </th></tr></table>
25391
25392 !! wikitext
25393 {|
25394 !foo!bar
25395 |}
25396 !! end
25397
25398 !! test
25399 Tables: 3b. Nested in th
25400 !! options
25401 parsoid=html2wt
25402 !! html/parsoid
25403 <table><tbody>
25404 <tr><th>foo!!bar</th>
25405 <th><i>foo|bar</i></th>
25406 <th><i>foo!!bar</i></th>
25407 <th><i><span>foo!!bar</span></i></th>
25408 </tr></tbody></table>
25409 !! wikitext
25410 {|
25411 !<nowiki>foo!!bar</nowiki>
25412 !''<nowiki>foo|bar</nowiki>''
25413 !''<nowiki>foo!!bar</nowiki>''
25414 !''<span><nowiki>foo!!bar</nowiki></span>''
25415 |}
25416 !! html/php
25417 <table>
25418 <tr>
25419 <th>foo!!bar
25420 </th>
25421 <th><i>foo|bar</i>
25422 </th>
25423 <th><i>foo!!bar</i>
25424 </th>
25425 <th><i><span>foo!!bar</span></i>
25426 </th></tr></table>
25427
25428 !! end
25429
25430 !! test
25431 Tables: 3c. Nested in th
25432 !! options
25433 parsoid=html2wt
25434 !! html/parsoid
25435 <table><tbody>
25436 <tr><th>foo||bar</th>
25437 <th><span typeof="mw:Nowiki">foo||bar</span></th>
25438 </tr></tbody></table>
25439 !! wikitext
25440 {|
25441 !<nowiki>foo||bar</nowiki>
25442 !<nowiki>foo||bar</nowiki>
25443 |}
25444 !! html/php
25445 <table>
25446 <tr>
25447 <th>foo||bar
25448 </th>
25449 <th>foo||bar
25450 </th></tr></table>
25451
25452 !! end
25453
25454 !! test
25455 Tables: 4a. Escape -
25456 !! options
25457 parsoid=html2wt
25458 !! html/*
25459 <table>
25460 <tr>
25461 <th>-bar
25462 </th></tr>
25463 <tr>
25464 <td>-bar
25465 </td></tr></table>
25466
25467 !! wikitext
25468 {|
25469 !-bar
25470 |-
25471 |<nowiki>-bar</nowiki>
25472 |}
25473 !! end
25474
25475 !! test
25476 Tables: 4b. Escape +
25477 !! options
25478 parsoid=html2wt
25479 !! html/*
25480 <table>
25481 <tr>
25482 <th>+bar
25483 </th></tr>
25484 <tr>
25485 <td>+bar
25486 </td></tr></table>
25487
25488 !! wikitext
25489 {|
25490 !+bar
25491 |-
25492 |<nowiki>+bar</nowiki>
25493 |}
25494 !! end
25495
25496 !! test
25497 Tables: 4c. No escaping needed
25498 !! options
25499 parsoid=html2wt
25500 !! html/parsoid
25501 <table><tbody>
25502 <tr><td>foo-bar</td><td>foo+bar</td></tr>
25503 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
25504 <tr><td>foo
25505 <p>bar|baz
25506 +bar
25507 -bar</p></td></tr>
25508 <tr><td>x
25509 <div>a|b</div></td>
25510 </tbody></table>
25511 !! wikitext
25512 {|
25513 |foo-bar
25514 |foo+bar
25515 |-
25516 |''foo''-bar
25517 |''foo''+bar
25518 |-
25519 |foo
25520 bar|baz
25521 +bar
25522 -bar
25523 |-
25524 |x
25525 <div>a|b</div>
25526 |}
25527 !! html/php
25528 <table>
25529 <tr>
25530 <td>foo-bar
25531 </td>
25532 <td>foo+bar
25533 </td></tr>
25534 <tr>
25535 <td><i>foo</i>-bar
25536 </td>
25537 <td><i>foo</i>+bar
25538 </td></tr>
25539 <tr>
25540 <td>foo
25541 <p>bar|baz
25542 +bar
25543 -bar
25544 </p>
25545 </td></tr>
25546 <tr>
25547 <td>x
25548 <div>a|b</div>
25549 </td></tr></table>
25550
25551 !! end
25552
25553 !! test
25554 Tables: 4d. No escaping needed
25555 !! options
25556 parsoid=html2wt
25557 !! html/parsoid
25558 <table>
25559 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
25560 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
25561 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
25562 </tbody></table>
25563 !! wikitext
25564 {|
25565 |[[Foo]]-bar
25566 ||+1
25567 ||-2
25568 |}
25569 !! html/php
25570 <table>
25571 <tr>
25572 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
25573 </td>
25574 <td>+1
25575 </td>
25576 <td>-2
25577 </td></tr></table>
25578
25579 !! end
25580
25581 !! test
25582 T97430: Don't emit empty nowiki pairs around marker meta tags
25583 !! options
25584 parsoid=html2wt
25585 !! html/parsoid
25586 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25587 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
25588 !! wikitext
25589 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25590 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
25591 !! end
25592
25593 !! test
25594 Unclosed xmlish element in table line shouldn't eat end delimiters
25595 !! options
25596 parsoid=html2wt
25597 !! html/parsoid
25598 <table>
25599 <tbody><tr><td> &lt;foo</td>
25600 <td> bar></td></tr>
25601 </tbody></table>
25602 !! wikitext
25603 {|
25604 | <foo
25605 | bar>
25606 |}
25607 !! html/php
25608 <table>
25609 <tr>
25610 <td> &lt;foo
25611 </td>
25612 <td> bar&gt;
25613 </td></tr></table>
25614
25615 !! end
25616
25617 #### --------------- Links ----------------
25618 #### 1. Quote marks in link text
25619 #### 2. Wikilinks: Escapes needed
25620 #### 3. Wikilinks: No escapes needed
25621 #### 4. Extlinks: Escapes needed
25622 #### 5. Extlinks: No escapes needed
25623 #### --------------------------------------
25624 !! test
25625 Links 1. WikiLinks: No escapes needed
25626 !! options
25627 parsoid=html2wt
25628 !! html/parsoid
25629 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
25630 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
25631 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
25632 !! wikitext
25633 [[Foo|Foo''boo'']]
25634 [[Foo|[Foobar]]]
25635 [[Foo|x [Foobar] x]]
25636 !! html/php
25637 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
25638 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
25639 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
25640 </p>
25641 !! end
25642
25643 !! test
25644 Links 2. WikiLinks: Escapes needed
25645 !! options
25646 parsoid=html2wt
25647 !! html/parsoid
25648 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
25649 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
25650 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
25651 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
25652 <a href="Foo" rel="mw:WikiLink">|Bar</a>
25653 <a href="Foo" rel="mw:WikiLink">]]bar</a>
25654 <a href="Foo" rel="mw:WikiLink">[[bar</a>
25655 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
25656 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
25657 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
25658 !! wikitext
25659 [[Foo|<nowiki>Foobar]</nowiki>]]
25660 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
25661 [[Foo|<nowiki>[[Bar]]</nowiki>]]
25662 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
25663 [[Foo|<nowiki>|Bar</nowiki>]]
25664 [[Foo|<nowiki>]]bar</nowiki>]]
25665 [[Foo|<nowiki>[[bar</nowiki>]]
25666 [[Foo|<nowiki>x [[ y</nowiki>]]
25667 [[Foo|<nowiki>x ]] y</nowiki>]]
25668 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
25669 !! html/php
25670 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
25671 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
25672 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
25673 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
25674 <a href="/wiki/Foo" title="Foo">|Bar</a>
25675 <a href="/wiki/Foo" title="Foo">]]bar</a>
25676 <a href="/wiki/Foo" title="Foo">[[bar</a>
25677 <a href="/wiki/Foo" title="Foo">x [[ y</a>
25678 <a href="/wiki/Foo" title="Foo">x ]] y</a>
25679 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
25680 </p>
25681 !! end
25682
25683 !! test
25684 Links 3. WikiLinks: No escapes needed
25685 !! options
25686 parsoid=html2wt
25687 !! html/parsoid
25688 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
25689 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
25690 !! wikitext
25691 [[Foo|[Foobar]]
25692 [[Foo|foo|bar]]
25693 !! html/php
25694 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
25695 <a href="/wiki/Foo" title="Foo">foo|bar</a>
25696 </p>
25697 !! end
25698
25699 !! test
25700 Links 4. ExtLinks: Escapes needed
25701 !! options
25702 parsoid=html2wt
25703 !! html/parsoid
25704 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
25705 <a rel="mw:ExtLink" href="http://google.com">google]</a>
25706 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
25707 <p>[http://google.com]</p>
25708 <p>[http://google.com google]</p>
25709 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
25710 <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>
25711 !! wikitext
25712 [http://google.com <nowiki>[google]</nowiki>]
25713 [http://google.com <nowiki>google]</nowiki>]
25714 [http://google.com <nowiki>goog] le</nowiki>]
25715
25716 <nowiki>[http://google.com]</nowiki>
25717
25718 <nowiki>[http://google.com google]</nowiki>
25719
25720 [http://google.com<nowiki>]</nowiki>
25721
25722 [{{echo|http://google.com}}<nowiki>]</nowiki>
25723 !! html/php
25724 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
25725 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
25726 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
25727 </p><p>[http://google.com]
25728 </p><p>[http://google.com google]
25729 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
25730 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
25731 </p>
25732 !! end
25733
25734 !! test
25735 Links 5. ExtLinks: No escapes needed
25736 !! options
25737 parsoid=html2wt
25738 !! html/parsoid
25739 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
25740 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
25741 !! wikitext
25742 [http://google.com [google]
25743
25744 [[http://google.com]]
25745 !! html/php
25746 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
25747 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
25748 </p>
25749 !! end
25750
25751 !! test
25752 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
25753 !! options
25754 parsoid=html2wt
25755 !! html/parsoid
25756 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
25757 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
25758 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
25759 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
25760 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
25761 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
25762 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
25763 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
25764 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
25765 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
25766 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
25767 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
25768 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
25769 </p>
25770 !! wikitext
25771 x<nowiki/>http://example.com<nowiki/>y
25772 http://example.com<nowiki/>?x
25773 http://example.com<nowiki/>&x
25774 http://example.com<nowiki/>'x
25775 http://example.com<nowiki/>,x
25776 http://example.com<nowiki/>.x
25777 http://example.com<nowiki/>;x
25778 http://example.com<nowiki/>:x
25779 http://example.com<nowiki/>;x
25780 http://example.com<nowiki/>!x
25781 http://example.com<nowiki/>=x
25782 http://example.com<nowiki/>(x)
25783 http://example.com(x<nowiki/>)
25784 !! end
25785
25786 !! test
25787 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
25788 !! options
25789 parsoid=html2wt
25790 !! html/parsoid
25791 <p>x
25792 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
25793 y
25794 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
25795 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
25796 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
25797 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
25798 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
25799 </p>
25800 !! wikitext
25801 x
25802 http://example.com
25803 y
25804 "http://example.com"
25805 (http://example.com)
25806 (http://example.com) foo
25807 http://example.com,
25808 http://example.com, foo
25809 !! html/php
25810 <p>x
25811 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
25812 y
25813 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
25814 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
25815 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
25816 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
25817 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
25818 </p>
25819 !! end
25820
25821 !! test
25822 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
25823 !! options
25824 parsoid=html2wt
25825 !! html/parsoid
25826 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
25827 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
25828 !! wikitext
25829 http://example.com.,;:!?\
25830 -http://example.com:
25831 !! html/php
25832 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
25833 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
25834 </p>
25835 !! end
25836
25837 !! test
25838 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
25839 !! options
25840 parsoid=html2wt
25841 !! html/parsoid
25842 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
25843 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
25844 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
25845 !! wikitext
25846 RFC 123<nowiki/>4
25847 RFC 123<nowiki/>y
25848 X<nowiki/>RFC 123<nowiki/>y
25849 !! end
25850
25851 !! test
25852 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
25853 !! options
25854 parsoid=html2wt
25855 !! html/parsoid
25856 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
25857 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
25858 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
25859 </p>
25860 !! wikitext
25861 RFC 123?foo
25862 RFC 123&foo
25863 -RFC 123-
25864 !! html/php
25865 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
25866 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
25867 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
25868 </p>
25869 !! end
25870
25871 !! test
25872 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
25873 !! options
25874 parsoid=html2wt
25875 !! html/parsoid
25876 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
25877 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
25878 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
25879 !! wikitext
25880 PMID 123<nowiki/>4
25881 PMID 123<nowiki/>y
25882 X<nowiki/>PMID 123<nowiki/>y
25883 !! end
25884
25885 !! test
25886 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
25887 !! options
25888 parsoid=html2wt
25889 !! html/parsoid
25890 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
25891 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
25892 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
25893 </p>
25894 !! wikitext
25895 PMID 123?foo
25896 PMID 123&foo
25897 -PMID 123-
25898 !! html/php
25899 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
25900 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
25901 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
25902 </p>
25903 !! end
25904
25905 !! test
25906 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
25907 !! options
25908 parsoid=html2wt
25909 !! html/parsoid
25910 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
25911 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
25912 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
25913 </p>
25914 !! wikitext
25915 ISBN 1234567890<nowiki/>1
25916 ISBN 1234567890<nowiki/>x
25917 a<nowiki/>ISBN 1234567890<nowiki/>b
25918 !! end
25919
25920 !! test
25921 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
25922 !! options
25923 parsoid=html2wt
25924 !! html/parsoid
25925 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
25926 !! wikitext
25927 -ISBN 1234567890's
25928 !! html/php
25929 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
25930 </p>
25931 !! end
25932
25933 !! test
25934 Links 14. Protect link-like plain text. (Parsoid bug T78425)
25935 !! options
25936 parsoid=html2wt
25937 !! html/*
25938 <p>this is not a link: http://example.com
25939 </p>
25940 !! wikitext
25941 this is not a link: <nowiki>http://example.com</nowiki>
25942 !! end
25943
25944 !! test
25945 Links 15. Link trails can't become link prefixes.
25946 !! options
25947 language=is
25948 parsoid=html2wt
25949 !! html/parsoid
25950 <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>
25951 !! wikitext
25952 [[Söfnuður]]-[[00]]
25953 !! html/php
25954 <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>
25955 </p>
25956 !! end
25957
25958 #### --------------- Quotes ---------------
25959 #### 1. Quotes inside <b> and <i>
25960 #### 2. Link fragments separated by <i> and <b> tags
25961 #### 3. Link fragments inside <i> and <b>
25962 #### 4. No escaping needed
25963 #### --------------------------------------
25964 !! test
25965 1a. Quotes inside <b> and <i>
25966 !! options
25967 parsoid=html2wt
25968 !! html/*
25969 <p><i>'foo'</i>
25970 <i>''foo''</i>
25971 <i>'''foo'''</i>
25972 <i>foo</i>'s
25973 <b>'foo'</b>
25974 <b>''foo''</b>
25975 <b>'''foo'''</b>
25976 <b>foo'<i>bar'</i>baz</b>
25977 <b>foo</b>'s
25978 '<i>foo</i>
25979 <i>foo</i>'
25980 <i>foo'</i>'
25981 '<i>foo</i>'
25982 '<b>foo</b>
25983 <b>foo</b>'
25984 '<b>foo</b>'
25985 <i>fools'<span> errand</span></i>
25986 <i><span>fool</span>'s errand</i>
25987 '<i>foo</i> bar '<i>baz</i>
25988 a|!*#-:;+-~[]{}b'<i>x</i>
25989 </p>
25990 !! wikitext
25991 ''<nowiki/>'foo'''
25992 ''<nowiki>''foo''</nowiki>''
25993 ''<nowiki>'''foo'''</nowiki>''
25994 ''foo''<nowiki/>'s
25995 '''<nowiki/>'foo''''
25996 '''<nowiki>''foo''</nowiki>'''
25997 '''<nowiki>'''foo'''</nowiki>'''
25998 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
25999 '''foo'''<nowiki/>'s
26000 '''foo''
26001 ''foo''<nowiki/>'
26002 ''foo'''<nowiki/>'
26003 '''foo''<nowiki/>'
26004 ''''foo'''
26005 '''foo'''<nowiki/>'
26006 ''''foo'''<nowiki/>'
26007 ''fools'<span> errand</span>''
26008 ''<span>fool</span>'s errand''
26009 '<nowiki/>''foo'' bar '''baz''
26010 a|!*#-:;+-~[]{}b'''x''
26011 !! end
26012
26013 !! test
26014 1b. Quotes inside <b> and <i> with other tags on same line
26015 !! options
26016 parsoid=html2wt
26017 !! html/parsoid
26018 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26019 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26020 <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>
26021 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
26022 '<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>
26023 '<i>foo</i> <div title="name">test</div>
26024 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
26025 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
26026 <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>
26027 </ol>
26028 !! wikitext
26029 '''a'' foo ''[[bar]]''
26030 ''a''' foo ''[[bar]]''
26031 ''a''' foo '''{{echo|[[bar]]}}'''
26032 [[foo]] x'''[[bar]]''
26033 '''foo'' <ref>test</ref>
26034 '''foo'' <div title="name">test</div>
26035 '''foo'' and <br> bar
26036 <references />
26037 !! end
26038
26039 !! test
26040 2. Link fragments separated by <i> and <b> tags
26041 !! options
26042 parsoid=html2wt
26043 !! html/parsoid
26044 <p>[[<i>foo</i>hello]]</p>
26045 <p>[[<b>foo</b>hello]]</p>
26046 !! wikitext
26047 [[''foo''<nowiki>hello]]</nowiki>
26048
26049 [['''foo'''<nowiki>hello]]</nowiki>
26050 !! end
26051
26052 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
26053 # this is one of the shortcomings of this format
26054 !! test
26055 3. Link fragments inside <i> and <b>
26056 !! options
26057 parsoid=html2wt
26058 !! html/parsoid
26059 <p><i>[[foo</i>]]</p>
26060 <p><b>[[foo</b>]]</p>
26061 !! wikitext
26062 ''[[foo''<nowiki>]]</nowiki>
26063
26064 '''[[foo'''<nowiki>]]</nowiki>
26065 !! end
26066
26067 !! test
26068 4. No escaping needed
26069 !! options
26070 parsoid=html2wt
26071 !! html/parsoid
26072 <p>'<span><i>bar</i></span>'
26073 '<span><b>bar</b></span>'
26074 'a:b'foo
26075 </p>
26076 !! wikitext
26077 '<span>''bar''</span>'
26078 '<span>'''bar'''</span>'
26079 'a:b'foo
26080 !! end
26081
26082 #### ----------- Paragraphs ---------------
26083 #### 1. No unnecessary escapes
26084 #### --------------------------------------
26085
26086 !! test
26087 1. No unnecessary escapes
26088 !! options
26089 parsoid=html2wt
26090 !! html/parsoid
26091 <p>bar <span>[[foo]]</span>
26092 </p><p>=bar <span>[[foo]]</span>
26093 </p><p>[[bar <span>[[foo]]</span>
26094 </p><p>]]bar <span>[[foo]]</span>
26095 </p><p>=bar <span>foo]]</span>=
26096 </p>
26097 !! wikitext
26098 bar <span><nowiki>[[foo]]</nowiki></span>
26099
26100 =bar <span><nowiki>[[foo]]</nowiki></span>
26101
26102 [[bar <span><nowiki>[[foo]]</nowiki></span>
26103
26104 ]]bar <span><nowiki>[[foo]]</nowiki></span>
26105
26106 =bar <span>foo]]</span><nowiki>=</nowiki>
26107 !!end
26108
26109 #### ----------------------- PRE --------------------------
26110 #### 1. Leading whitespace in SOL context should be escaped
26111 #### ------------------------------------------------------
26112 !! test
26113 1. Leading whitespace in SOL context should be escaped
26114 !! options
26115 parsoid=html2wt
26116 !! html/parsoid
26117 <p> a</p>
26118
26119 <p> a</p>
26120
26121 <p> a(tab)</p>
26122
26123 <p> a
26124 <!--cmt-->
26125 a</p>
26126
26127 <p>a
26128 b</p>
26129
26130 <p>a
26131 b</p>
26132
26133 <p>a
26134 b</p>
26135 !! wikitext
26136 <nowiki> </nowiki>a
26137
26138 <nowiki> </nowiki> a
26139
26140 a(tab)
26141
26142 <nowiki> </nowiki> a
26143 <!--cmt-->
26144 <nowiki> </nowiki>a
26145
26146 a
26147 <nowiki> </nowiki>b
26148
26149 a
26150 b
26151
26152 a
26153 b
26154 !! html/php
26155 <p> a
26156 </p><p> a
26157 </p><p> a(tab)
26158 </p><p> a
26159 a
26160 </p><p>a
26161 b
26162 </p><p>a
26163 b
26164 </p><p>a
26165 b
26166 </p>
26167 !! end
26168
26169 !! test
26170 2. Leading whitespace in non-indent-pre contexts should not be escaped
26171 !! options
26172 parsoid=html2wt
26173 !! html/parsoid
26174 <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>
26175 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
26176 <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>
26177 b</span></li>
26178 </ol>
26179 !! wikitext
26180 foo <ref>''a''
26181 b</ref>
26182 <references />
26183 !! end
26184
26185 !! test
26186 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
26187 !! options
26188 parsoid=html2wt
26189 !! html/parsoid
26190 <blockquote>
26191 <p>
26192 a
26193 <span>b</span>
26194 c</p>
26195 </blockquote>
26196 !! wikitext
26197 <blockquote>
26198 a
26199 <span>b</span>
26200 c
26201 </blockquote>
26202 !! end
26203
26204 !! test
26205 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
26206 !! options
26207 parsoid=html2wt
26208 !! html/parsoid
26209 <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>
26210 !! wikitext
26211 [[File:Foobar.jpg|thumb|caption]]
26212 !! end
26213
26214 !! test
26215 5. Nowiki escaping should account for indent-pres
26216 !! options
26217 parsoid=html2wt
26218 !! html/parsoid
26219 <pre>==foo==</pre>
26220 !! wikitext
26221 ==foo==
26222 !! end
26223
26224 !!test
26225 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
26226 !! options
26227 parsoid=html2wt
26228 !! html/parsoid
26229 <pre>
26230 * foo
26231 * bar
26232 </pre>
26233 !! wikitext
26234 * foo
26235 * bar
26236 !! end
26237
26238 #### --------------- Behavior Switches --------------------
26239
26240 !! test
26241 1. Valid behavior switches should be escaped
26242 !! options
26243 parsoid=html2wt
26244 !! html/parsoid
26245 __TOC__
26246 <i>__TOC__</i>
26247 !! wikitext
26248 <nowiki>__TOC__</nowiki>
26249 ''<nowiki>__TOC__</nowiki>''
26250 !! end
26251
26252 !! test
26253 2. Invalid behavior switches should not be escaped
26254 !! options
26255 parsoid=html2wt
26256 !! html/parsoid
26257 __TOO__
26258 __|__
26259 !! wikitext
26260 __TOO__
26261 __|__
26262 !! end
26263
26264 # We use indent-pre as an indirect way to test for sol-transparent behavior.
26265 !! test
26266 Behavior switches should be SOL-transparent
26267 !! options
26268 parsoid=html2wt
26269 !! html/parsoid
26270 <meta property="mw:PageProp/toc" />
26271
26272 <!-- this one's bogus -->
26273 <pre>__TOO__</pre>
26274
26275 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
26276
26277 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
26278 !! wikitext
26279 __TOC__
26280
26281 <!-- this one's bogus -->
26282 __TOO__
26283
26284 __TOC__ foo
26285
26286 __TOC__
26287 bar
26288 !! end
26289
26290 #### --------------- HTML tags ---------------
26291 #### 1. a tags
26292 #### 2. other tags
26293 #### 3. multi-line html tag
26294 #### 4. extension tags
26295 #### -----------------------------------------
26296 !! test
26297 1. a tags
26298 !! options
26299 parsoid=html2wt
26300 !! html/parsoid
26301 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
26302 !! wikitext
26303 <a href="http://google.com">google</a>
26304 !! end
26305
26306 !! test
26307 2. other tags
26308 !! options
26309 parsoid=html2wt
26310 !! html/parsoid
26311 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
26312 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
26313 <li> &lt;td&gt;</li></ul>
26314
26315 !! wikitext
26316 * <nowiki><div>foo</div></nowiki>
26317 * <nowiki><div style="color:red">foo</div></nowiki>
26318 * <nowiki><td></nowiki>
26319 !! end
26320
26321 !! test
26322 3. multi-line html tag
26323 !! options
26324 parsoid=html2wt
26325 !! html/parsoid
26326 <p>&lt;div
26327 &gt;foo&lt;/div
26328 &gt;
26329 </p>
26330 !! wikitext
26331 <nowiki><div
26332 >foo</div
26333 ></nowiki>
26334 !! end
26335
26336 !! test
26337 4. extension tags
26338 !! options
26339 parsoid=html2wt
26340 !! html/parsoid
26341 <p>&lt;ref&gt;foo&lt;/ref&gt;
26342 </p><p>&lt;ref&gt;bar
26343 </p><p>baz&lt;/ref&gt;
26344 </p>
26345 !! wikitext
26346 <nowiki><ref>foo</ref></nowiki>
26347
26348 <nowiki><ref>bar</nowiki>
26349
26350 baz<nowiki></ref></nowiki>
26351 !! end
26352
26353 #### --------------- Others ---------------
26354 !! test
26355 Escaping nowikis
26356 !! options
26357 parsoid=html2wt
26358 !! html/parsoid
26359 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
26360 </p>
26361 !! wikitext
26362 &lt;nowiki&gt;foo&lt;/nowiki&gt;
26363 !! end
26364
26365 ## The quote-char in the input is necessary for triggering the bug
26366 !! test
26367 (T54035) Nowiki-escaping should not get tripped by " :" in text
26368 !! options
26369 parsoid=html2wt
26370 !! html/parsoid
26371 <p>foo's bar :</p>
26372 !! wikitext
26373 foo's bar :
26374 !! end
26375
26376 #----------- End of wikitext escaping tests --------------
26377
26378 !! test
26379
26380 Tag-like HTML structures are passed through as text
26381 !! wikitext
26382 <x y>
26383
26384 <x.y>
26385
26386 <x-y>
26387
26388 1>2
26389
26390 x<y
26391
26392 a>b
26393
26394 1<d e>f
26395 !! html
26396 <p>&lt;x y&gt;
26397 </p><p>&lt;x.y&gt;
26398 </p><p>&lt;x-y&gt;
26399 </p><p>1&gt;2
26400 </p><p>x&lt;y
26401 </p><p>a&gt;b
26402 </p><p>1&lt;d e&gt;f
26403 </p>
26404 !! end
26405
26406 !! test
26407 HTML tag with necessary entities in attributes
26408 !! wikitext
26409 <span title="&amp;amp;">foo</span>
26410 !! html
26411 <p><span title="&amp;amp;">foo</span>
26412 </p>
26413 !! end
26414
26415 !! test
26416 HTML tag with 'unnecessary' entity encoding in attributes
26417 !! wikitext
26418 <span title="&amp;">foo</span>
26419 !! html
26420 <p><span title="&amp;">foo</span>
26421 </p>
26422 !! end
26423
26424 !! test
26425 HTML tag with broken attribute value quoting
26426 !! options
26427 parsoid=wt2html,html2html
26428 !! wikitext
26429 <span title="Hello world>Foo</span>
26430 !! html/php
26431 <p><span title="Hello world">Foo</span>
26432 </p>
26433 !! html/parsoid
26434 <p><span title="Hello world">Foo</span></p>
26435 !! end
26436
26437 !! test
26438 Self-closed tag with broken attribute value quoting
26439 !! options
26440 parsoid=wt2html,html2html
26441 !! wikitext
26442 <div title="Hello world />Foo
26443 !! html/php+tidy
26444 <div title="Hello world"></div><p>Foo
26445 </p>
26446 !! html/parsoid
26447 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
26448 !! end
26449
26450 !! test
26451 Table with broken attribute value quoting
26452 !! options
26453 parsoid=wt2html,html2html
26454 !! wikitext
26455 {|
26456 | title="Hello world|Foo
26457 |}
26458 !! html/php
26459 <table>
26460 <tr>
26461 <td title="Hello world">Foo
26462 </td></tr></table>
26463
26464 !! html/parsoid
26465 <table>
26466 <tr>
26467 <td title="Hello world">Foo
26468 </td></tr></table>
26469
26470 !! end
26471
26472 !! test
26473 Table with broken attribute value quoting on consecutive lines
26474 !! options
26475 parsoid=wt2html,html2html
26476 !! wikitext
26477 {|
26478 | title="Hello world|Foo
26479 | style="color:red|Bar
26480 |}
26481 !! html/php
26482 <table>
26483 <tr>
26484 <td title="Hello world">Foo
26485 </td>
26486 <td style="color:red">Bar
26487 </td></tr></table>
26488
26489 !! html/parsoid
26490 <table><tbody>
26491 <tr>
26492 <td title="Hello world">Foo
26493 </td><td style="color: red">Bar
26494 </td></tr></tbody></table>
26495
26496 !! end
26497
26498 !!test
26499 Accept empty td cell attribute
26500 !! wikitext
26501 {|
26502 | align="center" | foo || |
26503 |}
26504 !! html
26505 <table>
26506 <tr>
26507 <td align="center"> foo </td>
26508 <td>
26509 </td></tr></table>
26510
26511 !!end
26512
26513 !!test
26514 Non-empty attributes in th-cells
26515 !! wikitext
26516 {|
26517 ! Foo !! style="color: red" | Bar
26518 |}
26519 !! html
26520 <table>
26521 <tr>
26522 <th> Foo </th>
26523 <th style="color: red"> Bar
26524 </th></tr></table>
26525
26526 !!end
26527
26528 !!test
26529 Accept empty attributes in th-cells
26530 !! wikitext
26531 {|
26532 !| foo !!| bar
26533 |}
26534 !! html
26535 <table>
26536 <tr>
26537 <th> foo </th>
26538 <th> bar
26539 </th></tr></table>
26540
26541 !!end
26542
26543 !!test
26544 Empty table rows go away
26545 !! wikitext
26546 {|
26547 | Hello
26548 | there
26549 |- class="foo"
26550 |-
26551 |}
26552 !! html
26553 <table>
26554 <tr>
26555 <td> Hello
26556 </td>
26557 <td> there
26558 </td></tr>
26559
26560 </table>
26561
26562 !! end
26563
26564 ###
26565 ### Parsoid-centric tests for testing RTing of inter-element separators
26566 ### Edge cases not tested by existing parser tests and specific to
26567 ### Parsoid-specific serialization strategies.
26568 ###
26569
26570 !!test
26571 RT-ed inter-element separators should be valid separators
26572 !! wikitext
26573 {|
26574 |- [[foo]]
26575 |}
26576 !! html/php
26577 <table>
26578
26579 </table>
26580
26581 !! html/parsoid
26582 <table>
26583 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
26584 </tbody></table>
26585 !!end
26586
26587 # Parsoid-only test of a DOM pass
26588 !!test
26589 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
26590 !! wikitext
26591 {|
26592 |<small>foo
26593 bar
26594 |}
26595
26596 {|
26597 |<small>foo<small>
26598 |}
26599 !! html/parsoid
26600 <table>
26601 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
26602 <p>bar</p></small></td></tr>
26603 </tbody></table>
26604
26605 <table>
26606 <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>
26607 </tbody></table>
26608 !!end
26609
26610 # Note that the "style" attribute is really a template parameter here.
26611 # The = would have to be {{=}} if you wanted the literal.
26612 !!test
26613 Empty TD followed by TD with tpl-generated attribute
26614 !! wikitext
26615 {|
26616 |-
26617 |
26618 |{{echo|style='color:red'}}|foo
26619 |}
26620 !! html
26621 <table>
26622
26623 <tr>
26624 <td>
26625 </td>
26626 <td>foo
26627 </td></tr></table>
26628
26629 !!end
26630
26631 !!test
26632 Indented table with an empty td
26633 !! wikitext
26634 {|
26635 |-
26636 |
26637 |foo
26638 |}
26639 !! html
26640 <table>
26641
26642 <tr>
26643 <td>
26644 </td>
26645 <td>foo
26646 </td></tr></table>
26647
26648 !!end
26649
26650 ## We have some newline diffs RT-ing this edge case
26651 ## and it is not important enough -- we seem to be emitting
26652 ## at most 2 newlines after a </tr> and this is unrelated to
26653 ## the issue from T85627 that this is testing.
26654 !!test
26655 Indented table with blank lines in between (T85627)
26656 !! options
26657 parsoid=wt2html
26658 !! wikitext
26659 {|
26660 |foo
26661
26662
26663 |}
26664 !! html
26665 <table>
26666
26667 <tr>
26668 <td>foo
26669 </td></tr></table>
26670
26671 !!end
26672
26673 !!test
26674 Indented block & table
26675 !! wikitext
26676 <div>foo</div>
26677 {|
26678 |foo
26679 |}
26680 !! html/php
26681 <div>foo</div>
26682 <table>
26683 <tr>
26684 <td>foo
26685 </td></tr></table>
26686
26687 !! html/parsoid
26688 <div data-parsoid='{"stx":"html"}'>foo</div>
26689 <table><tbody>
26690 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
26691 </tbody></table>
26692 !!end
26693
26694 !! test
26695 Indent and comment before table row
26696 !! wikitext
26697 {|
26698 <!--hi-->|-
26699 | there
26700 |}
26701 !! html/php
26702 <table>
26703
26704 <tr>
26705 <td> there
26706 </td></tr></table>
26707
26708 !! html/parsoid
26709 <table>
26710 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
26711 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
26712 </tbody></table>
26713 !! end
26714
26715 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
26716 !!test
26717 Empty TR followed by a template-generated TR
26718 !!options
26719 parsoid
26720 !! wikitext
26721 {|
26722 |-
26723 {{echo|<tr><td>foo</td></tr>}}
26724 |}
26725 !! html
26726 <table>
26727 <tbody>
26728 <tr class='mw-empty-elt'></tr>
26729 <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}}]}'>
26730 <td>foo</td></tr>
26731 </tbody></table>
26732 !!end
26733
26734 ## PHP and parsoid output differ for this, and since this is primarily
26735 ## for testing Parsoid's serializer, marking this Parsoid only
26736 !!test
26737 Empty TR followed by mixed-ws-comment line should RT correctly
26738 !!options
26739 parsoid
26740 !! wikitext
26741 {|
26742 |-
26743 <!--c-->
26744 |-
26745 <!--c--> <!--d-->
26746 |}
26747 !! html
26748 <table>
26749 <tbody>
26750 <tr class='mw-empty-elt'></tr>
26751 <!--c-->
26752 <tr>
26753 <!--c--> </tr><!--d-->
26754 </tbody></table>
26755
26756 !!end
26757
26758 !!test
26759 Multi-line image caption generated by templates with/without trailing newlines
26760 !! wikitext
26761 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
26762 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
26763 !! html/parsoid
26764 <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>
26765 <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>
26766 !!end
26767
26768 !! test
26769 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
26770 !! options
26771 parsoid=html2wt
26772 !! html/parsoid
26773 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>foo&lt;/includeonly>"}'/><meta typeof="mw:Includes/IncludeOnly/End" data-parsoid='{"src":""}'/><p>new para</p>
26774
26775 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
26776 !! wikitext
26777 <includeonly>foo</includeonly>
26778 new para
26779
26780 [[Category:Foo]]
26781
26782 = new heading =
26783 !! end
26784
26785 ## PHP emits broken html for this, and since this is primarily
26786 ## a Parsoid serializer test, marking this Parsoid only
26787 !!test
26788 Improperly nested inline or quotes tags with whitespace in between
26789 !! wikitext
26790 <span> <s>x</span> </s>
26791 ''' ''x''' ''
26792 !! html/parsoid
26793 <p><span> <s>x</s></span><s> </s>
26794 <b> <i>x</i></b><i> </i>
26795 </p>
26796 !!end
26797
26798 !!test
26799 Encapsulate protected attributes from wt
26800 !! wikitext
26801 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
26802
26803 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
26804 | ok
26805 |}
26806 !! html/parsoid
26807 <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>
26808
26809 <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">
26810 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'> ok</td></tr>
26811 </tbody></table>
26812 !!end
26813
26814 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
26815 ## Having nested or stray pre tags results in the attempt to add duplicates,
26816 ## causing an assertion fail. This test tries to prevent that situation.
26817 !!test
26818 Ensure ParagraphWrapper can deal with stray closing pre tags
26819 !!options
26820 parsoid=wt2html
26821 !! wikitext
26822 plain text</pre>
26823 !! html/parsoid
26824 plain text
26825 !!end
26826
26827 !!test
26828 1. Ensure fostered text content is wrapped in element nodes
26829 !!options
26830 parsoid=wt2html
26831 !! wikitext
26832 <table>hi</table><table>ho</table>
26833 !! html/parsoid
26834 <p>hi</p>
26835 <table></table>
26836 <p>ho</p>
26837 <table></table>
26838 !!end
26839
26840 !!test
26841 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
26842 !!options
26843 parsoid=wt2html,wt2wt
26844 !! wikitext
26845 <table>
26846 <tr> || ||
26847 <td> a
26848 </table>
26849 !! html/parsoid
26850 <p> || ||
26851 </p><table>
26852 <tbody><tr><td> a</td></tr>
26853 </tbody></table>
26854 !!end
26855
26856 !!test
26857 Encapsulation properly handles null DSR information from foster box
26858 !!options
26859 parsoid=wt2html,wt2wt
26860 !! wikitext
26861 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
26862 !! html/parsoid
26863 <span typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;<table>foo<tr><td>bar</td></tr></table>&quot;}},&quot;i&quot;:0}}]}">foo</span><table><tbody><tr><td>bar</td></tr></tbody></table>
26864 !!end
26865
26866 !!test
26867 1. Encapsulate foster-parented transclusion content
26868 !!options
26869 parsoid=wt2wt,wt2html
26870 !! wikitext
26871 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
26872 !! html/parsoid
26873 <p typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table>&quot;,{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo<tr><td>bar</td></tr>&quot;}},&quot;i&quot;:0}},&quot;</table>&quot;]}">foo</p><table>
26874 <tbody>
26875 <tr>
26876 <td>bar</td>
26877 </tr>
26878 </tbody>
26879 </table>
26880 !!end
26881
26882 !!test
26883 2. Encapsulate foster-parented transclusion content
26884 !!options
26885 parsoid=wt2wt,wt2html
26886 !! wikitext
26887 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
26888 !! html/parsoid
26889 <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>
26890 <table>
26891 <tbody>
26892 <tr>
26893 <td>bar</td>
26894 </tr>
26895 </tbody>
26896 </table>
26897 !!end
26898
26899 !!test
26900 3. Encapsulate foster-parented transclusion content
26901 !!options
26902 parsoid=wt2wt,wt2html
26903 !! wikitext
26904 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
26905 !! html/parsoid
26906 <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;]}">
26907 <p>foo</p>
26908 </div>
26909 <table>
26910 <tbody>
26911 <tr>
26912 <td>bar</td>
26913 </tr>
26914 </tbody>
26915 </table>
26916 !!end
26917
26918 !!test
26919 4. Encapsulate foster-parented transclusion content
26920 !!options
26921 parsoid=wt2wt,wt2html
26922 !! wikitext
26923 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
26924 !! html/parsoid
26925 <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;]}">
26926 <p>foo</p>
26927 </div>
26928 <table>
26929 <tbody>
26930 <tr>
26931 <td>bar</td>
26932 </tr>
26933 </tbody>
26934 </table>
26935 !!end
26936
26937 !!test
26938 5. Encapsulate foster-parented transclusion content
26939 !!options
26940 parsoid=wt2wt,wt2html
26941 !! wikitext
26942 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
26943 !! html/parsoid
26944 <p typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table><tr><td><div><p>&quot;,{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo</p></div></td>foo&quot;}},&quot;i&quot;:0}},&quot;</tr></table>&quot;]}">foo</p>
26945 <table>
26946 <tbody>
26947 <tr>
26948 <td>
26949 <div>
26950 <p>foo</p>
26951 </div>
26952 </td>
26953 </tr>
26954 </tbody>
26955 </table>
26956 !!end
26957
26958 !!test
26959 6. Encapsulate foster-parented transclusion content
26960 !!options
26961 parsoid=wt2wt,wt2html
26962 !! wikitext
26963 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
26964 !! html/parsoid
26965 <p typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table><tr><td><div><p>&quot;,{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo</p></div></td>foo</tr></table>&quot;}},&quot;i&quot;:0}}]}">foo</p>
26966 <table>
26967 <tbody>
26968 <tr>
26969 <td>
26970 <div>
26971 <p>foo</p>
26972 </div>
26973 </td>
26974 </tr>
26975 </tbody>
26976 </table>
26977 <p>ok</p>
26978 !!end
26979
26980 !!test
26981 7. Encapsulate foster-parented transclusion content
26982 !!options
26983 parsoid=wt2wt,wt2html
26984 !! wikitext
26985 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
26986 !! html/parsoid
26987 <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>
26988 <table>
26989 <tbody>
26990 <tr>
26991 <td>bar</td>
26992 </tr>
26993 </tbody>
26994 </table>
26995 !!end
26996
26997 # Note that the wt is broken on purpose: the = should be {{=}} if you
26998 # don't want it to be a template parameter key.
26999 !!test
27000 8. Encapsulate foster-parented transclusion content
27001 !!options
27002 parsoid=wt2wt,wt2html
27003 !! wikitext
27004 {{echo|a
27005 }}{|{{echo|style='color:red'}}
27006 |-
27007 |b
27008 |}
27009 !! html/parsoid
27010 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}'>a</p>
27011 <span> </span>
27012 <p typeof="mw:Transclusion" data-mw='{"parts":["{|",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"style":{"wt":"&#39;color:red&#39;"}},"i":0}},"\n|-\n|b\n|}"]}'>{{{1}}}</p>
27013 <table>
27014 <tbody>
27015 <tr>
27016 <td>b</td>
27017 </tr>
27018 </tbody>
27019 </table>
27020 !!end
27021
27022 !!test
27023 9. Encapsulate foster-parented transclusion content
27024 !!options
27025 parsoid=wt2wt,wt2html
27026 !! wikitext
27027 <table>{{echo|hi</table>hello}}
27028 !! html/parsoid
27029 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":["&lt;table>",{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi&lt;/table>hello"}},"i":0}}]}' data-parsoid='{"fostered":true,"autoInsertedEnd":true,"autoInsertedStart":true,"pi":[[{"k":"1"}]]}'>hi</p><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><p about="#mwt2">hello</p>
27030 !!end
27031
27032 !!test
27033 Table in fosterable position
27034 !!options
27035 parsoid=wt2html
27036 !! wikitext
27037 {{OpenTable}}
27038 <div>
27039 {|
27040 |}
27041 </div>
27042 |}
27043 !! html/parsoid
27044 <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">
27045 </span>
27046 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
27047
27048 <table>
27049 </table>
27050 !!end
27051
27052 # Parsoid only for T66747
27053 !! test
27054 Properly encapsulate empty-content transclusions in fosterable positions
27055 !! wikitext
27056 <table>
27057 {{#if:|
27058 <td>foo</td>
27059 }}
27060 </table>
27061 !! html/parsoid
27062 <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"}]]}'>
27063
27064 </table>
27065 !! end
27066
27067 !! test
27068 Always encapsulate foster box when template range is expanded to table
27069 !! options
27070 parsoid=wt2wt
27071 !! wikitext
27072 {|
27073 hello
27074 {{OpenTable}}
27075 |}
27076 !! html/parsoid
27077
27078 !! end
27079
27080 !! test
27081 T115289: Unclosed table
27082 !! wikitext
27083 {{echo|<table>}}<!--c-->[[Category:Two]]
27084 !! html/parsoid
27085 <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>
27086 !! end
27087
27088 !! test
27089 T115289: Don't migrate newlines out of tables with fostered content
27090 !! wikitext
27091 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
27092 !! html/parsoid
27093 <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>
27094 !! end
27095
27096 !! test
27097 T73074: More fostering fun
27098 !! wikitext
27099 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
27100 !! html/parsoid
27101 <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>
27102 !! end
27103
27104 !!test
27105 Support <object> element with .data attribute
27106 !!options
27107 parsoid=html2wt
27108 !! html/parsoid
27109 <object data="test.swf"></object>
27110 !! wikitext
27111 <object data="test.swf"></object>
27112 !!end
27113
27114 !! test
27115 Don't block XML namespace declaration
27116 !! wikitext
27117 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27118 !! html/php
27119 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27120 </p>
27121 !! html/parsoid
27122 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
27123 !! end
27124
27125 # -----------------------------------------------------------------
27126 # The following section of tests are primarily to spec requirements
27127 # around Parsoid's serialization (old, new, edited content)
27128 #
27129 # All these tests are marked Parsoid html2wt and html2html only
27130 # ----------------------------------------------------------------
27131
27132 !! test
27133 Ignore rel attribute in a-tags during serialization to url-links
27134 !! options
27135 parsoid=html2wt
27136 !! html/parsoid
27137 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
27138 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
27139 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
27140 !! wikitext
27141 http://en.wikipedia.org/wiki/Foobar
27142 http://en.wikipedia.org/wiki/Foobar
27143 http://en.wikipedia.org/wiki/Foobar
27144 !! end
27145
27146 # 'mi' is a localinterwiki prefix as well as a language
27147 !! test
27148 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
27149 !! options
27150 parsoid=html2wt
27151 !! html/parsoid
27152 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
27153 !! wikitext
27154 [[Foo]]
27155 !! end
27156
27157 !! test
27158 Parsoid should accept interwiki shortcuts
27159 !! options
27160 parsoid=html2wt
27161 !! html/parsoid
27162 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
27163 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
27164 <a href='./fr:Foo'>Foo</a></p>
27165 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
27166 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
27167 <a href='fr%3AFoo'>Foo</a></p>
27168 <p><a href='FR%3AFoo'>Foo</a>
27169 <a href='./FR:Foo'>Foo</a></p>
27170 !! wikitext
27171 [[:fr:Foo|Foo]]
27172 [[:fr:Foo|Foo]]
27173 [[:fr:Foo|Foo]]
27174
27175 [[:fr:Foo|Foo]]
27176 [[:fr:Foo|Foo]]
27177 [[:fr:Foo|Foo]]
27178
27179 [[:fr:Foo|Foo]]
27180 [[:fr:Foo|Foo]]
27181 !! end
27182
27183 !! test
27184 Parsoid should not accept invalid interwiki shortcuts
27185 !! options
27186 parsoid=html2wt
27187 !! html/parsoid
27188 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
27189 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
27190 <a href='news:Foo'>Foo</a></p>
27191 !! wikitext
27192 [news:Foo Foo]
27193 [news:Foo Foo]
27194 [news:Foo Foo]
27195 !! end
27196
27197 # See T93839
27198 !! test
27199 New wikilinks should be serialized properly
27200 !! options
27201 parsoid=html2wt
27202 !! html/parsoid
27203 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
27204 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
27205 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
27206 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
27207 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
27208 !! wikitext
27209 [[Foo]]
27210 [[Foo]]
27211 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
27212 http://en.wikipedia.org/wiki/Foo
27213 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
27214 !! end
27215
27216 !! test
27217 New wiki links (href variations)
27218 !! options
27219 parsoid=html2wt
27220 !! html/parsoid
27221 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27222 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
27223 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
27224 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
27225 !! wikitext
27226 [[Foo_bar]]
27227 [[Foo_bar]]
27228 [[Foo_bar]]
27229 [[Toxine bactérienne]]
27230 !! end
27231
27232 !! test
27233 New wiki links (content string variations)
27234 !! options
27235 parsoid=html2wt
27236 !! html/parsoid
27237 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27238 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
27239 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
27240 !! wikitext
27241 [[Foo_bar]]
27242 [[Foo bar]]
27243 [[Foo_bar|./Foo_bar]]
27244 !! end
27245
27246 !! test
27247 New category links (href variations)
27248 !! options
27249 parsoid=html2wt
27250 !! html/parsoid
27251 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
27252 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
27253 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
27254 !! wikitext
27255 [[Category:Toxine bactérienne]]
27256 [[Category:Toxine bactérienne]]
27257 [[Category:Toxine bactérienne]]
27258 !! end
27259
27260 !! test
27261 New sol transparent links don't need indent-pre nowiki protection
27262 !! options
27263 parsoid=html2wt
27264 language=de
27265 !! html/parsoid
27266 <link rel="mw:PageProp/redirect" href="./Main_Page">
27267 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
27268 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
27269 !! wikitext
27270 #WEITERLEITUNG [[Main Page]]
27271 <!-- this is good --> [[Category:Good]]
27272 <!-- this is great --> [[Kategorie:Great]]
27273 !! end
27274
27275 !! test
27276 New interlanguage links (href variations)
27277 !! options
27278 parsoid=html2wt
27279 !! html/parsoid
27280 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
27281 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
27282 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
27283 !! wikitext
27284 [[es:Toxine bactérienne]]
27285 [[es:Toxine_bactérienne]]
27286 [[es:Toxine_bactérienne]]
27287 !! end
27288
27289 !! test
27290 Image: Modifying size of an image (1)
27291 !! options
27292 parsoid={
27293 "modes": ["wt2wt"],
27294 "changes": [
27295 ["img[height]", "attr", "height", "22"],
27296 ["img[width]", "attr", "width", "200"]
27297 ]
27298 }
27299 !! wikitext
27300 [[Image:Foobar.jpg|230x230px]]
27301 !! wikitext/edited
27302 [[Image:Foobar.jpg|200x200px]]
27303 !!end
27304
27305 !! test
27306 Image: Modifying size of an image (2)
27307 !! options
27308 parsoid={
27309 "modes": ["wt2wt"],
27310 "changes": [
27311 ["img[height]", "attr", "height", "100"],
27312 ["img[width]", "attr", "width", "500"]
27313 ]
27314 }
27315 !! wikitext
27316 [[Image:Foobar.jpg|230x230px]]
27317 !! wikitext/edited
27318 [[Image:Foobar.jpg|500x500px]]
27319 !!end
27320
27321 # Change in size is ignored so long as class='mw-default-size'
27322 !! test
27323 Image: Modifying size of an image (3)
27324 !! options
27325 parsoid={
27326 "modes": ["wt2wt"],
27327 "changes": [
27328 ["figure[class]", "removeClass", "mw-default-size"],
27329 ["figure img", "attr", "height", "19"],
27330 ["figure img", "attr", "width", "170"]
27331 ]
27332 }
27333 !! wikitext
27334 [[Image:Foobar.jpg|thumb]]
27335 !! wikitext/edited
27336 [[Image:Foobar.jpg|thumb|170x170px]]
27337 !!end
27338
27339 !! test
27340 Image: Modifying alignment of an image (T50665)
27341 !! options
27342 parsoid={
27343 "modes": ["wt2wt"],
27344 "changes": [
27345 ["figure[class]", "removeClass", "mw-halign-right"],
27346 ["figure[class]", "addClass", "mw-halign-left"]
27347 ]
27348 }
27349 !! wikitext
27350 [[Image:Foobar.jpg|thumb|caption|right]]
27351 !! wikitext/edited
27352 [[Image:Foobar.jpg|thumb|caption|left]]
27353 !! end
27354
27355 !! test
27356 Image: Modifying mw-default-size of an frameless image (T64805)
27357 !! options
27358 parsoid={
27359 "modes": ["wt2wt"],
27360 "changes": [
27361 ["figure.mw-default-size", "removeClass", "mw-default-size"]
27362 ]
27363 }
27364 !! wikitext
27365 [[Image:Foobar.jpg|frameless|right]]
27366 !! wikitext/edited
27367 [[Image:Foobar.jpg|frameless|right|220x220px]]
27368 !! end
27369
27370 !! test
27371 Image: Modifying valign of an image (T51221)
27372 !! options
27373 parsoid={
27374 "modes": ["wt2wt"],
27375 "changes": [
27376 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
27377 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
27378 ]
27379 }
27380 !! wikitext
27381 [[File:Foobar.jpg|20px|middle]]
27382 !! wikitext/edited
27383 [[File:Foobar.jpg|20px|text-top]]
27384 !! end
27385
27386 !! test
27387 Image: Modifying alt attribute of an image (T58400)
27388 !! options
27389 parsoid={
27390 "modes": ["wt2wt"],
27391 "changes": [
27392 ["img[alt]", "attr", "alt", "some alternate edited text"]
27393 ]
27394 }
27395 !! wikitext
27396 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
27397 !! wikitext/edited
27398 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
27399 !!end
27400
27401 !! test
27402 Image: Modifying caption of an image
27403 !! options
27404 parsoid={
27405 "modes": ["wt2wt"],
27406 "changes": [
27407 ["figcaption", "text", "new caption"]
27408 ]
27409 }
27410 !! wikitext
27411 [[Image:Foobar.jpg|thumb|original caption]]
27412 !! wikitext/edited
27413 [[Image:Foobar.jpg|thumb|new caption]]
27414 !!end
27415
27416 !! test
27417 Image: empty alt attribute (T50924)
27418 !! options
27419 parsoid
27420 !! wikitext
27421 [[File:Foobar.jpg|thumb|alt=|bar]]
27422 !! html
27423 <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>
27424 !! end
27425
27426 !! test
27427 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
27428 !! options
27429 parsoid=html2wt
27430 language=ar
27431 disabled
27432 !! html/parsoid
27433 <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>
27434 !! wikitext
27435 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
27436 !! end
27437
27438 !! test
27439 Image: Block level image should have \n before and after
27440 !! wikitext
27441 123
27442 [[File:Foobar.jpg|right|thumb|150x150px]]
27443 456
27444 !! html/parsoid
27445 <p>123</p>
27446 <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>
27447 <p>456</p>
27448 !! end
27449
27450 !! test
27451 Image: New block level image should have \n before and after (existing content)
27452 !! wikitext
27453 123
27454 [[File:Foobar.jpg|right|thumb|150x150px]]
27455 456
27456 !! html/parsoid
27457 <p>123</p>
27458 <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>
27459 <p>456</p>
27460 !! end
27461
27462 !! test
27463 Image: upright option (parsoid)
27464 !! wikitext
27465 [[File:Foobar.jpg|thumb|upright|caption]]
27466 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
27467 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
27468 !! html/parsoid
27469 <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>
27470 <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>
27471 <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>
27472 !! end
27473
27474 !! test
27475 Image: upright option is ignored on inline and frame images (parsoid)
27476 !! wikitext
27477 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
27478 !! html/parsoid
27479 <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>
27480 !! end
27481
27482 !! test
27483 Image: in template parameter with empty parameter
27484 !! wikitext
27485 {{echo|[[File:Foobar.jpg|link=]]}}
27486 !! html/parsoid
27487 <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>
27488 !! end
27489
27490 !! test
27491 Image: from basic HTML (1)
27492 !! options
27493 parsoid=html2wt
27494 !! html/parsoid
27495 <span typeof="mw:Image">
27496 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27497 </span>
27498 !! wikitext
27499 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27500 !! end
27501
27502 !! test
27503 Image: from basic HTML (2)
27504 !! options
27505 parsoid=html2wt
27506 !! html/parsoid
27507 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27508 !! wikitext
27509 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27510 !! end
27511
27512 !! test
27513 Image: from basic HTML (3)
27514 !! options
27515 parsoid=html2wt
27516 !! html/parsoid
27517 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
27518 !! wikitext
27519 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
27520 !! end
27521
27522 !! test
27523 Image: from basic HTML (4)
27524 !! options
27525 parsoid=html2wt
27526 !! html/parsoid
27527 <img src="./File:Foobar.jpg">
27528 !! wikitext
27529 [[File:Foobar.jpg|link=]]
27530 !! end
27531
27532 !! test
27533 Image: Invalid title as link
27534 !! wikitext
27535 [[File:Foobar.jpg|link=<]]
27536 !! html/php
27537 <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>
27538 </p>
27539 !! html/parsoid
27540 <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>
27541 !! end
27542
27543 !! test
27544 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
27545 !! options
27546 parsoid=html2wt
27547 !! html/parsoid
27548 <ul>
27549 <li><p>foo</p></li>
27550 </ul>
27551 !! wikitext
27552 * foo
27553 !! end
27554
27555 !! test
27556 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
27557 !! options
27558 parsoid=html2wt
27559 !! html/parsoid
27560 <ul> <li>foo</li></ul>
27561 !! wikitext
27562 * foo
27563 !! end
27564
27565 !! test
27566 Don't strip leading whitespace when handling indent-pre suppressing tags
27567 !! options
27568 parsoid=html2wt
27569 !! html/parsoid
27570 <table>
27571 <tr><td> indented row</td></tr>
27572 </table>
27573 <blockquote><p>
27574 <b>This is very bold of you!</b>
27575 </p>
27576 <table><tr><td>
27577 indented cell (no pre-wrapping!)
27578 </td></tr></table>
27579 </blockquote>
27580 <p>foo</p>
27581 <div>bar</div>
27582 !! wikitext
27583 {|
27584 | indented row
27585 |}
27586 <blockquote>
27587 '''This is very bold of you!'''
27588
27589 {|
27590 |
27591 indented cell (no pre-wrapping!)
27592 |}
27593 </blockquote>
27594 foo
27595 <div>bar</div>
27596 !! end
27597
27598 !! test
27599 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
27600 !! options
27601 parsoid=html2wt
27602 !! html/parsoid
27603 <p>foo</p>
27604 <span>bar</span>
27605
27606 <span>foo2
27607 </span>bar2
27608
27609 <div>foo</div>
27610 <span>bar</span>
27611
27612 <div>
27613 <span>foo</span>
27614 </div>
27615 !! wikitext
27616 foo
27617
27618 <span>bar</span>
27619
27620 <span>foo2
27621 <nowiki> </nowiki></span>bar2
27622
27623 <div>foo</div>
27624 <nowiki> </nowiki><span>bar</span>
27625
27626 <div>
27627 <nowiki> </nowiki><span>foo</span>
27628 </div>
27629 !! end
27630
27631 !! test
27632 Lists: Dont insert newlines in a serialized list item.
27633 !! options
27634 parsoid=html2wt
27635 !! html/parsoid
27636 <ul><li>a<br>b</li><li>c</li></ul>
27637 !! wikitext
27638 * a<br>b
27639 * c
27640 !! end
27641
27642 !! test
27643 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
27644 !! options
27645 parsoid={
27646 "modes": ["html2wt"],
27647 "scrubWikitext": false
27648 }
27649 !! html/parsoid
27650 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
27651 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
27652
27653 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
27654 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
27655
27656 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
27657
27658 <h2><meta property="mw:PageProp/toc" /> ok</h2>
27659 !! wikitext
27660 == hello there [[Category:A1]] ==
27661
27662 == [[Category:A2]] hi pal ==
27663
27664 == <!--foo--> [[Category:A3]] how goes it ==
27665
27666 == it goes well [[Category:A4]] <!--bar--> ==
27667
27668 ==howdy [[Category:A5]]==
27669
27670 == __TOC__ ok ==
27671 !! end
27672
27673 !! test
27674 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
27675 !! options
27676 parsoid={
27677 "modes": ["html2wt"],
27678 "scrubWikitext": true
27679 }
27680 !! html/parsoid
27681 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
27682 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
27683
27684 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
27685 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
27686
27687 <h2><meta property="mw:PageProp/toc" /> ok</h2>
27688 !! wikitext
27689 == hello there ==
27690 [[Category:A1]]
27691 [[Category:A2]]
27692
27693 == hi pal ==
27694
27695 <!--foo--> [[Category:A3]]
27696
27697 == how goes it ==
27698
27699 == it goes well ==
27700 [[Category:A4]] <!--bar-->
27701
27702 __TOC__
27703
27704 == ok ==
27705 !! end
27706
27707 !! test
27708 Headings: Don't hoist metas that come from templates
27709 !! options
27710 parsoid={
27711 "modes": ["html2wt"],
27712 "scrubWikitext": true
27713 }
27714 !! html/parsoid
27715 <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>
27716 !! wikitext
27717 == {{echo|foo [[Category:Foo]]}} ==
27718 !! end
27719
27720 !! test
27721 Headings: Category in ref isn't hoisted
27722 !! options
27723 parsoid={
27724 "modes": ["html2wt"],
27725 "scrubWikitext": true
27726 }
27727 !! html/parsoid
27728 <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>
27729
27730 <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>
27731 !! wikitext
27732 == foo <ref>bar
27733 [[Category:Baz]] </ref> ==
27734
27735 <references />
27736 !! end
27737
27738 !! test
27739 Parsoid: Serialize positional parameters with = in them as named parameter
27740 !! options
27741 parsoid=html2wt
27742 !! html/parsoid
27743 <p about="#mwt1" typeof="mw:Transclusion"
27744 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
27745
27746 <p about="#mwt1" typeof="mw:Transclusion"
27747 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
27748
27749 <!--Orig params with data-parsoid has heuristics for handling = chars-->
27750 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
27751 <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>
27752 !! wikitext
27753 {{echo|1=f=oo}}
27754
27755 {{echo|1=f=oo|2=bar}}
27756
27757 <!--Orig params with data-parsoid has heuristics for handling = chars-->
27758 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
27759 {{echo|<nowiki>f=oo</nowiki>|bar}}
27760 !! end
27761
27762 !! test
27763 Parsoid: Serialize positional parameters with = in extlink as named parameter
27764 !! options
27765 parsoid=html2wt
27766 !! html/parsoid
27767 <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>
27768 !! wikitext
27769 {{echo|1=http://stuff?is=ok}}
27770 !! end
27771
27772 !! test
27773 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
27774 !! options
27775 parsoid=html2wt
27776 !! html/parsoid
27777 <div>a<p>b</p></div>
27778 <div>a
27779 <p>b</p></div>
27780 <div>
27781 a
27782 <p>b</p></div>
27783 !! wikitext
27784 <div>a
27785 b
27786 </div>
27787 <div>a
27788 b
27789 </div>
27790 <div>
27791 a
27792
27793 b
27794 </div>
27795 !! end
27796
27797 !! test
27798 Substrings resembling wikitext in hrefs should not get nowiki escapes
27799 !! options
27800 parsoid=html2wt
27801 !! html/parsoid
27802 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
27803 !! wikitext
27804 [[Foo''bar''baz]]
27805 !! end
27806
27807 !! test
27808 Enforce single-line context in the serializer
27809 !! options
27810 parsoid=html2wt
27811 !! html/parsoid
27812 <h2>testing
27813 123</h2>
27814
27815 <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">
27816 </span><span about="#mwt1">you</span> </h2>
27817
27818 <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>
27819
27820 <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
27821 there</span></li></ol>
27822
27823 <ul><li>asd
27824 sdf</li></ul>
27825
27826 <ul><li>foo
27827 bar
27828 baz</li>
27829 <li>foo <b>bar</b>
27830 baz</li></ul>
27831
27832 <dl><dt>hi
27833 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
27834 ho</dd></dl>
27835
27836 <dl><dd> <table>
27837 <tbody><tr><td> ha
27838 ha
27839 ha</td></tr>
27840 </tbody></table></dd></dl>
27841 !! wikitext
27842 == testing 123 ==
27843
27844 == hi {{bogus|there
27845 you}} ==
27846
27847 == foo <ref>hello
27848 there</ref> ==
27849
27850 <references />
27851
27852 * asd sdf
27853
27854 * foo bar baz
27855 * foo '''bar''' baz
27856
27857 ; hi ho : hi ho
27858
27859 : {|
27860 | ha
27861 ha
27862 ha
27863 |}
27864 !! end
27865
27866 !! test
27867 Serialize new placeholder space without spans
27868 !! options
27869 parsoid=html2wt
27870 !! html/parsoid
27871 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
27872
27873 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
27874
27875 <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>
27876 !! wikitext
27877 foo : bar
27878
27879 foo : bar
27880
27881 <ref>foo : bar</ref>ok
27882 !! end
27883
27884
27885 #-----------------------
27886 # Tag minimization tests
27887 #-----------------------
27888
27889 !! test
27890 1. I/B quote minimization: wikitext-only tags should be combined
27891 !! options
27892 parsoid=html2wt
27893 !! html/parsoid
27894 <p><i>A</i><i>B</i></p>
27895 <p><b>A</b><b>B</b></p>
27896 <p><i>A</i><b><i>B</i></b></p>
27897 <p><b>A</b><i><b>B</b></i></p>
27898 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
27899 <p><i><b>A</b></i><i><b>B</b></i></p>
27900 <p><i><b>A</b></i><b><i>B</i></b></p>
27901 <p><b><i>A</i></b><i><b>B</b></i></p>
27902 !! wikitext
27903 ''AB''
27904
27905 '''AB'''
27906
27907 ''A'''B'''''
27908
27909 '''A''B'''''
27910
27911 '''A''BC''D'''
27912
27913 '''''AB'''''
27914
27915 '''''AB'''''
27916
27917 '''''AB'''''
27918 !! end
27919
27920 !! test
27921 2. I/B quote minimization: wikitext and html tags should not be combined
27922 !! options
27923 parsoid=html2wt
27924 !! html/parsoid
27925 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
27926 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
27927 !! wikitext
27928 ''A''<i>B</i>
27929
27930 ''A''<nowiki/>'''<i>B</i>'''
27931 !! end
27932
27933 !! test
27934 3. I/B quote minimization: templated content stops minimization
27935 !! options
27936 parsoid=html2wt
27937 !! html/parsoid
27938 <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>
27939 <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>
27940 !! wikitext
27941 ''A''{{echo|''B''}}
27942
27943 ''A''{{echo|'''''B'''''}}
27944 !! end
27945
27946 !! test
27947 4. I/B quote minimization: new content should be mimimized with adjacent old content
27948 !! options
27949 parsoid=html2wt
27950 !! html/parsoid
27951 <p><i>A</i><i>B</i></p>
27952 <p><b>A</b><b>B</b></p>
27953 <p><i>A</i><b><i>B</i></b></p>
27954 !! wikitext
27955 ''AB''
27956
27957 '''AB'''
27958
27959 ''A'''B'''''
27960 !! end
27961
27962 !! test
27963 5a. Merge adjacent quote nodes if they've been edited
27964 !! options
27965 parsoid={
27966 "modes": ["wt2wt", "selser"],
27967 "changes": [
27968 ["p", "contents", "remove", ":contains('b')"]
27969 ]
27970 }
27971 !! wikitext
27972 ''a''b''c''
27973 !! wikitext/edited
27974 ''ac''
27975 !! end
27976
27977 !! test
27978 5b. Merge adjacent quote nodes if they've been edited
27979 !! options
27980 parsoid={
27981 "modes": ["wt2wt", "selser"],
27982 "changes": [
27983 ["#x", "remove"]
27984 ]
27985 }
27986 !! wikitext
27987 ''a''<span id="x">b</span>''c''
27988 !! wikitext/edited
27989 ''ac''
27990 !! end
27991
27992 !! test
27993 1. Merge adjacent link nodes as long as at least one element is new
27994 !! options
27995 parsoid={
27996 "modes": ["html2wt"],
27997 "scrubWikitext": true
27998 }
27999 !! html/parsoid
28000 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28001 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28002 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
28003 !! wikitext
28004 [[Football]]
28005 [[Football]]
28006 [[Football|Foot]][[Football|ball]]
28007 !! end
28008
28009 !! test
28010 2. Merge adjacent link nodes and enable additional normalizations
28011 !! options
28012 parsoid={
28013 "modes": ["html2wt"],
28014 "scrubWikitext": true
28015 }
28016 !! html/parsoid
28017 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
28018 !! wikitext
28019 [[Football|''Football'']]
28020 !! end
28021
28022 !! test
28023 3. Don't merge adjacent link nodes if scrubWikitext is false
28024 !! options
28025 parsoid={
28026 "modes": ["html2wt"],
28027 "scrubWikitext": false
28028 }
28029 !! html/parsoid
28030 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28031 !! wikitext
28032 [[Football|Foot]][[Football|ball]]
28033 !! end
28034
28035 #------------------------------
28036 # End of tag minimization tests
28037 #------------------------------
28038
28039 !!test
28040 T56262: New entities
28041 !! options
28042 parsoid=html2wt
28043 !! html/parsoid
28044 <span typeof="mw:Entity">&nbsp;</span>
28045 !! wikitext
28046 &nbsp;
28047 !! end
28048
28049 ## Note that there is no wikitext output for 'unknownproperty' ##
28050 ## Unknown magic words are silently dropped ##
28051
28052 !! test
28053 Magic words
28054 !! options
28055 parsoid=html2wt
28056 !! html/parsoid
28057 <meta property='mw:PageProp/toc' />
28058 <meta property='mw:PageProp/notoc' />
28059 <meta property='mw:PageProp/forcetoc' />
28060 <meta property='mw:PageProp/index' />
28061 <meta property='mw:PageProp/noindex' />
28062 <meta property='mw:PageProp/nogallery' />
28063 <meta property='mw:PageProp/noeditsection' />
28064 <meta property='mw:PageProp/notitleconvert' />
28065 <meta property='mw:PageProp/nocontentconvert' />
28066 <meta property='mw:PageProp/unknownproperty' />
28067 !! wikitext
28068 __TOC__
28069 __NOTOC__
28070 __FORCETOC__
28071 __INDEX__
28072 __NOINDEX__
28073 __NOGALLERY__
28074 __NOEDITSECTION__
28075 __NOTITLECONVERT__
28076 __NOCONTENTCONVERT__
28077 !! end
28078
28079 !! test
28080 Consecutive <pre>s should not get merged
28081 !! options
28082 parsoid=html2wt,html2html
28083 !! html/parsoid
28084 <pre>a</pre><pre>b</pre>
28085
28086 <pre>c
28087 </pre><pre>
28088 d</pre>
28089
28090 <pre>e
28091
28092 </pre><pre>
28093
28094 f</pre>
28095 !! wikitext
28096 a
28097
28098 b
28099
28100 c
28101
28102 d
28103
28104 e
28105
28106
28107
28108 f
28109 !! end
28110
28111 !! test
28112 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
28113 !! options
28114 parsoid=html2wt
28115 !! html/parsoid
28116 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
28117 !! wikitext
28118 [[Special:BookSources/1234567890|ISBN 1234567895]]
28119 !! end
28120
28121 !! test
28122 Edited RFC links not serializable as RFC links should serialize as extlinks
28123 !! options
28124 parsoid=html2wt
28125 !! html/parsoid
28126 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
28127 !! wikitext
28128 [https://tools.ietf.org/html/rfc123 New RFC]
28129 !! end
28130
28131 !! test
28132 Edited PMID links not serializable as PMID links should serialize as extlinks
28133 !! options
28134 parsoid=html2wt
28135 !! html/parsoid
28136 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
28137 !! wikitext
28138 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
28139 !! end
28140
28141 !! test
28142 WTS of autolinks with trailing/surrounding context
28143 !! options
28144 parsoid=html2wt
28145 !! html/parsoid
28146 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
28147 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
28148 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
28149 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
28150 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
28151 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
28152 !! wikitext
28153 http://cscott.net'''foo'''
28154
28155 http://cscott.net<b>foo</b>
28156
28157 '''http://cscott.net'''
28158
28159 '''http://cscott.net '''
28160
28161 '''http://cscott.net<nowiki/>x'''
28162
28163 http://cscott.net<nowiki/>x
28164 !! end
28165
28166 !! test
28167 WTS of autolinks with nowikis (round-trip)
28168 !! wikitext
28169 x<nowiki/>http://cscott.net<nowiki/>x
28170 !! html/parsoid
28171 <p>x<a rel="mw:ExtLink" href="http://cscott.net">http://cscott.net</a>x</p>
28172 !! end
28173
28174 # this is the "easy" test because it leaves in place all the
28175 # data-parsoid information indicating this is an autolink
28176 !! test
28177 WTS of autolinks with escapes (editing)
28178 !! options
28179 parsoid={
28180 "modes": ["wt2wt"],
28181 "changes": [
28182 [ "span", "remove" ]
28183 ]
28184 }
28185 !! wikitext
28186 x<nowiki/>http://cscott.net<nowiki/>x
28187 !! wikitext/edited
28188 x<nowiki/>http://cscott.net<nowiki/>x
28189 !! end
28190
28191 !! test
28192 WTS of edited autolink-like text (T103364)
28193 !! options
28194 parsoid={
28195 "modes": ["wt2wt"],
28196 "changes": [
28197 [ "span[typeof]", "removeAttr", "typeof" ]
28198 ]
28199 }
28200 !! wikitext
28201 Not a link: <nowiki>http://example.com</nowiki>.
28202 !! wikitext/edited
28203 Not a link: <span><nowiki>http://example.com</nowiki></span>.
28204 !! end
28205
28206 !! test
28207 WTS of newly-authored autolink-like text (T103364)
28208 !! options
28209 parsoid=html2wt
28210 !! html/parsoid
28211 <p>http://example.com is not a link.</p>
28212 !! wikitext
28213 <nowiki>http://example.com</nowiki> is not a link.
28214 !! end
28215
28216 !! test
28217 WTS of autolink-like text after an autolink (T108563)
28218 !! options
28219 parsoid=html2wt
28220 !! html/parsoid
28221 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
28222 !! wikitext
28223 http://example.com <nowiki>http://example.com</nowiki> is not a link.
28224 !! end
28225
28226 !! test
28227 Magic links inside links (not autolinked)
28228 !! wikitext
28229 [[Foo|http://example.com]]
28230 [[Foo|RFC 1234]]
28231 [[Foo|PMID 1234]]
28232 [[Foo|ISBN 123456789x]]
28233
28234 [http://foo.com http://example.com]
28235 [http://foo.com RFC 1234]
28236 [http://foo.com PMID 1234]
28237 [http://foo.com ISBN 123456789x]
28238 !! html+tidy
28239 <p><a href="/wiki/Foo" title="Foo">http://example.com</a>
28240 <a href="/wiki/Foo" title="Foo">RFC 1234</a>
28241 <a href="/wiki/Foo" title="Foo">PMID 1234</a>
28242 <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a>
28243 </p><p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a>
28244 <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a>
28245 <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a>
28246 <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a>
28247 </p>
28248 !! html/parsoid
28249 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
28250 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
28251 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
28252 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
28253
28254 <p><a rel="mw:ExtLink" href="http://foo.com">http://example.com</a>
28255 <a rel="mw:ExtLink" href="http://foo.com">RFC 1234</a>
28256 <a rel="mw:ExtLink" href="http://foo.com">PMID 1234</a>
28257 <a rel="mw:ExtLink" href="http://foo.com">ISBN 123456789x</a></p>
28258 !! end
28259
28260 !! test
28261 Magic links inside image captions (autolinked)
28262 !! wikitext
28263 [[File:Foobar.jpg|thumb|http://example.com]]
28264 [[File:Foobar.jpg|thumb|RFC 1234]]
28265 [[File:Foobar.jpg|thumb|PMID 1234]]
28266 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
28267 !! html+tidy
28268 <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>
28269 <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>
28270 <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>
28271 <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>
28272 !! html/parsoid
28273 <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" href="http://example.com">http://example.com</a></figcaption></figure>
28274 <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">RFC 1234</a></figcaption></figure>
28275 <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">PMID 1234</a></figcaption></figure>
28276 <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>
28277 !! end
28278
28279 !! test
28280 WTS of magic word text (T109371)
28281 !! options
28282 parsoid=html2wt
28283 !! html/parsoid
28284 <p>RFC 1234</p>
28285 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
28286 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
28287 !! wikitext
28288 <nowiki>RFC 1234</nowiki>
28289
28290 [http://foo.com RFC 1234]
28291
28292 [[Foo|RFC 1234]]
28293 !! end
28294
28295 !! test
28296 Edited Redirect link should emit a non-piped wikitext link
28297 !! options
28298 parsoid=html2wt
28299 !! html/parsoid
28300 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
28301 !! wikitext
28302 #REDIRECT [[Bar]]
28303 !! end
28304
28305 !! test
28306 T75121: Infer extension name from typeOf if data-mw is not present
28307 !! options
28308 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28309 !! html/parsoid
28310 <div typeOf="mw:Extension/foo"></div>
28311 !! wikitext
28312 <foo />
28313 !! end
28314
28315 # Note that the <p> wrapping isn't present in PHP parser output
28316 # The important thing for this test is that P-wrapping doesn't
28317 # interfere with the <nowiki> protection for leading - in <td>
28318 # (which isn't necessary for <th>).
28319 !! test
28320 T88318: p-wrapped dash in table.
28321 !! options
28322 parsoid=html2wt,wt2wt
28323 !! html/parsoid
28324 <table><tbody>
28325 <tr><th><p>-</p></th><th><p>- </p></th></tr>
28326 <tr><td><p>-</p></td><td><p>- </p></td></tr>
28327 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
28328 </tbody></table>
28329 !! wikitext
28330 {|
28331 !-
28332 !-
28333 |-
28334 |<nowiki>-</nowiki>
28335 |<nowiki>- </nowiki>
28336 |-
28337 |<small>-</small>
28338 |<br>
28339 -
28340 |<br>
28341 -
28342 |}
28343 !! html/php+tidy
28344 <table>
28345 <tbody><tr>
28346 <th>-
28347 </th>
28348 <th>-
28349 </th></tr>
28350 <tr>
28351 <td>-
28352 </td>
28353 <td>-
28354 </td></tr>
28355 <tr>
28356 <td><small>-</small>
28357 </td>
28358 <td><br />
28359 <p>-
28360 </p>
28361 </td>
28362 <td><br />
28363 <p>-
28364 </p>
28365 </td></tr></tbody></table>
28366 !! end
28367
28368 !! test
28369 T149209: WTS: Handle newlines in table cells properly
28370 !! options
28371 parsoid=html2wt
28372 !! html/parsoid
28373 <table>
28374 <tbody>
28375 <tr><td>a
28376 b
28377 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
28378 <tr><td><p>x</p>
28379 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
28380 </tbody></table>
28381 <table>
28382 <tbody>
28383 <tr><th>a
28384 b
28385 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
28386 <tr><th><p>x</h>
28387 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
28388 </tbody></table>
28389 !! wikitext
28390 {|
28391 |a
28392 b
28393 |c
28394 |-
28395 |x
28396 {{!}}y
28397 |}
28398 {|
28399 !a
28400 b
28401 !c
28402 |-
28403 !x
28404 !y
28405 |}
28406 !! end
28407
28408 !! test
28409 T149209: Selser: Handle newlines in table cells properly
28410 !! options
28411 parsoid={
28412 "modes": ["selser"],
28413 "changes": [
28414 [ "#h1", "html", "a\nb\n" ],
28415 [ "#h2", "html", "a\nb\n" ],
28416 [ "#c1", "html", "a\nb\n" ],
28417 [ "#c2", "html", "<p>a</p>" ],
28418 [ "#c3", "html", "<p>a</p>" ],
28419 [ "#c4", "html", "edit-me<p>a</p>" ]
28420 ]
28421 }
28422 !! wikitext
28423 {|
28424 ! id="h1" |edit-me!!1
28425 |-
28426 ! id="h2" |edit-me||2
28427 |-
28428 | id="c1" |edit-me||3
28429 |-
28430 | id="c2" |edit-me||4
28431 |-
28432 | id="c3" |edit-me||p||q||r
28433 |-
28434 | id="c4" |edit-me||p||q||r
28435 |}
28436 !! wikitext/edited
28437 {|
28438 ! id="h1" |a
28439 b
28440 !1
28441 |-
28442 ! id="h2" |a
28443 b
28444 !2
28445 |-
28446 | id="c1" |a
28447 b
28448 |3
28449 |-
28450 | id="c2" |a
28451 |4
28452 |-
28453 | id="c3" |a
28454 |p||q||r
28455 |-
28456 | id="c4" |edit-me
28457 a
28458 |p||q||r
28459 |}
28460 !! end
28461
28462 !! test
28463 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
28464 !! options
28465 parsoid=html2wt
28466 !! html/parsoid
28467 <table id='mwAb'>
28468 <td id='mwAc'>foo</td>
28469 <td id='serialize-this'>bar</td>
28470 </table>
28471 !! wikitext
28472 {|
28473 |foo
28474 | id="serialize-this" |bar
28475 |}
28476 !! end
28477
28478 !! test
28479 Parsoid-like element ids should not be serialized to wikitext unless shadowed
28480 !! options
28481 parsoid=html2wt
28482 !! html/parsoid
28483 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
28484 !! wikitext
28485 <div id="hello">ok</div>
28486 !! end
28487
28488 !! test
28489 WTS change modes
28490 !! options
28491 parsoid={
28492 "modes": ["wt2wt"],
28493 "changes": [
28494 [ "#xyz", "before", "<b>before</b> stuff " ],
28495 [ "#xyz", "after", " stuff <i>after</i>" ],
28496 [ "#xyz", "html", "x <b>y</b> z" ]
28497 ]
28498 }
28499 !! wikitext
28500 <span id="xyz">hello</span>
28501 !! wikitext/edited
28502 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
28503 !! end
28504
28505 !! test
28506 Never serialize a-tag as html, regardless of what data-parsoid has to say
28507 !! options
28508 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28509 !! html/parsoid
28510 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
28511 !! wikitext
28512 [[Foo]]
28513 !! end
28514
28515 ## SSS FIXME: This is broken output nevertheless.
28516 ## What might be a reasonable non-broken output for this?
28517 ## This is an edge case unlikely to be seen in production
28518 ## that I am not wasting more time on this right now.
28519 !! test
28520 Never serialize a-tag as html, no matter what attributes it has
28521 !! options
28522 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28523 !! html/parsoid
28524 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
28525 !! wikitext
28526 [http://boo.org http://boohoo.org]
28527 !! end
28528
28529 # Misnested is an indication that selser can reuse the source but these have
28530 # shown to sneak through on occasion. See T101768.
28531 # The original wikitext here is: [http://test.com [[one]] two three]
28532 !! test
28533 Strip span tags added to mark misnested links
28534 !! options
28535 parsoid=html2wt
28536 !! html/parsoid
28537 <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>
28538 !! wikitext
28539 [http://test.com][[one]] two three
28540 !! end
28541
28542 !! test
28543 Catch regression when unpacking misnested links
28544 !! options
28545 parsoid=wt2html
28546 !! wikitext
28547 {{echo|hi}}[http://example.com [[ho]]]
28548 !! html/parsoid
28549 <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" href="http://example.com"></a><a rel="mw:WikiLink" href="./Ho" title="Ho" data-parsoid='{"misnested":true}'>ho</a></p>
28550 !! end
28551
28552 !! test
28553 Catch regression when unpacking with trailing content
28554 !! wikitext
28555 {{echo|Foo <references/> bar}}
28556 !! html/parsoid
28557 <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>
28558 !! end
28559
28560 !! test
28561 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
28562 !! options
28563 parsoid=html2wt
28564 !! html/parsoid
28565 <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|}"]}'>
28566 <tbody><tr><td>d
28567 </td></tr>
28568 </tbody></table>
28569 !! wikitext
28570 {{echo|a}}
28571 {|{{echo|c
28572 {{!}}d
28573 }}
28574 |}
28575 !! end
28576
28577 ## This test verifies the presence and computation of this attribute indirectly
28578 ## by making an edit and ensuring that the serialization is correct (which it would be
28579 ## only if firstWikitextNode is properly set).
28580 !! test
28581 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
28582 !! options
28583 parsoid= {
28584 "modes": ["wt2wt"],
28585 "changes": [
28586 [ "div#x", "remove" ],
28587 [ "div", "before", "<div>new</div>" ]
28588 ]
28589 }
28590 !! wikitext
28591 <div id="x">foo</div>
28592 {|
28593 {{echo|<div>boo</div>
28594 {{!}}b}}
28595 |c
28596 |}
28597 !! wikitext/edited
28598
28599 <div>new</div>
28600 {|
28601 {{echo|<div>boo</div>
28602 {{!}}b}}
28603 |c
28604 |}
28605 !! end
28606
28607 # --------------------------------------------
28608 # Tests spec'ing wikitext serialization norms |
28609 # --------------------------------------------
28610
28611 !! test
28612 Serialize multi-line indent-pre starting with wikitext syntax
28613 !! options
28614 parsoid=html2wt
28615 !! html/parsoid
28616 <pre>* 1
28617 ** 2
28618 * 3</pre>
28619 !! wikitext
28620 * 1
28621 ** 2
28622 * 3
28623 !! end
28624
28625 !! test
28626 1. Categories should always be serialized on their own line
28627 !! options
28628 parsoid=html2wt
28629 !! html/parsoid
28630 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
28631 !! wikitext
28632 foo
28633 [[Category:Foo]]
28634 bar
28635 !! end
28636
28637 !! test
28638 2. Categories that are part of templates should not introduce a line break
28639 !! wikitext
28640 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
28641 !! html/parsoid
28642 <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>
28643 !! end
28644
28645 # Careful while editing these next 2 tests. There are \u200f characters
28646 # before and after the <link> tags in the HTML and following some
28647 # of the categories in wikitext
28648 # Do not remove these characters in edits.
28649 #
28650 # As part of the serialization, these bidi characters will get stripped.
28651 !! test
28652 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
28653 !! options
28654 parsoid={
28655 "modes": ["html2wt"],
28656 "scrubWikitext": true
28657 }
28658 !! html/parsoid
28659 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
28660 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
28661 !! wikitext
28662 [[קטגוריה:טקסים]]
28663 [[קטגוריה: שיטות משפט]]
28664 !! end
28665
28666 !! test
28667 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
28668 !! options
28669 parsoid={
28670 "modes": ["html2wt"],
28671 "scrubWikitext": true
28672 }
28673 !! html/parsoid
28674 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
28675 !! wikitext
28676 [[קטגוריה:טקסים]]
28677 ‏y
28678 !! end
28679
28680 !! test
28681 Lists: Add space after bullets
28682 !! options
28683 parsoid=html2wt
28684 !! html/parsoid
28685 <ul>
28686 <li>foo</li>
28687 <li> bar</li>
28688 <li><span> baz</span></li>
28689 </ul>
28690 !! wikitext
28691 * foo
28692 * bar
28693 * <span> baz</span>
28694 !! end
28695
28696 !! test
28697 1. Headings: Add space before/after == (T53744)
28698 !! options
28699 parsoid=html2wt
28700 !! html/parsoid
28701 <h2>foo</h2>
28702 <h2> bar</h2>
28703 <h2>baz </h2>
28704 <h2><span> baz</span></h2>
28705 !! wikitext
28706 == foo ==
28707
28708 == bar ==
28709
28710 == baz ==
28711
28712 == <span> baz</span> ==
28713 !! end
28714
28715 !! test
28716 2. Headings: Add space before/after == even after hoisted content
28717 !! options
28718 parsoid={
28719 "modes": ["html2wt"],
28720 "scrubWikitext": true
28721 }
28722 !! html/parsoid
28723 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
28724 !! wikitext
28725 [[Category:A2]]
28726
28727 == ok ==
28728 !! end
28729
28730 !! test
28731 1. Headings: suppress newly created empty headings
28732 !! options
28733 parsoid={
28734 "modes": ["html2wt"],
28735 "scrubWikitext": true
28736 }
28737 !! html/parsoid
28738 <h2></h2>
28739 !! wikitext
28740 !! end
28741
28742 !! test
28743 2. Headings: don't suppress empty headings if scrubWikitext is false
28744 !! options
28745 parsoid=html2wt
28746 !! html/parsoid
28747 <h2></h2>
28748 !! wikitext
28749 ==<nowiki/>==
28750 !! end
28751
28752 !! test
28753 3. Headings: suppress empty headings on edits
28754 !! options
28755 parsoid={
28756 "modes": ["selser"],
28757 "scrubWikitext": true,
28758 "changes": [
28759 [ "#x", "remove"]
28760 ]
28761 }
28762 !! wikitext
28763 ==<span id="x">foo</span>==
28764 !! wikitext/edited
28765 !! end
28766
28767 !! test
28768 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
28769 !! options
28770 parsoid={
28771 "modes": ["html2wt"],
28772 "scrubWikitext": true
28773 }
28774 !! html/parsoid
28775 <h2>foo<br/>bar</h2>
28776 <h2>foo <span><br/>bar</span> baz</h2>
28777 !! wikitext
28778 == foo bar ==
28779
28780 == foo <span> bar</span> baz ==
28781 !! end
28782
28783 !! test
28784 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
28785 !! options
28786 parsoid={
28787 "modes": ["html2wt"],
28788 "scrubWikitext": false
28789 }
28790 !! html/parsoid
28791 <h2>foo<br/>bar</h2>
28792 !! wikitext
28793 == foo<br> bar ==
28794 !! end
28795
28796 !! test
28797 1. WT Quote Tags: suppress newly created empty style tags
28798 !! options
28799 parsoid={
28800 "modes": ["html2wt"],
28801 "scrubWikitext": true
28802 }
28803 !! html/parsoid
28804 <i></i><b></b>
28805 !! wikitext
28806 !! end
28807
28808 !! test
28809 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
28810 !! options
28811 parsoid=html2wt
28812 !! html/parsoid
28813 <i></i><b></b>
28814 !! wikitext
28815 ''<nowiki/>'''''<nowiki/>'''
28816 !! end
28817
28818 !! test
28819 3. WT Quote Tags: suppress empty style tags on edits
28820 !! options
28821 parsoid={
28822 "modes": ["selser"],
28823 "scrubWikitext": true,
28824 "changes": [
28825 [ "#x", "remove"]
28826 ]
28827 }
28828 !! wikitext
28829 '''<span id="x">foo</span>'''
28830 !! wikitext/edited
28831 !! end
28832
28833 !! test
28834 1. Anchors: suppress newly created empty anchors
28835 !! options
28836 parsoid={
28837 "modes": ["html2wt"],
28838 "scrubWikitext": true
28839 }
28840 !! html/parsoid
28841 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
28842 !! wikitext
28843 !! end
28844
28845 !! test
28846 2. Anchors: don't suppress empty anchors if scrubWikitext is false
28847 !! options
28848 parsoid={
28849 "modes": ["html2wt"],
28850 "scrubWikitext": false
28851 }
28852 !! html/parsoid
28853 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
28854 !! wikitext
28855 [[Test|<nowiki/>]]
28856 !! end
28857
28858 !! test
28859 3. Anchors: suppress empty anchors on edits
28860 !! options
28861 parsoid={
28862 "modes": ["selser"],
28863 "scrubWikitext": true,
28864 "changes": [
28865 [ "#x", "remove"]
28866 ]
28867 }
28868 !! wikitext
28869 [[Test|<span id="x">foo</span>]]
28870 !! wikitext/edited
28871 !! end
28872
28873 !! test
28874 3a. Anchors: do not suppress numbered extlinks
28875 !! options
28876 parsoid={
28877 "modes": ["wt2wt"],
28878 "scrubWikitext": true
28879 }
28880 !! wikitext
28881 [http://foo.com]
28882 !! html/parsoid
28883 <a rel="mw:ExtLink" href="http://foo.com"></a>
28884 !! end
28885
28886 !! test
28887 3b. Anchors: do not suppress numbered extlinks
28888 !! options
28889 parsoid={
28890 "modes": ["wt2wt"],
28891 "scrubWikitext": true,
28892 "changes": [
28893 [ "#x", "remove"]
28894 ]
28895 }
28896 !! wikitext
28897 [http://foo.com <span id="x">foo</span>]
28898 !! wikitext/edited
28899 [http://foo.com]
28900 !! end
28901
28902 !!test
28903 Normalizations should be restricted to edited content
28904 !!options
28905 parsoid={
28906 "modes": ["selser"],
28907 "scrubWikitext": true,
28908 "changes": [
28909 [ "h1", "before", "<i></i>"]
28910 ]
28911 }
28912 !!wikitext
28913 a
28914 = =
28915 b
28916 !!wikitext/edited
28917 a
28918 = =
28919 b
28920 !!end
28921
28922 !! test
28923 1. Multiple normalizations (html2wt)
28924 !! options
28925 parsoid={
28926 "modes": ["html2wt"],
28927 "scrubWikitext": true
28928 }
28929 !! html
28930 <h2><i></i></h2>
28931 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
28932 </a><b><i></i></b>x</p>
28933 !! wikitext
28934
28935 [[foo]]
28936 x
28937
28938 !! end
28939
28940 !! test
28941 2. Multiple normalizations (selser)
28942 !! options
28943 parsoid={
28944 "modes": ["selser"],
28945 "scrubWikitext": true,
28946 "changes": [
28947 [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
28948 ]
28949 }
28950 !! wikitext
28951 <span id="x">foo</span>
28952 !! wikitext/edited
28953 <span id="x">foo</span>
28954
28955 x
28956 !! end
28957
28958 !! test
28959 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
28960 !! options
28961 parsoid={
28962 "modes": ["html2wt"],
28963 "scrubWikitext": true
28964 }
28965 !! html/parsoid
28966 <p> hi</p>
28967 <p> hello</p>
28968 !! wikitext
28969 hi
28970
28971 hello
28972 !! end
28973
28974 !! test
28975 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
28976 !! options
28977 parsoid=html2wt
28978 !! html/parsoid
28979 <p> hi</p>
28980 <p> hello</p>
28981 !! wikitext
28982 <nowiki> </nowiki>hi
28983
28984 <nowiki> </nowiki> hello
28985 !! end
28986
28987 !! test
28988 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
28989 !! options
28990 parsoid={
28991 "modes": ["html2wt"],
28992 "scrubWikitext": true
28993 }
28994 !! html/parsoid
28995 <p>Foo
28996 bar
28997 baz</p>
28998
28999 <table><tr><td>Foo
29000 bar
29001 baz bang</td></tr></table>
29002
29003 <p><!--boo--> foo
29004 bar</p>
29005
29006 <p> foo
29007 bar<span>boo</span></p>
29008 !! wikitext
29009 Foo
29010 bar
29011 baz
29012
29013 {|
29014 |Foo
29015 bar
29016 baz bang
29017 |}
29018
29019 <!--boo-->foo
29020 bar
29021
29022 foo
29023 bar<span>boo</span>
29024 !! end
29025
29026 !! test
29027 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
29028 !! options
29029 parsoid={
29030 "modes": ["selser"],
29031 "scrubWikitext": true,
29032 "changes": [
29033 [ "p", "html", " a\n b" ]
29034 ]
29035 }
29036 !! wikitext
29037 xyz
29038 !! wikitext/edited
29039 a
29040 b
29041 !! end
29042
29043 !! test
29044 1. New links that end in spaces
29045 !! options
29046 parsoid={
29047 "modes": ["html2wt"],
29048 "scrubWikitext": false
29049 }
29050 !! html/parsoid
29051 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29052 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29053 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29054 !! wikitext
29055 [[Berlin ]]<nowiki/>is the capital of Germany.
29056
29057 [[Foo ]]'''bar'''
29058
29059 [[Boston ]] is a city.
29060 !! end
29061
29062 !! test
29063 2. New links that end in spaces
29064 !! options
29065 parsoid={
29066 "modes": ["html2wt"],
29067 "scrubWikitext": true
29068 }
29069 !! html/parsoid
29070 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29071 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29072 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29073 !! wikitext
29074 [[Berlin]] is the capital of Germany.
29075
29076 [[Foo]] '''bar'''
29077
29078 [[Boston]] is a city.
29079 !! end
29080
29081 !! test
29082 1. Table cells with escapable prefixes
29083 !! options
29084 parsoid={
29085 "modes": ["html2wt"],
29086 "scrubWikitext": false
29087 }
29088 !! html
29089 <table>
29090 <tr><td>a</td></tr>
29091 <tr><td>-</td></tr>
29092 <tr><td>+</td></tr>
29093 </table>
29094 !! wikitext
29095 {|
29096 |a
29097 |-
29098 |<nowiki>-</nowiki>
29099 |-
29100 |<nowiki>+</nowiki>
29101 |}
29102 !! end
29103
29104 !! test
29105 2. Table cells with escapable prefixes
29106 !! options
29107 parsoid={
29108 "modes": ["html2wt"],
29109 "scrubWikitext": true
29110 }
29111 !! html
29112 <table>
29113 <tr><td>a</td></tr>
29114 <tr><td>-</td></tr>
29115 <tr><td>+</td></tr>
29116 </table>
29117 !! wikitext
29118 {|
29119 |a
29120 |-
29121 | -
29122 |-
29123 | +
29124 |}
29125 !! end
29126
29127 !! test
29128 3a. Table cells with escapable prefixes after edits
29129 !! options
29130 parsoid={
29131 "modes": ["selser"],
29132 "scrubWikitext": true,
29133 "changes": [
29134 [ "table tbody tr:first-child td:first-child", "remove"]
29135 ]
29136 }
29137 !! wikitext
29138 {|
29139 |a||-
29140 |}
29141 !! wikitext/edited
29142 {|
29143 | -
29144 |}
29145 !! end
29146
29147 !! test
29148 3b. Table cells with escapable prefixes after edits
29149 !! options
29150 parsoid={
29151 "modes": ["selser"],
29152 "scrubWikitext": true,
29153 "changes": [
29154 [ "table tbody tr:first-child td:first-child", "html", "-" ],
29155 [ "#x", "remove" ]
29156 ]
29157 }
29158 !! wikitext
29159 {|
29160 |pqr
29161 |<span id="x">foo</span>+
29162 |}
29163 !! wikitext/edited
29164 {|
29165 | -
29166 | +
29167 |}
29168 !! end
29169
29170 # FIXME: This test will fail because
29171 # normalization doesn't realize that the id attribute
29172 # will eliminate the escapable scenario
29173 !! test
29174 4a. Table cells without escapable prefixes after edits
29175 !! options
29176 parsoid={
29177 "modes": ["selser"],
29178 "scrubWikitext": true,
29179 "changes": [
29180 [ "#x", "html", "-" ]
29181 ]
29182 }
29183 !! wikitext
29184 {|
29185 | id="x" |abcd
29186 |}
29187 !! wikitext/edited
29188 {|
29189 | id="x" |-
29190 |}
29191 !! end
29192
29193 ## This tests normalizer's ability to discriminate between
29194 ## cells having identical content.
29195 !! test
29196 4b. Table cells without escapable prefixes after edits
29197 !! options
29198 parsoid={
29199 "modes": ["selser"],
29200 "scrubWikitext": true,
29201 "changes": [
29202 [ "td", "html", "-" ]
29203 ]
29204 }
29205 !! wikitext
29206 {|
29207 |a||b
29208 |}
29209 !! wikitext/edited
29210 {|
29211 | -||-
29212 |}
29213 !! end
29214
29215 ## This tests normalizer's ability to not be tripped by
29216 ## comments (and whitespace)
29217 !! test
29218 4c. Table cells without escapable prefixes after edits
29219 !! options
29220 parsoid={
29221 "modes": ["selser"],
29222 "scrubWikitext": true,
29223 "changes": [
29224 [ "table tbody tr td:first-child", "remove" ]
29225 ]
29226 }
29227 !! wikitext
29228 {|
29229 |-
29230 <!--foo--> |a||-
29231 |}
29232 !! wikitext/edited
29233 {|
29234 |-
29235 <!--foo--> | -
29236 |}
29237 !! end
29238
29239 ## This tests normalizer's ability to handle HTML cells
29240 !! test
29241 4d. Table cells without escapable prefixes after edits
29242 !! options
29243 parsoid={
29244 "modes": ["selser"],
29245 "scrubWikitext": true,
29246 "changes": [
29247 [ "td", "html", "-" ]
29248 ]
29249 }
29250 !! wikitext
29251 <table>
29252 <tr><td>a</td></tr>
29253 </table>
29254 !! wikitext/edited
29255 <table>
29256 <tr><td>-</td></tr>
29257 </table>
29258 !! end
29259
29260 ## T111151 Remove font elements without attributes
29261 !! test
29262 5a. font tags without attributes should be dropped in scrubWikitext mode
29263 !! options
29264 parsoid={
29265 "modes": ["html2wt"],
29266 "scrubWikitext": true
29267 }
29268 !! html
29269 <font>foo</font>
29270 <font><font>bar</font></font>
29271 <font class="x">boo</font>
29272 !! wikitext
29273 foo
29274 bar
29275 <font class="x">boo</font>
29276 !! end
29277
29278 !! test
29279 5b. font tags should not be dropped without scrubWikitext being enabled
29280 !! options
29281 parsoid={
29282 "modes": ["html2wt"],
29283 "scrubWikitext": false
29284 }
29285 !! html
29286 <font>foo</font>
29287 !! wikitext
29288 <font>foo</font>
29289 !! end
29290
29291 !! test
29292 Escape nowiki DOM elements
29293 !! options
29294 parsoid=html2wt
29295 !! html/parsoid
29296 <nowiki><i>foo</i></nowiki>
29297 !! wikitext
29298 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
29299 !! end
29300
29301 # This is meant to be an interim fix while we go about figuring out
29302 # how to not introduce these trailing <nowiki/>s in the first place.
29303 !! test
29304 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
29305 !! options
29306 parsoid=html2wt
29307 !! html/parsoid
29308 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
29309 y</p>
29310 <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>
29311 <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>
29312 !! wikitext
29313 x
29314 y
29315
29316 {{echo|
29317 1 = <nowiki/>}}
29318
29319 {{echo|
29320 1 = <nowiki/>
29321 }}
29322 !! end
29323
29324 # ---------------------------------------------------
29325 # End of tests spec'ing wikitext serialization norms |
29326 # ---------------------------------------------------
29327
29328 # T104032
29329 !! test
29330 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
29331 !! options
29332 parsoid=html2wt
29333 !! html/parsoid
29334 a<p>b</p>
29335 <b>c</b><p>d</p>
29336 <table><tr>
29337 <td>a<p>b</p></td>
29338 <td><b>c</b><p>d</p></td>
29339 </tr></table>
29340 !! wikitext
29341 a
29342
29343 b
29344
29345 '''c'''
29346
29347 d
29348 {|
29349 |a
29350 b
29351 |'''c'''
29352 d
29353 |}
29354 !! end
29355
29356 !! test
29357 Anchor without href scenarios
29358 !! options
29359 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29360 !! html/parsoid
29361 <a class="bc"></a>
29362 <a class="no">dice</a>
29363 <a name="foo"></a>
29364 !! wikitext
29365
29366 dice
29367 <span name="foo"></span>
29368 !! end
29369
29370 !! test
29371 New transclusion added after a list should be serialized after the list
29372 !! options
29373 parsoid=html2wt
29374 !! html/parsoid
29375 <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>
29376 !! wikitext
29377 * a
29378 {{echo|foo}}
29379 !! end
29380
29381 # -----------------------------------------------------------------
29382 # End of section for Parsoid-only html2wt tests for serialization
29383 # of new content
29384 # -----------------------------------------------------------------
29385
29386 # -----------------------------------------------------------------
29387 # The following section of tests are primarily to spec behavior of
29388 # the selective serializer. All these tests have manual selser
29389 # changes. The automated selser changes for all tests handle the
29390 # wide variation of changes, but these tests here capture specs
29391 # deterministically.
29392 # ----------------------------------------------------------------
29393
29394 ## T90517
29395 !! test
29396 Selser: New comments should not be lost
29397 !! options
29398 parsoid={
29399 "modes": ["selser"],
29400 "changes": [
29401 [ "#a", "after", "<!--c1-->" ],
29402 [ "#b", "before", "<!--c2-->" ]
29403 ]
29404 }
29405 !! wikitext
29406 <span id="a">a</span>
29407
29408 <span id="b">b</span>
29409 !! wikitext/edited
29410 <span id="a">a</span><!--c1-->
29411
29412 <!--c2--><span id="b">b</span>
29413 !! end
29414
29415 ## T89383
29416 !! test
29417 Selser: Check for validity of DSR before using it
29418 !! options
29419 parsoid={
29420 "modes": ["selser"],
29421 "changes": [
29422 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
29423 ]
29424 }
29425 !! wikitext
29426 <span id="a">a</span>
29427 !! wikitext/edited
29428 {{DISPLAYTITLE:foo}}
29429 <span id="a">a</span>
29430 !! end
29431
29432 !! test
29433 1. DOMDiff: Changes to <ref> content should be looked up using id
29434 !! options
29435 parsoid={
29436 "modes": ["selser"],
29437 "changes": [
29438 ["#X", "after", "bar"],
29439 ["#Y", "after", "baz"]
29440 ]
29441 }
29442 !! wikitext
29443 X <ref><span id="X">foo</span></ref>
29444 Y <ref name="a" />
29445 <references>
29446 <ref name="a"><span id="Y">foo</span></ref>
29447 </references>
29448 !! wikitext/edited
29449 X <ref><span id="X">foo</span>bar</ref>
29450 Y <ref name="a" />
29451 <references>
29452 <ref name="a"><span id="Y">foo</span>baz</ref>
29453 </references>
29454 !! end
29455
29456 !! test
29457 2. DOMDiff: Changes to <ref> content should be looked up using id
29458 !! options
29459 parsoid={
29460 "modes": ["selser"],
29461 "changes": [
29462 ["#Z", "after", "bar"]
29463 ]
29464 }
29465 !! wikitext
29466 A <ref>foo bar for a</ref>
29467 B <ref group="X" name="b" />
29468
29469 <references />
29470
29471 <references group="X">
29472 <ref name="b"><span id="Z">foo</span></ref>
29473 </references>
29474 !! wikitext/edited
29475 A <ref>foo bar for a</ref>
29476 B <ref group="X" name="b" />
29477
29478 <references />
29479
29480 <references group="X">
29481 <ref name="b"><span id="Z">foo</span>bar</ref>
29482 </references>
29483 !! end
29484
29485 !! test
29486 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
29487 !! options
29488 parsoid={
29489 "modes": ["selser"],
29490 "changes": [
29491 [ "div:first-child", "text", "bar" ]
29492 ]
29493 }
29494 !! wikitext
29495 <div style="{{1x|color:red;}}%">foo</div>
29496 !! wikitext/edited
29497 <div style="{{1x|color:red;}}%">bar</div>
29498 !! end
29499
29500 !! test
29501 Empty LI (T49673)
29502 !! wikitext
29503 * a
29504 *
29505 *
29506 * b
29507 !! html+tidy
29508 <ul><li> a</li>
29509 <li class="mw-empty-elt"> </li>
29510 <li class="mw-empty-elt"></li>
29511 <li> b</li></ul>
29512 !! end
29513
29514 # FIXME: Why is there no html/parsoid section here?
29515 !! test
29516 Thumbnail output
29517 !! wikitext
29518 [[File:Thumb.png|thumb]]
29519 !! html/php+tidy
29520 <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>
29521 !! end
29522
29523 !! test
29524 unclosed internal link XSS (T137264)
29525 !! wikitext
29526 [[#%3Cscript%3Ealert(1)%3C/script%3E|
29527 !! html/php
29528 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
29529 </p>
29530 !! html/parsoid
29531 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
29532 !! end
29533
29534 # Use $wgRawHtml to inject a <style> tag, since you normally can't in wikitext
29535 # (Parsoid doesn't support $wgRawHtml==true)
29536 !! test
29537 Validating that <style> isn't eaten by tidy (T167349)
29538 !! options
29539 wgRawHtml=1
29540 !! wikitext
29541 <div class="foo">
29542 <html><style>.foo::before { content: "<foo>"; }</style></html>
29543 <html><style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style></html>
29544 </div>
29545 !! html/php+tidy
29546 <div class="foo">
29547 <style>.foo::before { content: "<foo>"; }</style>
29548 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
29549 </div>
29550 !! end
29551
29552 !! test
29553 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
29554 !! config
29555 wgFragmentMode=[ 'html5', 'legacy' ]
29556 !! wikitext
29557 == A&B&amp;C&amp;amp;D&amp;amp;amp;E ==
29558 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
29559 !! html/php
29560 <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>
29561 <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>
29562 </p>
29563 !! html/parsoid
29564 <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>
29565 <p><a rel="mw:WikiLink" href="./Main_Page#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E"},"sa":{"href":"#A&amp;B&amp;amp;C&amp;amp;amp;D&amp;amp;amp;amp;E"}}'>#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a></p>
29566 !! end
29567
29568 !! test
29569 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
29570 !! config
29571 wgFragmentMode=[ 'legacy' ]
29572 !! wikitext
29573 == A&B&amp;C&amp;amp;D&amp;amp;amp;E ==
29574 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
29575 !! html/php
29576 <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>
29577 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
29578 </p>
29579 !! end
29580
29581 !! test
29582 Decoding of HTML entities in embedded HTML tags
29583 !! wikitext
29584 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
29585 !! html/php
29586 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
29587
29588 !! html/parsoid
29589 <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>
29590 !! end
29591
29592 !! test
29593 Decoding of HTML entities in indicator names for IDs (T104196)
29594 !! options
29595 parsoid=wt2html,html2html
29596 showindicators
29597 !! wikitext
29598 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
29599 !! html/php
29600 1&2&3&amp;4&amp;amp;5=Indicator
29601
29602 !! html/parsoid
29603 <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>
29604 !! end
29605
29606 # this version of the test strips out the ambiguity so Parsoid rts cleanly
29607 !! test
29608 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
29609 !! options
29610 showindicators
29611 !! wikitext
29612 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
29613 !! html/php
29614 1&2&3&amp;4&amp;amp;5=Indicator
29615
29616 !! html/parsoid
29617 <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>
29618 !! end
29619
29620 # This fragment mode is what Parsoid supports.
29621 !! test
29622 HTML5 ids: fallback to legacy
29623 !! config
29624 wgFragmentMode=[ 'html5', 'legacy' ]
29625 !! wikitext
29626 == Foo bar ==
29627
29628 == foo Bar ==
29629
29630 == Тест ==
29631
29632 == Тест ==
29633
29634 == тест ==
29635
29636 == Hey < # " > % : ' ==
29637 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
29638
29639 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
29640
29641 <!-- These two links should produce identical HTML -->
29642 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
29643
29644 !! html/php
29645 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
29646 <ul>
29647 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
29648 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
29649 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
29650 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
29651 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
29652 <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>
29653 </ul>
29654 </div>
29655
29656 <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>
29657 <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>
29658 <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>
29659 <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>
29660 <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>
29661 <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>
29662 <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>
29663 </p><p>💩 <span id="💩"></span>
29664 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
29665 </p>
29666 !! html/parsoid
29667 <h2 id="Foo_bar"> Foo bar </h2>
29668
29669 <h2 id="foo_Bar_2"> foo Bar </h2>
29670
29671 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span> Тест </h2>
29672
29673 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span> Тест </h2>
29674
29675 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span> тест </h2>
29676
29677 <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>
29678 <p><a rel="mw:WikiLink" href="./Main_Page#Foo_bar">#Foo bar</a> <a rel="mw:WikiLink" href="./Main_Page#foo_Bar">#foo Bar</a> <a rel="mw:WikiLink" href="./Main_Page#Тест">#Тест</a> <a rel="mw:WikiLink" href="./Main_Page#тест">#тест</a> <a rel="mw:WikiLink" href="./Main_Page#Hey_&lt;_#_&quot;_>_%_:_'" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Hey_&lt;_#_\"_>_%_:_&#39;"},"sa":{"href":"#Hey &lt; # \" > % : &#39;"}}'>#Hey &lt; # " > % : '</a></p>
29679
29680 <p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode:💩","function":"anchorencode"},"params":{},"i":0}}]}'>💩</span> <span id="💩" about="#mwt3" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"id"},{"html":"&lt;span about=\"#mwt2\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[190,209,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:💩\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}&#39;>💩&lt;/span>"}]]}'></span></p>
29681
29682 <!-- These two links should produce identical HTML -->
29683 <p><a rel="mw:WikiLink" href="./Main_Page#啤酒">#啤酒</a> <a rel="mw:WikiLink" href="./Main_Page#啤酒" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#啤酒"},"sa":{"href":"#%E5%95%A4%E9%85%92"}}'>#啤酒</a></p>
29684 !! end
29685
29686 # Parsoid doesn't support this mode
29687 !! test
29688 HTML5 ids: legacy with a fallback to modern
29689 !! config
29690 wgFragmentMode=[ 'legacy', 'html5' ]
29691 !! wikitext
29692 == Foo bar ==
29693
29694 == foo Bar ==
29695
29696 == Тест ==
29697
29698 == Тест ==
29699
29700 == тест ==
29701
29702 == Hey < # " > % : ' ==
29703 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
29704
29705 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
29706
29707 <!-- These two links should produce identical HTML -->
29708 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
29709
29710 !! html/php
29711 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
29712 <ul>
29713 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
29714 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
29715 <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>
29716 <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>
29717 <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>
29718 <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>
29719 </ul>
29720 </div>
29721
29722 <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>
29723 <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>
29724 <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>
29725 <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>
29726 <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>
29727 <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>
29728 <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>
29729 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
29730 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
29731 </p>
29732 !! end
29733
29734 # Parsoid doesn't support this mode.
29735 !! test
29736 HTML5 ids: no legacy
29737 !! config
29738 wgFragmentMode=[ 'html5' ]
29739 !! wikitext
29740 == Foo bar ==
29741
29742 == foo Bar ==
29743
29744 == Тест ==
29745
29746 == Тест ==
29747
29748 == тест ==
29749
29750 == Hey < # " > % : ' ==
29751 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
29752
29753 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
29754
29755 <!-- These two links should produce identical HTML -->
29756 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
29757
29758 !! html/php
29759 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
29760 <ul>
29761 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
29762 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
29763 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
29764 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
29765 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
29766 <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>
29767 </ul>
29768 </div>
29769
29770 <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>
29771 <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>
29772 <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>
29773 <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>
29774 <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>
29775 <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>
29776 <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>
29777 </p><p>💩 <span id="💩"></span>
29778 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
29779 </p>
29780 !! end
29781
29782 !! test
29783 T90902: Normalize weird characters in section IDs
29784 !! config
29785 wgFragmentMode=[ 'html5', 'legacy' ]
29786 !! wikitext
29787 == Foo&nbsp;bar ==
29788 [[#Foo&nbsp;bar]]
29789
29790 !! html/php
29791 <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>
29792 <p><a href="#Foo_bar">#Foo&#160;bar</a>
29793 </p>
29794 !! end
29795
29796 !! test
29797 T51672: Test for brackets in attributes of elements in external link texts
29798 !! wikitext
29799 [http://example.com/ link <span title="title with [brackets]">span</span>]
29800 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
29801
29802 !! html/php
29803 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
29804 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
29805 </p>
29806 !! html/parsoid
29807 <p><a rel="mw:ExtLink" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
29808 <a rel="mw:ExtLink" 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>
29809 !! end
29810
29811 !! test
29812 T72875: Test for brackets in attributes of elements in internal link texts
29813 !! wikitext
29814 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
29815 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
29816
29817 !! html/php
29818 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
29819 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
29820 </p>
29821 !! html/parsoid
29822 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
29823 <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>
29824 !! end
29825
29826 !! test
29827 T179544: {{anchorencode:}} output should be always usable in links
29828 !! config
29829 wgFragmentMode=[ 'html5' ]
29830 !! wikitext
29831 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
29832 !! html/php
29833 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
29834 </p>
29835 !! html/parsoid
29836 <p><span id="[foo]" about="#mwt3" typeof="mw:ExpandedAttrs" data-parsoid='{"stx":"html","a":{"id":"[foo]"},"sa":{"id":"{{anchorencode:[foo]}}"}}' data-mw='{"attribs":[[{"txt":"id"},{"html":"&lt;span typeof=\"mw:Transclusion mw:Entity\" about=\"#mwt1\" data-parsoid=&apos;{\"srcContent\":\"[\",\"dsr\":[10,32,null,null],\"pi\":[[]]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:[foo]\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}&apos;>[&lt;/span>&lt;span about=\"#mwt1\" data-parsoid=\"{}\">foo&lt;/span>&lt;span typeof=\"mw:Entity\" about=\"#mwt1\" data-parsoid=&apos;{\"src\":\"&amp;amp;#x5D;\",\"srcContent\":\"]\"}&apos;>]&lt;/span>"}]]}'></span><a typeof="mw:ExpandedAttrs" about="#mwt4" rel="mw:WikiLink" href="./Main_Page#[foo]" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#[foo]"},"sa":{"href":"#{{anchorencode:[foo]}}"}}' data-mw='{"attribs":[[{"txt":"href"},{"html":"#&lt;span typeof=\"mw:Transclusion mw:Entity\" about=\"#mwt2\" data-parsoid=&apos;{\"srcContent\":\"[\",\"dsr\":[44,66,null,null],\"pi\":[[]]}&apos; data-mw=&apos;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:[foo]\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}&apos;>[&lt;/span>&lt;span about=\"#mwt2\" data-parsoid=\"{}\">foo&lt;/span>&lt;span typeof=\"mw:Entity\" about=\"#mwt2\" data-parsoid=&apos;{\"src\":\"&amp;amp;#x5D;\",\"srcContent\":\"]\"}&apos;>]&lt;/span>"}]]}'>#[foo]</a></p>
29837 !! end
29838
29839 ## ------------------------------
29840 ## Parsoid section-wrapping tests
29841 ## ------------------------------
29842 !! test
29843 Section wrapping for well-nested sections (no leading content)
29844 !! options
29845 parsoid={
29846 "wrapSections": true
29847 }
29848 !! wikitext
29849 = 1 =
29850 a
29851
29852 = 2 =
29853 b
29854
29855 == 2.1 ==
29856 c
29857
29858 == 2.2 ==
29859 d
29860
29861 === 2.2.1 ===
29862 e
29863
29864 = 3 =
29865 f
29866 !! html/parsoid
29867 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
29868 <p>a</p>
29869
29870 </section><section data-mw-section-id="2"><h1 id="2"> 2 </h1>
29871 <p>b</p>
29872
29873 <section data-mw-section-id="3"><h2 id="2.1"> 2.1 </h2>
29874 <p>c</p>
29875
29876 </section><section data-mw-section-id="4"><h2 id="2.2"> 2.2 </h2>
29877 <p>d</p>
29878
29879 <section data-mw-section-id="5"><h3 id="2.2.1"> 2.2.1 </h3>
29880 <p>e</p>
29881
29882 </section></section></section><section data-mw-section-id="6"><h1 id="3"> 3 </h1>
29883 <p>f</p>
29884
29885 </section>
29886 !! end
29887
29888 !! test
29889 Section wrapping for well-nested sections (with leading content)
29890 !! options
29891 parsoid={
29892 "wrapSections": true
29893 }
29894 !! wikitext
29895 Para 1.
29896
29897 Para 2 with a <div>nested in it</div>
29898
29899 Para 3.
29900
29901 = 1 =
29902 a
29903
29904 = 2 =
29905 b
29906
29907 == 2.1 ==
29908 c
29909 !! html/parsoid
29910 <section data-mw-section-id="0"><p>Para 1.</p>
29911
29912 <p>Para 2 with a </p><div>nested in it</div>
29913
29914 <p>Para 3.</p>
29915
29916 </section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
29917 <p>a</p>
29918
29919 </section><section data-mw-section-id="2"><h1 id="2"> 2 </h1>
29920 <p>b</p>
29921
29922 <section data-mw-section-id="3"><h2 id="2.1"> 2.1 </h2>
29923 <p>c</p>
29924
29925 </section></section>
29926 !! end
29927
29928 !! test
29929 Section wrapping with template-generated sections (good nesting 1)
29930 !! options
29931 parsoid={
29932 "wrapSections": true
29933 }
29934 !! wikitext
29935 = 1 =
29936 a
29937
29938 {{echo|1=
29939 == 1.1 ==
29940 b
29941 }}
29942
29943 == 1.2 ==
29944 c
29945
29946 = 2 =
29947 d
29948 !! html/parsoid
29949 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
29950 <p>a</p>
29951
29952 <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">
29953 </span><p about="#mwt1">b</p>
29954 </section><section data-mw-section-id="3"><h2 id="1.2"> 1.2 </h2>
29955 <p>c</p>
29956
29957 </section></section><section data-mw-section-id="4"><h1 id="2"> 2 </h1>
29958 <p>d</p></section>
29959 !! end
29960
29961 # In this example, the template scope is mildly expanded to incorporate the
29962 # trailing newline after the transclusion since that is part of section 1.1.1
29963 !! test
29964 Section wrapping with template-generated sections (good nesting 2)
29965 !! options
29966 parsoid={
29967 "wrapSections": true,
29968 "modes": ["wt2html", "wt2wt"]
29969 }
29970 !! wikitext
29971 = 1 =
29972 a
29973
29974 {{echo|1=
29975 == 1.1 ==
29976 b
29977 === 1.1.1 ===
29978 d
29979 }}
29980 = 2 =
29981 e
29982 !! html/parsoid
29983 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
29984 <p>a</p>
29985
29986 <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">
29987 </span><p about="#mwt1">b</p><span about="#mwt1">
29988 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1"> 1.1.1 </h3><span about="#mwt1">
29989 </span><p about="#mwt1">d</p><span about="#mwt1">
29990 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2"> 2 </h1>
29991 <p>e</p></section>
29992 !! end
29993
29994 # In this example, the template scope is mildly expanded to incorporate the
29995 # trailing newline after the transclusion since that is part of section 1.2.1
29996 !! test
29997 Section wrapping with template-generated sections (good nesting 3)
29998 !! options
29999 parsoid={
30000 "wrapSections": true,
30001 "modes": ["wt2html", "wt2wt"]
30002 }
30003 !! wikitext
30004 = 1 =
30005 a
30006
30007 {{echo|1=
30008 x
30009 == 1.1 ==
30010 b
30011 ==1.2==
30012 c
30013 ===1.2.1===
30014 d
30015 }}
30016 = 2 =
30017 e
30018 !! html/parsoid
30019 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
30020 <p>a</p>
30021
30022 <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">
30023 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1"> 1.1 </h2><span about="#mwt1">
30024 </span><p about="#mwt1">b</p><span about="#mwt1">
30025 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
30026 </span><p about="#mwt1">c</p><span about="#mwt1">
30027 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
30028 </span><p about="#mwt1">d</p><span about="#mwt1">
30029 </span></section></section></section><section data-mw-section-id="5"><h1 id="2"> 2 </h1>
30030 <p>e</p></section>
30031 !! end
30032
30033 # Because of section-wrapping and template-wrapping interactions,
30034 # the scope of the template is expanded so that the template markup
30035 # is valid in the presence of <section> tags.
30036 # This exercises the s1 is null scenario in the wrapSections code
30037 !! test
30038 Section wrapping with template-generated sections (bad nesting 1)
30039 !! options
30040 parsoid={
30041 "wrapSections": true
30042 }
30043 !! wikitext
30044 <div>
30045 a
30046
30047 {{echo|
30048 = 1 =
30049 b
30050 }}
30051
30052 c
30053 </div>
30054 !! html/parsoid
30055 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
30056 <p>a</p>
30057
30058 <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"]}'>
30059 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1"> 1 </h1><span about="#mwt1">
30060 </span><p about="#mwt1">b
30061 </p><span about="#mwt1">
30062
30063 </span><p about="#mwt1">c</p><span about="#mwt1">
30064 </span></section></div></section>
30065 !! end
30066
30067 # Because of section-wrapping and template-wrapping interactions,
30068 # the scope of the template is expanded so that the template markup
30069 # is valid in the presence of <section> tags.
30070 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
30071 !! test
30072 Section wrapping with template-generated sections (bad nesting 2)
30073 !! options
30074 parsoid={
30075 "wrapSections": true
30076 }
30077 !! wikitext
30078 = 1 =
30079 a
30080
30081 {{echo|1=
30082 = 2 =
30083 b
30084 == 2.1 ==
30085 c
30086 }}
30087
30088 d
30089
30090 = 3 =
30091 e
30092 !! html/parsoid
30093 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30094 <p>a</p>
30095
30096 </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">
30097 </span><p about="#mwt1">b</p><span about="#mwt1">
30098 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1"> 2.1 </h2><span about="#mwt1">
30099 </span><p about="#mwt1">c</p><span about="#mwt1">
30100
30101 </span><p about="#mwt1">d</p><span about="#mwt1">
30102
30103 </span></section></section><section data-mw-section-id="4"><h1 id="3"> 3 </h1>
30104 <p>e</p></section>
30105 !! end
30106
30107 # Because of section-wrapping and template-wrapping interactions,
30108 # additional template wrappers are added to <section> tags
30109 # so that template wrapping semantics are valid whether section
30110 # tags are retained or stripped. But, the template scope can expand
30111 # greatly when accounting for section tags.
30112 # This exercises the s1 and s2 are in different subtrees scenario
30113 !! test
30114 Section wrapping with template-generated sections (bad nesting 3)
30115 !! options
30116 parsoid={
30117 "wrapSections": true,
30118 "modes": ["wt2html", "wt2wt"]
30119 }
30120 !! wikitext
30121 = 1 =
30122 a
30123
30124 {{echo|1=
30125 == 1.2 ==
30126 b
30127 = 2 =
30128 c
30129 }}
30130
30131 d
30132
30133 = 3 =
30134 e
30135 !! html/parsoid
30136 <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>
30137 <p>a</p>
30138
30139 <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">
30140 </span><p about="#mwt1">b</p><span about="#mwt1">
30141 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2"> 2 </h1><span about="#mwt1">
30142 </span><p about="#mwt1">c</p>
30143
30144 <p>d</p>
30145 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3"> 3 </h1>
30146 <p>e</p></section>
30147 !! end
30148
30149 !! test
30150 Section wrapping with uneditable lead section + div wrapping multiple sections
30151 !! options
30152 parsoid={
30153 "wrapSections": true
30154 }
30155 !! wikitext
30156 foo
30157
30158 <div style="border:1px solid red;">
30159 = 1 =
30160 a
30161
30162 == 1.1 ==
30163 b
30164
30165 = 2 =
30166 c
30167 </div>
30168
30169 = 3 =
30170 d
30171
30172 == 3.1 ==
30173 e
30174 !! html/parsoid
30175 <section data-mw-section-id="-1"><p>foo</p>
30176
30177 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
30178 <section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30179 <p>a</p>
30180
30181 <section data-mw-section-id="2"><h2 id="1.1"> 1.1 </h2>
30182 <p>b</p>
30183
30184 </section></section><section data-mw-section-id="-1"><h1 id="2"> 2 </h1>
30185 <p>c</p>
30186 </section></div>
30187
30188 </section><section data-mw-section-id="4"><h1 id="3"> 3 </h1>
30189 <p>d</p>
30190
30191 <section data-mw-section-id="5"><h2 id="3.1"> 3.1 </h2>
30192 <p>e</p>
30193 </section></section>
30194 !! end
30195
30196 !! test
30197 Section wrapping with editable lead section + div overlapping multiple sections
30198 !! options
30199 parsoid={
30200 "wrapSections": true
30201 }
30202 !! wikitext
30203 foo
30204
30205 = 1 =
30206 a
30207 <div style="border:1px solid red;">
30208 b
30209
30210 == 1.1 ==
30211 c
30212
30213 = 2 =
30214 d
30215 </div>
30216 e
30217
30218 = 3 =
30219 f
30220
30221 == 3.1 ==
30222 g
30223 !! html/parsoid
30224 <section data-mw-section-id="0"><p>foo</p>
30225
30226 </section><section data-mw-section-id="-1"><h1 id="1"> 1 </h1>
30227 <p>a</p>
30228 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
30229 <p>b</p>
30230
30231 <section data-mw-section-id="2"><h2 id="1.1"> 1.1 </h2>
30232 <p>c</p>
30233
30234 </section><section data-mw-section-id="-1"><h1 id="2"> 2 </h1>
30235 <p>d</p>
30236 </section></div>
30237 <p>e</p>
30238
30239 </section><section data-mw-section-id="4"><h1 id="3"> 3 </h1>
30240 <p>f</p>
30241
30242 <section data-mw-section-id="5"><h2 id="3.1"> 3.1 </h2>
30243 <p>g</p>
30244 </section></section>
30245 !! end
30246
30247 !! test
30248 HTML header tags should not be wrapped in section tags
30249 !! options
30250 parsoid={
30251 "wrapSections": true
30252 }
30253 !! wikitext
30254 foo
30255
30256 <h1>a</h1>
30257
30258 = b =
30259
30260 <h1>c</h1>
30261
30262 = d =
30263 !! html/parsoid
30264 <section data-mw-section-id="0"><p>foo</p>
30265
30266 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
30267
30268 </section><section data-mw-section-id="1"><h1 id="b"> b </h1>
30269
30270 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
30271
30272 </section><section data-mw-section-id="2"><h1 id="d"> d </h1></section>
30273 !! end
30274
30275 !! test
30276 Lead section containing only whitespace and comments.
30277 !! options
30278 parsoid={
30279 "wrapSections": true
30280 }
30281 !! wikitext
30282
30283 <!-- this is a comment, presumably significant to editors -->
30284 = 1 =
30285 a
30286
30287 = 2 =
30288 b
30289 !! html/parsoid
30290 <section data-mw-section-id="0" data-parsoid="{}">
30291 <!-- this is a comment, presumably significant to editors -->
30292 </section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30293 <p>a</p>
30294
30295 </section><section data-mw-section-id="2"><h1 id="2"> 2 </h1>
30296 <p>b</p></section>
30297 !! end
30298
30299 !! test
30300 Pseudo-sections emitted by templates should have id -2
30301 !! options
30302 parsoid={
30303 "wrapSections": true
30304 }
30305 !! wikitext
30306 foo
30307 {{echo|<div>
30308 == a ==
30309 == b ==
30310 </div>
30311 }}
30312 !! html/parsoid
30313 <section data-mw-section-id="-1"><p>foo</p>
30314 </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}}]}'>
30315 <section data-mw-section-id="-1"><h2 id="a"> a </h2>
30316 </section><section data-mw-section-id="-1"><h2 id="b"> b </h2>
30317 </section></div><span about="#mwt1">
30318 </span></section>
30319 !! end