e6fa203419adaabb0749817cf87c371ab1b57c1b
[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 # Note that the html+tidy output removes the spaces after the <li>,
576 # which is a bug (https://sourceforge.net/p/tidy/bugs/945/, etc).
577 # This is an issue for all tests with lists. We intentionally do
578 # *not* add html+tidy clauses for these, as we don't want to
579 # document/test the broken behavior. (Parsoid matches the non-tidy
580 # output in these cases.)
581
582 !! test
583 Simple list
584 !! wikitext
585 * Item 1
586 * Item 2
587 !! html
588 <ul><li> Item 1</li>
589 <li> Item 2</li></ul>
590
591 !! end
592
593 !! test
594 Italics and bold
595 !! wikitext
596 * plain
597 * plain''italic''plain
598 * plain''italic''plain''italic''plain
599 * plain'''bold'''plain
600 * plain'''bold'''plain'''bold'''plain
601 * plain''italic''plain'''bold'''plain
602 * plain'''bold'''plain''italic''plain
603 * plain''italic'''bold-italic'''italic''plain
604 * plain'''bold''bold-italic''bold'''plain
605 * plain'''''bold-italic'''italic''plain
606 * plain'''''bold-italic''bold'''plain
607 * plain''italic'''bold-italic'''''plain
608 * plain'''bold''bold-italic'''''plain
609 * plain l'''italic''plain
610 * plain l''''bold''' plain
611 !! html
612 <ul><li> plain</li>
613 <li> plain<i>italic</i>plain</li>
614 <li> plain<i>italic</i>plain<i>italic</i>plain</li>
615 <li> plain<b>bold</b>plain</li>
616 <li> plain<b>bold</b>plain<b>bold</b>plain</li>
617 <li> plain<i>italic</i>plain<b>bold</b>plain</li>
618 <li> plain<b>bold</b>plain<i>italic</i>plain</li>
619 <li> plain<i>italic<b>bold-italic</b>italic</i>plain</li>
620 <li> plain<b>bold<i>bold-italic</i>bold</b>plain</li>
621 <li> plain<i><b>bold-italic</b>italic</i>plain</li>
622 <li> plain<b><i>bold-italic</i>bold</b>plain</li>
623 <li> plain<i>italic<b>bold-italic</b></i>plain</li>
624 <li> plain<b>bold<i>bold-italic</i></b>plain</li>
625 <li> plain l'<i>italic</i>plain</li>
626 <li> plain l'<b>bold</b> plain</li></ul>
627
628 !! end
629
630 # this example taken from the [[simple:Moon]] article (T49326)
631 !! test
632 Italics and possessives (1)
633 !! wikitext
634 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
635 !! html
636 <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
637 </p>
638 !! end
639
640 # this example taken from [[en:Flaming Pie]] (T51926)
641 !! test
642 Italics and possessives (2)
643 !! wikitext
644 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
645 !! html
646 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
647 </p>
648 !! end
649
650 # this example taken from [[en:Dictionary]] (T51926)
651 !! test
652 Italics and possessives (3)
653 !! wikitext
654 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''.
655 !! html
656 <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>.
657 </p>
658 !! end
659
660
661 ###
662 ### 2-quote opening sequence tests
663 ###
664 !! test
665 Italics and bold: 2-quote opening sequence: (2,2)
666 !! wikitext
667 ''foo''
668 !! html
669 <p><i>foo</i>
670 </p>
671 !!end
672
673 !! test
674 Italics and bold: 2-quote opening sequence: (2,3)
675 !! wikitext
676 ''foo'''
677 !! html/*
678 <p><i>foo'</i>
679 </p>
680 !!end
681
682 !! test
683 Italics and bold: 2-quote opening sequence: (2,4)
684 !! options
685 parsoid=wt2html
686 !! wikitext
687 ''foo''''
688 !! html/*
689 <p><i>foo''</i>
690 </p>
691 !!end
692
693 # same html as previous, but wikitext adjusted to match parsoid html2wt
694 !! test
695 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
696 !! wikitext
697 ''foo<nowiki>''</nowiki>''
698 !! html
699 <p><i>foo''</i>
700 </p>
701 !! end
702
703 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
704 !! test
705 Italics and bold: 2-quote opening sequence: (2,5)
706 !! options
707 parsoid=wt2html
708 !! wikitext
709 ''foo'''''
710 !! html/php
711 <p><i>foo</i>
712 </p>
713 !! html/parsoid
714 <p><i>foo</i><b></b>
715 </p>
716 !!end
717
718 # same html as previous, but wikitext adjusted to match parsoid html2wt
719 !! test
720 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
721 !! wikitext
722 ''foo'''''<nowiki/>'''
723 !! html/php
724 <p><i>foo</i>
725 </p>
726 !! html/parsoid
727 <p><i>foo</i><b></b>
728 </p>
729 !! end
730
731
732 ###
733 ### 3-quote opening sequence tests
734 ###
735
736 !! test
737 Italics and bold: 3-quote opening sequence: (3,2)
738 !! wikitext
739 '''foo''
740 !! html/*
741 <p>'<i>foo</i>
742 </p>
743 !!end
744
745 !! test
746 Italics and bold: 3-quote opening sequence: (3,3)
747 !! wikitext
748 '''foo'''
749 !! html
750 <p><b>foo</b>
751 </p>
752 !!end
753
754 !! test
755 Italics and bold: 3-quote opening sequence: (3,4)
756 !! wikitext
757 '''foo''''
758 !! html/*
759 <p><b>foo'</b>
760 </p>
761 !!end
762
763 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
764 !! test
765 Italics and bold: 3-quote opening sequence: (3,5)
766 !! options
767 parsoid=wt2html
768 !! wikitext
769 '''foo'''''
770 !! html/php
771 <p><b>foo</b>
772 </p>
773 !! html/parsoid
774 <p><b>foo</b><i></i>
775 </p>
776 !!end
777
778 # same html as previous, but wikitext adjusted to match parsoid html2wt
779 !! test
780 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
781 !! wikitext
782 '''foo'''''<nowiki/>''
783 !! html/php
784 <p><b>foo</b>
785 </p>
786 !! html/parsoid
787 <p><b>foo</b><i></i>
788 </p>
789 !! end
790
791
792 ###
793 ### 4-quote opening sequence tests
794 ###
795
796 !! test
797 Italics and bold: 4-quote opening sequence: (4,2)
798 !! options
799 parsoid=wt2html
800 !! wikitext
801 ''''foo''
802 !! html/*
803 <p>''<i>foo</i>
804 </p>
805 !!end
806
807 # same html as previous, but wikitext adjusted to match parsoid html2wt
808 !! test
809 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
810 !! wikitext
811 <nowiki>''</nowiki>''foo''
812 !! html
813 <p>''<i>foo</i>
814 </p>
815 !! end
816
817 !! test
818 Italics and bold: 4-quote opening sequence: (4,3)
819 !! wikitext
820 ''''foo'''
821 !! html/*
822 <p>'<b>foo</b>
823 </p>
824 !!end
825
826 !! test
827 Italics and bold: 4-quote opening sequence: (4,4)
828 !! options
829 parsoid=wt2html
830 !! wikitext
831 ''''foo''''
832 !! html/*
833 <p>'<b>foo'</b>
834 </p>
835 !!end
836
837 # same html as previous, but wikitext adjusted to match parsoid html2wt
838 !! test
839 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
840 !! wikitext
841 '<nowiki/>'''foo''''
842 !! html
843 <p>'<b>foo'</b>
844 </p>
845 !! end
846
847 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
848 !! test
849 Italics and bold: 4-quote opening sequence: (4,5)
850 !! options
851 parsoid=wt2html
852 !! wikitext
853 ''''foo'''''
854 !! html/php
855 <p>'<b>foo</b>
856 </p>
857 !! html/parsoid
858 <p>'<b>foo</b><i></i>
859 </p>
860 !!end
861
862 # same html as previous, but wikitext adjusted to match parsoid html2wt
863 !! test
864 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
865 !! wikitext
866 '<nowiki/>'''foo'''''<nowiki/>''
867 !! html/php
868 <p>'<b>foo</b>
869 </p>
870 !! html/parsoid
871 <p>'<b>foo</b><i></i>
872 </p>
873 !! end
874
875
876 ###
877 ### 5-quote opening sequence tests
878 ###
879
880 !! test
881 Italics and bold: 5-quote opening sequence: (5,2)
882 !! options
883 parsoid=wt2html
884 !! wikitext
885 '''''foo''
886 !! html/*
887 <p><b><i>foo</i></b>
888 </p>
889 !!end
890
891 # same html as previous, but wikitext adjusted to match parsoid html2wt
892 !! test
893 Italics and bold: 5-quote opening sequence: (5,2+3)
894 !! wikitext
895 '''''foo'''''
896 !! html/*
897 <p><i><b>foo</b></i>
898 </p>
899 !! end
900
901 !! test
902 Italics and bold: 5-quote opening sequence: (5,3)
903 !! options
904 parsoid=wt2html
905 !! wikitext
906 '''''foo'''
907 !! html/*
908 <p><i><b>foo</b></i>
909 </p>
910 !!end
911
912 # same html as previous, but wikitext adjusted to match parsoid html2wt
913 !! test
914 Italics and bold: 5-quote opening sequence: (5,3+2)
915 !! wikitext
916 '''''foo'''''
917 !! html
918 <p><i><b>foo</b></i>
919 </p>
920 !! end
921
922 !! test
923 Italics and bold: 5-quote opening sequence: (5,4)
924 !! options
925 parsoid=wt2html
926 !! wikitext
927 '''''foo''''
928 !! html/*
929 <p><i><b>foo'</b></i>
930 </p>
931 !!end
932
933 !! test
934 Italics and bold: 5-quote opening sequence: (5,5)
935 !! wikitext
936 '''''foo'''''
937 !! html
938 <p><i><b>foo</b></i>
939 </p>
940 !!end
941
942 !! test
943 Italics and bold: 5-quote opening sequence: (5,6)
944 !! wikitext
945 '''''foo''''''
946 !! html/*
947 <p><i><b>foo'</b></i>
948 </p>
949 !! end
950
951 ###
952 ### multiple quote sequences in a line
953 ###
954
955 !! test
956 Italics and bold: multiple quote sequences: (2,4,2)
957 !! options
958 parsoid=wt2html
959 !! wikitext
960 ''foo''''bar''
961 !! html/*
962 <p><i>foo'<b>bar</b></i>
963 </p>
964 !! end
965
966 # same html as previous, but wikitext adjusted to match parsoid html2wt
967 !! test
968 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
969 !! wikitext
970 ''foo'<nowiki/>'''bar'''''
971 !! html
972 <p><i>foo'<b>bar</b></i>
973 </p>
974 !! end
975
976 !! test
977 Italics and bold: multiple quote sequences: (2,4,3)
978 !! options
979 parsoid=wt2html
980 !! wikitext
981 ''foo''''bar'''
982 !! html/*
983 <p><i>foo'<b>bar</b></i>
984 </p>
985 !! end
986
987 # same html as previous, but wikitext adjusted to match parsoid html2wt
988 !! test
989 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
990 !! wikitext
991 ''foo'<nowiki/>'''bar'''''
992 !! html
993 <p><i>foo'<b>bar</b></i>
994 </p>
995 !! end
996
997 !! test
998 Italics and bold: multiple quote sequences: (2,4,4)
999 !! options
1000 parsoid=wt2html
1001 !! wikitext
1002 ''foo''''bar''''
1003 !! html/*
1004 <p><i>foo'<b>bar'</b></i>
1005 </p>
1006 !! end
1007
1008 # same html as previous, but wikitext adjusted to match parsoid html2wt
1009 !! test
1010 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
1011 !! wikitext
1012 ''foo'<nowiki/>'''bar'<nowiki/>'''''
1013 !! html
1014 <p><i>foo'<b>bar'</b></i>
1015 </p>
1016 !! end
1017
1018 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1019 !! test
1020 Italics and bold: multiple quote sequences: (3,4,2)
1021 !! options
1022 parsoid=wt2html
1023 !! wikitext
1024 '''foo''''bar''
1025 !! html/php
1026 <p><b>foo'</b>bar
1027 </p>
1028 !! html/parsoid
1029 <p><b>foo'</b>bar<i></i>
1030 </p>
1031 !! end
1032
1033 # same html as previous, but wikitext adjusted to match parsoid html2wt
1034 !! test
1035 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1036 !! wikitext
1037 '''foo''''bar''<nowiki/>''
1038 !! html/php
1039 <p><b>foo'</b>bar
1040 </p>
1041 !! html/parsoid
1042 <p><b>foo'</b>bar<i></i>
1043 </p>
1044 !! end
1045
1046 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1047 !! test
1048 Italics and bold: multiple quote sequences: (3,4,3)
1049 !! options
1050 parsoid=wt2html
1051 !! wikitext
1052 '''foo''''bar'''
1053 !! html/php
1054 <p><b>foo'</b>bar
1055 </p>
1056 !! html/parsoid
1057 <p><b>foo'</b>bar<b></b>
1058 </p>
1059 !! end
1060
1061 # same html as previous, but wikitext adjusted to match parsoid html2wt
1062 !! test
1063 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1064 !! wikitext
1065 '''foo''''bar'''<nowiki/>'''
1066 !! html/php
1067 <p><b>foo'</b>bar
1068 </p>
1069 !! html/parsoid
1070 <p><b>foo'</b>bar<b></b>
1071 </p>
1072 !! end
1073
1074 ###
1075 ### other quote tests
1076 ###
1077 !! test
1078 Italics and bold: other quote tests: (2,3,5)
1079 !! wikitext
1080 ''this is about '''foo's family'''''
1081 !! html
1082 <p><i>this is about <b>foo's family</b></i>
1083 </p>
1084 !!end
1085
1086
1087 !! test
1088 Italics and bold: other quote tests: (2,(3,3),2)
1089 !! wikitext
1090 ''this is about '''foo's''' family''
1091 !! html
1092 <p><i>this is about <b>foo's</b> family</i>
1093 </p>
1094 !!end
1095
1096
1097 !! test
1098 Italics and bold: other quote tests: (3,2,3,2)
1099 !! options
1100 parsoid=wt2html
1101 !! wikitext
1102 '''this is about ''foo'''s family''
1103 !! html/*
1104 <p><b>this is about <i>foo</i></b><i>s family</i>
1105 </p>
1106 !!end
1107
1108
1109 # same html as previous, but wikitext adjusted to match parsoid html2wt
1110 !! test
1111 Italics and bold: other quote tests: (3,2,3+2+2,2)
1112 !! wikitext
1113 '''this is about ''foo'''''<nowiki/>''s family''
1114 !! html
1115 <p><b>this is about <i>foo</i></b><i>s family</i>
1116 </p>
1117 !! end
1118
1119
1120 !! test
1121 Italics and bold: other quote tests: (3,2,3,3)
1122 !! wikitext
1123 '''this is about ''foo'''s family'''
1124 !! html/*
1125 <p>'<i>this is about </i>foo<b>s family</b>
1126 </p>
1127 !!end
1128
1129
1130 !! test
1131 Italics and bold: other quote tests: (3,(2,2),3)
1132 !! wikitext
1133 '''this is about ''foo's'' family'''
1134 !! html
1135 <p><b>this is about <i>foo's</i> family</b>
1136 </p>
1137 !!end
1138
1139
1140 !! test
1141 Italicized possessive
1142 !! wikitext
1143 The ''[[Main Page]]'''s talk page.
1144 !! html/php
1145 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1146 </p>
1147 !! html/parsoid
1148 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1149 !! end
1150
1151 !! test
1152 Parsoid only: Quote balancing context should be restricted to td/th cells on the same wikitext line
1153 (Requires tidy for PHP parser output to be fixed up)
1154 !! options
1155 parsoid=wt2html,wt2wt
1156 !! wikitext
1157 {|
1158 !''a!!''b
1159 |''a||''b
1160 |}
1161 !! html/php+tidy
1162 <table>
1163 <tr>
1164 <th><i>a</i></th>
1165 <th><i>b</i></th>
1166 <td><i>a</i></td>
1167 <td><i>b</i></td>
1168 </tr>
1169 </table>
1170 !! html/parsoid
1171 <table>
1172 <tbody><tr><th><i>a</i></th><th><i>b</i></th>
1173 <td><i>a</i></td><td><i>b</i></td></tr>
1174 </tbody></table>
1175 !! end
1176
1177 ###
1178 ### Non-html5 tags
1179 ###
1180
1181 !! test
1182 Non-html5 tags should be accepted
1183 !! wikitext
1184 <center>''foo''</center>
1185 <big>''foo''</big>
1186 <font>''foo''</font>
1187 <strike>''foo''</strike>
1188 <tt>''foo''</tt>
1189 !! html
1190 <center><i>foo</i></center>
1191 <p><big><i>foo</i></big>
1192 <font><i>foo</i></font>
1193 <strike><i>foo</i></strike>
1194 <tt><i>foo</i></tt>
1195 </p>
1196 !! end
1197
1198 !! test
1199 <wbr> is valid wikitext (T54468)
1200 !! wikitext
1201 <wbr>
1202 !! html
1203 <p><wbr />
1204 </p>
1205 !! end
1206
1207 # <strike> is HTML4, <s> is HTML4/5.
1208 !! test
1209 <s> or <strike> for strikethrough
1210 !! wikitext
1211 <strike>strike</strike>
1212
1213 <s>s</s>
1214 !! html
1215 <p><strike>strike</strike>
1216 </p><p><s>s</s>
1217 </p>
1218 !! end
1219
1220 ## a not permitted
1221 ## i,b,br omitted
1222 !! test
1223 Text-level semantic html elements in wikitext
1224 !! wikitext
1225 <em>text</em>
1226 <strong>text</strong>
1227 <small>text</small>
1228 <s>text</s>
1229 <cite>text</cite>
1230 <q>text</q>
1231 <dfn>text</dfn>
1232 <abbr>text</abbr>
1233 <data>text</data>
1234 <time>text</time>
1235 <code>text</code>
1236 <var>text</var>
1237 <samp>text</samp>
1238 <kbd>text</kbd>
1239 <sub>text</sub>
1240 <u>text</u>
1241 <mark>text</mark>
1242 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1243 <bdi>text</bdi>
1244 <bdo>text</bdo>
1245 <span>text</span>
1246 <wbr />
1247 !! html
1248 <p><em>text</em>
1249 <strong>text</strong>
1250 <small>text</small>
1251 <s>text</s>
1252 <cite>text</cite>
1253 <q>text</q>
1254 <dfn>text</dfn>
1255 <abbr>text</abbr>
1256 <data>text</data>
1257 <time>text</time>
1258 <code>text</code>
1259 <var>text</var>
1260 <samp>text</samp>
1261 <kbd>text</kbd>
1262 <sub>text</sub>
1263 <u>text</u>
1264 <mark>text</mark>
1265 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1266 <bdi>text</bdi>
1267 <bdo>text</bdo>
1268 <span>text</span>
1269 <wbr />
1270 </p>
1271 !! end
1272
1273 # test cases taken from
1274 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1275 !! test
1276 Ruby markup (W3C-style)
1277 !! wikitext
1278 ; Mono-ruby for individual base characters
1279 : <ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1280 ; Group ruby
1281 : <ruby>今日<rt>きょう</rt></ruby>
1282 ; Jukugo ruby
1283 : <ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1284 ; Inline ruby
1285 : <ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1286 ; Double-sided ruby
1287 : <ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1288 <ruby>
1289 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1290 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1291 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1292 </ruby>
1293 !! html
1294 <dl><dt> Mono-ruby for individual base characters</dt>
1295 <dd> <ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1296 <dt> Group ruby</dt>
1297 <dd> <ruby>今日<rt>きょう</rt></ruby></dd>
1298 <dt> Jukugo ruby</dt>
1299 <dd> <ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1300 <dt> Inline ruby</dt>
1301 <dd> <ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1302 <dt> Double-sided ruby</dt>
1303 <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>
1304 <p><ruby>
1305 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1306 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1307 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1308 </ruby>
1309 </p>
1310 !! end
1311
1312 # The next two test different paths in the sanitizer.
1313 !! test
1314 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1315 !! wikitext
1316 <blockquote|>a</blockquote>
1317
1318 <b→> doesn't terminate </b→>
1319
1320 <bä> doesn't terminate </bä>
1321
1322 <boo> doesn't terminate </boo>
1323
1324 <s.foo> doesn't terminate </s.foo>
1325
1326 <sub-ID#1>
1327 !! html
1328 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1329 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1330 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1331 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1332 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1333 </p><p>&lt;sub-ID#1&gt;
1334 </p>
1335 !! end
1336
1337 # There is a tidy bug here: https://sourceforge.net/p/tidy/bugs/946/
1338 # If the non-word-character tag made it through the sanitizer, tidy
1339 # would munge it up.
1340 !! test
1341 Non-word characters don't terminate tag names + tidy
1342 !! wikitext
1343 <blockquote|>a</blockquote>
1344
1345 <b→> doesn't terminate </b→>
1346
1347 <bä> doesn't terminate </bä>
1348
1349 <boo> doesn't terminate </boo>
1350
1351 <s.foo> doesn't terminate </s.foo>
1352
1353 <sub-ID#1>
1354 !! html+tidy
1355 <p>&lt;blockquote|&gt;a</p>
1356 <p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;</p>
1357 <p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;</p>
1358 <p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;</p>
1359 <p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;</p>
1360 <p>&lt;sub-ID#1&gt;</p>
1361 !! end
1362
1363 ###
1364 ### See tests/parser/parserTestsParserHook.php for the <tåg> extension)
1365 ### This checks that HTML5 tags (with non-word characters in the tag
1366 ### name) make it safely through the parser -- the Sanitizer will
1367 ### munge them later, as it should.
1368 ###
1369 !! test
1370 Non-word characters are valid in extension tags (T19663)
1371 !! wikitext
1372 <tåg>tåg</tåg>
1373 !! html/php
1374 <pre>
1375 'tåg'
1376 array (
1377 )
1378 </pre>
1379
1380 !! html/parsoid
1381 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1382 !! end
1383
1384 !! test
1385 Isolated close tags should be treated as literal text (T54760)
1386 !! options
1387 parsoid=wt2html
1388 !! wikitext
1389 </b>
1390
1391 <s.foo>s</s>
1392 !! html/php+tidy
1393 <p>&lt;s.foo&gt;s</p>
1394 !! html/parsoid
1395 <p>&lt;s.foo&gt;s</p>
1396 !! end
1397
1398 ###
1399 ### Special characters
1400 ###
1401
1402 !! test
1403 Bare pipe character (T54363)
1404 !! wikitext
1405 |
1406 !! html
1407 <p>|
1408 </p>
1409 !! end
1410
1411 !! test
1412 Bare pipe character from a template (T54363)
1413 !! wikitext
1414 {{pipe}}
1415 !! html
1416 <p>|
1417 </p>
1418 !! end
1419
1420 ###
1421 ### <nowiki> test cases
1422 ###
1423
1424 !! test
1425 <nowiki> unordered list
1426 !! wikitext
1427 <nowiki>* This is not an unordered list item.</nowiki>
1428 !! html/php
1429 <p>* This is not an unordered list item.
1430 </p>
1431 !! html/parsoid
1432 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1433 !! end
1434
1435 !! test
1436 <nowiki> spacing
1437 !! wikitext
1438 <nowiki>Lorem ipsum dolor
1439
1440 sed abit.
1441 sed nullum.
1442
1443 :and a colon
1444 </nowiki>
1445 !! html/php
1446 <p>Lorem ipsum dolor
1447
1448 sed abit.
1449 sed nullum.
1450
1451 :and a colon
1452
1453 </p>
1454 !! html/parsoid
1455 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1456
1457 sed abit.
1458 sed nullum.
1459
1460 :and a colon
1461 </span></p>
1462 !! end
1463
1464 !! test
1465 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1466 !! wikitext
1467 <nowiki><span class="error"></nowiki>
1468 !! html/php
1469 <p>&lt;span class="error"&gt;
1470 </p>
1471 !! html/parsoid
1472 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1473 !! end
1474
1475 !! test
1476 nowiki 3
1477 !! wikitext
1478 :There is not nowiki.
1479 :There is <nowiki>nowiki</nowiki>.
1480
1481 #There is not nowiki.
1482 #There is <nowiki>nowiki</nowiki>.
1483
1484 *There is not nowiki.
1485 *There is <nowiki>nowiki</nowiki>.
1486 !! html/php
1487 <dl><dd>There is not nowiki.</dd>
1488 <dd>There is nowiki.</dd></dl>
1489 <ol><li>There is not nowiki.</li>
1490 <li>There is nowiki.</li></ol>
1491 <ul><li>There is not nowiki.</li>
1492 <li>There is nowiki.</li></ul>
1493
1494 !! html/parsoid
1495 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1496 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1497
1498 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1499 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1500
1501 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1502 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1503 !! end
1504
1505 !! test
1506 Entities inside <nowiki>
1507 !! wikitext
1508 <nowiki>&lt;</nowiki>
1509 !! html/php
1510 <p>&lt;
1511 </p>
1512 !! html/parsoid
1513 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1514 !! end
1515
1516 !! test
1517 Entities inside template parameters
1518 !! wikitext
1519 {{echo|&ndash;}}
1520 !! html/php+tidy
1521 <p>–</p>
1522 !! html/parsoid
1523 <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>
1524 !! end
1525
1526 !! test
1527 Properly escape nowiki when combined with other wiki markup
1528 !! options
1529 parsoid=html2wt
1530 !! html/parsoid
1531 <p>* &lt;/nowiki&gt; tag</p>
1532 !! wikitext
1533 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1534 !! end
1535
1536 !! test
1537 T93824: Put escaped HTML tags inside nowiki
1538 !! options
1539 parsoid=html2wt
1540 !! html/parsoid
1541 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1542 !! wikitext
1543 <nowiki><h2>foo</h2></nowiki>
1544 !! end
1545
1546 !! test
1547 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1548 !! options
1549 parsoid=html2wt
1550 !! html/parsoid
1551 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1552 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1553 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1554 !! wikitext
1555 This text: L'[[Foo]]
1556 This text: L<nowiki>''</nowiki>[[Foo]]
1557 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1558 !! end
1559
1560 # This test fails because wikitext whitespace is not normalized before comparing.
1561 !! test
1562 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1563 !! options
1564 parsoid=html2wt
1565 !! html/parsoid
1566 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1567 </p>
1568 !! wikitext
1569 This text : L<nowiki>''</nowiki>[[Foo]]
1570 !! end
1571
1572 # This test and the next one are html2wt only as they test that incorrect wikitext
1573 # passed in template arguments gets escaped or wrapped in nowikis where required.
1574 !! test
1575 T71482: Use {{!}} instead of nowiki for single pipe in template argument
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;foo|bar&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;foo|bar |[[&quot;}},&quot;i&quot;:0}}]}" about="#mwt2"></p>
1581 !! wikitext
1582 {{echo|foo{{!}}bar}}
1583 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1584 !! end
1585
1586 !! test
1587 T53961: Output correct nowikis in template arguments
1588 !! options
1589 parsoid=html2wt
1590 !! html/parsoid
1591 <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>
1592 <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>
1593 <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>
1594 <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>
1595 <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>
1596 !! wikitext
1597 {{echo|a [ b}}
1598 {{echo|<nowiki>a }} b</nowiki>}}
1599 {{echo|<nowiki>a [[ b</nowiki>}}
1600 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1601 {{echo|a <nowiki>}</nowiki>}}
1602 !! end
1603
1604 !! test
1605 Cases where "!!" needs nowiki protection
1606 !! options
1607 parsoid=html2wt
1608 !! html/parsoid
1609 <table>
1610 <tr><th>this needs protection !! here</th></tr>
1611 </table>
1612
1613 <table>
1614 <tr><th>this does not need
1615 protection !! here</th></tr>
1616 </table>
1617 !! wikitext
1618 {|
1619 !<nowiki>this needs protection !! here</nowiki>
1620 |}
1621
1622 {|
1623 !this does not need
1624 protection !! here
1625 |}
1626 !! end
1627
1628 ###
1629 ### Comments
1630 ###
1631 !! test
1632 Comments and Indent-Pre
1633 !! wikitext
1634 <!-- comment 1 --> asdf
1635
1636 <!-- comment 1 --> asdf
1637 <!-- comment 2 -->
1638
1639 <!-- comment 1 --> asdf
1640 <!-- comment 2 -->xyz
1641
1642 <!-- comment 1 --> asdf
1643 <!-- comment 2 --> xyz
1644 !! html
1645 <pre>asdf
1646 </pre>
1647 <pre>asdf
1648 </pre>
1649 <pre>asdf
1650 </pre>
1651 <p>xyz
1652 </p>
1653 <pre>asdf
1654 xyz
1655 </pre>
1656 !! end
1657
1658 !! test
1659 Comment test 2a
1660 !! wikitext
1661 asdf
1662 <!-- comment 1 -->
1663 jkl
1664 !! html
1665 <p>asdf
1666 jkl
1667 </p>
1668 !! end
1669
1670 !! test
1671 Comment test 2b
1672 !! wikitext
1673 asdf
1674 <!-- comment 1 -->
1675
1676 jkl
1677 !! html
1678 <p>asdf
1679 </p><p>jkl
1680 </p>
1681 !! end
1682
1683 !! test
1684 Comment test 3
1685 !! wikitext
1686 asdf
1687 <!-- comment 1 -->
1688 <!-- comment 2 -->
1689 jkl
1690 !! html
1691 <p>asdf
1692 jkl
1693 </p>
1694 !! end
1695
1696 !! test
1697 Comment test 4
1698 !! wikitext
1699 asdf<!-- comment 1 -->jkl
1700 !! html
1701 <p>asdfjkl
1702 </p>
1703 !! end
1704
1705 !! test
1706 Comment spacing
1707 !! wikitext
1708 a
1709 <!-- foo --> b <!-- bar -->
1710 c
1711 !! html
1712 <p>a
1713 </p>
1714 <pre> b
1715 </pre>
1716 <p>c
1717 </p>
1718 !! end
1719
1720 !! test
1721 Comment whitespace
1722 !! wikitext
1723 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1724 !! html
1725
1726 !! end
1727
1728 !! test
1729 Comment semantics and delimiters
1730 !! wikitext
1731 <!-- --><!----><!-----><!------>
1732 !! html/php
1733
1734 !! html/parsoid
1735 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1736 !! end
1737
1738 !! test
1739 Comment semantics and delimiters, redux
1740 !! wikitext
1741 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1742 -- foo -- funky huh? ... -->
1743 !! html/php
1744
1745 !! html/parsoid
1746 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1747 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1748 !! end
1749
1750 !! test
1751 Comment semantics and delimiters: directors cut
1752 !! wikitext
1753 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1754 everything starting with < followed by !-- until the first -- and > we see,
1755 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1756 -->-->
1757 !! html/php
1758 <p>--&gt;
1759 </p>
1760 !! html/parsoid
1761 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1762 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1763 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1764 --><p>--></p>
1765 !! end
1766
1767 !! test
1768 Comment semantics: nesting
1769 !! wikitext
1770 <!--<!-- no, we're not going to do anything fancy here -->-->
1771 !! html/php
1772 <p>--&gt;
1773 </p>
1774 !! html/parsoid
1775 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1776 !! end
1777
1778 # Parsoid closes the unclosed comment, even if it means a slight
1779 # round-trip diff.
1780 !! test
1781 Comment semantics: unclosed comment at end
1782 !! options
1783 parsoid=wt2html,html2html
1784 !! wikitext
1785 <!--This comment will run out to the end of the document
1786 !! html/php
1787
1788 !! html/parsoid
1789 <!--This comment will run out to the end of the document-->
1790 !! end
1791
1792 !! test
1793 Comment semantics: normalize comments to play nice with XML and browsers
1794 !! wikitext
1795 <!-- Browsers --!> think this is closed -->
1796 <!--> This would normally be text -->
1797 <!---> As would this -->
1798 <!-- XML doesn't like trailing dashes -------->
1799 <!-- Nor doubled hyphens -- anywhere in the data -->
1800 But this is not a comment.
1801 !! html/php
1802 <p>But this is not a comment.
1803 </p>
1804 !! html/parsoid
1805 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1806 <!--&#x3E; This would normally be text -->
1807 <!--&#x2D;&#x3E; As would this -->
1808 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1809 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1810 <p>But this is not a comment.</p>
1811 !! end
1812
1813 !! test
1814 Comment semantics: round-trip even text which contains encoded -->
1815 !! wikitext
1816 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1817 !! html/parsoid
1818 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1819 !! end
1820
1821 !! test
1822 Comment in template title
1823 !! wikitext
1824 {{f<!---->oo}}
1825 !! html
1826 <p>FOO
1827 </p>
1828 !! end
1829
1830 !! test
1831 Comment on its own line post-expand
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 Comment on its own line post-expand with non-significant whitespace
1844 !! wikitext
1845 a
1846 {{blank}} <!---->
1847 b
1848 !! html
1849 <p>a
1850 </p><p>b
1851 </p>
1852 !! end
1853
1854 !! test
1855 Multiple comments should still parse as SOL-transparent
1856 !! options
1857 parsoid=wt2html,wt2wt
1858 !! wikitext
1859 <!--c1-->*a
1860 <!--c2--><!--c3--><!--c4-->*b
1861 !! html/php
1862 <ul><li>a</li>
1863 <li>b</li></ul>
1864
1865 !! html/parsoid
1866 <!--c1--><ul>
1867 <li>a
1868 </li>
1869 <!--c2--><!--c3--><!--c4-->
1870 <li>b
1871 </li>
1872 </ul>
1873 !! end
1874
1875 ## Make sure ">" gets escaped in comments to avoid XSS
1876 !! test
1877 IE conditional comments
1878 !! wikitext
1879 <!--[if lt IE 9]>
1880 <script>alert('hi');</script>
1881 <![endif]-->
1882 !! html/parsoid
1883 <!--[if lt IE 9]&#x3E;
1884 <script&#x3E;alert('hi');</script&#x3E;
1885 <![endif]-->
1886 !! end
1887
1888 ###
1889 ### paragraph wrapping tests
1890 ###
1891 !! test
1892 No block tags
1893 !! wikitext
1894 a
1895
1896 b
1897 !! html
1898 <p>a
1899 </p><p>b
1900 </p>
1901 !! end
1902
1903 !! test
1904 Block tag on one line (<div>)
1905 !! wikitext
1906 a <div>foo</div>
1907
1908 b
1909 !! html
1910 a <div>foo</div>
1911 <p>b
1912 </p>
1913 !! html+tidy
1914 <p>a</p>
1915 <div>foo</div>
1916 <p>b</p>
1917 !! end
1918
1919 !! test
1920 No p-wrappable content
1921 !! wikitext
1922 <span><div>x</div></span>
1923 <span><s><div>x</div></s></span>
1924 <small><em></em></small><span><s><div>x</div></s></span>
1925 !! html+tidy
1926 <div><span>x</span></div>
1927 <div><span><s>x</s></span></div>
1928 <div><span><s>x</s></span></div>
1929 !! html/parsoid
1930 <span><div>x</div></span>
1931 <span><s><div>x</div></s></span>
1932 <small><em></em></small><span><s><div>x</div></s></span>
1933 !! end
1934
1935 # T177612: Parsoid-only test
1936 !! test
1937 Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
1938 !! wikitext
1939 {{echo|<span><div>x</div></span>}}
1940 x
1941 !! html/parsoid
1942 <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>
1943 <p>x</p>
1944 !! end
1945
1946 !! test
1947 Block tag on one line (<blockquote>)
1948 !! wikitext
1949 a <blockquote>foo</blockquote>
1950
1951 b
1952 !! html
1953 a <blockquote>foo</blockquote>
1954 <p>b
1955 </p>
1956 !! html+tidy
1957 <p>a</p>
1958 <blockquote>
1959 <p>foo</p>
1960 </blockquote>
1961 <p>b</p>
1962 !! end
1963
1964 !! test
1965 Block tag on both lines (<div>)
1966 !! wikitext
1967 a <div>foo</div>
1968
1969 b <div>foo</div>
1970 !! html
1971 a <div>foo</div>
1972 b <div>foo</div>
1973
1974 !! html+tidy
1975 <p>a</p>
1976 <div>foo</div>
1977 <p>b</p>
1978 <div>foo</div>
1979 !! end
1980
1981 !! test
1982 Block tag on both lines (<blockquote>)
1983 !! wikitext
1984 a <blockquote>foo</blockquote>
1985
1986 b <blockquote>foo</blockquote>
1987 !! html
1988 a <blockquote>foo</blockquote>
1989 b <blockquote>foo</blockquote>
1990
1991 !! html+tidy
1992 <p>a</p>
1993 <blockquote>
1994 <p>foo</p>
1995 </blockquote>
1996 <p>b</p>
1997 <blockquote>
1998 <p>foo</p>
1999 </blockquote>
2000 !! end
2001
2002 !! test
2003 Multiple lines without block tags
2004 !! wikitext
2005 <div>foo</div> a
2006 b
2007 c
2008 d<!--foo--> e
2009 x <div>foo</div> z
2010 !! html
2011 <div>foo</div> a
2012 <p>b
2013 c
2014 d e
2015 </p>
2016 x <div>foo</div> z
2017
2018 !! html+tidy
2019 <div>foo</div>
2020 <p>a</p>
2021 <p>b c d e</p>
2022 <p>x</p>
2023 <div>foo</div>
2024 <p>z</p>
2025 !! end
2026
2027 # Tidy strips out the empty <div> tags. Parsoid doesn't.
2028 # So, we have a separate section for Parsoid. We don't want
2029 # to mimic this stripping behavior in Parsoid. It affects
2030 # editing experience and also requires us to maintain additional
2031 # info for RT-ing.
2032 !! test
2033 Empty lines between lines with block tags
2034 !! wikitext
2035 <div></div>
2036
2037
2038 <div></div>a
2039
2040 b
2041 <div>a</div>b
2042
2043 <div>b</div>d
2044
2045
2046 <div>e</div>
2047 !! html
2048 <div></div>
2049 <p><br />
2050 </p>
2051 <div></div>a
2052 <p>b
2053 </p>
2054 <div>a</div>b
2055 <div>b</div>d
2056 <p><br />
2057 </p>
2058 <div>e</div>
2059
2060 !! html+tidy
2061 <p><br /></p>
2062 <p>a</p>
2063 <p>b</p>
2064 <div>a</div>
2065 <p>b</p>
2066 <div>b</div>
2067 <p>d</p>
2068 <p><br /></p>
2069 <div>e</div>
2070 !! html/parsoid
2071 <div data-parsoid='{"stx":"html"}'></div>
2072
2073 <p><br /></p>
2074 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2075
2076 <p>b</p>
2077 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2078
2079 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2080
2081 <p><br /></p>
2082 <div data-parsoid='{"stx":"html"}'>e</div>
2083 !! end
2084
2085 ## PHP parser emits output which is broken
2086 !! test
2087 Unclosed HTML p-tags should be handled properly
2088 !! wikitext
2089 <div><p>foo</div>
2090 a
2091
2092 b
2093 !! html/php+tidy
2094 <div>
2095 <p>foo</p>
2096 </div>
2097 <p>a</p>
2098 <p>b</p>
2099 !! html/parsoid
2100 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2101 <p>a</p>
2102 <p>b</p>
2103 !! end
2104
2105 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2106 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2107 ## them for now.
2108 !! test
2109 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2110 !! options
2111 parsoid=wt2html
2112 !! wikitext
2113 a [[Category:A1]] [[Category:A2]]
2114 [[Category:A3]]
2115 [[Category:A4]]
2116 !! html/parsoid
2117 <p>a</p>
2118 <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"/>
2119 !! end
2120
2121 !! test
2122 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2123 !! options
2124 parsoid=wt2html
2125 !! wikitext
2126 [[Category:A1]]a
2127 !! html/parsoid
2128 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2129 !! end
2130
2131 ###
2132 ### Preformatted text
2133 ###
2134 !! test
2135 Preformatted text
2136 !! wikitext
2137 This is some
2138 Preformatted text
2139 With ''italic''
2140 And '''bold'''
2141 And a [[Main Page|link]]
2142 !! html
2143 <pre>This is some
2144 Preformatted text
2145 With <i>italic</i>
2146 And <b>bold</b>
2147 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2148 </pre>
2149 !! end
2150
2151 !! test
2152 Tabs don't trigger preformatted text
2153 !! wikitext
2154 This is not
2155 preformatted text.
2156 This is preformatted text.
2157 So is this.
2158 !! html/php
2159 <p> This is not
2160 preformatted text.
2161 </p>
2162 <pre>This is preformatted text.
2163 So is this.
2164 </pre>
2165 !! html/parsoid
2166 <p> This is not
2167 preformatted text.</p>
2168 <pre>This is preformatted text.
2169 So is this.</pre>
2170 !! end
2171
2172 !! test
2173 Space before tab needs nowiki pre protection
2174 !! options
2175 parsoid=html2wt
2176 !! html/parsoid
2177 <p> a</p>
2178 !! wikitext
2179 <nowiki> </nowiki> a
2180 !! end
2181
2182 !! test
2183 Ident preformatting with inline content
2184 !! wikitext
2185 a
2186 ''b''
2187 !! html
2188 <pre>a
2189 <i>b</i>
2190 </pre>
2191 !! end
2192
2193 !! test
2194 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2195 !! wikitext
2196 <pre><nowiki>
2197 <b>
2198 <cite>
2199 <em>
2200 </nowiki></pre>
2201 !! html
2202 <pre>
2203 &lt;b&gt;
2204 &lt;cite&gt;
2205 &lt;em&gt;
2206 </pre>
2207
2208 !! end
2209
2210 !! test
2211 Regression with preformatted in <center>
2212 !! wikitext
2213 <center>
2214 Blah
2215 </center>
2216 !! html
2217 <center>
2218 <pre>Blah
2219 </pre>
2220 </center>
2221
2222 !! end
2223
2224 !! test
2225 T54763: Preformatted in <blockquote>
2226 !! wikitext
2227 <blockquote>
2228 Blah
2229 {|
2230 |
2231 indented cell (no pre-wrapping!)
2232 |}
2233 </blockquote>
2234 !! html
2235 <blockquote>
2236 <p> Blah
2237 </p>
2238 <table>
2239 <tr>
2240 <td>
2241 <p> indented cell (no pre-wrapping!)
2242 </p>
2243 </td></tr></table>
2244 </blockquote>
2245
2246 !! end
2247
2248 !! test
2249 T53086: Double newlines in blockquotes should be turned into paragraphs
2250 !! wikitext
2251 <blockquote>
2252 Foo
2253
2254 Bar
2255 </blockquote>
2256 !! html
2257 <blockquote>
2258 <p>Foo
2259 </p><p>Bar
2260 </p>
2261 </blockquote>
2262
2263 !! end
2264
2265 !! test
2266 T17491: <ins>/<del> in blockquote
2267 !! wikitext
2268 <blockquote>
2269 Foo <del>bar</del> <ins>baz</ins> quux
2270 </blockquote>
2271 !! html
2272 <blockquote>
2273 <p>Foo <del>bar</del> <ins>baz</ins> quux
2274 </p>
2275 </blockquote>
2276
2277 !! end
2278
2279 # Note that the p-wrapping is newline sensitive, which could be
2280 # considered a bug: tidy will wrap only the 'Foo' in the example
2281 # below in a <p> tag. (see comment 23-25 of T8200)
2282 !! test
2283 T17491: <ins>/<del> in blockquote (2)
2284 !! wikitext
2285 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2286 </blockquote>
2287 !! html
2288 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2289 </blockquote>
2290
2291 !! html+tidy
2292 <blockquote>
2293 <p>Foo</p>
2294 <del>bar</del> <ins>baz</ins> quux</blockquote>
2295 !! end
2296
2297 !! test
2298 <pre> with attributes (T5202)
2299 !! wikitext
2300 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2301 !! html
2302 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2303
2304 !! end
2305
2306 !! test
2307 <pre> with width attribute (T5202)
2308 !! wikitext
2309 <pre width="8">Narrow screen goodies</pre>
2310 !! html
2311 <pre width="8">Narrow screen goodies</pre>
2312
2313 !! end
2314
2315 !! test
2316 <pre> with forbidden attribute (T5202)
2317 !! wikitext
2318 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2319 !! html
2320 <pre width="8">Narrow screen goodies</pre>
2321
2322 !! end
2323
2324 !! test
2325 Entities inside <pre>
2326 !! wikitext
2327 <pre>&lt;</pre>
2328 !! html
2329 <pre>&lt;</pre>
2330
2331 !! end
2332
2333 !! test
2334 <pre> with forbidden attribute values (T5202)
2335 !! wikitext
2336 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2337 !! html
2338 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2339
2340 !! end
2341
2342 !! test
2343 <nowiki> inside <pre> (T15238)
2344 !! wikitext
2345 <pre>
2346 <nowiki>
2347 </pre>
2348 <pre>
2349 <nowiki></nowiki>
2350 </pre>
2351 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2352 !! html
2353 <pre>
2354 &lt;nowiki&gt;
2355 </pre>
2356 <pre>
2357
2358 </pre>
2359 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2360
2361 !! end
2362
2363 !! test
2364 <nowiki> inside of #tag:pre
2365 !! wikitext
2366 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2367 !! html/php
2368 <pre>Foo &#8594;bar</pre>
2369
2370 !! html/parsoid
2371 <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>
2372 !! end
2373
2374 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2375 ## aren't enclosed in nowikis.
2376 !! test
2377 <nowiki> and <pre> preference (first one wins)
2378 !! options
2379 parsoid=wt2html
2380 !! wikitext
2381 <pre>
2382 <nowiki>
2383 </pre>
2384 </nowiki>
2385 </pre>
2386
2387 <nowiki>
2388 <pre>
2389 <nowiki>
2390 </pre>
2391 </nowiki>
2392 </pre>
2393
2394 !! html/php
2395 <pre>
2396 &lt;nowiki&gt;
2397 </pre>
2398 <p>&lt;/nowiki&gt;
2399 &lt;/pre&gt;
2400 </p><p>
2401 &lt;pre&gt;
2402 &lt;nowiki&gt;
2403 &lt;/pre&gt;
2404
2405 &lt;/pre&gt;
2406 </p>
2407 !! html/parsoid
2408 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2409 </pre>
2410 <p>&lt;/nowiki></p>
2411
2412
2413 <p><span typeof="mw:Nowiki">
2414 &lt;pre>
2415 &lt;nowiki>
2416 &lt;/pre>
2417 </span></p>
2418 !! end
2419
2420 !! test
2421 </pre> inside nowiki
2422 !! wikitext
2423 <nowiki></pre></nowiki>
2424 !! html
2425 <p>&lt;/pre&gt;
2426 </p>
2427 !! end
2428
2429 # Parsoid doesn't strip empty tags, like Tidy does.
2430 !! test
2431 Empty pre; pre inside other HTML tags (T56946)
2432 !! wikitext
2433 a
2434
2435 <div><pre>
2436 foo
2437 </pre></div>
2438 <pre></pre>
2439 !! html/php
2440 <p>a
2441 </p>
2442 <div><pre>
2443 foo
2444 </pre></div>
2445 <pre></pre>
2446
2447 !! html/php+tidy
2448 <p>a</p>
2449 <div>
2450 <pre>
2451 foo
2452 </pre></div>
2453 !! html/parsoid
2454 <p>a</p>
2455
2456 <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
2457 </pre></div>
2458 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2459 !! end
2460
2461 !! test
2462 HTML pre followed by indent-pre
2463 !! wikitext
2464 <pre>foo</pre>
2465 bar
2466 !! html
2467 <pre>foo</pre>
2468 <pre>bar
2469 </pre>
2470 !! end
2471
2472 # Note that tidy removes the empty <p> tags from the start and end.
2473 # Parsoid does not, by design.
2474 !! test
2475 Block tag pre
2476 !! wikitext
2477 <p><pre>foo</pre></p>
2478 !! html/php+tidy
2479 <pre>
2480 foo
2481 </pre>
2482 !! html/parsoid
2483 <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>
2484 !! end
2485
2486 !!test
2487 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2488 !! wikitext
2489 {{echo|}}
2490 !! html
2491
2492 !!end
2493
2494 !!test
2495 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2496 !! wikitext
2497 {{echo|
2498 foo}}
2499 !! html
2500 <p>foo
2501 </p>
2502 !!end
2503
2504 !! test
2505 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2506 !! wikitext
2507 {{echo|a
2508 b}}
2509 !! html
2510 <pre>a
2511 </pre>
2512 <p>b
2513 </p>
2514 !!end
2515
2516 !! test
2517 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2518 !! wikitext
2519 {{echo|a
2520 b
2521 c
2522 d
2523 e
2524 }}
2525 !! html
2526 <pre>a
2527 </pre>
2528 <p>b
2529 c
2530 </p>
2531 <pre>d
2532 </pre>
2533 <p>e
2534 </p>
2535 !!end
2536
2537 !!test
2538 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2539 !! wikitext
2540 {{echo| foo}}
2541
2542 {{echo| foo}}{{echo| bar}}
2543
2544 {{echo| foo}}
2545 {{echo| bar}}
2546
2547 {{echo|<!--cmt--> foo}}
2548
2549 <!--cmt-->{{echo| foo}}
2550
2551 {{echo|{{echo| }}bar}}
2552 !! html
2553 <pre>foo
2554 </pre>
2555 <pre>foo bar
2556 </pre>
2557 <pre>foo
2558 bar
2559 </pre>
2560 <pre>foo
2561 </pre>
2562 <pre>foo
2563 </pre>
2564 <pre>bar
2565 </pre>
2566 !!end
2567
2568 !! test
2569 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2570 !! wikitext
2571 {{echo| }}a
2572
2573 {{echo|
2574 }}a
2575
2576 {{echo|
2577 b}}
2578
2579 {{echo|a
2580 }}b
2581
2582 {{echo|a
2583 }} b
2584 !! html
2585 <pre>a
2586 </pre>
2587 <p><br />
2588 </p>
2589 <pre>a
2590 </pre>
2591 <p><br />
2592 </p>
2593 <pre>b
2594 </pre>
2595 <p>a
2596 </p>
2597 <pre>b
2598 </pre>
2599 <p>a
2600 </p>
2601 <pre>b
2602 </pre>
2603 !!end
2604
2605 ## Hmm, should Parsoid rt this?
2606 !! test
2607 Pres with newline attributes
2608 !! options
2609 parsoid=wt2html,html2html
2610 !! wikitext
2611 <pre class="one
2612 two">hi</pre>
2613 !! html/php
2614 <pre class="one two">hi</pre>
2615
2616 !! html/parsoid
2617 <pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2618 !! end
2619
2620 !! test
2621 Things that look like <pre> tags aren't treated as such
2622 !! wikitext
2623 Barack Obama <President> of the United States
2624 <President></President>
2625 !! html
2626 <p>Barack Obama &lt;President&gt; of the United States
2627 &lt;President&gt;&lt;/President&gt;
2628 </p>
2629 !! end
2630
2631 !! test
2632 Handle broken pre-like tags (T66025)
2633 !! options
2634 parsoid=wt2html
2635 !! wikitext
2636 {{echo|<pre <pre>x</pre>}}
2637
2638 <table><pre </table>
2639 !! html/php
2640 <pre>x</pre>
2641 <table>&lt;pre </table>
2642
2643 !! html/php+tidy
2644 <pre>
2645 x
2646 </pre>
2647 <p>&lt;pre</p>
2648 !! html/parsoid
2649 <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>
2650
2651
2652 <p>&lt;pre </p>
2653
2654 <table></table>
2655 !! end
2656
2657 !! test
2658 Parsoid: handle pre with space after attribute
2659 !! options
2660 parsoid=wt2html
2661 !! wikitext
2662 <pre style="width:50%;" >{{echo|foo}}</pre>
2663 !! html/php
2664 <pre style="width:50%;">{{echo|foo}}</pre>
2665
2666 !! html/parsoid
2667 <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>
2668 !! end
2669
2670 # TODO / maybe: fix wt2wt for this
2671 !! test
2672 Parsoid: Don't paragraph-wrap fosterable content
2673 !! options
2674 parsoid=wt2html
2675 !! wikitext
2676 {|
2677 <td></td>
2678 <td></td>
2679
2680
2681
2682 |}
2683 !! html
2684 <table>
2685
2686 <tbody>
2687 <tr>
2688 <td></td>
2689
2690 <td></td></tr>
2691
2692
2693
2694 </tbody></table>
2695 !! end
2696
2697 !! test
2698 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2699 !! options
2700 parsoid=wt2html
2701 !! wikitext
2702 {|
2703 <td>
2704 <td>
2705 </td>
2706
2707
2708
2709 |}
2710 !! html
2711 <table>
2712
2713 <tbody>
2714 <tr>
2715 <td></td>
2716
2717 <td>
2718 </td></tr>
2719
2720
2721
2722 </tbody></table>
2723 !! end
2724
2725
2726 #--------------------------------------------------------------------
2727 # Transclusion parameter whitespace stripping tests
2728 # Behavior is different for positional and named parameters
2729 #--------------------------------------------------------------------
2730 !! test
2731 Templates: Strip leading and trailing whitespace from named-param values
2732 !! wikitext
2733 {{echo|1= a }}
2734
2735 {{echo|1= {{echo|b}} }}
2736
2737 {{echo| 1 =
2738 c }}
2739
2740 {{echo| 1 =
2741 * d
2742 }}
2743 !! html
2744 <p>a
2745 </p><p>b
2746 </p><p>c
2747 </p>
2748 <ul><li> d</li></ul>
2749
2750 !! end
2751
2752 !! test
2753 Templates: Don't strip whitespace from positional-param values
2754 !! wikitext
2755 {{echo|a }}
2756
2757 {{echo|{{echo|b}} }}
2758
2759 {{echo| c
2760 }}
2761
2762 {{echo| {{echo|d}}
2763 }}
2764
2765 {{echo|
2766 e}}
2767
2768 {{echo|
2769 * f}}
2770
2771 {{echo|
2772 }}g
2773 !! html
2774 <p>a
2775 </p><p>b
2776 </p>
2777 <pre>c
2778 </pre>
2779 <p><br />
2780 </p>
2781 <pre>d
2782 </pre>
2783 <p><br />
2784 </p>
2785 <pre>e
2786 </pre>
2787 <p><br />
2788 </p>
2789 <ul><li> f</li></ul>
2790 <p><br />
2791 </p>
2792 <pre>g
2793 </pre>
2794 !! end
2795
2796 !! test
2797 Templates: Don't recognize targets split by newlines
2798 !! options
2799 parsoid=wt2html
2800 !! wikitext
2801 {{ech
2802 o|foo}}
2803 !! html/php
2804 <p>{{ech
2805 o|foo}}
2806 </p>
2807 !! html/parsoid
2808 <p>{{ech
2809 o|foo}}</p>
2810 !! end
2811
2812 !! test
2813 Templates: Recognize targets when newlines and comments don't split the target
2814 !! options
2815 parsoid=wt2html
2816 !! wikitext
2817 {{
2818 <!--X--> ech<!--X-->o<!--X-->
2819 <!--X--> <!--X-->
2820
2821 |foo}}
2822 !! html/php
2823 <p>foo
2824 </p>
2825 !! html/parsoid
2826 <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>
2827 !! end
2828
2829 !! test
2830 Templates: Handle empty comment-and-ws-only lines correctly
2831 !! wikitext
2832 {{echo|foo
2833 <!--should be ignored-->
2834 <!--should be ignored as well-->
2835 bar}}
2836 !! html/php
2837 <p>foo
2838 bar
2839 </p>
2840 !! html/parsoid
2841 <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>
2842 !! end
2843
2844 !! test
2845 Templates: Handle comments in the target
2846 !! wikitext
2847 {{echo
2848 <!-- should be ignored -->
2849 |foo}}
2850
2851 {{echo
2852 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
2853 |foo}}
2854
2855 {{echo<!-- should be ignored -->
2856 |foo}}
2857
2858 {{echo<!-- should be ignored -->|foo}}
2859
2860 {{<!-- should be ignored -->echo|foo}}
2861 !! html/php
2862 <p>foo
2863 </p><p>foo
2864 </p><p>foo
2865 </p><p>foo
2866 </p><p>foo
2867 </p>
2868 !! html/parsoid
2869 <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>
2870
2871 <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>
2872
2873 <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>
2874
2875 <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>
2876
2877 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
2878 !! end
2879
2880 !! test
2881 Templates: Handle comments in parameter names (T69657)
2882 !! wikitext
2883 {{echo|1
2884 <!-- should be ignored -->
2885 =foo}}
2886
2887 {{echo|
2888 <!-- should be ignored -->
2889 1 = foo}}
2890
2891 {{echo|1<!-- should be ignored -->=foo}}
2892
2893 {{echo|<!-- should be ignored -->1=foo}}
2894 !! html/php
2895 <p>foo
2896 </p><p>foo
2897 </p><p>foo
2898 </p><p>foo
2899 </p>
2900 !! html/parsoid
2901 <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>
2902
2903 <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>
2904
2905 <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>
2906
2907 <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>
2908 !! end
2909
2910 !! test
2911 Templates: Other wikitext in parameter names (T69657)
2912 !! wikitext
2913 {{echo|''1''=foo}}
2914 !! html/php
2915 <p>{{{1}}}
2916 </p>
2917 !! html/parsoid
2918 <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>
2919 !! end
2920
2921 !! test
2922 Templates: With colons
2923 !! wikitext
2924 {{With: Colon}}
2925 !! html/php
2926 <p>Template with colon
2927 </p>
2928 !! html/parsoid
2929 <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>
2930 !! end
2931
2932 #--------------------------------------------------------------------
2933 # Transclusion parameter escaping tests
2934 #--------------------------------------------------------------------
2935
2936 !! test
2937 Templates: Parsoid parameter escaping test 1
2938 !! wikitext
2939 {{echo|[foo]|{{echo|[bar]}}}}
2940 !! html/php+tidy
2941 <p>[foo]</p>
2942 !! html/parsoid
2943 <p about="#mwt1" typeof="mw:Transclusion"
2944 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
2945 !! end
2946
2947 !! test
2948 Parsoid: Pipes in external links in template parameter
2949 !! wikitext
2950 {{echo|[{{echo|http://example.com}} link]}}
2951 !! html/php+tidy
2952 <p><a rel="nofollow" class="external text" href="http://example.com">link</a></p>
2953 !! html/parsoid
2954 <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>
2955 !! end
2956
2957 !! test
2958 Parsoid: pipe in transclusion parameter
2959 !! wikitext
2960 {{echo|http://foo.com/a&#124;b}}
2961 !! html/php+tidy
2962 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a></p>
2963 !! html/parsoid
2964 <p><a rel="mw:ExtLink" href="http://foo.com/a%7Cb" about="#mwt1"
2965 typeof="mw:Transclusion"
2966 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>
2967 !! end
2968
2969 !! test
2970 Parsoid: Pipe in external link target and content in template parameter
2971 !! options
2972 parsoid=html2wt,wt2wt
2973 !! wikitext
2974 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
2975 !! html/php+tidy
2976 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a|b</a></p>
2977 !! html/parsoid
2978 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
2979 typeof="mw:Transclusion"
2980 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
2981 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
2982 !! end
2983
2984 !! test
2985 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
2986 !! options
2987 parsoid
2988 !! wikitext
2989 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
2990 !! html
2991 <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>
2992 !! end
2993
2994 !! test
2995 Templates: Don't escape already nowiki-escaped text in template parameters
2996 !! options
2997 parsoid=html2wt,wt2wt
2998 !! wikitext
2999 {{echo|foo<nowiki>|</nowiki>bar}}
3000 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
3001 {{echo|<nowiki></nowiki>}}
3002 !! html/php+tidy
3003 <p>foo|bar &lt;div&gt;</p>
3004 !! html/parsoid
3005 <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>
3006 <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>
3007 <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>
3008 </p>
3009 !! end
3010
3011 ## T54824
3012 !! test
3013 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
3014 !! options
3015 parsoid=html2wt,wt2wt
3016 !! wikitext
3017 {{echo|{{echo|1=bar}}}}
3018 !! html/php+tidy
3019 <p>bar</p>
3020 !! html/parsoid
3021 <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>
3022 !! end
3023
3024 ## T58733
3025 !! test
3026 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
3027 !! wikitext
3028 {{echo|a : b}}
3029 !! html/php+tidy
3030 <p>a&#160;: b</p>
3031 !! html/parsoid
3032 <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>
3033 !! end
3034
3035 ## T73412
3036 !! test
3037 Templates: Preserve blank parameter names
3038 !! wikitext
3039 {{echo|=foo}}
3040 !! html/php+tidy
3041 <p>{{{1}}}</p>
3042 !! html/parsoid
3043 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3044 !! end
3045
3046 !! test
3047 Templates: Preserve blank parameter names in other positions
3048 !! wikitext
3049 {{blank_param|bar|=foo}}
3050 !! html/php+tidy
3051 <p>bar foo</p>
3052 !! html/parsoid
3053 <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
3054 foo</p>
3055 !! end
3056
3057 ###
3058 ### Parsoid-centric tests for testing RT edge cases for pre
3059 ###
3060
3061 !!test
3062 1a. Indent-Pre and Comments
3063 !! wikitext
3064 a
3065 <!--a-->
3066 c
3067 !! html
3068 <pre>a
3069 </pre>
3070 <p>c
3071 </p>
3072 !!end
3073
3074 !!test
3075 1b. Indent-Pre and Comments
3076 !! wikitext
3077 a
3078 <!--a-->
3079 c
3080 !! html
3081 <pre>a
3082 </pre>
3083 <p>c
3084 </p>
3085 !!end
3086
3087 !!test
3088 1c. Indent-Pre and Comments
3089 !! wikitext
3090 <!--a--> a
3091
3092 <!--a--> a
3093 !! html
3094 <pre> a
3095 </pre>
3096 <pre> a
3097 </pre>
3098 !!end
3099
3100 !!test
3101 1d. Indent-Pre and Comments
3102 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3103 !! wikitext
3104 <!--a--> a
3105
3106 <!--b-->b
3107 !! html
3108 <pre>a
3109 </pre>
3110 <pre>b
3111 </pre>
3112 !!end
3113
3114 !!test
3115 2a. Indent-Pre and tables
3116 !! wikitext
3117 {|
3118 |-
3119 !h1!!h2
3120 |foo||bar
3121 |}
3122 !! html
3123 <table>
3124
3125 <tr>
3126 <th>h1</th>
3127 <th>h2
3128 </th>
3129 <td>foo</td>
3130 <td>bar
3131 </td></tr></table>
3132
3133 !!end
3134
3135 !!test
3136 2b. Indent-Pre and tables
3137 !! wikitext
3138 {|
3139 |-
3140 |foo
3141 |}
3142 !! html
3143 <table>
3144
3145 <tr>
3146 <td>foo
3147 </td></tr></table>
3148
3149 !!end
3150
3151 !!test
3152 2c. Indent-Pre and tables (T44252)
3153 !! wikitext
3154 {|
3155 |+ foo
3156 ! | bar
3157 |}
3158 !! html
3159 <table>
3160 <caption> foo
3161 </caption>
3162 <tr>
3163 <th> bar
3164 </th></tr></table>
3165
3166 !!end
3167
3168 !!test
3169 2d. Indent-Pre and tables
3170 !! wikitext
3171 a
3172 {|
3173 | b
3174 |}
3175 !! html/php
3176 <pre>a
3177 </pre>
3178 <table>
3179 <tr>
3180 <td> b
3181 </td></tr></table>
3182
3183 !! html/parsoid
3184 <pre>a</pre>
3185 <table>
3186 <tbody><tr><td> b</td></tr>
3187 </tbody></table>
3188 !!end
3189
3190 !!test
3191 2e. Indent-Pre and table-line syntax
3192 !! wikitext
3193 a
3194 | b
3195 | c
3196 !! html/php
3197 <pre>a
3198 | b
3199 | c
3200 </pre>
3201 !!end
3202
3203 !!test
3204 2f. Indent-pre started by table-line syntax
3205 !! wikitext
3206 a
3207 | b
3208 | c
3209 !! html/php
3210 <p>a
3211 </p>
3212 <pre>| b
3213 | c
3214 </pre>
3215 !! html/parsoid
3216 <p>a</p>
3217 <pre>
3218 | b
3219 | c</pre>
3220 !!end
3221
3222 !! test
3223 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3224 !! wikitext
3225 <table>
3226 <tr>
3227 <td>
3228 Text that should be rendered preformatted
3229 </td>
3230 </tr>
3231 </table>
3232 !! html
3233 <table>
3234 <tr>
3235 <td>
3236 <pre>Text that should be rendered preformatted
3237 </pre>
3238 </td>
3239 </tr>
3240 </table>
3241
3242 !! end
3243
3244 !!test
3245 3a. Indent-Pre and block tags (single-line html)
3246 !! wikitext
3247 a <p> foo </p>
3248 b <div> foo </div>
3249 c <blockquote> foo </blockquote>
3250 <span> foo </span>
3251 !! html
3252 a <p> foo </p>
3253 b <div> foo </div>
3254 c <blockquote> foo </blockquote>
3255 <pre><span> foo </span>
3256 </pre>
3257 !! html/parsoid
3258 <p>a </p><p data-parsoid='{"stx":"html"}'> foo </p>
3259 <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3260 <p>c </p><blockquote data-parsoid='{"stx":"html"}'> foo </blockquote>
3261 <pre><span> foo </span>
3262 </pre>
3263 !! html+tidy
3264 <p>a</p>
3265 <p>foo</p>
3266 <p>b</p>
3267 <div>foo</div>
3268 <p>c</p>
3269 <blockquote>
3270 <p>foo</p>
3271 </blockquote>
3272 <pre>
3273 <span> foo </span>
3274 </pre>
3275 !! end
3276
3277 !!test
3278 3b. Indent-Pre and block tags (multi-line html)
3279 !! wikitext
3280 a <span>foo</span>
3281 b <div> foo </div>
3282 !! html
3283 <pre>a <span>foo</span>
3284 </pre>
3285 b <div> foo </div>
3286
3287 !! html/parsoid
3288 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3289 b <div data-parsoid='{"stx":"html"}'> foo </div>
3290 !! html+tidy
3291 <pre>
3292 a <span>foo</span>
3293 </pre>
3294 <p>b</p>
3295 <div>foo</div>
3296 !!end
3297
3298 !!test
3299 3c. Indent-Pre and block tags (pre-content on separate line)
3300 !! wikitext
3301 <p>
3302 foo
3303 </p>
3304
3305 <div>
3306 foo
3307 </div>
3308
3309 <center>
3310 foo
3311 </center>
3312
3313 <blockquote>
3314 foo
3315 </blockquote>
3316
3317 <blockquote>
3318 <pre>
3319 foo
3320 </pre>
3321 </blockquote>
3322
3323 <table><tr><td>
3324 foo
3325 </td></tr></table>
3326
3327 <ul><li>
3328 foo
3329 </li></ul>
3330
3331 !! html
3332 <p>
3333 foo
3334 </p>
3335 <div>
3336 <pre>foo
3337 </pre>
3338 </div>
3339 <center>
3340 <pre>foo
3341 </pre>
3342 </center>
3343 <blockquote>
3344 <p> foo
3345 </p>
3346 </blockquote>
3347 <blockquote>
3348 <pre>
3349 foo
3350 </pre>
3351 </blockquote>
3352 <table><tr><td>
3353 <pre>foo
3354 </pre>
3355 </td></tr></table>
3356 <ul><li>
3357 foo
3358 </li></ul>
3359
3360 !!end
3361
3362 !! test
3363 4. Indent-Pre and extension tags
3364 !! wikitext
3365 a <tag />
3366 !! html/php
3367 a <pre>
3368 NULL
3369 array (
3370 )
3371 </pre>
3372
3373 !! html/parsoid
3374 a <pre typeof="mw:Extension/tag" about="#mwt2" data-parsoid='{}' data-mw='{"name":"tag","attrs":{},"body":null}'></pre>
3375 !! end
3376
3377 !! test
3378 5. Indent-Pre and html pre
3379 !! wikitext
3380 <pre class="123">hi</pre>
3381 !! html/php
3382 <pre class="123">hi</pre>
3383
3384 !! html/parsoid
3385 <pre typeof="mw:Extension/pre" about="#mwt2" class="123" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3386 !! end
3387
3388 !!test
3389 Render paragraphs when indent-pre is suppressed in blocklevels
3390 !! wikitext
3391 <blockquote>
3392 foo
3393
3394 bar
3395 </blockquote>
3396 !! html
3397 <blockquote>
3398 <p> foo
3399 </p><p> bar
3400 </p>
3401 </blockquote>
3402
3403 !!end
3404
3405 !!test
3406 4. Multiple spaces at start-of-line
3407 !! wikitext
3408 <p> foo </p>
3409 foo
3410 {|
3411 |foo
3412 |}
3413 !! html
3414 <p> foo </p>
3415 <pre> foo
3416 </pre>
3417 <table>
3418 <tr>
3419 <td>foo
3420 </td></tr></table>
3421
3422 !!end
3423
3424 ## NOTE: the leading white-space chars on empty line are significant
3425 !! test
3426 5a. White-space in indent-pre
3427 !! wikitext
3428 a<br />
3429
3430 b
3431 !! html
3432 <pre>a<br />
3433
3434 b
3435 </pre>
3436 !! end
3437
3438 ## NOTE: the leading white-space chars on empty line are significant
3439 !! test
3440 5b. White-space in indent-pre
3441 !! wikitext
3442 a
3443
3444 b
3445
3446
3447 c
3448 !! html
3449 <pre>a
3450
3451 b
3452
3453
3454 c
3455 </pre>
3456 !! end
3457
3458 !! test
3459 5c. White-space in indent-pre
3460 !! wikitext
3461 ''a''
3462 ''b''
3463 ''c''
3464 !! html
3465 <pre><i>a</i>
3466 <i>b</i>
3467 <i>c</i>
3468 </pre>
3469 !! end
3470
3471 !! test
3472 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3473 !! wikitext
3474 a
3475
3476 <!-- continue -->
3477 b
3478
3479 c
3480
3481 d
3482 !! html
3483 <pre>a
3484
3485 b
3486 </pre>
3487 <pre>c
3488
3489 </pre>
3490 <p>d
3491 </p>
3492 !! end
3493
3494 !! test
3495 7a. Indent-pre and category links
3496 !! options
3497 parsoid=wt2html,wt2wt
3498 !! wikitext
3499 [[Category:foo]] <!-- No pre-wrapping -->
3500 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3501 !! html/php+tidy
3502 !! html/parsoid
3503 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3504 <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 -->
3505 !! end
3506
3507 ## We used to, but no longer wt2wt this test since the default serializer
3508 ## will normalize all categories to serialize on their own line.
3509 ## This wikitext usage is going to be fairly uncommon in production and
3510 ## selser will take care of preserving formatting in those scenarios.
3511 !! test
3512 7b. Indent-pre and category links
3513 !! options
3514 parsoid=wt2html
3515 !! wikitext
3516 [[Category:foo]] a
3517 [[Category:foo]] {{echo|b}}
3518 !! html/parsoid
3519 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3520 <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>
3521 !! end
3522
3523 !! test
3524 Indent-Pre: Newlines in comments shouldn't affect sol state
3525 !! wikitext
3526 a <!--
3527 foo
3528 --> b
3529 !! html/php+tidy
3530 <p>a b</p>
3531 !! html/parsoid
3532 <p>a <!--
3533 foo
3534 --> b</p>
3535 !! end
3536
3537 ###
3538 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3539 ###
3540
3541 !!test
3542 HTML-pre: 1. embedded newlines
3543 !! wikitext
3544 <pre>foo</pre>
3545
3546 <pre>
3547 foo
3548 </pre>
3549
3550 <pre>
3551
3552 foo
3553 </pre>
3554
3555 <pre>
3556
3557
3558 foo
3559 </pre>
3560 !! html/php+tidy
3561 <pre>
3562 foo
3563 </pre>
3564 <pre>
3565 foo
3566 </pre>
3567 <pre>
3568
3569 foo
3570 </pre>
3571 <pre>
3572
3573
3574 foo
3575 </pre>
3576 !! html/parsoid
3577 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3578
3579 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3580 </pre>
3581
3582 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3583
3584 foo
3585 </pre>
3586
3587 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3588
3589
3590 foo
3591 </pre>
3592 !!end
3593
3594 !! test
3595 HTML-pre: big spaces
3596 !! wikitext
3597 <pre>
3598
3599
3600
3601
3602 haha
3603
3604
3605
3606
3607 haha
3608
3609
3610
3611
3612 </pre>
3613 !! html/php+tidy
3614 <pre>
3615
3616
3617
3618
3619 haha
3620
3621
3622
3623
3624 haha
3625
3626
3627
3628
3629 </pre>
3630 !! html/parsoid
3631 <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"}}'>
3632
3633
3634
3635
3636 haha
3637
3638
3639
3640
3641 haha
3642
3643
3644
3645
3646 </pre>
3647 !! end
3648
3649 !!test
3650 HTML-pre: 2: indented text
3651 !! wikitext
3652 <pre>
3653 foo
3654 </pre>
3655 !! html
3656 <pre>
3657 foo
3658 </pre>
3659
3660 !!end
3661
3662 !!test
3663 HTML-pre: 3: other wikitext
3664 !! wikitext
3665 <pre>
3666 * foo
3667 # bar
3668 = no-h =
3669 '' no-italic ''
3670 [[ NoLink ]]
3671 </pre>
3672 !! html/php
3673 <pre>
3674 * foo
3675 # bar
3676 = no-h =
3677 '' no-italic ''
3678 [[ NoLink ]]
3679 </pre>
3680
3681 !! html/parsoid
3682 <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
3683 # bar
3684 = no-h =
3685 '' no-italic ''
3686 [[ NoLink ]]
3687 </pre>
3688 !!end
3689
3690 ###
3691 ### Definition lists
3692 ###
3693 !! test
3694 Simple definition
3695 !! wikitext
3696 ; name : Definition
3697 !! html
3698 <dl><dt> name&#160;</dt>
3699 <dd> Definition</dd></dl>
3700
3701 !! end
3702
3703 !! test
3704 Definition list for indentation only
3705 !! wikitext
3706 : Indented text
3707 !! html
3708 <dl><dd> Indented text</dd></dl>
3709
3710 !! end
3711
3712 !! test
3713 Definition list with no space
3714 !! wikitext
3715 ;name:Definition
3716 !! html
3717 <dl><dt>name</dt>
3718 <dd>Definition</dd></dl>
3719
3720 !!end
3721
3722 !! test
3723 Definition list with URL link
3724 !! wikitext
3725 ; http://example.com/ : definition
3726 !! html
3727 <dl><dt> <a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&#160;</dt>
3728 <dd> definition</dd></dl>
3729
3730 !! end
3731
3732 !! test
3733 Definition list with bracketed URL link
3734 !! wikitext
3735 ;[http://www.example.com/ Example]:Something about it
3736 !! html
3737 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
3738 <dd>Something about it</dd></dl>
3739
3740 !! end
3741
3742 !! test
3743 Definition list with wikilink containing colon
3744 !! wikitext
3745 ; [[Help:FAQ]]: The least-read page on Wikipedia
3746 !! html
3747 <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>
3748 <dd> The least-read page on Wikipedia</dd></dl>
3749
3750 !! end
3751
3752 # At Brion's and JeLuF's insistence... :)
3753 !! test
3754 Definition list with news link containing colon
3755 !! wikitext
3756 ; news:alt.wikipedia.rox: This isn't even a real newsgroup!
3757 !! html/php
3758 <dl><dt> <a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
3759 <dd> This isn't even a real newsgroup!</dd></dl>
3760
3761 !! html/parsoid
3762 <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>
3763 !! end
3764
3765 !! test
3766 Malformed definition list with colon
3767 !! wikitext
3768 ; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
3769 !! html
3770 <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>
3771
3772 !! end
3773
3774 !! test
3775 Definition lists: colon in external link text
3776 !! wikitext
3777 ; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
3778 !! html
3779 <dl><dt> <a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia&#160;: The Next Generation</a></dt>
3780 <dd> OK, I made that up</dd></dl>
3781
3782 !! end
3783
3784 !! test
3785 Definition lists: colon in HTML attribute
3786 !! wikitext
3787 ;<b style="display: inline">bold</b>
3788 !! html
3789 <dl><dt><b style="display: inline">bold</b></dt></dl>
3790
3791 !! end
3792
3793 !! test
3794 Definition lists: self-closed tag
3795 !! wikitext
3796 ;one<br/>two : two-line fun
3797 !! html
3798 <dl><dt>one<br />two&#160;</dt>
3799 <dd> two-line fun</dd></dl>
3800
3801 !! end
3802
3803 !! test
3804 Definition lists: ignore colons inside tags
3805 !! wikitext
3806 ;one <b>two : tag <i>fun:</i>:</b>: def
3807 !! html
3808 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
3809 <dd> def</dd></dl>
3810
3811 !! end
3812
3813 !! test
3814 Definition lists: excess closed tags
3815 !! wikitext
3816 ;one</b>two : bad tag fun
3817 !! html/php+tidy
3818 <dl>
3819 <dt>onetwo&#160;</dt>
3820 <dd>bad tag fun</dd>
3821 </dl>
3822 !! html/parsoid
3823 <dl>
3824 <dt>onetwo</dt>
3825 <dd>bad tag fun</dd>
3826 </dl>
3827 !! end
3828
3829 !! test
3830 T13748: Literal closing tags
3831 !! wikitext
3832 <dl>
3833 <dt>test 1</dt>
3834 <dd>test test test test test</dd>
3835 <dt>test 2</dt>
3836 <dd>test test test test test</dd>
3837 </dl>
3838 !! html
3839 <dl>
3840 <dt>test 1</dt>
3841 <dd>test test test test test</dd>
3842 <dt>test 2</dt>
3843 <dd>test test test test test</dd>
3844 </dl>
3845
3846 !! end
3847
3848 !! test
3849 Definition and unordered list using wiki syntax nested in unordered list using html tags.
3850 !! wikitext
3851 <ul><li>
3852 ; term : description
3853 * unordered
3854 </li></ul>
3855 !! html
3856 <ul><li>
3857 <dl><dt> term&#160;</dt>
3858 <dd> description</dd></dl>
3859 <ul><li> unordered</li></ul>
3860 </li></ul>
3861
3862 !! end
3863
3864 !! test
3865 Definition list with empty definition and following paragraph
3866 !! wikitext
3867 ; term:
3868 Paragraph text
3869 !! html
3870 <dl><dt> term</dt>
3871 <dd></dd></dl>
3872 <p>Paragraph text
3873 </p>
3874 !! end
3875
3876 !! test
3877 Nested definition lists using html syntax
3878 !! wikitext
3879 <dl><dt>x</dt>
3880 <dd>a</dd>
3881 <dd>b</dd></dl>
3882 !! html
3883 <dl><dt>x</dt>
3884 <dd>a</dd>
3885 <dd>b</dd></dl>
3886
3887 !! end
3888
3889 !! test
3890 Definition Lists: No nesting: Multiple dd's
3891 !! wikitext
3892 ;x
3893 :a
3894 :b
3895 !! html
3896 <dl><dt>x</dt>
3897 <dd>a</dd>
3898 <dd>b</dd></dl>
3899
3900 !! end
3901
3902 !! test
3903 Definition Lists: Indentation: Regular
3904 !! wikitext
3905 :i1
3906 ::i2
3907 :::i3
3908 !! html
3909 <dl><dd>i1
3910 <dl><dd>i2
3911 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3912
3913 !! end
3914
3915 !! test
3916 Definition Lists: Indentation: Missing 1st level
3917 !! wikitext
3918 ::i2
3919 :::i3
3920 !! html
3921 <dl><dd><dl><dd>i2
3922 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3923
3924 !! end
3925
3926 !! test
3927 Definition Lists: Indentation: Multi-level indent
3928 !! wikitext
3929 :::i3
3930 !! html
3931 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
3932
3933 !! end
3934
3935 !! test
3936 Definition Lists: Hacky use to indent tables
3937 !! wikitext
3938 ::{|
3939 |foo
3940 |bar
3941 |}
3942 this text
3943 should be left alone
3944 !! html
3945 <dl><dd><dl><dd><table>
3946 <tr>
3947 <td>foo
3948 </td>
3949 <td>bar
3950 </td></tr></table></dd></dl></dd></dl>
3951 <p>this text
3952 should be left alone
3953 </p>
3954 !! end
3955
3956 !! test
3957 Definition Lists: Hacky use to indent tables, with comments (T65979)
3958 !! wikitext
3959 <!-- foo -->
3960 ::{|
3961 |foo
3962 |bar
3963 |}<!-- bar -->
3964 this text
3965 should be left alone
3966 !! html/parsoid
3967 <!-- foo -->
3968 <dl><dd><dl><dd><table><tr>
3969 <td>foo</td>
3970 <td>bar</td>
3971 </tr></table><!-- bar --></dd></dl></dd></dl>
3972 <p>this text
3973 should be left alone</p>
3974 !! end
3975
3976 !! test
3977 Definition Lists: Hacky use to indent tables, with comment before table
3978 !! wikitext
3979 ::<!-- foo -->{|
3980 |foo
3981 |}
3982 !! html/parsoid
3983 <dl><dd><dl><dd><!-- foo --><table><tr>
3984 <td>foo</td>
3985 </tr></table></dd></dl></dd></dl>
3986 !! end
3987
3988 # The trailing whitespace in this test is to catch a regression in
3989 # Parsoid after T54473.
3990 !! test
3991 Definition Lists: Hacky use to indent tables (WS-insensitive)
3992 !! wikitext
3993 : {|
3994 |a
3995 |}
3996 !! html/php
3997 <dl><dd><table>
3998 <tr>
3999 <td>a
4000 </td></tr></table></dd></dl>
4001
4002 !! html/parsoid
4003 <dl><dd> <table>
4004 <tbody><tr><td>a</td></tr>
4005 </tbody></table> </dd></dl>
4006 !! end
4007
4008 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
4009 ## as an empty dt item. It also ignores all but the last ";" when followed
4010 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
4011 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
4012 ## ";"s.
4013 ##
4014 ## Ex: ";;t2 ::d2" is transformed into:
4015 ##
4016 ## <dl>
4017 ## <dt>t2 </dt>
4018 ## <dd>
4019 ## <dl>
4020 ## <dt></dt>
4021 ## <dd>d2</dd>
4022 ## </dl>
4023 ## </dd>
4024 ## </dl>
4025 ##
4026 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
4027 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
4028 ##
4029 ## <dl>
4030 ## <dt>
4031 ## <dl>
4032 ## <dt>t2 </dt>
4033 ## <dd>:d2</dd>
4034 ## </dl>
4035 ## </dt>
4036 ## </dl>
4037 ##
4038 ## All Parsoid only definition list tests have this difference.
4039 ##
4040 ## See also: https://phabricator.wikimedia.org/T8569
4041 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4042
4043 !! test
4044 Table / list interaction: indented table with lists in table contents
4045 !! wikitext
4046 :{|
4047 |-
4048 | a
4049 * b
4050 |-
4051 | c
4052 * d
4053 |}
4054 !! html
4055 <dl><dd><table>
4056
4057 <tr>
4058 <td> a
4059 <ul><li> b</li></ul>
4060 </td></tr>
4061 <tr>
4062 <td> c
4063 <ul><li> d</li></ul>
4064 </td></tr></table></dd></dl>
4065
4066 !! end
4067
4068 !!test
4069 Table / list interaction: lists nested in tables nested in indented lists
4070 !! wikitext
4071 :{|
4072 |
4073 :a
4074 :b
4075 |
4076 *c
4077 *d
4078 |}
4079
4080 *e
4081 *f
4082 !! html
4083 <dl><dd><table>
4084 <tr>
4085 <td>
4086 <dl><dd>a</dd>
4087 <dd>b</dd></dl>
4088 </td>
4089 <td>
4090 <ul><li>c</li>
4091 <li>d</li></ul>
4092 </td></tr></table></dd></dl>
4093 <ul><li>e</li>
4094 <li>f</li></ul>
4095
4096 !!end
4097
4098 !! test
4099 Definition Lists: Nesting: Multi-level (Parsoid only)
4100 !! options
4101 parsoid
4102 !! wikitext
4103 ;t1 :d1
4104 ;;t2 ::d2
4105 ;;;t3 :::d3
4106 !! html
4107 <dl>
4108 <dt>t1 </dt>
4109 <dd>d1</dd>
4110 <dt>
4111 <dl>
4112 <dt>t2 </dt>
4113 <dd>:d2</dd>
4114 <dt>
4115 <dl>
4116 <dt>t3 </dt>
4117 <dd>::d3</dd>
4118 </dl>
4119 </dt>
4120 </dl>
4121 </dt>
4122 </dl>
4123
4124
4125 !! end
4126
4127
4128 !! test
4129 Definition Lists: Nesting: Test 2 (Parsoid only)
4130 !! wikitext
4131 ;t1
4132 ::d2
4133 !! html/php+tidy
4134 <dl>
4135 <dt>t1</dt>
4136 <dd>
4137 <dl>
4138 <dd>d2</dd>
4139 </dl>
4140 </dd>
4141 </dl>
4142 !! html/parsoid
4143 <dl>
4144 <dt>t1</dt>
4145 <dd>
4146 <dl>
4147 <dd>d2</dd>
4148 </dl>
4149 </dd>
4150 </dl>
4151
4152 !! end
4153
4154
4155 !! test
4156 Definition Lists: Nesting: Test 3 (Parsoid only)
4157 !! wikitext
4158 :;t1
4159 ::::d2
4160 !! html/php+tidy
4161 <dl>
4162 <dd>
4163 <dl>
4164 <dt>t1</dt>
4165 <dd>
4166 <dl>
4167 <dd>
4168 <dl>
4169 <dd>d2</dd>
4170 </dl>
4171 </dd>
4172 </dl>
4173 </dd>
4174 </dl>
4175 </dd>
4176 </dl>
4177 !! html/parsoid
4178 <dl>
4179 <dd>
4180 <dl>
4181 <dt>t1</dt>
4182 <dd>
4183 <dl>
4184 <dd>
4185 <dl>
4186 <dd>d2</dd>
4187 </dl>
4188 </dd>
4189 </dl>
4190 </dd>
4191 </dl>
4192 </dd>
4193 </dl>
4194
4195 !! end
4196
4197
4198 !! test
4199 Definition Lists: Nesting: Test 4
4200 !! wikitext
4201 ::;t3
4202 :::d3
4203 !! html
4204 <dl><dd><dl><dd><dl><dt>t3</dt>
4205 <dd>d3</dd></dl></dd></dl></dd></dl>
4206
4207 !! end
4208
4209
4210 ## The Parsoid team believes the following three test exposes a
4211 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4212 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4213 ## It also exposes a "misfeature" in tidy, which doesn't like
4214 ## <dl> tags with a single <dt> child; it converts the <dt> into
4215 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4216 !! test
4217 Definition Lists: Mixed Lists: Test 1
4218 !! wikitext
4219 :;* foo
4220 ::* bar
4221 :; baz
4222 !! html/php
4223 <dl><dd><dl><dt><ul><li> foo</li>
4224 <li> bar</li></ul></dt></dl>
4225 <dl><dt> baz</dt></dl></dd></dl>
4226
4227 !! html/php+tidy
4228 <dl>
4229 <dd>
4230 <dl>
4231 <dd>
4232 <ul>
4233 <li>foo</li>
4234 <li>bar</li>
4235 </ul>
4236 </dd>
4237 </dl>
4238 <dl>
4239 <dt>baz</dt>
4240 </dl>
4241 </dd>
4242 </dl>
4243 !! html/parsoid
4244 <dl>
4245 <dd><dl>
4246 <dt><ul>
4247 <li> foo
4248 </li>
4249 </ul></dt>
4250 <dd><ul>
4251 <li> bar
4252 </li>
4253 </ul></dd>
4254 <dt> baz</dt>
4255 </dl></dd>
4256 </dl>
4257 !! end
4258
4259 !! test
4260 Definition Lists: Mixed Lists: Test 2
4261 !! wikitext
4262 *: d1
4263 *: d2
4264 !! html
4265 <ul><li><dl><dd> d1</dd>
4266 <dd> d2</dd></dl></li></ul>
4267
4268 !! end
4269
4270
4271 !! test
4272 Definition Lists: Mixed Lists: Test 3
4273 !! wikitext
4274 *::: d1
4275 *::: d2
4276 !! html
4277 <ul><li><dl><dd><dl><dd><dl><dd> d1</dd>
4278 <dd> d2</dd></dl></dd></dl></dd></dl></li></ul>
4279
4280 !! end
4281
4282
4283 !! test
4284 Definition Lists: Mixed Lists: Test 4
4285 !! wikitext
4286 *;d1 :d2
4287 *;d3 :d4
4288 !! html
4289 <ul><li><dl><dt>d1&#160;</dt>
4290 <dd>d2</dd>
4291 <dt>d3&#160;</dt>
4292 <dd>d4</dd></dl></li></ul>
4293
4294 !! end
4295
4296
4297 !! test
4298 Definition Lists: Mixed Lists: Test 5
4299 !! wikitext
4300 *:d1
4301 *:: d2
4302 !! html
4303 <ul><li><dl><dd>d1
4304 <dl><dd> d2</dd></dl></dd></dl></li></ul>
4305
4306 !! end
4307
4308
4309 !! test
4310 Definition Lists: Mixed Lists: Test 6
4311 !! wikitext
4312 #*:d1
4313 #*::: d3
4314 !! html
4315 <ol><li><ul><li><dl><dd>d1
4316 <dl><dd><dl><dd> d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4317
4318 !! end
4319
4320
4321 !! test
4322 Definition Lists: Mixed Lists: Test 7
4323 !! wikitext
4324 :* d1
4325 :* d2
4326 !! html
4327 <dl><dd><ul><li> d1</li>
4328 <li> d2</li></ul></dd></dl>
4329
4330 !! end
4331
4332
4333 !! test
4334 Definition Lists: Mixed Lists: Test 8
4335 !! wikitext
4336 :* d1
4337 ::* d2
4338 !! html
4339 <dl><dd><ul><li> d1</li></ul>
4340 <dl><dd><ul><li> d2</li></ul></dd></dl></dd></dl>
4341
4342 !! end
4343
4344
4345 !! test
4346 Definition Lists: Mixed Lists: Test 9
4347 !! wikitext
4348 *;foo :bar
4349 !! html
4350 <ul><li><dl><dt>foo&#160;</dt>
4351 <dd>bar</dd></dl></li></ul>
4352
4353 !! end
4354
4355
4356 !! test
4357 Definition Lists: Mixed Lists: Test 10
4358 !! wikitext
4359 *#;foo :bar
4360 !! html
4361 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4362 <dd>bar</dd></dl></li></ol></li></ul>
4363
4364 !! end
4365
4366 # This is a regression test for T175099
4367 # html/php+tidy is insufficient since Tidy covers up the bug.
4368 # But once Tidy is replaced with RemexHTML, html/php+tidy is good enough
4369 !! test
4370 Definition Lists: Mixed Lists: Test 11
4371 !! wikitext
4372 ; a
4373 :* b
4374 !! html/*
4375 <dl><dt> a</dt>
4376 <dd>
4377 <ul><li> b</li></ul></dd></dl>
4378
4379 !! end
4380
4381 # The Parsoid team disagrees with the PHP parser's seemingly-random
4382 # rules regarding dd/dt on the next two tests. Parsoid is more
4383 # consistent, and recognizes the shared nesting and keeps the
4384 # still-open tags around until the nesting is complete.
4385 # (And tidy again converts <dt> to <dd> before 'bar'.)
4386
4387 !! test
4388 Definition Lists: Mixed Lists: Test 12
4389 !! wikitext
4390 *#*#;*;;foo :bar
4391 *#*#;boo :baz
4392 !! html/php
4393 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4394 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4395 <dl><dt>boo&#160;</dt>
4396 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4397
4398 !! html/php+tidy
4399 <ul>
4400 <li>
4401 <ol>
4402 <li>
4403 <ul>
4404 <li>
4405 <ol>
4406 <li>
4407 <dl>
4408 <dt>foo&#160;</dt>
4409 <dd>
4410 <ul>
4411 <li>
4412 <dl>
4413 <dd>
4414 <dl>
4415 <dt>bar</dt>
4416 </dl>
4417 </dd>
4418 </dl>
4419 </li>
4420 </ul>
4421 </dd>
4422 </dl>
4423 <dl>
4424 <dt>boo&#160;</dt>
4425 <dd>baz</dd>
4426 </dl>
4427 </li>
4428 </ol>
4429 </li>
4430 </ul>
4431 </li>
4432 </ol>
4433 </li>
4434 </ul>
4435 !! html/parsoid
4436 <ul>
4437 <li>
4438 <ol>
4439 <li>
4440 <ul>
4441 <li>
4442 <ol>
4443 <li>
4444 <dl>
4445 <dt>
4446 <ul>
4447 <li>
4448 <dl>
4449 <dt>
4450 <dl>
4451 <dt>foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4452 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4453 </dl></dt>
4454 </dl></li>
4455 </ul></dt>
4456 <dt>boo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4457 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4458 </dl></li>
4459 </ol></li>
4460 </ul></li>
4461 </ol></li>
4462 </ul>
4463 !! end
4464
4465
4466 # Another case where tidy converts a <dt> to a <dd> (but Parsoid doesn't).
4467 # From whitelist:
4468 # * The test is wrong, there are two colons where there should be :;
4469 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4470 !! test
4471 Definition Lists: Weird Ones: Test 1
4472 !! wikitext
4473 *#;*::;; foo : bar (who uses this?)
4474 !! html/php
4475 <ul><li><ol><li><dl><dt> foo&#160;</dt>
4476 <dd><ul><li><dl><dd><dl><dd><dl><dt><dl><dt> bar (who uses this?)</dt></dl></dd></dl></dd></dl></dd></dl></li></ul></dd></dl></li></ol></li></ul>
4477
4478 !! html/php+tidy
4479 <ul>
4480 <li>
4481 <ol>
4482 <li>
4483 <dl>
4484 <dt>foo&#160;</dt>
4485 <dd>
4486 <ul>
4487 <li>
4488 <dl>
4489 <dd>
4490 <dl>
4491 <dd>
4492 <dl>
4493 <dd>
4494 <dl>
4495 <dt>bar (who uses this?)</dt>
4496 </dl>
4497 </dd>
4498 </dl>
4499 </dd>
4500 </dl>
4501 </dd>
4502 </dl>
4503 </li>
4504 </ul>
4505 </dd>
4506 </dl>
4507 </li>
4508 </ol>
4509 </li>
4510 </ul>
4511 !! html/parsoid
4512 <ul>
4513 <li>
4514 <ol>
4515 <li>
4516 <dl>
4517 <dt>
4518 <ul>
4519 <li>
4520 <dl>
4521 <dd>
4522 <dl>
4523 <dd>
4524 <dl>
4525 <dt>
4526 <dl>
4527 <dt> foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span></dt>
4528 <dd data-parsoid='{"stx":"row"}'> bar (who uses this?)</dd>
4529 </dl></dt>
4530 </dl></dd>
4531 </dl></dd>
4532 </dl></li>
4533 </ul></dt>
4534 </dl></li>
4535 </ol></li>
4536 </ul>
4537 !! end
4538
4539 !! test
4540 Definition Lists: colons occurring in tags
4541 !! wikitext
4542 ;a:b
4543 ;'''a:b'''
4544 ;<i>a:b</i>
4545 ;<span>a:b</span>
4546 ;<div>a:b</div>
4547 ;<div>a
4548 :b</div>
4549 ;{{echo|a:b}}
4550 ;{{echo|''a:b''}}
4551 ;;;''a:b''
4552 !! html+tidy
4553 <dl>
4554 <dt>a</dt>
4555 <dd>b</dd>
4556 <dt><b>a:b</b></dt>
4557 <dt><i>a:b</i></dt>
4558 <dt><span>a:b</span></dt>
4559 <dd>
4560 <div>a:b</div>
4561 </dd>
4562 <dd>
4563 <div>a
4564 <dl>
4565 <dd>b</dd>
4566 </dl>
4567 </div>
4568 </dd>
4569 <dt>a</dt>
4570 <dd>b</dd>
4571 <dt><i>a:b</i></dt>
4572 </dl>
4573 <dl>
4574 <dd>
4575 <dl>
4576 <dd>
4577 <dl>
4578 <dt><i>a:b</i></dt>
4579 </dl>
4580 </dd>
4581 </dl>
4582 </dd>
4583 </dl>
4584 !! html/parsoid
4585 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4586 <dt><b>a:b</b></dt>
4587 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4588 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4589 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4590 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4591 <dd>b</dd>
4592 <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>
4593 <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>
4594 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4595 !! end
4596
4597 !! test
4598 Definition Lists: colons and tables 1
4599 !! wikitext
4600 :{|
4601 | x
4602 |}
4603 :{|
4604 | y
4605 |}
4606 !! html
4607 <dl><dd><table>
4608 <tr>
4609 <td> x
4610 </td></tr></table></dd></dl>
4611 <dl><dd><table>
4612 <tr>
4613 <td> y
4614 </td></tr></table></dd></dl>
4615
4616 !! end
4617
4618 # Parsoid's output (as documented below) differs from php's in this case.
4619 # This is probably a bug. If we fixup parsoid to match php's output, the
4620 # above test should pass and the below test case can be removed. It is
4621 # unclear which output is more desirable.
4622
4623 !! test
4624 Definition Lists: colons and tables 2
4625 !! wikitext
4626 :{|
4627 | x
4628 |}
4629 :{|
4630 | y
4631 |}
4632 !! html/parsoid
4633 <dl><dd><table>
4634 <tr>
4635 <td> x
4636 </td></tr></table></dd>
4637 <dd><table>
4638 <tr>
4639 <td> y
4640 </td></tr></table></dd></dl>
4641 !! end
4642
4643 !! test
4644 Definition Lists: template interaction
4645 !! wikitext
4646 ::{{definition_list}}
4647
4648 :one
4649 ::{{definition_list}}
4650 :::two
4651 :::three
4652 ::four
4653 !! html/parsoid
4654 <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">
4655 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4656
4657 <dl><dd data-parsoid='{}'>one
4658 <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">
4659 </span><dd about="#mwt2">two
4660 <dl><dd>two</dd>
4661 <dd>three</dd></dl></dd>
4662 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4663 !! end
4664
4665
4666 ###
4667 ### External links
4668 ###
4669 !! test
4670 External links: non-bracketed
4671 !! wikitext
4672 Non-bracketed: http://example.com
4673 !! html
4674 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4675 </p>
4676 !! end
4677
4678 # parsoid doesn't explicitly mark autonumbered links, see T55505
4679 !! test
4680 External links: numbered
4681 !! wikitext
4682 Numbered: [http://example.com]
4683 Numbered: [http://example.net]
4684 Numbered: [http://example.com]
4685 !! html/php
4686 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4687 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4688 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4689 </p>
4690 !! html/parsoid
4691 <p>Numbered: <a rel="mw:ExtLink" href="http://example.com"></a>
4692 Numbered: <a rel="mw:ExtLink" href="http://example.net"></a>
4693 Numbered: <a rel="mw:ExtLink" href="http://example.com"></a></p>
4694 !!end
4695
4696 !! test
4697 External links: specified text
4698 !! wikitext
4699 Specified text: [http://example.com link]
4700 !! html
4701 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4702 </p>
4703 !!end
4704
4705 !! test
4706 External links: trail
4707 !! wikitext
4708 Linktrails should not work for external links: [http://example.com link]s
4709 !! html
4710 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4711 </p>
4712 !! end
4713
4714 !! test
4715 External links: dollar sign in URL
4716 !! wikitext
4717 http://example.com/1$2345
4718 !! html
4719 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4720 </p>
4721 !! end
4722
4723 # parsoid doesn't explicitly mark autonumbered links, see T55505
4724 !! test
4725 External links: dollar sign in URL (autonumber)
4726 !! wikitext
4727 [http://example.com/1$2345]
4728 !! html/php
4729 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4730 </p>
4731 !! html/parsoid
4732 <p><a rel="mw:ExtLink" href="http://example.com/1$2345"></a></p>
4733 !!end
4734
4735 !! test
4736 External links: open square bracket forbidden in URL (T6377)
4737 !! options
4738 parsoid=wt2html,wt2wt,html2html
4739 !! wikitext
4740 http://example.com/1[2345
4741 !! html/php
4742 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4743 </p>
4744 !! html/parsoid
4745 <p><a rel="mw:ExtLink" href="http://example.com/1">http://example.com/1</a>[2345</p>
4746 !! end
4747
4748 !! test
4749 External links: open square bracket forbidden in URL (named) (T6377)
4750 !! options
4751 parsoid=wt2html,html2html
4752 !! wikitext
4753 [http://example.com/1[2345]
4754 !! html/php
4755 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4756 </p>
4757 !! html/parsoid
4758 <p><a rel="mw:ExtLink" href="http://example.com/1">[2345</a></p>
4759 !!end
4760
4761 # parsoid adds a space before the link name
4762 !! test
4763 External links: open square bracket forbidden in URL (named) (T6377)
4764 Parsoid variant.
4765 !! wikitext
4766 [http://example.com/1 [2345]
4767 !! html
4768 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4769 </p>
4770 !!end
4771
4772 !! test
4773 External links: nowiki in URL link text (T8230)
4774 !! wikitext
4775 [http://example.com/ <nowiki>''example site''</nowiki>]
4776 !! html
4777 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4778 </p>
4779 !! end
4780
4781 !! test
4782 External links: newline forbidden in text (T8230 regression check)
4783 !! wikitext
4784 [http://example.com/ first
4785 second]
4786 !! html
4787 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4788 second]
4789 </p>
4790 !!end
4791
4792 !! test
4793 External links: Pipe char between url and text
4794 !! wikitext
4795 [http://example.com | link]
4796 !! html
4797 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4798 </p>
4799 !!end
4800
4801 !! test
4802 External links: protocol-relative URL in brackets
4803 !! wikitext
4804 [//example.com/ Test]
4805 !! html
4806 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4807 </p>
4808 !! end
4809
4810 # parsoid doesn't explicitly mark autonumbered links, see T55505
4811 !! test
4812 External links: protocol-relative URL in brackets without text
4813 !! wikitext
4814 [//example.com]
4815 !! html/php
4816 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
4817 </p>
4818 !! html/parsoid
4819 <p><a rel="mw:ExtLink" href="//example.com"></a></p>
4820 !! end
4821
4822 !! test
4823 External links: protocol-relative URL in free text is left alone
4824 !! wikitext
4825 //example.com/Foo
4826 !! html
4827 <p>//example.com/Foo
4828 </p>
4829 !!end
4830
4831 !! test
4832 External links: protocol-relative URL in the middle of a word is left alone (T32269)
4833 !! wikitext
4834 foo//example.com/Foo
4835 !! html
4836 <p>foo//example.com/Foo
4837 </p>
4838 !! end
4839
4840 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
4841 !! test
4842 External links: with no contents
4843 !! options
4844 parsoid=wt2html,wt2wt
4845 !! wikitext
4846 [http://en.wikipedia.org/wiki/Foo]
4847
4848 [[wikipedia:Foo|Bar]]
4849
4850 [[wikipedia:Foo|<span>Bar</span>]]
4851 !! html/php
4852 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
4853 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
4854 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
4855 </p>
4856 !! html/parsoid
4857 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo"></a></p>
4858 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
4859 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
4860 !! end
4861
4862 !! test
4863 External links: Free with trailing punctuation
4864 !! wikitext
4865 http://example.com,
4866 http://example.com;
4867 http://example.com\
4868 http://example.com.
4869 http://example.com:
4870 http://example.com!
4871 http://example.com?
4872 http://example.com)
4873 http://example.com/url_with_(brackets)
4874 (http://example.com/url_without_brackets)
4875 http://example.com/url_with_entity&amp;
4876 http://example.com/url_with_entity&#x26;
4877 http://example.com/url_with_entity&#038;
4878 http://example.com/url_with_entity&nbsp;
4879 http://example.com/url_with_entity&#xA0;
4880 http://example.com/url_with_entity&#160;
4881 http://example.com/url_with_entity&lt;
4882 http://example.com/url_with_entity&#x3C;
4883 http://example.com/url_with_entity&#60;
4884 !! html/php
4885 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
4886 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
4887 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
4888 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
4889 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
4890 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
4891 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
4892 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
4893 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4894 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4895 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4896 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4897 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4898 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4899 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
4900 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4901 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
4902 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
4903 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
4904 </p>
4905 !! html/parsoid
4906 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a>,
4907 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>;
4908 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>\
4909 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>.
4910 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:
4911 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>!
4912 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>?
4913 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>)
4914 <a rel="mw:ExtLink" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4915 (<a rel="mw:ExtLink" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4916 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4917 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4918 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4919 <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>
4920 <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>
4921 <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>
4922 <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>
4923 <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>
4924 <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>
4925 !! end
4926
4927 !! test
4928 External links: tricky Parsoid html2html case
4929 !! options
4930 parsoid=wt2html,wt2wt,html2html
4931 !! wikitext
4932 http://example.com/url_with_entity&amp;amp;
4933 !! html/php
4934 <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>;
4935 </p>
4936 !! html/parsoid
4937 <p><a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;amp">http://example.com/url_with_entity&amp;amp</a>;</p>
4938 !! end
4939
4940 !! test
4941 External links: Free with trailing quotes (T113666)
4942 !! wikitext
4943 '''News:''' Stuff here
4944
4945 news:'a'b''c''d e
4946 !! html/php
4947 <p><b>News:</b> Stuff here
4948 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
4949 </p>
4950 !! html/parsoid
4951 <p><b>News:</b> Stuff here</p>
4952 <p><a rel="mw:ExtLink" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
4953 !! end
4954
4955 !! test
4956 External links: with entity
4957 !! wikitext
4958 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
4959 !! html/php
4960 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
4961 </p>
4962 !! html/parsoid
4963 <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>
4964 !! end
4965
4966 !! test
4967 External links: Lone protocols are never linked (T105697)
4968 !! wikitext
4969 http://
4970 http://;
4971 (http://)
4972 bitcoin:
4973 bitcoin:;
4974 (bitcoin:)
4975 !! html
4976 <p>http://
4977 http://;
4978 (http://)
4979 bitcoin:
4980 bitcoin:;
4981 (bitcoin:)
4982 </p>
4983 !! end
4984
4985 !! test
4986 External links: No preceding word characters allowed (T67278)
4987 !! wikitext
4988 NOPEhttp://example.com
4989 N0http://example.com
4990 ok:http://example.com
4991 ok-http://example.com
4992 !! html
4993 <p>NOPEhttp://example.com
4994 N0http://example.com
4995 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4996 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4997 </p>
4998 !! end
4999
5000 !! test
5001 External links: nofollow domain exception
5002 !! wikitext
5003 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
5004 !! html
5005 <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>.
5006 </p>
5007 !!end
5008
5009 !! test
5010 External image
5011 !! wikitext
5012 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5013 !! html
5014 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5015 </p>
5016 !! end
5017
5018 !! test
5019 External image from https
5020 !! wikitext
5021 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5022 !! html
5023 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5024 </p>
5025 !! end
5026
5027 !! test
5028 External image (when not allowed)
5029 !! options
5030 wgAllowExternalImages=0
5031 !! wikitext
5032 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5033 !! html
5034 <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>
5035 </p>
5036 !! end
5037
5038 !! test
5039 Link to non-http image, no img tag
5040 !! wikitext
5041 Link to non-http image, no img tag: ftp://example.com/test.jpg
5042 !! html
5043 <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>
5044 </p>
5045 !! end
5046
5047 !! test
5048 External links: terminating separator
5049 !! wikitext
5050 Terminating separator: http://example.com/thing,
5051 !! html
5052 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
5053 </p>
5054 !! end
5055
5056 !! test
5057 External links: intervening separator
5058 !! wikitext
5059 Intervening separator: http://example.com/1,2,3
5060 !! html
5061 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
5062 </p>
5063 !! end
5064
5065 !! test
5066 External links: old bug with URL in query
5067 !! wikitext
5068 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
5069 !! html
5070 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
5071 </p>
5072 !! end
5073
5074 !! test
5075 External links: old URL-in-URL bug, mixed protocols
5076 !! wikitext
5077 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
5078 !! html
5079 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
5080 </p>
5081 !!end
5082
5083 # Since Parsoid is starting to emit canonical wikitext for links,
5084 # [http://example.com http://example.com] will not RT back to that
5085 # form anymore.
5086 !! test
5087 External links: URL in text
5088 !! options
5089 parsoid=wt2html
5090 !! wikitext
5091 URL in text: [http://example.com http://example.com]
5092 !! html/php
5093 <p>URL in text: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5094 </p>
5095 !! html/parsoid
5096 <p>URL in text: <a rel="mw:ExtLink" href="http://example.com">http://example.com</a></p>
5097 !! end
5098
5099 !! test
5100 External links: Clickable images
5101 !! wikitext
5102 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5103 !! html/php
5104 <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>
5105 </p>
5106 !! html/parsoid
5107 <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>
5108 !! end
5109
5110 !! test
5111 External links: raw ampersand
5112 !! wikitext
5113 Old &amp; use: http://x&y
5114 !! html
5115 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5116 </p>
5117 !! end
5118
5119 !! test
5120 External links: encoded ampersand
5121 !! wikitext
5122 Old &amp; use: http://x&amp;y
5123 !! html/php
5124 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5125 </p>
5126 !! html/parsoid
5127 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y">http://x&amp;y</a></p>
5128 !! end
5129
5130 !! test
5131 External links: encoded equals (T8102)
5132 !! wikitext
5133 http://example.com/?foo&#61;bar
5134 !! html/php
5135 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5136 </p>
5137 !! html/parsoid
5138 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5139 !! end
5140
5141 ##
5142 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5143 ## does it number them. As discussed in T55505, we can identify
5144 ## autonumbered links via CSS.
5145 ##
5146
5147 !! test
5148 External links: [raw ampersand]
5149 !! wikitext
5150 Old &amp; use: [http://x&y]
5151 !! html/php
5152 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5153 </p>
5154 !! html/parsoid
5155 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y"></a></p>
5156 !! end
5157
5158 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5159 # mode will return the [raw ampersand] wikitext
5160 !! test
5161 External links: [encoded ampersand]
5162 !! options
5163 parsoid=wt2html,wt2wt,html2html
5164 !! wikitext
5165 Old &amp; use: [http://x&amp;y]
5166 !! html/php
5167 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5168 </p>
5169 !! html/parsoid
5170 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y"></a></p>
5171 !! end
5172
5173 !! test
5174 External links: [raw equals]
5175 !! wikitext
5176 [http://example.com/?foo=bar]
5177 !! html/php
5178 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5179 </p>
5180 !! html/parsoid
5181 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar"></a></p>
5182 !! end
5183
5184 # note that parsoid html is identical to [raw equals] case; so html2wt
5185 # mode will return the [raw equals] wikitext
5186 !! test
5187 External links: [encoded equals] (T8102)
5188 !! options
5189 parsoid=wt2html,wt2wt,html2html
5190 !! wikitext
5191 [http://example.com/?foo&#61;bar]
5192 !! html/php
5193 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5194 </p>
5195 !! html/parsoid
5196 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar"></a></p>
5197 !! end
5198
5199 # xxx parsoid strips the IDN character, so the round-trip tests will
5200 # obviously fail and are disabled. --cscott
5201 !! test
5202 External links: [IDN ignored character reference in hostname; strip it right off]
5203 !! options
5204 parsoid=wt2html,wt2wt,html2html
5205 !! wikitext
5206 [http://e&zwnj;xample.com/]
5207 !! html/php
5208 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5209 </p>
5210 !! html/parsoid
5211 <p><a rel="mw:ExtLink" href="http://example.com/"></a></p>
5212 !! end
5213
5214 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5215 # Where an external link could easily circumvent the sanitization of the text of
5216 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5217 # test demands a higher standard. That's a bit strange.
5218 #
5219 # Example:
5220 #
5221 # http://e‌xample.com -> [http://example.com|http://example.com]
5222 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5223 #
5224 # The first example is sanitized, but the second is not. Any security benefits
5225 # from this production are trivial to circumvent. Either remove this test and
5226 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5227 # the test accordingly.
5228 #
5229 # All our love,
5230 # The Parsoid team.
5231 # xxx parsoid strips the IDN character, so the round-trip tests will
5232 # obviously fail and are disabled. --cscott
5233 !! test
5234 External links: IDN ignored character reference in hostname; strip it right off
5235 !! options
5236 parsoid=wt2html,html2html
5237 !! wikitext
5238 http://e&zwnj;xample.com/
5239 !! html/php
5240 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5241 </p>
5242 !! html/parsoid
5243 <p><a rel="mw:ExtLink" href="http://example.com/">http://example.com/</a></p>
5244 !! end
5245
5246 !! test
5247 External links: www.jpeg.org (T2554)
5248 !! wikitext
5249 http://www.jpeg.org
5250 !! html
5251 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5252 </p>
5253 !! end
5254
5255 # parsoid doesn't explicitly mark autonumbered links, see T55505
5256 !! test
5257 External links: URL within URL (T2002)
5258 !! wikitext
5259 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5260 !! html/php
5261 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5262 </p>
5263 !! html/parsoid
5264 <p><a rel="mw:ExtLink" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp"></a></p>
5265 !! end
5266
5267 !! test
5268 T2361: URL inside bracketed URL
5269 !! wikitext
5270 [http://www.example.com/foo http://www.example.com/bar]
5271 !! html
5272 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5273 </p>
5274 !! end
5275
5276 !! test
5277 T2361: URL within URL, not bracketed
5278 !! wikitext
5279 http://www.example.com/foo?=http://www.example.com/bar
5280 !! html
5281 <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>
5282 </p>
5283 !! end
5284
5285 !! test
5286 T2289: ">"-token in URL-tail
5287 !! wikitext
5288 http://www.example.com/<hello>
5289 !! html
5290 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5291 </p>
5292 !!end
5293
5294 !! test
5295 T2289: literal ">"-token in URL-tail
5296 !! wikitext
5297 http://www.example.com/<b>html</b>
5298 !! html/php
5299 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5300 </p>
5301 !! html/parsoid
5302 <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>
5303 !! end
5304
5305 !! test
5306 T2289: ">"-token in bracketed URL
5307 !! wikitext
5308 [http://www.example.com/<hello> stuff]
5309 !! html
5310 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5311 </p>
5312 !!end
5313
5314 !! test
5315 T2289: literal ">"-token in bracketed URL
5316 !! wikitext
5317 [http://www.example.com/<b>html</b> stuff]
5318 !! html
5319 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5320 </p>
5321 !!end
5322
5323 !! test
5324 T2289: literal double quote at end of URL
5325 !! wikitext
5326 http://www.example.com/"hello"
5327 !! html
5328 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5329 </p>
5330 !!end
5331
5332 !! test
5333 T2289: literal double quote in bracketed URL
5334 !! wikitext
5335 [http://www.example.com/"hello" stuff]
5336 !! html
5337 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5338 </p>
5339 !!end
5340
5341 !! test
5342 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5343 !! wikitext
5344 [http://www.example.com test]
5345 !! html
5346 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5347 </p>
5348 !! end
5349
5350 !! test
5351 External links: link text with spaces
5352 !! wikitext
5353 [http://www.example.com a b c]
5354 [http://www.example.com ''a'' ''b'']
5355 !! html
5356 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5357 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5358 </p>
5359 !! end
5360
5361 !! test
5362 External links: wiki links within external link (T5695)
5363 !! options
5364 parsoid=wt2html,html2html
5365 !! wikitext
5366 [http://example.com [[wikilink]] embedded in ext link]
5367 !! html/php
5368 <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>
5369 </p>
5370 !! html/parsoid
5371 <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>
5372 !! end
5373
5374 !! test
5375 T2787: Links with one slash after the url protocol are invalid
5376 !! wikitext
5377 http:/example.com
5378
5379 [http:/example.com title]
5380 !! html
5381 <p>http:/example.com
5382 </p><p>[http:/example.com title]
5383 </p>
5384 !! end
5385
5386 !! test
5387 Bracketed external links with template-generated invalid target
5388 !! wikitext
5389 [{{echo|http:/example.com}} title]
5390 !! html
5391 <p>[http:/example.com title]
5392 </p>
5393 !! end
5394
5395 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5396 !! test
5397 Broken wikilinks (but not external links) prevent templates from closing
5398 !! options
5399 parsoid=wt2html
5400 !! wikitext
5401 [http://example.com x
5402
5403 {{echo|[http://example.com x}}
5404
5405 [[Foo
5406
5407 {{echo|[[Foo}}
5408 !! html/php
5409 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5410 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5411 </p><p>[[Foo
5412 </p><p>{{echo|[[Foo}}
5413 </p>
5414 !! html/parsoid
5415 <p>[<a rel="mw:ExtLink" href="http://example.com">http://example.com</a> x</p>
5416 <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>
5417 <p>[[Foo</p>
5418 <p>{{echo|[[Foo}}</p>
5419 !! end
5420
5421 !! test
5422 Wikilinks with embedded newlines are not broken
5423 !! wikitext
5424 {{echo|[[ Foo
5425 B
5426 C]]}}
5427 !! html/php
5428 <p>[[ Foo
5429 B
5430 C]]
5431 </p>
5432 !! html/parsoid
5433 <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>
5434 !! end
5435
5436 !! test
5437 Broken templates
5438 !! options
5439 parsoid=wt2html
5440 !! wikitext
5441 {{echo|[[Foo|}}]]
5442
5443 [[Foo|{{echo|]]}}
5444 !! html/php
5445 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5446 </p><p>[[Foo|]]
5447 </p>
5448 !! html/parsoid
5449 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5450 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5451 !! end
5452
5453 !! test
5454 T4702: Mismatched <i>, <b> and <a> tags are invalid
5455 !! wikitext
5456 ''[http://example.com text'']
5457 [http://example.com '''text]'''
5458 ''Something [http://example.com in italic'']
5459 ''Something [http://example.com mixed''''', even bold]'''
5460 '''''Now [http://example.com both''''']
5461 !! html
5462 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5463 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5464 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5465 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5466 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5467 </p>
5468 !! end
5469
5470
5471 !! test
5472 T6781: %26 in URL
5473 !! wikitext
5474 http://www.example.com/?title=AT%26T
5475 !! html/php
5476 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5477 </p>
5478 !! html/parsoid
5479 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a></p>
5480 !! end
5481
5482 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5483 # % is actually legal in HTML5. Any change in output would need testing though.
5484 !! test
5485 T6781, T7267: %25 in URL
5486 !! wikitext
5487 http://www.example.com/?title=100%25_Bran
5488 !! html/php
5489 <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>
5490 </p>
5491 !! html/parsoid
5492 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=100%25_Bran">http://www.example.com/?title=100%25_Bran</a></p>
5493 !! end
5494
5495 !! test
5496 T6781, T7267: %28, %29 in URL
5497 !! wikitext
5498 http://www.example.com/?title=Ben-Hur_%281959_film%29
5499 !! html/php
5500 <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>
5501 </p>
5502 !! html/parsoid
5503 <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>
5504 !! end
5505
5506
5507 !! test
5508 T6781: %26 in autonumber URL
5509 !! wikitext
5510 [http://www.example.com/?title=AT%26T]
5511 !! html/php
5512 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5513 </p>
5514 !! html/parsoid
5515 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T"></a></p>
5516 !! end
5517
5518 !! test
5519 T6781, T7267: %26 in autonumber URL
5520 !! wikitext
5521 [http://www.example.com/?title=100%25_Bran]
5522 !! html/php
5523 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5524 </p>
5525 !! html/parsoid
5526 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=100%25_Bran"></a></p>
5527 !! end
5528
5529 !! test
5530 T6781, T7267: %28, %29 in autonumber URL
5531 !! wikitext
5532 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5533 !! html/php
5534 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5535 </p>
5536 !! html/parsoid
5537 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5538 !! end
5539
5540
5541 !! test
5542 T6781: %26 in bracketed URL
5543 !! wikitext
5544 [http://www.example.com/?title=AT%26T link]
5545 !! html/php
5546 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5547 </p>
5548 !! html/parsoid
5549 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T">link</a></p>
5550 !! end
5551
5552 !! test
5553 T6781, T7267: %25 in bracketed URL
5554 !! wikitext
5555 [http://www.example.com/?title=100%25_Bran link]
5556 !! html
5557 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5558 </p>
5559 !! end
5560
5561 !! test
5562 T6781, T7267: %28, %29 in bracketed URL
5563 !! wikitext
5564 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5565 !! html/php
5566 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5567 </p>
5568 !! html/parsoid
5569 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5570 !! end
5571
5572 !! test
5573 External link containing a period in the anchor. (T65947)
5574 !! wikitext
5575 [//foo.org/bar#baz. bang]
5576
5577 [//foo.org/bar. bang]
5578 !! html/php
5579 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5580 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5581 </p>
5582 !! html/parsoid
5583 <p><a rel="mw:ExtLink" href="//foo.org/bar#baz.">bang</a></p>
5584 <p><a rel="mw:ExtLink" href="//foo.org/bar.">bang</a></p>
5585 !! end
5586
5587 !! test
5588 External link containing a single quote. (T65947)
5589 !! wikitext
5590 [//foo.org/bar'baz]
5591
5592 [//foo.org/bar'baz bang]
5593 !! html/php
5594 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
5595 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
5596 </p>
5597 !! html/parsoid
5598 <p><a rel="mw:ExtLink" href="//foo.org/bar'baz"></a></p>
5599 <p><a rel="mw:ExtLink" href="//foo.org/bar'baz">bang</a></p>
5600 !! end
5601
5602 !! test
5603 External link containing double-single-quotes in text '' (T6598 sanity check)
5604 !! wikitext
5605 Some [http://example.com/ pretty ''italics'' and stuff]!
5606 !! html
5607 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5608 </p>
5609 !! end
5610
5611 !! test
5612 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5613 !! wikitext
5614 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5615 !! html
5616 <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>
5617 </p>
5618 !! end
5619
5620 !! test
5621 External link containing double-single-quotes with no space separating the url from text in italics
5622 !! wikitext
5623 [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]].]
5624 !! html/php
5625 <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 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>.</a>
5626 </p>
5627 !! html/php+tidy
5628 <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>.</p>
5629 !! html/parsoid
5630 <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>
5631 !! end
5632
5633 !! test
5634 External link with comments in link text
5635 !! wikitext
5636 [http://www.google.com Google <!-- comment -->]
5637 !! html/php
5638 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5639 </p>
5640 !! html/parsoid
5641 <p><a rel="mw:ExtLink" href="http://www.google.com">Google <!-- comment --></a></p>
5642 !! end
5643
5644 !! test
5645 External link to bare IPv4 address
5646 !! wikitext
5647 [http://192.168.0.1 Link]
5648 !! html/php
5649 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5650 </p>
5651 !! html/parsoid
5652 <p><a rel="mw:ExtLink" href="http://192.168.0.1">Link</a></p>
5653 !! end
5654
5655 !! test
5656 URL-encoding in URL functions (single parameter)
5657 !! wikitext
5658 {{localurl:Some page|amp=&}}
5659 !! html
5660 <p>/index.php?title=Some_page&amp;amp=&amp;
5661 </p>
5662 !! end
5663
5664 !! test
5665 URL-encoding in URL functions (multiple parameters)
5666 !! wikitext
5667 {{localurl:Some page|q=?&amp=&}}
5668 !! html
5669 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5670 </p>
5671 !! end
5672
5673 !! test
5674 Brackets in urls
5675 !! wikitext
5676 http://example.com/index.php?foozoid%5B%5D=bar
5677
5678 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5679 !! html/php
5680 <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>
5681 </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>
5682 </p>
5683 !! html/parsoid
5684 <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>
5685
5686 <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>
5687 !! end
5688
5689 !! test
5690 IPv6 urls, autolink format (T23261)
5691 !! wikitext
5692 http://[2404:130:0:1000::187:2]/index.php
5693
5694 Examples from RFC 2373, section 2.2:
5695 * http://[1080::8:800:200C:417A]/unicast
5696 * http://[FF01::101]/multicast
5697 * http://[::1]/loopback
5698 * http://[::]/unspecified
5699 * http://[::13.1.68.3]/ipv4compat
5700 * http://[::FFFF:129.144.52.38]/ipv4compat
5701
5702 Examples from RFC 2732, section 2:
5703 * http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5704 * http://[1080:0:0:0:8:800:200C:417A]/index.html
5705 * http://[3ffe:2a00:100:7031::1]
5706 * http://[1080::8:800:200C:417A]/foo
5707 * http://[::192.9.5.5]/ipng
5708 * http://[::FFFF:129.144.52.38]:80/index.html
5709 * http://[2010:836B:4179::836B:4179]
5710
5711 !! html/php
5712 <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>
5713 </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:
5714 </p>
5715 <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>
5716 <li> <a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5717 <li> <a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5718 <li> <a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5719 <li> <a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5720 <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>
5721 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5722 </p>
5723 <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>
5724 <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>
5725 <li> <a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5726 <li> <a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5727 <li> <a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5728 <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>
5729 <li> <a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5730
5731 !! html/parsoid
5732 <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>
5733
5734 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
5735 <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
5736 <li> <a rel="mw:ExtLink" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5737 <li> <a rel="mw:ExtLink" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5738 <li> <a rel="mw:ExtLink" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5739 <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5740 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
5741
5742 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
5743 <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>
5744 <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>
5745 <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5746 <li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5747 <li> <a rel="mw:ExtLink" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5748 <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>
5749 <li> <a rel="mw:ExtLink" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5750 !! end
5751
5752 !! test
5753 IPv6 urls, bracketed format (T23261)
5754 !! wikitext
5755 [http://[2404:130:0:1000::187:2]/index.php test]
5756
5757 Examples from RFC 2373, section 2.2:
5758 * [http://[1080::8:800:200C:417A] unicast]
5759 * [http://[FF01::101] multicast]
5760 * [http://[::1]/ loopback]
5761 * [http://[::] unspecified]
5762 * [http://[::13.1.68.3] ipv4compat]
5763 * [http://[::FFFF:129.144.52.38] ipv4compat]
5764
5765 Examples from RFC 2732, section 2:
5766 * [http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5767 * [http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5768 * [http://[3ffe:2a00:100:7031::1] 3]
5769 * [http://[1080::8:800:200C:417A]/foo 4]
5770 * [http://[::192.9.5.5]/ipng 5]
5771 * [http://[::FFFF:129.144.52.38]:80/index.html 6]
5772 * [http://[2010:836B:4179::836B:4179] 7]
5773
5774 !! html/php
5775 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5776 </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:
5777 </p>
5778 <ul><li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5779 <li> <a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5780 <li> <a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5781 <li> <a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5782 <li> <a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5783 <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5784 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5785 </p>
5786 <ul><li> <a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5787 <li> <a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5788 <li> <a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5789 <li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5790 <li> <a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5791 <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5792 <li> <a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5793
5794 !! html/parsoid
5795 <p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5796
5797 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
5798 <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5799 <li> <a rel="mw:ExtLink" href="http://[FF01::101]">multicast</a></li>
5800 <li> <a rel="mw:ExtLink" href="http://[::1]/">loopback</a></li>
5801 <li> <a rel="mw:ExtLink" href="http://[::]">unspecified</a></li>
5802 <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]">ipv4compat</a></li>
5803 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5804
5805 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
5806 <ul><li> <a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5807 <li> <a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5808 <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5809 <li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5810 <li> <a rel="mw:ExtLink" href="http://[::192.9.5.5]/ipng">5</a></li>
5811 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5812 <li> <a rel="mw:ExtLink" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5813 !! end
5814
5815 !! test
5816 Non-extlinks in brackets
5817 !! wikitext
5818 [foo]
5819 [foo bar]
5820 [foo ''bar'']
5821 [fool's] errand
5822 [fool's errand]
5823 [{{echo|foo}}]
5824 [{{echo|foo}} bar]
5825 [{{echo|foo}} ''bar'']
5826 [{{echo|foo}}l's] errand
5827 [{{echo|foo}}l's errand]
5828 [url={{echo|foo}}]
5829 [url=http://example.com]
5830 [http:// bare protocols don't count]
5831 !! html/php
5832 <p>[foo]
5833 [foo bar]
5834 [foo <i>bar</i>]
5835 [fool's] errand
5836 [fool's errand]
5837 [foo]
5838 [foo bar]
5839 [foo <i>bar</i>]
5840 [fool's] errand
5841 [fool's errand]
5842 [url=foo]
5843 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
5844 [http:// bare protocols don't count]
5845 </p>
5846 !! html/parsoid
5847 <p>[foo]
5848 [foo bar]
5849 [foo <i>bar</i>]
5850 [fool's] errand
5851 [fool's errand]
5852 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span>]
5853 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span> bar]
5854 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span> <i>bar</i>]
5855 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}l&#39;s"}'>fool's</span>] errand
5856 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}l&#39;s"}'>fool's</span> errand]
5857 [<span typeof="mw:Placeholder" data-parsoid='{"src":"url={{echo|foo}}"}'>url=foo</span>]
5858 [url=<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>]
5859 [http:// bare protocols don't count]</p>
5860 !! end
5861
5862 !! test
5863 Percent encoding in external links
5864 !! wikitext
5865 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
5866 !! html/php
5867 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
5868 </p>
5869 !! html/parsoid
5870 <p><a rel="mw:ExtLink"
5871 href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
5872 !! end
5873
5874 !! test
5875 Use url link syntax for links where the content is equal the link target
5876 !! wikitext
5877 http://example.com
5878 !! html/php
5879 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5880 </p>
5881 !! html/parsoid
5882 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></p>
5883 !! end
5884
5885 !! test
5886 Parenthesis in external links, especially URL links
5887 !! wikitext
5888 http://example.com)
5889
5890 http://example.com/test)
5891
5892 http://example.com/(test)
5893
5894 http://example.com/((test)
5895
5896 (http://example.com/(test))
5897
5898 (http://example.com/(test)))))
5899
5900 http://example.com/a)b
5901
5902 [http://example.com) foo]
5903 !! html/php
5904 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5905 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
5906 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
5907 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
5908 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
5909 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
5910 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
5911 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
5912 </p>
5913 !! html/parsoid
5914 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a>)</p>
5915 <p><a rel="mw:ExtLink" href="http://example.com/test">http://example.com/test</a>)</p>
5916 <p><a rel="mw:ExtLink" href="http://example.com/(test)">http://example.com/(test)</a></p>
5917 <p><a rel="mw:ExtLink" href="http://example.com/((test)">http://example.com/((test)</a></p>
5918 <p>(<a rel="mw:ExtLink" href="http://example.com/(test))">http://example.com/(test))</a></p>
5919 <p>(<a rel="mw:ExtLink" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
5920 <p><a rel="mw:ExtLink" href="http://example.com/a)b">http://example.com/a)b</a></p>
5921 <p><a rel="mw:ExtLink" href="http://example.com)">foo</a></p>
5922 !! end
5923
5924 !! test
5925 Parenthesis in external links, w/ transclusion or comment
5926 !! wikitext
5927 (http://example.com/{{echo|hi}})
5928
5929 (http://example.com<!-- hi -->)
5930 !! html/php
5931 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
5932 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5933 </p>
5934 !! html/parsoid
5935 <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>
5936
5937 <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>
5938 !! end
5939
5940 !! test
5941 Serialize <a> tags with invalid link targets as plain text
5942 !! options
5943 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
5944 !! html/parsoid
5945 <a rel="mw:WikiLink" href="[[foo]]">text</a>
5946 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
5947 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
5948 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
5949 !! wikitext
5950 text
5951 <nowiki>*</nowiki>text
5952 <nowiki>[[foo]]</nowiki>
5953 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
5954 !! end
5955
5956 !! test
5957 mw:ExtLink -vs- mw:WikiLink (T94723)
5958 !! options
5959 parsoid=html2wt
5960 !! html/parsoid
5961 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
5962 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
5963 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5964 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5965 <p>
5966 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5967 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5968 </p>
5969 !! wikitext
5970 [[Foo|Bar]]
5971 [[Foo|Bar]]
5972 [[:en:Foo|Bar]]
5973 [[:en:Foo|Bar]]
5974
5975 [[:en:European_Robin|European Robin]]
5976 [[:en:European_Robin|European Robin]]
5977 !! end
5978
5979 !! test
5980 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
5981 !! options
5982 parsoid=wt2wt
5983 !! wikitext
5984 [http://en.wikipedia.org/wiki/European_Robin European Robin]
5985 !! html/parsoid
5986 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
5987 !! end
5988
5989
5990 ###
5991 ### Quotes
5992 ###
5993
5994 !! test
5995 Quotes
5996 !! wikitext
5997 Normal text. '''Bold text.''' Normal text. ''Italic text.''
5998
5999 Normal text. '''''Bold italic text.''''' Normal text.
6000 !! html
6001 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
6002 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
6003 </p>
6004 !! end
6005
6006
6007 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
6008 # parser strips. The wikitext contains just the first half of the bold
6009 # quote pair.
6010 !! test
6011 Unclosed and unmatched quotes
6012 !! wikitext
6013 '''''Bold italic text '''with bold deactivated''' in between.'''''
6014
6015 '''''Bold italic text ''with italic deactivated'' in between.'''''
6016
6017 '''Bold text..
6018
6019 ..spanning two paragraphs (should not work).'''
6020
6021 '''Bold tag left open
6022
6023 ''Italic tag left open
6024
6025 Normal text.
6026
6027 <!-- Unmatching number of opening, closing tags: -->
6028 '''This year''''s election ''should'' beat '''last year''''s.
6029
6030 ''Tom'''s car is bigger than ''Susan'''s.
6031
6032 Plain ''italic'''s plain
6033 !! html/php
6034 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6035 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6036 </p><p><b>Bold text..</b>
6037 </p><p>..spanning two paragraphs (should not work).
6038 </p><p><b>Bold tag left open</b>
6039 </p><p><i>Italic tag left open</i>
6040 </p><p>Normal text.
6041 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6042 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6043 </p><p>Plain <i>italic'</i>s plain
6044 </p>
6045 !! html/parsoid
6046 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6047 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6048 </p><p><b>Bold text..</b>
6049 </p><p>..spanning two paragraphs (should not work).<b></b>
6050 </p><p><b>Bold tag left open</b>
6051 </p><p><i>Italic tag left open</i>
6052 </p><p>Normal text.
6053 </p>
6054 <!-- Unmatching number of opening, closing tags: -->
6055 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6056 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6057 </p><p>Plain <i>italic'</i>s plain
6058 </p>
6059 !! end
6060
6061 ###
6062 ### Tables
6063 ###
6064 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
6065 ###
6066
6067 # This should not produce <table></table> as <table><tr><td></td></tr></table>
6068 # is the bare minimum required by the spec, see:
6069 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
6070 # Parsoid team replies: empty table tags are legal in HTML5
6071 !! test
6072 A table with no data.
6073 !! options
6074 parsoid=wt2html
6075 !! wikitext
6076 {||}
6077 !! html/php
6078
6079 !! html/parsoid
6080 <table></table>
6081
6082 !! end
6083
6084 !! test
6085 A table with stray table end tags on start tag line (wt2html)
6086 !! options
6087 parsoid=wt2html
6088 !! wikitext
6089 {|style="color: red;"|}
6090
6091 {|style="color: red;" |}
6092 |foo
6093 |}
6094
6095 {|style="color: red;"|} id="foo"
6096 |foo
6097 |}
6098
6099 {|style="color: red;" |} id="foo"
6100 |foo
6101 |}
6102 !! html
6103 <table style="color: red;"></table>
6104
6105 <table style="color: red;">
6106 <tbody><tr>
6107 <td>foo</td>
6108 </tr></tbody>
6109 </table>
6110
6111 <table style="color: red;" id="foo">
6112 <tbody><tr>
6113 <td>foo</td>
6114 </tr></tbody>
6115 </table>
6116
6117 <table style="color: red;" id="foo">
6118 <tbody><tr>
6119 <td>foo</td>
6120 </tr></tbody>
6121 </table>
6122
6123 !! end
6124
6125 !! test
6126 A table with no data (take 2)
6127 !! wikitext
6128 {|
6129 |}
6130 !! html/parsoid
6131 <table></table>
6132 !! end
6133
6134 # A table with nothing but a caption is invalid XHTML, we might want to render
6135 # this as <p>caption</p>
6136 # Parsoid team replies: table with only a caption is legal in HTML5
6137 !! test
6138 A table with nothing but a caption
6139 !! wikitext
6140 {|
6141 |+ caption
6142 |}
6143 !! html/php
6144 <table>
6145 <caption> caption
6146 </caption><tr><td></td></tr></table>
6147
6148 !! html/parsoid
6149 <table><caption> caption</caption></table>
6150 !! end
6151
6152 !! test
6153 A table with caption with default-spaced attributes and a table row
6154 !! wikitext
6155 {|
6156 |+ style="color: red;" | caption1
6157 |-
6158 | foo
6159 |}
6160 !! html
6161 <table>
6162 <caption style="color: red;"> caption1
6163 </caption>
6164 <tr>
6165 <td> foo
6166 </td></tr></table>
6167
6168 !! end
6169
6170 !! test
6171 A table with captions with non-default spaced attributes and a table row
6172 !! wikitext
6173 {|
6174 |+style="color: red;"|caption2
6175 |+ style="color: red;"| caption3
6176 |-
6177 | foo
6178 |}
6179 !! html
6180 <table>
6181 <caption style="color: red;">caption2
6182 </caption>
6183 <caption style="color: red;"> caption3
6184 </caption>
6185 <tr>
6186 <td> foo
6187 </td></tr></table>
6188
6189 !! end
6190
6191 !! test
6192 Table td-cell syntax variations
6193 !! wikitext
6194 {|
6195 | foo bar foo | baz
6196 | foo bar foo || baz
6197 | style='color:red;' | baz
6198 | style='color:red;' || baz
6199 |}
6200 !! html
6201 <table>
6202 <tr>
6203 <td> baz
6204 </td>
6205 <td> foo bar foo </td>
6206 <td> baz
6207 </td>
6208 <td style="color:red;"> baz
6209 </td>
6210 <td> style='color:red;' </td>
6211 <td> baz
6212 </td></tr></table>
6213
6214 !! end
6215
6216 !! test
6217 Simple table
6218 !! wikitext
6219 {|
6220 | 1 || 2
6221 |-
6222 | 3 || 4
6223 |}
6224 !! html
6225 <table>
6226 <tr>
6227 <td> 1 </td>
6228 <td> 2
6229 </td></tr>
6230 <tr>
6231 <td> 3 </td>
6232 <td> 4
6233 </td></tr></table>
6234
6235 !! end
6236
6237 !! test
6238 Simple table but with multiple dashes for row wikitext
6239 !! wikitext
6240 {|
6241 | foo
6242 |-----
6243 | bar
6244 |}
6245 !! html
6246 <table>
6247 <tr>
6248 <td> foo
6249 </td></tr>
6250 <tr>
6251 <td> bar
6252 </td></tr></table>
6253
6254 !! end
6255
6256 !! test
6257 Multiplication table
6258 !! wikitext
6259 {| border="1" cellpadding="2"
6260 |+Multiplication table
6261 |-
6262 ! &times; !! 1 !! 2 !! 3
6263 |-
6264 ! 1
6265 | 1 || 2 || 3
6266 |-
6267 ! 2
6268 | 2 || 4 || 6
6269 |-
6270 ! 3
6271 | 3 || 6 || 9
6272 |-
6273 ! 4
6274 | 4 || 8 || 12
6275 |-
6276 ! 5
6277 | 5 || 10 || 15
6278 |}
6279 !! html
6280 <table border="1" cellpadding="2">
6281 <caption>Multiplication table
6282 </caption>
6283 <tr>
6284 <th> &#215; </th>
6285 <th> 1 </th>
6286 <th> 2 </th>
6287 <th> 3
6288 </th></tr>
6289 <tr>
6290 <th> 1
6291 </th>
6292 <td> 1 </td>
6293 <td> 2 </td>
6294 <td> 3
6295 </td></tr>
6296 <tr>
6297 <th> 2
6298 </th>
6299 <td> 2 </td>
6300 <td> 4 </td>
6301 <td> 6
6302 </td></tr>
6303 <tr>
6304 <th> 3
6305 </th>
6306 <td> 3 </td>
6307 <td> 6 </td>
6308 <td> 9
6309 </td></tr>
6310 <tr>
6311 <th> 4
6312 </th>
6313 <td> 4 </td>
6314 <td> 8 </td>
6315 <td> 12
6316 </td></tr>
6317 <tr>
6318 <th> 5
6319 </th>
6320 <td> 5 </td>
6321 <td> 10 </td>
6322 <td> 15
6323 </td></tr></table>
6324
6325 !! end
6326
6327 !! test
6328 Accept "||" in table headings
6329 !! wikitext
6330 {|
6331 !h1 || h2
6332 |}
6333 !! html
6334 <table>
6335 <tr>
6336 <th>h1 </th>
6337 <th> h2
6338 </th></tr></table>
6339
6340 !! end
6341
6342 !! test
6343 Accept "!!" in table data
6344 !! wikitext
6345 {|
6346 | Foo!! ||
6347 |}
6348 !! html
6349 <table>
6350 <tr>
6351 <td> Foo!! </td>
6352 <td>
6353 </td></tr></table>
6354
6355 !! html/parsoid
6356 <table>
6357 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
6358 </tbody></table>
6359 !! end
6360
6361 !! test
6362 Accept "||" in indented table headings
6363 !! wikitext
6364 :{|
6365 !h1 || h2
6366 |}
6367 !! html
6368 <dl><dd><table>
6369 <tr>
6370 <th>h1 </th>
6371 <th> h2
6372 </th></tr></table></dd></dl>
6373
6374 !! end
6375
6376 !! test
6377 Accept "!!" in templates
6378 !! wikitext
6379 {|
6380 !a {{echo|b!!c}}
6381 |}
6382 !! html/php
6383 <table>
6384 <tr>
6385 <th>a b</th>
6386 <th>c
6387 </th></tr></table>
6388
6389 !! html/parsoid
6390 <table>
6391 <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>
6392 !! end
6393
6394 !! test
6395 Accept "!!" in table headings after newline
6396 !! wikitext
6397 {|
6398 !a
6399 b!!c
6400 |}
6401 !! html/php
6402 <table>
6403 <tr>
6404 <th>a
6405 <p>b!!c
6406 </p>
6407 </th></tr></table>
6408
6409 !! html/parsoid
6410 <table>
6411 <tbody><tr><th>a
6412 <p>b!!c</p></th></tr>
6413 </tbody></table>
6414 !! end
6415
6416 !! test
6417 Accept "!!" in table data of mixed wikitext / html syntax
6418 !! wikitext
6419 {|
6420 !a
6421 <tr><td>b!!c</td></tr>
6422 |}
6423 !! html+tidy
6424 <table>
6425 <tr>
6426 <th>a</th>
6427 </tr>
6428 <tr>
6429 <td>b!!c</td>
6430 </tr>
6431 </table>
6432 !! html/parsoid
6433 <table>
6434 <tbody><tr><th>a</th></tr>
6435 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6436 </tbody></table>
6437 !! end
6438
6439 !! test
6440 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6441 !! wikitext
6442 {|
6443 !| h1
6444 || a
6445 |}
6446 !! html
6447 <table>
6448 <tr>
6449 <th> h1
6450 </th>
6451 <td> a
6452 </td></tr></table>
6453
6454 !! end
6455
6456 !!test
6457 Accept "| !" at start of line in tables (ignore !-attribute)
6458 !! wikitext
6459 {|
6460 |-
6461 | !style="color:red" | bar
6462 |}
6463 !! html
6464 <table>
6465
6466 <tr>
6467 <td> bar
6468 </td></tr></table>
6469
6470 !!end
6471
6472 !!test
6473 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 +/-
6474 !! wikitext
6475 {|
6476 |-
6477 |style='color:red;'|+1
6478 |style='color:blue;'|-1
6479 |-
6480 | 1 || 2 || 3
6481 | 1 ||+2 ||-3
6482 |-
6483 | +1
6484 | -1
6485 |}
6486 !! html
6487 <table>
6488
6489 <tr>
6490 <td style="color:red;">+1
6491 </td>
6492 <td style="color:blue;">-1
6493 </td></tr>
6494 <tr>
6495 <td> 1 </td>
6496 <td> 2 </td>
6497 <td> 3
6498 </td>
6499 <td> 1 </td>
6500 <td>+2 </td>
6501 <td>-3
6502 </td></tr>
6503 <tr>
6504 <td> +1
6505 </td>
6506 <td> -1
6507 </td></tr></table>
6508
6509 !!end
6510
6511 !! test
6512 Table rowspan
6513 !! wikitext
6514 {| border=1
6515 | Cell 1, row 1
6516 |rowspan=2| Cell 2, row 1 (and 2)
6517 | Cell 3, row 1
6518 |-
6519 | Cell 1, row 2
6520 | Cell 3, row 2
6521 |}
6522 !! html
6523 <table border="1">
6524 <tr>
6525 <td> Cell 1, row 1
6526 </td>
6527 <td rowspan="2"> Cell 2, row 1 (and 2)
6528 </td>
6529 <td> Cell 3, row 1
6530 </td></tr>
6531 <tr>
6532 <td> Cell 1, row 2
6533 </td>
6534 <td> Cell 3, row 2
6535 </td></tr></table>
6536
6537 !! end
6538
6539 !! test
6540 Nested table
6541 !! wikitext
6542 {| border=1
6543 | &alpha;
6544 |
6545 {| bgcolor=#ABCDEF border=2
6546 |nested
6547 |-
6548 |table
6549 |}
6550 |the original table again
6551 |}
6552 !! html
6553 <table border="1">
6554 <tr>
6555 <td> &#945;
6556 </td>
6557 <td>
6558 <table bgcolor="#ABCDEF" border="2">
6559 <tr>
6560 <td>nested
6561 </td></tr>
6562 <tr>
6563 <td>table
6564 </td></tr></table>
6565 </td>
6566 <td>the original table again
6567 </td></tr></table>
6568
6569 !! end
6570
6571 !! test
6572 Invalid attributes in table cell (T3830)
6573 !! wikitext
6574 {|
6575 |Cell:|broken
6576 |}
6577 !! html
6578 <table>
6579 <tr>
6580 <td>broken
6581 </td></tr></table>
6582
6583 !! end
6584
6585 !! test
6586 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6587 !! wikitext
6588 {|
6589 | title="foo" |bar
6590 | title="foo<nowiki>|</nowiki>" |bar
6591 | title="foo<nowiki>|</nowiki>" bar
6592 |}
6593 !! html/php
6594 <table>
6595 <tr>
6596 <td title="foo">bar
6597 </td>
6598 <td title="foo&#124;">bar
6599 </td>
6600 <td> title="foo|" bar
6601 </td></tr></table>
6602
6603 !! html/parsoid
6604 <table>
6605 <tbody><tr><td title="foo">bar</td>
6606 <td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
6607 <td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6608 </tbody></table>
6609 !! end
6610
6611 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6612 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6613 # *2wt modes will fail.
6614 !! test
6615 Table security: embedded pipes
6616 !! options
6617 parsoid=wt2html,html2html
6618 !! wikitext
6619 {|
6620 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6621 !! html/php
6622 <table>
6623 <tr>
6624 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6625 <td>]" onmouseover="alert(document.cookie)"&gt;test
6626 </td>
6627 </tr>
6628 </table>
6629
6630 !! html/parsoid
6631 <table><tbody>
6632 <tr>
6633 <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>
6634 !! end
6635
6636 !! test
6637 Element attributes with double ! should not be broken up by <th>
6638 !! wikitext
6639 {|
6640 ! hi <div class="!!">ha</div> ho
6641 |}
6642 !! html/php
6643 <table>
6644 <tr>
6645 <th> hi <div class="!!">ha</div> ho
6646 </th></tr></table>
6647
6648 !! html/parsoid
6649 <table>
6650 <tbody><tr><th> hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6651 </tbody></table>
6652 !! end
6653
6654 !! test
6655 ! and || in element attributes should not be parsed as <th>/<td>
6656 !! wikitext
6657 {|
6658 | <div style="color: red !important;" data-contrived="put this here ||">hi</div>
6659 |}
6660 !! html/php
6661 <table>
6662 <tr>
6663 <td> <div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
6664 </td></tr></table>
6665
6666 !! html/parsoid
6667 <table>
6668 <tbody><tr><td> <div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6669 </tbody></table>
6670 !! end
6671
6672 # FIXME: The output seems broken. Filed as T110268.
6673 !! test
6674 ! and || in td attributes should not be parsed as <th>/<td>
6675 !! options
6676 parsoid=wt2html
6677 !! wikitext
6678 {|
6679 | style="color: red !important;" data-contrived="put this here ||" | foo
6680 |}
6681 !! html/php
6682 <table>
6683 <tr>
6684 <td> style="color: red !important;" data-contrived="put this here </td>
6685 <td> foo
6686 </td></tr></table>
6687
6688 !! html/parsoid
6689 <table>
6690 <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>
6691 </tbody></table>
6692 !! end
6693
6694 !! test
6695 Break on | in element attribute in template
6696 !! options
6697 parsoid=wt2html,html2html
6698 !! wikitext
6699 {{echo|1=<div class="hi|ho">ha</div>}}
6700 !! html/php
6701 <p>ho"&gt;ha&lt;/div&gt;
6702 </p>
6703 !! html/parsoid
6704 <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>
6705 !! end
6706
6707 !! test
6708 Break on | in element attribute name in template
6709 !! wikitext
6710 {{echo|<div cla|ss="hiho">ha</div>}}
6711 !! html/parsoid
6712 <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>
6713 !! end
6714
6715 !! test
6716 Don't break on | in extension attribute in template
6717 !! wikitext
6718 {{echo|<ref name="hi|ho">ha</ref>}}
6719
6720 <references />
6721 !! html/parsoid
6722 <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>
6723
6724 <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>
6725 !! end
6726
6727 ## We don't support roundtripping of these attributes in Parsoid.
6728 ## Selective serialization takes care of preventing dirty diffs.
6729 ## But, on edits, we dirty-diff the invalid attribute text.
6730 !! test
6731 Invalid text in table attributes should be discarded
6732 !! options
6733 parsoid=wt2html
6734 !! wikitext
6735 {| <span>boo</span> style='border:1px solid black'
6736 | <span>boo</span> style='color:blue' | 1
6737 |<span>boo</span> style='color:blue'| 2
6738 |}
6739 !! html/php
6740 <table style="border:1px solid black">
6741 <tr>
6742 <td style="color:blue"> 1
6743 </td>
6744 <td style="color:blue"> 2
6745 </td></tr></table>
6746
6747 !! html/parsoid
6748 <table style="border:1px solid black">
6749 <tr>
6750 <td style="color:blue"> 1</td>
6751 <td style="color:blue"> 2</td>
6752 </tr>
6753 </table>
6754 !! end
6755
6756 !! test
6757 Invalid text in table attributes should be preserved by selective serializer
6758 !! options
6759 parsoid={
6760 "modes": ["selser"],
6761 "changes": [
6762 ["td:first-child", "text", "abc"],
6763 ["td + td", "text", "xyz"]
6764 ]
6765 }
6766 !! wikitext
6767 {| <span>boo</span> style='border:1px solid black'
6768 | <span>boo</span> style='color:blue' | 1
6769 |<span>boo</span> style='color:blue'| 2
6770 |}
6771 !! wikitext/edited
6772 {| <span>boo</span> style='border:1px solid black'
6773 | <span>boo</span> style='color:blue' |abc
6774 |<span>boo</span> style='color:blue'|xyz
6775 |}
6776 !! end
6777
6778 !! test
6779 1. Template-generated table cell attributes and cell content
6780 !! wikitext
6781 {|
6782 |{{table_attribs}}
6783 | {{table_attribs}}
6784 || {{table_attribs_5}}
6785 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
6786 |align=center {{table_attribs}}
6787 | <!--foo--> align=center <!--bar--> {{table_attribs}}
6788 |}
6789 !! html
6790 <table>
6791 <tr>
6792 <td style="color:red;">Foo
6793 </td>
6794 <td style="color:red;">Foo
6795 </td>
6796 <td> style="color:red;"</td>
6797 <td>Bar
6798 </td>
6799 <td style="color:red;">Foo
6800 </td>
6801 <td align="center" style="color:red;">Foo
6802 </td>
6803 <td align="center" style="color:red;">Foo
6804 </td></tr></table>
6805
6806 !! end
6807
6808 !! test
6809 2. Template-generated table cell attributes and cell content
6810 !! wikitext
6811 {|
6812 |{{table_attribs_2}}
6813 |}
6814 !! html/php
6815 <table>
6816 <tr>
6817 <td style="color:red;">Foo
6818 </td>
6819 <td>Bar</td>
6820 <td>Baz
6821 </td></tr></table>
6822
6823 !! html/parsoid
6824 <table>
6825 <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>
6826 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
6827 </tbody></table>
6828 !! end
6829
6830 !! test
6831 3. Template-generated table cell attributes and cell content
6832 !! wikitext
6833 {|
6834 !align=center {{table_header_cells}}
6835 |-
6836 |align=center {{table_cells}}
6837 |}
6838 !! html/php
6839 <table>
6840 <tr>
6841 <th align="center" style="color:red;">Foo</th>
6842 <th style="color:red;"><i>Bar</i></th>
6843 <th style="color:brown;"><i>Foo</i> and Baz
6844 </th></tr>
6845 <tr>
6846 <td align="center" style="color:red;">Foo</td>
6847 <td style="color:red;"><i>Bar</i></td>
6848 <td style="color:brown;"><i>Foo</i> and Baz
6849 </td></tr></table>
6850
6851 !! html/parsoid
6852 <table>
6853 <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>
6854 <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>
6855 </tbody></table>
6856 !! end
6857
6858 !! test
6859 4. Template-generated table cell attributes and cell content inside a templated table
6860 !! wikitext
6861 {{tbl-start}}
6862 !align=center {{table_header_cells}}
6863 |-
6864 |align=center {{table_cells}}
6865 {{tbl-end}}
6866 !! html/php
6867 <table>
6868 <tr>
6869 <th align="center" style="color:red;">Foo</th>
6870 <th style="color:red;"><i>Bar</i></th>
6871 <th style="color:brown;"><i>Foo</i> and Baz
6872 </th></tr>
6873 <tr>
6874 <td align="center" style="color:red;">Foo</td>
6875 <td style="color:red;"><i>Bar</i></td>
6876 <td style="color:brown;"><i>Foo</i> and Baz
6877 </td></tr></table>
6878
6879 !! html/parsoid
6880 <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}}]}'>
6881 <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>
6882 <tr>
6883 <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>
6884 </tbody></table>
6885 !! end
6886
6887 ## Edge case fix to prevent future regressions
6888 !! test
6889 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
6890 !! wikitext
6891 {|
6892 |{{table_attribs_7}}
6893 |}
6894 <references />
6895 !! html/parsoid
6896 <table>
6897 <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>
6898 </tbody></table>
6899 <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>
6900 !! end
6901
6902 !! test
6903 Table with row followed by newlines and table heading
6904 !! options
6905 parsoid=wt2html,html2html
6906 !! wikitext
6907 {|
6908 |-
6909
6910 ! foo
6911 |}
6912 !! html/*
6913 <table>
6914
6915
6916 <tr>
6917 <th> foo
6918 </th></tr></table>
6919
6920 !! end
6921
6922 !! test
6923 Table with empty line following the start tag
6924 !! options
6925 parsoid=wt2html,html2html
6926 !! wikitext
6927 {|
6928
6929 |-
6930 | foo
6931 |}
6932 !! html/*
6933 <table>
6934
6935
6936 <tr>
6937 <td> foo
6938 </td></tr></table>
6939
6940 !! end
6941
6942 !! test
6943 Table attributes with empty value
6944 !! options
6945 parsoid=wt2html,html2html
6946 !! wikitext
6947 {|
6948 | style=| hello
6949 |}
6950 !! html/php
6951 <table>
6952 <tr>
6953 <td style=""> hello
6954 </td></tr></table>
6955
6956 !! html/parsoid
6957 <table>
6958 <tbody><tr><td style=""> hello</td></tr>
6959 </tbody></table>
6960 !! end
6961
6962 !! test
6963 Wikitext table with a lot of comments
6964 !! wikitext
6965 {|
6966 <!-- c0 -->
6967 | foo
6968 <!-- c1 -->
6969 |-<!-- c2 -->
6970 <!-- c3 -->
6971 |<!-- c4 -->
6972 <!-- c5 -->
6973 |}
6974 !! html
6975 <table>
6976 <tr>
6977 <td> foo
6978 </td></tr>
6979 <tr>
6980 <td>
6981 </td></tr></table>
6982
6983 !! end
6984
6985 !! test
6986 Wikitext table comments represented in parsoid dom
6987 !! wikitext
6988 {|<!--c1--><!--c2-->
6989 |-<!--c3-->
6990 | x
6991 |}
6992 !! html/php+tidy
6993 <table>
6994 <tr>
6995 <td>x</td>
6996 </tr>
6997 </table>
6998 !! html/parsoid
6999 <table><!--c1--><!--c2-->
7000 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
7001 <td data-parsoid='{"autoInsertedEnd":true}'> x</td></tr>
7002 </tbody></table>
7003 !! end
7004
7005 !! test
7006 Wikitext table with double-line table cell
7007 !! wikitext
7008 {|
7009 |a
7010 b
7011 |}
7012 !! html
7013 <table>
7014 <tr>
7015 <td>a
7016 <p>b
7017 </p>
7018 </td></tr></table>
7019
7020 !! end
7021
7022 !! test
7023 Table cell with a single comment
7024 !! wikitext
7025 {|
7026 | <!-- c1 -->
7027 | a
7028 |}
7029 !! html
7030 <table>
7031 <tr>
7032 <td>
7033 </td>
7034 <td> a
7035 </td></tr></table>
7036
7037 !! end
7038
7039 !! test
7040 Table-cell after a comment-only-empty-line
7041 !! wikitext
7042 {|
7043 |a
7044 <!--c1-->
7045 <!--c2-->| b
7046 |}
7047 !! html
7048 <table>
7049 <tr>
7050 <td>a
7051 </td>
7052 <td> b
7053 </td></tr></table>
7054
7055 !! html/parsoid
7056 <table>
7057 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
7058 <!--c1-->
7059 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'> b</td></tr>
7060 </tbody></table>
7061
7062 !! end
7063
7064 !! test
7065 Build table with {{!}}
7066 !! wikitext
7067 {{{!}} class="wikitable"
7068 ! header
7069 ! second header
7070 {{!}}- style="color:red;"
7071 {{!}} data {{!}}{{!}} style="color:red;" {{!}} second data
7072 {{!}}}
7073 !! html
7074 <table class="wikitable">
7075 <tr>
7076 <th> header
7077 </th>
7078 <th> second header
7079 </th></tr>
7080 <tr style="color:red;">
7081 <td> data </td>
7082 <td style="color:red;"> second data
7083 </td></tr></table>
7084
7085 !! end
7086
7087 !! test
7088 Build table with pipe as data
7089 !! wikitext
7090 {| class="wikitable"
7091 ! header
7092 ! second header
7093 |- style="color:red;"
7094 | data || style="color:red;" | second data
7095 |-
7096 | style="color:red;" | data with | || style="color:red;" | second data with |
7097 |-
7098 || data with | ||| second data with |
7099 |}
7100 !! html
7101 <table class="wikitable">
7102 <tr>
7103 <th> header
7104 </th>
7105 <th> second header
7106 </th></tr>
7107 <tr style="color:red;">
7108 <td> data </td>
7109 <td style="color:red;"> second data
7110 </td></tr>
7111 <tr>
7112 <td style="color:red;"> data with | </td>
7113 <td style="color:red;"> second data with |
7114 </td></tr>
7115 <tr>
7116 <td> data with | </td>
7117 <td> second data with |
7118 </td></tr></table>
7119
7120 !! end
7121
7122 !! test
7123 Build table with wikilink
7124 !! wikitext
7125 {| class="wikitable"
7126 ! header || second header
7127 |- style="color:red;"
7128 | data [[Main Page|linktext]] || second data [[Main Page|linktext]]
7129 |-
7130 | data || second data [[Main Page|link|text with pipe]]
7131 |}
7132 !! html
7133 <table class="wikitable">
7134 <tr>
7135 <th> header </th>
7136 <th> second header
7137 </th></tr>
7138 <tr style="color:red;">
7139 <td> data <a href="/wiki/Main_Page" title="Main Page">linktext</a> </td>
7140 <td> second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
7141 </td></tr>
7142 <tr>
7143 <td> data </td>
7144 <td> second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
7145 </td></tr></table>
7146
7147 !! end
7148
7149 # The expected HTML structure in this test is debatable. The PHP parser does
7150 # not parse this kind of table at all. The main focus for Parsoid is on
7151 # round-tripping, so this output is ok for now. TODO: revisit!
7152 !! test
7153 Wikitext table with html-syntax row
7154 !! wikitext
7155 {|
7156 |-
7157 <td>foo</td>
7158 |}
7159 !! html/parsoid
7160 <table>
7161 <tbody>
7162 <tr>
7163 <td>foo</td></tr></tbody></table>
7164 !! end
7165
7166 !! test
7167 Implicit <td> after a |-
7168 !! options
7169 parsoid=wt2html,html2html
7170 !! wikitext
7171 {|
7172 |-
7173 a
7174 |}
7175 !! html/php
7176 <table>
7177
7178 a
7179 </table>
7180
7181 !! html/php+tidy
7182 <p>a</p>
7183 !! html/parsoid
7184 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>a</p><table>
7185 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7186
7187 </tr></tbody></table>
7188 !! end
7189
7190 !! test
7191 Lists should be recognized in an implicit <td> context
7192 !! options
7193 parsoid=wt2html,html2html
7194 !! wikitext
7195 {|
7196 |-
7197 *a
7198 |}
7199 !! html/php
7200 <table>
7201
7202 <ul><li>a</li></ul>
7203 </table>
7204
7205 !! html/php+tidy
7206 <ul>
7207 <li>a</li>
7208 </ul>
7209 !! html/parsoid
7210 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7211 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7212
7213 </tr></tbody></table>
7214 !! end
7215
7216 !! test
7217 Table cells not properly parsed in an implicit-td context
7218 !! wikitext
7219 {|
7220 |-
7221 {{table_attribs_4}} || a || b
7222 |}
7223 !! html/php+tidy
7224 <table>
7225 <tr>
7226 <td style="background-color:#DC241f;" width="10px"></td>
7227 <td>a</td>
7228 <td>b</td>
7229 </tr>
7230 </table>
7231 !! html/parsoid
7232 <table>
7233 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7234 <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>
7235 !! end
7236
7237 !! test
7238 Parsoid: Round-trip tables directly followed by content (T53219)
7239 !! options
7240 parsoid=wt2html,wt2wt
7241 !! wikitext
7242 {|
7243 |foo
7244 |} bar
7245
7246 {|
7247 |baz
7248 |}<b>quux</b>
7249 !! html+tidy
7250 <table>
7251 <tr>
7252 <td>foo</td>
7253 </tr>
7254 </table>
7255 <p>bar</p>
7256 <table>
7257 <tr>
7258 <td>baz</td>
7259 </tr>
7260 </table>
7261 <p><b>quux</b></p>
7262 !! end
7263
7264 !! test
7265 Parsoid: Default to a newline after tables in new content (T53219)
7266 !! options
7267 parsoid=html2wt
7268 !! html/parsoid
7269 <table><tbody>
7270 <tr><td>foo</td></tr></tbody></table> bar
7271 <table><tbody>
7272 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7273 !! wikitext
7274 {|
7275 |foo
7276 |}
7277 <nowiki> </nowiki>bar
7278 {|
7279 |baz
7280 |}
7281 '''quux'''
7282 !! end
7283
7284 !! test
7285 Parsoid: newline inducing block nodes don't suppress <nowiki>
7286 !! options
7287 parsoid=html2wt
7288 !! html/parsoid
7289 a<h1>foo</h1>
7290 !! wikitext
7291 <nowiki> </nowiki>a
7292
7293 = foo =
7294 !! end
7295
7296 !! test
7297 Parsoid: Row-syntax table headings followed by comment & table cells
7298 !! options
7299 parsoid=wt2html,wt2wt
7300 !! wikitext
7301 {|
7302 ! foo || bar
7303 <!-- foo --> || baz || quux
7304 |}
7305 !! html/php
7306 <table>
7307 <tr>
7308 <th> foo </th>
7309 <th> bar
7310 </th>
7311 <td> baz </td>
7312 <td> quux
7313 </td></tr></table>
7314
7315 !! html/parsoid
7316 <table>
7317 <tbody><tr><th> foo </th><th> bar
7318 <!-- foo --> </th><td> baz </td><td> quux</td></tr>
7319 </tbody></table>
7320 !! end
7321
7322 !!test
7323 Parsoid: Recover better from broken table attributes
7324 !!options
7325 parsoid=wt2html
7326 !!wikitext
7327 {| class="foo
7328 | class="bar" |
7329 foo
7330 |}
7331 !!html/php+tidy
7332 <table class="foo">
7333 <tr>
7334 <td class="bar">
7335 <p>foo</p>
7336 </td>
7337 </tr>
7338 </table>
7339 !!html/parsoid
7340 <table class="foo">
7341 <tr>
7342 <td class="bar">
7343 <p>foo</p></td></tr>
7344 </tbody></table>
7345 !!end
7346
7347 !! test
7348 Tables: Digest broken attributes on table and tr tag
7349 !! options
7350 parsoid=wt2html
7351 !! wikitext
7352 {| || |} ++
7353 |- || || ++ --
7354 |- > [
7355 |}
7356 !! html
7357 <table>
7358 <tbody>
7359 <tr class='mw-empty-elt'></tr>
7360 <tr class='mw-empty-elt'></tr>
7361 </tbody></table>
7362 !! end
7363
7364 # T137406: Whitespace in the HTML
7365 !! test
7366 1. Generate correct wikitext for tables with thead/tbody/tfoot
7367 !! options
7368 parsoid=html2wt
7369 !! html/parsoid
7370 <table>
7371 <caption>Test</caption>
7372 <thead>
7373 <tr>
7374 <th>Month</th>
7375 <th>Savings</th>
7376 </tr>
7377 </thead>
7378 <tbody>
7379 <tr>
7380 <td>January</td>
7381 <td>$100</td>
7382 </tr>
7383 <tr>
7384 <td>February</td>
7385 <td>$80</td>
7386 </tr>
7387 </tbody>
7388 <tfoot>
7389 <tr>
7390 <td>Sum</td>
7391 <td>$180</td>
7392 </tr>
7393 </tfoot>
7394 </table>
7395 !! wikitext
7396 {|
7397 |+Test
7398 !Month
7399 !Savings
7400 |-
7401 |January
7402 |$100
7403 |-
7404 |February
7405 |$80
7406 |-
7407 |Sum
7408 |$180
7409 |}
7410 !! html/php+tidy
7411 <table>
7412 <caption>Test</caption>
7413 <tr>
7414 <th>Month</th>
7415 <th>Savings</th>
7416 </tr>
7417 <tr>
7418 <td>January</td>
7419 <td>$100</td>
7420 </tr>
7421 <tr>
7422 <td>February</td>
7423 <td>$80</td>
7424 </tr>
7425 <tr>
7426 <td>Sum</td>
7427 <td>$180</td>
7428 </tr>
7429 </table>
7430 !! end
7431
7432 # T137406: No whitespace in the HTML
7433 !! test
7434 2. Generate correct wikitext for tables with thead/tbody/tfoot
7435 !! options
7436 parsoid=html2wt
7437 !! html/parsoid
7438 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7439 !! wikitext
7440 {|
7441 !heading
7442 |-
7443 |foo
7444 |}
7445 !! end
7446
7447 !! test
7448 Testing serialization after deletion in references
7449 !! options
7450 parsoid={
7451 "modes": ["wt2wt"],
7452 "changes": [
7453 ["#x", "remove"]
7454 ]
7455 }
7456 !! wikitext
7457 hi <ref><div id="x">ho</div></ref>
7458
7459 <references />
7460 !! wikitext/edited
7461 hi <ref></ref>
7462
7463 <references />
7464 !! end
7465
7466 !!test
7467 Testing serialization after deletion of table cells
7468 !!options
7469 parsoid={
7470 "modes": ["wt2wt", "selser"],
7471 "changes": [
7472 ["#x", "remove"]
7473 ]
7474 }
7475 !!wikitext
7476 {|
7477 !h1 !!h2 !!h3
7478 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
7479 |}
7480 !! wikitext/edited
7481 {|
7482 !h1 !!h2 !!h3
7483 |c2 |||c3
7484 |}
7485 !!end
7486
7487 !! test
7488 Testing selser after addition of new row before first row (T125419)
7489 !! options
7490 parsoid={
7491 "modes": ["wt2wt", "selser"],
7492 "changes": [
7493 [ "tr", "before", "<tr><td>X</td></tr>" ]
7494 ]
7495 }
7496 !! wikitext
7497 {|
7498 |a
7499 |}
7500 !! wikitext/edited
7501 {|
7502 |X
7503 |-
7504 |a
7505 |}
7506 !! end
7507
7508 !! test
7509 Serialize new table rows in a HTML table using HTML tags
7510 !! options
7511 parsoid={
7512 "modes": ["wt2wt", "selser"],
7513 "changes": [
7514 [ "tr", "before", "<tr><td>X</td></tr>" ]
7515 ]
7516 }
7517 !! wikitext
7518 <table><tr><td>a</td></tr></table>
7519 !! wikitext/edited
7520 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
7521 !! end
7522
7523 !! test
7524 Serialize new table cells in a HTML row using HTML tags
7525 !! options
7526 parsoid={
7527 "modes": ["wt2wt", "selser"],
7528 "changes": [
7529 [ "td", "before", "<td>X</td>" ]
7530 ]
7531 }
7532 !! wikitext
7533 <table><tr><td>a</td></tr></table>
7534 !! wikitext/edited
7535 <table><tr><td>X</td><td>a</td></tr></table>
7536 !! end
7537
7538 !! test
7539 Wikitext tables can be nested inside HTML tables
7540 !! options
7541 parsoid=html2wt
7542 !! html
7543 <table data-parsoid='{"stx":"html"}'>
7544 <tr><td>
7545 <table>
7546 <tr><td>foo</td></tr>
7547 </table>
7548 </td></tr>
7549 </table>
7550 !! wikitext
7551 <table>
7552 <tr><td>
7553 {|
7554 |foo
7555 |}
7556 </td></tr>
7557 </table>
7558 !! end
7559
7560 !! test
7561 Serialize wikitext list items as HTML list items when embedded in a HTML list
7562 !! options
7563 parsoid=html2wt
7564 !! html
7565 <ul data-parsoid='{"stx": "html"}'>
7566 <li data-parsoid='{}'>a</li>
7567 <li>b</li>
7568 </ul>
7569 !! wikitext
7570 <ul>
7571 <li>a</li>
7572 <li>b</li>
7573 </ul>
7574 !! end
7575
7576 # SSS FIXME: Is this actually a good thing given the
7577 # odd nested list output that is generated by MW?
7578 # <ul><li>foo<ul>..</ul></li></ul> instead of
7579 # <ul><li>foo</li><ul>..</ul></ul>
7580 !! test
7581 Wikitext lists can be nested inside HTML lists
7582 !! options
7583 parsoid=html2wt
7584 !! html
7585 <ul data-parsoid='{"stx": "html"}'>
7586 <li data-parsoid='{"stx": "html"}'>a
7587 <ul><li>b</li></ul>
7588 </li>
7589 </ul>
7590
7591 <ul data-parsoid='{"stx": "html"}'>
7592 <li>x
7593 <ul><li>y</li></ul>
7594 </li>
7595 </ul>
7596 !! wikitext
7597 <ul>
7598 <li>a
7599 * b
7600 </li>
7601 </ul>
7602
7603 <ul>
7604 <li>x
7605 * y
7606 </li>
7607 </ul>
7608 !! end
7609
7610 ###
7611 ### Internal links
7612 ###
7613 !! test
7614 Plain link, capitalized
7615 !! wikitext
7616 [[Main Page]]
7617 !! html
7618 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7619 </p>
7620 !! end
7621
7622 !! test
7623 Plain link, uncapitalized
7624 !! wikitext
7625 [[main Page]]
7626 !! html
7627 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7628 </p>
7629 !! end
7630
7631 !! test
7632 Piped link
7633 !! wikitext
7634 [[Main Page|The Main Page]]
7635 !! html
7636 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7637 </p>
7638 !! end
7639
7640 !! test
7641 Piped link with comment in link text
7642 !! wikitext
7643 [[Main Page|The Main<!--front--> Page]]
7644 !! html
7645 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7646 </p>
7647 !! end
7648
7649 !! test
7650 Piped link with multiple pipe characters in link text
7651 !! wikitext
7652 [[Main Page||The|Main|Page|]]
7653 !! html/php
7654 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7655 </p>
7656 !! html/parsoid
7657 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7658 !! end
7659
7660 !! test
7661 Piped link with no link text
7662 !! wikitext
7663 [[Thomas Bek (bishop of St David's)|]]
7664 !! html/php
7665 <p>[[Thomas Bek (bishop of St David's)|]]
7666 </p>
7667 !! html/parsoid
7668 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7669 !! end
7670
7671 !! test
7672 Piped link with empty link text
7673 !! wikitext
7674 [[Main Page|<nowiki/>]] - empty nowiki
7675 [[Main Page| ]] - empty space
7676 [[Main Page|&nbsp;]] - empty non breaking space
7677 !! html/php
7678 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7679 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7680 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7681 </p>
7682 !! html/parsoid
7683 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7684 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7685 <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>
7686 !! end
7687
7688 !! test
7689 Broken link
7690 !! wikitext
7691 [[Zigzagzogzagzig]]
7692 !! html
7693 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7694 </p>
7695 !! end
7696
7697 !! test
7698 Broken link with fragment
7699 !! wikitext
7700 [[Zigzagzogzagzig#zug]]
7701 !! html
7702 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7703 </p>
7704 !! end
7705
7706 !! test
7707 Special page link with fragment
7708 !! wikitext
7709 [[Special:Version#anchor]]
7710 !! html
7711 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7712 </p>
7713 !! end
7714
7715 !! test
7716 Nonexistent special page link with fragment
7717 !! wikitext
7718 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7719 !! html
7720 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7721 </p>
7722 !! end
7723
7724 !! test
7725 Link with prefix
7726 !! wikitext
7727 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7728 !! html
7729 <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>
7730 </p>
7731 !! end
7732
7733 !! test
7734 Link with suffix
7735 !! wikitext
7736 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7737 !! html
7738 <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>!!!
7739 </p>
7740 !! end
7741
7742 !! article
7743 prefixed article
7744 !! text
7745 Some text
7746 !! endarticle
7747
7748 !! test
7749 T45661: Piped links with identical prefixes
7750 !! wikitext
7751 [[prefixed article|prefixed articles with spaces]]
7752
7753 [[prefixed article|prefixed articlesaoeu]]
7754
7755 [[Main Page|Main Page test]]
7756 !! html
7757 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7758 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7759 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7760 </p>
7761 !! end
7762
7763
7764 !! test
7765 Link with HTML entity in suffix / tail
7766 !! wikitext
7767 [[Main Page]]&quot;, [[Main Page]]&#97;
7768 !! html/php
7769 <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;
7770 </p>
7771 !! html/parsoid
7772 <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>
7773 !! end
7774
7775 !! test
7776 Link with 3 brackets
7777 !! wikitext
7778 [[[Main Page]]]
7779 Foo [[[Main Page]]]
7780 !! html
7781 <p>[[[Main Page]]]
7782 Foo [[[Main Page]]]
7783 </p>
7784 !! end
7785
7786 !! test
7787 Link with 4 brackets
7788 !! wikitext
7789 [[[[Main Page]]]]
7790 !! html
7791 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7792 </p>
7793 !! end
7794
7795 !! test
7796 Piped link with 3 brackets
7797 !! wikitext
7798 [[[main page|the main page]]]
7799 !! html
7800 <p>[[[main page|the main page]]]
7801 </p>
7802 !! end
7803
7804 !! test
7805 Piped link with extlink-like text
7806 !! wikitext
7807 [[Main Page|[bar]]]
7808 [[Main Page|This is a [bar]]]
7809 [[Main Page|[bar]]
7810 !! html/php
7811 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7812 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7813 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7814 </p>
7815 !! html/parsoid
7816 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7817 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7818 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7819 !! end
7820
7821 !! test
7822 Link with multiple pipes
7823 !! wikitext
7824 [[Main Page|The|Main|Page]]
7825 !! html
7826 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7827 </p>
7828 !! end
7829
7830 !! test
7831 Anchor containing a #. (T65430)
7832 !! config
7833 wgFragmentMode=[ 'html5', 'legacy' ]
7834 !! wikitext
7835 [[Main Page#And#Link]]
7836 !! html/php
7837 <p><a href="/wiki/Main_Page#And#Link" title="Main Page">Main Page#And#Link</a>
7838 </p>
7839 !! html/parsoid
7840 <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>
7841 !! end
7842
7843 !! test
7844 Link to namespaces
7845 !! wikitext
7846 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7847 !! html
7848 <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>
7849 </p>
7850 !! end
7851
7852 !! test
7853 Link with space in namespace
7854 !! wikitext
7855 [[User talk:Foo bar]]
7856 !! html
7857 <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>
7858 </p>
7859 !! end
7860
7861 !! article
7862 MemoryAlpha:AlphaTest
7863 !! text
7864 This is an article in the MemoryAlpha namespace
7865 (which shadows the memoryalpha interwiki link).
7866 !! endarticle
7867
7868 !! test
7869 Namespace takes precedence over interwiki link (T53680)
7870 !! wikitext
7871 [[MemoryAlpha:AlphaTest]]
7872 !! html
7873 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7874 </p>
7875 !! end
7876
7877 # The previous test doesn't work correctly in html2*, due to not recognizing the
7878 # link as an internal one. This one checks for the correct behavior.
7879 !! test
7880 Link to namespace preferred over interwiki with correct rel attribute
7881 !! options
7882 parsoid=html2wt,html2html
7883 !! html/parsoid
7884 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7885 !! wikitext
7886 [[MemoryAlpha:AlphaTest]]
7887 !! end
7888
7889 !! test
7890 Piped link to namespace
7891 !! wikitext
7892 [[Meta:Disclaimers|The disclaimers]]
7893 !! html
7894 <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>
7895 </p>
7896 !! end
7897
7898 !! test
7899 Link containing }
7900 !! wikitext
7901 [[Usually caused by a typo (oops}]]
7902 !! html
7903 <p>[[Usually caused by a typo (oops}]]
7904 </p>
7905 !! end
7906
7907 !! article
7908 7% Solution
7909 !! text
7910 Just a test of an article title containing a percent.
7911 !! endarticle
7912
7913 !! test
7914 Link containing % (not as a hex sequence)
7915 !! wikitext
7916 [[7% Solution]]
7917 [[7% Solution|7%25 Solution]]
7918 !! html/php
7919 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7920 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7921 </p>
7922 !! html/parsoid
7923 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7924 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7925 !! end
7926
7927 # note that the parsoid HTML is identical to the previous test output,
7928 # so the previous test ensures that the html2wt mode will generate the
7929 # "not as a hex sequence" wikitext.
7930 !! test
7931 Link containing % as a single hex sequence interpreted to char
7932 !! options
7933 parsoid=wt2wt,wt2html,html2html
7934 !! wikitext
7935 [[7%25 Solution]]
7936 [[7%25 Solution|7%25 Solution]]
7937 !! html/php
7938 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7939 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7940 </p>
7941 !! html/parsoid
7942 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7943 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7944 !!end
7945
7946 !! test
7947 Link containing % as a double hex sequence interpreted to hex sequence
7948 !! wikitext
7949 [[7%2525 Solution]]
7950 !! html
7951 <p>[[7%2525 Solution]]
7952 </p>
7953 !!end
7954
7955 ## Example for such a section: == < ==
7956 !! test
7957 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
7958 !! config
7959 wgFragmentMode=[ 'html5', 'legacy' ]
7960 !! wikitext
7961 [[%23%3c]][[%23%3e]]
7962 !! html/php
7963 <p><a href="#&lt;">#&lt;</a><a href="#&gt;">#&gt;</a>
7964 </p>
7965 !! html/parsoid
7966 <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>
7967 !! end
7968
7969 ## Example for such a section: == < ==
7970 !! test
7971 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors (legacy)
7972 !! config
7973 wgFragmentMode=[ 'legacy' ]
7974 !! wikitext
7975 [[%23%3c]][[%23%3e]]
7976 !! html/php
7977 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
7978 </p>
7979 !! end
7980
7981 !! test
7982 Link containing "<#" and ">#" as a hex sequences
7983 !! wikitext
7984 [[%3c%23]][[%3e%23]]
7985 !! html
7986 <p>[[%3c%23]][[%3e%23]]
7987 </p>
7988 !! end
7989
7990 !! test
7991 Link containing an equals sign
7992 !! wikitext
7993 [[Special:BookSources/isbn=4-00-026157-6]]
7994 !! html/php
7995 <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>
7996 </p>
7997 !! html/parsoid
7998 <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>
7999 !! end
8000
8001 !! article
8002 Foo~bar
8003 !! text
8004 Just a test of an article title containing a tilde.
8005 !! endarticle
8006
8007 # note that links containing signatures, like [[Foo~~~~]], are
8008 # massaged by the pre-save transform (PST) and so the tildes are never
8009 # seen by the parser.
8010 !! test
8011 Link containing a tilde
8012 !! wikitext
8013 [[Foo~bar]]
8014 !! html/php
8015 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
8016 </p>
8017 !! html/parsoid
8018 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
8019 !! end
8020
8021 !! test
8022 Link containing double-single-quotes '' (T6598)
8023 !! wikitext
8024 [[Lista d''e paise d''o munno]]
8025 !! html/php
8026 <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>
8027 </p>
8028 !! html/parsoid
8029 <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>
8030 !! end
8031
8032 !! test
8033 Link containing double quotes and spaces
8034 !! wikitext
8035 [[Cool "Gator"]]
8036 !! html/php
8037 <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>
8038 </p>
8039 !! html/parsoid
8040 <p><a rel="mw:WikiLink" href='./Cool_"Gator"' title='Cool "Gator"'>Cool "Gator"</a></p>
8041 !! end
8042
8043 !! test
8044 File containing double quotes and spaces
8045 !! wikitext
8046 [[File:Cool "Gator".png]]
8047 !! html/parsoid
8048 <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>
8049 !! end
8050
8051 !! test
8052 Redirect containing double quotes and spaces
8053 !! wikitext
8054 #REDIRECT [[Cool "Gator"]]
8055 !! html/parsoid
8056 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
8057 !! end
8058
8059 !! test
8060 Link containing double-single-quotes '' in text (T6598 sanity check)
8061 !! wikitext
8062 Some [[Link|pretty ''italics'' and stuff]]!
8063 !! html/php
8064 <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>!
8065 </p>
8066 !! html/parsoid
8067 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
8068 !! end
8069
8070 !! test
8071 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
8072 !! wikitext
8073 ''Some [[Link|pretty ''italics'' and stuff]]!''
8074 !! html
8075 <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>
8076 </p>
8077 !! end
8078
8079 !! test
8080 Link with double quotes in title part (literal) and alternate part (interpreted)
8081 !! wikitext
8082 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
8083
8084 [[''Pentecoste'']]
8085
8086 [[''Pentecoste''|Pentecoste]]
8087
8088 [[''Pentecoste''|''Pentecoste'']]
8089 !! html/php
8090 <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>
8091 </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>
8092 </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>
8093 </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>
8094 </p>
8095 !! html/parsoid
8096 <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>
8097 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
8098 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
8099 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
8100 !! end
8101
8102 !! test
8103 Broken image links with HTML captions (T41700)
8104 !! wikitext
8105 [[File:Nonexistent|<script></script>]]
8106 [[File:Nonexistent|100x100px|<script></script>]]
8107 [[File:Nonexistent|&lt;]]
8108 [[File:Nonexistent|a<i>b</i>c]]
8109 !! html/php
8110 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8111 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8112 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8113 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8114 </p>
8115 !! html/parsoid
8116 <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>
8117 <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>
8118 <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>
8119 <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>
8120 !! end
8121
8122 !! test
8123 Plain link to URL
8124 !! wikitext
8125 [[http://www.example.com]]
8126 !! html/php
8127 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8128 </p>
8129 !! html/parsoid
8130 <p>[<a rel="mw:ExtLink" href="http://www.example.com"></a>]</p>
8131 !! end
8132
8133 !! test
8134 Plain link to URL with link text
8135 !! wikitext
8136 [[http://www.example.com Link text]]
8137 !! html
8138 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8139 </p>
8140 !! end
8141
8142 !! test
8143 Plain link to protocol-relative URL
8144 !! wikitext
8145 [[//www.example.com]]
8146 !! html/php
8147 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8148 </p>
8149 !! html/parsoid
8150 <p>[<a rel="mw:ExtLink" href="//www.example.com"></a>]</p>
8151 !! end
8152
8153 !! test
8154 Plain link to protocol-relative URL with link text
8155 !! wikitext
8156 [[//www.example.com Link text]]
8157 !! html
8158 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8159 </p>
8160 !! end
8161
8162 !! test
8163 Plain link to page with question mark in title
8164 !! wikitext
8165 [[A?b]]
8166
8167 [[A?b|Baz]]
8168 !! html
8169 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8170 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8171 </p>
8172 !! end
8173
8174 # I'm fairly sure the expected result here is wrong.
8175 # We want these to be URL links, not pseudo-pages with URLs for titles....
8176 # However the current output is also pretty screwy.
8177 #
8178 # ----
8179 # I'm changing it to match the current output--it arguably makes more
8180 # sense in the light of the test above. Old expected result was:
8181 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8182 #</p>
8183 # But I think this test is bordering on "garbage in, garbage out" anyway.
8184 # -- wtm
8185 !! test
8186 Piped link to URL
8187 !! wikitext
8188 Piped link to URL: [[http://www.example.com|an example URL]]
8189 !! html/php
8190 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8191 </p>
8192 !! html/parsoid
8193 <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>
8194 !! end
8195
8196 !! test
8197 Plain link in template argument
8198 !! options
8199 parsoid=wt2html
8200 !! wikitext
8201 {{echo|[http://www.example.com |123]}}
8202
8203 {{echo|[[http://www.example.com |123]]}}
8204
8205 {{echo|[[http://www.example.com |123]}}
8206
8207 {{echo|[http://www.example.com |123]]}}
8208 !! html/php
8209 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8210 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8211 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8212 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8213 </p>
8214 !! html/parsoid
8215 <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>
8216
8217 <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>
8218
8219 <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>
8220
8221 <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>
8222 !! end
8223
8224 !! test
8225 T2002: [[page|http://url/]] should link to page, not http://url/
8226 !! wikitext
8227 [[Main Page|http://url/]]
8228 !! html/php
8229 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8230 </p>
8231 !! html/parsoid
8232 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8233 !! end
8234
8235 # Parsoid does not mark self-links, by design.
8236 !! test
8237 T2337: Escaped self-links should be bold
8238 !! options
8239 title=[[Bug462]]
8240 !! wikitext
8241 [[Bu&#103;462]] [[Bug462]]
8242 !! html/php
8243 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8244 </p>
8245 !! html/php+tidy
8246 <p><a class="mw-selflink selflink">Bug462</a> <a class="mw-selflink selflink">Bug462</a></p>
8247 !! html/parsoid
8248 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8249 !! end
8250
8251 !! test
8252 Self-link to section should not be bold
8253 !! options
8254 title=[[Main Page]]
8255 !! wikitext
8256 [[Main Page#section]]
8257 !! html
8258 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8259 </p>
8260 !! end
8261
8262 !! article
8263 00
8264 !! text
8265 This is 00.
8266 !! endarticle
8267
8268 !!test
8269 Self-link to numeric title
8270 !!options
8271 title=[[0]]
8272 !! wikitext
8273 [[0]]
8274 !! html
8275 <p><a class="mw-selflink selflink">0</a>
8276 </p>
8277 !!end
8278
8279 !!test
8280 Link to numeric-equivalent title
8281 !!options
8282 title=[[0]]
8283 !! wikitext
8284 [[00]]
8285 !! html
8286 <p><a href="/wiki/00" title="00">00</a>
8287 </p>
8288 !!end
8289
8290 !! test
8291 <nowiki> inside a link
8292 !! wikitext
8293 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8294 !! html
8295 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8296 </p>
8297 !! end
8298
8299 !! test
8300 Non-breaking spaces in title
8301 !! wikitext
8302 [[&nbsp; Main &nbsp; Page &nbsp;]]
8303 !! html
8304 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8305 </p>
8306 !!end
8307
8308 # Add new article for the test below so that it doesn't red-link
8309 !! article
8310 Foo bar baz
8311 !! text
8312 boo
8313 !! endarticle
8314
8315 !! test
8316 Multiple spaces in titles should normalize to a single underscore
8317 !! options
8318 parsoid=wt2html,wt2wt
8319 !! wikitext
8320 [[Foo bar baz|x]]
8321 [[Foo bar baz|x]]
8322 [[Foo bar baz|x]]
8323 !! html/php
8324 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8325 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8326 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8327 </p>
8328 !! html/parsoid
8329 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8330 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8331 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8332 </p>
8333 !! end
8334
8335 !! test
8336 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8337 !! options
8338 language=ca
8339 !! wikitext
8340 '''[[Main Page]]'''
8341 !! html
8342 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8343 </p>
8344 !! end
8345
8346 !! test
8347 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8348 !! options
8349 language=ca
8350 !! wikitext
8351 ''[[Main Page]]''
8352 !! html
8353 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8354 </p>
8355 !! end
8356
8357 !! test
8358 Internal link with en linktrail: no apostrophes (T29473)
8359 !! options
8360 language=en
8361 !! wikitext
8362 [[Something]]'nice
8363 !! html
8364 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8365 </p>
8366 !! end
8367
8368 !! test
8369 Internal link with ca linktrail with apostrophes (T29473)
8370 !! options
8371 language=ca
8372 !! wikitext
8373 [[Something]]'nice
8374 !! html
8375 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8376 </p>
8377 !! end
8378
8379 !! test
8380 Internal link with kaa linktrail with apostrophes (T29473)
8381 !! options
8382 language=kaa
8383 !! wikitext
8384 [[Something]]'nice
8385 !! html
8386 <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>
8387 </p>
8388 !! end
8389
8390 !! test
8391 Link with multiple ":" in a subpage-supporting namespace (T65636)
8392 !! wikitext
8393 [[User:Foo/Test/63636:Bar|Test]]
8394 !! html/php
8395 <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>
8396 </p>
8397 !! html/parsoid
8398 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8399 !! end
8400
8401 ## Mainly a sanity check for Parsoid
8402 !! test
8403 Handle title parsing for subpages
8404 !! options
8405 title=[[/123123]]
8406 subpage
8407 !! wikitext
8408 123
8409 !! html/php
8410 <p>123
8411 </p>
8412 !! html/parsoid
8413 <p>123</p>
8414 !! end
8415
8416 !! article
8417 User:Test/123
8418 !! text
8419 test 123
8420 !! endarticle
8421
8422 !! test
8423 Link to a subpage from a namespace other than main
8424 !! options
8425 title=[[User:Test]]
8426 subpage
8427 !! wikitext
8428 [[/123]]
8429 !! html/php
8430 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8431 </p>
8432 !! html/parsoid
8433 <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>
8434 !! end
8435
8436 !! test
8437 Ensure that transclusion titles are not url-decoded
8438 !! options
8439 subpage title=[[Test]]
8440 parsoid=wt2html
8441 !! wikitext
8442 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8443 !! html/php
8444 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8445 </p>
8446 !! html/parsoid
8447 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8448 !! end
8449
8450 !! test
8451 Purely hash wikilink
8452 !! options
8453 title=[[User:Test/123]]
8454 subpage
8455 !! wikitext
8456 [[#a|b]]
8457 !! html/php
8458 <p><a href="#a">b</a>
8459 </p>
8460 !! html/parsoid
8461 <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>
8462 !! end
8463
8464 !! test
8465 Serialization of purely hash wikilink
8466 !! options
8467 title=[[User:Test/123]]
8468 subpage
8469 parsoid=html2wt
8470 !! html/parsoid
8471 <p><a href="#a">[[</a></p>
8472 !! wikitext
8473 [[#a|<nowiki>[[</nowiki>]]
8474 !! html/php
8475 <p><a href="#a">[[</a>
8476 </p>
8477 !! end
8478
8479 !! test
8480 1. Interaction of linktrail and template encapsulation
8481 !! wikitext
8482 {{echo|[[Foo]]}}l
8483 !! html/parsoid
8484 <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>
8485 !! end
8486
8487 !! test
8488 2. Interaction of linktrail and template encapsulation
8489 !! options
8490 parsoid
8491 !! wikitext
8492 {{echo|Some [[Fool]]}}s
8493 !! html
8494 <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>
8495 !! end
8496
8497 !! test
8498 3. Interaction of linktrail and template encapsulation
8499 !! options
8500 parsoid
8501 !! wikitext
8502 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8503 !! html
8504 <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>
8505 !! end
8506
8507 !! article
8508 Söfnuður
8509 !! text
8510 Test.
8511 !! endarticle
8512
8513 !! test
8514 Internal link with is link prefix
8515 !! options
8516 language=is
8517 !! wikitext
8518 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8519 !! html
8520 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8521 </p>
8522 !! end
8523
8524 !! article
8525 Mótmælendatrú
8526 !! text
8527 Test.
8528 !! endarticle
8529
8530 !! test
8531 Internal link with is link trail and link prefix
8532 !! options
8533 language=is
8534 !! wikitext
8535 [[mótmælendatrú|xxx]]ar
8536 [[mótmælendatrú]]ar
8537 mótmælenda[[söfnuður]]
8538 mótmælenda[[söfnuður|söfnuðir]]
8539 mótmælenda[[söfnuður|söfnuðir]]xxx
8540 !! html
8541 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8542 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8543 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8544 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8545 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8546 </p>
8547 !! end
8548
8549 !! test
8550 Parsoid link trail escaping
8551 !! options
8552 parsoid=html2wt,html2html
8553 !! html/parsoid
8554 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8555 !! wikitext
8556 [[apple]]<nowiki/>s
8557 !! end
8558
8559 !! test
8560 Parsoid link prefix escaping
8561 !! options
8562 language=is
8563 parsoid=html2wt,html2html
8564 !! html/parsoid
8565 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8566 !! wikitext
8567 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8568 !! end
8569
8570 !! test
8571 Parsoid link bracket escaping
8572 !! options
8573 parsoid=html2wt,html2html
8574 !! html/parsoid
8575 <p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
8576 <p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
8577 <p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
8578 <p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
8579 <p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
8580 <p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
8581 !! wikitext
8582 [[Test]]
8583
8584 [<nowiki/>[[Test]]]
8585
8586 [[[[Test]]]]
8587
8588 [[[<nowiki/>[[Test]]]]]
8589
8590 [[[[[[Test]]]]]]
8591
8592 [[[[[<nowiki/>[[Test]]]]]]]
8593 !! end
8594
8595 !! test
8596 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8597 !! wikitext
8598 [[Foo| bar]]
8599
8600 [[Foo| ''bar'']]
8601
8602 [http://wp.org foo]
8603
8604 [http://wp.org ''foo'']
8605 !! html
8606 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8607 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8608 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8609 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8610 </p>
8611 !! end
8612
8613 !! test
8614 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8615 !! wikitext
8616 [[Foo|{{echo|a}} b {{echo|c}}]]
8617 !! html/parsoid
8618 <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>
8619 !! end
8620
8621 !! test
8622 Link with angle bracket after anchor
8623 !! config
8624 wgFragmentMode=[ 'html5', 'legacy' ]
8625 !! wikitext
8626 [[Foo#<bar>]]
8627 !! html/php
8628 <p><a href="/wiki/Foo#&lt;bar&gt;" title="Foo">Foo#&lt;bar&gt;</a>
8629 </p>
8630 !! html/parsoid
8631 <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>
8632 !! end
8633
8634 !! test
8635 Link with angle bracket after anchor (legacy)
8636 !! config
8637 wgFragmentMode=[ 'legacy' ]
8638 !! wikitext
8639 [[Foo#<bar>]]
8640 !! html/php
8641 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8642 </p>
8643 !! end
8644
8645 ###
8646 ### Interwiki links (see maintenance/interwiki.sql)
8647 ###
8648
8649 !! test
8650 Inline interwiki link
8651 !! options
8652 parsoid=wt2html,wt2wt,html2html
8653 !! wikitext
8654 [[MeatBall:SoftSecurity]]
8655 !! html/php
8656 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8657 </p>
8658 !! html/parsoid
8659 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8660 !! end
8661
8662 !! test
8663 Inline interwiki link with empty title (T4372)
8664 !! options
8665 parsoid=wt2html,wt2wt,html2html
8666 !! wikitext
8667 [[MeatBall:]]
8668 !! html/php
8669 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8670 </p>
8671 !! html/parsoid
8672 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8673 !! end
8674
8675 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8676 !! test
8677 Interwiki link encoding conversion (T3636)
8678 !! options
8679 parsoid=wt2html,wt2wt
8680 !! wikitext
8681 *[[Wikipedia:ro:Olteni&#0355;a]]
8682 *[[Wikipedia:ro:Olteni&#355;a]]
8683 !! html
8684 <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>
8685 <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>
8686
8687 !! html+tidy
8688 <ul>
8689 <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>
8690 <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>
8691 </ul>
8692 !! html/parsoid
8693 <ul>
8694 <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>
8695 <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>
8696 </ul>
8697 !! end
8698
8699 !! test
8700 Interwiki link with fragment (T4130)
8701 !! wikitext
8702 [[MeatBall:SoftSecurity#foo]]
8703 !! html
8704 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8705 </p>
8706 !! end
8707
8708 !! test
8709 Link scenarios with escaped fragments
8710 !! config
8711 wgFragmentMode=[ 'html5', 'legacy' ]
8712 !! wikitext
8713 [[#Is this great?]]
8714 [[Foo#Is this great?]]
8715 [[meatball:Foo#Is this great?]]
8716 !! html/php
8717 <p><a href="#Is_this_great?">#Is this great?</a>
8718 <a href="/wiki/Foo#Is_this_great?" title="Foo">Foo#Is this great?</a>
8719 <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>
8720 </p>
8721 !! html/parsoid
8722 <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>
8723 <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>
8724 <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>
8725 !! end
8726
8727 !! test
8728 Link scenarios with escaped fragments (legacy)
8729 !! config
8730 wgFragmentMode=[ 'legacy' ]
8731 !! wikitext
8732 [[#Is this great?]]
8733 [[Foo#Is this great?]]
8734 [[meatball:Foo#Is this great?]]
8735 !! html/php
8736 <p><a href="#Is_this_great.3F">#Is this great?</a>
8737 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8738 <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>
8739 </p>
8740 !! end
8741
8742 # Ideally the wikipedia: prefix here should be proto-relative too
8743 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8744 # define the 'en' prefix, and originally the test used 'wikipedia',
8745 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8746 # article.
8747 !! test
8748 Different interwiki prefixes mapping to the same URL
8749 !! wikitext
8750 [[:en:Foo]]
8751
8752 [[:en:Foo|Foo]]
8753
8754 [[wikipedia:Foo]]
8755
8756 [[:wikipedia:Foo|Foo]]
8757
8758 [[wikipedia:en:Foo]]
8759
8760 [[:wikipedia:en:Foo]]
8761
8762 [[ wikiPEdia :Foo]]
8763 !! html/parsoid
8764 <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>
8765
8766 <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>
8767
8768 <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>
8769
8770 <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>
8771
8772 <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>
8773
8774 <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>
8775
8776 <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>
8777 !! end
8778
8779 !! test
8780 Interwiki links that cannot be represented in wiki syntax
8781 !! wikitext
8782 [[meatball:ok]]
8783 [[meatball:ok#foo|ok with fragment]]
8784 [[meatball:ok_as_well?|ok ending with ? mark]]
8785 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8786 [http://de.wikipedia.org/wiki/#foo is just fragment]
8787
8788 !! html/php
8789 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8790 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8791 <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>
8792 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8793 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8794 </p>
8795 !! html/parsoid
8796 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8797 <a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8798 <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>
8799 <a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8800 <a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8801 !! end
8802
8803 !! test
8804 Interwiki links: trail
8805 !! wikitext
8806 [[wikipedia:Foo|Ba]]r
8807 !! html/php
8808 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8809 </p>
8810 !! html/parsoid
8811 <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>
8812 !! end
8813
8814 !! test
8815 Local interwiki link
8816 !! options
8817 parsoid=wt2html,wt2wt,html2html
8818 !! wikitext
8819 [[local:Template:Foo]]
8820 !! html/php
8821 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8822 </p>
8823 !! html/parsoid
8824 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8825 !! end
8826
8827 # Parsoid does not mark self-links, by design.
8828 !! test
8829 Local interwiki link: self-link to current page
8830 !! options
8831 title=[[Main Page]]
8832 parsoid=wt2html,wt2wt,html2html
8833 !! wikitext
8834 [[local:Main Page]]
8835 !! html/php
8836 <p><a class="mw-selflink selflink">local:Main Page</a>
8837 </p>
8838 !! html/parsoid
8839 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8840 !! end
8841
8842 !! test
8843 Local interwiki link: prefix only (T66167)
8844 !! options
8845 parsoid=wt2html,wt2wt,html2html
8846 !! wikitext
8847 [[local:]]
8848 !! html/php
8849 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8850 </p>
8851 !! html/parsoid
8852 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8853 !! end
8854
8855 !! test
8856 Local interwiki link: with additional interwiki prefix (T63357)
8857 !! options
8858 parsoid=wt2html,wt2wt,html2html
8859 !! wikitext
8860 [[local:meatball:Hello]]
8861 !! html/php
8862 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8863 </p>
8864 !! html/parsoid
8865 <p><a rel="mw:WikiLink/Interwiki" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8866 !! end
8867
8868 !! test
8869 Multiple local interwiki link prefixes
8870 !! wikitext
8871 [[local:local:local:local:mi:local:Foo]]
8872 !! options
8873 parsoid=wt2html,wt2wt,html2html
8874 !! html/php
8875 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8876 </p>
8877 !! html/parsoid
8878 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8879 !! end
8880
8881 ###
8882 ### Interlanguage links
8883 ### Language links (so that searching for '### language' matches..)
8884 ###
8885
8886 !! test
8887 Interlanguage link
8888 !! wikitext
8889 Blah blah blah
8890 [[zh:Chinese]]
8891 !! html/php
8892 <p>Blah blah blah
8893 </p>
8894 !! html/parsoid
8895 <p>Blah blah blah</p>
8896 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8897 !! end
8898
8899 ## parsoid html2wt will lose the space variations
8900 !! test
8901 Interlanguage link with spacing
8902 !! options
8903 parsoid=wt2html,wt2wt,html2html
8904 !! wikitext
8905 Blah blah blah
8906 [[ zh : Chinese ]]
8907 !! html/php
8908 <p>Blah blah blah
8909 </p>
8910 !! html/parsoid
8911 <p>Blah blah blah</p>
8912 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8913 !! end
8914
8915 !! test
8916 Double interlanguage link
8917 !! wikitext
8918 Blah blah blah
8919 [[es:Spanish]]
8920 [[zh:Chinese]]
8921 !! html/php
8922 <p>Blah blah blah
8923 </p>
8924 !! html/parsoid
8925 <p>Blah blah blah</p>
8926 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8927 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8928 !! end
8929
8930 ## parsoid html2wt will lose the space variations
8931 !! test
8932 Interlanguage link variations
8933 !! options
8934 parsoid=wt2html,wt2wt,html2html
8935 !! wikitext
8936 Blah blah blah
8937 [[ es :Spanish]]
8938 [[ ZH :Chinese]]
8939 [[es:Foo_bar]]
8940 !! html/php
8941 <p>Blah blah blah
8942 </p>
8943 !! html/parsoid
8944 <p>Blah blah blah</p>
8945 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
8946 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
8947 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
8948 !! end
8949
8950 !! test
8951 Escaping of interlanguage links (T129218, T156308)
8952 !! wikitext
8953 Blah blah blah
8954 [[:es:Spanish]]
8955 [[ : zh : Chinese ]]
8956 !! html/php
8957 <p>Blah blah blah
8958 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8959 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
8960 </p>
8961 !! html/parsoid
8962 <p>Blah blah blah
8963 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8964 <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
8965 !! end
8966
8967 !! test
8968 Multiple colons escaping interlanguage links
8969 !! options
8970 parsoid=wt2html
8971 !! wikitext
8972 [[:es:Spanish]]
8973 [[::es:Spanish]]
8974 [[:::es:Spanish]]
8975 !! html/php
8976 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8977 [[::es:Spanish]]
8978 [[:::es:Spanish]]
8979 </p>
8980 !! html/parsoid
8981 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8982 [[::es:Spanish]]
8983 [[:::es:Spanish]]</p>
8984 !! end
8985
8986 ## parsoid html2wt will normalize the space to _
8987 !! test
8988 Space and question mark encoding in interlanguage links (T95473)
8989 !! options
8990 parsoid=wt2html,wt2wt,html2html
8991 !! wikitext
8992 Blah blah blah
8993 [[es:Foo bar?]]
8994 !! html/php
8995 <p>Blah blah blah
8996 </p>
8997 !! html/parsoid
8998 <p>Blah blah blah</p>
8999 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
9000 !! end
9001
9002 !! test
9003 Interlanguage link, with prefix links
9004 !! options
9005 language=ln
9006 !! wikitext
9007 Blah blah blah
9008 [[zh:Chinese]]
9009 !! html/php
9010 <p>Blah blah blah
9011 </p>
9012 !! html/parsoid
9013 <p>Blah blah blah</p>
9014 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9015 !! end
9016
9017 !! test
9018 Double interlanguage link, with prefix links (T10897)
9019 !! options
9020 language=ln
9021 !! wikitext
9022 Blah blah blah
9023 [[es:Spanish]]
9024 [[zh:Chinese]]
9025 !! html/php
9026 <p>Blah blah blah
9027 </p>
9028 !! html/parsoid
9029 <p>Blah blah blah</p>
9030 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
9031 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
9032 !! end
9033
9034 !! test
9035 "Extra" interlanguage links (T34189 / gerrit 111390)
9036 !! wikitext
9037 Blah blah blah
9038 [[mul:Article]]
9039 !! html/php
9040 <p>Blah blah blah
9041 </p>
9042 !! html/parsoid
9043 <p>Blah blah blah</p>
9044 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
9045 !! end
9046
9047 ## PHP parser tests script needs an update
9048 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9049 !! test
9050 Language links render as inline links if $wgInterwikiMagic=false
9051 !! options
9052 wgInterwikiMagic=false
9053 parsoid=wt2html,wt2wt,html2html
9054 !! wikitext
9055 Blah blah blah
9056 [[zh:Chinese]]
9057 !! html/parsoid
9058 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9059 !! end
9060
9061 ## PHP parser tests script needs an update
9062 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9063 !! test
9064 Language links render as inline links in the Talk namespace
9065 !! options
9066 title=Talk:Foo
9067 parsoid=wt2html,wt2wt,html2html
9068 !! wikitext
9069 Blah blah blah
9070 [[zh:Chinese]]
9071 !! html/parsoid
9072 <p>Blah blah blah <a rel="mw:WikiLink/Interwiki" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9073 !! end
9074
9075 !! test
9076 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
9077 !! options
9078 language=ln
9079 !! wikitext
9080 [[WW&nbsp;II]]
9081 !! html
9082 <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>
9083 </p>
9084 !! end
9085
9086 !! test
9087 Parsoid T55221: Wikilinks should be properly entity-escaped
9088 !! options
9089 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
9090 !! html/parsoid
9091 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9092 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9093 !! wikitext
9094 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
9095
9096 He&amp;nbsp;llo He&amp;nbsp;llo
9097 !! html/php
9098 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
9099 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
9100 </p>
9101 !! end
9102
9103 # html2wt will fail because of title normalization without data-parsoid
9104 !! test
9105 Parsoid: handle constructor well
9106 !! options
9107 parsoid=wt2html,wt2wt
9108 !! wikitext
9109 [[constructor]]
9110
9111 [[constructor:foo]]
9112 !! html/php
9113 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
9114 </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>
9115 </p>
9116 !! html/parsoid
9117 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
9118
9119 <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>
9120 !! end
9121
9122 !! article
9123 ko:
9124 !! text
9125 Test.
9126 !! endarticle
9127
9128 # Note that `ko` isn't a known interlanguage prefix
9129 !! test
9130 Parsoid: recognize interlanguage links without a target page
9131 !! options
9132 ill
9133 !! wikitext
9134 [[es:]]
9135
9136 [[ko:]]
9137 !! html/php
9138 es:
9139 !! html/parsoid
9140 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
9141
9142 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9143 !! end
9144
9145 # Note that `ko` isn't a known interwiki prefix
9146 !! test
9147 Parsoid: recognize interwiki links without a target page
9148 !! options
9149 parsoid=wt2html,wt2wt,html2html
9150 !! wikitext
9151 [[:es:]]
9152
9153 [[:ko:]]
9154 !! html/php
9155 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9156 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9157 </p>
9158 !! html/parsoid
9159 <p><a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9160 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9161 !! end
9162
9163 !! test
9164 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9165 !! wikitext
9166 [[mi:Foo]]
9167 !! html/php
9168 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9169 </p>
9170 !! html/parsoid
9171 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9172 !! end
9173
9174 !! test
9175 Interlanguage link with preceding local interwiki link (T70085)
9176 !! options
9177 parsoid=wt2html,wt2wt,html2html
9178 !! wikitext
9179 Blah blah blah
9180 [[local:es:Spanish]]
9181 !! html/php
9182 <p>Blah blah blah
9183 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9184 </p>
9185 !! html/parsoid
9186 <p>Blah blah blah
9187 <a rel="mw:WikiLink/Interwiki" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9188 !! end
9189
9190 !! test
9191 Looks like an interlanguage link, but is actually a local interwiki
9192 !! options
9193 parsoid=wt2html,wt2wt,html2html
9194 !! wikitext
9195 Blah blah blah
9196 [[mi:Template:Foo]]
9197 !! html/php
9198 <p>Blah blah blah
9199 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9200 </p>
9201 !! html/parsoid
9202 <p>Blah blah blah
9203 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9204 !! end
9205
9206 ###
9207 ### Redirects, Parsoid-only
9208 ###
9209
9210 !! test
9211 1. Simple redirect to page
9212 !! wikitext
9213 #REDIRECT [[Main Page]]
9214 !! html/parsoid
9215 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9216 !! end
9217
9218 !! test
9219 2. Other redirect variants
9220 !! wikitext
9221 #REDIRECT [[Main_Page]]
9222 !! html/parsoid
9223 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9224 !! end
9225
9226 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9227 # This tests the Parsoid bail-out code.
9228 !! test
9229 3. Other redirect variants
9230 !! options
9231 parsoid=wt2html
9232 !! wikitext
9233 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9234 !! html/parsoid
9235 <ol><li>REDIRECT [[<span typeof="mw:Nowiki">[[Bar]]</span>]]</li></ol>
9236 !! end
9237
9238 !! test
9239 4. Redirect to a templated destination
9240 !! wikitext
9241 #REDIRECT [[{{echo|Foo}}bar]]
9242 !! html/parsoid
9243 <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"}]]}'/>
9244 !! end
9245
9246 !! test
9247 Empty redirect
9248 !! options
9249 parsoid=wt2html,wt2wt
9250 !! wikitext
9251 #REDIRECT [[]]
9252 !! html/parsoid
9253 <ol>
9254 <li>REDIRECT [[]]</li></ol>
9255 !! end
9256
9257 !! test
9258 Optional colon in #REDIRECT
9259 !! options
9260 # the colon is archaic syntax. we support it for wt2html, but we
9261 # don't care that it roundtrips back to the modern syntax.
9262 parsoid=wt2html,html2html
9263 !! wikitext
9264 #REDIRECT:[[Main Page]]
9265 !! html/parsoid
9266 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9267 !! end
9268
9269 !! test
9270 Whitespace in #REDIRECT with optional colon
9271 !! options
9272 # the colon and gratuitous whitespace is archaic syntax. we support
9273 # it for wt2html, but we don't care that it roundtrips back to the
9274 # modern syntax (without extra whitespace)
9275 parsoid=wt2html,html2html
9276 !! wikitext
9277
9278 #REDIRECT
9279 :
9280 [[Main Page]]
9281 !! html/parsoid
9282 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9283 !! end
9284
9285 !! test
9286 Piped link in #REDIRECT
9287 !! options
9288 # content after piped link is ignored. we support this syntax,
9289 # but don't care that the piped link is lost when we roundtrip this.
9290 parsoid=wt2html
9291 !! wikitext
9292 #REDIRECT [[Main Page|bar]]
9293 !! html/parsoid
9294 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9295 !! end
9296
9297 !! test
9298 Redirect to category (T104502)
9299 !! options
9300 parsoid=wt2html,wt2wt
9301 !! wikitext
9302 #REDIRECT [[Category:Foo]]
9303 !! html/parsoid
9304 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9305 !! end
9306
9307 !! test
9308 Redirect to category with URL encoding (T104502)
9309 !! options
9310 parsoid=wt2html
9311 !! wikitext
9312 #REDIRECT [[Category%3AFoo]]
9313 !! html/parsoid
9314 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9315 !! end
9316
9317 !! test
9318 Redirect to category page
9319 !! wikitext
9320 #REDIRECT [[:Category:Foo]]
9321 !! html/parsoid
9322 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9323 !! end
9324
9325 !! test
9326 Redirect to image page (1)
9327 !! wikitext
9328 #REDIRECT [[File:Wiki.png]]
9329 !! html/parsoid
9330 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9331 !! end
9332
9333 !! test
9334 Redirect to image page (2)
9335 !! wikitext
9336 #REDIRECT [[Image:Wiki.png]]
9337 !! html/parsoid
9338 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9339 !! end
9340
9341 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9342 # Next test confirms this.
9343 !! test
9344 Redirect to language (1) (T104918)
9345 !! options
9346 parsoid=wt2html,wt2wt,html2html
9347 !! wikitext
9348 #REDIRECT [[en:File:Wiki.png]]
9349 !! html/parsoid
9350 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9351 !! end
9352
9353 !! test
9354 Redirect to language (2) (T104918)
9355 !! wikitext
9356 #REDIRECT [[:en:File:Wiki.png]]
9357 !! html/parsoid
9358 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9359 !! end
9360
9361 !! test
9362 Redirect to interwiki (T104918)
9363 !! wikitext
9364 #REDIRECT [[meatball:File:Wiki.png]]
9365 !! html/parsoid
9366 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9367 !! end
9368
9369 !! test
9370 Non-English #REDIRECT
9371 !! options
9372 language=is
9373 !! wikitext
9374 #TILVÍSUN [[Main Page]]
9375 !! html/parsoid
9376 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9377 !! end
9378
9379 !! test
9380 Redirect syntax under text isn't considered a redirect
9381 !! wikitext
9382 some text
9383 #redirect [[Main Page]]
9384 !! html/parsoid
9385 <p>some text</p>
9386 <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>
9387 !! end
9388
9389 !! test
9390 New redirect
9391 !! options
9392 parsoid=html2wt
9393 !! html/parsoid
9394 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9395 !! wikitext
9396 #REDIRECT [[Foo]]
9397 Foo
9398 !! end
9399
9400 !! test
9401 Redirect followed by block on the same line
9402 !! options
9403 parsoid=wt2html
9404 !! wikitext
9405 #REDIRECT [[Main Page]]<!-- haha -->== hi ==
9406 !! html/parsoid
9407 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi"> hi </h2>
9408 !! end
9409
9410 !! test
9411 Redirect followed by a newline
9412 !! wikitext
9413 #REDIRECT [[Main Page]]
9414 A newline
9415 !! html/parsoid
9416 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9417 <p>A newline</p>
9418 !! end
9419
9420 !! test
9421 Redirect followed by multiple newlines
9422 !! wikitext
9423 #REDIRECT [[Main Page]]
9424
9425
9426 A newline
9427 !! html/parsoid
9428 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9429
9430 <p><br/>
9431 A newline</p>
9432 !! end
9433
9434 !! test
9435 Drop duplicate redirects
9436 !! options
9437 parsoid=html2wt
9438 !! html/parsoid
9439 <link rel="mw:PageProp/redirect" href="./Foo"/>
9440 <link rel="mw:PageProp/redirect" href="./Bar"/>
9441 <link rel="mw:PageProp/redirect" href="./Baz"/>
9442 !! wikitext
9443 #REDIRECT [[Foo]]
9444 !! end
9445
9446 ##
9447 ## XHTML tidiness
9448 ###
9449
9450 !! test
9451 <br> to <br />
9452 !! wikitext
9453 1<br>2<br />3
9454 !! html
9455 <p>1<br />2<br />3
9456 </p>
9457 !! end
9458
9459 !! test
9460 Broken br tag sanitization
9461 !! wikitext
9462 </br>
9463 !! html/php
9464 <p>&lt;/br&gt;
9465 </p>
9466 !! end
9467
9468 # TODO: Fix html2html mode (T53055)!
9469 !! test
9470 Parsoid: Broken br tag recognition
9471 !! options
9472 parsoid=wt2html
9473 !! wikitext
9474 </br>
9475
9476 <br/ >
9477 !! html+tidy
9478 <p><br /></p>
9479 <p><br /></p>
9480 !! end
9481
9482 !! test
9483 Incorrecly removing closing slashes from correctly formed XHTML
9484 !! wikitext
9485 <br style="clear:both;" />
9486 !! html
9487 <p><br style="clear:both;" />
9488 </p>
9489 !! end
9490
9491 !! test
9492 Failing to transform badly formed HTML into correct XHTML
9493 !! wikitext
9494 <br style="clear: left;">
9495 <br style="clear: right;">
9496 <br style="clear: both;">
9497 !! html
9498 <p><br style="clear: left;" />
9499 <br style="clear: right;" />
9500 <br style="clear: both;" />
9501 </p>
9502 !!end
9503
9504 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9505 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9506 !! test
9507 Handling html with a div self-closing tag
9508 !! wikitext
9509 <div title />
9510 <div title/>
9511 <div title/ >
9512 <div title=bar />
9513 <div title=bar/>
9514 <div title=bar/ >
9515 !! html/php
9516 <p>&lt;div title /&gt;
9517 &lt;div title/&gt;
9518 </p>
9519 <div>
9520 <p>&lt;div title=bar /&gt;
9521 &lt;div title=bar/&gt;
9522 </p>
9523 <div title="bar/"></div>
9524 </div>
9525
9526 !! html/parsoid
9527 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9528 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9529 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9530 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9531 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9532 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>
9533 !! end
9534
9535 !! test
9536 Handling html with a br self-closing tag
9537 !! wikitext
9538 <br title />
9539 <br title/>
9540 <br title/ >
9541 <br title=bar />
9542 <br title=bar/>
9543 <br title=bar/ >
9544 !! html/php
9545 <p><br title="" />
9546 <br title="" />
9547 <br />
9548 <br title="bar" />
9549 <br title="bar" />
9550 <br title="bar/" />
9551 </p>
9552 !! html/parsoid
9553 <p><br title="" />
9554 <br title="" />
9555 <br title="" />
9556 <br title="bar" />
9557 <br title="bar" />
9558 <br title="bar/" />
9559 </p>
9560 !! end
9561
9562 !! test
9563 Horizontal ruler (should it add that extra space?)
9564 !! wikitext
9565 <hr>
9566 <hr >
9567 foo <hr
9568 > bar
9569 !! html+tidy
9570 <hr />
9571 <hr />
9572 <p>foo</p>
9573 <hr />
9574 <p>bar</p>
9575 !! end
9576
9577 !! test
9578 Horizontal ruler -- 4+ dashes render hr
9579 !! wikitext
9580 ----
9581 !! html
9582 <hr />
9583
9584 !! end
9585
9586 !! test
9587 Horizontal ruler -- eats additional dashes on the same line
9588 !! wikitext
9589 ---------
9590 !! html
9591 <hr />
9592
9593 !! end
9594
9595 !! test
9596 Horizontal ruler -- does not collapse dashes on consecutive lines
9597 !! wikitext
9598 ----
9599 ----
9600 !! html
9601 <hr />
9602 <hr />
9603
9604 !! end
9605
9606 !! test
9607 Horizontal ruler -- <4 dashes render as plain text
9608 !! wikitext
9609 ---
9610 !! html
9611 <p>---
9612 </p>
9613 !! end
9614
9615 !! test
9616 Horizontal ruler -- Supports content following dashes on same line
9617 !! wikitext
9618 ---- Foo
9619 !! html
9620 <hr /> Foo
9621
9622 !! html+tidy
9623 <hr />
9624 <p>Foo</p>
9625 !! end
9626
9627 ###
9628 ### Block-level elements
9629 ###
9630 !! test
9631 Common list
9632 !! wikitext
9633 *Common list
9634 * item 2
9635 *item 3
9636 !! html
9637 <ul><li>Common list</li>
9638 <li> item 2</li>
9639 <li>item 3</li></ul>
9640
9641 !! end
9642
9643 !! test
9644 Numbered list
9645 !! wikitext
9646 #Numbered list
9647 #item 2
9648 # item 3
9649 !! html
9650 <ol><li>Numbered list</li>
9651 <li>item 2</li>
9652 <li> item 3</li></ol>
9653
9654 !! end
9655
9656 !! test
9657 Mixed list
9658 !! wikitext
9659 *Mixed list
9660 *# with numbers
9661 ** and bullets
9662 *# and numbers
9663 *bullets again
9664 **bullet level 2
9665 ***bullet level 3
9666 ***#Number on level 4
9667 **bullet level 2
9668 **#Number on level 3
9669 **#Number on level 3
9670 *#number level 2
9671 *Level 1
9672 *** Level 3
9673 #** Level 3, but ordered
9674 !! html
9675 <ul><li>Mixed list
9676 <ol><li> with numbers</li></ol>
9677 <ul><li> and bullets</li></ul>
9678 <ol><li> and numbers</li></ol></li>
9679 <li>bullets again
9680 <ul><li>bullet level 2
9681 <ul><li>bullet level 3
9682 <ol><li>Number on level 4</li></ol></li></ul></li>
9683 <li>bullet level 2
9684 <ol><li>Number on level 3</li>
9685 <li>Number on level 3</li></ol></li></ul>
9686 <ol><li>number level 2</li></ol></li>
9687 <li>Level 1
9688 <ul><li><ul><li> Level 3</li></ul></li></ul></li></ul>
9689 <ol><li><ul><li><ul><li> Level 3, but ordered</li></ul></li></ul></li></ol>
9690
9691 !! end
9692
9693 !! test
9694 1. Nested mixed wikitext and html list
9695 !! wikitext
9696 * hi
9697 * <ul><li>ho</li></ul>
9698 * hi
9699 ** ho
9700 !! html/php
9701 <ul><li> hi</li>
9702 <li> <ul><li>ho</li></ul></li>
9703 <li> hi
9704 <ul><li> ho</li></ul></li></ul>
9705
9706 !! html/parsoid
9707 <ul><li> hi</li>
9708 <li> <ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9709 <li> hi
9710 <ul><li> ho</li></ul></li></ul>
9711 !! end
9712
9713 !! test
9714 2. Nested mixed wikitext and html list (incompatible)
9715 !! wikitext
9716 ; hi
9717 : {{echo|<li>ho</li>}}
9718 !! html/php
9719 <dl><dt> hi</dt>
9720 <dd> <li>ho</li></dd></dl>
9721
9722 !! html/parsoid
9723 <dl><dt> hi</dt>
9724 <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>
9725 !! end
9726
9727 !! test
9728 Nested lists 1
9729 !! wikitext
9730 *foo
9731 **bar
9732 !! html
9733 <ul><li>foo
9734 <ul><li>bar</li></ul></li></ul>
9735
9736 !! end
9737
9738 !! test
9739 Nested lists 2
9740 !! wikitext
9741 **foo
9742 *bar
9743 !! html
9744 <ul><li><ul><li>foo</li></ul></li>
9745 <li>bar</li></ul>
9746
9747 !! end
9748
9749 !! test
9750 Nested lists 3 (first element empty)
9751 !! wikitext
9752 *
9753 **bar
9754 !! html
9755 <ul><li>
9756 <ul><li>bar</li></ul></li></ul>
9757
9758 !! end
9759
9760 !! test
9761 Nested lists 4 (first element empty)
9762 !! wikitext
9763 **
9764 *bar
9765 !! html
9766 <ul><li><ul><li></li></ul></li>
9767 <li>bar</li></ul>
9768
9769 !! end
9770
9771 !! test
9772 Nested lists 5 (both elements empty)
9773 !! wikitext
9774 **
9775 *
9776 !! html
9777 <ul><li><ul><li></li></ul></li>
9778 <li></li></ul>
9779
9780 !! end
9781
9782 !! test
9783 Nested lists 6 (both elements empty)
9784 !! wikitext
9785 *
9786 **
9787 !! html
9788 <ul><li>
9789 <ul><li></li></ul></li></ul>
9790
9791 !! end
9792
9793 !! test
9794 Nested lists 7 (skip initial nesting levels)
9795 !! wikitext
9796 *** foo
9797 !! html
9798 <ul><li><ul><li><ul><li> foo</li></ul></li></ul></li></ul>
9799
9800 !! end
9801
9802 !! test
9803 Nested lists 8 (multiple nesting transitions)
9804 !! wikitext
9805 * foo
9806 *** bar
9807 ** baz
9808 * boo
9809 !! html
9810 <ul><li> foo
9811 <ul><li><ul><li> bar</li></ul></li>
9812 <li> baz</li></ul></li>
9813 <li> boo</li></ul>
9814
9815 !! end
9816
9817 !! test
9818 Nested lists 9 (extension interaction)
9819 !! options
9820 parsoid
9821 !! wikitext
9822 *<references />
9823 !! html/parsoid
9824 <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>
9825 !! end
9826
9827 !! test
9828 1. Lists with start-of-line-transparent tokens before bullets: Comments
9829 !! wikitext
9830 *foo
9831 *<!--cmt-->bar
9832 <!--cmt-->*baz
9833 !! html
9834 <ul><li>foo</li>
9835 <li>bar</li>
9836 <li>baz</li></ul>
9837
9838 !! end
9839
9840 !! test
9841 2. Lists with start-of-line-transparent tokens before bullets: Template close
9842 !! wikitext
9843 *foo {{echo|bar
9844 }}*baz
9845 !! html
9846 <ul><li>foo bar</li>
9847 <li>baz</li></ul>
9848
9849 !! end
9850
9851 !! test
9852 List items are not parsed correctly following a <pre> block (T2785)
9853 !! wikitext
9854 * <pre>foo</pre>
9855 * <pre>bar</pre>
9856 * zar
9857 !! html/php
9858 <ul><li> <pre>foo</pre></li>
9859 <li> <pre>bar</pre></li>
9860 <li> zar</li></ul>
9861
9862 !! html/parsoid
9863 <ul><li> <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
9864 <li> <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
9865 <li> zar</li></ul>
9866 !! end
9867
9868 !! test
9869 List items from template
9870 !! wikitext
9871
9872 {{inner list}}
9873 * item 2
9874
9875 * item 0
9876 {{inner list}}
9877 * item 2
9878
9879 * item 0
9880 * notSOL{{inner list}}
9881 * item 2
9882 !! html
9883 <ul><li> item 1</li>
9884 <li> item 2</li></ul>
9885 <ul><li> item 0</li>
9886 <li> item 1</li>
9887 <li> item 2</li></ul>
9888 <ul><li> item 0</li>
9889 <li> notSOL</li>
9890 <li> item 1</li>
9891 <li> item 2</li></ul>
9892
9893 !! end
9894
9895 !! test
9896 List interrupted by empty line or heading
9897 !! wikitext
9898 * foo
9899
9900 ** bar
9901 == A heading ==
9902 * Another list item
9903 !! html
9904 <ul><li> foo</li></ul>
9905 <ul><li><ul><li> bar</li></ul></li></ul>
9906 <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>
9907 <ul><li> Another list item</li></ul>
9908
9909 !!end
9910
9911 !!test
9912 Multiple list tags generated by templates
9913 !! wikitext
9914 {{echo|<li>}}a
9915 {{echo|<li>}}b
9916 {{echo|<li>}}c
9917 !! html
9918 <li>a
9919 <li>b
9920 <li>c</li>
9921 </li>
9922 </li>
9923
9924 !! html+tidy
9925 <ul>
9926 <li>a</li>
9927 <li>b</li>
9928 <li>c</li>
9929 </ul>
9930 !!end
9931
9932 !!test
9933 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
9934 !! wikitext
9935 *a
9936 <!--This line will NOT split the list-->
9937 *b
9938 <!--This line will NOT split the list either-->
9939 *c
9940 <!--foo--> <!----> <!--This line NOT split the list either-->
9941 *d
9942 !! html
9943 <ul><li>a</li>
9944 <li>b</li>
9945 <li>c</li>
9946 <li>d</li></ul>
9947
9948 !!end
9949
9950 !!test
9951 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
9952 !! wikitext
9953 *a
9954 <!--This line will NOT split the list-->
9955 *b
9956 <!--This line will NOT split the list either-->
9957 *c
9958 <!--foo--> <!----> <!--This line NOT split the list
9959 either-->
9960 *d
9961 !! html
9962 <ul><li>a</li>
9963 <li>b</li>
9964 <li>c</li>
9965 <li>d</li></ul>
9966
9967 !!end
9968
9969 !!test
9970 Test the li-hack
9971 (The PHP parser relies on Tidy for the hack)
9972 !!options
9973 parsoid=wt2html,wt2wt
9974 !! wikitext
9975 * foo
9976 * <li>li-hack
9977 * {{echo|<li>templated li-hack}}
9978 * <!--foo--> <li> unsupported li-hack with preceding comments
9979
9980 <ul>
9981 <li><li>not a li-hack
9982 </li>
9983 </ul>
9984 !! html+tidy
9985 <ul>
9986 <li>foo</li>
9987 <li>li-hack</li>
9988 <li>templated li-hack</li>
9989 <li>unsupported li-hack with preceding comments</li>
9990 </ul>
9991 <ul>
9992 <li>not a li-hack</li>
9993 </ul>
9994 !! html/parsoid
9995 <ul><li> foo</li>
9996 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"* "}'>li-hack</li>
9997 <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>
9998 <li data-parsoid='{"autoInsertedEnd":true}'> <!--foo--> </li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'> unsupported li-hack with preceding comments</li></ul>
9999
10000 <ul data-parsoid='{"stx":"html"}'>
10001 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
10002 </li>
10003 </ul>
10004
10005 !!end
10006
10007 !! test
10008 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
10009 !! options
10010 parsoid
10011 !! wikitext
10012 # foo
10013 ## bar
10014 * foo
10015 ** bar
10016 : foo
10017 :: bar
10018 !! html
10019 <ol>
10020 <li> foo<ol>
10021 <li> bar</li>
10022 </ol></li>
10023 </ol><ul>
10024 <li> foo<ul>
10025 <li> bar</li>
10026 </ul></li>
10027 </ul><dl>
10028 <dd> foo<dl>
10029 <dd> bar</dd>
10030 </dl></dd>
10031 </dl>
10032 !! end
10033
10034 !! test
10035 Parsoid: Test of whitespace serialization with Templated bullets
10036 !! options
10037 parsoid
10038 !! wikitext
10039 * {{bullet}}
10040 !! html/parsoid
10041 <ul>
10042 <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>
10043 </ul>
10044 !! end
10045
10046 # ------------------------------------------------------------------------
10047 # The next set of tests are about Parsoid's ability to handle badly nested
10048 # tags (parse, minimize scope of fixup, and roundtrip back)
10049 # ------------------------------------------------------------------------
10050
10051 !! test
10052 Unbalanced closing block tags break a list
10053 (php parser relies on Tidy to fix up)
10054 !! wikitext
10055 <div>
10056 *a</div><div>
10057 *b</div>
10058 !! html+tidy
10059 <div>
10060 <ul>
10061 <li>a</li>
10062 </ul>
10063 </div>
10064 <div>
10065 <ul>
10066 <li>b</li>
10067 </ul>
10068 </div>
10069 !! end
10070
10071 # Parsoid fails this test, but it might be tricky to support properly.
10072 # See T70395.
10073 !! test
10074 Unbalanced closing non-block tags don't break a list
10075 (php parser relies on Tidy to fix up)
10076 !! wikitext
10077 <span>
10078 *a</span><span>
10079 *b</span>
10080 !! html/php+tidy
10081 <ul>
10082 <li><span>a</span></li>
10083 <li><span>b</span></li>
10084 </ul>
10085 !! html/parsoid
10086 <span>
10087 <ul>
10088 <li>a<span></span>
10089 </li>
10090 <li>b
10091 </li>
10092 </ul>
10093 </span>
10094 !! end
10095
10096 !! test
10097 Unclosed formatting tags that straddle lists are closed and reopened
10098 (php parser relies on Tidy to fix up)
10099 !! options
10100 parsoid=wt2html,wt2wt,html2html
10101 !! wikitext
10102 # <s> a
10103 # b </s>
10104 !! html/php+tidy
10105 <ol>
10106 <li><s>a</s></li>
10107 <li><s>b</s></li>
10108 </ol>
10109 !! html/parsoid
10110 <ol><li> <s> a</s></li>
10111 <li><s> b </s></li></ol>
10112 !! end
10113
10114 # See T70395.
10115 !!test
10116 1. List embedded in a formatting tag
10117 !! wikitext
10118 <small>
10119 * foo
10120 </small>
10121 !! html/php+tidy
10122 <ul>
10123 <li><small>foo</small></li>
10124 </ul>
10125 !! html/parsoid
10126 <small>
10127 <ul>
10128 <li> foo</li>
10129 </ul>
10130 </small>
10131 !!end
10132
10133 ## Ugly Parsoid output here
10134 ## Not sure what the right output is.
10135 !!test
10136 2. List embedded in a formatting tag
10137 !! wikitext
10138 <small>
10139 *a
10140 *b</small>
10141 !! html/php+tidy
10142 <ul>
10143 <li><small>a</small></li>
10144 <li><small>b</small></li>
10145 </ul>
10146 !! html/parsoid
10147 <small></small>
10148 <ul><small>
10149 <li>a</li>
10150 </small>
10151 <li><small>b</small></li>
10152 </ul>
10153 !!end
10154
10155 # Ugly Parsoid and PHP parser output here
10156 # Not sure if we want to make this a test!
10157 #
10158 ## !!test
10159 ## 3. Unclosed formatting tags in list elements
10160 ## !! wikitext
10161 ## *<small>a
10162 ## *<small>b
10163 ## !! html/php+tidy
10164 ## <ul>
10165 ## <li><small>a</small></li>
10166 ## <li><small><small>b</small></small></li>
10167 ## </ul>
10168 ## !! html/parsoid
10169 ## <ul>
10170 ## <li><small>a</small></li>
10171 ## <small>
10172 ## <li><small>b</small></li>
10173 ## </small></ul>
10174 ## !!end
10175
10176 # This is a bug in the PHP parser + tidy combination.
10177 # (The </tr> tag gets parsed as text and html-escaped by PHP,
10178 # and then fostered out of the table by tidy.)
10179 # We believe the Parsoid output to be correct.
10180 !! test
10181 Table with missing opening <tr> tag
10182 !! options
10183 parsoid=wt2html,wt2wt
10184 !! wikitext
10185 <table>
10186 <td>foo</td>
10187 </tr>
10188 </table>
10189 !! html+tidy
10190 <table>
10191 <tr>
10192 <td>foo</td>
10193 </tr>
10194 </table>
10195 !! end
10196
10197 ###
10198 ### Magic Words
10199 ###
10200
10201 # Note that the current date is hard-coded as
10202 # 1970-01-01T00:02:03Z (a Thursday)
10203 # when running parser tests. The timezone is also fixed to GMT, so
10204 # local date will be identical to current date.
10205
10206 !! test
10207 Magic Word: {{CURRENTDAY}}
10208 !! wikitext
10209 {{CURRENTDAY}}
10210 !! html
10211 <p>1
10212 </p>
10213 !! end
10214
10215 !! test
10216 Magic Word: {{CURRENTDAY2}}
10217 !! wikitext
10218 {{CURRENTDAY2}}
10219 !! html
10220 <p>01
10221 </p>
10222 !! end
10223
10224 !! test
10225 Magic Word: {{CURRENTDAYNAME}}
10226 !! wikitext
10227 {{CURRENTDAYNAME}}
10228 !! html
10229 <p>Thursday
10230 </p>
10231 !! end
10232
10233 !! test
10234 Magic Word: {{CURRENTDOW}}
10235 !! wikitext
10236 {{CURRENTDOW}}
10237 !! html
10238 <p>4
10239 </p>
10240 !! end
10241
10242 !! test
10243 Magic Word: {{CURRENTMONTH}}
10244 !! wikitext
10245 {{CURRENTMONTH}}
10246 !! html
10247 <p>01
10248 </p>
10249 !! end
10250
10251 !! test
10252 Magic Word: {{CURRENTMONTH1}}
10253 !! wikitext
10254 {{CURRENTMONTH1}}
10255 !! html
10256 <p>1
10257 </p>
10258 !! end
10259
10260 !! test
10261 Magic Word: {{CURRENTMONTHABBREV}}
10262 !! wikitext
10263 {{CURRENTMONTHABBREV}}
10264 !! html
10265 <p>Jan
10266 </p>
10267 !! end
10268
10269 !! test
10270 Magic Word: {{CURRENTMONTHNAME}}
10271 !! wikitext
10272 {{CURRENTMONTHNAME}}
10273 !! html
10274 <p>January
10275 </p>
10276 !! end
10277
10278 !! test
10279 Magic Word: {{CURRENTMONTHNAMEGEN}}
10280 !! wikitext
10281 {{CURRENTMONTHNAMEGEN}}
10282 !! html
10283 <p>January
10284 </p>
10285 !! end
10286
10287 !! test
10288 Magic Word: {{CURRENTTIME}}
10289 !! wikitext
10290 {{CURRENTTIME}}
10291 !! html
10292 <p>00:02
10293 </p>
10294 !! end
10295
10296 !! test
10297 Magic Word: {{CURRENTHOUR}}
10298 !! wikitext
10299 {{CURRENTHOUR}}
10300 !! html
10301 <p>00
10302 </p>
10303 !! end
10304
10305 !! test
10306 Magic Word: {{CURRENTWEEK}} (T6594)
10307 !! wikitext
10308 {{CURRENTWEEK}}
10309 !! html
10310 <p>1
10311 </p>
10312 !! end
10313
10314 !! test
10315 Magic Word: {{CURRENTYEAR}}
10316 !! wikitext
10317 {{CURRENTYEAR}}
10318 !! html
10319 <p>1970
10320 </p>
10321 !! end
10322
10323 !! test
10324 Magic Word: {{CURRENTTIMESTAMP}}
10325 !! wikitext
10326 {{CURRENTTIMESTAMP}}
10327 !! html
10328 <p>19700101000203
10329 </p>
10330 !! end
10331
10332 !! test
10333 Magic Words LOCAL (UTC)
10334 !! wikitext
10335 * {{LOCALMONTH}}
10336 * {{LOCALMONTH1}}
10337 * {{LOCALMONTHNAME}}
10338 * {{LOCALMONTHNAMEGEN}}
10339 * {{LOCALMONTHABBREV}}
10340 * {{LOCALDAY}}
10341 * {{LOCALDAY2}}
10342 * {{LOCALDAYNAME}}
10343 * {{LOCALYEAR}}
10344 * {{LOCALTIME}}
10345 * {{LOCALHOUR}}
10346 * {{LOCALWEEK}}
10347 * {{LOCALDOW}}
10348 * {{LOCALTIMESTAMP}}
10349 !! html
10350 <ul><li> 01</li>
10351 <li> 1</li>
10352 <li> January</li>
10353 <li> January</li>
10354 <li> Jan</li>
10355 <li> 1</li>
10356 <li> 01</li>
10357 <li> Thursday</li>
10358 <li> 1970</li>
10359 <li> 00:02</li>
10360 <li> 00</li>
10361 <li> 1</li>
10362 <li> 4</li>
10363 <li> 19700101000203</li></ul>
10364
10365 !! end
10366
10367 !! test
10368 Magic Word: {{FULLPAGENAME}}
10369 !! options
10370 title=[[User:Ævar Arnfjörð Bjarmason]]
10371 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10372 !! wikitext
10373 {{FULLPAGENAME}}
10374 !! html/*
10375 <p>User:Ævar Arnfjörð Bjarmason
10376 </p>
10377 !! end
10378
10379 !! test
10380 Magic Word: {{FULLPAGENAMEE}}
10381 !! options
10382 title=[[User:Ævar Arnfjörð Bjarmason]]
10383 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10384 !! wikitext
10385 {{FULLPAGENAMEE}}
10386 !! html/*
10387 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10388 </p>
10389 !! end
10390
10391 !! test
10392 Magic Word: {{TALKSPACE}}
10393 !! options
10394 title=[[User:Ævar Arnfjörð Bjarmason]]
10395 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10396 !! wikitext
10397 {{TALKSPACE}}
10398 !! html/*
10399 <p>User talk
10400 </p>
10401 !! end
10402
10403 !! test
10404 Magic Word: {{TALKSPACE}}, same namespace
10405 !! options
10406 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10407 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10408 !! wikitext
10409 {{TALKSPACE}}
10410 !! html/*
10411 <p>User talk
10412 </p>
10413 !! end
10414
10415 !! test
10416 Magic Word: {{TALKSPACE}}, main namespace
10417 !! options
10418 title=[[Parser Test]]
10419 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10420 !! wikitext
10421 {{TALKSPACE}}
10422 !! html/*
10423 <p>Talk
10424 </p>
10425 !! end
10426
10427 !! test
10428 Magic Word: {{TALKSPACEE}}
10429 !! options
10430 title=[[User:Ævar Arnfjörð Bjarmason]]
10431 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10432 !! wikitext
10433 {{TALKSPACEE}}
10434 !! html/*
10435 <p>User_talk
10436 </p>
10437 !! end
10438
10439 !! test
10440 Magic Word: {{SUBJECTSPACE}}
10441 !! options
10442 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10443 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10444 !! wikitext
10445 {{SUBJECTSPACE}}
10446 !! html/*
10447 <p>User
10448 </p>
10449 !! end
10450
10451 !! test
10452 Magic Word: {{SUBJECTSPACE}}, same namespace
10453 !! options
10454 title=[[User:Ævar Arnfjörð Bjarmason]]
10455 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10456 !! wikitext
10457 {{SUBJECTSPACE}}
10458 !! html/*
10459 <p>User
10460 </p>
10461 !! end
10462
10463 !! test
10464 Magic Word: {{SUBJECTSPACE}}, main namespace
10465 !! options
10466 title=[[Parser Test]]
10467 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10468 !! wikitext
10469 {{SUBJECTSPACE}}
10470 !! html/*
10471
10472 !! end
10473
10474 !! test
10475 Magic Word: {{SUBJECTSPACEE}}
10476 !! options
10477 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10478 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10479 !! wikitext
10480 {{SUBJECTSPACEE}}
10481 !! html/*
10482 <p>User
10483 </p>
10484 !! end
10485
10486 !! test
10487 Magic Word: {{NAMESPACE}}
10488 !! options
10489 title=[[User:Ævar Arnfjörð Bjarmason]]
10490 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10491 !! wikitext
10492 {{NAMESPACE}}
10493 !! html/*
10494 <p>User
10495 </p>
10496 !! end
10497
10498 !! test
10499 Magic Word: {{NAMESPACEE}}
10500 !! options
10501 title=[[User:Ævar Arnfjörð Bjarmason]]
10502 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10503 !! wikitext
10504 {{NAMESPACEE}}
10505 !! html/*
10506 <p>User
10507 </p>
10508 !! end
10509
10510 !! test
10511 Magic Word: {{NAMESPACENUMBER}}
10512 !! options
10513 title=[[User:Ævar Arnfjörð Bjarmason]]
10514 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10515 !! wikitext
10516 {{NAMESPACENUMBER}}
10517 !! html/*
10518 <p>2
10519 </p>
10520 !! end
10521
10522 !! test
10523 Magic Word: {{SUBPAGENAME}}
10524 !! options
10525 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10526 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10527 !! wikitext
10528 {{SUBPAGENAME}}
10529 !! html/*
10530 <p>sub ö
10531 </p>
10532 !! end
10533
10534 !! test
10535 Magic Word: {{SUBPAGENAMEE}}
10536 !! options
10537 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10538 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10539 !! wikitext
10540 {{SUBPAGENAMEE}}
10541 !! html/*
10542 <p>sub_%C3%B6
10543 </p>
10544 !! end
10545
10546 !! test
10547 Magic Word: {{ROOTPAGENAME}}
10548 !! options
10549 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10550 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10551 !! wikitext
10552 {{ROOTPAGENAME}}
10553 !! html/*
10554 <p>Ævar Arnfjörð Bjarmason
10555 </p>
10556 !! end
10557
10558 !! test
10559 Magic Word: {{ROOTPAGENAMEE}}
10560 !! options
10561 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10562 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10563 !! wikitext
10564 {{ROOTPAGENAMEE}}
10565 !! html/*
10566 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10567 </p>
10568 !! end
10569
10570 !! test
10571 Magic Word: {{BASEPAGENAME}}
10572 !! options
10573 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10574 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10575 !! wikitext
10576 {{BASEPAGENAME}}
10577 !! html/*
10578 <p>Ævar Arnfjörð Bjarmason
10579 </p>
10580 !! end
10581
10582 !! test
10583 Magic Word: {{BASEPAGENAMEE}}
10584 !! options
10585 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10586 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10587 !! wikitext
10588 {{BASEPAGENAMEE}}
10589 !! html/*
10590 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10591 </p>
10592 !! end
10593
10594 !! test
10595 Magic Word: {{TALKPAGENAME}}
10596 !! options
10597 title=[[User:Ævar Arnfjörð Bjarmason]]
10598 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10599 !! wikitext
10600 {{TALKPAGENAME}}
10601 !! html/*
10602 <p>User talk:Ævar Arnfjörð Bjarmason
10603 </p>
10604 !! end
10605
10606 !! test
10607 Magic Word: {{TALKPAGENAMEE}}
10608 !! options
10609 title=[[User:Ævar Arnfjörð Bjarmason]]
10610 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10611 !! wikitext
10612 {{TALKPAGENAMEE}}
10613 !! html/*
10614 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10615 </p>
10616 !! end
10617
10618 !! test
10619 Magic Word: {{SUBJECTPAGENAME}}
10620 !! options
10621 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10622 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10623 !! wikitext
10624 {{SUBJECTPAGENAME}}
10625 !! html/*
10626 <p>User:Ævar Arnfjörð Bjarmason
10627 </p>
10628 !! end
10629
10630 !! test
10631 Magic Word: {{SUBJECTPAGENAMEE}}
10632 !! options
10633 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10634 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10635 !! wikitext
10636 {{SUBJECTPAGENAMEE}}
10637 !! html/*
10638 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10639 </p>
10640 !! end
10641
10642 !! test
10643 Magic Word: {{NUMBEROFFILES}}
10644 !! options
10645 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10646 !! wikitext
10647 {{NUMBEROFFILES}}
10648 !! html/*
10649 <p>7
10650 </p>
10651 !! end
10652
10653 !! test
10654 Magic Word: {{PAGENAME}}
10655 !! options
10656 title=[[User:Ævar Arnfjörð Bjarmason]]
10657 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10658 !! wikitext
10659 {{PAGENAME}}
10660 !! html/*
10661 <p>Ævar Arnfjörð Bjarmason
10662 </p>
10663 !! end
10664
10665 !! test
10666 Magic Word: {{PAGENAME}} with metacharacters
10667 !! options
10668 title=[['foo & bar = baz']]
10669 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10670 !! wikitext
10671 ''{{PAGENAME}}''
10672 !! html/php
10673 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10674 </p>
10675 !! html+tidy
10676 <p><i>'foo &amp; bar = baz'</i></p>
10677 !! end
10678
10679 !! test
10680 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10681 !! options
10682 title=[[*RFC 1234 http://example.com/]]
10683 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10684 !! wikitext
10685 {{PAGENAME}}
10686 !! html/php
10687 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10688 </p>
10689 !! html+tidy
10690 <p>*RFC 1234 http://example.com/</p>
10691 !! end
10692
10693 !! test
10694 Magic Word: {{PAGENAMEE}}
10695 !! options
10696 title=[[User:Ævar Arnfjörð Bjarmason]]
10697 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10698 !! wikitext
10699 {{PAGENAMEE}}
10700 !! html/*
10701 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10702 </p>
10703 !! end
10704
10705 !! test
10706 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10707 !! options
10708 title=[[*RFC 1234 http://example.com/]]
10709 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10710 !! wikitext
10711 {{PAGENAMEE}}
10712 !! html/php
10713 <p>&#42;RFC_1234_http&#58;//example.com/
10714 </p>
10715 !! html+tidy
10716 <p>*RFC_1234_http://example.com/</p>
10717 !! end
10718
10719 !! test
10720 Magic Word: {{REVISIONID}}
10721 !! options
10722 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10723 showflags
10724 !! wikitext
10725 {{REVISIONID}}
10726 !! html/*
10727 <p>1337
10728 </p>
10729 flags=vary-revision-id
10730 !! end
10731
10732 !! test
10733 Magic Word: {{SCRIPTPATH}}
10734 !! options
10735 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10736 !! wikitext
10737 {{SCRIPTPATH}}
10738 !! html/*
10739
10740 !! end
10741
10742 !! test
10743 Magic Word: {{STYLEPATH}}
10744 !! options
10745 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10746 !! wikitext
10747 {{STYLEPATH}}
10748 !! html/*
10749 <p>/skins
10750 </p>
10751 !! end
10752
10753 !! test
10754 Magic Word: {{SERVER}}
10755 !! options
10756 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10757 !! wikitext
10758 {{SERVER}}
10759 !! html/*
10760 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10761 </p>
10762 !! end
10763
10764 !! test
10765 Magic Word: {{SERVERNAME}}
10766 !! options
10767 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10768 !! wikitext
10769 {{SERVERNAME}}
10770 !! html/*
10771 <p>example.org
10772 </p>
10773 !! end
10774
10775 !! test
10776 Magic Word: {{SITENAME}}
10777 !! options
10778 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10779 !! wikitext
10780 {{SITENAME}}
10781 !! html/*
10782 <p>MediaWiki
10783 </p>
10784 !! end
10785
10786 !! test
10787 Magic Word: {{PAGELANGUAGE}}
10788 !! options
10789 language=fr
10790 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10791 !! wikitext
10792 {{PAGELANGUAGE}}
10793 !! html/*
10794 <p>fr
10795 </p>
10796 !! end
10797
10798 !! test
10799 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10800 !! options
10801 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10802 !! wikitext
10803 {{PAGELANGUAGE}}
10804 !! html/*
10805 <p>en
10806 </p>
10807 !! end
10808
10809 !! test
10810 Case-sensitive magic words, when cased differently, should just be template transclusions
10811 !! wikitext
10812 {{CurrentMonth}}
10813 {{currentday}}
10814 {{cURreNTweEK}}
10815 {{currentHour}}
10816 !! html
10817 <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>
10818 <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>
10819 <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>
10820 <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>
10821 </p>
10822 !! end
10823
10824 !! test
10825 Case-insensitive magic words should still work with weird casing.
10826 !! wikitext
10827 {{sErVeRNaMe}}
10828 {{LCFirst:AOEU}}
10829 {{ucFIRST:aoeu}}
10830 {{SERver}}
10831 !! html
10832 <p>example.org
10833 aOEU
10834 Aoeu
10835 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10836 </p>
10837 !! end
10838
10839 # From plwiki:PLOS_ONE
10840 !! test
10841 Parsoid: Page property magic word with magic word contents
10842 !! wikitext
10843 {{DISPLAYTITLE:''{{PAGENAME}}''}}
10844 !! html/parsoid
10845 <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>"}]]}'/>
10846 !! end
10847
10848 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
10849 # But, this is a limitation of our representation and is documented in
10850 # TemplateHandler.js in processSpecialMagicWord
10851 !! test
10852 Parsoid: Template-generated DISPLAYTITLE
10853 !! wikitext
10854 {{{{echo|DISPLAYTITLE}}:Foo}}
10855 !! options
10856 showtitle
10857 !! config
10858 wgAllowDisplayTitle=true
10859 wgRestrictDisplayTitle=false
10860 !! html/php
10861 Foo
10862
10863 !! html/parsoid
10864 <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"}]]}'/>
10865 !! end
10866
10867 !! test
10868 Namespace 1 {{ns:1}}
10869 !! wikitext
10870 {{ns:1}}
10871 !! html
10872 <p>Talk
10873 </p>
10874 !! end
10875
10876 !! test
10877 Namespace 1 {{ns:01}}
10878 !! wikitext
10879 {{ns:01}}
10880 !! html
10881 <p>Talk
10882 </p>
10883 !! end
10884
10885 !! test
10886 Namespace 0 {{ns:0}} (T6783)
10887 !! wikitext
10888 {{ns:0}}
10889 !! html
10890
10891 !! end
10892
10893 !! test
10894 Namespace 0 {{ns:00}} (T6783)
10895 !! wikitext
10896 {{ns:00}}
10897 !! html
10898
10899 !! end
10900
10901 !! test
10902 Namespace -1 {{ns:-1}}
10903 !! wikitext
10904 {{ns:-1}}
10905 !! html
10906 <p>Special
10907 </p>
10908 !! end
10909
10910 !! test
10911 Namespace User {{ns:User}}
10912 !! wikitext
10913 {{ns:User}}
10914 !! html
10915 <p>User
10916 </p>
10917 !! end
10918
10919 !! test
10920 Namespace User talk {{ns:User_talk}}
10921 !! wikitext
10922 {{ns:User_talk}}
10923 !! html
10924 <p>User talk
10925 </p>
10926 !! end
10927
10928 !! test
10929 Namespace User talk {{ns:uSeR tAlK}}
10930 !! wikitext
10931 {{ns:uSeR tAlK}}
10932 !! html
10933 <p>User talk
10934 </p>
10935 !! end
10936
10937 !! test
10938 Namespace File {{ns:File}}
10939 !! wikitext
10940 {{ns:File}}
10941 !! html
10942 <p>File
10943 </p>
10944 !! end
10945
10946 !! test
10947 Namespace File {{ns:Image}}
10948 !! wikitext
10949 {{ns:Image}}
10950 !! html
10951 <p>File
10952 </p>
10953 !! end
10954
10955 !! test
10956 Namespace (lang=de) Benutzer {{ns:User}}
10957 !! options
10958 language=de
10959 !! wikitext
10960 {{ns:User}}
10961 !! html
10962 <p>Benutzer
10963 </p>
10964 !! end
10965
10966 !! test
10967 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
10968 !! options
10969 language=de
10970 !! wikitext
10971 {{ns:3}}
10972 !! html
10973 <p>Benutzer Diskussion
10974 </p>
10975 !! end
10976
10977 !! test
10978 Urlencode
10979 !! wikitext
10980 {{urlencode:hi world?!}}
10981 {{urlencode:hi world?!|WIKI}}
10982 {{urlencode:hi world?!|PATH}}
10983 {{urlencode:hi world?!|QUERY}}
10984 !! html/php
10985 <p>hi+world%3F%21
10986 hi_world%3F!
10987 hi%20world%3F%21
10988 hi+world%3F%21
10989 </p>
10990 !! end
10991
10992 !! test
10993 Magic Word: prioritize type info over data-parsoid
10994 !! options
10995 parsoid=html2wt
10996 !! html/parsoid
10997 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
10998 !! wikitext
10999 __FORCETOC__
11000 !! end
11001
11002 !! test
11003 Magic Word: serialize on separate line (parsoid)
11004 !! options
11005 parsoid=wt2wt,html2wt
11006 !! wikitext
11007 foo
11008 __NOTOC__
11009 bar
11010 !! html/parsoid
11011 foo<meta property="mw:PageProp/notoc"/>bar
11012 !! end
11013
11014 !! test
11015 Magic Word: rt non-english wikis
11016 !! options
11017 parsoid=wt2wt
11018 language=de
11019 !! wikitext
11020 __NOEDITSECTION__
11021 !! html/parsoid
11022 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
11023 !! end
11024
11025 !!test
11026 __proto__ is treated as normal wikitext (T105997)
11027 !!wikitext
11028 __proto__
11029 !!html
11030 <p>__proto__
11031 </p>
11032 !!end
11033
11034 ###
11035 ### Magic links
11036 ###
11037 !! test
11038 Magic links: internal link to RFC (T2479)
11039 !! wikitext
11040 [[RFC 123]]
11041 !! html/php
11042 <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>
11043 </p>
11044 !! html/parsoid
11045 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
11046 !! end
11047
11048 !! test
11049 Magic links: RFC (T2479)
11050 !! wikitext
11051 RFC 822
11052 !! html/php
11053 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11054 </p>
11055 !! html/parsoid
11056 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a></p>
11057 !! end
11058
11059 !! test
11060 Magic links: RFC (T67278)
11061 !! wikitext
11062 This is RFC 822 but thisRFC 822 is not RFC 822linked.
11063 !! html/php
11064 <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.
11065 </p>
11066 !! html/parsoid
11067 <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>
11068 !! end
11069
11070 !! test
11071 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
11072 !! wikitext
11073 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
11074 RFC
11075 822
11076 !! html/php
11077 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11078 RFC
11079 822
11080 </p>
11081 !! html/parsoid
11082 <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>
11083 RFC
11084 822</p>
11085 !! end
11086
11087 !! test
11088 Magic links: ISBN (T3937)
11089 !! wikitext
11090 ISBN 0-306-40615-2
11091 !! html/php
11092 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
11093 </p>
11094 !! html/parsoid
11095 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
11096 !! end
11097
11098 !! test
11099 Magic links: ISBN (T67278)
11100 !! wikitext
11101 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
11102 !! html/php
11103 <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.
11104 </p>
11105 !! html/parsoid
11106 <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>
11107 !! end
11108
11109 !! test
11110 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
11111 !! wikitext
11112 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
11113 ISBN
11114 9780316098113
11115 ISBN 978
11116 0316098113
11117 !! html/php
11118 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
11119 ISBN
11120 9780316098113
11121 ISBN 978
11122 0316098113
11123 </p>
11124 !! html/parsoid
11125 <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>
11126 ISBN
11127 9780316098113
11128 ISBN 978
11129 0316098113</p>
11130 !! end
11131
11132 !! test
11133 Magic links: PMID incorrectly converts space to underscore
11134 !! wikitext
11135 PMID 1234
11136 !! html/php
11137 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11138 </p>
11139 !! html/parsoid
11140 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a></p>
11141 !! end
11142
11143 !! test
11144 Magic links: PMID (T67278)
11145 !! wikitext
11146 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
11147 !! html/php
11148 <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.
11149 </p>
11150 !! html/parsoid
11151 <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>
11152 !! end
11153
11154 !! test
11155 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
11156 !! wikitext
11157 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
11158 PMID
11159 1234
11160 !! html/php
11161 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11162 PMID
11163 1234
11164 </p>
11165 !! html/parsoid
11166 <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>
11167 PMID
11168 1234</p>
11169 !! end
11170
11171 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
11172 # since these are ExtLinkText, not MagicLinkText
11173 !! test
11174 Magic links: use appropriate serialization for "almost" magic links.
11175 !! wikitext
11176 X[[Special:BookSources/0978739256|foo]]
11177
11178 X[https://tools.ietf.org/html/rfc1234 foo]
11179 !! html/php
11180 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
11181 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
11182 </p>
11183 !! html/parsoid
11184 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11185 <p>X<a rel="mw:ExtLink" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
11186 !! end
11187
11188 !! test
11189 Magic links: All disabled (T47942)
11190 !! options
11191 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11192 !! wikitext
11193 ISBN 0-306-40615-2
11194 PMID 1234
11195 RFC 4321
11196 !! html/php
11197 <p>ISBN 0-306-40615-2
11198 PMID 1234
11199 RFC 4321
11200 </p>
11201 !! end
11202
11203 ###
11204 ### Templates
11205 ####
11206
11207 !! test
11208 Nonexistent template
11209 !! wikitext
11210 {{thistemplatedoesnotexist}}
11211 !! html
11212 <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>
11213 </p>
11214 !! end
11215
11216 !! test
11217 Template with invalid target containing tags
11218 !! wikitext
11219 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11220 !! html
11221 <p>{{a<b>b</b>|foo|a=b|a = b}}
11222 </p>
11223 !! end
11224
11225 !! test
11226 Template with invalid target containing unclosed tag
11227 !! wikitext
11228 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11229 !! html
11230 <p>{{a<b>|foo|a=b|a = b}}</b>
11231 </p>
11232 !! end
11233
11234 !! test
11235 Template with invalid target containing wikilink
11236 !! wikitext
11237 {{[[Main Page]]}}
11238 !! html/php
11239 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11240 </p>
11241 !! html/parsoid
11242 <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>
11243 !! end
11244
11245 !! test
11246 Template with just whitespace in it, T70421
11247 !! wikitext
11248 {{echo|{{ }}}}
11249 !! html/parsoid
11250 <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>
11251 !! end
11252
11253 !! article
11254 Template:test
11255 !! text
11256 This is a test template
11257 !! endarticle
11258
11259 !! test
11260 Simple template
11261 !! wikitext
11262 {{test}}
11263 !! html
11264 <p>This is a test template
11265 </p>
11266 !! end
11267
11268 !! test
11269 Template with explicit namespace
11270 !! wikitext
11271 {{Template:test}}
11272 !! html
11273 <p>This is a test template
11274 </p>
11275 !! end
11276
11277
11278 !! article
11279 Template:paramtest
11280 !! text
11281 This is a test template with parameter {{{param}}}
11282 !! endarticle
11283
11284 !! test
11285 Template parameter
11286 !! wikitext
11287 {{paramtest|param=foo}}
11288 !! html
11289 <p>This is a test template with parameter foo
11290 </p>
11291 !! end
11292
11293 !! article
11294 Template:paramtestnum
11295 !! text
11296 [[{{{1}}}|{{{2}}}]]
11297 !! endarticle
11298
11299 !! test
11300 Template unnamed parameter
11301 !! wikitext
11302 {{paramtestnum|Main Page|the main page}}
11303 !! html
11304 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11305 </p>
11306 !! end
11307
11308 !! article
11309 Template:templatesimple
11310 !! text
11311 (test)
11312 !! endarticle
11313
11314 !! article
11315 Template:templateredirect
11316 !! text
11317 #redirect [[Template:templatesimple]]
11318 !! endarticle
11319
11320 !! article
11321 Template:templateasargtestnum
11322 !! text
11323 {{{{{1}}}}}
11324 !! endarticle
11325
11326 !! article
11327 Template:templateasargtest
11328 !! text
11329 {{template{{{templ}}}}}
11330 !! endarticle
11331
11332 !! article
11333 Template:templateasargtest2
11334 !! text
11335 {{{{{templ}}}}}
11336 !! endarticle
11337
11338 !! test
11339 Template with template name as unnamed argument
11340 !! wikitext
11341 {{templateasargtestnum|templatesimple}}
11342 !! html
11343 <p>(test)
11344 </p>
11345 !! end
11346
11347 !! test
11348 Template with template name as argument
11349 !! wikitext
11350 {{templateasargtest|templ=simple}}
11351 !! html
11352 <p>(test)
11353 </p>
11354 !! end
11355
11356 !! test
11357 Template with template name as argument (2)
11358 !! wikitext
11359 {{templateasargtest2|templ=templatesimple}}
11360 !! html
11361 <p>(test)
11362 </p>
11363 !! end
11364
11365 !! article
11366 Template:templateasargtestdefault
11367 !! text
11368 {{{{{templ|templatesimple}}}}}
11369 !! endarticle
11370
11371 !! article
11372 Template:templa
11373 !! text
11374 '''templ'''
11375 !! endarticle
11376
11377 !! test
11378 Template with default value
11379 !! wikitext
11380 {{templateasargtestdefault}}
11381 !! html
11382 <p>(test)
11383 </p>
11384 !! end
11385
11386 !! test
11387 Template with default value (value set)
11388 !! wikitext
11389 {{templateasargtestdefault|templ=templa}}
11390 !! html
11391 <p><b>templ</b>
11392 </p>
11393 !! end
11394
11395 !! test
11396 Template redirect
11397 !! wikitext
11398 {{templateredirect}}
11399 !! html/php
11400 <p>(test)
11401 </p>
11402 !! html/parsoid
11403 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11404 !! end
11405
11406 !! test
11407 Template with argument in separate line
11408 !! wikitext
11409 {{ templateasargtest |
11410 templ = simple }}
11411 !! html
11412 <p>(test)
11413 </p>
11414 !! end
11415
11416 !! test
11417 Template with complex template as argument
11418 !! wikitext
11419 {{paramtest|
11420 param ={{ templateasargtest |
11421 templ = simple }}}}
11422 !! html
11423 <p>This is a test template with parameter (test)
11424 </p>
11425 !! end
11426
11427 !! test
11428 Templates with templated name
11429 !! wikitext
11430 {{{{echo|echo}}|foo}}
11431 {{{{echo|inner list}} }}
11432 !! html
11433 <p>foo
11434 </p>
11435 <ul><li> item 1</li></ul>
11436
11437 !! html/parsoid
11438 <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>
11439 <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>
11440 !! end
11441
11442 ## Regression test; the output here isn't really that interesting.
11443 !! test
11444 Templates with templated name and top level template args
11445 !! wikitext
11446 {{1{{2{{{3}}}|4=5}}}}
11447 !! html/parsoid
11448 <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>
11449 !! end
11450
11451 # Parsoid markup is deliberate "broken". This is an edge case.
11452 # See long comment in TemplateHandler.js:convertAttribsToString.
11453 !! test
11454 Templates with invalid templated targets
11455 !! wikitext
11456 {{echo
11457 {{echo|foo}}
11458 }}
11459 !! html/php
11460 <p>{{echo
11461 foo
11462 }}
11463 </p>
11464 !! html/parsoid
11465 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11466 foo }}</p>
11467 !! end
11468
11469 !! test
11470 Template with thumb image (with link in description)
11471 !! wikitext
11472 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11473 !! html/php
11474 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>
11475
11476 !! html+tidy
11477 <p>This is a test template with parameter</p>
11478 <div class="thumb tright">
11479 <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>
11480 <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>
11481 </div>
11482 </div>
11483 !! html/parsoid
11484 <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>
11485 !! end
11486
11487 !! article
11488 Template:complextemplate
11489 !! text
11490 {{{1}}} {{paramtest|
11491 param ={{{param}}}}}
11492 !! endarticle
11493
11494 !! test
11495 Template with complex arguments
11496 !! wikitext
11497 {{complextemplate|
11498 param ={{ templateasargtest |
11499 templ = simple }}|[[Template:complextemplate|link]]}}
11500 !! html
11501 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11502 </p>
11503 !! end
11504
11505 !! test
11506 T2553: link with two variables in a piped link
11507 !! wikitext
11508 {|
11509 |[[{{{1}}}|{{{2}}}]]
11510 |}
11511 !! html/php
11512 <table>
11513 <tr>
11514 <td>[[{{{1}}}|{{{2}}}]]
11515 </td></tr></table>
11516
11517 !! html/parsoid
11518 <table>
11519 <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>
11520 </tbody></table>
11521 !! end
11522
11523 # See: T2553
11524 !! test
11525 Abort table cell attribute parsing on wikilink
11526 !! wikitext
11527 {|
11528 | testing [[one|two]] | three || four
11529 | testing one two | three || four
11530 | testing="[[one|two]]" | three || four
11531 |}
11532 !! html/php
11533 <table>
11534 <tr>
11535 <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>
11536 <td> four
11537 </td>
11538 <td> three </td>
11539 <td> four
11540 </td>
11541 <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>
11542 <td> four
11543 </td></tr></table>
11544
11545 !! html/parsoid
11546 <table>
11547 <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>
11548 <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>
11549 <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>
11550 </tbody></table>
11551 !! end
11552
11553 !! test
11554 Don't abort table cell attribute parsing if wikilink is found in template arg
11555 !! wikitext
11556 {|
11557 | Test {{#tag:ref|One two "[[three]]" four}}
11558 |}
11559 !! html/parsoid
11560 <table>
11561 <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>
11562 </tbody></table>
11563 !! end
11564
11565 !! test
11566 Magic variable as template parameter
11567 !! wikitext
11568 {{paramtest|param={{SITENAME}}}}
11569 !! html
11570 <p>This is a test template with parameter MediaWiki
11571 </p>
11572 !! end
11573
11574 !! article
11575 Template:linktest
11576 !! text
11577 [[{{{param}}}|link]]
11578 !! endarticle
11579
11580 !! test
11581 Template parameter as link source
11582 !! wikitext
11583 {{linktest|param=Main Page}}
11584 !! html
11585 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11586 </p>
11587 !! end
11588
11589 !!article
11590 Template:paramtest2
11591 !! text
11592 including another template, {{paramtest|param={{{arg}}}}}
11593 !! endarticle
11594
11595 !! test
11596 Template passing argument to another template
11597 !! wikitext
11598 {{paramtest2|arg='hmm'}}
11599 !! html
11600 <p>including another template, This is a test template with parameter 'hmm'
11601 </p>
11602 !! end
11603
11604 !! article
11605 Template:Linktest2
11606 !! text
11607 Main Page
11608 !! endarticle
11609
11610 !! test
11611 Template as link source
11612 !! wikitext
11613 [[{{linktest2}}]]
11614
11615 [[{{linktest2}}|Main Page]]
11616
11617 [[{{linktest2}}]]Page
11618 !! html
11619 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11620 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11621 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11622 </p>
11623 !! end
11624
11625
11626 !! article
11627 Template:loop1
11628 !! text
11629 {{loop2}}
11630 !! endarticle
11631
11632 !! article
11633 Template:loop2
11634 !! text
11635 {{loop1}}
11636 !! endarticle
11637
11638 !! test
11639 Template infinite loop
11640 !! wikitext
11641 {{loop1}}
11642 !! html
11643 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11644 </p>
11645 !! end
11646
11647 !! test
11648 Template from main namespace
11649 !! wikitext
11650 {{:Main Page}}
11651 !! html
11652 <p>blah blah
11653 </p>
11654 !! end
11655
11656 !! article
11657 Template:table
11658 !! text
11659 {|
11660 | 1 || 2
11661 |-
11662 | 3 || 4
11663 |}
11664 !! endarticle
11665
11666 !! test
11667 T2529: Template with table, not included at beginning of line
11668 !! wikitext
11669 foo {{table}}
11670 !! html
11671 <p>foo
11672 </p>
11673 <table>
11674 <tr>
11675 <td> 1 </td>
11676 <td> 2
11677 </td></tr>
11678 <tr>
11679 <td> 3 </td>
11680 <td> 4
11681 </td></tr></table>
11682
11683 !! end
11684
11685 !! test
11686 T2523: Template shouldn't eat newline (or add an extra one before table)
11687 !! wikitext
11688 foo
11689 {{table}}
11690 !! html
11691 <p>foo
11692 </p>
11693 <table>
11694 <tr>
11695 <td> 1 </td>
11696 <td> 2
11697 </td></tr>
11698 <tr>
11699 <td> 3 </td>
11700 <td> 4
11701 </td></tr></table>
11702
11703 !! end
11704
11705 !! test
11706 T2041: Template parameters shown as broken links
11707 !! wikitext
11708 {{{parameter}}}
11709 !! html
11710 <p>{{{parameter}}}
11711 </p>
11712 !! end
11713
11714 !! test
11715 Template with targets containing wikilinks
11716 !! options
11717 parsoid=wt2html
11718 !! wikitext
11719 {{[[foo]]}}
11720
11721 {{[[{{echo|foo}}]]}}
11722
11723 {{{{echo|[[foo}}]]}}
11724 !! html/php
11725 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11726 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11727 </p><p>{{[[foo}}]]
11728 </p>
11729 !! html/parsoid
11730 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11731 <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>
11732 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11733 !! end
11734
11735 !! article
11736 Template:''
11737 !! text
11738 bar
11739 !! endarticle
11740
11741 !! test
11742 Templates: Double quotes as template target
11743 !! wikitext
11744 foo {{''}} baz
11745 !! html/php
11746 <p>foo bar baz
11747 </p>
11748 !! html/parsoid
11749 <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
11750 </p>
11751 !! end
11752
11753 ## This test is about making sure Parsoid's data-mw is well formed in the
11754 ## face of multiple templates with intersecting and overlapping ranges. The
11755 ## wikitext itself is wretched.
11756 !! test
11757 Templates with intersecting and overlapping ranges
11758 !! wikitext
11759 {|{{echo|
11760 <p>ha</p>}}
11761 {|{{echo|
11762 <p>ho</p>}}
11763 {{echo|{{!}}hi}}
11764 |}
11765 !! html/php+tidy
11766 <p>ha</p>
11767 <p>ho</p>
11768 <table>
11769 <tr>
11770 <td></td>
11771 </tr>
11772 <tr>
11773 <td>hi</td>
11774 </tr>
11775 </table>
11776 <table>
11777 <tr>
11778 <td></td>
11779 </tr>
11780 </table>
11781 !! html/parsoid
11782 <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":""}]]}'>
11783
11784 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11785
11786 <tbody><tr><td>hi</td></tr>
11787 </tbody></table>
11788 !! end
11789
11790 !! article
11791 Template:MSGNW test
11792 !! text
11793 ''None'' of '''this''' should be
11794 * interpreted
11795 but rather passed unmodified
11796 {{test}}
11797 <gallery>
11798 File:Foobar.jpg
11799 </gallery>
11800 <!-- comment -->
11801 !! endarticle
11802
11803 # hmm, fix this or just deprecate msgnw and document its behavior?
11804 !! test
11805 msgnw keyword
11806 !! wikitext
11807 {{msgnw:MSGNW test}}
11808 !! html/php
11809 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11810 &#42; interpreted
11811 &#32;but rather passed unmodified
11812 &#123;&#123;test&#125;&#125;
11813 &#60;gallery&#62;
11814 File:Foobar.jpg
11815 &#60;/gallery&#62;
11816 &#60;!-- comment --&#62;
11817 </p>
11818 !! end
11819
11820 !! test
11821 int keyword
11822 !! wikitext
11823 {{int:youhavenewmessages|lots of money|not!}}
11824 !! html
11825 <p>You have lots of money (not!).
11826 </p>
11827 !! end
11828
11829 !! test
11830 int keyword - non-existing message
11831 !! wikitext
11832 {{int:var}}
11833 !! html
11834 <p>⧼var⧽
11835 </p>
11836 !! end
11837
11838 !! article
11839 Template:Includes
11840 !! text
11841 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11842 !! endarticle
11843
11844 !! test
11845 <includeonly> and <noinclude> being included
11846 !! wikitext
11847 {{Includes}}
11848 !! html
11849 <p>Foobar
11850 </p>
11851 !! end
11852
11853 !! article
11854 Template:Includes2
11855 !! text
11856 <onlyinclude>Foo</onlyinclude>bar
11857 !! endarticle
11858
11859 !! test
11860 <onlyinclude> being included
11861 !! wikitext
11862 {{Includes2}}
11863 !! html
11864 <p>Foo
11865 </p>
11866 !! end
11867
11868
11869 !! article
11870 Template:Includes3
11871 !! text
11872 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
11873 !! endarticle
11874
11875 !! test
11876 <onlyinclude> and <includeonly> being included
11877 !! wikitext
11878 {{Includes3}}
11879 !! html
11880 <p>Foo
11881 </p>
11882 !! end
11883
11884 !! test
11885 <includeonly> and <noinclude> on a page
11886 !! wikitext
11887 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11888 !! html
11889 <p>Foozar
11890 </p>
11891 !! end
11892
11893 !! test
11894 Un-closed <noinclude>
11895 !! wikitext
11896 <noinclude>
11897 !! html
11898 !! end
11899
11900 !! test
11901 <onlyinclude> on a page
11902 !! wikitext
11903 <onlyinclude>Foo</onlyinclude>bar
11904 !! html
11905 <p>Foobar
11906 </p>
11907 !! end
11908
11909 !! test
11910 Un-closed <onlyinclude>
11911 !! wikitext
11912 <onlyinclude>
11913 !! html
11914 !! end
11915
11916 !!test
11917 Self-closed noinclude, includeonly, onlyinclude tags
11918 !! wikitext
11919 <noinclude />
11920 <includeonly />
11921 <onlyinclude />
11922 !! html
11923 <p><br />
11924 </p>
11925 !!end
11926
11927 !!test
11928 Unbalanced includeonly and noinclude tags
11929 !! wikitext
11930 {|
11931 |a</noinclude>
11932 |b</noinclude></noinclude>
11933 |c</noinclude></includeonly>
11934 |d</includeonly></includeonly>
11935 |}
11936 !! html
11937 <table>
11938 <tr>
11939 <td>a
11940 </td>
11941 <td>b
11942 </td>
11943 <td>c&lt;/includeonly&gt;
11944 </td>
11945 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
11946 </td></tr></table>
11947
11948 !!end
11949
11950 !! article
11951 Template:Includeonly section
11952 !! text
11953 <includeonly>
11954 ==Includeonly section==
11955 </includeonly>
11956 ==Section T-1==
11957 !!endarticle
11958
11959 !! test
11960 T8563: Edit link generation for section shown by <includeonly>
11961 !! wikitext
11962 {{includeonly section}}
11963 !! html
11964 <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>
11965 <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>
11966
11967 !! end
11968
11969 # Uses same input as the contents of [[Template:Includeonly section]]
11970 !! test
11971 T8563: Section extraction for section shown by <includeonly>
11972 !! options
11973 section=T-2
11974 !! wikitext
11975 <includeonly>
11976 ==Includeonly section==
11977 </includeonly>
11978 ==Section T-2==
11979 !! html
11980 ==Section T-2==
11981 !! end
11982
11983 !! test
11984 T8563: Edit link generation for section suppressed by <includeonly>
11985 !! wikitext
11986 <includeonly>
11987 ==Includeonly section==
11988 </includeonly>
11989 ==Section 1==
11990 !! html
11991 <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>
11992
11993 !! end
11994
11995 !! test
11996 T8563: Section extraction for section suppressed by <includeonly>
11997 !! options
11998 section=1
11999 !! wikitext
12000 <includeonly>
12001 ==Includeonly section==
12002 </includeonly>
12003 ==Section 1==
12004 !! html
12005 ==Section 1==
12006 !! end
12007
12008 !! test
12009 Un-closed <includeonly>
12010 !! wikitext
12011 <includeonly>
12012 !! html/php
12013 !! html/parsoid
12014 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}'/>
12015 !! end
12016
12017 ## We used to, but no longer wt2wt this test since the default serializer
12018 ## will normalize the include directives to serialize on their own line.
12019 ## Selser will take care of preserving formatting in scenarios where they
12020 ## intermingled with other wikitext.
12021 !! test
12022 Includes and comments at SOL
12023 !! options
12024 parsoid=wt2html,html2html
12025 !! wikitext
12026 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->== hu ==
12027
12028 <noinclude>
12029 some
12030 </noinclude>* stuff
12031 * here
12032
12033 <includeonly>can have stuff</includeonly>=== here ===
12034
12035 !! html/php
12036 <h2><span class="mw-headline" id="hu">hu</span></h2>
12037 <p>some
12038 </p>
12039 <ul><li> stuff</li>
12040 <li> here</li></ul>
12041 <h3><span class="mw-headline" id="here">here</span></h3>
12042
12043 !! html/parsoid
12044 <!-- 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>
12045
12046 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
12047 <p>some</p>
12048 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li> stuff</li>
12049 <li> here</li></ul>
12050
12051 <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>
12052
12053 !! end
12054
12055 # TODO: test with DOM fragment reuse!
12056 !! test
12057 Parsoid: DOM fragment reuse
12058 !! options
12059 parsoid=wt2wt,wt2html
12060 !! wikitext
12061 a{{echo|b<table></table>c}}d
12062
12063 a{{echo|b
12064 <table></table>
12065 c}}d
12066
12067 {{echo|a
12068
12069 <table></table>
12070
12071 b}}
12072 !! html
12073 <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>
12074
12075 <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">
12076 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
12077 </span><p about="#mwt2">cd</p>
12078
12079 <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">
12080
12081 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
12082
12083 </span><p about="#mwt3">b</p>
12084 !! end
12085
12086 !! test
12087 Parsoid: Merge double tds (T52603)
12088 !! options
12089 parsoid
12090 !! wikitext
12091 {|
12092 |{{echo|{{!}} foo}}
12093 |}
12094 !! html
12095 <table><tbody>
12096 <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>
12097 </tbody></table>
12098 !! end
12099
12100 !! test
12101 Parsoid: Merge double tds in nested transclusion content (T52603)
12102 !! options
12103 parsoid
12104 !! wikitext
12105 {{echo|<div>}}
12106 {|
12107 |{{echo|{{!}} foo}}
12108 |}
12109 {{echo|</div>}}
12110 !! html
12111 <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}}]}'>
12112 <table><tbody>
12113 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
12114 </tbody></table>
12115 </div>
12116 !! end
12117
12118 ###
12119 ### <includeonly> and <noinclude> in attributes
12120 ###
12121 !!test
12122 0. includeonly around the entire attribute
12123 !! wikitext
12124 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
12125 !! html
12126 <p><span id="v2">bar</span>
12127 </p>
12128 !!end
12129
12130 !!test
12131 1. includeonly in html attr key
12132 !! wikitext
12133 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
12134 !! html
12135 <p><span id="foo">bar</span>
12136 </p>
12137 !!end
12138
12139 !!test
12140 2. includeonly in html attr value
12141 !! wikitext
12142 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
12143 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
12144 !! html
12145 <p><span id="v1">bar</span>
12146 <span id="v1">bar</span>
12147 </p>
12148 !!end
12149
12150 !!test
12151 3. includeonly in part of an attr value
12152 !! wikitext
12153 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
12154 !! html
12155 <p><span style="color:red;">bar</span>
12156 </p>
12157 !!end
12158
12159 !!test
12160 4. includeonly in table attributes
12161 !! wikitext
12162 {|
12163 |- <noinclude>
12164 |-
12165 |a
12166 </noinclude>
12167 |- <includeonly>
12168 |-
12169 |b
12170 </includeonly>
12171 |}
12172 !! html
12173 <table>
12174
12175
12176 <tr>
12177 <td>a
12178 </td></tr>
12179 </table>
12180
12181 !!end
12182
12183 ###
12184 ### Preprocessor precedence tests
12185 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
12186 ###
12187 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
12188 !! test
12189 Preprocessor precedence 1: link is rightmost opening
12190 !! options
12191 parsoid=wt2html
12192 !! wikitext
12193 {{[[Foo|bar}}]]
12194
12195 But close-brace is not a valid character in a link title:
12196 {{[[Foo}}|bar]]
12197
12198 However, we can still tell this was handled as a link in the preprocessor:
12199 {{echo|[[Foo}}|bar]]|bat}}
12200 !! html/php
12201 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12202 </p><p>But close-brace is not a valid character in a link title:
12203 {{[[Foo}}|bar]]
12204 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12205 [[Foo}}|bar]]
12206 </p>
12207 !! html/parsoid
12208 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12209 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12210 <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>
12211 !! end
12212
12213 !! test
12214 Preprocessor precedence 2: template is rightmost opening
12215 !! options
12216 language=zh
12217 !! wikitext
12218 -{{echo|foo}-}}-
12219 !! html/php
12220 <p>-foo}--
12221 </p>
12222 !! html/parsoid
12223 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12224 !! end
12225
12226 !! test
12227 Preprocessor precedence 3: language converter is rightmost opening
12228 !! options
12229 language=zh
12230 parsoid=wt2html
12231 !! wikitext
12232 {{echo|hi}}
12233
12234 {{-{R|echo|hi}}}-
12235
12236 [[-{R|raw]]}-
12237 !! html/php
12238 <p>hi
12239 </p><p>{{echo|hi}}
12240 </p><p>[[raw]]
12241 </p>
12242 !! html/parsoid
12243 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12244 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12245 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12246 !! end
12247
12248 !! test
12249 Preprocessor precedence 4: left-most angle bracket
12250 !! options
12251 language=zh
12252 !! wikitext
12253 <!--{raw}-->
12254 !! html/php
12255 !! html/parsoid
12256 <!--{raw}-->
12257 !! end
12258
12259 !! article
12260 Template:Precedence5
12261 !! text
12262 {{{{{1}}}}}
12263 !! endarticle
12264
12265 !! test
12266 Preprocessor precedence 5: tplarg takes precedence over template
12267 !! wikitext
12268 {{Precedence5|Bullet}}
12269 !! html/php
12270 <ul><li> Bar</li></ul>
12271
12272 !! html/parsoid
12273 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li> Bar</li></ul>
12274 !! end
12275
12276 !! test
12277 Preprocessor precedence 6: broken link is rightmost opening
12278 !! options
12279 parsoid=wt2html
12280 !! wikitext
12281 {{echo|[[Foo}}
12282
12283 {{echo|[[Foo|bar|bat=baz}}
12284 !! html/php
12285 <p>{{echo|[[Foo}}
12286 </p><p>{{echo|[[Foo|bar|bat=baz}}
12287 </p>
12288 !! html/parsoid
12289 <p>{{echo|[[Foo}}</p>
12290 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12291 !! end
12292
12293 # This next test exposes a difference between PHP and Parsoid:
12294 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12295 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12296 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12297 # outer `[[Foo` extends until the `y]]`
12298 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12299 # intermediate result (after template expansion), and link processing
12300 # happens on this intermediate result, which moves the wikilink
12301 # boundary leftward to `[[Foo|Bar]]`
12302 # 2b) Parsoid works in a single step, so it's going to keep the
12303 # wikilink as extending to the `y]]`
12304 # 3a) Then PHP does linktrail processing which slurps up the trailing
12305 # `xy` inside the link.
12306 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12307 # `z` inside the link.
12308 # This is "correct" behavior. Parsoid's basic worldview is that the
12309 # `]]` inside the template shouldn't be allowed to leak out to affect
12310 # the surrounding wikilink. PHP may match Parsoid (in the future)
12311 # if you use {{#balance}} (T114445).
12312
12313 !! test
12314 Preprocessor precedence 7: broken template is rightmost opening
12315 !! options
12316 parsoid=wt2html
12317 !! wikitext
12318 [[Foo|{{echo|Bar]]
12319
12320 [[Foo|{{echo|Bar]]-x}}-y]]-z
12321
12322 Careful: linktrails can move the end of the wikilink:
12323 [[Foo|{{echo|y']]a}}l]]l
12324 !! html/php
12325 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12326 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12327 </p><p>Careful: linktrails can move the end of the wikilink:
12328 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12329 </p>
12330 !! html/parsoid
12331 <p>[[Foo|{{echo|Bar]]</p>
12332 <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>
12333 <p>Careful: linktrails can move the end of the wikilink:
12334 <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>
12335 !! end
12336
12337 !! test
12338 Preprocessor precedence 8: broken language converter is rightmost opening
12339 !! options
12340 language=zh
12341 !! wikitext
12342 [[Foo-{R|raw]]
12343 !! html
12344 <p>[[Foo-{R|raw]]
12345 </p>
12346 !! end
12347
12348 !! article
12349 Template:Preprocessor_precedence_9
12350 !! text
12351 ;4: {{{{1}}}}
12352 ;5: {{{{{2}}}}}
12353 ;6: {{{{{{3}}}}}}
12354 ;7: {{{{{{{4}}}}}}}
12355 !! endarticle
12356
12357 !! test
12358 Preprocessor precedence 9: groups of braces
12359 !! wikitext
12360 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12361 !! html/php
12362 <dl><dt>4</dt>
12363 <dd> {Four}</dd>
12364 <dt>5</dt>
12365 <dd> </dd></dl>
12366 <ul><li> Bar</li></ul>
12367 <dl><dt>6</dt>
12368 <dd> Four</dd>
12369 <dt>7</dt>
12370 <dd> {Bullet}</dd></dl>
12371
12372 !! html/parsoid
12373 <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}}]}'>
12374 <dt>4</dt>
12375 <dd>{Four}</dd>
12376 <dt>5</dt>
12377 <dd></dd>
12378 </dl><ul about="#mwt1">
12379 <li>Bar</li>
12380 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12381 <dt>6</dt>
12382 <dd>Four</dd>
12383 <dt>7</dt>
12384 <dd>{Bullet}</dd>
12385 </dl>
12386 !! end
12387
12388 !! article
12389 Template:Preprocessor_precedence_10
12390 !! text
12391 ;1: -{R|raw}-
12392 ;2: -{{Bullet}}-
12393 ;3: -{{{1}}}-
12394 ;4: -{{{{2}}}}-
12395 ;5: -{{{{{3}}}}}-
12396 ;6: -{{{{{{4}}}}}}-
12397 ;7: -{{{{{{{5}}}}}}}-
12398 !! endarticle
12399
12400 !! test
12401 Preprocessor precedence 10: groups of braces with leading dash
12402 !! options
12403 language=zh
12404 !! wikitext
12405 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12406 !! html/php
12407 <dl><dt>1</dt>
12408 <dd> raw</dd>
12409 <dt>2</dt>
12410 <dd> -</dd></dl>
12411 <ul><li> Bar-</li></ul>
12412 <dl><dt>3</dt>
12413 <dd> -Three-</dd>
12414 <dt>4</dt>
12415 <dd> raw2</dd>
12416 <dt>5</dt>
12417 <dd> -</dd></dl>
12418 <ul><li> Bar-</li></ul>
12419 <dl><dt>6</dt>
12420 <dd> -Three-</dd>
12421 <dt>7</dt>
12422 <dd> raw2</dd></dl>
12423
12424 !! html/parsoid
12425 <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}}]}'>
12426 <dt>1</dt>
12427 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12428 <dt>2</dt>
12429 <dd>-</dd>
12430 </dl><ul about="#mwt1">
12431 <li>Bar-</li>
12432 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12433 <dt>3</dt>
12434 <dd>-Three-</dd>
12435 <dt>4</dt>
12436 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12437 <dt>5</dt>
12438 <dd>-</dd>
12439 </dl><ul about="#mwt1">
12440 <li>Bar-</li>
12441 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12442 <dt>6</dt>
12443 <dd>-Three-</dd>
12444 <dt>7</dt>
12445 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12446 </dl>
12447 !! end
12448
12449 !! test
12450 Preprocessor precedence 11: found during visual diff testing
12451 !! wikitext
12452 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12453
12454 {{echo|-{{echo|-{{echo|x}}}}}}
12455
12456 {{echo|-{{echo|x}}}}
12457 !! html/php
12458 <p><span>-<span>-x</span></span>
12459 </p><p>--x
12460 </p><p>-x
12461 </p>
12462 !! html/parsoid
12463 <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>
12464
12465 <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>
12466
12467 <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>
12468 !! end
12469
12470 !! test
12471 Preprocessor precedence 12: broken language converter closed by brace.
12472 !! options
12473 parsoid=wt2html
12474 !! wikitext
12475 This form breaks the template, which is unfortunate:
12476 * {{echo|foo-{bar}bat}}
12477
12478 But if the broken language converter markup is inside an extension
12479 tag, nothing bad happens:
12480 * <nowiki>foo-{bar}bat</nowiki>
12481 * {{echo|<nowiki>foo-{bar}bat</nowiki>}}
12482 * <pre>foo-{bar}bat</pre>
12483 * {{echo|<pre>foo-{bar}bat</pre>}}
12484
12485 <tag>foo-{bar}bat</tag>
12486 {{echo|<tag>foo-{bar}bat</tag>}}
12487
12488 !! html/php+tidy
12489 <p>This form breaks the template, which is unfortunate:</p>
12490 <ul>
12491 <li>{{echo|foo-{bar}bat}}</li>
12492 </ul>
12493 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12494 <ul>
12495 <li>foo-{bar}bat</li>
12496 <li>foo-{bar}bat</li>
12497 <li>
12498 <pre>
12499 foo-{bar}bat
12500 </pre></li>
12501 <li>
12502 <pre>
12503 foo-{bar}bat
12504 </pre></li>
12505 </ul>
12506 <pre>
12507 'foo-{bar}bat'
12508 array (
12509 )
12510 </pre>
12511 <pre>
12512 'foo-{bar}bat'
12513 array (
12514 )
12515 </pre>
12516 !! html/parsoid
12517 <p>This form breaks the template, which is unfortunate:</p>
12518 <ul>
12519 <li>{{echo|foo-{bar}bat}}</li>
12520 </ul>
12521 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12522 <ul>
12523 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12524 <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>
12525 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12526 <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>
12527 </ul>
12528 <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>
12529 !! end
12530
12531 !! test
12532 Preprocessor precedence 13: broken language converter in external link
12533 !! options
12534 parsoid=wt2html
12535 !! wikitext
12536 * [http://example.com/-{foo Example in URL]
12537 * [http://example.com Example in -{link} description]
12538 * {{echo|[http://example.com/-{foo Breaks template, however]}}
12539 !! html/php+tidy
12540 <ul>
12541 <li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12542 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12543 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12544 </ul>
12545 !! html/parsoid
12546 <ul>
12547 <li><a rel="mw:ExtLink" href="http://example.com/-{foo">Example in URL</a></li>
12548 <li><a rel="mw:ExtLink" href="http://example.com">Example in -{link} description</a></li>
12549 <li>{{echo|<a rel="mw:ExtLink" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12550 </ul>
12551 !! end
12552
12553 !! test
12554 Preprocessor precedence 14: broken language converter in comment
12555 !! wikitext
12556 * <!--{{foo}}--> ...should be ok
12557 * <!---{{foo}}--> ...extra dashes
12558 * {{echo|foo<!-- -{bar} -->bat}} ...should be ok
12559 !! html/php+tidy
12560 <ul>
12561 <li>...should be ok</li>
12562 <li>...extra dashes</li>
12563 <li>foobat ...should be ok</li>
12564 </ul>
12565 !! html/parsoid
12566 <ul>
12567 <li><!--{{foo}}--> ...should be ok</li>
12568 <li><!--&#x2D;{{foo}}--> ...extra dashes</li>
12569 <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>
12570 </ul>
12571 !! end
12572
12573 !! test
12574 Preprocessor precedence 15: broken brace markup in headings
12575 !! config
12576 wgFragmentMode=[ 'html5', 'legacy' ]
12577 !! options
12578 parsoid=wt2html
12579 !! wikitext
12580 __NOTOC__ __NOEDITSECTION__
12581 ===1 foo[bar 1===
12582 1
12583 ===2 foo[[bar 2===
12584 2
12585 ===3 foo{bar 3===
12586 3
12587 ===4 foo{{bar 4===
12588 4
12589 ===5 foo{{{bar 5===
12590 5
12591 ===6 foo-{bar 6===
12592 6
12593 !! html/php+tidy
12594 <h3><span id="1_foo.5Bbar_1"></span><span class="mw-headline" id="1_foo[bar_1">1 foo[bar 1</span></h3>
12595 <p>1</p>
12596 <h3><span id="2_foo.5B.5Bbar_2"></span><span class="mw-headline" id="2_foo[[bar_2">2 foo[[bar 2</span></h3>
12597 <p>2</p>
12598 <h3><span id="3_foo.7Bbar_3"></span><span class="mw-headline" id="3_foo{bar_3">3 foo{bar 3</span></h3>
12599 <p>3</p>
12600 <h3><span id="4_foo.7B.7Bbar_4"></span><span class="mw-headline" id="4_foo{{bar_4">4 foo{{bar 4</span></h3>
12601 <p>4</p>
12602 <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>
12603 <p>5</p>
12604 <h3><span id="6_foo-.7Bbar_6"></span><span class="mw-headline" id="6_foo-{bar_6">6 foo-{bar 6</span></h3>
12605 <p>6</p>
12606 !! html/parsoid
12607 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/>
12608 <h3 id="1_foo[bar_1"><span id="1_foo.5Bbar_1" typeof="mw:FallbackId"></span>1 foo[bar 1</h3>
12609 <p>1</p>
12610 <h3 id="2_foo[[bar_2"><span id="2_foo.5B.5Bbar_2" typeof="mw:FallbackId"></span>2 foo[[bar 2</h3>
12611 <p>2</p>
12612 <h3 id="3_foo{bar_3"><span id="3_foo.7Bbar_3" typeof="mw:FallbackId"></span>3 foo{bar 3</h3>
12613 <p>3</p>
12614 <h3 id="4_foo{{bar_4"><span id="4_foo.7B.7Bbar_4" typeof="mw:FallbackId"></span>4 foo{{bar 4</h3>
12615 <p>4</p>
12616 <h3 id="5_foo{{{bar_5"><span id="5_foo.7B.7B.7Bbar_5" typeof="mw:FallbackId"></span>5 foo{{{bar 5</h3>
12617 <p>5</p>
12618 <h3 id="6_foo-{bar_6"><span id="6_foo-.7Bbar_6" typeof="mw:FallbackId"></span>6 foo-{bar 6</h3>
12619 <p>6</p>
12620 !! end
12621
12622 !! test
12623 Preprocessor precedence 16: matching closing braces to opening braces
12624 !! options
12625 language=zh
12626 parsoid=wt2html
12627 !! wikitext
12628 -{{{echo|foo}}bar}-
12629 !! html/php
12630 <p>foobar
12631 </p>
12632 !! html/parsoid
12633 <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>
12634 !! end
12635
12636 !! test
12637 Preprocessor precedence 17: template w/o target shouldn't prevent closing
12638 !! options
12639 parsoid=wt2html
12640 !! wikitext
12641 {{echo|hi {{}}}}
12642 !! html/php
12643 <p>hi {{}}
12644 </p>
12645 !! html/parsoid
12646 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi {{}}"}},"i":0}}]}'>hi {{}}</p>
12647 !! end
12648
12649 ###
12650 ### Token Stream Patcher tests
12651 ###
12652 ### These tests won't always pass wt2wt and other modes because
12653 ### on serialization, the table will be output on a new line.
12654 ### For now, we are blacklisting them, and using this to test selser.
12655 ###
12656
12657 !!test
12658 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12659 !!options
12660 parsoid=wt2html,wt2wt
12661 !!wikitext
12662 {{echo|}}{| width = '100%'
12663 |foo
12664 |}
12665 !!html/parsoid
12666 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12667 <tbody><tr><td>foo</td></tr>
12668 </tbody></table>
12669 !!end
12670
12671 ## We used to, but no longer wt2wt this test since the default serializer
12672 ## will normalize the include directives to serialize on their own line.
12673 ## Selser will take care of preserving formatting in scenarios where they
12674 ## intermingled with other wikitext.
12675 !!test
12676 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12677 !!options
12678 parsoid=wt2html
12679 !!wikitext
12680 <includeonly>a</includeonly>{| {{{b}}}
12681 |c
12682 |}
12683 !!html/parsoid
12684 <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":""}]]}'>
12685 <tbody><tr><td>c</td></tr>
12686 </tbody></table>
12687 !!end
12688
12689 !! test
12690 Table wikitext syntax outside wiki-tables
12691 !! wikitext
12692 a
12693 |+ not a caption
12694 ! not a table heading
12695 |- not a table row
12696 | not a table cell
12697 | class="foo bar" | baz
12698 b
12699 |}
12700 |-
12701 c
12702 !! html
12703 <p>a
12704 |+ not a caption
12705 ! not a table heading
12706 |- not a table row
12707 | not a table cell
12708 | class="foo bar" | baz
12709 b
12710 |}
12711 |-
12712 c
12713 </p>
12714 !! end
12715
12716 ###
12717 ### Testing parsing of templates where a template arg
12718 ### has the same name as the template itself.
12719 ###
12720
12721 !! article
12722 Template:quote
12723 !! text
12724 {{{quote|{{{1}}}}}}
12725 !! endarticle
12726
12727 !!test
12728 Templates: Template Name/Arg clash: 1. Use of positional param
12729 !! wikitext
12730 {{quote|foo}}
12731 !! html
12732 <p>foo
12733 </p>
12734 !!end
12735
12736 !!test
12737 Templates: Template Name/Arg clash: 2. Use of named param
12738 !! wikitext
12739 {{quote|quote=foo}}
12740 !! html
12741 <p>foo
12742 </p>
12743 !!end
12744
12745 !!test
12746 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12747 !! wikitext
12748 {{quote|quote}}
12749 !! html
12750 <p>quote
12751 </p>
12752 !!end
12753
12754 ###
12755 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12756 ###
12757
12758 !!test
12759 Templates: 1. Simple use
12760 !! wikitext
12761 {{echo|Foo}}
12762 !! html
12763 <p>Foo
12764 </p>
12765 !!end
12766
12767 !!test
12768 Templates: 2. Inside a block tag
12769 !! wikitext
12770 <div>{{echo|Foo}}</div>
12771 <blockquote>{{echo|Foo}}</blockquote>
12772 !! html
12773 <div>Foo</div>
12774 <blockquote>Foo</blockquote>
12775
12776 !! html+tidy
12777 <div>Foo</div>
12778 <blockquote>
12779 <p>Foo</p>
12780 </blockquote>
12781 !!end
12782
12783 !!test
12784 Templates: P-wrapping: 1a. Templates on consecutive lines
12785 !! wikitext
12786 {{echo|Foo}}
12787 {{echo|bar}}
12788 !! html
12789 <p>Foo
12790 bar
12791 </p>
12792 !!end
12793
12794 !!test
12795 Templates: P-wrapping: 1b. Templates on consecutive lines
12796 !! wikitext
12797 Foo
12798
12799 {{echo|bar}}
12800 {{echo|baz}}
12801 !! html
12802 <p>Foo
12803 </p><p>bar
12804 baz
12805 </p>
12806 !!end
12807
12808 !!test
12809 Templates: P-wrapping: 1c. Templates on consecutive lines
12810 !! wikitext
12811 {{echo|Foo}}
12812 {{echo|bar}} <div>baz</div>
12813 !! html
12814 <p>Foo
12815 </p>
12816 bar <div>baz</div>
12817
12818 !! html+tidy
12819 <p>Foo</p>
12820 <p>bar</p>
12821 <div>baz</div>
12822 !! end
12823
12824 !!test
12825 Templates: P-wrapping: 1d. Template preceded by comment-only line
12826 !!options
12827 parsoid
12828 !! wikitext
12829 <!-- foo -->
12830 {{echo|Bar}}
12831 !! html
12832 <!-- foo -->
12833
12834 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
12835 !!end
12836
12837 !!test
12838 Templates: Inline Text: 1. Multiple template uses
12839 !! wikitext
12840 {{echo|Foo}}bar{{echo|baz}}
12841 !! html
12842 <p>Foobarbaz
12843 </p>
12844 !!end
12845
12846 !!test
12847 Templates: Inline Text: 2. Back-to-back template uses
12848 !! wikitext
12849 {{echo|Foo}}{{echo|bar}}
12850 !! html
12851 <p>Foobar
12852 </p>
12853 !!end
12854
12855 !!test
12856 Templates: Block Tags: 1. Multiple template uses
12857 !! wikitext
12858 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
12859 !! html
12860 <div>Foo</div><div>bar</div><div>baz</div>
12861
12862 !!end
12863
12864 !!test
12865 Templates: Block Tags: 2. Back-to-back template uses
12866 !! wikitext
12867 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
12868 !! html
12869 <div>Foo</div><div>bar</div>
12870
12871 !!end
12872
12873 # This is an edge case relating to paragraph wrapping.
12874 !!test
12875 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
12876 !! wikitext
12877 {{echo|a
12878 b</p>}}
12879 !! html/parsoid
12880 <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
12881 b</p>
12882 !!end
12883
12884 !!test
12885 Templates: Links: 1. Simple example
12886 !! wikitext
12887 {{echo|[[Foo|bar]]}}
12888 !! html
12889 <p><a href="/wiki/Foo" title="Foo">bar</a>
12890 </p>
12891 !!end
12892
12893 !!test
12894 Templates: Links: 2. Generation of link href
12895 !! wikitext
12896 [[{{echo|Foo}}|bar]]
12897 !! html
12898 <p><a href="/wiki/Foo" title="Foo">bar</a>
12899 </p>
12900 !!end
12901
12902 !!test
12903 Templates: Links: 3. Generation of part of a link href
12904 !! wikitext
12905 [[Fo{{echo|o}}|bar]]
12906
12907 [[Foo{{echo|bar}}]]
12908
12909 [[Foo{{echo|bar}}baz]]
12910
12911 [[Foo{{echo|bar}}|bar]]
12912
12913 [[:Foo{{echo|bar}}]]
12914
12915 [[:Foo{{echo|bar}}|bar]]
12916 !! html
12917 <p><a href="/wiki/Foo" title="Foo">bar</a>
12918 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12919 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
12920 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12921 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12922 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12923 </p>
12924 !!end
12925
12926 !!test
12927 Templates: Links: 4. Multiple templates generating link href
12928 !! wikitext
12929 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
12930 !! html
12931 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12932 </p>
12933 !!end
12934
12935 !!test
12936 Templates: Links: 5. Generation of link text
12937 !! wikitext
12938 [[Foo|{{echo|bar}}]]
12939 !! html
12940 <p><a href="/wiki/Foo" title="Foo">bar</a>
12941 </p>
12942 !!end
12943
12944 !!test
12945 Templates: Links: 5. Nested templates (only outermost template should be marked)
12946 !! wikitext
12947 {{echo|[[{{echo|Foo}}|bar]]}}
12948 !! html
12949 <p><a href="/wiki/Foo" title="Foo">bar</a>
12950 </p>
12951 !!end
12952
12953 !!test
12954 Templates: HTML Tag: 1. Generation of HTML attr. key
12955 !! wikitext
12956 <div {{echo|style}}="color:red;">foo</div>
12957 !! html
12958 <div style="color:red;">foo</div>
12959
12960 !!end
12961
12962 !!test
12963 Templates: HTML Tag: 2. Generation of HTML attr. value
12964 !! wikitext
12965 <div style={{echo|'color:red;'}}>foo</div>
12966 !! html
12967 <div style="color:red;">foo</div>
12968
12969 !!end
12970
12971 !!test
12972 Templates: HTML Tag: 3. Generation of HTML attr key and value
12973 !! wikitext
12974 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
12975 !! html
12976 <div style="color:red;">foo</div>
12977
12978 !!end
12979
12980 !!test
12981 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
12982 !! wikitext
12983 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
12984 !! html
12985 <div title="This is a long title with just one piece templated">foo</div>
12986
12987 !!end
12988
12989 !!test
12990 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
12991 !! wikitext
12992 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
12993 !! html
12994 <div title="This is a long title with just one piece templated">foo</div>
12995
12996 !!end
12997
12998 !!test
12999 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
13000 !! wikitext
13001 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
13002 !! html
13003 <div title="This is a long title with just one piece templated">foo</div>
13004
13005 !!end
13006
13007 # SSS FIXME: While it is great we added support for all this,
13008 # do we want to make this part of the spec? Maybe we want to
13009 # deprecate this kind of usage in the future?
13010 !!test
13011 Templates: HTML Tag: 7. Generation of partial attribute key string
13012 !! wikitext
13013 <div st{{echo|yle}}="color:red;">foo</div>
13014 !! html
13015 <div style="color:red;">foo</div>
13016
13017 !!end
13018
13019 !! test
13020 Templates: HTML Tag: 8. Template-generated attribute (k=v)
13021 !! wikitext
13022 <div {{echo|1=id="v1"}}>bar</div>
13023 !! html
13024 <div id="v1">bar</div>
13025
13026 !!end
13027
13028 !! test
13029 Templates: HTML Tag: 9. Multiple template-generated attributes
13030 !! wikitext
13031 <div {{echo|1=id="v1" title="foo"}}>bar</div>
13032 !! html
13033 <div id="v1" title="foo">bar</div>
13034
13035 !!end
13036
13037 !! test
13038 Templates: Support for templates generating attributes and content
13039 !! wikitext
13040 {| {{mixed_attr_content_template}}
13041 |-
13042 |bar
13043 |}
13044 !! html/php
13045 <table style="color:red;" title="T48811">
13046
13047 <tr>
13048 <td>foo
13049 </td></tr>
13050 <tr>
13051 <td>bar
13052 </td></tr></table>
13053
13054 !! html/parsoid
13055 <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|}"]}'>
13056 <tbody><tr>
13057 <td>foo</td></tr>
13058 <tr>
13059 <td>bar</td></tr>
13060 </tbody></table>
13061 !!end
13062
13063 !! test
13064 1. Entities and nowikis inside templated attributes should be handled correctly
13065 !! wikitext
13066 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
13067 !! html/php
13068 <div style="background:#f9f9f9;">foo</div>
13069
13070 !! html/parsoid
13071 <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>
13072 !! end
13073
13074 !! test
13075 2. Entities and nowikis inside templated attributes should be handled correctly
13076 !! wikitext
13077 {|
13078 |{{table_attribs_3}}
13079 |}
13080 !! html/php
13081 <table>
13082 <tr>
13083 <td style="background:#f9f9f9;">Foo
13084 </td></tr></table>
13085
13086 !! html/parsoid
13087 <table>
13088 <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>
13089 </tbody></table>
13090 !! end
13091
13092 !! test
13093 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13094 !! wikitext
13095 {{tbl-start}}
13096 |{{table_attribs_3}}
13097 {{tbl-end}}
13098 !! html/php
13099 <table>
13100 <tr>
13101 <td style="background:#f9f9f9;">Foo
13102 </td></tr></table>
13103
13104 !! html/parsoid
13105 <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}}]}'>
13106 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
13107 </tbody></table>
13108 !! end
13109
13110 # T107622
13111 !! test
13112 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13113 !! wikitext
13114 {|
13115 | {{table_attribs_6}} hi
13116 |}
13117 !! html/php
13118 <table>
13119 <tr>
13120 <td style="background: red;"> hi
13121 </td></tr></table>
13122
13123 !! html/parsoid
13124 <table>
13125 <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>
13126 </tbody></table>
13127 !! end
13128
13129 !!test
13130 Templates: HTML Tables: 1. Generating start of a HTML table
13131 !! wikitext
13132 {{echo|<table><tr><td>foo</td>}}</tr></table>
13133 !! html
13134 <table><tr><td>foo</td></tr></table>
13135
13136 !!end
13137
13138 !!test
13139 Templates: HTML Tables: 2a. Generating middle of a HTML table
13140 !! wikitext
13141 <table><tr>{{echo|<td>foo</td>}}</tr></table>
13142 !! html
13143 <table><tr><td>foo</td></tr></table>
13144
13145 !!end
13146
13147 !!test
13148 Templates: HTML Tables: 2b. Generating middle of a HTML table
13149 !! wikitext
13150 <table>{{echo|<tr><td>foo</td></tr>}}</table>
13151 !! html
13152 <table><tr><td>foo</td></tr></table>
13153
13154 !!end
13155
13156 !!test
13157 Templates: HTML Tables: 3. Generating end of a HTML table
13158 !! wikitext
13159 <table><tr>{{echo|<td>foo</td></tr></table>}}
13160 !! html
13161 <table><tr><td>foo</td></tr></table>
13162
13163 !!end
13164
13165 !!test
13166 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13167 !! wikitext
13168 {{echo|<table>}}<tr><td>foo</td></tr></table>
13169 !! html
13170 <table><tr><td>foo</td></tr></table>
13171
13172 !!end
13173
13174 !!test
13175 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13176 !! wikitext
13177 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13178 !! html
13179 <table><tr><td>foo</td></tr></table>
13180
13181 !!end
13182
13183 !!test
13184 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13185 !! wikitext
13186 <table><tr>{{echo|<td>}}foo</td></tr></table>
13187 !! html
13188 <table><tr><td>foo</td></tr></table>
13189
13190 !!end
13191
13192 !!test
13193 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13194 !! wikitext
13195 <table><tr><td>foo{{echo|</td>}}</tr></table>
13196 !! html
13197 <table><tr><td>foo</td></tr></table>
13198
13199 !!end
13200
13201 !!test
13202 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13203 !! wikitext
13204 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13205 !! html
13206 <table><tr><td>foo</td></tr></table>
13207
13208 !!end
13209
13210 !!test
13211 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13212 !! wikitext
13213 <table><tr><td>foo</td></tr>{{echo|</table>}}
13214 !! html
13215 <table><tr><td>foo</td></tr></table>
13216
13217 !!end
13218
13219 !!test
13220 Templates: HTML Tables: 5. Proper fostering of categories from inside
13221 !!options
13222 parsoid=wt2html,wt2wt
13223 !! wikitext
13224 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13225 <!--Two categories (T52330)-->
13226 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13227 !! html
13228 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13229 <!--Two categories (T52330)-->
13230 <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>
13231 !!end
13232
13233 !!test
13234 Templates: Wiki Tables: 1a. Fostering of entire template content
13235 !! wikitext
13236 {|
13237 {{echo|a}}
13238 |}
13239 !! html
13240 <table>
13241 a
13242 <tr><td></td></tr></table>
13243
13244 !! html+tidy
13245 <p>a</p>
13246 <table>
13247 <tr>
13248 <td></td>
13249 </tr>
13250 </table>
13251 !! end
13252
13253 !!test
13254 Templates: Wiki Tables: 1b. Fostering of entire template content
13255 !! wikitext
13256 {|
13257 {{echo|<div>}}
13258 foo
13259 {{echo|</div>}}
13260 |}
13261 !! html
13262 <table>
13263 <div>
13264 <p>foo
13265 </p>
13266 </div>
13267 <tr><td></td></tr></table>
13268
13269 !! html+tidy
13270 <div>
13271 <p>foo</p>
13272 </div>
13273 <table>
13274 <tr>
13275 <td></td>
13276 </tr>
13277 </table>
13278 !! end
13279
13280 !!test
13281 Templates: Wiki Tables: 2. Fostering of partial template content
13282 !! wikitext
13283 {|
13284 {{echo|a
13285 <div>b</div>}}
13286 |}
13287 !! html
13288 <table>
13289 a
13290 <div>b</div>
13291 <tr><td></td></tr></table>
13292
13293 !! html+tidy
13294 <p>a</p>
13295 <div>b</div>
13296 <table>
13297 <tr>
13298 <td></td>
13299 </tr>
13300 </table>
13301 !! end
13302
13303 !!test
13304 Templates: Wiki Tables: 3. td-content via multiple templates
13305 !! wikitext
13306 {|
13307 {{echo|{{pipe}}a}}{{echo|b}}
13308 |}
13309 !! html
13310 <table>
13311 <tr>
13312 <td>ab
13313 </td></tr></table>
13314
13315 !!end
13316
13317 !!test
13318 Templates: Wiki Tables: 4. Templated tags, no content
13319 !! wikitext
13320 {{tbl-start}}
13321 {{tbl-end}}
13322 !! html
13323 <table>
13324 <tr><td></td></tr></table>
13325
13326 !!end
13327
13328 !!test
13329 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13330 !! wikitext
13331 {{tbl-start}}
13332 |foo
13333 {{tbl-end}}
13334 !! html
13335 <table>
13336 <tr>
13337 <td>foo
13338 </td></tr></table>
13339
13340 !!end
13341
13342 !!test
13343 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13344 !! wikitext
13345 {{tbl-start}}
13346 {{!}}foo
13347 {{tbl-end}}
13348 !! html
13349 <table>
13350 <tr>
13351 <td>foo
13352 </td></tr></table>
13353
13354 !!end
13355
13356 ## This test case is very specific to Parsoid's internals
13357 ## and is hence only tested for Parsoid's code. Parsoid uses
13358 ## a <meta> marker tag for <ref> tags and they are expanded
13359 ## much later. We are verifying that this <meta> tag usage
13360 ## doesn't prevent foster parenting.
13361 !!test
13362 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13363 !!wikitext
13364 {{PartialTable}}<ref>foo</ref>
13365 |}
13366
13367 <references />
13368 !!html/parsoid
13369 <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">
13370 <tbody>
13371 </tbody></table>
13372
13373 <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>
13374 !!end
13375
13376 !! test
13377 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13378 !! wikitext
13379 {{echo|
13380 {{{!}}
13381 {{!}}-}}
13382 <onlyinclude>
13383 |foo
13384 </onlyinclude>
13385 {{!}}}
13386 !! html/parsoid
13387 <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{{!}}}"]}'>
13388 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13389 <tbody><tr>
13390
13391 <td>foo
13392 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13393 </tbody></table>
13394 !! end
13395
13396 !!test
13397 Templates: Lists: Multi-line list-items via templates
13398 !! wikitext
13399 *{{echo|a {{nonexistent|
13400 unused}}}}
13401 *{{echo|b {{nonexistent|
13402 unused}}}}
13403 !! html
13404 <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>
13405 <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>
13406
13407 !!end
13408
13409 !!test
13410 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13411 !! wikitext
13412 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13413 !! html
13414 <p><i>ab</i>c<i>d</i>e
13415 </p>
13416 !!end
13417
13418 !!test
13419 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13420 (PHP parser generates misnested html)
13421 !! wikitext
13422 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13423 !! html/parsoid
13424 <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>
13425 !!end
13426
13427 !!test
13428 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13429 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13430 !! options
13431 parsoid=wt2html,wt2wt
13432 !! wikitext
13433 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13434 !! html
13435 <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>
13436 <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>
13437 <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>
13438 !!end
13439
13440 !!test
13441 Templates: Ugly nesting: 4. Divs opened/closed across templates
13442 !! wikitext
13443 a<div>b{{echo|c</div>d}}e
13444 !! html
13445 a<div>bc</div>de
13446
13447 !! html+tidy
13448 <p>a</p>
13449 <div>bc</div>
13450 <p>de</p>
13451 !! end
13452
13453 !!test
13454 Templates: Ugly templates: 1. Navbox template parses badly leading to table misnesting
13455 (Parsoid-centric)
13456 !! options
13457 parsoid
13458 !! wikitext
13459 {|
13460 |{{echo|foo</table>}}
13461 |bar
13462 |}
13463 !! html
13464 <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|}"]}'>
13465
13466 <tbody>
13467 <tr>
13468 <td>foo</td></tr></tbody></table><span about="#mwt1">
13469 </span><span about="#mwt1">|bar</span><span about="#mwt1">
13470 |}</span>
13471 !!end
13472
13473 !!test
13474 Templates: Ugly templates: 2. Navbox template parses badly leading to table misnesting
13475 (Parsoid-centric)
13476 !! options
13477 parsoid
13478 !! wikitext
13479 <table>
13480 <tr>
13481 <td>
13482 <table>
13483 <tr>
13484 <td>1. {{echo|foo </table>}}</td>
13485 <td> bar </td>
13486 <td>2. {{echo|baz </table>}}</td>
13487 </tr>
13488 <tr>
13489 <td>abc</td>
13490 </tr>
13491 </table>
13492 </td>
13493 </tr>
13494 <tr>
13495 <td>xyz</td>
13496 </tr>
13497 </table>
13498 !! html
13499 <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>"]}'>
13500 <tbody><tr>
13501 <td>
13502 <table>
13503 <tbody><tr>
13504 <td>1. foo </td></tr></tbody></table></td>
13505 <td> bar </td>
13506 <td>2. baz </td></tr></tbody></table><span about="#mwt2">
13507 </span><span about="#mwt2">
13508 </span><span about="#mwt2">
13509 </span><span about="#mwt2">abc</span><span about="#mwt2">
13510 </span><span about="#mwt2">
13511 </span><span about="#mwt2">
13512 </span><span about="#mwt2">
13513 </span><span about="#mwt2">
13514 </span><span about="#mwt2">
13515 </span><span about="#mwt2">xyz</span><span about="#mwt2">
13516 </span><span about="#mwt2">
13517 </span>
13518 !!end
13519
13520 !! test
13521 Templates: Ugly templates: 3. newline-only template parameter
13522 !! wikitext
13523 foo {{echo|
13524 }}
13525 !! html
13526 <p>foo
13527 </p>
13528 !! end
13529
13530 # This looks like a bug: a single newline triggers p/br for some reason.
13531 !! test
13532 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13533 !! wikitext
13534 {{echo|
13535 }}
13536 !! html
13537 <p><br />
13538 </p>
13539 !! end
13540
13541 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13542 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13543 !! test
13544 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13545 !! wikitext
13546 {{echo|<table>}}
13547 {{echo|<div>foo}}
13548 {{echo|</table>}}
13549 !! html/parsoid
13550 <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
13551 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13552 </table>
13553 !! end
13554
13555 # T66017 -- ugly wikitext with fostered content generates two template ranges
13556 # that are "identical" and generate nesting cycles in the algorithm
13557 !! test
13558 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13559 !! wikitext
13560 {{echo|<table><tr><td><table>}}
13561 {{echo|<div>}}
13562 {{echo|</div>}}
13563 !! html/parsoid
13564 <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"}'>
13565 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13566 </table></td></tr></tbody></table>
13567 !! end
13568
13569 !! test
13570 Templates: Parameters substituted at the top-level
13571 !! wikitext
13572 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13573
13574 {{{foo|bar|baz}}}
13575 !! html/php
13576 <p><i>who</i> me? <b>never!</b>
13577 </p><p>bar
13578 </p>
13579 !! html/parsoid
13580 <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>
13581
13582 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13583 !! end
13584
13585 !! test
13586 Templates: Param with empty arg in the final position
13587 !! wikitext
13588 {{{hi|}}}
13589 !! html/parsoid
13590 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13591 !! end
13592
13593 !!test
13594 Parser Functions: 1. Simple example
13595 !! wikitext
13596 {{uc:foo}}
13597 !! html
13598 <p>FOO
13599 </p>
13600 !!end
13601
13602 !!test
13603 Parser Functions: 2. Nested use (only outermost should be marked up)
13604 !! wikitext
13605 {{uc:{{lc:FOO}}}}
13606 !! html
13607 <p>FOO
13608 </p>
13609 !!end
13610
13611 ###
13612 ### Pre-save transform tests
13613 ###
13614 !! test
13615 pre-save transform: subst:
13616 !! options
13617 pst
13618 !! wikitext
13619 {{subst:test}}
13620 !! html/php
13621 This is a test template
13622 !! end
13623
13624 !! test
13625 pre-save transform: normal template
13626 !! options
13627 pst
13628 !! wikitext
13629 {{test}}
13630 !! html/php
13631 {{test}}
13632 !! end
13633
13634 !! test
13635 pre-save transform: nonexistent template
13636 !! options
13637 pst
13638 !! wikitext
13639 {{thistemplatedoesnotexist}}
13640 !! html/php
13641 {{thistemplatedoesnotexist}}
13642 !! end
13643
13644 !! test
13645 pre-save transform: subst magic variables
13646 !! options
13647 pst
13648 !! wikitext
13649 {{subst:SITENAME}}
13650 !! html/php
13651 MediaWiki
13652 !! end
13653
13654 # This is T2089, which I fixed. -- wtm
13655 !! test
13656 pre-save transform: subst: templates with parameters
13657 !! options
13658 pst
13659 !! wikitext
13660 {{subst:paramtest|param="something else"}}
13661 !! html/php
13662 This is a test template with parameter "something else"
13663 !! end
13664
13665 !! article
13666 Template:nowikitest
13667 !! text
13668 <nowiki>'''not wiki'''</nowiki>
13669 !! endarticle
13670
13671 !! test
13672 pre-save transform: nowiki in subst (T3188)
13673 !! options
13674 pst
13675 !! wikitext
13676 {{subst:nowikitest}}
13677 !! html/php
13678 <nowiki>'''not wiki'''</nowiki>
13679 !! end
13680
13681 !! article
13682 Template:commenttest
13683 !! text
13684 This template has <!-- a comment --> in it.
13685 !! endarticle
13686
13687 !! test
13688 pre-save transform: comment in subst (T3936)
13689 !! options
13690 pst
13691 !! wikitext
13692 {{subst:commenttest}}
13693 !! html/php
13694 This template has <!-- a comment --> in it.
13695 !! end
13696
13697 !! test
13698 pre-save transform: unclosed tag
13699 !! options
13700 pst
13701 !! wikitext
13702 <nowiki>'''not wiki'''
13703 !! html/php
13704 <nowiki>'''not wiki'''
13705 !! end
13706
13707 !! test
13708 pre-save transform: mixed tag case
13709 !! options
13710 pst
13711 !! wikitext
13712 <NOwiki>'''not wiki'''</noWIKI>
13713 !! html/php
13714 <NOwiki>'''not wiki'''</noWIKI>
13715 !! end
13716
13717 !! test
13718 pre-save transform: unclosed comment in <nowiki>
13719 !! options
13720 pst
13721 !! wikitext
13722 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13723 !! html/php
13724 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13725 !!end
13726
13727 # Leading @ in this template definition works around a limitation
13728 # in parsoid's parserTests which otherwise strips the <span> from the
13729 # result (confusing it for a template wrapper)
13730 !! article
13731 Template:dangerous
13732 !!text
13733 @<span onmouseover="alert('crap')">Oh no</span>
13734 !!endarticle
13735
13736 !!test
13737 (confirming safety of fix for subst T3936)
13738 !! wikitext
13739 {{Template:dangerous}}
13740 !! html
13741 <p>@<span>Oh no</span>
13742 </p>
13743 !! end
13744
13745 !! test
13746 pre-save transform: comment containing gallery (T7024)
13747 !! options
13748 pst
13749 !! wikitext
13750 <!-- <gallery>data</gallery> -->
13751 !! html/php
13752 <!-- <gallery>data</gallery> -->
13753 !!end
13754
13755 !! test
13756 pre-save transform: comment containing extension
13757 !! options
13758 pst
13759 !! wikitext
13760 <!-- <tag>data</tag> -->
13761 !! html/php
13762 <!-- <tag>data</tag> -->
13763 !!end
13764
13765 !! test
13766 pre-save transform: comment containing nowiki
13767 !! options
13768 pst
13769 !! wikitext
13770 <!-- <nowiki>data</nowiki> -->
13771 !! html/php
13772 <!-- <nowiki>data</nowiki> -->
13773 !!end
13774
13775 !! test
13776 pre-save transform: <noinclude> in subst (T5298)
13777 !! options
13778 pst
13779 !! wikitext
13780 {{subst:Includes}}
13781 !! html/php
13782 Foobar
13783 !! end
13784
13785 !! test
13786 pre-save transform: <onlyinclude> in subst (T5298)
13787 !! options
13788 pst
13789 !! wikitext
13790 {{subst:Includes2}}
13791 !! html/php
13792 Foo
13793 !! end
13794
13795 !! article
13796 Template:SubstTest
13797 !!text
13798 {{<includeonly>subst:</includeonly>Includes}}
13799 !! endarticle
13800
13801 !! article
13802 Template:SafeSubstTest
13803 !! text
13804 {{<includeonly>safesubst:</includeonly>Includes}}
13805 !! endarticle
13806
13807 !! test
13808 T24297: safesubst: works during PST
13809 !! options
13810 pst
13811 !! wikitext
13812 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
13813 !! html/php
13814 FoobarFoobar
13815 !! end
13816
13817 !! test
13818 T24297: safesubst: works during normal parse
13819 !! wikitext
13820 {{SafeSubstTest}}
13821 !! html
13822 <p>Foobar
13823 </p>
13824 !! end
13825
13826 !! test
13827 subst: does not work during normal parse
13828 !! wikitext
13829 {{SubstTest}}
13830 !! html
13831 <p>{{subst:Includes}}
13832 </p>
13833 !! end
13834
13835 !! test
13836 pre-save transform: context links ("pipe trick")
13837 !! options
13838 pst
13839 !! wikitext
13840 [[Article (context)|]]
13841 [[Bar:Article|]]
13842 [[:Bar:Article|]]
13843 [[Bar:Article (context)|]]
13844 [[:Bar:Article (context)|]]
13845 [[|Article]]
13846 [[|Article (context)]]
13847 [[Bar:X (Y) Z|]]
13848 [[:Bar:X (Y) Z|]]
13849 !! html/php
13850 [[Article (context)|Article]]
13851 [[Bar:Article|Article]]
13852 [[:Bar:Article|Article]]
13853 [[Bar:Article (context)|Article]]
13854 [[:Bar:Article (context)|Article]]
13855 [[Article]]
13856 [[Article (context)]]
13857 [[Bar:X (Y) Z|X (Y) Z]]
13858 [[:Bar:X (Y) Z|X (Y) Z]]
13859 !! end
13860
13861 !! test
13862 pre-save transform: context links ("pipe trick") with interwiki prefix
13863 !! options
13864 pst
13865 !! wikitext
13866 [[interwiki:Article|]]
13867 [[:interwiki:Article|]]
13868 [[interwiki:Bar:Article|]]
13869 [[:interwiki:Bar:Article|]]
13870 !! html/php
13871 [[interwiki:Article|Article]]
13872 [[:interwiki:Article|Article]]
13873 [[interwiki:Bar:Article|Bar:Article]]
13874 [[:interwiki:Bar:Article|Bar:Article]]
13875 !! end
13876
13877 !! test
13878 pre-save transform: context links ("pipe trick") with parens in title
13879 !! options
13880 pst title=[[Somearticle (context)]]
13881 !! wikitext
13882 [[|Article]]
13883 !! html/php
13884 [[Article (context)|Article]]
13885 !! end
13886
13887 !! test
13888 pre-save transform: context links ("pipe trick") with comma in title
13889 !! options
13890 pst title=[[Someplace, Somewhere]]
13891 !! wikitext
13892 [[|Otherplace]]
13893 [[Otherplace, Elsewhere|]]
13894 [[Otherplace, Elsewhere, Anywhere|]]
13895 !! html/php
13896 [[Otherplace, Somewhere|Otherplace]]
13897 [[Otherplace, Elsewhere|Otherplace]]
13898 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
13899 !! end
13900
13901 !! test
13902 pre-save transform: context links ("pipe trick") with parens and comma
13903 !! options
13904 pst title=[[Someplace (IGNORED), Somewhere]]
13905 !! wikitext
13906 [[|Otherplace]]
13907 [[Otherplace (place), Elsewhere|]]
13908 !! html/php
13909 [[Otherplace, Somewhere|Otherplace]]
13910 [[Otherplace (place), Elsewhere|Otherplace]]
13911 !! end
13912
13913 !! test
13914 pre-save transform: context links ("pipe trick") with comma and parens
13915 !! options
13916 pst title=[[Who, me? (context)]]
13917 !! wikitext
13918 [[|Yes, you.]]
13919 [[Me, Myself, and I (1937 song)|]]
13920 !! html/php
13921 [[Yes, you. (context)|Yes, you.]]
13922 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
13923 !! end
13924
13925 !! test
13926 pre-save transform: context links ("pipe trick") with namespace
13927 !! options
13928 pst title=[[Ns:Somearticle]]
13929 !! wikitext
13930 [[|Article]]
13931 !! html/php
13932 [[Ns:Article|Article]]
13933 !! end
13934
13935 !! test
13936 pre-save transform: context links ("pipe trick") with namespace and parens
13937 !! options
13938 pst title=[[Ns:Somearticle (context)]]
13939 !! wikitext
13940 [[|Article]]
13941 !! html/php
13942 [[Ns:Article (context)|Article]]
13943 !! end
13944
13945 !! test
13946 pre-save transform: context links ("pipe trick") with namespace and comma
13947 !! options
13948 pst title=[[Ns:Somearticle, Context, Whatever]]
13949 !! wikitext
13950 [[|Article]]
13951 !! html/php
13952 [[Ns:Article, Context, Whatever|Article]]
13953 !! end
13954
13955 !! test
13956 pre-save transform: context links ("pipe trick") with namespace, comma and parens
13957 !! options
13958 pst title=[[Ns:Somearticle, Context (context)]]
13959 !! wikitext
13960 [[|Article]]
13961 !! html/php
13962 [[Ns:Article (context)|Article]]
13963 !! end
13964
13965 !! test
13966 pre-save transform: context links ("pipe trick") with namespace, parens and comma
13967 !! options
13968 pst title=[[Ns:Somearticle (IGNORED), Context]]
13969 !! wikitext
13970 [[|Article]]
13971 !! html/php
13972 [[Ns:Article, Context|Article]]
13973 !! end
13974
13975 !! test
13976 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
13977 !! options
13978 pst
13979 !! wikitext
13980 [[Article(context)|]]
13981 [[Bar:Article(context)|]]
13982 [[:Bar:Article(context)|]]
13983 [[|Article(context)]]
13984 [[Bar:X(Y)Z|]]
13985 [[:Bar:X(Y)Z|]]
13986 !! html/php
13987 [[Article(context)|Article]]
13988 [[Bar:Article(context)|Article]]
13989 [[:Bar:Article(context)|Article]]
13990 [[Article(context)]]
13991 [[Bar:X(Y)Z|X(Y)Z]]
13992 [[:Bar:X(Y)Z|X(Y)Z]]
13993 !! end
13994
13995 !! test
13996 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
13997 !! options
13998 pst
13999 !! wikitext
14000 [[Article (context)|]]
14001 [[Bar:Article (context)|]]
14002 [[:Bar:Article (context)|]]
14003 [[|Article (context)]]
14004 [[Bar:X (Y) Z|]]
14005 [[:Bar:X (Y) Z|]]
14006 !! html/php
14007 [[Article (context)|Article]]
14008 [[Bar:Article (context)|Article]]
14009 [[:Bar:Article (context)|Article]]
14010 [[Article (context)]]
14011 [[Bar:X (Y) Z|X (Y) Z]]
14012 [[:Bar:X (Y) Z|X (Y) Z]]
14013 !! end
14014
14015 !! test
14016 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
14017 !! options
14018 pst
14019 !! wikitext
14020 [[Article(context)|]]
14021 [[Bar:Article(context)|]]
14022 [[:Bar:Article(context)|]]
14023 [[|Article(context)]]
14024 [[Bar:X(Y)Z|]]
14025 [[:Bar:X(Y)Z|]]
14026 !! html/php
14027 [[Article(context)|Article]]
14028 [[Bar:Article(context)|Article]]
14029 [[:Bar:Article(context)|Article]]
14030 [[Article(context)]]
14031 [[Bar:X(Y)Z|X(Y)Z]]
14032 [[:Bar:X(Y)Z|X(Y)Z]]
14033 !! end
14034
14035 !! test
14036 pre-save transform: context links ("pipe trick") with commas (T23660)
14037 !! options
14038 pst
14039 !! wikitext
14040 [[Article (context), context|]]
14041 [[Article (context),context|]]
14042 [[Bar:Article (context), context|]]
14043 [[Bar:Article (context),context|]]
14044 [[:Bar:Article (context), context|]]
14045 [[:Bar:Article (context),context|]]
14046 !! html/php
14047 [[Article (context), context|Article]]
14048 [[Article (context),context|Article]]
14049 [[Bar:Article (context), context|Article]]
14050 [[Bar:Article (context),context|Article]]
14051 [[:Bar:Article (context), context|Article]]
14052 [[:Bar:Article (context),context|Article]]
14053 !! end
14054
14055 !! test
14056 Parsoid: backwards pipe trick
14057 !! wikitext
14058 [[|'''bar''']]
14059 !! html/php
14060 <p>[[|<b>bar</b>]]
14061 </p>
14062 !! html/parsoid
14063 <p>[[|<b>bar</b>]]</p>
14064 !! end
14065
14066 !! test
14067 pre-save transform: trim trailing empty lines
14068 !! options
14069 pst
14070 !! wikitext
14071 Empty lines are trimmed
14072
14073
14074
14075
14076 !! html/php
14077 Empty lines are trimmed
14078 !! end
14079
14080 !! test
14081 pre-save transform: Signature expansion
14082 !! options
14083 pst
14084 !! wikitext
14085 * ~~~
14086 * ~~~~
14087 * ~~~~~
14088 * <noinclude>~~~</noinclude>
14089 * <includeonly>~~~</includeonly>
14090 * <onlyinclude>~~~</onlyinclude>
14091 !! html/php
14092 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
14093 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14094 * 00:02, 1 January 1970 (UTC)
14095 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
14096 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
14097 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
14098 !! end
14099
14100
14101 !! test
14102 ParserOutput flags from signature expansion (T84843)
14103 !! options
14104 pst
14105 showflags
14106 !! wikitext
14107 ~~~~
14108 !! html/php
14109 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14110 flags=user-signature
14111 !! end
14112
14113
14114 !! test
14115 pre-save transform: Signature expansion in nowiki tags (T2093)
14116 !! options
14117 pst disabled
14118 !! wikitext
14119 Shall not expand:
14120
14121 <nowiki>~~~~</nowiki>
14122
14123 <includeonly><nowiki>~~~~</nowiki></includeonly>
14124
14125 <noinclude><nowiki>~~~~</nowiki></noinclude>
14126
14127 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14128
14129 {{subst:Foo}} shall be converted to FOO
14130
14131 As well as inside noinclude/onlyinclude
14132 <noinclude>{{subst:Foo}}</noinclude>
14133 <onlyinclude>{{subst:Foo}}</onlyinclude>
14134
14135 But not inside includeonly
14136 <includeonly>{{subst:Foo}}</includeonly>
14137 !! html/php
14138 Shall not expand:
14139
14140 <nowiki>~~~~</nowiki>
14141
14142 <includeonly><nowiki>~~~~</nowiki></includeonly>
14143
14144 <noinclude><nowiki>~~~~</nowiki></noinclude>
14145
14146 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14147
14148 FOO shall be converted to FOO
14149
14150 As well as inside noinclude/onlyinclude
14151 <noinclude>FOO</noinclude>
14152 <onlyinclude>FOO</onlyinclude>
14153
14154 But not inside includeonly
14155 <includeonly>{{subst:Foo}}</includeonly>
14156 !! end
14157
14158 !! test
14159 Parsoid: Recognize nowiki with trailing space in tags
14160 !! options
14161 parsoid=wt2html
14162 !! wikitext
14163 <nowiki ><div>[[foo]]</nowiki >
14164
14165 a<nowiki / >b
14166
14167 c<nowiki />d
14168
14169 e<nowiki/ >f
14170 !! html
14171 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14172 <p>ab</p>
14173 <p>cd</p>
14174 <p>ef</p>
14175 !! end
14176
14177 !! test
14178 Parsoid: Recognize nowiki with odd capitalization
14179 !! options
14180 parsoid=wt2html
14181 !! wikitext
14182 <noWikI ><div>[[foo]]</Nowiki >
14183 !! html
14184 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14185 !! end
14186
14187
14188 !! test
14189 Parsoid: Escape nowiki with trailing space in tags
14190 !! options
14191 parsoid=html2wt
14192 !! html/parsoid
14193 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14194 <p>a&lt;nowiki /&gt;b</p>
14195 <p>c&lt;nowiki/ &gt;d</p>
14196 !! wikitext
14197 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14198
14199 a&lt;nowiki /&gt;b
14200
14201 c&lt;nowiki/ &gt;d
14202 !! end
14203
14204 !! test
14205 Parsoid: Escape weird noWikI capitalizations
14206 !! options
14207 parsoid=html2wt
14208 !! html/parsoid
14209 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14210 !! wikitext
14211 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14212 !! end
14213
14214 ###
14215 ### Message transform tests
14216 ###
14217 !! test
14218 message transform: magic variables
14219 !! options
14220 msg
14221 !! wikitext
14222 {{SITENAME}}
14223 !! html
14224 MediaWiki
14225 !! end
14226
14227 !! test
14228 message transform: should not transform wiki markup
14229 !! options
14230 msg
14231 !! wikitext
14232 ''test''
14233 !! html
14234 ''test''
14235 !! end
14236
14237 !! test
14238 message transform: <noinclude> in transcluded template (T6926)
14239 !! options
14240 msg
14241 !! wikitext
14242 {{Includes}}
14243 !! html
14244 Foobar
14245 !! end
14246
14247 !! test
14248 message transform: <onlyinclude> in transcluded template (T6926)
14249 !! options
14250 msg
14251 !! wikitext
14252 {{Includes2}}
14253 !! html
14254 Foo
14255 !! end
14256
14257 !! test
14258 {{#special:}} page name, known
14259 !! options
14260 msg
14261 !! wikitext
14262 {{#special:Recentchanges}}
14263 !! html
14264 Special:RecentChanges
14265 !! end
14266
14267 !! test
14268 {{#special:}} page name with subpage, known
14269 !! options
14270 msg
14271 !! wikitext
14272 {{#special:Recentchanges/param}}
14273 !! html
14274 Special:RecentChanges/param
14275 !! end
14276
14277 !! test
14278 {{#special:}} page name, unknown
14279 !! options
14280 msg
14281 !! wikitext
14282 {{#special:foobar nonexistent}}
14283 !! html
14284 Special:Foobar nonexistent
14285 !! end
14286
14287 !! test
14288 {{#speciale:}} page name, known
14289 !! options
14290 msg
14291 !! wikitext
14292 {{#speciale:Recentchanges}}
14293 !! html
14294 Special:RecentChanges
14295 !! end
14296
14297 !! test
14298 {{#speciale:}} page name with subpage, known
14299 !! options
14300 msg
14301 !! wikitext
14302 {{#speciale:Recentchanges/param}}
14303 !! html
14304 Special:RecentChanges/param
14305 !! end
14306
14307 !! test
14308 {{#speciale:}} page name, unknown
14309 !! options
14310 msg
14311 !! wikitext
14312 {{#speciale:foobar nonexistent}}
14313 !! html
14314 Special:Foobar_nonexistent
14315 !! end
14316
14317 ###
14318 ### Images
14319 ###
14320 ### For Parsoid-specific tests, see
14321 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14322
14323 !! test
14324 Simple image
14325 !! options
14326 parsoid=wt2html,wt2wt,html2html
14327 !! wikitext
14328 [[Image:foobar.jpg]]
14329 !! html/php
14330 <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>
14331 </p>
14332 !! html/parsoid
14333 <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>
14334 !! end
14335
14336 !! test
14337 Serialize simple image with span wrapper
14338 !! options
14339 parsoid=html2wt
14340 !! html/parsoid
14341 <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>
14342 !! wikitext
14343 [[File:Foobar.jpg]]
14344 !! end
14345
14346 !! test
14347 Simple image (using File: namespace, now canonical)
14348 !! wikitext
14349 [[File:Foobar.jpg]]
14350 !! html/php
14351 <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>
14352 </p>
14353 !! html/parsoid
14354 <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>
14355 !! end
14356
14357 !! test
14358 Right-aligned image
14359 !! wikitext
14360 [[File:Foobar.jpg|right]]
14361 !! html/php
14362 <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>
14363
14364 !! html/parsoid
14365 <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>
14366 !! end
14367
14368 !! test
14369 Image with caption
14370 !! wikitext
14371 [[File:Foobar.jpg|right|Caption text]]
14372 !! html/php
14373 <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>
14374
14375 !! html/parsoid
14376 <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>
14377 !! end
14378
14379 !! test
14380 Image with caption, T55312 #1
14381 !! wikitext
14382 [[File:Foobar.jpg|right|Caption page stuff]]
14383 !! html/php
14384 <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>
14385
14386 !! html/parsoid
14387 <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>
14388 !! end
14389
14390 !! test
14391 Image with caption, T55312 #2
14392 !! wikitext
14393 [[File:Foobar.jpg|right|Caption page=]]
14394 !! html/php
14395 <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>
14396
14397 !! html/parsoid
14398 <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>
14399 !! end
14400
14401 !! test
14402 Image with caption, T55312 #3
14403 !! wikitext
14404 [[File:Foobar.jpg|right|Caption page=stuff]]
14405 !! html/php
14406 <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>
14407
14408 !! html/parsoid
14409 <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>
14410 !! end
14411
14412 !! test
14413 Image caption with pipe entity
14414 !! wikitext
14415 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14416 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14417 !! html/php
14418 <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>
14419 <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>
14420
14421 !! html/parsoid
14422 <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>
14423 <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>
14424 !! end
14425
14426 !! test
14427 Allow empty links in image captions (T62753)
14428 !! options
14429 thumbsize=220
14430 !! wikitext
14431 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14432 [[]]
14433 [[Link2]]
14434 ]]
14435 !! html/php
14436 <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>
14437
14438 !! html/parsoid
14439 <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>
14440 [[]]
14441 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14442 </figcaption></figure>
14443 !! end
14444
14445 !! test
14446 Titles in unlinked images (T23454)
14447 !! wikitext
14448 [[File:Foobar.jpg|link=|stuff]]
14449 !! html/php
14450 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
14451 </p>
14452 !! end
14453
14454 !! test
14455 Link with empty target
14456 !! wikitext
14457 [[]]
14458 !! html
14459 <p>[[]]
14460 </p>
14461 !! end
14462
14463 !! test
14464 Image with link trail
14465 !! wikitext
14466 Linktrails should not work for images: [[File:Foobar.jpg]]s
14467 !! html/php
14468 <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
14469 </p>
14470 !! html/parsoid
14471 <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>
14472 !! end
14473
14474 !! test
14475 Image with empty attribute
14476 !! options
14477 parsoid=wt2html,wt2wt,html2html
14478 !! wikitext
14479 [[File:Foobar.jpg|right||Caption text]]
14480 !! html/php
14481 <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>
14482
14483 !! html/parsoid
14484 <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>
14485 !! end
14486
14487 !! test
14488 1. Block image with individual attributes from templates
14489 !! wikitext
14490 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14491 !! html/php
14492 <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>
14493
14494 !! html/parsoid
14495 <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>
14496 !! end
14497
14498 !! test
14499 2. Block Image with individual attributes from templates
14500 !! wikitext
14501 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14502 !! html/php
14503 <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>
14504
14505 !! html/parsoid
14506 <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>
14507 !! end
14508
14509 !! test
14510 3. Inline image with individual attributes from templates
14511 !! wikitext
14512 [[File:Foobar.jpg|{{echo|50px}}]]
14513 !! html/php
14514 <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>
14515 </p>
14516 !! html/parsoid
14517 <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>
14518 !! end
14519
14520 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14521 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14522 !! test
14523 Image with multiple attributes from the same template
14524 !! wikitext
14525 [[File:Foobar.jpg|{{image_attribs}}]]
14526 !! html/php
14527 <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>
14528
14529 !! html/parsoid
14530 <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>
14531 !! end
14532
14533 !! test
14534 Image with link tails
14535 !! options
14536 thumbsize=220
14537 !! wikitext
14538 123[[File:Foobar.jpg]]456
14539 123[[File:Foobar.jpg|right]]456
14540 123[[File:Foobar.jpg|thumb]]456
14541 !! html/php
14542 <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
14543 </p>
14544 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
14545 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
14546
14547 !! html/php+tidy
14548 <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</p>
14549 <p>123</p>
14550 <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>
14551 <p>456 123</p>
14552 <div class="thumb tright">
14553 <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>
14554 <div class="thumbcaption">
14555 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
14556 </div>
14557 </div>
14558 </div>
14559 <p>456</p>
14560 !! html/parsoid
14561 <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>
14562 <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>
14563 <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>
14564 !! end
14565
14566 !! test
14567 Image with multiple captions -- only last one is accepted
14568 !! wikitext
14569 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14570 !! html/php
14571 <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>
14572
14573 !! html/parsoid
14574 <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>
14575 !! end
14576
14577 !! test
14578 Image with multiple widths -- use last
14579 !! wikitext
14580 [[File:Foobar.jpg|200px|300px|caption]]
14581 !! html/php
14582 <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>
14583 </p>
14584 !! html/parsoid
14585 <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>
14586 !! end
14587
14588 !! test
14589 Image with multiple alignments -- use first (T50664)
14590 !! options
14591 thumbsize=220
14592 !! wikitext
14593 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14594
14595 [[File:Foobar.jpg|middle|text-top|caption]]
14596 !! html/php
14597 <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>
14598 <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>
14599 </p>
14600 !! html/parsoid
14601 <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>
14602 <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>
14603 !! end
14604
14605 !! test
14606 Image with width attribute at different positions
14607 !! wikitext
14608 [[File:Foobar.jpg|200px|right|Caption]]
14609 [[File:Foobar.jpg|right|200px|Caption]]
14610 [[File:Foobar.jpg|right|Caption|200px]]
14611 !! html/php
14612 <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>
14613 <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>
14614 <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>
14615
14616 !! html/parsoid
14617 <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>
14618 <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>
14619 <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>
14620 !! end
14621
14622 # a sad bit of backward-compatibility
14623 !! test
14624 Image with size specified with pxpx (T15500, T53628)
14625 !! options
14626 parsoid=wt2html,wt2wt,html2html
14627 !! wikitext
14628 [[File:Foobar.jpg|20pxpx]]
14629 [[File:Foobar.jpg|200x20pxpx]]
14630 !! html/php
14631 <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>
14632 <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>
14633 </p>
14634 !! html/parsoid
14635 <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>
14636 !! end
14637
14638 !! test
14639 Image with link parameter, wiki target
14640 !! wikitext
14641 [[File:Foobar.jpg|link=Main Page]]
14642 !! html/php
14643 <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>
14644 </p>
14645 !! html/parsoid
14646 <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>
14647 !! end
14648
14649 # parsoid T51293 (part 1)
14650 !! test
14651 Image with link parameter, URL target
14652 !! wikitext
14653 [[File:Foobar.jpg|link=http://example.com/]]
14654 !! html/php
14655 <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>
14656 </p>
14657 !! html/parsoid
14658 <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>
14659 !! end
14660
14661 # parsoid T51293 (part 2)
14662 !! test
14663 Image with link parameter, protocol-less URL target
14664 !! wikitext
14665 [[File:Foobar.jpg|link=//example.com/]]
14666 !! html/php
14667 <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>
14668 </p>
14669 !! html/parsoid
14670 <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>
14671 !! end
14672
14673 !! test
14674 Escaping non-block captions (T107435)
14675 !! options
14676 parsoid={
14677 "modes": ["wt2wt"],
14678 "changes": [
14679 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14680 ]
14681 }
14682 !! wikitext
14683 [[Image:Foobar.jpg|caption]]
14684 !! wikitext/edited
14685 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14686 !! end
14687
14688 # wgExternalLinkTarget not supported by Parsoid
14689 !! test
14690 Image with link parameter, wgExternalLinkTarget
14691 !! wikitext
14692 [[Image:foobar.jpg|link=http://example.com/]]
14693 !! config
14694 wgExternalLinkTarget='foobar'
14695 !! html/php
14696 <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>
14697 </p>
14698 !! end
14699
14700 !! test
14701 Image with link parameter, wgNoFollowLinks set to false
14702 !! wikitext
14703 [[Image:foobar.jpg|link=http://example.com/]]
14704 !! config
14705 wgNoFollowLinks=false
14706 !! html
14707 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14708 </p>
14709 !! end
14710
14711 !! test
14712 Image with link parameter, wgNoFollowDomainExceptions
14713 !! wikitext
14714 [[Image:foobar.jpg|link=http://example.com/]]
14715 !! config
14716 wgNoFollowDomainExceptions='example.com'
14717 !! html
14718 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14719 </p>
14720 !! end
14721
14722 # wgExternalLinkTarget not supported by Parsoid
14723 !! test
14724 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14725 !! wikitext
14726 [[Image:foobar.jpg|link=http://example.com/|Title]]
14727 !! config
14728 wgExternalLinkTarget='foobar'
14729 !! html/php
14730 <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>
14731 </p>
14732 !! end
14733
14734 !! test
14735 Image with empty link parameter
14736 !! wikitext
14737 [[File:Foobar.jpg|link=]]
14738 !! html/php
14739 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14740 </p>
14741 !! html/parsoid
14742 <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>
14743 !! end
14744
14745 !! test
14746 Image with link parameter (wiki target) and unnamed parameter
14747 !! wikitext
14748 [[File:Foobar.jpg|link=Main_Page|Title]]
14749 !! html/php
14750 <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>
14751 </p>
14752 !! html/parsoid
14753 <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>
14754 !! end
14755
14756 !! test
14757 Image with link parameter (URL target) and unnamed parameter
14758 !! wikitext
14759 [[File:Foobar.jpg|link=http://example.com/|Title]]
14760 !! html/php
14761 <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>
14762 </p>
14763 !! html/parsoid
14764 <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>
14765 !! end
14766
14767 !! test
14768 Thumbnail image with link parameter
14769 !! options
14770 thumbsize=220
14771 parsoid=wt2html,wt2wt,html2html
14772 !! wikitext
14773 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14774 !! html/php
14775 <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>
14776
14777 !! html/parsoid
14778 <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>
14779 !! end
14780
14781 !! test
14782 Manually-specified thumbnail image
14783 !! options
14784 thumbsize=220
14785 !! wikitext
14786 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14787 !! html/php
14788 <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>
14789
14790 !! html/parsoid
14791 <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>
14792 !! end
14793
14794 !! test
14795 Manually-specified thumbnail image with explicit link to wiki page
14796 !! options
14797 thumbsize=220
14798 parsoid=wt2html,wt2wt,html2html
14799 !! wikitext
14800 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14801 !! html/php
14802 <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>
14803
14804 !! html/parsoid
14805 <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>
14806 !! end
14807
14808 !! test
14809 Manually-specified thumbnail image with explicit link to url
14810 !! options
14811 thumbsize=220
14812 parsoid=wt2html,wt2wt,html2html
14813 !! wikitext
14814 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14815 !! html/php
14816 <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>
14817
14818 !! html/parsoid
14819 <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>
14820 !! end
14821
14822 !! test
14823 Manually-specified thumbnail image with explicit no link
14824 !! options
14825 thumbsize=220
14826 parsoid=wt2html,wt2wt,html2html
14827 !! wikitext
14828 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14829 !! html/php
14830 <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>
14831
14832 !! html/parsoid
14833 <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>
14834 !! end
14835
14836 !! test
14837 Manually-specified thumbnail image with explicit link and alt text
14838 !! options
14839 thumbsize=220
14840 parsoid=wt2html,wt2wt,html2html
14841 !! wikitext
14842 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14843 !! html/php
14844 <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>
14845
14846 !! html/parsoid
14847 <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>
14848 !! end
14849
14850 !! test
14851 Image with frame and link
14852 !! options
14853 parsoid=wt2html,wt2wt,html2html
14854 !! wikitext
14855 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14856 !! html/php
14857 <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>
14858
14859 !! html/parsoid
14860 <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>
14861 !! end
14862
14863 !! test
14864 Image with frame and link and explicit alt
14865 !! options
14866 parsoid=wt2html,wt2wt,html2html
14867 !! wikitext
14868 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
14869 !! html/php
14870 <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>
14871
14872 !! html/parsoid
14873 <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>
14874 !! end
14875
14876 !! test
14877 Image with wiki markup in implicit alt
14878 !! wikitext
14879 [[Image:Foobar.jpg|testing '''bold''' in alt]]
14880
14881 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
14882 !! html/php
14883 <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>
14884 </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>
14885 </p>
14886 !! html/parsoid
14887 <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>
14888
14889 <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>
14890 !! end
14891
14892 !! test
14893 Alt image option should handle most kinds of wikitext without barfing
14894 !! wikitext
14895 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
14896 !! html/php
14897 <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>
14898
14899 !! html/parsoid
14900 <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>
14901 !! end
14902
14903 !! test
14904 Image with table with attributes in caption
14905 !! options
14906 parsoid=wt2html,html2html
14907 !! wikitext
14908 [[File:Foobar.jpg|thumb|
14909 {| class="123" |
14910 |- class="456" |
14911 | ha
14912 |}
14913 ]]
14914 !! html/parsoid
14915 <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>
14916 <table class="123">
14917 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
14918 <td> ha</td></tr>
14919 </tbody></table>
14920 </figcaption></figure>
14921 !! end
14922
14923 !! test
14924 Image with table with rows from templates in caption
14925 !! wikitext
14926 [[File:Foobar.jpg|thumb|
14927 {|
14928 {{echo|{{!}} hi}}
14929 |}
14930 ]]
14931 !! html/parsoid
14932 <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>
14933 <table>
14934 <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>
14935 </tbody></table>
14936 </figcaption></figure>
14937 !! end
14938
14939 !! test
14940 Image with nested tables in caption
14941 !! wikitext
14942 [[File:Foobar.jpg|thumb|Foo<br />
14943 {|
14944 |
14945 {|
14946 |z
14947 |}
14948 |}
14949 ]]
14950 !! html/parsoid
14951 <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}'/>
14952 <table>
14953 <tbody><tr><td>
14954 <table>
14955 <tbody><tr><td>z</td></tr>
14956 </tbody></table></td></tr>
14957 </tbody></table>
14958 </figcaption></figure>
14959 !! end
14960
14961 ###################
14962 # Conflicting image format options.
14963 # First option specified should 'win'.
14964 # All three cases in each test should be identical.
14965
14966 !! test
14967 Image with 'frameless' first.
14968 !! options
14969 parsoid=wt2html,wt2wt,html2html
14970 !! wikitext
14971 [[File:Foobar.jpg|frameless|caption]]
14972
14973 [[File:Foobar.jpg|frameless|frame|caption]]
14974
14975 [[File:Foobar.jpg|frameless|thumb|caption]]
14976 !! html/php
14977 <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>
14978 </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>
14979 </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>
14980 </p>
14981 !! html/parsoid
14982 <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>
14983 <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>
14984 <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>
14985 !! end
14986
14987 !! test
14988 Image with 'frame' first.
14989 !! options
14990 parsoid=wt2html,wt2wt,html2html
14991 !! wikitext
14992 [[File:Foobar.jpg|frame|caption]]
14993 [[File:Foobar.jpg|frame|frameless|caption]]
14994 [[File:Foobar.jpg|frame|thumb|caption]]
14995 !! html/php
14996 <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>
14997 <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>
14998 <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>
14999
15000 !! html/parsoid
15001 <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>
15002 <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>
15003 <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>
15004 !! end
15005
15006 !! test
15007 Image with 'thumb' first.
15008 !! options
15009 parsoid=wt2html,wt2wt,html2html
15010 !! wikitext
15011 [[File:Foobar.jpg|thumb|caption]]
15012 [[File:Foobar.jpg|thumb|frameless|caption]]
15013 [[File:Foobar.jpg|thumb|frame|caption]]
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>caption</div></div></div>
15016 <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>
15017 <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>
15018
15019 !! html/parsoid
15020 <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>
15021 <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>
15022 <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>
15023 !! end
15024
15025 ###################
15026 # Image sizing.
15027 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
15028 # and https://phabricator.wikimedia.org/T64258
15029 # Foobar has actual size of 1941x220
15030 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
15031 # a scalable format.
15032 # 2. Framed images always ignore size options; always render at default size.
15033 # 3. "Unspecified format" and border are the only types which can be
15034 # enlarged.
15035
15036 !! test
15037 Image: unspecified format and border enlarge
15038 !! options
15039 parsoid=wt2html,wt2wt,html2html
15040 !! wikitext
15041 [[File:Foobar.jpg|2000px]]
15042
15043 [[File:Foobar.jpg|border|2000px]]
15044 !! html/php
15045 <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>
15046 </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>
15047 </p>
15048 !! html/parsoid
15049 <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>
15050 <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>
15051 !! end
15052
15053 !! test
15054 Image: "unspecified format" and border reduce
15055 !! options
15056 parsoid=wt2html,wt2wt,html2html
15057 !! wikitext
15058 [[File:Foobar.jpg|1000px]]
15059
15060 [[File:Foobar.jpg|border|1000px]]
15061 !! html/php
15062 <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>
15063 </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>
15064 </p>
15065 !! html/parsoid
15066 <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>
15067 <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>
15068 !! end
15069
15070 !! test
15071 Image: thumbs reduce
15072 !! options
15073 parsoid=wt2html,wt2wt,html2html
15074 !! wikitext
15075 [[File:Foobar.jpg|thumb|50px]]
15076 !! html/php
15077 <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>
15078
15079 !! html/parsoid
15080 <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>
15081 !! end
15082
15083 !! test
15084 Image: bitmap thumbs can't be enlarged past original size, but vector can.
15085 !! options
15086 parsoid=wt2html,wt2wt,html2html
15087 !! wikitext
15088 [[File:Foobar.jpg|thumb|2000px]]
15089
15090 [[File:Foobar.svg|thumb|2000px]]
15091 !! html/php
15092 <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>
15093 <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>
15094
15095 !! html/parsoid
15096 <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>
15097 <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>
15098 !! end
15099
15100 !! test
15101 Image: frameless can reduce in size
15102 !! options
15103 parsoid=wt2html,wt2wt,html2html
15104 !! wikitext
15105 [[File:Foobar.jpg|frameless|50px]]
15106 !! html/php
15107 <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>
15108 </p>
15109 !! html/parsoid
15110 <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>
15111 !! end
15112
15113 !! test
15114 Image: bitmap frameless can't be enlarged past original size, but vector can
15115 !! options
15116 parsoid=wt2html,wt2wt,html2html
15117 !! wikitext
15118 [[File:Foobar.jpg|frameless|2000px]]
15119
15120 [[File:Foobar.svg|frameless|2000px]]
15121 !! html/php
15122 <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>
15123 </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>
15124 </p>
15125 !! html/parsoid
15126 <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>
15127 <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>
15128 !! end
15129
15130 !! test
15131 Image: framed images are always unscaled.
15132 !! options
15133 parsoid=wt2html,wt2wt,html2html
15134 !! wikitext
15135 [[File:Foobar.jpg|frame]]
15136
15137 [[File:Foobar.jpg|frame|50px]]
15138
15139 [[File:Foobar.jpg|frame|50x50px]]
15140
15141 [[File:Foobar.jpg|frame|2000px]]
15142 !! html/php
15143 <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>
15144 <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>
15145 <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>
15146 <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>
15147
15148 !! html/parsoid
15149 <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>
15150 <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>
15151 <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>
15152 <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>
15153 !! end
15154
15155 ###################
15156
15157 !! test
15158 Link to image page- image page normally doesn't exists, hence edit link
15159 Add test with existing image page
15160 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
15161 !! wikitext
15162 [[:Image:test]]
15163 !! html
15164 <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>
15165 </p>
15166 !! end
15167
15168 !! test
15169 T20784 Link to non-existent image page with caption should use caption as link text
15170 !! wikitext
15171 [[:Image:test|caption]]
15172 !! html
15173 <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>
15174 </p>
15175 !! end
15176
15177 !! test
15178 Frameless image caption with a free URL
15179 !! wikitext
15180 [[File:Foobar.jpg|http://example.com]]
15181 !! html/php
15182 <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>
15183 </p>
15184 !! html/parsoid
15185 <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>
15186 !! end
15187
15188 !! test
15189 Thumbnail image caption with a free URL
15190 !! options
15191 thumbsize=220
15192 !! wikitext
15193 [[File:Foobar.jpg|thumb|http://example.com]]
15194 !! html/php
15195 <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>
15196
15197 !! html/parsoid
15198 <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>
15199 !! end
15200
15201 !! test
15202 Thumbnail image caption with a free URL and explicit alt
15203 !! options
15204 thumbsize=220
15205 parsoid=wt2html,wt2wt,html2html
15206 !! wikitext
15207 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
15208 !! html/php
15209 <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>
15210
15211 !! html/parsoid
15212 <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>
15213 !! end
15214
15215 !! test
15216 SVG thumbnails with no language set
15217 !! options
15218 !! wikitext
15219 [[File:Foobar.svg|thumb|caption]]
15220 !! html/php
15221 <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>
15222
15223 !! html/parsoid
15224 <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>
15225 !! end
15226
15227 !! test
15228 SVG thumbnails with language de
15229 !! options
15230 parsoid=wt2html,wt2wt,html2html
15231 !! wikitext
15232 [[File:Foobar.svg|thumb|caption|lang=de]]
15233 !! html/php
15234 <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>
15235
15236 !! html/parsoid
15237 <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>
15238 !! end
15239
15240 !! test
15241 SVG thumbnails with invalid language code
15242 !! options
15243 parsoid=wt2html,wt2wt,html2html
15244 !! wikitext
15245 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
15246 !! html/php
15247 <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>
15248
15249 !! html/parsoid
15250 <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>
15251 !! end
15252
15253 !! test
15254 T3887: A ISBN with a thumbnail
15255 !! wikitext
15256 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15257 !! html/php
15258 <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>
15259
15260 !! html/parsoid
15261 <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>
15262 !! end
15263
15264 !! test
15265 T3887: A RFC with a thumbnail
15266 !! wikitext
15267 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15268 !! html/php
15269 <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>
15270
15271 !! html/parsoid
15272 <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>
15273 !! end
15274
15275 !! test
15276 T3887: A mailto link with a thumbnail
15277 !! wikitext
15278 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15279 !! html/php
15280 <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>
15281
15282 !! html/parsoid
15283 <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>
15284 !! end
15285
15286 # Pending resolution to T2368
15287 !! test
15288 T2648: Frameless image caption with a link
15289 !! wikitext
15290 [[File:Foobar.jpg|text with a [[link]] in it]]
15291 !! html/php
15292 <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>
15293 </p>
15294 !! html/parsoid
15295 <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>
15296 !! end
15297
15298 !! test
15299 T2648: Frameless image caption with a link (suffix)
15300 !! wikitext
15301 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15302 !! html/php
15303 <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>
15304 </p>
15305 !! html/parsoid
15306 <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>
15307 !! end
15308
15309 !! test
15310 T2648: Frameless image caption with an interwiki link
15311 !! wikitext
15312 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15313 !! html/php
15314 <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>
15315 </p>
15316 !! html/parsoid
15317 <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>
15318 !! end
15319
15320 !! test
15321 T2648: Frameless image caption with a piped interwiki link
15322 !! wikitext
15323 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15324 !! html/php
15325 <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>
15326 </p>
15327 !! html/parsoid
15328 <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>
15329 !! end
15330
15331 !! test
15332 T107474: Frameless image caption with <nowiki>
15333 !! wikitext
15334 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15335 !! html/parsoid
15336 <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>
15337 !! end
15338
15339 !! test
15340 Escape HTML special chars in image alt text
15341 !! wikitext
15342 [[File:Foobar.jpg|& < > "]]
15343 !! html/php
15344 <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>
15345 </p>
15346 !! html/parsoid
15347 <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>
15348 !! end
15349
15350 !! test
15351 Escape HTML special chars in image alt text with LanguageConverter
15352 !! options
15353 language=zh
15354 !! wikitext
15355 [[File:Foobar.jpg|& < > "]]
15356 !! html/php
15357 <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>
15358 </p>
15359 !! html/parsoid
15360 <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>
15361 !! end
15362
15363 !! test
15364 Entities in file name and attributes
15365 !! wikitext
15366 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
15367 !! html/php
15368 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
15369 </p>
15370 !! html/parsoid
15371 <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>
15372 !! end
15373
15374 !! test
15375 T2499: Alt text should have &#1234;, not &amp;1234;
15376 !! wikitext
15377 [[File:Foobar.jpg|&#9792;]]
15378 !! html/php
15379 <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>
15380 </p>
15381 !! html/parsoid
15382 <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>
15383 !! end
15384
15385 !! test
15386 Broken image caption with link
15387 !! options
15388 parsoid=wt2html,wt2wt,html2html
15389 !! wikitext
15390 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
15391 !! html/php
15392 <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.
15393 </p>
15394 !! html/parsoid
15395 <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>
15396 !! end
15397
15398 !! test
15399 Image caption containing another image
15400 !! wikitext
15401 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
15402 !! html/php
15403 <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>
15404
15405 !! html/parsoid
15406 <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>
15407 !! end
15408
15409 !! test
15410 Image: caption containing a newline
15411 !! wikitext
15412 [[File:Foobar.jpg|This
15413 *is some text]]
15414 !! html/php
15415 <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>
15416 </p>
15417 !! html/parsoid
15418 <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>
15419 !!end
15420
15421 !!test
15422 Image: caption containing leading space
15423 (The leading space should not trigger nowiki escaping in wt2wt mode)
15424 !! wikitext
15425 [[File:Foobar.jpg|thumb| bar]]
15426 !! html/php
15427 <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>
15428
15429 !! html/parsoid
15430 <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>
15431 !!end
15432
15433 !! test
15434 Image: caption containing a table
15435 !! options
15436 parsoid=wt2html,wt2wt,html2html
15437 !! wikitext
15438 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
15439 {|
15440 ! Foo !! Bar
15441 |-
15442 | Foo1 || Bar1
15443 |}
15444 and some more text.]]
15445 !! html/php
15446 <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>
15447
15448 !! html/parsoid
15449 <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
15450 <table>
15451 <tbody>
15452 <tr><th>Foo </th><th>Bar</th></tr>
15453 <tr>
15454 <td>Foo1 </td>
15455 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
15456 !! end
15457
15458 !! test
15459 T5090: External links other than http: in image captions
15460 !! wikitext
15461 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
15462 !! html/php
15463 <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>
15464
15465 !! html/parsoid
15466 <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>
15467 !! end
15468
15469 !! test
15470 Custom class
15471 !! options
15472 parsoid=wt2html,wt2wt,html2html
15473 !! wikitext
15474 [[Image:foobar.jpg|a|class=b]]
15475 !! html/php
15476 <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>
15477 </p>
15478 !! html/parsoid
15479 <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>
15480 !! end
15481
15482 !! test
15483 Localized image handling (1).
15484 !! options
15485 parsoid=wt2html,wt2wt,html2html
15486 language=es
15487 !! wikitext
15488 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
15489 !! html/php
15490 <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>
15491
15492 !! html/parsoid
15493 <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>
15494 !! end
15495
15496 !! test
15497 Localized image handling (2).
15498 !! options
15499 thumbsize=220
15500 parsoid=wt2html,wt2wt,html2html
15501 language=es
15502 !! wikitext
15503 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
15504 !! html/php
15505 <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>
15506
15507 !! html/parsoid
15508 <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>
15509 !! end
15510
15511 !! test
15512 Localized image handling (3).
15513 !! options
15514 language=fa
15515 parsoid=html2wt
15516 !! html/parsoid
15517 <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>
15518 !! wikitext
15519 [[File:Foobar.jpg|بندانگشتی]]
15520 !! end
15521
15522 !! test
15523 "border", "frameless" and "class" attributes on an image.
15524 !! options
15525 thumbsize=220
15526 parsoid=wt2html,wt2wt,html2html
15527 !! wikitext
15528 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
15529 !! html/php
15530 <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>
15531 </p>
15532 !! html/parsoid
15533 <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>
15534 !! end
15535
15536 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
15537 !! test
15538 Invalid image attributes (T64500)
15539 !! options
15540 thumbsize=220
15541 parsoid=wt2html,wt2wt,html2html
15542 !! wikitext
15543 [[File:Foobar.jpg|thumb|float|left|caption]]
15544
15545 [[File:Foobar.jpg|thumb|righ|caption]]
15546
15547 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
15548 !! html/php
15549 <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>
15550 <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>
15551 <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>
15552
15553 !! html/parsoid
15554 <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>
15555 <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>
15556 <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>
15557 !! end
15558
15559 !! article
15560 File:Barfoo.jpg
15561 !! text
15562 #REDIRECT [[File:Barfoo.jpg]]
15563 !! endarticle
15564
15565 # FIXME: Parsoid should run this test -- but we'd need to teach the
15566 # mockAPI about the redirected Barfoo.jpg image.
15567 !! test
15568 Redirected image
15569 !! wikitext
15570 [[Image:Barfoo.jpg]]
15571 !! html/php
15572 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
15573 </p>
15574 !! end
15575
15576 !! test
15577 Missing image with uploads disabled
15578 !! options
15579 wgEnableUploads=0
15580 !! wikitext
15581 [[File:Foobaz.jpg]]
15582 !! html/php
15583 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
15584 </p>
15585 !! html/parsoid
15586 <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>
15587 !! end
15588
15589 # Parsoid-specific testing for images
15590 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
15591 # Currently imperfect due to a flaw in the Parsoid testrunner
15592 # Work in progress
15593 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
15594 # image tests.
15595
15596 !! test
15597 Parsoid-specific image handling - simple image with size and middle alignment
15598 !! wikitext
15599 [[File:Foobar.jpg|middle|50px]]
15600 !! html/parsoid
15601 <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>
15602 !! end
15603
15604 !! test
15605 Parsoid-specific image handling - simple image with size, middle alignment,
15606 non-standard namespace alias
15607 !! options
15608 parsoid=wt2wt,wt2html,html2html
15609 !! wikitext
15610 [[Image:Foobar.jpg|middle|50px]]
15611 !! html/parsoid
15612 <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>
15613 !! end
15614
15615 !! test
15616 Parsoid-specific image handling - simple image with size and middle alignment
15617 (existing content)
15618 !! wikitext
15619 [[File:Foobar.jpg|50px|middle]]
15620 !! html/parsoid
15621 <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>
15622 !! end
15623
15624 !! test
15625 Parsoid-specific image handling - simple image with size and middle alignment
15626 and non-standard namespace name
15627 !! options
15628 parsoid=wt2html,wt2wt,html2html
15629 !! wikitext
15630 [[Image:Foobar.jpg|50px|middle]]
15631 !! html/parsoid
15632 <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>
15633 !! end
15634
15635 !! test
15636 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
15637 !! wikitext
15638 [[File:Foobar.jpg|500x10px|baseline|caption]]
15639 !! html/parsoid
15640 <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>
15641 !! end
15642
15643 !! test
15644 Parsoid-specific image handling - simple image with border and size spec
15645 !! wikitext
15646 [[File:Foobar.jpg|50px|border|caption]]
15647 !! html/parsoid
15648 <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>
15649 !! end
15650
15651 !! test
15652 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15653 !! wikitext
15654 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
15655 !! html/parsoid
15656 <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>
15657 !! end
15658
15659 !! test
15660 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15661 (existing content)
15662 !! wikitext
15663 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
15664 !! html/parsoid
15665 <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>
15666 !! end
15667
15668 !! test
15669 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
15670 !! wikitext
15671 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
15672 !! html/parsoid
15673 <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>
15674 !! end
15675
15676 !! test
15677 Parsoid-specific image handling - thumbnail with specific size, halign,
15678 valign, and caption (existing content)
15679 !! wikitext
15680 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
15681 !! html/parsoid
15682 <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>
15683 !! end
15684
15685 !! test
15686 Parsoid-specific image handling - framed image with specific size and caption
15687 (size is ignored)
15688 !! options
15689 parsoid=wt2html,wt2wt,html2html
15690 !! wikitext
15691 [[File:Foobar.jpg|frame|500x50px|caption]]
15692 !! html/parsoid
15693 <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>
15694 !! end
15695
15696 !! test
15697 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption
15698 (size is ignored)
15699 !! options
15700 parsoid=wt2html,wt2wt,html2html
15701 !! wikitext
15702 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
15703 !! html/parsoid
15704 <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>
15705 !! end
15706
15707 !! test
15708 Parsoid-specific image handling - frameless image with specific size, border, and caption
15709 !! wikitext
15710 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
15711 !! html/parsoid
15712 <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>
15713 !! end
15714
15715 !! test
15716 Parsoid-specific image handling - simple image with a formatted caption
15717 !! wikitext
15718 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
15719 !! html/parsoid
15720 <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>
15721 !! end
15722
15723 !! test
15724 Parsoid-specific image handling - caption with a template in it
15725 !! wikitext
15726 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
15727 !! html/parsoid
15728 <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>
15729 !! end
15730
15731 !! test
15732 Parsoid-specific image handling - caption with unbalanced tags in it
15733 !! options
15734 parsoid=wt2html,wt2wt,html2html
15735 !! wikitext
15736 foo
15737 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
15738 bar
15739 !! html/parsoid
15740 <p>foo</p>
15741 <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>
15742 <p>bar</p>
15743 !! end
15744
15745 !! test
15746 Parsoid-specific image handling - empty caption (1)
15747 !! options
15748 parsoid=wt2html,wt2wt
15749 !! wikitext
15750 [[File:Foobar.jpg|thumb|]]
15751 !! html/parsoid
15752 <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>
15753 !! end
15754
15755 # empty captions don't get serialized unless we're in the "round trip" case
15756 !! test
15757 Parsoid-specific image handling - empty caption (2)
15758 !! options
15759 parsoid=html2wt
15760 !! html/parsoid
15761 <figure class="mw-default-size" typeof="mw:Image/Thumb">
15762 <a href="./File:Foobar.jpg">
15763 <img resource="./File:Foobar.jpg"
15764 src="//example.com/images/3/3a/Foobar.jpg"
15765 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
15766 height="25" width="220"/>
15767 </a>
15768 <figcaption></figcaption>
15769 </figure>
15770 !! wikitext
15771 [[File:Foobar.jpg|thumb]]
15772 !! end
15773
15774 !! test
15775 Parsoid-specific image handling - whitespace caption
15776 !! wikitext
15777 [[File:Foobar.jpg|thumb| ]]
15778 !! html/parsoid
15779 <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>
15780 !! end
15781
15782 !! test
15783 Parsoid-specific image handling - lang option
15784 !! wikitext
15785 foo
15786 [[File:Foobar.svg|lang=de|caption]]
15787 bar
15788 !! html/parsoid
15789 <p>foo
15790 <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>
15791 bar</p>
15792 !! end
15793
15794 ## Edge case bugs in Parsoid from T93580
15795 !! test
15796 T93580: 1. Templated <ref> inside block images
15797 !! wikitext
15798 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
15799
15800 <references />
15801 !! html/parsoid
15802 <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>
15803
15804 <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>
15805 !! end
15806
15807 !! test
15808 T93580: 2. <ref> inside inline images
15809 !! wikitext
15810 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
15811
15812 <references />
15813 !! html/parsoid
15814 <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>
15815
15816 <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>
15817 !! end
15818
15819 !! test
15820 T93580: 3. Templated <ref> inside inline images
15821 !! wikitext
15822 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
15823
15824 <references />
15825 !! html/parsoid
15826 <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>
15827
15828 <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>
15829 !! end
15830
15831 ###
15832 ### Subpages
15833 ###
15834 !! article
15835 Subpage test/subpage
15836 !! text
15837 foo
15838 !! endarticle
15839
15840 !! test
15841 Subpage link
15842 !! options
15843 subpage title=[[Subpage test]]
15844 !! wikitext
15845 [[/subpage]]
15846 !! html
15847 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
15848 </p>
15849 !! end
15850
15851 !! test
15852 Subpage noslash link
15853 !! options
15854 subpage title=[[Subpage test]]
15855 !! wikitext
15856 [[/subpage/]]
15857 !! html
15858 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
15859 </p>
15860 !! end
15861
15862 !! article
15863 Subpage test/1/2/subpage
15864 !! text
15865 blah
15866 !! endarticle
15867
15868 !! test
15869 Relative subpage noslash link
15870 !! options
15871 parsoid=wt2wt,wt2html,html2html
15872 subpage title=[[Subpage test/1/2/3/4]]
15873 !! wikitext
15874 [[../../subpage/]]
15875
15876 [[../../subpage]]
15877 !! html/php
15878 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
15879 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
15880 </p>
15881 !! html/parsoid
15882 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
15883 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
15884 !! end
15885
15886 !! test
15887 Parsoid: dot-slash prefixed wikilinks
15888 !! wikitext
15889 [[./foo]]
15890
15891 [[././bar]]
15892
15893 [[././baz/]]
15894 !! html/php
15895 <p>[[./foo]]
15896 </p><p>[[././bar]]
15897 </p><p>[[././baz/]]
15898 </p>
15899 !! html/parsoid
15900 <p>[[./foo]]
15901 </p><p>[[././bar]]
15902 </p><p>[[././baz/]]
15903 </p>
15904 !! end
15905
15906 !! test
15907 Render invalid page names as plain text (T53090)
15908 !! wikitext
15909 [[./../foo|bar]]
15910 [[foo�|bar]]
15911 [[foo/.|bar]]
15912 [[foo/..|bar]]
15913 [[foo~~~bar]]
15914 [[foo>bar]]
15915 [[foo[bar]]
15916 [[.]]
15917 [[..]]
15918 [[foo././bar]]
15919 [[foo[http://example.com]xyz]]
15920
15921 [[{{echo|./../foo}}|bar]]
15922 [[{{echo|foo/.}}|bar]]
15923 [[{{echo|foo/..}}|bar]]
15924 [[{{echo|foo~~~~bar}}]]
15925 [[{{echo|foo>bar}}]]
15926 [[{{echo|foo././bar}}]]
15927 [[{{echo|foo{bar}}]]
15928 [[{{echo|foo}bar}}]]
15929 [[{{echo|foo[bar}}]]
15930 [[{{echo|foo]bar}}]]
15931 [[{{echo|foo<bar}}]]
15932 !!html/php
15933 <p>[[./../foo|bar]]
15934 [[foo�|bar]]
15935 [[foo/.|bar]]
15936 [[foo/..|bar]]
15937 [[foo~~~bar]]
15938 [[foo&gt;bar]]
15939 [[foo[bar]]
15940 [[.]]
15941 [[..]]
15942 [[foo././bar]]
15943 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
15944 </p><p>[[./../foo|bar]]
15945 [[foo/.|bar]]
15946 [[foo/..|bar]]
15947 [[foo~~~~bar]]
15948 [[foo&gt;bar]]
15949 [[foo././bar]]
15950 [[foo{bar]]
15951 [[foo}bar]]
15952 [[foo[bar]]
15953 [[foo]bar]]
15954 [[foo&lt;bar]]
15955 </p>
15956 !!html/parsoid
15957 <p>[[./../foo|bar]]
15958 [[foo�|bar]]
15959 [[foo/.|bar]]
15960 [[foo/..|bar]]
15961 [[foo~~~bar]]
15962 [[foo>bar]]
15963 [[foo[bar]]
15964 [[.]]
15965 [[..]]
15966 [[foo././bar]]
15967 [[foo<a rel="mw:ExtLink" href="http://example.com"></a>xyz]]</p>
15968
15969 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
15970 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
15971 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
15972 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
15973 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
15974 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
15975 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
15976 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
15977 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
15978 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
15979 [[<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>
15980 !!end
15981
15982 !! test
15983 Disabled subpages
15984 !! wikitext
15985 [[/subpage]]
15986 !! html
15987 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
15988 </p>
15989 !! end
15990
15991 !! test
15992 T2561: {{/Subpage}}
15993 !! options
15994 subpage title=[[Page]]
15995 !! wikitext
15996 {{/Subpage}}
15997 !! html
15998 <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>
15999 </p>
16000 !! end
16001
16002 ###
16003 ### Categories
16004 ###
16005 !! article
16006 Category:MediaWiki User's Guide
16007 !! text
16008 blah
16009 !! endarticle
16010
16011 !! test
16012 Link to category
16013 !! wikitext
16014 [[:Category:MediaWiki User's Guide]]
16015 !! html
16016 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
16017 </p>
16018 !! end
16019
16020 !! test
16021 Simple category
16022 !! options
16023 cat
16024 !! wikitext
16025 [[Category:MediaWiki User's Guide]]
16026 !! html/php
16027 cat=MediaWiki_User's_Guide sort=
16028 !! html/parsoid
16029 <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"}}'/>
16030 !! end
16031
16032 !! test
16033 PAGESINCATEGORY invalid title fatal (r33546 fix)
16034 !! wikitext
16035 {{PAGESINCATEGORY:<bogus>}}
16036 !! html
16037 <p>0
16038 </p>
16039 !! end
16040
16041 !! test
16042 Category with different sort key
16043 !! options
16044 cat
16045 !! wikitext
16046 [[Category:MediaWiki User's Guide|Foo]]
16047 !! html/php
16048 cat=MediaWiki_User's_Guide sort=Foo
16049 !! html/parsoid
16050 <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"}}'/>
16051 !! end
16052
16053 !! test
16054 Category with identical sort key
16055 !! options
16056 cat
16057 !! wikitext
16058 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16059 !! html/php
16060 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
16061 !! html/parsoid
16062 <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"}}'/>
16063 !! end
16064
16065 !! test
16066 Category with empty sort key
16067 !! options
16068 cat
16069 pst
16070 !! wikitext
16071 [[Category:MediaWiki User's Guide|]]
16072 !! html/php
16073 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16074 !! end
16075
16076 !! test
16077 Category with empty sort key and parentheses
16078 !! options
16079 cat
16080 pst
16081 !! wikitext
16082 [[Category:Foo (bar)|]]
16083 !! html/php
16084 [[Category:Foo (bar)|Foo]]
16085 !! end
16086
16087 !! test
16088 Category with link tail
16089 !! options
16090 cat
16091 pst
16092 !! wikitext
16093 123[[Category:Foo]]456
16094 !! html/php
16095 123[[Category:Foo]]456
16096 !! end
16097
16098 !! test
16099 Category with template
16100 !! options
16101 cat
16102 pst
16103 !! wikitext
16104 [[Category:{{echo|Foo}}]]
16105 !! html/php
16106 [[Category:{{echo|Foo}}]]
16107 !! end
16108
16109 !! test
16110 Category with template in sort key
16111 !! options
16112 cat
16113 pst
16114 !! wikitext
16115 [[Category:Foo|{{echo|Bar}}]]
16116 !! html/php
16117 [[Category:Foo|{{echo|Bar}}]]
16118 !! end
16119
16120 !! test
16121 Category with template in sort key and title
16122 !! options
16123 cat
16124 pst
16125 !! wikitext
16126 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16127 !! html/php
16128 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16129 !! end
16130
16131 ## We used to, but no longer wt2wt this test since the default serializer
16132 ## will normalize all categories to serialize on their own line.
16133 ## This wikitext usage is going to be fairly uncommon in production and
16134 ## selser will take care of preserving formatting in those scenarios.
16135 !! test
16136 Category / paragraph interactions
16137 !! options
16138 parsoid=wt2html
16139 !! wikitext
16140 Foo [[Category:Baz]] Bar
16141
16142 Foo [[Category:Baz]]
16143 Bar
16144
16145 Foo
16146 [[Category:Baz]]
16147 Bar
16148
16149 Foo
16150 [[Category:Baz]] Bar
16151
16152 Foo
16153 [[Category:Baz]]
16154 [[Category:Baz]]
16155 [[Category:Baz]]
16156 Bar
16157
16158 [[Category:Baz]]
16159 [[Category:Baz]]
16160 [[Category:Baz]]
16161
16162 [[Category:Baz]]
16163 {{echo|[[Category:Baz]]}}
16164 [[Category:Baz]]
16165 !! html/php
16166 <p>Foo Bar
16167 </p><p>Foo
16168 Bar
16169 </p><p>Foo
16170 Bar
16171 </p><p>Foo Bar
16172 </p><p>Foo
16173 Bar
16174 </p>
16175 !! html/parsoid
16176 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16177 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16178 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16179 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16180 <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>
16181 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16182 !! end
16183
16184 ## We used to, but no longer wt2wt this test since the default serializer
16185 ## will normalize all categories to serialize on their own line.
16186 ## This wikitext usage is going to be fairly uncommon in production and
16187 ## selser will take care of preserving formatting in those scenarios.
16188 ##
16189 ## The whitespace on the empty line is part of the test. Please do not delete
16190 !! test
16191 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16192 !! options
16193 parsoid=wt2html
16194 !! wikitext
16195 This
16196
16197 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16198
16199 {{echo|[[Category:Foo]] and so should this!}}
16200 !! html/php
16201 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16202 </p>
16203 !! html/parsoid
16204 <p>This
16205
16206 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16207
16208 <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>
16209 !! end
16210
16211 ## Parsoid will not try to wt2wt this while preserving newlines because
16212 ## it suppresses excess newlines within list items -- and we don't want to
16213 ## introduce a special case just for categories, which is, in reality somewhat
16214 ## odd behavior -- categories are unlikely to be used in list items like this
16215 ## in top-level pages and are only likely to show up in template-generated
16216 ## list items where this RT-ing is a non-issue.
16217 ##
16218 ## The whitespace on the empty line is part of the test. Please do not delete
16219 !! test
16220 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16221 !! options
16222 parsoid=wt2html
16223 !! wikitext
16224 * This
16225
16226 [[Category:Foo]] and this should be part of the same list item
16227 * So should this
16228
16229 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16230 !! html
16231 <ul><li>This and this should be part of the same list item</li>
16232 <li>So should this and this should be part of the same list item</li></ul>
16233 !! html/parsoid
16234 <ul>
16235 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16236 <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>
16237 </ul>
16238 !! end
16239
16240 ## Newlines and categories that follow the last item of a list
16241 ## are treated differently because this (list followed by categories)
16242 ## is an extremely common pattern on wikis.
16243 !! test
16244 3. Categories and newlines: newline suppression for last list item should RT properly
16245 !! wikitext
16246 * a
16247 * b
16248
16249 [[Category:Foo]]
16250
16251 [[Category:Bar]]
16252 [[Category:Baz]]
16253 !! html/parsoid
16254 <ul><li> a</li>
16255 <li> b</li></ul>
16256
16257 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16258
16259 <link rel="mw:PageProp/Category" href="./Category:Bar" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16260 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16261 !! end
16262
16263 !! test
16264 4. Categories and newlines: newline suppression for last list item should RT properly
16265 !! wikitext
16266 * a
16267 **** b
16268
16269 [[Category:Foo]]
16270 !! html/parsoid
16271 <ul><li> a
16272 <ul><li><ul><li><ul><li> b</li></ul></li></ul></li></ul></li></ul>
16273
16274 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16275 !! end
16276
16277 ## only wt2html for this to make sure the algo only applies to the rightmost path
16278 !! test
16279 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16280 !! options
16281 parsoid=wt2html
16282 !! wikitext
16283 * a
16284 ** b
16285 [[Category:Foo]]
16286 * c
16287 ** d
16288 [[Category:Foo]]
16289 !! html/parsoid
16290 <ul><li> a
16291 <ul><li> b
16292 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16293 <li> c
16294 <ul><li> d</li></ul></li></ul>
16295 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16296 !! end
16297
16298 ## We used to, but no longer wt2wt this test since the default serializer
16299 ## will normalize all categories to serialize on their own line.
16300 ## This wikitext usage is going to be fairly uncommon in production and
16301 ## selser will take care of preserving formatting in those scenarios.
16302 !! test
16303 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16304 !! options
16305 parsoid=wt2html
16306 !! wikitext
16307 * a [[Category:Foo]]
16308 !! html/parsoid
16309 <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>
16310 !! end
16311
16312 # This test also demonstrates because of newline+category tunneling
16313 # through the list hander, template wrapping doesn't expand to the
16314 # containing list when the list item swallows the category.
16315 !! test
16316 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16317 !! wikitext
16318 * {{echo|a
16319 [[Category:Foo]]}}
16320 !! html/parsoid
16321 <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
16322 </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>
16323 !! end
16324
16325 !! test
16326 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
16327 !! wikitext
16328 * a
16329
16330 {{echo|[[Category:Foo]]
16331 [[Category:Bar]]}}
16332 [[Category:Baz]]
16333 !! html/parsoid
16334 <ul><li> a</li></ul>
16335
16336 <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">
16337 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16338 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16339 !! end
16340
16341 !! test
16342 9. Categories and newlines: should behave properly with linkprefix (T87753)
16343 !! options
16344 language=ar
16345 !! wikitext
16346 foo bar
16347 foo bar
16348 [[تصنيف:Foo]]
16349 [[تصنيف:Bar]]
16350 !! html/php
16351 <p>foo bar
16352 foo bar
16353 </p>
16354 !! html/parsoid
16355 <p>foo bar
16356 foo bar</p>
16357 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
16358 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
16359 !! end
16360
16361 !! test
16362 10. No regressions on internal links following category (T174639)
16363 !! options
16364 parsoid=wt2html,html2html
16365 !! wikitext
16366 [[Category:Foo]]<div>a
16367
16368 [[Foo]]</div>
16369 !! html/php
16370 <div>a
16371 <a href="/wiki/Foo" title="Foo">Foo</a></div>
16372
16373 !! html/parsoid
16374 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
16375
16376 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
16377 !! end
16378
16379 # Note that Parsoid differs slightly from PHP due to T175421
16380 !! test
16381 11. Special case where only newlines separate links (T175416)
16382 !! options
16383 parsoid=wt2html,html2html
16384 !! wikitext
16385 [[Category:Foo]]
16386
16387 [[Foo]][[es:Alimento]]
16388
16389 [[Foo]]
16390 !! html/php
16391 <p><br />
16392 <a href="/wiki/Foo" title="Foo">Foo</a>
16393 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
16394 </p>
16395 !! html/parsoid
16396 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16397
16398 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16399
16400 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
16401 !! end
16402
16403 !! test
16404 Category links with multiple namespaces
16405 !! wikitext
16406 [[Category:Project:Foo]]
16407 !! html/parsoid
16408 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
16409 !! end
16410
16411 !! test
16412 Parsoid: Serialize link to category page with colon escape
16413 !! options
16414 parsoid
16415 !! wikitext
16416
16417 [[:Category:Foo]]
16418 [[:Category:Foo|Bar]]
16419 !! html
16420 <p>
16421 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
16422 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
16423 </p>
16424 !! end
16425
16426 # We used to, but no longer wt2wt this test since the default serializer
16427 # will normalize all categories to serialize on their own line.
16428 # This wikitext usage is going to be fairly uncommon in production and
16429 # selser will take care of preventing whitespace insertion if this
16430 # occurs in an article.
16431 #
16432 # html2html disabled for the same reason (whitespace insertion between
16433 # x and y).
16434 #
16435 # html2wt disabled because it localizes the "Category" namespace.
16436 !! test
16437 Link prefix/suffixes aren't applied to category links
16438 !! options
16439 parsoid=wt2html
16440 language=is
16441 !! wikitext
16442 x[[Category:Foo]]y
16443 !! html/php
16444 <p>xy
16445 </p>
16446 !! html/parsoid
16447 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
16448 !! end
16449
16450 !! test
16451 Link prefix/suffixes aren't applied to language links
16452 !! options
16453 parsoid=wt2html
16454 language=is
16455 !! wikitext
16456 x[[es:Foo]]y
16457 !! html/php
16458 <p>xy
16459 </p>
16460 !! html/parsoid
16461 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
16462 !! end
16463
16464 !! test
16465 Parsoid: Serialize link to file page with colon escape
16466 !! options
16467 parsoid
16468 !! wikitext
16469
16470 [[:File:Foo.png]]
16471 [[:File:Foo.png|Bar]]
16472 !! html
16473 <p>
16474 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
16475 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
16476 </p>
16477 !! end
16478
16479 !! test
16480 Parsoid: Serialize a genuine category link without colon escape
16481 !! options
16482 parsoid
16483 !! wikitext
16484 [[Category:Foo]]
16485 [[Category:Foo|Bar]]
16486 !! html
16487 <link rel="mw:PageProp/Category" href="./Category:Foo">
16488 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
16489 !! end
16490
16491 !! test
16492 Normalize hrefs properly before testing for invalid link targets (T72894)
16493 !! options
16494 parsoid=html2wt
16495 !! html/parsoid
16496 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
16497 !! wikitext
16498 [[Category:Toxine bactérienne]]
16499 !! end
16500
16501 !! test
16502 Parsoid: Defaultsort
16503 !! wikitext
16504 {{DEFAULTSORT:Foo}}
16505 !! html/parsoid
16506 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
16507 !! end
16508
16509 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
16510 # But, this is a limitation of our representation and is documented in
16511 # TemplateHandler.js in processSpecialMagicWord
16512 !! test
16513 Parsoid: Defaultsort (template-generated)
16514 !! wikitext
16515 {{{{echo|DEFAULTSORT}}:Foo}}
16516 !! html/parsoid
16517 <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"}]]}'/>
16518 !! end
16519
16520 ###
16521 ### Inter-language links
16522 ###
16523 !! test
16524 Interlanguage links
16525 !! options
16526 ill
16527 !! wikitext
16528 [[es:Alimento]]
16529 [[fr:Nourriture]]
16530 [[zh:食品]]
16531 !! html/php
16532 es:Alimento fr:Nourriture zh:食品
16533 !! html/parsoid
16534 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16535 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
16536 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
16537 !! end
16538
16539 !! test
16540 Duplicate interlanguage links (T26502)
16541 !! options
16542 ill
16543 !! wikitext
16544 [[es:1]]
16545 [[es:2]]
16546 [[fr:1]]
16547 [[fr:2]]
16548 !! html/php
16549 es:1 fr:1
16550 !! html/parsoid
16551 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
16552 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
16553 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
16554 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
16555 !! end
16556
16557 ###
16558 ### Sections
16559 ###
16560 !! test
16561 Basic section headings
16562 !! wikitext
16563 == Headline 1 ==
16564 Some text
16565
16566 ==Headline 2==
16567 More
16568 ===Smaller headline===
16569 Blah blah
16570 !! html
16571 <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>
16572 <p>Some text
16573 </p>
16574 <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>
16575 <p>More
16576 </p>
16577 <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>
16578 <p>Blah blah
16579 </p>
16580 !! end
16581
16582 !! test
16583 Section headings with TOC
16584 !! wikitext
16585 == Headline 1 ==
16586 === Subheadline 1 ===
16587 ===== Skipping a level =====
16588 ====== Skipping a level ======
16589
16590 == Headline 2 ==
16591 Some text
16592 ===Another headline===
16593 !! html
16594 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16595 <ul>
16596 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
16597 <ul>
16598 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
16599 <ul>
16600 <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>
16601 <ul>
16602 <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>
16603 </ul>
16604 </li>
16605 </ul>
16606 </li>
16607 </ul>
16608 </li>
16609 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
16610 <ul>
16611 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
16612 </ul>
16613 </li>
16614 </ul>
16615 </div>
16616
16617 <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>
16618 <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>
16619 <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>
16620 <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>
16621 <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>
16622 <p>Some text
16623 </p>
16624 <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>
16625
16626 !! end
16627
16628 !! test
16629 TOC anchors don't collide
16630 !! wikitext
16631 __FORCETOC__
16632 == Headline 2 ==
16633 == Headline ==
16634 == Headline 2 ==
16635 == Headline ==
16636 !! html/php
16637 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16638 <ul>
16639 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
16640 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
16641 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
16642 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
16643 </ul>
16644 </div>
16645
16646 <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>
16647 <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>
16648 <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>
16649 <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>
16650
16651 !! end
16652
16653 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
16654 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
16655 !! test
16656 Handling of sections up to level 6 and beyond
16657 !! options
16658 parsoid=wt2html
16659 !! wikitext
16660 = Level 1 Heading=
16661 == Level 2 Heading==
16662 === Level 3 Heading===
16663 ==== Level 4 Heading====
16664 ===== Level 5 Heading=====
16665 ====== Level 6 Heading======
16666 ======= Level 7 Heading=======
16667 ======== Level 8 Heading========
16668 ========= Level 9 Heading=========
16669 ========== Level 10 Heading==========
16670 !! html/php
16671 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16672 <ul>
16673 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
16674 <ul>
16675 <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>
16676 <ul>
16677 <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>
16678 <ul>
16679 <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>
16680 <ul>
16681 <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>
16682 <ul>
16683 <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>
16684 <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>
16685 <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>
16686 <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>
16687 <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>
16688 </ul>
16689 </li>
16690 </ul>
16691 </li>
16692 </ul>
16693 </li>
16694 </ul>
16695 </li>
16696 </ul>
16697 </li>
16698 </ul>
16699 </div>
16700
16701 <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>
16702 <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>
16703 <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>
16704 <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>
16705 <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>
16706 <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>
16707 <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>
16708 <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>
16709 <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>
16710 <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>
16711
16712 !! html/parsoid
16713 <h1 id="Level_1_Heading" data-parsoid='{}'> Level 1 Heading</h1>
16714 <h2 id="Level_2_Heading" data-parsoid='{}'> Level 2 Heading</h2>
16715 <h3 id="Level_3_Heading" data-parsoid='{}'> Level 3 Heading</h3>
16716 <h4 id="Level_4_Heading" data-parsoid='{}'> Level 4 Heading</h4>
16717 <h5 id="Level_5_Heading" data-parsoid='{}'> Level 5 Heading</h5>
16718 <h6 id="Level_6_Heading" data-parsoid='{}'> Level 6 Heading</h6>
16719 <h6 id="=_Level_7_Heading=" data-parsoid='{}'><span id=".3D_Level_7_Heading.3D" typeof="mw:FallbackId"></span>= Level 7 Heading=</h6>
16720 <h6 id="==_Level_8_Heading==" data-parsoid='{}'><span id=".3D.3D_Level_8_Heading.3D.3D" typeof="mw:FallbackId"></span>== Level 8 Heading==</h6>
16721 <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>
16722 <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>
16723 !! end
16724
16725 !! test
16726 TOC regression (T11764)
16727 !! wikitext
16728 == title 1 ==
16729 === title 1.1 ===
16730 ==== title 1.1.1 ====
16731 === title 1.2 ===
16732 == title 2 ==
16733 === title 2.1 ===
16734 !! html
16735 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16736 <ul>
16737 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16738 <ul>
16739 <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>
16740 <ul>
16741 <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>
16742 </ul>
16743 </li>
16744 <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>
16745 </ul>
16746 </li>
16747 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16748 <ul>
16749 <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>
16750 </ul>
16751 </li>
16752 </ul>
16753 </div>
16754
16755 <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>
16756 <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>
16757 <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>
16758 <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>
16759 <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>
16760 <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>
16761
16762 !! end
16763
16764 !! test
16765 TOC for heading containing <span id="..."></span> (T96153)
16766 !! wikitext
16767 __FORCETOC__
16768 ==<span id="old-anchor"></span>New title==
16769 !! html/php
16770 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16771 <ul>
16772 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
16773 </ul>
16774 </div>
16775
16776 <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>
16777
16778 !! end
16779
16780 !! test
16781 TOC with wgMaxTocLevel=3 (T8204)
16782 !! options
16783 wgMaxTocLevel=3
16784 !! wikitext
16785 == title 1 ==
16786 === title 1.1 ===
16787 ==== title 1.1.1 ====
16788 === title 1.2 ===
16789 == title 2 ==
16790 === title 2.1 ===
16791 !! html
16792 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16793 <ul>
16794 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16795 <ul>
16796 <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>
16797 <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>
16798 </ul>
16799 </li>
16800 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16801 <ul>
16802 <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>
16803 </ul>
16804 </li>
16805 </ul>
16806 </div>
16807
16808 <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>
16809 <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>
16810 <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>
16811 <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>
16812 <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>
16813 <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>
16814
16815 !! end
16816
16817 !! test
16818 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
16819 !! options
16820 wgMaxTocLevel=3
16821 !! wikitext
16822 ==Section 1==
16823 ===Section 1.1===
16824 ====Section 1.1.1====
16825 ====Section 1.1.1.1====
16826 ==Section 2==
16827 !! html
16828 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16829 <ul>
16830 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
16831 <ul>
16832 <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>
16833 </ul>
16834 </li>
16835 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
16836 </ul>
16837 </div>
16838
16839 <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>
16840 <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>
16841 <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>
16842 <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>
16843 <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>
16844
16845 !! end
16846
16847
16848 !! test
16849 Resolving duplicate section names
16850 !! wikitext
16851 == Foo bar ==
16852 == Foo bar ==
16853 !! html
16854 <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>
16855 <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>
16856
16857 !! end
16858
16859 !! test
16860 Resolving duplicate section names with differing case (T12721)
16861 !! wikitext
16862 == Foo bar ==
16863 == Foo Bar ==
16864 !! html
16865 <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>
16866 <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>
16867
16868 !! end
16869
16870 !! article
16871 Template:sections
16872 !! text
16873 ===Section 1===
16874 ==Section 2==
16875 !! endarticle
16876
16877 !! test
16878 Template with sections, __NOTOC__
16879 !! wikitext
16880 __NOTOC__
16881 ==Section 0==
16882 {{sections}}
16883 ==Section 4==
16884 !! html
16885 <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>
16886 <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>
16887 <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>
16888 <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>
16889
16890 !! end
16891
16892 !! test
16893 __NOEDITSECTION__ keyword
16894 !! wikitext
16895 __NOEDITSECTION__
16896 ==Section 1==
16897 ==Section 2==
16898 !! html
16899 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
16900 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
16901
16902 !! end
16903
16904 !! test
16905 Link inside a section heading
16906 !! wikitext
16907 ==Section with a [[Main Page|link]] in it==
16908 !! html
16909 <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>
16910
16911 !! end
16912
16913 !! test
16914 TOC regression (T14077)
16915 !! wikitext
16916 __TOC__
16917 == title 1 ==
16918 === title 1.1 ===
16919 == title 2 ==
16920 !! html
16921 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16922 <ul>
16923 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16924 <ul>
16925 <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>
16926 </ul>
16927 </li>
16928 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
16929 </ul>
16930 </div>
16931
16932 <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>
16933 <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>
16934 <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>
16935
16936 !! end
16937
16938 !! test
16939 T3219 URL next to image (good)
16940 !! wikitext
16941 http://example.com [[File:Foobar.jpg]]
16942 !! html/php
16943 <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>
16944 </p>
16945 !! html/parsoid
16946 <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>
16947 !!end
16948
16949 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
16950 !! test
16951 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
16952 !! options
16953 parsoid=wt2html,html2html
16954 !! wikitext
16955 ===
16956 The line above must have a trailing space!
16957 === <!--
16958 --> <!-- -->
16959 But just in case it doesn't...
16960 !! html/php
16961 <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>
16962 <p>The line above must have a trailing space!
16963 </p>
16964 <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>
16965 <p>But just in case it doesn't...
16966 </p>
16967 !! html/parsoid
16968 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
16969 <p>The line above must have a trailing space!</p>
16970 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
16971 --> <!-- -->
16972 <p>But just in case it doesn't...</p>
16973 !! end
16974
16975 !! test
16976 Header with special characters (T27462)
16977 !! wikitext
16978 The tooltips shall not show entities to the user (ie. be double escaped)
16979
16980 == text > text ==
16981 section 1
16982
16983 == text < text ==
16984 section 2
16985
16986 == text & text ==
16987 section 3
16988
16989 == text ' text ==
16990 section 4
16991
16992 == text " text ==
16993 section 5
16994 !! html/php
16995 <p>The tooltips shall not show entities to the user (ie. be double escaped)
16996 </p>
16997 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16998 <ul>
16999 <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>
17000 <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>
17001 <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>
17002 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
17003 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
17004 </ul>
17005 </div>
17006
17007 <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>
17008 <p>section 1
17009 </p>
17010 <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>
17011 <p>section 2
17012 </p>
17013 <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>
17014 <p>section 3
17015 </p>
17016 <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>
17017 <p>section 4
17018 </p>
17019 <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>
17020 <p>section 5
17021 </p>
17022 !! html/parsoid
17023 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
17024
17025 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span> text > text </h2>
17026 <p>section 1</p>
17027
17028 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span> text &lt; text </h2>
17029 <p>section 2</p>
17030
17031 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span> text &amp; text </h2>
17032 <p>section 3</p>
17033
17034 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span> text ' text </h2>
17035 <p>section 4</p>
17036
17037 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span> text " text </h2>
17038 <p>section 5</p>
17039 !! end
17040
17041 !! test
17042 Header with space, plus and underscore as entity
17043 !! wikitext
17044 Id should not contain + for spaces
17045
17046 == Space between Text ==
17047 section 1
17048
17049 == Space-Entity&#32;between&#32;Text ==
17050 section 2
17051
17052 == Plus+between+Text ==
17053 section 3
17054
17055 == Plus-Entity&#43;between&#43;Text ==
17056 section 4
17057
17058 == Underscore_between_Text ==
17059 section 5
17060
17061 == Underscore-Entity&#95;between&#95;Text ==
17062 section 6
17063
17064 [[#Space between Text]]
17065 [[#Space-Entity&#32;between&#32;Text]]
17066 [[#Plus+between+Text]]
17067 [[#Plus-Entity&#43;between&#43;Text]]
17068 [[#Underscore_between_Text]]
17069 [[#Underscore-Entity&#95;between&#95;Text]]
17070 !! html/php
17071 <p>Id should not contain + for spaces
17072 </p>
17073 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
17074 <ul>
17075 <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>
17076 <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>
17077 <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>
17078 <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>
17079 <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>
17080 <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>
17081 </ul>
17082 </div>
17083
17084 <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>
17085 <p>section 1
17086 </p>
17087 <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>
17088 <p>section 2
17089 </p>
17090 <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>
17091 <p>section 3
17092 </p>
17093 <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>
17094 <p>section 4
17095 </p>
17096 <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>
17097 <p>section 5
17098 </p>
17099 <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>
17100 <p>section 6
17101 </p><p><a href="#Space_between_Text">#Space between Text</a>
17102 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
17103 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
17104 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
17105 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
17106 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
17107 </p>
17108 !! html/parsoid
17109 <p>Id should not contain + for spaces</p>
17110
17111 <h2 id="Space_between_Text"> Space between Text </h2>
17112 <p>section 1</p>
17113
17114 <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>
17115 <p>section 2</p>
17116
17117 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span> Plus+between+Text </h2>
17118 <p>section 3</p>
17119
17120 <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>
17121 <p>section 4</p>
17122
17123 <h2 id="Underscore_between_Text"> Underscore_between_Text </h2>
17124 <p>section 5</p>
17125
17126 <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>
17127 <p>section 6</p>
17128
17129 <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>
17130 <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>
17131 <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>
17132 <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>
17133 <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>
17134 <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>
17135 !! end
17136
17137 # Parsoid html2wt disabled because it adds padding spaces around =
17138 !! test
17139 Headers with excess '=' characters
17140 (Are similar tests necessary beyond the 1st level?)
17141 !! options
17142 parsoid=wt2html,wt2wt,html2html
17143 !! wikitext
17144 =foo==
17145 ==foo=
17146 =''italic'' heading==
17147 ==''italic'' heading=
17148 !! html/php
17149 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
17150 <ul>
17151 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
17152 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
17153 <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>
17154 <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>
17155 </ul>
17156 </div>
17157
17158 <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>
17159 <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>
17160 <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>
17161 <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>
17162
17163 !! html/parsoid
17164 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
17165 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
17166 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
17167 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
17168 !! end
17169
17170 !! test
17171 HTML headers vs TOC (T25393)
17172 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17173 !! wikitext
17174 <h1>Header 1</h1>
17175 == Header 1.1 ==
17176 == Header 1.2 ==
17177
17178 <h1>Header 2
17179 </h1>
17180 == Header 2.1 ==
17181 == Header 2.2 ==
17182 __NOEDITSECTION__
17183 !! html/php
17184 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
17185 <ul>
17186 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17187 <ul>
17188 <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>
17189 <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>
17190 </ul>
17191 </li>
17192 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17193 <ul>
17194 <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>
17195 <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>
17196 </ul>
17197 </li>
17198 </ul>
17199 </div>
17200
17201 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17202 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17203 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17204 <h1><span class="mw-headline" id="Header_2">Header 2</span></h1>
17205 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17206 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17207
17208 !! html/parsoid
17209 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
17210 <h2 id="Header_1.1" data-parsoid='{}'> Header 1.1 </h2>
17211 <h2 id="Header_1.2" data-parsoid='{}'> Header 1.2 </h2>
17212
17213 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
17214 </h1>
17215 <h2 id="Header_2.1" data-parsoid='{}'> Header 2.1 </h2>
17216 <h2 id="Header_2.2" data-parsoid='{}'> Header 2.2 </h2>
17217 <meta property="mw:PageProp/noeditsection"/>
17218 !! end
17219
17220 !! test
17221 Single-line or multiline-comments can follow headings
17222 !! options
17223 parsoid=wt2html,wt2wt
17224 !! wikitext
17225 ==foo==<!---->
17226 ==bar==<!--c1-->
17227 ==baz==<!--
17228 c2
17229 c3-->
17230 !! html/php
17231 <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>
17232 <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>
17233 <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>
17234
17235 !! html/parsoid
17236 <h2 id="foo">foo</h2><!---->
17237 <h2 id="bar">bar</h2><!--c1-->
17238 <h2 id="baz">baz</h2><!--
17239 c2
17240 c3-->
17241 !! end
17242
17243 !! test
17244 T3219 URL next to image (broken)
17245 !! wikitext
17246 http://example.com[[File:Foobar.jpg]]
17247 !! html/php
17248 <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>
17249 </p>
17250 !! html/parsoid
17251 <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>
17252 !!end
17253
17254 !! test
17255 T3186 news: in the middle of text
17256 !! wikitext
17257 http://en.wikinews.org/wiki/Wikinews:Workplace
17258 !! html
17259 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
17260 </p>
17261 !!end
17262
17263
17264 !! test
17265 Namespaced link must have a title
17266 !! wikitext
17267 [[Project:]]
17268 !! html
17269 <p>[[Project:]]
17270 </p>
17271 !!end
17272
17273 !! test
17274 Namespaced link must have a title (bad fragment version)
17275 !! wikitext
17276 [[Project:#fragment]]
17277 !! html
17278 <p>[[Project:#fragment]]
17279 </p>
17280 !!end
17281
17282
17283 ###
17284 ### HTML tags and HTML attributes
17285 ###
17286
17287 !! test
17288 div with no attributes
17289 !! wikitext
17290 <div>HTML rocks</div>
17291 !! html
17292 <div>HTML rocks</div>
17293
17294 !! end
17295
17296 !! test
17297 div with double-quoted attribute
17298 !! wikitext
17299 <div id="rock">HTML rocks</div>
17300 !! html
17301 <div id="rock">HTML rocks</div>
17302
17303 !! end
17304
17305 !! test
17306 div with single-quoted attribute
17307 !! wikitext
17308 <div id='rock'>HTML rocks</div>
17309 !! html
17310 <div id="rock">HTML rocks</div>
17311
17312 !! end
17313
17314 !! test
17315 div with unquoted attribute
17316 !! wikitext
17317 <div id=rock>HTML rocks</div>
17318 !! html
17319 <div id="rock">HTML rocks</div>
17320
17321 !! end
17322
17323 !! test
17324 div with illegal double attributes
17325 !! wikitext
17326 <div id="a" id="b">HTML rocks</div>
17327 !! html
17328 <div id="b">HTML rocks</div>
17329
17330 !!end
17331
17332 !! test
17333 div with empty attribute value, space before equals
17334 !! options
17335 parsoid=wt2html,html2html
17336 !! wikitext
17337 <div class =>HTML rocks</div>
17338 !! html/php
17339 <div class="">HTML rocks</div>
17340
17341 !! html/parsoid
17342 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17343 !! end
17344
17345 !! test
17346 div with multiple empty attribute values
17347 !! config
17348 wgFragmentMode=[ 'html5', 'legacy' ]
17349 !! options
17350 parsoid=wt2html,html2html
17351 !! wikitext
17352 <div id= title=>HTML rocks</div>
17353 !! html/php
17354 <div id="title=">HTML rocks</div>
17355
17356 !! html/parsoid
17357 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17358 !! end
17359
17360 !! test
17361 table with multiple empty attribute values
17362 !! options
17363 parsoid=wt2html,html2html
17364 !! wikitext
17365 {| title= id=
17366 | hi
17367 |}
17368 !! html/php
17369 <table title="id=">
17370 <tr>
17371 <td> hi
17372 </td></tr></table>
17373
17374 !! html/parsoid
17375 <table title="id=">
17376 <tbody><tr><td> hi</td></tr>
17377 </tbody></table>
17378 !! end
17379
17380 !! test
17381 div with braces in attribute value
17382 !! wikitext
17383 <div title="{}">Foo</div>
17384 !! html/php
17385 <div title="&#123;&#125;">Foo</div>
17386
17387 !! html/parsoid
17388 <div title="{}">Foo</div>
17389 !! end
17390
17391 !! test
17392 div with empty attribute value, no space before equals
17393 !! options
17394 parsoid=wt2html,html2html
17395 !! wikitext
17396 <div class=>HTML rocks</div>
17397 !! html/php
17398 <div class="">HTML rocks</div>
17399
17400 !! html/parsoid
17401 <div class="">HTML rocks</div>
17402 !! end
17403
17404 !! test
17405 HTML multiple attributes correction
17406 !! wikitext
17407 <p class="error" class="awesome">Awesome!</p>
17408 !! html
17409 <p class="awesome">Awesome!</p>
17410
17411 !!end
17412
17413 !! test
17414 Table multiple attributes correction
17415 !! wikitext
17416 {|
17417 !+ class="error" class="awesome"| status
17418 |}
17419 !! html
17420 <table>
17421 <tr>
17422 <th class="awesome"> status
17423 </th></tr></table>
17424
17425 !!end
17426
17427 !! test
17428 DIV IN UPPERCASE
17429 !! wikitext
17430 <DIV ID="x">HTML ROCKS</DIV>
17431 !! html
17432 <div id="x">HTML ROCKS</div>
17433
17434 !!end
17435
17436 !! test
17437 Non-ASCII pseudo-tags are rendered as text
17438 !! wikitext
17439 <khyô>
17440 !! html
17441 <p>&lt;khyô&gt;
17442 </p>
17443 !! end
17444
17445 !! test
17446 Pseudo-tag with URL 'name' renders as url link
17447 !! wikitext
17448 <http://example.com/>
17449 !! html
17450 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
17451 </p>
17452 !! end
17453
17454 !! test
17455 text with amp in the middle of nowhere
17456 !! wikitext
17457 Remember AT&T?
17458 !! html
17459 <p>Remember AT&amp;T?
17460 </p>
17461 !! end
17462
17463 !! test
17464 text with character entity: eacute
17465 !! wikitext
17466 I always thought &eacute; was a cute letter.
17467 !! html
17468 <p>I always thought &#233; was a cute letter.
17469 </p>
17470 !! html+tidy
17471 <p>I always thought é was a cute letter.</p>
17472 !! end
17473
17474 !! test
17475 text with entity-escaped character entity-like string: eacute
17476 !! wikitext
17477 I always thought &amp;eacute; was a cute letter.
17478 !! html
17479 <p>I always thought &amp;eacute; was a cute letter.
17480 </p>
17481 !! end
17482
17483 !! test
17484 text with undefined character entity: xacute
17485 !! wikitext
17486 I always thought &xacute; was a cute letter.
17487 !! html
17488 <p>I always thought &amp;xacute; was a cute letter.
17489 </p>
17490 !! end
17491
17492 !! test
17493 HTML5 tags
17494 !! wikitext
17495 <data value="5">five</data>
17496 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17497 <mark>This highlighted text</mark>
17498 !! html
17499 <p><data value="5">five</data>
17500 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17501 <mark>This highlighted text</mark>
17502 </p>
17503 !! end
17504
17505 !! test
17506 HTML tag with leading space is parsed as text
17507 !! wikitext
17508 < div>foo< /div>
17509 !! html
17510 <p>&lt; div&gt;foo&lt; /div&gt;
17511 </p>
17512 !! end
17513
17514 ## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
17515 ## the HTML5 parsing spec.
17516 !! test
17517 Element with broken attribute syntax
17518 !! options
17519 parsoid=wt2html
17520 !! wikitext
17521 <div style=" style="123">hi</div>
17522 <div =>ho</div>
17523 !! html/php
17524 <div style="123">hi</div>
17525 <div>ho</div>
17526
17527 !! html/parsoid
17528 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
17529 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
17530 !! end
17531
17532 ###
17533 ### Nesting tests (see T43545, T52604, T53081)
17534 ###
17535
17536 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
17537 # Note that html2wt is considerably more difficult if we use <b> in
17538 # the test case, instead of <small>
17539 !! test
17540 Ensure that HTML adoption agency algorithm is properly implemented.
17541 !! wikitext
17542 <small>X<small>Y</small>Z</small>
17543 !! html
17544 <p><small>X<small>Y</small>Z</small>
17545 </p>
17546 !! end
17547
17548 # This was T43545 in the PHP parser.
17549 # Note that tidy doesn't handle this correctly.
17550 !! test
17551 Nesting of <kbd>
17552 !! wikitext
17553 <kbd>X<kbd>Y</kbd>Z</kbd>
17554 !! html
17555 <p><kbd>X<kbd>Y</kbd>Z</kbd>
17556 </p>
17557 !! end
17558
17559 # The following cases were T53081 in the PHP parser.
17560 # Note that there are some other nestable tags (b, i, etc) which are
17561 # not covered; see T53081 for discussion.
17562
17563 # Note that tidy doesn't handle this correctly.
17564 !! test
17565 Nesting of <em>
17566 !! wikitext
17567 <em>X<em>Y</em>Z</em>
17568 !! html
17569 <p><em>X<em>Y</em>Z</em>
17570 </p>
17571 !! end
17572
17573 # Note that tidy doesn't handle this correctly.
17574 !! test
17575 Nesting of <strong>
17576 !! wikitext
17577 <strong>X<strong>Y</strong>Z</strong>
17578 !! html
17579 <p><strong>X<strong>Y</strong>Z</strong>
17580 </p>
17581 !! end
17582
17583 !! test
17584 Nesting of <q>
17585 !! wikitext
17586 <q>X<q>Y</q>Z</q>
17587 !! html+tidy
17588 <p><q>X<q>Y</q>Z</q></p>
17589 !! end
17590
17591 # Note that tidy doesn't handle this correctly.
17592 !! test
17593 Nesting of <ruby>
17594 !! wikitext
17595 <ruby>X<ruby>Y</ruby>Z</ruby>
17596 !! html
17597 <p><ruby>X<ruby>Y</ruby>Z</ruby>
17598 </p>
17599 !! end
17600
17601 # Note that tidy doesn't handle this correctly.
17602 !! test
17603 Nesting of <bdo>
17604 !! wikitext
17605 <bdo>X<bdo>Y</bdo>Z</bdo>
17606 !! html
17607 <p><bdo>X<bdo>Y</bdo>Z</bdo>
17608 </p>
17609 !! end
17610
17611
17612 ###
17613 ### Media links
17614 ###
17615
17616 !! test
17617 Media link
17618 !! wikitext
17619 [[Media:Foobar.jpg]]
17620 [[Media:Video.ogv]]
17621 [[:Media:Video.ogv]]
17622 !! html/php
17623 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
17624 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17625 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17626 </p>
17627 !! html/parsoid
17628 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
17629 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv">Media:Video.ogv</a>
17630 <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>
17631 !! end
17632
17633 !! test
17634 Media link with text
17635 !! wikitext
17636 [[Media:Foobar.jpg|A neat file to look at]]
17637 !! html/php
17638 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
17639 </p>
17640 !! html/parsoid
17641 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
17642 !! end
17643
17644 # FIXME: this is still bad HTML tag nesting
17645 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
17646 !! test
17647 Media link with nasty text
17648 !! wikitext
17649 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
17650 !! html/php
17651 <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>
17652
17653 !! html+php/tidy
17654 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link</a></p>
17655 <div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div>
17656 !! html/parsoid
17657 <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>
17658
17659 !! end
17660
17661 !! test
17662 Media link to nonexistent file (T3702)
17663 !! wikitext
17664 [[Media:No such.jpg]]
17665 [[Media:No_such file.jpg]]
17666 !! html/php
17667 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
17668 <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>
17669 </p>
17670 !! html/parsoid
17671 <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>
17672 <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>
17673 !! end
17674
17675 !! test
17676 Image link to nonexistent file (T3850 - good)
17677 !! wikitext
17678 [[File:No_such.jpg]]
17679 !! html/php
17680 <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>
17681 </p>
17682 !! html/parsoid
17683 <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>
17684 !! end
17685
17686 !! test
17687 :Image link to nonexistent file (T3850 - bad)
17688 !! wikitext
17689 [[:Image:No such.jpg]]
17690 !! html/php
17691 <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>
17692 </p>
17693 !! html/parsoid
17694 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
17695 !! end
17696
17697 !! test
17698 Character reference normalization in link text (T3938)
17699 !! wikitext
17700 [[Main Page|this&that]]
17701 !! html
17702 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
17703 </p>
17704 !!end
17705
17706 !! article
17707 אַ
17708 !! text
17709 Test for unicode normalization
17710
17711 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
17712 !! endarticle
17713
17714 !! test
17715 (T21451) Links should refer to the normalized form.
17716 !! wikitext
17717 [[&#xFB2E;]]
17718 [[&#x5d0;&#x5b7;]]
17719 [[&#x5d0;ַ]]
17720 [[א&#x5b7;]]
17721 [[אַ]]
17722 !! html
17723 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
17724 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
17725 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
17726 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
17727 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
17728 </p>
17729 !! end
17730
17731 !! test
17732 Empty attribute crash test (T4067)
17733 !! wikitext
17734 <font color="">foo</font>
17735 !! html
17736 <p><font color="">foo</font>
17737 </p>
17738 !! end
17739
17740 !! test
17741 Empty attribute crash test single-quotes (T4067)
17742 !! wikitext
17743 <font color=''>foo</font>
17744 !! html
17745 <p><font color="">foo</font>
17746 </p>
17747 !! end
17748
17749 !! test
17750 Attribute test: equals, then nothing
17751 !! options
17752 parsoid=wt2html,html2html
17753 !! wikitext
17754 <font color=>foo</font>
17755 !! html/php
17756 <p><font color="">foo</font>
17757 </p>
17758 !! html/parsoid
17759 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
17760 !! end
17761
17762 !! test
17763 Attribute test: unquoted value
17764 !! options
17765 parsoid=wt2html,html2html
17766 !! wikitext
17767 <font color=x>foo</font>
17768 !! html/php
17769 <p><font color="x">foo</font>
17770 </p>
17771 !! html/parsoid
17772 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
17773 !! end
17774
17775 !! test
17776 Attribute test: unquoted but illegal value (hash)
17777 !! wikitext
17778 <font color=#x>foo</font>
17779 !! html
17780 <p><font color="#x">foo</font>
17781 </p>
17782 !! end
17783
17784 # Parsoid does not serialize to empty attribute syntax,
17785 # so wt2wt and html2wt cases are skipped
17786 !! test
17787 Attribute test: no value (T54330)
17788 !! options
17789 parsoid=wt2html,html2html
17790 !! wikitext
17791 <font color>foo</font>
17792 !! html/php
17793 <p><font color="">foo</font>
17794 </p>
17795 !! html/parsoid
17796 <p><font color="">foo</font></p>
17797 !! end
17798
17799 !! test
17800 T4095: link with three closing brackets
17801 !! wikitext
17802 [[Main Page]]]
17803 !! html/php
17804 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
17805 </p>
17806 !! html/parsoid
17807 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
17808 !! end
17809
17810 !! test
17811 T4095: link with pipe and three closing brackets
17812 !! wikitext
17813 [[Main Page|link]]]
17814 !! html/php
17815 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
17816 </p>
17817 !! html/parsoid
17818 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
17819 !! end
17820
17821 !! test
17822 T4095: link with pipe and three closing brackets, version 2
17823 !! wikitext
17824 [[Main Page|[http://example.com/]]]
17825 !! html/php
17826 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
17827 </p>
17828 !! html/parsoid
17829 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
17830 !! end
17831
17832
17833 ###
17834 ### Safety
17835 ###
17836
17837 !! article
17838 Template:Dangerous attribute
17839 !! text
17840 " onmouseover="alert(document.cookie)
17841 !! endarticle
17842
17843 !! article
17844 Template:Dangerous style attribute
17845 !! text
17846 border-size: expression(alert(document.cookie))
17847 !! endarticle
17848
17849 !! article
17850 Template:Div style
17851 !! text
17852 <div style="float: right; {{{1}}}">Magic div</div>
17853 !! endarticle
17854
17855 !! test
17856 T4304: HTML attribute safety (safe template; regression T4309)
17857 !! wikitext
17858 <div title="{{test}}"></div>
17859 !! html/php
17860 <div title="This is a test template"></div>
17861
17862 !! html/parsoid
17863 <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>
17864 !! end
17865
17866 # Parsoid has enough context to handle this case
17867 !! test
17868 T4304: HTML attribute safety (dangerous template; 2309)
17869 !! wikitext
17870 <div title="{{dangerous attribute}}"></div>
17871 !! html/php
17872 <div title=""></div>
17873
17874 !! html/parsoid
17875 <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>
17876 !! end
17877
17878 !! test
17879 T4304: HTML attribute safety (dangerous style template; 2309)
17880 !! wikitext
17881 <div style="{{dangerous style attribute}}"></div>
17882 !! html/php
17883 <div style="/* insecure input */"></div>
17884
17885 !! html/parsoid
17886 <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>
17887 !! end
17888
17889 !! test
17890 T4304: HTML attribute safety (safe parameter; 2309)
17891 !! wikitext
17892 {{div style|width: 200px}}
17893 !! html/php
17894 <div style="float: right; width: 200px">Magic div</div>
17895
17896 !! html/parsoid
17897 <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>
17898 !! end
17899
17900 !! test
17901 T4304: HTML attribute safety (unsafe parameter; 2309)
17902 !! wikitext
17903 {{div style|width: expression(alert(document.cookie))}}
17904 !! html/php
17905 <div style="/* insecure input */">Magic div</div>
17906
17907 !! html/parsoid
17908 <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>
17909 !! end
17910
17911 ## Parsoid output here differs; needs investigation.
17912 !! test
17913 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
17914 !! wikitext
17915 {{div style|"><script>alert(document.cookie)</script>}}
17916 !! html
17917 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17918
17919 !! end
17920
17921 ## Parsoid output here differs; needs investigation.
17922 !! test
17923 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
17924 !! wikitext
17925 {{div style|" ><script>alert(document.cookie)</script>}}
17926 !! html
17927 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17928
17929 !! end
17930
17931 !! test
17932 T4304: HTML attribute safety (link)
17933 !! wikitext
17934 <div title="[[Main Page]]"></div>
17935 !! html/php
17936 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
17937
17938 !! html/parsoid
17939 <div title="[[Main Page]]"></div>
17940 !! end
17941
17942 !! test
17943 T4304: HTML attribute safety (italics)
17944 !! wikitext
17945 <div title="''foobar''"></div>
17946 !! html
17947 <div title="&#39;&#39;foobar&#39;&#39;"></div>
17948
17949 !! end
17950
17951 !! test
17952 T4304: HTML attribute safety (bold)
17953 !! wikitext
17954 <div title="'''foobar'''"></div>
17955 !! html
17956 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
17957
17958 !! end
17959
17960 !! test
17961 T4304: HTML attribute safety (ISBN)
17962 !! wikitext
17963 <div title="ISBN 1234567890"></div>
17964 !! html
17965 <div title="&#73;SBN 1234567890"></div>
17966
17967 !! end
17968
17969 !! test
17970 T4304: HTML attribute safety (RFC)
17971 !! wikitext
17972 <div title="RFC 1234"></div>
17973 !! html
17974 <div title="&#82;FC 1234"></div>
17975
17976 !! end
17977
17978 !! test
17979 T4304: HTML attribute safety (PMID)
17980 !! wikitext
17981 <div title="PMID 1234567890"></div>
17982 !! html
17983 <div title="&#80;MID 1234567890"></div>
17984
17985 !! end
17986
17987 !! test
17988 T4304: HTML attribute safety (web link)
17989 !! wikitext
17990 <div title="http://example.com/"></div>
17991 !! html
17992 <div title="http&#58;//example.com/"></div>
17993
17994 !! end
17995
17996 !! test
17997 T4304: HTML attribute safety (named web link)
17998 !! wikitext
17999 <div title="[http://example.com/ link]"></div>
18000 !! html/php
18001 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
18002
18003 !! html/parsoid
18004 <div title="[http://example.com/ link]"></div>
18005 !! end
18006
18007 !! test
18008 T5244: HTML attribute safety (extension; safe)
18009 !! wikitext
18010 <div style="<nowiki>background:blue</nowiki>"></div>
18011 !! html/php
18012 <div style="background:blue"></div>
18013
18014 !! html/parsoid
18015 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
18016 !! end
18017
18018 !! test
18019 T5244: HTML attribute safety (extension; unsafe)
18020 !! wikitext
18021 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
18022 !! html/php
18023 <div style="/* insecure input */"></div>
18024
18025 !! html/parsoid
18026 <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>
18027 !! end
18028
18029 # More MSIE fun discovered by Tom Gilder
18030
18031 !! test
18032 MSIE CSS safety test: spurious slash
18033 !! wikitext
18034 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
18035 !! html/php
18036 <div style="/* insecure input */">evil</div>
18037
18038 !! html/parsoid
18039 <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>
18040 !! end
18041
18042 !! test
18043 MSIE CSS safety test: hex code
18044 !! wikitext
18045 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
18046 !! html/php
18047 <div style="/* insecure input */">evil</div>
18048
18049 !! html/parsoid
18050 <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>
18051 !! end
18052
18053 !! test
18054 MSIE CSS safety test: comment in url
18055 !! wikitext
18056 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
18057 !! html/php
18058 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
18059
18060 !! html/parsoid
18061 <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>
18062 !! end
18063
18064 !! test
18065 MSIE CSS safety test: comment in expression
18066 !! wikitext
18067 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
18068 !! html/php
18069 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
18070
18071 !! html/parsoid
18072 <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>
18073 !! end
18074
18075 !! test
18076 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
18077 !! wikitext
18078 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
18079 !! html/php
18080 <p style="/* invalid control char */">A</p>
18081
18082 !! html/parsoid
18083 <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>
18084 !! end
18085
18086 !! test
18087 MSIE 6 CSS safety test: Fullwidth (T57332)
18088 !! wikitext
18089 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
18090 <div style="top:EXPRESSION(alert())">B</div>
18091 !! html/php
18092 <p style="/* insecure input */">A</p>
18093 <div style="/* insecure input */">B</div>
18094
18095 !! html/parsoid
18096 <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>
18097 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
18098 !! end
18099
18100 !! test
18101 MSIE 6 CSS safety test: IPA extensions (T57332)
18102 !! wikitext
18103 <div style="background-image:uʀʟ(javascript:alert())">A</div>
18104 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
18105 !! html/php
18106 <div style="/* insecure input */">A</div>
18107 <p style="/* insecure input */">B</p>
18108
18109 !! html/parsoid
18110 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
18111 <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>
18112 !! end
18113
18114 !! test
18115 MSIE 6 CSS safety test: sup/sub script (T57332)
18116 !! wikitext
18117 <div style="background-image:url⁽javascript:alert())">A</div>
18118 <div style="background-image:url₍javascript:alert())">B</div>
18119 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
18120 !! html/php
18121 <div style="/* insecure input */">A</div>
18122 <div style="/* insecure input */">B</div>
18123 <p style="/* insecure input */">C</p>
18124
18125 !! html/parsoid
18126 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
18127 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
18128 <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>
18129 !! end
18130
18131 !! test
18132 Opera -o-link CSS
18133 !! options
18134 parsoid=wt2html,html2html
18135 !! wikitext
18136 <div
18137 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;"
18138 style="-o-link:attr(title);-o-link-source:current">X</div>
18139 !! html/php
18140 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
18141
18142 !! html/parsoid
18143 <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>
18144 !! end
18145
18146 !! test
18147 MSIE 6 CSS safety test: Repetition markers (T57332)
18148 !! wikitext
18149 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
18150 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
18151 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
18152 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
18153 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
18154 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
18155 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
18156 !! html/php
18157 <p style="/* insecure input */">A</p>
18158 <p style="/* insecure input */">B</p>
18159 <p style="/* insecure input */">C</p>
18160 <p style="/* insecure input */">D</p>
18161 <p style="/* insecure input */">E</p>
18162 <p style="/* insecure input */">F</p>
18163 <p style="/* insecure input */">G</p>
18164
18165 !! html/parsoid
18166 <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>
18167 <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>
18168 <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>
18169 <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>
18170 <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>
18171 <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>
18172 <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>
18173 !! end
18174
18175 !! test
18176 Table attribute legitimate extension
18177 !! wikitext
18178 {|
18179 !+ style="<nowiki>color:blue</nowiki>"| status
18180 |}
18181 !! html
18182 <table>
18183 <tr>
18184 <th style="color:blue"> status
18185 </th></tr></table>
18186
18187 !!end
18188
18189 !! test
18190 Table attribute safety
18191 !! wikitext
18192 {|
18193 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
18194 |}
18195 !! html
18196 <table>
18197 <tr>
18198 <th style="/* insecure input */"> status
18199 </th></tr></table>
18200
18201 !! end
18202
18203 !! test
18204 CSS line continuation 1
18205 !! wikitext
18206 <div style="background-image: u\&#10;rl(test.jpg);"></div>
18207 !! html
18208 <div style="/* insecure input */"></div>
18209
18210 !! end
18211
18212 !! test
18213 CSS line continuation 2
18214 !! wikitext
18215 <div style="background-image: u\&#13;rl(test.jpg); "></div>
18216 !! html
18217 <div style="/* invalid control char */"></div>
18218
18219 !! end
18220
18221 !! article
18222 Template:Identity
18223 !! text
18224 {{{1}}}
18225 !! endarticle
18226
18227 !! test
18228 Expansion of multi-line templates in attribute values (T8255)
18229 !! wikitext
18230 <div style="background: {{identity|#00FF00}}">-</div>
18231 !! html
18232 <div style="background: #00FF00">-</div>
18233
18234 !! end
18235
18236 !! test
18237 Expansion of multi-line templates in attribute values (T8255 sanity check)
18238 !! wikitext
18239 <div style="background:
18240 #00FF00">-</div>
18241 !! html/php
18242 <div style="background: #00FF00">-</div>
18243
18244 !! html/parsoid
18245 <div style="background:
18246 #00FF00">-</div>
18247 !! end
18248
18249 !! test
18250 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
18251 !! wikitext
18252 <div style="background: &#10;#00FF00">-</div>
18253 !! html
18254 <div style="background: &#10;#00FF00">-</div>
18255
18256 !! end
18257
18258 !! test
18259 Tags which are hidden from Tidy cannot pass through the Sanitizer
18260 !! wikitext
18261 <mw:toc><script>alert();</script></mw:toc>
18262 !! html+tidy
18263 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;</p>
18264 !! end
18265
18266 ###
18267 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
18268 ###
18269
18270 !! test
18271 Parser hook: empty input
18272 !! wikitext
18273 <tag></tag>
18274 !! html/php
18275 <pre>
18276 ''
18277 array (
18278 )
18279 </pre>
18280
18281 !! html/parsoid
18282 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18283 !! end
18284
18285 ## Don't expect parsoid to rt this form.
18286 !! test
18287 Parser hook: empty input using terminated empty elements
18288 !! options
18289 parsoid=wt2html,html2html
18290 !! wikitext
18291 <tag/>
18292 !! html/php
18293 <pre>
18294 NULL
18295 array (
18296 )
18297 </pre>
18298
18299 !! html/parsoid
18300 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18301 !! end
18302
18303 !! test
18304 Parser hook: empty input using terminated empty elements (space before)
18305 !! wikitext
18306 <tag />
18307 !! html/php
18308 <pre>
18309 NULL
18310 array (
18311 )
18312 </pre>
18313
18314 !! html/parsoid
18315 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18316 !! end
18317
18318 !! test
18319 Parser hook: basic input
18320 !! wikitext
18321 <tag>input</tag>
18322 !! html/php
18323 <pre>
18324 'input'
18325 array (
18326 )
18327 </pre>
18328
18329 !! html/parsoid
18330 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18331 !! end
18332
18333 ## Don't expect parsoid to rt this form.
18334 !! test
18335 Parser hook: case insensitive
18336 !! options
18337 parsoid=wt2html,html2html
18338 !! wikitext
18339 <TAG>input</TAG>
18340 !! html/php
18341 <pre>
18342 'input'
18343 array (
18344 )
18345 </pre>
18346
18347 !! html/parsoid
18348 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18349 !! end
18350
18351 ## Don't expect parsoid to rt this form.
18352 !! test
18353 Parser hook: case insensitive, redux
18354 !! options
18355 parsoid=wt2html,html2html
18356 !! wikitext
18357 <TaG>input</TAg>
18358 !! html/php
18359 <pre>
18360 'input'
18361 array (
18362 )
18363 </pre>
18364
18365 !! html/parsoid
18366 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18367 !! end
18368
18369 !! test
18370 Parser hook: nested tags
18371 !! wikitext
18372 <tag><tag></tag></tag>
18373 !! html/php
18374 <pre>
18375 '<tag>'
18376 array (
18377 )
18378 </pre>&lt;/tag&gt;
18379
18380 !! html/parsoid
18381 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}' data-parsoid='{}' about="#mwt2"></pre>&lt;/tag>
18382 !! end
18383
18384 !! test
18385 Parser hook: basic arguments
18386 !! wikitext
18387 <tag width="200" height="100" depth="50" square=""></tag>
18388 !! html/php
18389 <pre>
18390 ''
18391 array (
18392 'width' => '200',
18393 'height' => '100',
18394 'depth' => '50',
18395 'square' => '',
18396 )
18397 </pre>
18398
18399 !! html/parsoid
18400 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18401 !! end
18402
18403 ## Don't expect parsoid to rt this form.
18404 !! test
18405 Parser hook: basic arguments, variations
18406 !! options
18407 parsoid=wt2html,html2html
18408 !! wikitext
18409 <tag width=200 height = "100" depth = '50' square></tag>
18410 !! html/php
18411 <pre>
18412 ''
18413 array (
18414 'width' => '200',
18415 'height' => '100',
18416 'depth' => '50',
18417 'square' => '',
18418 )
18419 </pre>
18420
18421 !! html/parsoid
18422 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18423 !! end
18424
18425 !! test
18426 Parser hook: argument containing a forward slash (T7344)
18427 !! wikitext
18428 <tag filename="/tmp/bla"></tag>
18429 !! html/php
18430 <pre>
18431 ''
18432 array (
18433 'filename' => '/tmp/bla',
18434 )
18435 </pre>
18436
18437 !! html/parsoid
18438 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18439 !! end
18440
18441 ## Don't expect parsoid to rt this form.
18442 !! test
18443 Parser hook: empty input using terminated empty elements (T4374)
18444 !! options
18445 parsoid=wt2html,html2html
18446 !! wikitext
18447 <tag foo=bar/>text
18448 !! html/php
18449 <pre>
18450 NULL
18451 array (
18452 'foo' => 'bar',
18453 )
18454 </pre>text
18455
18456 !! html/parsoid
18457 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text
18458 !! end
18459
18460 ## </tag> should be output literally since there is no matching tag that begins it
18461 ## Don't expect parsoid to rt this form.
18462 !! test
18463 Parser hook: basic arguments using terminated empty elements (T4374)
18464 !! options
18465 parsoid=wt2html
18466 !! wikitext
18467 <tag width=200 height = "100" depth = '50' square/>
18468 other stuff
18469 </tag>
18470 !! html/php
18471 <pre>
18472 NULL
18473 array (
18474 'width' => '200',
18475 'height' => '100',
18476 'depth' => '50',
18477 'square' => '',
18478 )
18479 </pre>
18480 <p>other stuff
18481 &lt;/tag&gt;
18482 </p>
18483 !! html/parsoid
18484 <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
18485 &lt;/tag></p>
18486 !! end
18487
18488 ## Don't expect parsoid to rt this form.
18489 !! test
18490 Parser hook: Don't allow unclosed extension tags
18491 !! options
18492 parsoid=wt2html
18493 !! wikitext
18494 test <tag>123
18495
18496 this is a '''test'''
18497 !! html/php
18498 <p>test &lt;tag&gt;123
18499 </p><p>this is a <b>test</b>
18500 </p>
18501 !! html/parsoid
18502 <p>test &lt;tag>123</p>
18503
18504 <p>this is a <b>test</b></p>
18505 !! end
18506
18507 ###
18508 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
18509 ###
18510
18511 !! test
18512 Parser hook: static parser hook not inside a comment
18513 !! wikitext
18514 <statictag>hello, world</statictag>
18515
18516 <statictag action="flush" />
18517 !! html/php
18518 <p><br />
18519 hello, world
18520 </p>
18521 !! html/parsoid
18522 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
18523 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p>
18524 !! end
18525
18526 !! test
18527 Parser hook: static parser hook inside a comment
18528 !! wikitext
18529 <!-- <statictag>hello, world</statictag> -->
18530 <statictag action="flush" />
18531 !! html/php
18532 <p><br />
18533 </p>
18534 !! html/parsoid
18535 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
18536 <p typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about='#mwt2'></p>
18537 !! end
18538
18539 # Nested template calls; this case was broken by Parser.php rev 1.506,
18540 # since reverted.
18541
18542 !! article
18543 Template:One-parameter
18544 !! text
18545 (My parameter is: {{{1}}})
18546 !! endarticle
18547
18548 !! article
18549 Template:Map-one-parameter
18550 !! text
18551 {{{{{1}}}|{{{2}}}}}
18552 !! endarticle
18553
18554 !! test
18555 Nested template calls
18556 !! wikitext
18557 {{Map-one-parameter|One-parameter|param}}
18558 !! html
18559 <p>(My parameter is: param)
18560 </p>
18561 !! end
18562
18563
18564 ###
18565 ### Sanitizer
18566 ###
18567
18568 # HTML+Tidy strips out empty tags completely. Parsoid doesn't.
18569 # FIXME: Wikitext for this first test doesn't match its title.
18570 !! test
18571 Sanitizer: Closing of open tags
18572 !! wikitext
18573 <s></s><table></table>
18574 !! html/php+tidy
18575
18576 !! html/parsoid
18577 <s></s><table></table>
18578 !! end
18579
18580 !! test
18581 Sanitizer: Closing of open but not closed tags
18582 !! wikitext
18583 <s>foo
18584 !! html
18585 <p><s>foo</s>
18586 </p>
18587 !! end
18588
18589 !! test
18590 Sanitizer: Closing of closed but not open tags
18591 !! options
18592 parsoid=wt2html
18593 !! wikitext
18594 </s>
18595 !! html/php+tidy
18596 !! html/parsoid
18597 !! end
18598
18599 !! test
18600 Sanitizer: Closing of closed but not open table tags
18601 !! options
18602 parsoid=wt2html
18603 !! wikitext
18604 Table not started</td></tr></table>
18605 !! html/php+tidy
18606 <p>Table not started</p>
18607 !! html/parsoid
18608 <p>Table not started</p>
18609 !! end
18610
18611 !! test
18612 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
18613 !! config
18614 wgFragmentMode=[ 'html5', 'legacy' ]
18615 !! wikitext
18616 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18617 !! html/php
18618 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
18619 </p>
18620 !! html/parsoid
18621 <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>
18622 !! end
18623
18624 !! test
18625 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
18626 !! config
18627 wgFragmentMode=[ 'legacy' ]
18628 !! wikitext
18629 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18630 !! html/php
18631 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
18632 </p>
18633 !! end
18634
18635 # In HTML5, the restrictions are that id must contain at least one character,
18636 # and must not contain any space characters.
18637 !! test
18638 Sanitizer: Validating the contents of the id attribute (T6515)
18639 !! options
18640 disabled
18641 !! wikitext
18642 <br id="" /><br id="a space" />
18643 !! html
18644 Something ...
18645 !! end
18646
18647 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
18648 !! test
18649 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
18650 !! options
18651 disabled
18652 !! wikitext
18653 <br id="foo" /><br id="foo" />
18654 !! html
18655 Something need to be done. foo-2 ?
18656 !! end
18657
18658 !! test
18659 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
18660 !! wikitext
18661 <div itemscope>
18662 <meta itemprop="hello" content="world">
18663 <meta http-equiv="refresh" content="5">
18664 <meta itemprop="hello" http-equiv="refresh" content="5">
18665 <link itemprop="hello" href="{{SERVER}}">
18666 <link rel="stylesheet" href="{{SERVER}}">
18667 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
18668 </div>
18669 !! html
18670 <div itemscope="">
18671 <p> <meta itemprop="hello" content="world" />
18672 &lt;meta http-equiv="refresh" content="5"&gt;
18673 <meta itemprop="hello" content="5" />
18674 <link itemprop="hello" href="http&#58;//example.org" />
18675 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
18676 <link itemprop="hello" href="http&#58;//example.org" />
18677 </p>
18678 </div>
18679
18680 !! end
18681
18682 !! test
18683 Sanitizer: Strip comments from CSS attributes
18684 !! options
18685 parsoid=wt2html,wt2wt
18686 !! wikitext
18687 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
18688 !! html/php
18689 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
18690 </p>
18691 !! html/parsoid
18692 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
18693 !! end
18694
18695 !! test
18696 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
18697 !! wikitext
18698 [[meatball:Soft"Security]]
18699 !! html/php
18700 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
18701 </p>
18702 !! html/parsoid
18703 <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>
18704 !! end
18705
18706 !! test
18707 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
18708 !! wikitext
18709 [[meatball:Foo<Bar]]
18710 [[meatball:Foo>Bar]]
18711 [[meatball:Foo&lt;bar]]
18712 [[meatball:Foo&gt;bar]]
18713 !! html/php
18714 <p>[[meatball:Foo&lt;Bar]]
18715 [[meatball:Foo&gt;Bar]]
18716 [[meatball:Foo&lt;bar]]
18717 [[meatball:Foo&gt;bar]]
18718 </p>
18719 !! html/parsoid
18720 <p>[[meatball:Foo&lt;Bar]]
18721 [[meatball:Foo>Bar]]
18722 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
18723 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
18724 !! end
18725
18726 !! test
18727 Language converter: output gets cut off unexpectedly (T7757)
18728 !! options
18729 language=zh
18730 !! wikitext
18731 this bit is safe: }-
18732
18733 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
18734
18735 then we get cut off here: }-
18736
18737 all additional text is vanished
18738 !! html/php
18739 <p>this bit is safe: }-
18740 </p><p>but if we add a conversion instance: xxx
18741 </p><p>then we get cut off here: }-
18742 </p><p>all additional text is vanished
18743 </p>
18744 !! html/parsoid
18745 <p>this bit is safe: }-</p>
18746 <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>
18747 <p>then we get cut off here: }-</p>
18748 <p>all additional text is vanished</p>
18749 !! end
18750
18751 !! test
18752 Language converter glossary rules inside attributes (T119158)
18753 !! options
18754 language=sr variant=sr-el
18755 !! wikitext
18756 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
18757
18758 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
18759 !! html/php
18760 <p>
18761 </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>
18762 </p>
18763 !! html/parsoid
18764 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
18765
18766 <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>
18767 !! end
18768
18769 !! test
18770 Self closed html pairs (T7487)
18771 !! wikitext
18772 <center><font id="bug" />Centered text</center>
18773 <div><font id="bug2" />In div text</div>
18774 !! html+tidy
18775 <center><font id="bug"></font>Centered text</center>
18776 <div><font id="bug2"></font>In div text</div>
18777 !! end
18778
18779 #
18780 #
18781 #
18782
18783 !! test
18784 Punctuation: nbsp before exclamation
18785 !! wikitext
18786 C'est grave !
18787 !! html
18788 <p>C'est grave&#160;!
18789 </p>
18790 !! end
18791
18792 !! test
18793 Punctuation: CSS !important (T13874)
18794 !! wikitext
18795 <div style="width:50% !important">important</div>
18796 !! html
18797 <div style="width:50% !important">important</div>
18798
18799 !!end
18800
18801 !! test
18802 Punctuation: CSS ! important (T13874; with space after)
18803 !! wikitext
18804 <div style="width:50% ! important">important</div>
18805 !! html
18806 <div style="width:50% ! important">important</div>
18807
18808 !!end
18809
18810 !! test
18811 HTML bullet list, closed tags (T7497)
18812 !! wikitext
18813 <ul>
18814 <li>One</li>
18815 <li>Two</li>
18816 </ul>
18817 !! html/php
18818 <ul>
18819 <li>One</li>
18820 <li>Two</li>
18821 </ul>
18822
18823 !! html/parsoid
18824 <ul data-parsoid='{"stx":"html"}'>
18825 <li data-parsoid='{"stx":"html"}'>One</li>
18826 <li data-parsoid='{"stx":"html"}'>Two</li>
18827 </ul>
18828
18829 !! end
18830
18831 !! test
18832 HTML bullet list, unclosed tags (T7497)
18833 !! wikitext
18834 <ul>
18835 <li>One
18836 <li>Two
18837 </ul>
18838 !! html/php+tidy
18839 <ul>
18840 <li>One</li>
18841 <li>Two</li>
18842 </ul>
18843 !! html/parsoid
18844 <ul data-parsoid='{"stx":"html"}'>
18845 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18846 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18847 </ul>
18848
18849 !! end
18850
18851 !! test
18852 HTML ordered list, closed tags (T7497)
18853 !! wikitext
18854 <ol>
18855 <li>One</li>
18856 <li>Two</li>
18857 </ol>
18858 !! html/php
18859 <ol>
18860 <li>One</li>
18861 <li>Two</li>
18862 </ol>
18863
18864 !! html/parsoid
18865 <ol data-parsoid='{"stx":"html"}'>
18866 <li data-parsoid='{"stx":"html"}'>One</li>
18867 <li data-parsoid='{"stx":"html"}'>Two</li>
18868 </ol>
18869
18870 !! end
18871
18872 !! test
18873 HTML ordered list, unclosed tags (T7497)
18874 !! options
18875 !! wikitext
18876 <ol>
18877 <li>One
18878 <li>Two
18879 </ol>
18880 !! html/php+tidy
18881 <ol>
18882 <li>One</li>
18883 <li>Two</li>
18884 </ol>
18885 !! html/parsoid
18886 <ol data-parsoid='{"stx":"html"}'>
18887 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18888 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18889 </ol>
18890
18891 !! end
18892
18893 !! test
18894 HTML nested bullet list, closed tags (T7497)
18895 !! wikitext
18896 <ul>
18897 <li>One</li>
18898 <li>Two:
18899 <ul>
18900 <li>Sub-one</li>
18901 <li>Sub-two</li>
18902 </ul>
18903 </li>
18904 </ul>
18905 !! html/php
18906 <ul>
18907 <li>One</li>
18908 <li>Two:
18909 <ul>
18910 <li>Sub-one</li>
18911 <li>Sub-two</li>
18912 </ul>
18913 </li>
18914 </ul>
18915
18916 !! html/parsoid
18917 <ul data-parsoid='{"stx":"html"}'>
18918 <li data-parsoid='{"stx":"html"}'>One</li>
18919 <li data-parsoid='{"stx":"html"}'>Two:
18920 <ul data-parsoid='{"stx":"html"}'>
18921 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
18922 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
18923 </ul>
18924 </li>
18925 </ul>
18926 !! end
18927
18928 !! test
18929 HTML nested bullet list, open tags (T7497)
18930 !! wikitext
18931 <ul>
18932 <li>One
18933 <li>Two:
18934 <ul>
18935 <li>Sub-one
18936 <li>Sub-two
18937 </ul>
18938 </ul>
18939 !! html/php+tidy
18940 <ul>
18941 <li>One</li>
18942 <li>Two:
18943 <ul>
18944 <li>Sub-one</li>
18945 <li>Sub-two</li>
18946 </ul>
18947 </li>
18948 </ul>
18949 !! html/parsoid
18950 <ul>
18951 <li>One
18952 </li>
18953 <li>Two:
18954 <ul>
18955 <li>Sub-one
18956 </li>
18957 <li>Sub-two
18958 </li>
18959 </ul>
18960 </li>
18961 </ul>
18962
18963 !! end
18964
18965 !! test
18966 HTML nested ordered list, closed tags (T7497)
18967 !! wikitext
18968 <ol>
18969 <li>One</li>
18970 <li>Two:
18971 <ol>
18972 <li>Sub-one</li>
18973 <li>Sub-two</li>
18974 </ol>
18975 </li>
18976 </ol>
18977 !! html
18978 <ol>
18979 <li>One</li>
18980 <li>Two:
18981 <ol>
18982 <li>Sub-one</li>
18983 <li>Sub-two</li>
18984 </ol>
18985 </li>
18986 </ol>
18987
18988 !! end
18989
18990 !! test
18991 HTML nested ordered list, open tags (T7497)
18992 !! wikitext
18993 <ol>
18994 <li>One
18995 <li>Two:
18996 <ol>
18997 <li>Sub-one
18998 <li>Sub-two
18999 </ol>
19000 </ol>
19001 !! html/php
19002 <ol>
19003 <li>One
19004 <li>Two:
19005 <ol>
19006 <li>Sub-one
19007 <li>Sub-two
19008 </ol>
19009 </ol>
19010
19011 !! html/parsoid
19012 <ol>
19013 <li>One
19014 </li>
19015 <li>Two:
19016 <ol>
19017 <li>Sub-one
19018 </li>
19019 <li>Sub-two
19020 </li>
19021 </ol>
19022 </li>
19023 </ol>
19024
19025 !! end
19026
19027 !! test
19028 HTML ordered list item with parameters oddity
19029 !! wikitext
19030 <ol><li id="fragment">One</li>
19031 </ol>
19032 !! html
19033 <ol><li id="fragment">One</li>
19034 </ol>
19035
19036 !! end
19037
19038 # parsoid doesn't explicitly mark autonumbered links, see T55505
19039 !!test
19040 T7918: autonumbering
19041 !! wikitext
19042 [http://first/] [http://second] [ftp://ftp]
19043
19044 ftp://inlineftp
19045
19046 [mailto:enclosed@mail.tld With target]
19047
19048 [mailto:enclosed@mail.tld]
19049
19050 mailto:inline@mail.tld
19051 !! html/php
19052 <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>
19053 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
19054 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
19055 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
19056 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
19057 </p>
19058 !! html/parsoid
19059 <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>
19060 <p><a rel="mw:ExtLink" href="ftp://inlineftp">ftp://inlineftp</a></p>
19061 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld">With target</a></p>
19062 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld"></a></p>
19063 <p><a rel="mw:ExtLink" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
19064 !! end
19065
19066
19067 #
19068 # Security and HTML correctness
19069 # From Nick Jenkins' fuzz testing
19070 #
19071
19072 !! test
19073 Fuzz testing: Parser13
19074 !! wikitext
19075 {|
19076 | http://a|
19077 !! html
19078 <table>
19079 <tr>
19080 <td>
19081 </td>
19082 </tr>
19083 </table>
19084
19085 !! end
19086
19087 # Note that Parsoid output differs from the PHP parser here: the PHP
19088 # parser breaks the URL for the magic word, while in Parsoid the URL
19089 # production takes precedence.
19090 !! test
19091 Fuzz testing: Parser14
19092 !! wikitext
19093 == onmouseover= ==
19094 http://__TOC__
19095 !! html/php
19096 <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>
19097 http://<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
19098 <ul>
19099 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19100 </ul>
19101 </div>
19102
19103
19104 !! html/php+tidy
19105 <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>
19106 <p>http://</p>
19107 <div id="toc" class="toc">
19108 <div class="toctitle" lang="en" dir="ltr" xml:lang="en">
19109 <h2>Contents</h2>
19110 </div>
19111 <ul>
19112 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19113 </ul>
19114 </div>
19115 <p></p>
19116 !! html/parsoid
19117 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span> onmouseover= </h2>
19118 <p><a rel="mw:ExtLink" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
19119 !! end
19120
19121 !! test
19122 Fuzz testing: Parser14-table
19123 !! options
19124 parsoid=wt2html,html2html
19125 !! wikitext
19126 ==a==
19127 {| STYLE=__TOC__
19128 !! html
19129 <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>
19130 <table style="&#95;_TOC&#95;_">
19131 <tr><td></td></tr>
19132 </table>
19133
19134 !! html+tidy
19135 <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>
19136 <table style="__TOC__">
19137 <tr>
19138 <td></td>
19139 </tr>
19140 </table>
19141 !! html/parsoid
19142 <h2 id="a">a</h2>
19143 <table style="__TOC__"></table>
19144 !! end
19145
19146 # Known to produce bogus xml (extra </td>)
19147 !! test
19148 Fuzz testing: Parser16
19149 !! wikitext
19150 {|
19151 !https://||||||
19152 !! html
19153 <table>
19154 <tr>
19155 <th>https://</th>
19156 <th></th>
19157 <th></th>
19158 <th>
19159 </td>
19160 </tr>
19161 </table>
19162
19163 !! html+tidy
19164 <table>
19165 <tr>
19166 <th>https://</th>
19167 <th></th>
19168 <th></th>
19169 <th></th>
19170 </tr>
19171 </table>
19172 !! end
19173
19174 !! test
19175 Fuzz testing: Parser21
19176 !! wikitext
19177 {|
19178 ! irc://{{ftp://a" onmouseover="alert('hello world');"
19179 |
19180 !! html
19181 <table>
19182 <tr>
19183 <th> <a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
19184 </th>
19185 <td>
19186 </td>
19187 </tr>
19188 </table>
19189
19190 !! end
19191
19192 !! test
19193 Fuzz testing: Parser22
19194 !! wikitext
19195 http://===r:::https://b
19196
19197 {|
19198 !! html
19199 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
19200 </p>
19201 <table>
19202 <tr><td></td></tr>
19203 </table>
19204
19205 !! end
19206
19207 # Known to produce bad XML for now
19208 !! test
19209 Fuzz testing: Parser24
19210 !! options
19211 parsoid=wt2html
19212 !! wikitext
19213 {|
19214 {{{|
19215 <u CLASS=
19216 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
19217 <br style="onmouseover='alert(document.cookie);' " />
19218
19219 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19220 |
19221 !! html/php
19222 <table>
19223 {{{|
19224 <u class="&#124;">}}}} &gt;
19225 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19226
19227 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19228 <tr>
19229 <td></u>
19230 </td>
19231 </tr>
19232 </table>
19233
19234 !! html/parsoid
19235 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
19236 <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>"}'/>}}}} >
19237 <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}'>
19238
19239
19240
19241 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table>
19242 !! end
19243
19244 # Note: the current result listed for this is not what the original one was,
19245 # but the original bug was JavaScript injection, which is fixed in any case.
19246 # It's not clear that the original result listed was any more correct than the
19247 # current one. Original result:
19248 # <p>{{{|
19249 # </p>
19250 # <li class="&#124;&#124;">
19251 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19252 !!test
19253 Fuzz testing: Parser25 (T8055)
19254 !! wikitext
19255 {{{
19256 |
19257 <LI CLASS=||
19258 >
19259 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
19260 !! html/php
19261 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19262 </p>
19263 !! html/parsoid
19264 <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"]}'>
19265 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
19266 !! end
19267
19268 !!test
19269 Fuzz testing: URL adjacent extension (with space, clean)
19270 !! wikitext
19271 http://example.com <nowiki>junk</nowiki>
19272 !! html/php
19273 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
19274 </p>
19275 !! html/parsoid
19276 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a> <span typeof="mw:Nowiki">junk</span></p>
19277 !! end
19278
19279 !!test
19280 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
19281 !! wikitext
19282 http://example.com<nowiki>junk</nowiki>
19283 !! html/php
19284 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
19285 </p>
19286 !! html/parsoid
19287 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a><span typeof="mw:Nowiki">junk</span></p>
19288 !! end
19289
19290 !! test
19291 Fuzz testing: URL adjacent extension (no space, dirty; pre)
19292 !! wikitext
19293 http://example.com<pre>junk</pre>
19294 !! html/php
19295 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
19296
19297 !! html/php+tidy
19298 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p>
19299 <pre>
19300 junk
19301 </pre>
19302 !! html/parsoid
19303 <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>
19304 !! end
19305
19306 !! test
19307 Fuzz testing: image with bogus manual thumbnail
19308 !! wikitext
19309 [[Image:foobar.jpg|thumbnail= ]]
19310 !! html/php
19311 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
19312
19313 !! html/parsoid
19314 <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>
19315 !! end
19316
19317 # Parsoid will emit the newline literally in wt2wt; see next test case.
19318 !! test
19319 Fuzz testing: encoded newline in generated HTML replacements (T8577)
19320 !! options
19321 parsoid=wt2html
19322 !! wikitext
19323 <pre dir="&#10;"></pre>
19324 !! html/php
19325 <pre dir="&#10;"></pre>
19326
19327 !! html/parsoid
19328 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19329 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19330 !! end
19331
19332 !! test
19333 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
19334 !! options
19335 parsoid=html2wt
19336 !! html/parsoid
19337 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19338 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19339 !! wikitext
19340 <pre dir="
19341 "></pre>
19342 !! html/php
19343 <pre dir=""></pre>
19344
19345 !! end
19346
19347 !! test
19348 Templates in extension attributes are not expanded
19349 !! wikitext
19350 <pre dir="{{echo|ltr}}"></pre>
19351 !! html/php
19352 <pre dir="{{echo|ltr}}"></pre>
19353
19354 !! html/parsoid
19355 <pre typeof="mw:Extension/pre" about="#mwt2" dir="{{echo|ltr}}" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
19356 !! end
19357
19358 !! test
19359 Parsing optional HTML elements (T8171)
19360 !! options
19361 !! wikitext
19362 <table>
19363 <tr>
19364 <td> Some tabular data</td>
19365 <td> More tabular data ...
19366 <td> And yet som tabular data</td>
19367 </tr>
19368 </table>
19369 !! html
19370 <table>
19371 <tr>
19372 <td> Some tabular data</td>
19373 <td> More tabular data ...
19374 </td><td> And yet som tabular data</td>
19375 </tr>
19376 </table>
19377
19378 !! end
19379
19380 !! test
19381 Correct handling of <td>, <tr> (T8171)
19382 !! options
19383 !! wikitext
19384 <table>
19385 <tr>
19386 <td> Some tabular data</td>
19387 <td> More tabular data ...</td>
19388 <td> And yet som tabular data</td>
19389 </tr>
19390 </table>
19391 !! html
19392 <table>
19393 <tr>
19394 <td> Some tabular data</td>
19395 <td> More tabular data ...</td>
19396 <td> And yet som tabular data</td>
19397 </tr>
19398 </table>
19399
19400 !! end
19401
19402
19403 !! test
19404 Parsing crashing regression (fr:JavaScript)
19405 !! wikitext
19406 </body></x>
19407 !! html
19408 <p>&lt;/body&gt;&lt;/x&gt;
19409 </p>
19410 !! end
19411
19412 !! test
19413 Inline wiki vs wiki block nesting
19414 !! wikitext
19415 '''Bold paragraph
19416
19417 New wiki paragraph
19418 !! html
19419 <p><b>Bold paragraph</b>
19420 </p><p>New wiki paragraph
19421 </p>
19422 !! end
19423
19424 # FIXME: The current php output is documented
19425 # and desired output is the parsoid target.
19426 !! test
19427 Inline HTML vs wiki block nesting
19428 !! wikitext
19429 <b>Bold paragraph
19430
19431 New wiki paragraph
19432 !! html/php
19433 <p><b>Bold paragraph
19434 </p><p>New wiki paragraph</b>
19435 </p>
19436 !! html/parsoid
19437 <p><b>Bold paragraph</b>
19438 </p><p>New wiki paragraph
19439 </p>
19440 !! end
19441
19442 # Original result was this:
19443 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
19444 # </p>
19445 # While that might be marginally more intuitive, maybe, the six-apostrophe
19446 # construct is clearly pathological and the result stated here (which is what
19447 # the parser actually does) is about as reasonable as anything.
19448 !!test
19449 Mixing markup for italics and bold
19450 !! options
19451 !! wikitext
19452 '''bold''''''bold''bolditalics'''''
19453 !! html
19454 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
19455 </p>
19456 !! end
19457
19458
19459 !! article
19460 Xyzzyx
19461 !! text
19462 Article for special page transclusion test
19463 !! endarticle
19464
19465 !! test
19466 Special page transclusion
19467 !! options
19468 !! wikitext
19469 {{Special:Prefixindex/Xyzzyx}}
19470 !! html
19471 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19472 </ul>
19473
19474 !! end
19475
19476 !! test
19477 Special page transclusion twice (T7021)
19478 !! options
19479 !! wikitext
19480 {{Special:Prefixindex/Xyzzyx}}
19481 {{Special:Prefixindex/Xyzzyx}}
19482 !! html
19483 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19484 </ul>
19485 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19486 </ul>
19487
19488 !! end
19489
19490 !! test
19491 Transclusion of default MediaWiki message
19492 !! wikitext
19493 {{MediaWiki:Mainpage}}
19494 !! html
19495 <p>Main Page
19496 </p>
19497 !! end
19498
19499 !! test
19500 Transclusion of nonexistent MediaWiki message
19501 !! wikitext
19502 {{MediaWiki:Mainpagexxx}}
19503 !! html
19504 <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>
19505 </p>
19506 !! end
19507
19508 !! test
19509 Transclusion of MediaWiki message with underscore
19510 !! wikitext
19511 {{MediaWiki:history_short}}
19512 !! html
19513 <p>History
19514 </p>
19515 !! end
19516
19517 !! test
19518 Transclusion of MediaWiki message with space
19519 !! wikitext
19520 {{MediaWiki:history short}}
19521 !! html
19522 <p>History
19523 </p>
19524 !! end
19525
19526 !! test
19527 Invalid header with following text
19528 !! wikitext
19529 = x = y
19530 !! html
19531 <p>= x = y
19532 </p>
19533 !! end
19534
19535
19536 !! test
19537 Section extraction test (section 0)
19538 !! options
19539 section=0
19540 !! wikitext
19541 start
19542 ==a==
19543 ===aa===
19544 ====aaa====
19545 ==b==
19546 ===ba===
19547 ===bb===
19548 ====bba====
19549 ===bc===
19550 ==c==
19551 ===ca===
19552 !! html/php
19553 start
19554 !! end
19555
19556 !! test
19557 Section extraction test (section 1)
19558 !! options
19559 section=1
19560 !! wikitext
19561 start
19562 ==a==
19563 ===aa===
19564 ====aaa====
19565 ==b==
19566 ===ba===
19567 ===bb===
19568 ====bba====
19569 ===bc===
19570 ==c==
19571 ===ca===
19572 !! html/php
19573 ==a==
19574 ===aa===
19575 ====aaa====
19576 !! end
19577
19578 !! test
19579 Section extraction test (section 2)
19580 !! options
19581 section=2
19582 !! wikitext
19583 start
19584 ==a==
19585 ===aa===
19586 ====aaa====
19587 ==b==
19588 ===ba===
19589 ===bb===
19590 ====bba====
19591 ===bc===
19592 ==c==
19593 ===ca===
19594 !! html/php
19595 ===aa===
19596 ====aaa====
19597 !! end
19598
19599 !! test
19600 Section extraction test (section 3)
19601 !! options
19602 section=3
19603 !! wikitext
19604 start
19605 ==a==
19606 ===aa===
19607 ====aaa====
19608 ==b==
19609 ===ba===
19610 ===bb===
19611 ====bba====
19612 ===bc===
19613 ==c==
19614 ===ca===
19615 !! html/php
19616 ====aaa====
19617 !! end
19618
19619 !! test
19620 Section extraction test (section 4)
19621 !! options
19622 section=4
19623 !! wikitext
19624 start
19625 ==a==
19626 ===aa===
19627 ====aaa====
19628 ==b==
19629 ===ba===
19630 ===bb===
19631 ====bba====
19632 ===bc===
19633 ==c==
19634 ===ca===
19635 !! html/php
19636 ==b==
19637 ===ba===
19638 ===bb===
19639 ====bba====
19640 ===bc===
19641 !! end
19642
19643 !! test
19644 Section extraction test (section 5)
19645 !! options
19646 section=5
19647 !! wikitext
19648 start
19649 ==a==
19650 ===aa===
19651 ====aaa====
19652 ==b==
19653 ===ba===
19654 ===bb===
19655 ====bba====
19656 ===bc===
19657 ==c==
19658 ===ca===
19659 !! html/php
19660 ===ba===
19661 !! end
19662
19663 !! test
19664 Section extraction test (section 6)
19665 !! options
19666 section=6
19667 !! wikitext
19668 start
19669 ==a==
19670 ===aa===
19671 ====aaa====
19672 ==b==
19673 ===ba===
19674 ===bb===
19675 ====bba====
19676 ===bc===
19677 ==c==
19678 ===ca===
19679 !! html/php
19680 ===bb===
19681 ====bba====
19682 !! end
19683
19684 !! test
19685 Section extraction test (section 7)
19686 !! options
19687 section=7
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 ====bba====
19702 !! end
19703
19704 !! test
19705 Section extraction test (section 8)
19706 !! options
19707 section=8
19708 !! wikitext
19709 start
19710 ==a==
19711 ===aa===
19712 ====aaa====
19713 ==b==
19714 ===ba===
19715 ===bb===
19716 ====bba====
19717 ===bc===
19718 ==c==
19719 ===ca===
19720 !! html/php
19721 ===bc===
19722 !! end
19723
19724 !! test
19725 Section extraction test (section 9)
19726 !! options
19727 section=9
19728 !! wikitext
19729 start
19730 ==a==
19731 ===aa===
19732 ====aaa====
19733 ==b==
19734 ===ba===
19735 ===bb===
19736 ====bba====
19737 ===bc===
19738 ==c==
19739 ===ca===
19740 !! html/php
19741 ==c==
19742 ===ca===
19743 !! end
19744
19745 !! test
19746 Section extraction test (section 10)
19747 !! options
19748 section=10
19749 !! wikitext
19750 start
19751 ==a==
19752 ===aa===
19753 ====aaa====
19754 ==b==
19755 ===ba===
19756 ===bb===
19757 ====bba====
19758 ===bc===
19759 ==c==
19760 ===ca===
19761 !! html/php
19762 ===ca===
19763 !! end
19764
19765 !! test
19766 Section extraction test (nonexistent section 11)
19767 !! options
19768 section=11
19769 !! wikitext
19770 start
19771 ==a==
19772 ===aa===
19773 ====aaa====
19774 ==b==
19775 ===ba===
19776 ===bb===
19777 ====bba====
19778 ===bc===
19779 ==c==
19780 ===ca===
19781 !! html/php
19782 !! end
19783
19784 !! test
19785 Section extraction test with bogus heading (section 1)
19786 !! options
19787 section=1
19788 !! wikitext
19789 ==a==
19790 ==bogus== not a legal section
19791 ==b==
19792 !! html/php
19793 ==a==
19794 ==bogus== not a legal section
19795 !! end
19796
19797 !! test
19798 Section extraction test with bogus heading (section 2)
19799 !! options
19800 section=2
19801 !! wikitext
19802 ==a==
19803 ==bogus== not a legal section
19804 ==b==
19805 !! html/php
19806 ==b==
19807 !! end
19808
19809 !! test
19810 Section extraction test with comment after heading (section 1)
19811 !! options
19812 section=1
19813 !! wikitext
19814 ==a==
19815 ==b== <!-- -->
19816 ==c==
19817 !! html/php
19818 ==a==
19819 !! end
19820
19821 !! test
19822 Section extraction test with comment after heading (section 2)
19823 !! options
19824 section=2
19825 !! wikitext
19826 ==a==
19827 ==b== <!-- -->
19828 ==c==
19829 !! html/php
19830 ==b== <!-- -->
19831 !! end
19832
19833 !! test
19834 Section extraction test with bogus <nowiki> heading (section 1)
19835 !! options
19836 section=1
19837 !! wikitext
19838 ==a==
19839 ==bogus== <nowiki>not a legal section</nowiki>
19840 ==b==
19841 !! html/php
19842 ==a==
19843 ==bogus== <nowiki>not a legal section</nowiki>
19844 !! end
19845
19846 !! test
19847 Section extraction test with bogus <nowiki> heading (section 2)
19848 !! options
19849 section=2
19850 !! wikitext
19851 ==a==
19852 ==bogus== <nowiki>not a legal section</nowiki>
19853 ==b==
19854 !! html/php
19855 ==b==
19856 !! end
19857
19858 # Formerly testing for T4587, now resolved by the use of unmarked sections
19859 # instead of respecting commented sections
19860 !! test
19861 Section extraction prefixed by comment (section 1)
19862 !! options
19863 section=1
19864 !! wikitext
19865 <!-- -->==sec1==
19866 ==sec2==
19867 !! html/php
19868 ==sec2==
19869 !!end
19870
19871 !! test
19872 Section extraction prefixed by comment (section 2)
19873 !! options
19874 section=2
19875 !! wikitext
19876 <!-- -->==sec1==
19877 ==sec2==
19878 !! html/php
19879
19880 !!end
19881
19882 # Formerly testing for T4607, now resolved by the use of unmarked sections
19883 # instead of respecting HTML-style headings
19884 !! test
19885 Section extraction, mixed wiki and html (section 1)
19886 !! options
19887 section=1
19888 !! wikitext
19889 <h2>unmarked</h2>
19890 unmarked
19891 ==1==
19892 one
19893 ==2==
19894 two
19895 !! html/php
19896 ==1==
19897 one
19898 !! end
19899
19900 !! test
19901 Section extraction, mixed wiki and html (section 2)
19902 !! options
19903 section=2
19904 !! wikitext
19905 <h2>unmarked</h2>
19906 unmarked
19907 ==1==
19908 one
19909 ==2==
19910 two
19911 !! html/php
19912 ==2==
19913 two
19914 !! end
19915
19916
19917 # Formerly testing for T5342
19918 !! test
19919 Section extraction, heading surrounded by <noinclude>
19920 !! options
19921 section=1
19922 !! wikitext
19923 <noinclude>==unmarked==</noinclude>
19924 ==marked==
19925 !! html/php
19926 ==marked==
19927 !!end
19928
19929 # Test behavior of T21910
19930 !! test
19931 Sectiion with all-equals
19932 !! options
19933 section=2
19934 !! wikitext
19935 ===
19936 The line above must have a trailing space
19937 === <!--
19938 --> <!-- -->
19939 But just in case it doesn't...
19940 !! html/php
19941 === <!--
19942 --> <!-- -->
19943 But just in case it doesn't...
19944 !! end
19945
19946 !! test
19947 Section replacement test (section 0)
19948 !! options
19949 replace=0,"xxx"
19950 !! wikitext
19951 start
19952 ==a==
19953 ===aa===
19954 ====aaa====
19955 ==b==
19956 ===ba===
19957 ===bb===
19958 ====bba====
19959 ===bc===
19960 ==c==
19961 ===ca===
19962 !! html/php
19963 xxx
19964
19965 ==a==
19966 ===aa===
19967 ====aaa====
19968 ==b==
19969 ===ba===
19970 ===bb===
19971 ====bba====
19972 ===bc===
19973 ==c==
19974 ===ca===
19975 !! end
19976
19977 !! test
19978 Section replacement test (section 1)
19979 !! options
19980 replace=1,"xxx"
19981 !! wikitext
19982 start
19983 ==a==
19984 ===aa===
19985 ====aaa====
19986 ==b==
19987 ===ba===
19988 ===bb===
19989 ====bba====
19990 ===bc===
19991 ==c==
19992 ===ca===
19993 !! html/php
19994 start
19995 xxx
19996
19997 ==b==
19998 ===ba===
19999 ===bb===
20000 ====bba====
20001 ===bc===
20002 ==c==
20003 ===ca===
20004 !! end
20005
20006 !! test
20007 Section replacement test (section 2)
20008 !! options
20009 replace=2,"xxx"
20010 !! wikitext
20011 start
20012 ==a==
20013 ===aa===
20014 ====aaa====
20015 ==b==
20016 ===ba===
20017 ===bb===
20018 ====bba====
20019 ===bc===
20020 ==c==
20021 ===ca===
20022 !! html/php
20023 start
20024 ==a==
20025 xxx
20026
20027 ==b==
20028 ===ba===
20029 ===bb===
20030 ====bba====
20031 ===bc===
20032 ==c==
20033 ===ca===
20034 !! end
20035
20036 !! test
20037 Section replacement test (section 3)
20038 !! options
20039 replace=3,"xxx"
20040 !! wikitext
20041 start
20042 ==a==
20043 ===aa===
20044 ====aaa====
20045 ==b==
20046 ===ba===
20047 ===bb===
20048 ====bba====
20049 ===bc===
20050 ==c==
20051 ===ca===
20052 !! html/php
20053 start
20054 ==a==
20055 ===aa===
20056 xxx
20057
20058 ==b==
20059 ===ba===
20060 ===bb===
20061 ====bba====
20062 ===bc===
20063 ==c==
20064 ===ca===
20065 !! end
20066
20067 !! test
20068 Section replacement test (section 4)
20069 !! options
20070 replace=4,"xxx"
20071 !! wikitext
20072 start
20073 ==a==
20074 ===aa===
20075 ====aaa====
20076 ==b==
20077 ===ba===
20078 ===bb===
20079 ====bba====
20080 ===bc===
20081 ==c==
20082 ===ca===
20083 !! html/php
20084 start
20085 ==a==
20086 ===aa===
20087 ====aaa====
20088 xxx
20089
20090 ==c==
20091 ===ca===
20092 !! end
20093
20094 !! test
20095 Section replacement test (section 5)
20096 !! options
20097 replace=5,"xxx"
20098 !! wikitext
20099 start
20100 ==a==
20101 ===aa===
20102 ====aaa====
20103 ==b==
20104 ===ba===
20105 ===bb===
20106 ====bba====
20107 ===bc===
20108 ==c==
20109 ===ca===
20110 !! html/php
20111 start
20112 ==a==
20113 ===aa===
20114 ====aaa====
20115 ==b==
20116 xxx
20117
20118 ===bb===
20119 ====bba====
20120 ===bc===
20121 ==c==
20122 ===ca===
20123 !! end
20124
20125 !! test
20126 Section replacement test (section 6)
20127 !! options
20128 replace=6,"xxx"
20129 !! wikitext
20130 start
20131 ==a==
20132 ===aa===
20133 ====aaa====
20134 ==b==
20135 ===ba===
20136 ===bb===
20137 ====bba====
20138 ===bc===
20139 ==c==
20140 ===ca===
20141 !! html/php
20142 start
20143 ==a==
20144 ===aa===
20145 ====aaa====
20146 ==b==
20147 ===ba===
20148 xxx
20149
20150 ===bc===
20151 ==c==
20152 ===ca===
20153 !! end
20154
20155 !! test
20156 Section replacement test (section 7)
20157 !! options
20158 replace=7,"xxx"
20159 !! wikitext
20160 start
20161 ==a==
20162 ===aa===
20163 ====aaa====
20164 ==b==
20165 ===ba===
20166 ===bb===
20167 ====bba====
20168 ===bc===
20169 ==c==
20170 ===ca===
20171 !! html/php
20172 start
20173 ==a==
20174 ===aa===
20175 ====aaa====
20176 ==b==
20177 ===ba===
20178 ===bb===
20179 xxx
20180
20181 ===bc===
20182 ==c==
20183 ===ca===
20184 !! end
20185
20186 !! test
20187 Section replacement test (section 8)
20188 !! options
20189 replace=8,"xxx"
20190 !! wikitext
20191 start
20192 ==a==
20193 ===aa===
20194 ====aaa====
20195 ==b==
20196 ===ba===
20197 ===bb===
20198 ====bba====
20199 ===bc===
20200 ==c==
20201 ===ca===
20202 !! html/php
20203 start
20204 ==a==
20205 ===aa===
20206 ====aaa====
20207 ==b==
20208 ===ba===
20209 ===bb===
20210 ====bba====
20211 xxx
20212
20213 ==c==
20214 ===ca===
20215 !!end
20216
20217 !! test
20218 Section replacement test (section 9)
20219 !! options
20220 replace=9,"xxx"
20221 !! wikitext
20222 start
20223 ==a==
20224 ===aa===
20225 ====aaa====
20226 ==b==
20227 ===ba===
20228 ===bb===
20229 ====bba====
20230 ===bc===
20231 ==c==
20232 ===ca===
20233 !! html/php
20234 start
20235 ==a==
20236 ===aa===
20237 ====aaa====
20238 ==b==
20239 ===ba===
20240 ===bb===
20241 ====bba====
20242 ===bc===
20243 xxx
20244 !! end
20245
20246 !! test
20247 Section replacement test (section 10)
20248 !! options
20249 replace=10,"xxx"
20250 !! wikitext
20251 start
20252 ==a==
20253 ===aa===
20254 ====aaa====
20255 ==b==
20256 ===ba===
20257 ===bb===
20258 ====bba====
20259 ===bc===
20260 ==c==
20261 ===ca===
20262 !! html/php
20263 start
20264 ==a==
20265 ===aa===
20266 ====aaa====
20267 ==b==
20268 ===ba===
20269 ===bb===
20270 ====bba====
20271 ===bc===
20272 ==c==
20273 xxx
20274 !! end
20275
20276 !! test
20277 Section replacement test with initial whitespace (T15728)
20278 !! options
20279 replace=2,"xxx"
20280 !! wikitext
20281 Preformatted initial line
20282 ==a==
20283 ===a===
20284 !! html/php
20285 Preformatted initial line
20286 ==a==
20287 xxx
20288 !! end
20289
20290
20291 !! test
20292 Section extraction, heading followed by pre with 20 spaces (T8398)
20293 !! options
20294 section=1
20295 !! wikitext
20296 ==a==
20297 a
20298 !! html/php
20299 ==a==
20300 a
20301 !! end
20302
20303 !! test
20304 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
20305 !! options
20306 section=1
20307 !! wikitext
20308 ==a==
20309 a
20310 !! html/php
20311 ==a==
20312 a
20313 !! end
20314
20315
20316 !! test
20317 Section extraction, <pre> around bogus header (T12309)
20318 !! options
20319 section=2
20320 !! wikitext
20321 == Section One ==
20322 <pre>
20323 =======
20324 </pre>
20325
20326 == Section Two ==
20327 stuff
20328 !! html/php
20329 == Section Two ==
20330 stuff
20331 !! end
20332
20333 !! test
20334 Section replacement, <pre> around bogus header (T12309)
20335 !! options
20336 replace=2,"xxx"
20337 !! wikitext
20338 == Section One ==
20339 <pre>
20340 =======
20341 </pre>
20342
20343 == Section Two ==
20344 stuff
20345 !! html/php
20346 == Section One ==
20347 <pre>
20348 =======
20349 </pre>
20350
20351 xxx
20352 !! end
20353
20354 !! test
20355 Handling of &#x0A; in URLs
20356 !! wikitext
20357 ** irc://&#x0A;a
20358 !! html/php
20359 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
20360
20361 !! html/parsoid
20362 <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>
20363 !! end
20364
20365 !! test
20366 Handling of %0A in URLs
20367 !! wikitext
20368 ** irc://%0Aa
20369 !! html/php
20370 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
20371
20372 !! html/parsoid
20373 <ul><li><ul><li> <a rel="mw:ExtLink" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
20374 !! end
20375
20376 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
20377 !! test
20378 5 quotes, code coverage +1 line
20379 !! options
20380 parsoid=wt2html
20381 !! wikitext
20382 '''''
20383 !! html/php
20384 !! html/parsoid
20385 <b><i></i></b>
20386 !! end
20387
20388 # same html as previous, but wikitext adjusted to match parsoid html2wt
20389 # note that wt2html and html2html will put the <i> before the <b>
20390 !! test
20391 5 quotes, code coverage +1 line w/ nowiki (1)
20392 !! options
20393 parsoid=wt2wt,html2wt
20394 !! wikitext
20395 '''''<nowiki/>'''''
20396 !! html/php
20397 <p><i></i>
20398 </p>
20399 !! html/parsoid
20400 <p><b><i></i></b></p>
20401 !! end
20402
20403 # same as previous, just swapping the <i> and <b>
20404 !! test
20405 5 quotes, code coverage +1 line w/ nowiki (2)
20406 !! wikitext
20407 '''''<nowiki/>'''''
20408 !! html/php
20409 <p><i></i>
20410 </p>
20411 !! html/parsoid
20412 <p><i><b></b></i></p>
20413 !! end
20414
20415 !! test
20416 Special:Search page linking.
20417 !! wikitext
20418 {{Special:search}}
20419 !! html
20420 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
20421 </p>
20422 !! end
20423
20424 !! test
20425 {{!}} is a magic word
20426 !! wikitext
20427 {{!}} is a magic word there and {{!}} is still a magic word here
20428 | is not a magic word here but {{!}} is still a magic word here
20429 !! html/php
20430 <p>| is a magic word there and | is still a magic word here
20431 | is not a magic word here but | is still a magic word here
20432 </p>
20433 !! html/parsoid
20434 <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
20435 | 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>
20436 !! end
20437
20438 !! test
20439 Say the magic word
20440 !! options
20441 title=[[Parser test]]
20442 !! wikitext
20443 * {{PAGENAME}}
20444 * {{PAGENAMEE}}
20445 * {{FULLPAGENAME}}
20446 * {{FULLPAGENAMEE}}
20447 * {{BASEPAGENAME}}
20448 * {{BASEPAGENAMEE}}
20449 * {{SUBPAGENAME}}
20450 * {{SUBPAGENAMEE}}
20451 * {{ROOTPAGENAME}}
20452 * {{ROOTPAGENAMEE}}
20453 * {{TALKPAGENAME}}
20454 * {{TALKPAGENAMEE}}
20455 * {{SUBJECTPAGENAME}}
20456 * {{SUBJECTPAGENAMEE}}
20457 * {{NAMESPACEE}}
20458 * {{NAMESPACE}}
20459 * {{NAMESPACENUMBER}}
20460 * {{TALKSPACE}}
20461 * {{TALKSPACEE}}
20462 * {{SUBJECTSPACE}}
20463 * {{SUBJECTSPACEE}}
20464 * {{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
20465 !! html
20466 <ul><li> Parser test</li>
20467 <li> Parser_test</li>
20468 <li> Parser test</li>
20469 <li> Parser_test</li>
20470 <li> Parser test</li>
20471 <li> Parser_test</li>
20472 <li> Parser test</li>
20473 <li> Parser_test</li>
20474 <li> Parser test</li>
20475 <li> Parser_test</li>
20476 <li> Talk:Parser test</li>
20477 <li> Talk:Parser_test</li>
20478 <li> Parser test</li>
20479 <li> Parser_test</li>
20480 <li> </li>
20481 <li> </li>
20482 <li> 0</li>
20483 <li> Talk</li>
20484 <li> Talk</li>
20485 <li> </li>
20486 <li> </li>
20487 <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>
20488
20489 !! end
20490 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
20491
20492 !! test
20493 Gallery with valid attributes
20494 !! wikitext
20495 <gallery type="123" summary="345">
20496 File:File:Foobar.jpg
20497 </gallery>
20498 !! html/php
20499 <ul class="gallery mw-gallery-traditional" type="123">
20500 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20501 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
20502 <div class="gallerytext">
20503 </div>
20504 </div></li>
20505 </ul>
20506
20507 !! html/parsoid
20508 <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"}}'>
20509 <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>
20510 </ul>
20511 !! end
20512
20513 ## Parsoid thinks the "centre" here is a property, not a caption.
20514 !! test
20515 Gallery
20516 !! options
20517 parsoid={
20518 "modes": ["wt2html"],
20519 "nativeGallery": true
20520 }
20521 !! wikitext
20522 <gallery>
20523 image1.png |
20524 image2.gif|||||
20525
20526 image3|
20527 image4 |300px| centre
20528 image5.svg| http://///////
20529 [[x|xx]]]]
20530 * image6
20531 </gallery>
20532 !! html/php
20533 <ul class="gallery mw-gallery-traditional">
20534 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20535 <div class="thumb" style="height: 150px;">Image1.png</div>
20536 <div class="gallerytext">
20537 </div>
20538 </div></li>
20539 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20540 <div class="thumb" style="height: 150px;">Image2.gif</div>
20541 <div class="gallerytext">
20542 </div>
20543 </div></li>
20544 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20545 <div class="thumb" style="height: 150px;">Image3</div>
20546 <div class="gallerytext">
20547 </div>
20548 </div></li>
20549 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20550 <div class="thumb" style="height: 150px;">Image4</div>
20551 <div class="gallerytext">
20552 <pre>centre
20553 </pre>
20554 </div>
20555 </div></li>
20556 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20557 <div class="thumb" style="height: 150px;">Image5.svg</div>
20558 <div class="gallerytext">
20559 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
20560 </p>
20561 </div>
20562 </div></li>
20563 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20564 <div class="thumb" style="height: 150px;">* image6</div>
20565 <div class="gallerytext">
20566 </div>
20567 </div></li>
20568 </ul>
20569
20570 !! html/parsoid
20571 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20572 <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>
20573 <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>
20574 <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>
20575 <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>
20576 <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>
20577 <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>
20578 </ul>
20579 !! end
20580
20581 !! test
20582 Gallery (with options, html)
20583 !! options
20584 parsoid={
20585 "modes": ["wt2html", "html2html"],
20586 "nativeGallery": true
20587 }
20588 !! wikitext
20589 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20590 File:Nonexistent.jpg|caption
20591 File:Nonexistent.jpg
20592 image:foobar.jpg|some '''caption''' [[Main Page]]
20593 image:foobar.jpg
20594 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20595 </gallery>
20596 !! html/php
20597 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20598 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20599 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20600 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20601 <div class="gallerytext">
20602 <p>caption
20603 </p>
20604 </div>
20605 </div></li>
20606 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20607 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20608 <div class="gallerytext">
20609 </div>
20610 </div></li>
20611 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20612 <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>
20613 <div class="gallerytext">
20614 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20615 </p>
20616 </div>
20617 </div></li>
20618 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20619 <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>
20620 <div class="gallerytext">
20621 </div>
20622 </div></li>
20623 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20624 <div class="thumb" style="width: 100px;"><div style="margin:31px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="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>
20625 <div class="gallerytext">
20626 <p>blabla.
20627 </p>
20628 </div>
20629 </div></li>
20630 </ul>
20631
20632 !! html/parsoid
20633 <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":{}}'>
20634 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20635 <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>
20636 <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>
20637 <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>
20638 <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>
20639 <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>
20640 </ul>
20641 !! end
20642
20643 !! test
20644 Gallery (with options, extsrc)
20645 !! options
20646 parsoid={
20647 "nativeGallery": false
20648 }
20649 !! wikitext
20650 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20651 File:Nonexistent.jpg|caption
20652 File:Nonexistent.jpg
20653 image:foobar.jpg|some '''caption''' [[Main Page]]
20654 image:foobar.jpg
20655 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20656 </gallery>
20657 !! html/php
20658 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20659 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20660 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20661 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20662 <div class="gallerytext">
20663 <p>caption
20664 </p>
20665 </div>
20666 </div></li>
20667 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20668 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20669 <div class="gallerytext">
20670 </div>
20671 </div></li>
20672 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20673 <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>
20674 <div class="gallerytext">
20675 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20676 </p>
20677 </div>
20678 </div></li>
20679 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20680 <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>
20681 <div class="gallerytext">
20682 </div>
20683 </div></li>
20684 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20685 <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>
20686 <div class="gallerytext">
20687 <p>blabla.
20688 </p>
20689 </div>
20690 </div></li>
20691 </ul>
20692
20693 !! html/parsoid
20694 <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"}}'>
20695 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20696 <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>
20697 <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>
20698 <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>
20699 <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>
20700 <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>
20701 </ul>
20702 !! end
20703
20704 !! test
20705 Gallery (without px units)
20706 !! wikitext
20707 <gallery widths="70" heights="40">
20708 File:Foobar.jpg
20709 </gallery>
20710 !! html/php
20711 <ul class="gallery mw-gallery-traditional">
20712 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20713 <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>
20714 <div class="gallerytext">
20715 </div>
20716 </div></li>
20717 </ul>
20718
20719 !! html/parsoid
20720 <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"}}'>
20721 <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>
20722 </ul>
20723 !! end
20724
20725 !! test
20726 Gallery (with invalid units)
20727 !! wikitext
20728 <gallery widths="70em" heights="40em">
20729 File:Foobar.jpg
20730 </gallery>
20731 !! html/php
20732 <ul class="gallery mw-gallery-traditional">
20733 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20734 <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>
20735 <div class="gallerytext">
20736 </div>
20737 </div></li>
20738 </ul>
20739
20740 !! html/parsoid
20741 <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"}}'>
20742 <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>
20743 </ul>
20744 !! end
20745
20746 !! test
20747 Gallery with link that has fragment
20748 !! options
20749 parsoid={
20750 "modes": ["wt2html", "html2html"],
20751 "nativeGallery": true
20752 }
20753 !! wikitext
20754 <gallery>
20755 image:foobar.jpg|link=Main_Page
20756 image:foobar.jpg|link=Main_Page#section
20757 image:foobar.jpg|link=Main Page#section|caption
20758 </gallery>
20759 !! html/php
20760 <ul class="gallery mw-gallery-traditional">
20761 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20762 <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>
20763 <div class="gallerytext">
20764 </div>
20765 </div></li>
20766 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20767 <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>
20768 <div class="gallerytext">
20769 </div>
20770 </div></li>
20771 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20772 <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>
20773 <div class="gallerytext">
20774 <p>caption
20775 </p>
20776 </div>
20777 </div></li>
20778 </ul>
20779
20780 !! html/parsoid
20781 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20782 <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>
20783 <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>
20784 <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>
20785 </ul>
20786 !! end
20787
20788 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
20789 !! test
20790 Gallery with template inside caption
20791 !! options
20792 parsoid={
20793 "nativeGallery": true
20794 }
20795 !! wikitext
20796 <gallery caption="{{echo|hi}}">
20797 File:Foobar.jpg|{{echo|ho}}
20798 </gallery>
20799 !! html/php
20800 <ul class="gallery mw-gallery-traditional">
20801 <li class='gallerycaption'>{{echo|hi}}</li>
20802 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20803 <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>
20804 <div class="gallerytext">
20805 <p>ho
20806 </p>
20807 </div>
20808 </div></li>
20809 </ul>
20810
20811 !! html/parsoid
20812 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20813 <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>
20814 <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>
20815 </ul>
20816 !! end
20817
20818 !! test
20819 Gallery with wikitext inside caption
20820 !! options
20821 parsoid={
20822 "nativeGallery": true
20823 }
20824 !! wikitext
20825 <gallery>
20826 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
20827 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
20828 </gallery>
20829 !! html/php
20830 <ul class="gallery mw-gallery-traditional">
20831 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20832 <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>
20833 <div class="gallerytext">
20834 <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>
20835 </p>
20836 </div>
20837 </div></li>
20838 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20839 <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>
20840 <div class="gallerytext">
20841 <p>This is a test template
20842 </p>
20843 </div>
20844 </div></li>
20845 </ul>
20846
20847 !! html/parsoid
20848 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20849 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img 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>
20850 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img 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>
20851 </ul>
20852 !! end
20853
20854 !! test
20855 Gallery (with showfilename option)
20856 !! options
20857 parsoid={
20858 "nativeGallery": true
20859 }
20860 !! wikitext
20861 <gallery showfilename="">
20862 File:Nonexistent.jpg|caption
20863 File:Nonexistent.jpg
20864 File:Foobar.jpg|some '''caption''' [[Main Page]]
20865 File:Foobar.jpg
20866 </gallery>
20867 !! html/php
20868 <ul class="gallery mw-gallery-traditional">
20869 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20870 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20871 <div class="gallerytext">
20872 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20873 caption
20874 </p>
20875 </div>
20876 </div></li>
20877 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20878 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20879 <div class="gallerytext">
20880 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20881 </p>
20882 </div>
20883 </div></li>
20884 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20885 <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>
20886 <div class="gallerytext">
20887 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20888 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20889 </p>
20890 </div>
20891 </div></li>
20892 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20893 <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>
20894 <div class="gallerytext">
20895 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20896 </p>
20897 </div>
20898 </div></li>
20899 </ul>
20900
20901 !! html/parsoid
20902 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
20903 <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>
20904 <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>
20905 <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>
20906 <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>
20907 </ul>
20908 !! end
20909
20910 ## Should Parsoid be preserving these variations? See T151367
20911 !! test
20912 Gallery (with namespace-less filenames)
20913 !! options
20914 parsoid={
20915 "modes": ["wt2html", "html2html"],
20916 "nativeGallery": true
20917 }
20918 !! wikitext
20919 <gallery>
20920 File:Nonexistent.jpg
20921 Nonexistent.jpg
20922 image:foobar.jpg
20923 foobar.jpg
20924 </gallery>
20925 !! html/php
20926 <ul class="gallery mw-gallery-traditional">
20927 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20928 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20929 <div class="gallerytext">
20930 </div>
20931 </div></li>
20932 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20933 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20934 <div class="gallerytext">
20935 </div>
20936 </div></li>
20937 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20938 <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>
20939 <div class="gallerytext">
20940 </div>
20941 </div></li>
20942 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20943 <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>
20944 <div class="gallerytext">
20945 </div>
20946 </div></li>
20947 </ul>
20948
20949 !! html/parsoid
20950 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20951 <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>
20952 <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>
20953 <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>
20954 <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>
20955 </ul>
20956 !! end
20957
20958 !! test
20959 Gallery override link with wikilink (T36852)
20960 !! options
20961 parsoid={
20962 "nativeGallery": true
20963 }
20964 !! wikitext
20965 <gallery>
20966 File:Foobar.jpg|alt=galleryalt|link=Wikilink
20967 </gallery>
20968 !! html/php
20969 <ul class="gallery mw-gallery-traditional">
20970 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20971 <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>
20972 <div class="gallerytext">
20973 </div>
20974 </div></li>
20975 </ul>
20976
20977 !! html/parsoid
20978 <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":{}}'>
20979 <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>
20980 </ul>
20981 !! end
20982
20983 !! test
20984 Gallery override link with absolute external link (T36852)
20985 !! options
20986 parsoid={
20987 "nativeGallery": true
20988 }
20989 !! wikitext
20990 <gallery>
20991 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
20992 </gallery>
20993 !! html/php
20994 <ul class="gallery mw-gallery-traditional">
20995 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20996 <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>
20997 <div class="gallerytext">
20998 </div>
20999 </div></li>
21000 </ul>
21001
21002 !! html/parsoid
21003 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21004 <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>
21005 </ul>
21006 !! end
21007
21008 !! test
21009 Gallery override link with absolute external link with LanguageConverter
21010 !! options
21011 language=zh
21012 !! input
21013 <gallery>
21014 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
21015 </gallery>
21016 !! result
21017 <ul class="gallery mw-gallery-traditional">
21018 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21019 <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>
21020 <div class="gallerytext">
21021 <p>caption
21022 </p>
21023 </div>
21024 </div></li>
21025 </ul>
21026
21027 !! end
21028
21029 !! test
21030 Gallery override link with malicious javascript (T36852)
21031 !! options
21032 parsoid={
21033 "modes": ["wt2html", "html2html"],
21034 "nativeGallery": true
21035 }
21036 !! wikitext
21037 <gallery>
21038 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
21039 </gallery>
21040 !! html/php
21041 <ul class="gallery mw-gallery-traditional">
21042 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21043 <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>
21044 <div class="gallerytext">
21045 </div>
21046 </div></li>
21047 </ul>
21048
21049 !! html/parsoid
21050 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21051 <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>
21052 </ul>
21053 !! end
21054
21055 # Note that parsoid uses the invalid link as a caption, PHP does not.
21056 !! test
21057 Gallery with invalid title as link (T45964)
21058 !! options
21059 parsoid={
21060 "modes": ["wt2html", "html2html"],
21061 "nativeGallery": true
21062 }
21063 !! wikitext
21064 <gallery>
21065 File:Foobar.jpg|link=<
21066 </gallery>
21067 !! html/php
21068 <ul class="gallery mw-gallery-traditional">
21069 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21070 <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>
21071 <div class="gallerytext">
21072 </div>
21073 </div></li>
21074 </ul>
21075
21076 !! html/parsoid
21077 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21078 <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>
21079 </ul>
21080 !! end
21081
21082 !! test
21083 Serialize gallery without attrs in data-mw
21084 !! options
21085 parsoid={
21086 "modes": ["html2wt"],
21087 "nativeGallery": true
21088 }
21089 !! html/parsoid
21090 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
21091 <li class="gallerycaption">123</li>
21092 <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>
21093 </ul>
21094 !! wikitext
21095 <gallery caption="123">
21096 File:Test.png
21097 </gallery>
21098 !! end
21099
21100 !! test
21101 Gallery with class and style attributes
21102 !! options
21103 parsoid={
21104 "nativeGallery": true
21105 }
21106 !! wikitext
21107 <gallery class="center" style="text-align: center;">
21108 File:Foobar.jpg
21109 </gallery>
21110 !! html/php
21111 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
21112 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21113 <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>
21114 <div class="gallerytext">
21115 </div>
21116 </div></li>
21117 </ul>
21118
21119 !! html/parsoid
21120 <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":{}}'>
21121 <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>
21122 </ul>
21123 !! end
21124
21125 !! test
21126 Gallery in slideshow mode
21127 !! options
21128 parsoid={
21129 "nativeGallery": true
21130 }
21131 !! wikitext
21132 <gallery mode="slideshow" showthumbnails="">
21133 File:Foobar.jpg
21134 </gallery>
21135 !! html/php
21136 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
21137 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21138 <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>
21139 <div class="gallerytext">
21140 </div>
21141 </div></li>
21142 </ul>
21143
21144 !! html/parsoid
21145 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
21146 <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>
21147 </ul>
21148 !! end
21149
21150 !! test
21151 HTML Hex character encoding (spells the word "JavaScript")
21152 !! options
21153 parsoid=wt2html,wt2wt,html2html
21154 !! wikitext
21155 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
21156 !! html/php
21157 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
21158 </p>
21159 !! html/php+tidy
21160 <p>JavaScript</p>
21161 !! html/parsoid
21162 <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>
21163 !! end
21164
21165 !! test
21166 HTML Hex character encoding bogus encoding (T28437 regression check)
21167 !! wikitext
21168 &#xsee;&#XSEE;
21169 !! html/php
21170 <p>&amp;#xsee;&amp;#XSEE;
21171 </p>
21172 !! html/parsoid
21173 <p>&amp;#xsee;&amp;#XSEE;</p>
21174 !! end
21175
21176 !! test
21177 HTML Hex character encoding mixed case
21178 !! options
21179 parsoid=wt2html,wt2wt,html2html
21180 !! wikitext
21181 &#xEE;&#Xee;
21182 !! html/php
21183 <p>&#xee;&#xee;
21184 </p>
21185 !! html/php+tidy
21186 <p>îî</p>
21187 !! html/parsoid
21188 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
21189 !! end
21190
21191 # See: https://www.w3.org/TR/html5/syntax.html#character-references
21192 # Note that U+000C (form feed) is not a valid XML character, so
21193 # it is banned even though allowed in HTML5.
21194 !! test
21195 Illegal character references (T106578)
21196 !! wikitext
21197 ; Null: &#00;
21198 ; FF: &#xC;
21199 ; CR: &#xD;
21200 ; Control (low): &#8;
21201 ; Control (high): &#x7F; &#x9F;
21202 ; Surrogate: &#xD83D;&#xDCA9;
21203 ; This is an okay astral character: &#x1F4A9;
21204 !! html+tidy
21205 <dl>
21206 <dt>Null</dt>
21207 <dd>&amp;#00;</dd>
21208 <dt>FF</dt>
21209 <dd>&amp;#xC;</dd>
21210 <dt>CR</dt>
21211 <dd>&amp;#xD;</dd>
21212 <dt>Control (low)</dt>
21213 <dd>&amp;#8;</dd>
21214 <dt>Control (high)</dt>
21215 <dd>&amp;#x7F; &amp;#x9F;</dd>
21216 <dt>Surrogate</dt>
21217 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
21218 <dt>This is an okay astral character</dt>
21219 <dd>💩</dd>
21220 </dl>
21221 !! end
21222
21223 !! test
21224 __FORCETOC__ override
21225 !! wikitext
21226 __NEWSECTIONLINK__
21227 __FORCETOC__
21228 !! html/php
21229 <p><br />
21230 </p>
21231 !! end
21232
21233 !! test
21234 ISBN code coverage
21235 !! wikitext
21236 ISBN 978-0-1234-56&#x20;789
21237 !! html
21238 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
21239 </p>
21240 !! html+tidy
21241 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a> 789</p>
21242 !! html/parsoid
21243 <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>
21244 !! end
21245
21246 !! test
21247 ISBN followed by 5 spaces
21248 !! wikitext
21249 ISBN
21250 !! html
21251 <p>ISBN
21252 </p>
21253 !! end
21254
21255 !! test
21256 Double ISBN
21257 !! wikitext
21258 ISBN ISBN 1234567890
21259 !! html/php
21260 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21261 </p>
21262 !! html/parsoid
21263 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21264 !! end
21265
21266 # Uppercase X and lowercase x as well
21267 !! test
21268 ISBN with an X
21269 !! wikitext
21270 ISBN 3-462-04561-X
21271 ISBN 3-462-04561-x
21272 ISBN 080442957X
21273 ISBN 080442957x
21274 ISBN 978080442957X
21275 ISBN 978080442957x
21276 !! html/php
21277 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
21278 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
21279 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
21280 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
21281 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
21282 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
21283 </p>
21284 !! html/parsoid
21285 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
21286 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
21287 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
21288 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
21289 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
21290 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
21291 !! end
21292
21293 !! test
21294 ISBN with empty prefix (parsoid test)
21295 !! wikitext
21296 ISBN 1234567890
21297 !! html/php
21298 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21299 </p>
21300 !! html/parsoid
21301 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
21302 !! end
21303
21304 !! test
21305 T24905: <abbr> followed by ISBN followed by </a>
21306 !! wikitext
21307 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
21308 !! html/php
21309 <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>
21310 </p>
21311 !! html/parsoid
21312 <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>
21313 !! end
21314
21315 !! test
21316 Double RFC
21317 !! wikitext
21318 RFC RFC 1234
21319 !! html
21320 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
21321 </p>
21322 !! end
21323
21324 !! test
21325 Double RFC with a wiki link
21326 !! wikitext
21327 RFC [[RFC 1234]]
21328 !! html
21329 <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>
21330 </p>
21331 !! end
21332
21333 !! test
21334 RFC code coverage
21335 !! wikitext
21336 RFC 983&#x20;987
21337 !! html
21338 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
21339 </p>
21340 !! html+tidy
21341 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a> 987</p>
21342 !! end
21343
21344 !! test
21345 Centre-aligned image
21346 !! wikitext
21347 [[Image:foobar.jpg|centre]]
21348 !! html
21349 <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>
21350
21351 !!end
21352
21353 !! test
21354 None-aligned image
21355 !! wikitext
21356 [[Image:foobar.jpg|none]]
21357 !! html
21358 <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>
21359
21360 !!end
21361
21362 !! test
21363 Width + Height sized image (using px) (height is ignored)
21364 !! wikitext
21365 [[Image:foobar.jpg|640x480px]]
21366 !! html
21367 <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>
21368 </p>
21369 !!end
21370
21371 !! test
21372 Width-sized image (using px, no following whitespace)
21373 !! wikitext
21374 [[Image:foobar.jpg|640px]]
21375 !! html
21376 <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>
21377 </p>
21378 !!end
21379
21380 !! test
21381 Width-sized image (using px, with following whitespace - test regression from r39467)
21382 !! wikitext
21383 [[Image:foobar.jpg|640px ]]
21384 !! html
21385 <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>
21386 </p>
21387 !!end
21388
21389 !! test
21390 Width-sized image (using px, with preceding whitespace - test regression from r39467)
21391 !! wikitext
21392 [[Image:foobar.jpg| 640px]]
21393 !! html
21394 <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>
21395 </p>
21396 !!end
21397
21398 !! test
21399 Image with page parameter
21400 !! options
21401 djvu
21402 !! wikitext
21403 [[File:LoremIpsum.djvu|page=2]]
21404 !! html/php
21405 <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>
21406 </p>
21407 !! html/parsoid
21408 <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>
21409 !! end
21410
21411 !! test
21412 Another italics / bold test
21413 !! wikitext
21414 ''' ''x'
21415 !! html
21416 <pre>'<i> </i>x'
21417 </pre>
21418 !!end
21419
21420 # FIXME: The php output seems broken. It's interleaving some open/close tags.
21421 !! test
21422 dt/dd/dl test
21423 !! wikitext
21424 :;;;::
21425 !! html/php
21426 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
21427
21428 !! html/parsoid
21429 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
21430
21431 !!end
21432
21433 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
21434 !! test
21435 Images with the "|" character in the comment
21436 !! wikitext
21437 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
21438 !! html/php
21439 <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>
21440
21441 !! html/parsoid
21442 <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>
21443 !! end
21444
21445 !! test
21446 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
21447 !! wikitext
21448 <html><script>alert(1);</script></html>
21449 !! html
21450 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
21451 </p>
21452 !! end
21453
21454 !! test
21455 HTML with raw HTML ($wgRawHtml==true)
21456 !! options
21457 wgRawHtml=1
21458 !! wikitext
21459 <html><script>alert(1);</script></html>
21460 !! html/php
21461 <p><script>alert(1);</script>
21462 </p>
21463 !! end
21464
21465 !! test
21466 Parents of subpages, one level up
21467 !! options
21468 subpage title=[[Subpage test/L1/L2/L3]]
21469 !! wikitext
21470 [[../|L2]]
21471 !! html
21472 <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>
21473 </p>
21474 !! end
21475
21476
21477 !! test
21478 Parents of subpages, one level up, not named
21479 !! options
21480 subpage title=[[Subpage test/L1/L2/L3]]
21481 !! wikitext
21482 [[../]]
21483 !! html
21484 <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>
21485 </p>
21486 !! end
21487
21488
21489
21490 !! test
21491 Parents of subpages, two levels up
21492 !! options
21493 subpage title=[[Subpage test/L1/L2/L3]]
21494 !! wikitext
21495 [[../../|L1]]2
21496
21497 [[../../|L1]]l
21498 !! html
21499 <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
21500 </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>
21501 </p>
21502 !! end
21503
21504 !! test
21505 Parents of subpages, two levels up, without trailing slash or name.
21506 !! options
21507 subpage title=[[Subpage test/L1/L2/L3]]
21508 !! wikitext
21509 [[../..]]
21510 !! html
21511 <p>[[../..]]
21512 </p>
21513 !! end
21514
21515 !! test
21516 Parents of subpages, two levels up, with lots of extra trailing slashes.
21517 !! options
21518 subpage title=[[Subpage test/L1/L2/L3]]
21519 !! wikitext
21520 [[../../////]]
21521 !! html
21522 <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>
21523 </p>
21524 !! end
21525
21526 !! article
21527 Subpage test/L1/L2/L3Sibling
21528 !! text
21529 Sibling article
21530 !! endarticle
21531
21532 !! test
21533 Transclusion of a sibling page (one level up)
21534 !! options
21535 subpage title=[[Subpage test/L1/L2/L3]]
21536 !! wikitext
21537 {{../L3Sibling}}
21538 !! html
21539 <p>Sibling article
21540 </p>
21541 !! end
21542
21543 !! test
21544 Transclusion of a child page
21545 !! options
21546 subpage title=[[Subpage test/L1/L2]]
21547 !! wikitext
21548 {{/L3Sibling}}
21549 !! html
21550 <p>Sibling article
21551 </p>
21552 !! end
21553
21554 # This is wt2html only in Parsoid because we add <nowiki>
21555 # because of {{..}} and we don't expect to fix that to
21556 # eliminate the nowikis selective for {{..}} markup.
21557 !! test
21558 Non-transclusion because of too many up levels
21559 !! options
21560 subpage title=[[Subpage test/L1/L2/L3]]
21561 parsoid=wt2html
21562 !! wikitext
21563 {{../../../../More than parent}}
21564 !! html/php
21565 <p>{{../../../../More than parent}}
21566 </p>
21567 !! html/parsoid
21568 <p>{{../../../../More than parent}}</p>
21569 !! end
21570
21571 !! test
21572 Definition list code coverage
21573 !! wikitext
21574 ; title : def
21575 ; title : def
21576 ;title: def
21577 !! html/php
21578 <dl><dt> title &#160;</dt>
21579 <dd> def</dd>
21580 <dt> title&#160;</dt>
21581 <dd> def</dd>
21582 <dt>title</dt>
21583 <dd> def</dd></dl>
21584
21585 !! html/parsoid
21586 <dl><dt> title <span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21587 <dt> title<span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21588 <dt>title</dt><dd> def</dd></dl>
21589 !! end
21590
21591 !! test
21592 Don't fall for the self-closing div
21593 !! wikitext
21594 <div>hello world</div/>
21595 !! html
21596 <div>hello world</div>
21597
21598 !! end
21599
21600 !! test
21601 MSGNW magic word
21602 !! wikitext
21603 {{MSGNW:msg}}
21604 !! html/php
21605 <p>&#91;&#91;:Template:Msg&#93;&#93;
21606 </p>
21607 !! end
21608
21609 !! test
21610 RAW magic word
21611 !! wikitext
21612 {{RAW:QUERTY}}
21613 !! html
21614 <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>
21615 </p>
21616 !! end
21617
21618 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
21619 !! test
21620 Always escape literal '>' in output, not just after '<'
21621 !! wikitext
21622 ><>
21623 !! html
21624 <p>&gt;&lt;&gt;
21625 </p>
21626 !! end
21627
21628 !! test
21629 Template caching
21630 !! wikitext
21631 {{Test}}
21632 {{Test}}
21633 !! html
21634 <p>This is a test template
21635 This is a test template
21636 </p>
21637 !! end
21638
21639
21640 !! article
21641 MediaWiki:Fake
21642 !! text
21643 ==header==
21644 !! endarticle
21645
21646 !! test
21647 Inclusion of !userCanEdit() content
21648 !! wikitext
21649 {{MediaWiki:Fake}}
21650 !! html
21651 <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>
21652
21653 !! end
21654
21655
21656 !! test
21657 Out-of-order TOC heading levels
21658 !! wikitext
21659 ==2==
21660 ======6======
21661 ===3===
21662 =1=
21663 =====5=====
21664 ==2==
21665 !! html
21666 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
21667 <ul>
21668 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
21669 <ul>
21670 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
21671 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
21672 </ul>
21673 </li>
21674 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
21675 <ul>
21676 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
21677 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
21678 </ul>
21679 </li>
21680 </ul>
21681 </div>
21682
21683 <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>
21684 <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>
21685 <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>
21686 <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>
21687 <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>
21688 <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>
21689
21690 !! end
21691
21692
21693 !! test
21694 ISBN with a dummy number
21695 !! wikitext
21696 ISBN ---
21697 !! html
21698 <p>ISBN ---
21699 </p>
21700 !! end
21701
21702
21703 !! test
21704 ISBN with space-delimited number
21705 !! wikitext
21706 ISBN 92 9017 032 8
21707 !! html/php
21708 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
21709 </p>
21710 !! html/parsoid
21711 <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>
21712 !! end
21713
21714
21715 !! test
21716 ISBN with multiple spaces, no number
21717 !! wikitext
21718 ISBN foo
21719 !! html
21720 <p>ISBN foo
21721 </p>
21722 !! end
21723
21724
21725 !! test
21726 ISBN length
21727 !! wikitext
21728 ISBN 123456789
21729
21730 ISBN 1234567890
21731
21732 ISBN 12345678901
21733 !! html/php
21734 <p>ISBN 123456789
21735 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21736 </p><p>ISBN 12345678901
21737 </p>
21738 !! html/parsoid
21739 <p>ISBN 123456789</p>
21740
21741 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21742
21743 <p>ISBN 12345678901</p>
21744 !! end
21745
21746
21747 !! test
21748 ISBN with trailing year (T9110)
21749 !! wikitext
21750 ISBN 1-234-56789-0 - 2006
21751
21752 ISBN 1 234 56789 0 - 2006
21753 !! html/php
21754 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
21755 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
21756 </p>
21757 !! html/parsoid
21758 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
21759
21760 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
21761 !! end
21762
21763
21764 !! test
21765 anchorencode
21766 !! config
21767 wgFragmentMode=[ 'html5', 'legacy' ]
21768 !! wikitext
21769 {{anchorencode:foo bar©#%n}}
21770 !! html/php
21771 <p>foo_bar©#%n
21772 </p>
21773 !! html/parsoid
21774 <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>
21775 !! end
21776
21777 !! test
21778 anchorencode (legacy)
21779 !! config
21780 wgFragmentMode=[ 'legacy' ]
21781 !! wikitext
21782 {{anchorencode:foo bar©#%n}}
21783 !! html/php
21784 <p>foo_bar.C2.A9.23.25n
21785 </p>
21786 !! end
21787
21788 !! test
21789 anchorencode trims spaces
21790 !! config
21791 wgFragmentMode=[ 'html5', 'legacy' ]
21792 !! wikitext
21793 {{anchorencode: __pretty__please__}}
21794 !! html/php
21795 <p>pretty_please
21796 </p>
21797 !! html/parsoid
21798 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
21799 !! end
21800
21801 !! test
21802 anchorencode deals with links
21803 !! config
21804 wgFragmentMode=[ 'html5', 'legacy' ]
21805 !! wikitext
21806 {{anchorencode: [[hello|world]] [[hi]]}}
21807 !! html/php
21808 <p>world_hi
21809 </p>
21810 !! html/parsoid
21811 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
21812 !! end
21813
21814 !! test
21815 anchorencode deals with templates
21816 !! config
21817 wgFragmentMode=[ 'html5', 'legacy' ]
21818 !! wikitext
21819 {{anchorencode: {{Foo}} x}}
21820 !! html/php
21821 <p>FOO_x
21822 </p>
21823 !! html/parsoid
21824 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
21825 !! end
21826
21827 !! test
21828 anchorencode encodes like the TOC generator: (T20431)
21829 !! config
21830 wgFragmentMode=[ 'html5', 'legacy' ]
21831 !! wikitext
21832 === _ +:.3A%3A _ &&amp;]] x ===
21833 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
21834 __NOEDITSECTION__
21835 !! html/php
21836 <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>
21837 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
21838 </p>
21839 !! html/parsoid
21840 <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>
21841 <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>
21842 <meta property="mw:PageProp/noeditsection"/>
21843 !! end
21844
21845 !! test
21846 anchorencode encodes like the TOC generator: (T20431) (legacy)
21847 !! config
21848 wgFragmentMode=[ 'legacy' ]
21849 !! wikitext
21850 === _ +:.3A%3A&&amp;]] ===
21851 {{anchorencode: _ +:.3A%3A&&amp;]] }}
21852 __NOEDITSECTION__
21853 !! html/php
21854 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
21855 <p>.2B:.3A.253A.26.26.5D.5D
21856 </p>
21857 !! end
21858
21859 !! test
21860 T8200: blockquotes and paragraph formatting
21861 !! wikitext
21862 <blockquote>
21863 foo
21864 </blockquote>
21865
21866 bar
21867
21868 baz
21869 !! html
21870 <blockquote>
21871 <p>foo
21872 </p>
21873 </blockquote>
21874 <p>bar
21875 </p>
21876 <pre>baz
21877 </pre>
21878 !! end
21879
21880 !! test
21881 T10293: Use of center tag ruins paragraph formatting
21882 !! wikitext
21883 <center>
21884 foo
21885 </center>
21886
21887 bar
21888
21889 baz
21890 !! html
21891 <center>
21892 <p>foo
21893 </p>
21894 </center>
21895 <p>bar
21896 </p>
21897 <pre>baz
21898 </pre>
21899 !! end
21900
21901 !!test
21902 Parsing of overlapping (improperly nested) inline html tags
21903 !! wikitext
21904 <span><s>x</span></s>
21905 !! html/php
21906 <p><span><s>x&lt;/span&gt;</s></span>
21907 </p>
21908 !! html/parsoid
21909 <p><span><s>x</s></span>
21910 </p>
21911 !!end
21912
21913 ###
21914 ### Language variants related tests
21915 ###
21916
21917 # Parsoid does not mark self-links.
21918 # Parsoid does not convert links; PHP will do any necessary redirects.
21919
21920 !! test
21921 Self-link in language variants
21922 !! options
21923 title=[[Dunav]] language=sr
21924 !! wikitext
21925 Both [[Dunav]] and [[Дунав]] are names for this river.
21926 !! html/php
21927 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
21928 </p>
21929 !! html/parsoid
21930 <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>
21931 !! end
21932
21933 !! article
21934 Дуна
21935 !! text
21936 content
21937 !! endarticle
21938
21939 !! test
21940 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
21941 !! options
21942 title=[[Duna]] language=sr
21943 !! wikitext
21944 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
21945 !! html/php
21946 <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.
21947 </p>
21948 !! html/parsoid
21949 <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>
21950 !! end
21951
21952 !! test
21953 Link to a section of a variant of this title shouldn't be parsed as self-link
21954 !! options
21955 title=[[Duna]] language=sr
21956 !! wikitext
21957 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
21958 !! html/php
21959 <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.
21960 </p>
21961 !! html/parsoid
21962 <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>
21963 !! end
21964
21965 !! test
21966 Link to pages in language variants
21967 !! options
21968 language=sr
21969 !! wikitext
21970 Main Page can be written as [[Маин Паге]]
21971 !! html/php
21972 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
21973 </p>
21974 !! html/parsoid
21975 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
21976 !! end
21977
21978
21979 !! test
21980 Multiple links to pages in language variants
21981 !! options
21982 language=sr
21983 !! wikitext
21984 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
21985 !! html/php
21986 <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>.
21987 </p>
21988 !! html/parsoid
21989 <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>
21990 !! end
21991
21992
21993 !! test
21994 Simple template in language variants
21995 !! options
21996 language=sr
21997 !! wikitext
21998 {{тест}}
21999 !! html/php
22000 <p>This is a test template
22001 </p>
22002 !! end
22003
22004
22005 !! test
22006 Template with explicit namespace in language variants
22007 !! options
22008 language=sr
22009 !! wikitext
22010 {{Template:тест}}
22011 !! html/php
22012 <p>This is a test template
22013 </p>
22014 !! end
22015
22016
22017 !! test
22018 Basic test for template parameter in language variants
22019 !! options
22020 language=sr
22021 !! wikitext
22022 {{парамтест|param=foo}}
22023 !! html/php
22024 <p>This is a test template with parameter foo
22025 </p>
22026 !! end
22027
22028 !! test
22029 Simple category in language variants
22030 !! options
22031 language=sr cat
22032 !! wikitext
22033 [[Category:МедиаWики Усер'с Гуиде]]
22034 !! html/php
22035 cat=МедиаWики_Усер'с_Гуиде sort=
22036 !! html/parsoid
22037 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
22038 !! end
22039
22040 !! article
22041 Category:分类
22042 !! text
22043 blah
22044 !! endarticle
22045
22046 !! article
22047 Category:分類
22048 !! text
22049 blah
22050 !! endarticle
22051
22052 ## We used to, but no longer wt2wt this test since the default serializer
22053 ## will normalize all categories to serialize on their own line.
22054 ## This wikitext usage is going to be fairly uncommon in production and
22055 ## selser will take care of preserving formatting in those scenarios.
22056 !! test
22057 Don't convert blue categorylinks to another variant (T35210)
22058 !! options
22059 cat
22060 language=zh
22061 parsoid=wt2html
22062 !! wikitext
22063 [[A]][[Category:分类]]
22064 !! html/php
22065 cat=分类 sort=
22066 !! html/parsoid
22067 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
22068 <link rel="mw:PageProp/Category" href="./Category:分类"/>
22069 !! end
22070
22071 !! test
22072 Stripping -{}- tags (language variants)
22073 !! options
22074 language=sr
22075 !! wikitext
22076 Latin proverb: -{Ne nuntium necare}-
22077 !! html/php
22078 <p>Latin proverb: Ne nuntium necare
22079 </p>
22080 !! html/parsoid
22081 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22082 !! end
22083
22084
22085 !! test
22086 Prevent conversion with -{}- tags (language variants)
22087 !! options
22088 language=sr variant=sr-ec
22089 !! wikitext
22090 Latinski: -{Ne nuntium necare}-
22091 !! html/php
22092 <p>Латински: Ne nuntium necare
22093 </p>
22094 !! html/parsoid
22095 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22096 !! end
22097
22098
22099 !! test
22100 Prevent conversion of text with -{}- tags (language variants)
22101 !! options
22102 language=sr variant=sr-ec
22103 !! wikitext
22104 Latinski: -{Ne nuntium necare}-
22105 !! html/php
22106 <p>Латински: Ne nuntium necare
22107 </p>
22108 !! html/parsoid
22109 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22110 !! end
22111
22112
22113 !! test
22114 Prevent conversion of links with -{}- tags (language variants)
22115 !! options
22116 language=sr variant=sr-ec
22117 !! wikitext
22118 -{[[Main Page]]}-
22119 !! html/php
22120 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22121 </p>
22122 !! html/parsoid
22123 <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>
22124 !! end
22125
22126
22127 !! test
22128 -{}- tags within headlines (within html for parserConvert())
22129 !! config
22130 wgFragmentMode=[ 'html5', 'legacy' ]
22131 !! options
22132 language=sr variant=sr-ec
22133 !! wikitext
22134 == -{Naslov}- ==
22135
22136 Note that even an unprotected headline ID is not affected by language
22137 conversion:
22138
22139 == Latinski ==
22140 !! html/php
22141 <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>
22142 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
22143 цонверсион:
22144 </p>
22145 <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>
22146
22147 !! html/parsoid
22148 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span> <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span> </h2>
22149
22150 <p>Note that even an unprotected headline ID is not affected by language
22151 conversion:</p>
22152
22153 <h2 id="Latinski">Latinski</h2>
22154 !! end
22155
22156 !! test
22157 Explicit definition of language variant alternatives
22158 !! options
22159 language=zh variant=zh-tw
22160 !! wikitext
22161 -{zh:China;zh-tw:Taiwan}-, not China
22162 !! html/php
22163 <p>Taiwan, not China
22164 </p>
22165 !! html/parsoid
22166 <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>
22167 !! end
22168
22169 !! test
22170 Filter syntax for language variants
22171 !! options
22172 language=zh variant=zh-tw
22173 !! wikitext
22174 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
22175 !! html/php
22176 <p>fooblog, WEBJOURNAL, WEBLOGquux
22177 </p>
22178 !! html/parsoid
22179 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
22180 !! end
22181
22182 # Note that Parsoid post-processing for language variants needs to
22183 # update the `title` attribute here, based on the mw:ExpandedAttrs property
22184 !! test
22185 Conversion around HTML tags
22186 !! options
22187 language=sr variant=sr-ec
22188 !! wikitext
22189 -{H|span=>sr-ec:script;title=>sr-ec:src}-
22190 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
22191 !! html/php
22192 <p>
22193 <span title="ЛаCтин">ски</span>
22194 </p>
22195 !! html/parsoid
22196 <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"}]}'/>
22197 <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>
22198 !! end
22199
22200 !! test
22201 Explicit session-wise two-way language variant mapping (A flag and - flag)
22202 !! options
22203 language=zh variant=zh-tw
22204 !! wikitext
22205 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
22206
22207 Taiwan is not China.
22208
22209 But -{A|zh:China; zh-tw:Taiwan}- is China,
22210
22211 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
22212
22213 and -{China}- is China.
22214 !! html/php
22215 <p>This is Taiwan, but we'll forget that now.
22216 </p><p>Taiwan is not China.
22217 </p><p>But Taiwan is Taiwan,
22218 </p><p>(This should be stripped!)
22219 </p><p>and China is China.
22220 </p>
22221 !! html/parsoid
22222 <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>
22223 <p>Taiwan is not China.</p>
22224 <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>
22225 <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>
22226 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
22227 !! end
22228
22229 !! test
22230 Explicit session-wise one-way language variant mapping (A flag and - flag)
22231 !! options
22232 language=zh variant=zh-tw
22233 !! wikitext
22234 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
22235
22236 COUNTRY is China or Taiwan.
22237
22238 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
22239
22240 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22241
22242 and -{COUNTRY}- is COUNTRY.
22243 !! html/php
22244 <p>This is Taiwan, but we'll forget that now.
22245 </p><p>COUNTRY is China or Taiwan.
22246 </p><p>But Taiwan is Taiwan,
22247 </p><p>(This should be stripped!)
22248 </p><p>and COUNTRY is COUNTRY.
22249 </p>
22250 !! html/parsoid
22251 <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>
22252 <p>COUNTRY is China or Taiwan.</p>
22253 <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>
22254 <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>
22255 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
22256 !! end
22257
22258 !! test
22259 Explicit session-wise two-way language variant mapping (H flag for hide)
22260 !! options
22261 language=zh variant=zh-tw
22262 !! wikitext
22263 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
22264
22265 Taiwan is China.
22266 !! html/php
22267 <p>(This should be stripped!)
22268 </p><p>Taiwan is Taiwan.
22269 </p>
22270 !! html/parsoid
22271 <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>
22272 <p>Taiwan is China.</p>
22273 !! end
22274
22275 !! test
22276 Explicit session-wise one-way language variant mapping (H flag for hide)
22277 !! options
22278 language=zh variant=zh-tw
22279 !! wikitext
22280 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22281
22282 COUNTRY is Taiwan or China.
22283 !! html/php
22284 <p>(This should be stripped!)
22285 </p><p>Taiwan is Taiwan or China.
22286 </p>
22287 !! html/parsoid
22288 <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>
22289 <p>COUNTRY is Taiwan or China.</p>
22290 !! end
22291
22292 ## Note that parsoid test runner does not support 'showtitle' option.
22293 !! test
22294 Adding explicit conversion rule for title (T flag)
22295 !! options
22296 language=zh variant=zh-tw showtitle
22297 !! wikitext
22298 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
22299
22300 Taiwan is China.
22301 !! html/php
22302 Taiwan
22303 <p>Should be stripped!
22304 </p><p>Taiwan is China.
22305 </p>
22306 !! html/parsoid
22307 <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>
22308 <p>Taiwan is China.</p>
22309 !! end
22310
22311 !! test
22312 Code coverage: T combined with H flag
22313 !! options
22314 language=zh variant=zh-tw showtitle
22315 !! wikitext
22316 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
22317
22318 Taiwan is China.
22319 !! html/php
22320 Taiwan
22321 <p>Should be stripped!
22322 </p><p>Taiwan is Taiwan.
22323 </p>
22324 !! html/parsoid
22325 <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>
22326 <p>Taiwan is China.</p>
22327 !! end
22328
22329 !! test
22330 Code coverage: T with no variants
22331 !! options
22332 language=zh variant=zh-tw showtitle
22333 !! wikitext
22334 -{H|zh:China; zh-tw:Taiwan}-
22335 Taiwan is China.-{T|Taiwan is China}-
22336 !! html/php
22337 Taiwan is China
22338 <p>
22339 Taiwan is Taiwan.
22340 </p>
22341 !! html/parsoid
22342 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22343 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
22344 !! end
22345
22346 !! test
22347 Code coverage: rules with no variants
22348 !! options
22349 language=zh variant=zh-tw
22350 !! wikitext
22351 -{H|zh:China; zh-tw:Taiwan}-
22352 Taiwan is China.
22353 -{H|China}-
22354 Taiwan is China.
22355 !! html/php
22356 <p>
22357 Taiwan is Taiwan.
22358
22359 Taiwan is China.
22360 </p>
22361 !! html/parsoid
22362 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22363 Taiwan is China.
22364 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
22365 Taiwan is China.</p>
22366 !! end
22367
22368
22369 !! test
22370 Code coverage: D flag for conversion rule
22371 !! options
22372 language=zh variant=zh-tw
22373 !! wikitext
22374 -{D|zh-cn:XA; zh-tw:YA}-
22375 -{A;D|zh-cn:XB; zh-tw:YB}-
22376 -{D;H|zh-cn:XC; zh-tw:YC}-
22377
22378 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
22379
22380 -{D|0=>zh-tw:1}-
22381 -{A;D|2=>zh-tw:3}-
22382 -{D;H|4=>zh-tw:5}-
22383
22384 XA XB XC YA YB YC FOO BAR BAT 012345
22385 !! html/php
22386 <p>大陆:XA;台灣:YA;
22387
22388 大陆:XC;台灣:YC;
22389 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
22390 </p><p>0⇒台灣:1;
22391
22392 4⇒台灣:5;
22393 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
22394 </p>
22395 !! html/parsoid
22396 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
22397 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
22398 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
22399 <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>
22400 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
22401 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
22402 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
22403 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
22404 !! end
22405
22406 !! test
22407 Code coverage: N flag for conversion rule
22408 !! options
22409 language=zh variant=zh-cn
22410 !! wikitext
22411 -{N|zh-cn}-
22412
22413 -{N|zh-tw}-
22414
22415 -{N|sr-ec}-
22416 !! html/php
22417 <p>大陆
22418 </p><p>台灣
22419 </p><p>српски (ћирилица)‎
22420 </p>
22421 !! html/parsoid
22422 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
22423 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
22424 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
22425 !! end
22426
22427 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
22428 !! test
22429 Code coverage: N flag for conversion rule (wt2html only)
22430 !! options
22431 language=zh variant=zh-cn
22432 parsoid=wt2html,html2html
22433 !! wikitext
22434 -{D;N|en}-
22435 !! html/php
22436 <p>English
22437 </p>
22438 !! html/parsoid
22439 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
22440 !! end
22441
22442 !! test
22443 Testing that changing the language variant here in the tests actually works
22444 !! options
22445 language=zh variant=zh showtitle
22446 !! wikitext
22447 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22448 !! html/php
22449 China
22450 <p>Should be stripped!
22451 </p>
22452 !! html/parsoid
22453 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
22454 !! end
22455
22456 !! test
22457 Recursive conversion of alt and title attrs shouldn't clear converter state
22458 !! options
22459 language=zh variant=zh-cn
22460 showtitle
22461 !! wikitext
22462 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
22463 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
22464 !! html/php
22465 China
22466 <p>
22467 Should be stripped<span title="Exclamation">!</span>
22468 </p>
22469 !! html/parsoid
22470 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
22471 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>
22472 !! end
22473
22474 !! test
22475 T26072: more test on conversion rule for title
22476 !! options
22477 language=zh variant=zh-tw showtitle
22478 !! wikitext
22479 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22480
22481 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
22482 !! html/php
22483 Taiwan
22484 <p>This should be stripped!
22485 </p><p>This won't take interferes with the title rule.
22486 </p>
22487 !! html/parsoid
22488 <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>
22489 <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>
22490 !! end
22491
22492 !! test
22493 Partly disable title conversion if variant == main language code
22494 !! options
22495 language=zh variant=zh title=[[ZH]] showtitle
22496 !! wikitext
22497 -{T|zh-cn:CN;zh-tw:TW}-
22498 !! html/php
22499 ZH
22500 <p>
22501 </p>
22502 !! html/parsoid
22503 <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>
22504 !! end
22505
22506 !! test
22507 Partly disable title conversion if variant == main language code, more
22508 !! options
22509 language=zh variant=zh title=[[ZH]] showtitle
22510 !! wikitext
22511 -{T|TW}-
22512 !! html/php
22513 ZH
22514 <p>
22515 </p>
22516 !! html/parsoid
22517 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
22518 !! end
22519
22520 !! test
22521 Raw output of variant escape tags (R flag)
22522 !! options
22523 language=zh variant=zh-tw
22524 !! wikitext
22525 Raw: -{R|zh:China;zh-tw:Taiwan}-
22526 !! html/php
22527 <p>Raw: zh:China;zh-tw:Taiwan
22528 </p>
22529 !! html/parsoid
22530 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
22531 !! end
22532
22533 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
22534 !! test
22535 Raw output of variant escape tags (R flag) (wt2html only)
22536 !! options
22537 language=zh variant=zh-tw
22538 parsoid=wt2html,html2html
22539 !! wikitext
22540 -{Variant}- -{D|syntax}- -{D;R|options}-
22541 !! html/php
22542 <p>Variant syntax options
22543 </p>
22544 !! html/parsoid
22545 <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>
22546 !! end
22547
22548 !! test
22549 Nested markup inside raw output of variant escape tags (R flag)
22550 !! options
22551 language=zh variant=zh-tw
22552 !! wikitext
22553 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
22554 !! html/php
22555 <p>Nested raw: nested Taiwan nested
22556 </p>
22557 !! html/parsoid
22558 <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>
22559 !! end
22560
22561 !! test
22562 Nested markup and spaces inside raw output of variant escape tags (R flag)
22563 !! options
22564 language=zh variant=zh-tw
22565 !! wikitext
22566 X-{ outer -{ inner }- outer }-X
22567 !! html/php
22568 <p>X outer inner outer X
22569 </p>
22570 !! html/parsoid
22571 <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>
22572 !! end
22573
22574 !! test
22575 Templates inside raw output of variant escape tags (R flag)
22576 !! options
22577 language=zh variant=zh-tw
22578 !! wikitext
22579 Nested raw: -{R|nested {{echo|hi}} templates}-
22580 !! html/php
22581 <p>Nested raw: nested hi templates
22582 </p>
22583 !! html/parsoid
22584 <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>
22585 !! end
22586
22587 !! test
22588 Strings evaluating false shouldn't be ignored by Language converter (T51072)
22589 !! options
22590 language=zh variant=zh-cn
22591 !! input
22592 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
22593 !! html/php
22594 <p>0
22595 </p>
22596 !! html/parsoid
22597 <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>
22598 !! end
22599
22600 !! test
22601 Conversion rules from [numeric-only string] to [something else] (T48634)
22602 !! options
22603 language=zh variant=zh-cn
22604 !! input
22605 -{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
22606 !! html/php
22607 <p>D12345EE12345
22608 </p>
22609 !! html/parsoid
22610 <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>
22611 !! end
22612
22613 !! test
22614 Two-way converter rule entries with an empty value should be ignored (T53551)
22615 !! options
22616 language=zh variant=zh-cn
22617 !! input
22618 -{H|zh-cn:foo;zh-tw:;}-foobar
22619 !! html/php
22620 <p>foobar
22621 </p>
22622 !! html/parsoid
22623 <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>
22624 !! end
22625
22626 !! test
22627 One-way converter rule entries with an empty "from" string should be ignored (T53551)
22628 !! options
22629 language=zh variant=zh-cn
22630 !! input
22631 -{H|=>zh-cn:foo;}-foobar
22632 !! html/php
22633 <p>foobar
22634 </p>
22635 !! html/parsoid
22636 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
22637 !! end
22638
22639 !! test
22640 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
22641 !! options
22642 language=zh variant=zh-cn
22643 !! input
22644 -{H|}-foobar
22645 !! html/php
22646 <p>foobar
22647 </p>
22648 !! html/parsoid
22649 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
22650 !! end
22651
22652 !! test
22653 Nested using of manual convert syntax
22654 !! options
22655 language=zh variant=zh-hk
22656 !! wikitext
22657 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
22658 !! html/php
22659 <p>Nested: Hello Hong Kong!
22660 </p>
22661 !! html/parsoid
22662 <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>
22663 !! end
22664
22665 !! test
22666 HTML markups with conversion syntax in attribs, nested in other conversion blocks
22667 !! options
22668 language=zh variant=zh-cn
22669 !! wikitext
22670 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
22671 !! html/php
22672 <p><span title="X">A</span>
22673 </p>
22674 !! html/parsoid
22675 <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>
22676 !! end
22677
22678 !! test
22679 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
22680 !! options
22681 language=zh variant=zh-cn
22682 !! wikitext
22683 -{<span title="-{X}-">A</span>}-
22684 !! html/php+disabled
22685 <p><span title="X">A</span>
22686 </p>
22687 !! html/parsoid
22688 <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>
22689 !! end
22690
22691 # Parsoid and PHP disagree on how to parse this example: Parsoid
22692 # insists that the content of a language converter element be a valid
22693 # DOM fragment or attribute string
22694 !! test
22695 Language converter markup with block content
22696 !! options
22697 language=zh variant=zh-cn
22698 !! wikitext
22699 <span>a-{b<div>c}-d
22700
22701 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
22702
22703 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
22704 !! html/php+tidy
22705 <p><span>ab</span></p>
22706 <div><span>cd <span>ab</span></span>
22707 <div><span>cd <span>ad</span></span></div>
22708 </div>
22709 !! html/parsoid
22710 <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>
22711
22712 <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>
22713
22714 <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>
22715 !! end
22716
22717 !! test
22718 LanguageConverter selser (1)
22719 !! options
22720 language=zh variant=zh-cn
22721 parsoid={
22722 "modes": ["wt2wt", "selser"],
22723 "changes": [
22724 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22725 ]
22726 }
22727 !! wikitext
22728 -{raw}-
22729 !! wikitext/edited
22730 -{edited}-
22731 !! end
22732
22733 !! test
22734 LanguageConverter selser (2)
22735 !! options
22736 language=zh variant=zh-cn
22737 parsoid={
22738 "modes": ["wt2wt", "selser"],
22739 "changes": [
22740 ["span[class='x']", "contents", "text", "-{foo}-"],
22741 ["a", "contents", "text", "-{"],
22742 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
22743 ]
22744 }
22745 !! wikitext
22746 <span class="x">TEXT1</span>
22747 [http://example.com TEXT2]
22748 [[Foo|TEXT3]]
22749 {{echo|TEXT4}}
22750 !! wikitext/edited
22751 <span class="x"><nowiki>-{foo}-</nowiki></span>
22752 [http://example.com -{]
22753 [[Foo|<nowiki>-{</nowiki>]]
22754 {{1x|<nowiki>-{</nowiki>}}
22755 !! end
22756
22757 # Tests LanguageVariantText in ConstrainedText
22758 !! test
22759 LanguageConverter selser (3)
22760 !! options
22761 language=zh variant=zh-cn
22762 parsoid={
22763 "modes": ["wt2wt", "selser"],
22764 "changes": [
22765 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
22766 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22767 ]
22768 }
22769 !! wikitext
22770 {|
22771 |-
22772 |<span>Foo</span>
22773 |}
22774 !! wikitext/edited
22775 {|
22776 |-
22777 |<nowiki/>-{edited}-
22778 |}
22779 !! end
22780
22781 # Tests LanguageVariantText._fromSelSer
22782 !! test
22783 LanguageConverter selser (4)
22784 !! options
22785 language=zh variant=zh-cn
22786 parsoid={
22787 "modes": ["wt2wt", "selser"],
22788 "changes": [
22789 ["td > span.x", "remove"]
22790 ]
22791 }
22792 !! wikitext
22793 {|
22794 |-
22795 |<span class="x">Foo</span>-{Bar}-
22796 ||<span class="x">Foo</span>-{Bar}-
22797 |}
22798 !! wikitext/edited
22799 {|
22800 |-
22801 |<nowiki/>-{Bar}-
22802 ||-{Bar}-
22803 |}
22804 !! end
22805
22806 # Since Parsoid is starting to emit canonical wikitext for links,
22807 # [http://example.com http://example.com] will not RT back to that
22808 # form anymore.
22809 # Parsoid does not language-convert links (it is done in a
22810 # post-processing step)
22811 !! test
22812 Proper conversion of text in external links
22813 !! options
22814 language=sr variant=sr-ec
22815 parsoid=wt2html
22816 !! wikitext
22817 http://www.google.com
22818 gopher://www.google.com
22819 [http://www.google.com http://www.google.com]
22820 [gopher://www.google.com gopher://www.google.com]
22821 [https://www.google.com irc://www.google.com]
22822 [ftp://www.google.com www.google.com/ftp://dir]
22823 [//www.google.com www.google.com]
22824 !! html/php
22825 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22826 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22827 <a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22828 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22829 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
22830 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
22831 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
22832 </p>
22833 !! html/parsoid
22834 <p><a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
22835 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
22836 <a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
22837 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
22838 <a rel="mw:ExtLink" href="https://www.google.com">irc://www.google.com</a>
22839 <a rel="mw:ExtLink" href="ftp://www.google.com">www.google.com/ftp://dir</a>
22840 <a rel="mw:ExtLink" href="//www.google.com">www.google.com</a></p>
22841 !! end
22842
22843 !! test
22844 Do not convert roman numbers to language variants
22845 !! options
22846 language=sr variant=sr-ec
22847 !! wikitext
22848 Fridrih IV je car.
22849 !! html/php
22850 <p>Фридрих IV је цар.
22851 </p>
22852 !! html/parsoid
22853 <p>Fridrih IV je car.</p>
22854 !! end
22855
22856 !! test
22857 Unclosed language converter markup "-{"
22858 !! options
22859 language=sr
22860 !! wikitext
22861 -{T|hello
22862 !! html
22863 <p>-{T|hello
22864 </p>
22865 !! end
22866
22867 !! test
22868 Don't convert raw rule "-{R|=&gt;}-" to "=>"
22869 !! options
22870 language=sr
22871 !! wikitext
22872 -{R|=&gt;}-
22873 !! html/php
22874 <p>=&gt;
22875 </p>
22876 !! html/parsoid
22877 <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>
22878 !!end
22879
22880 !! test
22881 Don't break link parsing if language converter markup is in the caption.
22882 !! options
22883 language=sr variant=sr-ec
22884 !! wikitext
22885 [[Main Page|-{R|main page}-]]
22886 !! html/php
22887 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
22888 </p>
22889 !! html/parsoid
22890 <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>
22891 !! end
22892
22893 !! test
22894 T146304: Don't break template parsing if language converter markup is in the parameter.
22895 !! options
22896 language=sr variant=sr-ec
22897 !! wikitext
22898 {{echo|-{R|foo}-}}
22899 !! html/php
22900 <p>foo
22901 </p>
22902 !! html/parsoid
22903 <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>
22904 !! end
22905
22906 !! test
22907 T146305: Don't break image parsing if language converter markup is in the caption.
22908 !! options
22909 language=sr
22910 !! wikitext
22911 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
22912 !! html/php
22913 <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>
22914
22915 !! html/parsoid
22916 <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>
22917 !! end
22918
22919 !! test
22920 T146305: Don't break image parsing if nested language converter markup is in the caption.
22921 !! options
22922 language=zh variant=zh-cn
22923 !! wikitext
22924 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
22925 !! html/php
22926 <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>
22927
22928 !! html/parsoid
22929 <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>
22930 !! end
22931
22932 # XXX html2wt disabled because rich markup in alt is not preserved.
22933 !! test
22934 Don't break gallery if language converter markup is inside.
22935 !! options
22936 language=zh
22937 !! wikitext
22938 <gallery>
22939 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
22940 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
22941 </gallery>
22942 !! html/php
22943 <ul class="gallery mw-gallery-traditional">
22944 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22945 <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>
22946 <div class="gallerytext">
22947 <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>
22948 </p>
22949 </div>
22950 </div></li>
22951 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22952 <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>
22953 <div class="gallerytext">
22954 <p>This is a test template
22955 </p>
22956 </div>
22957 </div></li>
22958 </ul>
22959
22960 !! html/parsoid
22961 <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"}}'>
22962 <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>
22963 <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>
22964 </ul>
22965 !! end
22966
22967 !! test
22968 T153135: Don't break list handling if language converter markup is in the item.
22969 !! options
22970 language=zh variant=zh-cn
22971 !! wikitext
22972 ;-{zh-cn:AAA;zh-tw:BBB}-
22973 ;-{R|foo:bar}-
22974 !! html/php
22975 <dl><dt>AAA</dt>
22976 <dt>foo:bar</dt></dl>
22977
22978 !! html/parsoid
22979 <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>
22980 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
22981 </dl>
22982 !! end
22983
22984 // Note that parsoid does not protect colons unless language converter
22985 // markup is properly nested, because it is a backtracking parser.
22986 !! test
22987 T153135: Unclosed markup in definition list (code coverage)
22988 !! options
22989 language=zh variant=zh-cn
22990 !! wikitext
22991 ;<b>foo:bar
22992 ;-{zh-cn:AAA
22993 !! html/php+tidy
22994 <dl>
22995 <dt><b>foo:bar</b></dt>
22996 <dt><b>-{zh-cn:AAA</b></dt>
22997 </dl>
22998 !! html/parsoid
22999 <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}'>
23000 <dt data-parsoid='{"dsr":[12,20,1,0]}'>-{zh-cn</dt>
23001 <dd data-parsoid='{"stx":"row","dsr":[20,24,1,0]}'>AAA</dd>
23002 </b></dl>
23003 !! end
23004
23005 !! test
23006 T153135: Nested language converter markup in definition list (code coverage)
23007 !! options
23008 language=zh variant=zh-cn
23009 !! wikitext
23010 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
23011 !! html/php
23012 <dl><dt>AAA foo:bar bat:baz</dt>
23013 <dd>def</dd></dl>
23014
23015 !! html/parsoid
23016 <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>
23017 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
23018 </dl>
23019 !! end
23020
23021 # html2wt mode disabled due to <nowiki> insertion.
23022 !! test
23023 T153140: Don't break table handling if language converter markup is in the cell.
23024 !! options
23025 language=sr variant=sr-ec
23026 parsoid=wt2html,wt2wt,html2html
23027 !! wikitext
23028 {|
23029 |-
23030 | -{R|B}-
23031 |}
23032 !! html/php
23033 <table>
23034
23035 <tr>
23036 <td> B
23037 </td></tr></table>
23038
23039 !! html/parsoid
23040 <table>
23041 <tbody>
23042 <tr>
23043 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
23044 </tr>
23045 </tbody>
23046 </table>
23047 !! end
23048
23049 !! test
23050 Language converter tricky html2wt cases (1)
23051 !! options
23052 language=sr
23053 parsoid=html2wt,wt2wt
23054 !! html/parsoid
23055 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
23056 !! wikitext
23057 -{<nowiki>}-</nowiki>}-
23058 !! html/php
23059 <p>&#125;-
23060 </p>
23061 !! end
23062
23063 !! test
23064 Language converter tricky html2wt cases (2)
23065 !! options
23066 language=sr
23067 parsoid=html2wt,wt2wt
23068 !! html/parsoid
23069 <p>-{foo}-</p>
23070 !! wikitext
23071 <nowiki>-{foo}-</nowiki>
23072 !! html/php
23073 <p>-&#123;foo&#125;-
23074 </p>
23075 !! end
23076
23077 !! test
23078 Language converter tricky html2wt cases (3)
23079 !! options
23080 language=sr
23081 parsoid=html2wt,wt2wt
23082 !! html/parsoid
23083 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
23084 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
23085 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
23086 !! wikitext
23087 -{R||}-
23088
23089 -{R|R|raw}-
23090
23091 -{<nowiki>-{foo}-</nowiki>}-
23092 !! html/php
23093 <p>|
23094 </p><p>R|raw
23095 </p><p>-&#123;foo&#125;-
23096 </p>
23097 !! end
23098
23099 !! test
23100 Language converter tricky html2wt cases (4)
23101 !! options
23102 language=sr
23103 parsoid=html2wt,wt2wt
23104 !! html/parsoid
23105 <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>
23106 !! wikitext
23107 -{R|{{echo|hey}}}-
23108 !! html/php
23109 <p>hey
23110 </p>
23111 !! end
23112
23113 # Note that the <nowiki> escaping added by parsoid for source text,
23114 # destination text, and language names only works on the PHP side
23115 # for *destination text*. (HTML entity escaping wouldn't work
23116 # any better.) This is probably a bug, at least for source texts.
23117 # (For language names PHP uses a precise regexp based on the languages
23118 # it currently knows have variants, which is fragile since this set
23119 # can grow/shrink over time.)
23120 !! test
23121 Language converter tricky html2wt cases (5)
23122 !! options
23123 language=zh variant=zh-cn
23124 !! html/parsoid
23125 <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>
23126 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
23127 <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>
23128 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
23129 <p>a:b=>c xyz</p>
23130 !! wikitext
23131 -{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
23132
23133 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
23134
23135 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
23136
23137 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
23138
23139 a:b=>c xyz
23140 !! html/php+disabled
23141 <p>foobat;xyz=&gt;zh-cn:abc
23142 </p><p>A
23143 </p><p>0;zh-tw:bar
23144 </p><p>abc
23145 </p><p>a:b=&gt;c 0;zh-tw:bar
23146 </p>
23147 !! end
23148
23149 !! test
23150 T179579: Nowiki and lc interaction
23151 !! options
23152 parsoid=wt2html
23153 language=sr
23154 !! wikitext
23155 -{</nowiki>123}-
23156
23157 -{123<nowiki>|</nowiki>456}-
23158 !! html/parsoid
23159 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
23160
23161 <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>
23162 !! end
23163
23164 !! test
23165 T2529: Uncovered bullet
23166 !! wikitext
23167 * Foo {{bullet}}
23168 !! html
23169 <ul><li> Foo </li>
23170 <li> Bar</li></ul>
23171
23172 !! end
23173
23174 # Plain MediaWiki does not remove empty lists, but tidy actually does.
23175 # Templates in Wikipedia rely on this behavior, as tidy has always been
23176 # enabled there. These tests are normally run *without* tidy, so specify the
23177 # full output here.
23178 # To test realistic parsing behavior, apply a tidy-like transformation to both
23179 # the expected output and your parser's output.
23180 !! test
23181 T2529: Uncovered bullet leaving empty list, normally removed by tidy
23182 !! wikitext
23183 ******* Foo {{bullet}}
23184 !! html
23185 <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>
23186 <li> Bar</li></ul>
23187
23188 !! end
23189
23190 !! test
23191 T2529: Uncovered table already at line-start
23192 !! wikitext
23193 x
23194
23195 {{table}}
23196 y
23197 !! html
23198 <p>x
23199 </p>
23200 <table>
23201 <tr>
23202 <td> 1 </td>
23203 <td> 2
23204 </td></tr>
23205 <tr>
23206 <td> 3 </td>
23207 <td> 4
23208 </td></tr></table>
23209 <p>y
23210 </p>
23211 !! end
23212
23213 !! test
23214 T2529: Uncovered bullet in parser function result
23215 !! wikitext
23216 * Foo {{lc:{{bullet}} }}
23217 !! html
23218 <ul><li> Foo </li>
23219 <li> bar</li></ul>
23220
23221 !! end
23222
23223 !! test
23224 T7678: Double-parsed template argument
23225 !! wikitext
23226 {{lc:{{{1}}}|hello}}
23227 !! html
23228 <p>{{{1}}}
23229 </p>
23230 !! end
23231
23232 !! test
23233 T7678: Double-parsed template invocation
23234 !! wikitext
23235 {{lc:{{paramtest {{!}} param = hello }} }}
23236 !! html
23237 <p>{{paramtest | param = hello }}
23238 </p>
23239 !! end
23240
23241 !! test
23242 Case insensitivity of parser functions for non-ASCII characters (T10143)
23243 !! options
23244 language=cs
23245 title=[[Main Page]]
23246 !! wikitext
23247 {{PRVNÍVELKÉ:ěščř}}
23248 {{prvnívelké:ěščř}}
23249 {{PRVNÍMALÉ:ěščř}}
23250 {{prvnímalé:ěščř}}
23251 {{MALÁ:ěščř}}
23252 {{malá:ěščř}}
23253 {{VELKÁ:ěščř}}
23254 {{velká:ěščř}}
23255 !! html
23256 <p>Ěščř
23257 Ěščř
23258 ěščř
23259 ěščř
23260 ěščř
23261 ěščř
23262 ĚŠČŘ
23263 ĚŠČŘ
23264 </p>
23265 !! end
23266
23267 !! test
23268 Morwen/13: Unclosed link followed by heading
23269 !! wikitext
23270 [[link
23271 ==heading==
23272 !! html
23273 <p>[[link
23274 </p>
23275 <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>
23276
23277 !! end
23278
23279 !! test
23280 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
23281 !! wikitext
23282 {{foo|
23283 =heading=
23284 !! html
23285 <p>{{foo|
23286 </p>
23287 <h1><span class="mw-headline" id="heading">heading</span></h1>
23288
23289 !! end
23290
23291 !! test
23292 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
23293 !! wikitext
23294 {{foo|
23295 ==heading==
23296 !! html
23297 <p>{{foo|
23298 </p>
23299 <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>
23300
23301 !! end
23302
23303 !! test
23304 Tildes in comments
23305 !! options
23306 pst
23307 !! wikitext
23308 <!-- ~~~~ -->
23309 !! html/php
23310 <!-- ~~~~ -->
23311 !! end
23312
23313 !! test
23314 Paragraphs inside divs (no extra line breaks)
23315 !! wikitext
23316 <div>Line one
23317
23318 Line two</div>
23319 !! html
23320 <div>Line one
23321 Line two</div>
23322
23323 !! end
23324
23325 !! test
23326 Paragraphs inside divs (extra line break on open)
23327 !! wikitext
23328 <div>
23329 Line one
23330
23331 Line two</div>
23332 !! html
23333 <div>
23334 <p>Line one
23335 </p>
23336 Line two</div>
23337
23338 !! end
23339
23340 !! test
23341 Paragraphs inside divs (extra line break on close)
23342 !! wikitext
23343 <div>Line one
23344
23345 Line two
23346 </div>
23347 !! html
23348 <div>Line one
23349 <p>Line two
23350 </p>
23351 </div>
23352
23353 !! end
23354
23355 !! test
23356 Paragraphs inside divs (extra line break on open and close)
23357 !! wikitext
23358 <div>
23359 Line one
23360
23361 Line two
23362 </div>
23363 !! html
23364 <div>
23365 <p>Line one
23366 </p><p>Line two
23367 </p>
23368 </div>
23369
23370 !! end
23371
23372 !! test
23373 Nesting tags, paragraphs on lines which begin with <div>
23374 !! wikitext
23375 <div></div><strong>A
23376 B</strong>
23377 !! html/php+tidy
23378 <p><strong>A</strong></p>
23379 <p><strong>B</strong></p>
23380 !! html/parsoid
23381 <div></div>
23382 <p><strong>A
23383 B</strong>
23384 </p>
23385 !! end
23386
23387 # T8200: <blockquote> should behave like <div> with respect to line breaks
23388 !! test
23389 T8200: paragraphs inside blockquotes (no extra line breaks)
23390 !! wikitext
23391 <blockquote>Line one
23392
23393 Line two</blockquote>
23394 !! html
23395 <blockquote>Line one
23396 Line two</blockquote>
23397
23398 !! html+tidy
23399 <blockquote>
23400 <p>Line one Line two</p>
23401 </blockquote>
23402 !! end
23403
23404 !! test
23405 T8200: paragraphs inside blockquotes (extra line break on open)
23406 !! wikitext
23407 <blockquote>
23408 Line one
23409
23410 Line two</blockquote>
23411 !! html
23412 <blockquote>
23413 <p>Line one
23414 </p>
23415 Line two</blockquote>
23416
23417 !! html+tidy
23418 <blockquote>
23419 <p>Line one</p>
23420 Line two</blockquote>
23421 !! end
23422
23423 !! test
23424 T8200: paragraphs inside blockquotes (extra line break on close)
23425 !! wikitext
23426 <blockquote>Line one
23427
23428 Line two
23429 </blockquote>
23430 !! html
23431 <blockquote>Line one
23432 <p>Line two
23433 </p>
23434 </blockquote>
23435
23436 !! html+tidy
23437 <blockquote>
23438 <p>Line one</p>
23439 <p>Line two</p>
23440 </blockquote>
23441 !! end
23442
23443 !! test
23444 T8200: paragraphs inside blockquotes (extra line break on open and close)
23445 !! wikitext
23446 <blockquote>
23447 Line one
23448
23449 Line two
23450 </blockquote>
23451 !! html
23452 <blockquote>
23453 <p>Line one
23454 </p><p>Line two
23455 </p>
23456 </blockquote>
23457
23458 !! html+tidy
23459 <blockquote>
23460 <p>Line one</p>
23461 <p>Line two</p>
23462 </blockquote>
23463 !! end
23464
23465 !! test
23466 Paragraphs inside blockquotes/divs (no extra line breaks)
23467 !! wikitext
23468 <blockquote><div>Line one
23469
23470 Line two</div></blockquote>
23471 !! html
23472 <blockquote><div>Line one
23473 Line two</div></blockquote>
23474
23475 !! end
23476
23477 !! test
23478 Paragraphs inside blockquotes/divs (extra line break on open)
23479 !! wikitext
23480 <blockquote><div>
23481 Line one
23482
23483 Line two</div></blockquote>
23484 !! html
23485 <blockquote><div>
23486 <p>Line one
23487 </p>
23488 Line two</div></blockquote>
23489
23490 !! end
23491
23492 !! test
23493 Paragraphs inside blockquotes/divs (extra line break on close)
23494 !! wikitext
23495 <blockquote><div>Line one
23496
23497 Line two
23498 </div></blockquote>
23499 !! html
23500 <blockquote><div>Line one
23501 <p>Line two
23502 </p>
23503 </div></blockquote>
23504
23505 !! end
23506
23507 !! test
23508 Paragraphs inside blockquotes/divs (extra line break on open and close)
23509 !! wikitext
23510 <blockquote><div>
23511 Line one
23512
23513 Line two
23514 </div></blockquote>
23515 !! html
23516 <blockquote><div>
23517 <p>Line one
23518 </p><p>Line two
23519 </p>
23520 </div></blockquote>
23521
23522 !! end
23523
23524 !! test
23525 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
23526 !! options
23527 wgLinkHolderBatchSize=0
23528 !! wikitext
23529 [[meatball:1]]
23530 [[meatball:2]]
23531 [[meatball:3]]
23532 !! html
23533 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
23534 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
23535 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
23536 </p>
23537 !! end
23538
23539 !! test
23540 Free external link invading image caption
23541 !! wikitext
23542 [[Image:Foobar.jpg|thumb|http://x|hello]]
23543 !! html
23544 <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>
23545
23546 !! end
23547
23548 !! test
23549 T17196: localised external link numbers
23550 !! options
23551 language=fa
23552 !! wikitext
23553 [http://en.wikipedia.org/]
23554 !! html/php
23555 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
23556 </p>
23557 !! html/parsoid
23558 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/"></a></p>
23559 !! end
23560
23561 !! test
23562 Multibyte character in padleft
23563 !! wikitext
23564 {{padleft:-Hello|7|Æ}}
23565 !! html
23566 <p>Æ-Hello
23567 </p>
23568 !! end
23569
23570 !! test
23571 Multibyte character in padright
23572 !! wikitext
23573 {{padright:Hello-|7|Æ}}
23574 !! html
23575 <p>Hello-Æ
23576 </p>
23577 !! end
23578
23579 !!test
23580 formatdate parser function
23581 !! wikitext
23582 {{#formatdate:2009-03-24}}
23583 !! html
23584 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
23585 </p>
23586 !! end
23587
23588 !!test
23589 formatdate parser function, with default format
23590 !! wikitext
23591 {{#formatdate:2009-03-24|mdy}}
23592 !! html
23593 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
23594 </p>
23595 !! end
23596
23597 !! test
23598 Spacing of numbers in formatted dates
23599 !! wikitext
23600 {{#formatdate:January 15}}
23601 !! html
23602 <p><span class="mw-formatted-date" title="01-15">January 15</span>
23603 </p>
23604 !! end
23605
23606 !! test
23607 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
23608 !! options
23609 language=nl title=[[MediaWiki:Common.css]]
23610 !! wikitext
23611 {{#formatdate:2009-03-24|dmy}}
23612 !! html
23613 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
23614 </p>
23615 !! end
23616
23617 #
23618 #
23619 #
23620
23621 #
23622 # Edit comments
23623 #
23624
23625 !! test
23626 Edit comment with link
23627 !! options
23628 comment
23629 !! wikitext
23630 I like the [[Main Page]] a lot
23631 !! html/php
23632 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
23633 !!end
23634
23635 !! test
23636 Edit comment with link and link text
23637 !! options
23638 comment
23639 !! wikitext
23640 I like the [[Main Page|best pages]] a lot
23641 !! html/php
23642 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23643 !!end
23644
23645 !! test
23646 Edit comment with link and link text with suffix
23647 !! options
23648 comment
23649 !! wikitext
23650 I like the [[Main Page|best page]]s a lot
23651 !! html/php
23652 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23653 !!end
23654
23655 !! test
23656 Edit comment with section link (non-local, eg in history list)
23657 !! options
23658 comment title=[[Main Page]]
23659 !! wikitext
23660 /* External links */ removed bogus entries
23661 !! html/php
23662 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23663 !!end
23664
23665 !! test
23666 Edit comment with section link and text before it (non-local, eg in history list)
23667 !! options
23668 comment title=[[Main Page]]
23669 !! wikitext
23670 pre-comment text /* External links */ removed bogus entries
23671 !! html/php
23672 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>
23673 !!end
23674
23675 !! test
23676 Edit comment with section link (local, eg in diff view)
23677 !! options
23678 comment local title=[[Main Page]]
23679 !! wikitext
23680 /* External links */ removed bogus entries
23681 !! html/php
23682 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23683 !!end
23684
23685 !! test
23686 Edit comment with subpage link (T16080)
23687 !! options
23688 comment
23689 subpage
23690 title=[[Subpage test]]
23691 !! wikitext
23692 Poked at a [[/subpage]] here...
23693 !! html/php
23694 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
23695 !!end
23696
23697 !! test
23698 Edit comment with subpage link and link text (T16080)
23699 !! options
23700 comment
23701 subpage
23702 title=[[Subpage test]]
23703 !! wikitext
23704 Poked at a [[/subpage|neat little page]] here...
23705 !! html/php
23706 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
23707 !!end
23708
23709 !! test
23710 Edit comment with bogus subpage link in non-subpage NS (T16080)
23711 !! options
23712 comment
23713 title=[[Subpage test]]
23714 !! wikitext
23715 Poked at a [[/subpage]] here...
23716 !! html/php
23717 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...
23718 !!end
23719
23720 !! test
23721 Edit comment with bare anchor link (local, as on diff)
23722 !! options
23723 comment
23724 local
23725 title=[[Main Page]]
23726 !! wikitext
23727 [[#section]]
23728 !! html/php
23729 <a href="#section">#section</a>
23730 !! end
23731
23732 !! test
23733 Edit comment with bare anchor link (non-local, as on history)
23734 !! options
23735 comment
23736 title=[[Main Page]]
23737 !! wikitext
23738 [[#section]]
23739 !! html/php
23740 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
23741 !! end
23742
23743 !! test
23744 Anchor starting with underscore
23745 !! options
23746 title=[[Foo]]
23747 !! wikitext
23748 [[#_ref|One]]
23749 !! html/php
23750 <p><a href="#_ref">One</a>
23751 </p>
23752 !! html/parsoid
23753 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
23754 !! end
23755
23756 !! test
23757 Id starting with underscore
23758 !! wikitext
23759 <div id="_ref"></div>
23760 !! html/*
23761 <div id="_ref"></div>
23762
23763 !! end
23764
23765 !! test
23766 Edit comment with link with more than one pipe (T99346)
23767 !! options
23768 comment
23769 !! wikitext
23770 [[Main Page|Many|pipes]]
23771 !! html/php
23772 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
23773 !! end
23774
23775 !! test
23776 Complex edit comment with link with more than one pipe (T99346)
23777 !! options
23778 comment
23779 !! wikitext
23780 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
23781 !! html/php
23782 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;
23783 !! end
23784
23785 !! test
23786 Space normalisation on autocomment (T24784)
23787 !! options
23788 comment
23789 title=[[Main Page]]
23790 !! wikitext
23791 /* __hello__world__ */
23792 !! html/php
23793 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
23794 !! end
23795
23796 !! test
23797 percent-encoding and + signs in comments (T28410)
23798 !! options
23799 comment
23800 !! wikitext
23801 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
23802 !! html/php
23803 <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>
23804 !! end
23805
23806 # Parsoid doesn't support this yet: see T75581
23807 # but it *should* omit the 'src' attribute if the image is bad.
23808 # PHP side of tests was disabled in
23809 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
23810 # because of issues in the PHP parserTests infrastructure
23811 # (but the output below is indeed what the PHP side emits)
23812 !! test
23813 Bad images - basic functionality
23814 !! wikitext
23815 [[File:Bad.jpg]]
23816 !! DISABLED/html/php
23817 !! html/parsoid
23818 <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>
23819 !! end
23820
23821 !! test
23822 Bad images - T18039: text after bad image disappears
23823 !! wikitext
23824 Foo bar
23825 [[File:Bad.jpg]]
23826 Bar foo
23827 !! DISABLED/html/php
23828 <p>Foo bar
23829 </p><p>Bar foo
23830 </p>
23831 !! html/parsoid
23832 <p>Foo bar
23833 <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>
23834 Bar foo</p>
23835 !! end
23836
23837 !! test
23838 Verify that displaytitle works (T24501) no displaytitle
23839 !! options
23840 showtitle
23841 !! config
23842 wgAllowDisplayTitle=true
23843 wgRestrictDisplayTitle=false
23844 !! wikitext
23845 this is not the the title
23846 !! html/php
23847 Parser test
23848 <p>this is not the the title
23849 </p>
23850 !! end
23851
23852 !! test
23853 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
23854 !! options
23855 showtitle
23856 title=[[Screen]]
23857 !! config
23858 wgAllowDisplayTitle=true
23859 wgRestrictDisplayTitle=false
23860 !! wikitext
23861 this is not the the title
23862 {{DISPLAYTITLE:whatever}}
23863 !! html/php
23864 whatever
23865 <p>this is not the the title
23866 </p>
23867 !! end
23868
23869 !! test
23870 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
23871 !! options
23872 showtitle
23873 title=[[Screen]]
23874 !! config
23875 wgAllowDisplayTitle=true
23876 wgRestrictDisplayTitle=true
23877 !! wikitext
23878 this is not the the title
23879 {{DISPLAYTITLE:whatever}}
23880 !! html/php
23881 Screen
23882 <p>this is not the the title
23883 </p>
23884 !! end
23885
23886 !! test
23887 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
23888 !! options
23889 showtitle
23890 title=[[Screen]]
23891 !! config
23892 wgAllowDisplayTitle=true
23893 wgRestrictDisplayTitle=true
23894 !! wikitext
23895 this is not the the title
23896 {{DISPLAYTITLE:screen}}
23897 !! html/php
23898 screen
23899 <p>this is not the the title
23900 </p>
23901 !! end
23902
23903 !! test
23904 Verify that displaytitle works (T24501) AllowDisplayTitle=false
23905 !! options
23906 showtitle
23907 title=[[Screen]]
23908 !! config
23909 wgAllowDisplayTitle=false
23910 !! wikitext
23911 this is not the the title
23912 {{DISPLAYTITLE:screen}}
23913 !! html/php
23914 Screen
23915 <p>this is not the the title
23916 <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>
23917 </p>
23918 !! end
23919
23920 !! test
23921 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
23922 !! options
23923 showtitle
23924 title=[[Screen]]
23925 !! config
23926 wgAllowDisplayTitle=false
23927 !! wikitext
23928 this is not the the title
23929 !! html/php
23930 Screen
23931 <p>this is not the the title
23932 </p>
23933 !! end
23934
23935 !! test
23936 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
23937 !! options
23938 showtitle
23939 title=[[Screen]]
23940 !! config
23941 wgAllowDisplayTitle=true
23942 wgRestrictDisplayTitle=true
23943 !! wikitext
23944 this is not the the title
23945 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
23946 !! html/php
23947 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
23948 <p>this is not the the title
23949 </p>
23950 !! end
23951
23952 !! test
23953 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
23954 !! options
23955 showtitle
23956 title=[[Screen]]
23957 !! config
23958 wgAllowDisplayTitle=true
23959 wgRestrictDisplayTitle=true
23960 !! wikitext
23961 this is not the the title
23962 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
23963 !! html/php
23964 <span style="color: red;">s</span>creen
23965 <p>this is not the the title
23966 </p>
23967 !! end
23968
23969 !! test
23970 Page status indicators: Empty name is invalid
23971 !! options
23972 showindicators
23973 !! wikitext
23974 <indicator name=" "></indicator>
23975 <indicator></indicator>
23976 !! html/php
23977 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23978 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23979 </p>
23980 !! end
23981
23982 !! test
23983 Page status indicators: Weird syntaxes that are okay
23984 !! options
23985 showindicators
23986 !! wikitext
23987 <indicator name="empty" />
23988 <indicator name="name"></indicator>
23989 !! html/php
23990 empty=
23991 name=
23992 <p><br />
23993 </p>
23994 !! end
23995
23996 !! test
23997 Page status indicators: Torture test
23998 !! options
23999 showindicators
24000 !! wikitext
24001 <indicator name="01">hello world</indicator>
24002 <indicator name="02">[[Main Page]]</indicator>
24003 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
24004 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
24005 <indicator name="05">* foo
24006 * bar</indicator>
24007 <indicator name="06"><nowiki>foo</nowiki></indicator>
24008 <indicator name="07"> Preformatted</indicator>
24009 <indicator name="08"><div>Broken tag</indicator>
24010 <indicator name="09">{| class=wikitable
24011 | cell
24012 |}</indicator>
24013 <indicator name="10">Two
24014
24015 paragraphs</indicator>
24016 !! html/php
24017 01=hello world
24018 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
24019 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" />
24020 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>
24021 05=<ul><li> foo</li>
24022 <li> bar</li></ul>
24023
24024 06=foo
24025 07=<pre>Preformatted
24026 </pre>
24027 08=<div>Broken tag</div>
24028
24029 09=<table class="wikitable">
24030 <tr>
24031 <td> cell
24032 </td></tr></table>
24033
24034 10=<p>Two
24035 </p><p>paragraphs
24036 </p>
24037 <p><br />
24038 </p><p><br />
24039 </p><p><br />
24040 </p><p><br />
24041 </p><p><br />
24042 </p>
24043 !! end
24044
24045 !! test
24046 preload: check <noinclude> and <includeonly>
24047 !! options
24048 preload
24049 !! wikitext
24050 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
24051 !! html/php
24052 Hello kind world.
24053 !! end
24054
24055 !! test
24056 preload: check <onlyinclude>
24057 !! options
24058 preload
24059 !! wikitext
24060 Goodbye <onlyinclude>Hello world</onlyinclude>
24061 !! html/php
24062 Hello world
24063 !! end
24064
24065 !! test
24066 preload: can pass tags through if we want to
24067 !! options
24068 preload
24069 !! wikitext
24070 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
24071 !! html/php
24072 <includeonly>Hello world</includeonly>
24073 !! end
24074
24075 !! test
24076 preload: check that it doesn't try to do tricks
24077 !! options
24078 preload
24079 !! wikitext
24080 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24081 !! html/php
24082 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24083 !! end
24084
24085 !! test
24086 Play a bit with r67090 and T5158
24087 !! wikitext
24088 <div style="width:50% !important">&nbsp;</div>
24089 <div style="width:50%&nbsp;!important">&nbsp;</div>
24090 <div style="width:50%&#160;!important">&nbsp;</div>
24091 <div style="border : solid;">&nbsp;</div>
24092 !! html/php
24093 <div style="width:50% !important">&#160;</div>
24094 <div style="width:50% !important">&#160;</div>
24095 <div style="width:50% !important">&#160;</div>
24096 <div style="border&#160;: solid;">&#160;</div>
24097
24098 !! html/parsoid
24099 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24100 <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>
24101 <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>
24102 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24103
24104 !! end
24105
24106 !! test
24107 HTML5 data attributes
24108 !! wikitext
24109 <span data-foo="bar">Baz</span>
24110 <p data-abc-def_hij="">Quuz</p>
24111 !! html/php
24112 <p><span data-foo="bar">Baz</span>
24113 </p>
24114 <p data-abc-def_hij="">Quuz</p>
24115
24116 !! html/parsoid
24117 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
24118 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
24119 !! end
24120
24121 !! test
24122 Strip reserved data attributes
24123 !! wikitext
24124 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
24125 !! html/php
24126 <div data-ok="fred">d</div>
24127
24128 !! html/parsoid
24129 <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>
24130 !! end
24131
24132 !! test
24133 percent-encoding and + signs in internal links (T28410)
24134 !! wikitext
24135 [[User:+%]] [[Page+title%]]
24136 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
24137 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
24138 [[%33%45]] [[%33%45+]]
24139 !! html/php
24140 <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>
24141 <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>
24142 <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>
24143 <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>
24144 </p>
24145 !! html/parsoid
24146 <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>
24147 <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>
24148 <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>
24149 <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>
24150 !! end
24151
24152 !! test
24153 Special characters in embedded file links (T29679)
24154 !! wikitext
24155 [[File:Contains & ampersand.jpg]]
24156 [[File:Does not exist.jpg|Title with & ampersand]]
24157 !! html/php
24158 <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>
24159 <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>
24160 </p>
24161 !! html/parsoid
24162 <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>
24163 <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>
24164 !! end
24165
24166 !! test
24167 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
24168 !! wikitext
24169 Text&apos;s been normalized?
24170 !! html
24171 <p>Text&#39;s been normalized?
24172 </p>
24173 !! end
24174
24175 !! test
24176 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
24177 !! wikitext
24178 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
24179 !! html
24180 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
24181 </p>
24182 !! end
24183
24184 !! test
24185 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
24186 !! wikitext
24187 [http://www.example.org/ ideograms]
24188 !! html
24189 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
24190 </p>
24191 !! end
24192
24193 !! test
24194 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
24195 !! wikitext
24196 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
24197 !! html
24198 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
24199 </p>
24200 !! end
24201
24202 !! article
24203 Mediawiki:loop1
24204 !! text
24205 {{Identical|A}}
24206 !! endarticle
24207
24208 !! article
24209 Mediawiki:loop2
24210 !! text
24211 {{Identical|B}}
24212 !! endarticle
24213
24214 !! article
24215 Template:Identical
24216 !! text
24217 {{int:loop1}}
24218 {{int:loop2}}
24219 !! endarticle
24220
24221 !! test
24222 T33098 Template which includes system messages which includes the template
24223 !! wikitext
24224 {{Identical}}
24225 !! html
24226 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24227 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24228 </p>
24229 !! end
24230
24231 !! test
24232 T33490 Turkish: ucfirst 'blah'
24233 !! options
24234 language=tr
24235 !! wikitext
24236 {{ucfirst:blah}}
24237 !! html
24238 <p>Blah
24239 </p>
24240 !! end
24241
24242 !! test
24243 T33490 Turkish: ucfirst 'ix'
24244 !! options
24245 language=tr
24246 !! wikitext
24247 {{ucfirst:ix}}
24248 !! html
24249 <p>İx
24250 </p>
24251 !! end
24252
24253 !! test
24254 T33490 Turkish: lcfirst 'BLAH'
24255 !! options
24256 language=tr
24257 !! wikitext
24258 {{lcfirst:BLAH}}
24259 !! html
24260 <p>bLAH
24261 </p>
24262 !! end
24263
24264 !! test
24265 T33490 Turkish: ucfırst (with a dotless i)
24266 !! options
24267 language=tr
24268 !! wikitext
24269 {{ucfırst:blah}}
24270 !! html
24271 <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>
24272 </p>
24273 !! end
24274
24275 !! test
24276 T33490 ucfırst (with a dotless i) with English language
24277 !! options
24278 language=en
24279 !! wikitext
24280 {{ucfırst:blah}}
24281 !! html
24282 <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>
24283 </p>
24284 !! end
24285
24286 # Note that Parsoid doesn't emit an explicit TOC.
24287 # Note also that the html2wt direction tends to emit an extra newline
24288 # between the __TOC__ magicword and the first heading unless *both*
24289 # the <meta> and the <h2> have a data-parsoid attribute set (even if
24290 # it's "{}").
24291
24292 !! test
24293 T28375: TOC with italics
24294 !! options
24295 title=[[Main Page]]
24296 !! wikitext
24297 __TOC__
24298 == ''Lost'' episodes ==
24299 !! html/php
24300 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24301 <ul>
24302 <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>
24303 </ul>
24304 </div>
24305
24306 <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>
24307
24308 !! html/parsoid
24309 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24310 <h2 id="Lost_episodes" data-parsoid='{}'> <i>Lost</i> episodes </h2>
24311 !! end
24312
24313 !! test
24314 T28375: TOC with bold
24315 !! options
24316 title=[[Main Page]]
24317 !! wikitext
24318 __TOC__
24319 == '''should be bold''' then normal text ==
24320 !! html/php
24321 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24322 <ul>
24323 <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>
24324 </ul>
24325 </div>
24326
24327 <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>
24328
24329 !! html/parsoid
24330 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24331 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'> <b>should be bold</b> then normal text </h2>
24332 !! end
24333
24334 !! test
24335 T35845: Headings become cursive in TOC when they contain an image
24336 !! options
24337 title=[[Main Page]]
24338 !! wikitext
24339 __TOC__
24340 == Image [[Image:foobar.jpg]] ==
24341 !! html/php
24342 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24343 <ul>
24344 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
24345 </ul>
24346 </div>
24347
24348 <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>
24349
24350 !! html/parsoid
24351 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24352 <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>
24353 !! end
24354
24355 !! test
24356 T35845 (2): Headings become bold in TOC when they contain a blockquote
24357 !! options
24358 title=[[Main Page]]
24359 !! wikitext
24360 __TOC__
24361 == <blockquote>Quote</blockquote> ==
24362 !! html/php
24363 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24364 <ul>
24365 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24366 </ul>
24367 </div>
24368
24369 <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>
24370
24371 !! html/php+tidy
24372 <p></p>
24373 <div id="toc" class="toc">
24374 <div class="toctitle" lang="en" dir="ltr" xml:lang="en">
24375 <h2>Contents</h2>
24376 </div>
24377 <ul>
24378 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24379 </ul>
24380 </div>
24381 <p></p>
24382 <h2><span class="mw-headline" id="Quote"></span></h2>
24383 <blockquote>
24384 <p><span class="mw-headline" id="Quote">Quote</span></p>
24385 </blockquote>
24386 <p><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></p>
24387 !! html/parsoid
24388 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24389 <h2 id="Quote" data-parsoid='{}'> <blockquote>Quote</blockquote> </h2>
24390 !! end
24391
24392 !! test
24393 Unclosed tags in TOC
24394 !! config
24395 wgFragmentMode=[ 'html5', 'legacy' ]
24396 !! options
24397 title=[[Main Page]]
24398 !! wikitext
24399 __TOC__
24400 == Proof: 2 < 3 ==
24401 <small>Hanc marginis exiguitas non caperet.</small>
24402 QED
24403 !! html/php
24404 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24405 <ul>
24406 <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>
24407 </ul>
24408 </div>
24409
24410 <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>
24411 <p><small>Hanc marginis exiguitas non caperet.</small>
24412 QED
24413 </p>
24414 !! html/parsoid
24415 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24416 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span> Proof: 2 &lt; 3 </h2>
24417 <p><small>Hanc marginis exiguitas non caperet.</small>
24418 QED</p>
24419 !! end
24420
24421 !! test
24422 Multiple tags in TOC
24423 !! wikitext
24424 __TOC__
24425 == <i>Foo</i> <b>Bar</b> ==
24426
24427 == <i>Foo</i> <blockquote>Bar</blockquote> ==
24428 !! html/php
24429 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24430 <ul>
24431 <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>
24432 <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>
24433 </ul>
24434 </div>
24435
24436 <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>
24437 <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>
24438
24439 !! html/php+tidy
24440 <p></p>
24441 <div id="toc" class="toc">
24442 <div class="toctitle" lang="en" dir="ltr" xml:lang="en">
24443 <h2>Contents</h2>
24444 </div>
24445 <ul>
24446 <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>
24447 <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>
24448 </ul>
24449 </div>
24450 <p></p>
24451 <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>
24452 <h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i></span></h2>
24453 <blockquote>
24454 <p><span class="mw-headline" id="Foo_Bar_2">Bar</span></p>
24455 </blockquote>
24456 <p><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></p>
24457 !! html/parsoid
24458 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24459 <h2 id="Foo_Bar" data-parsoid='{}'> <i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b> </h2>
24460
24461 <h2 id="Foo_Bar_2" data-parsoid='{}'> <i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote> </h2>
24462 !! end
24463
24464 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
24465 # html5 tag parsing.
24466 !! test
24467 Tags with parameters in TOC
24468 !! options
24469 parsoid=wt2html
24470 !! wikitext
24471 __TOC__
24472 == <sup class="in-h2">Hello</sup> ==
24473
24474 == <sup class="a > b">Evilbye</sup> ==
24475 !! html/php
24476 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24477 <ul>
24478 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
24479 <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>
24480 </ul>
24481 </div>
24482
24483 <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>
24484 <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>
24485
24486 !! html/parsoid
24487 <meta property="mw:PageProp/toc" />
24488 <h2 id="Hello"> <sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup> </h2>
24489
24490 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span> <sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup> </h2>
24491 !! end
24492
24493 !! test
24494 span tags with directionality in TOC
24495 !! wikitext
24496 __TOC__
24497 == <span dir="ltr">C++</span> ==
24498
24499 == <span dir="rtl">זבנג!</span> ==
24500
24501 == <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> ==
24502
24503 == <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> ==
24504
24505 == <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> ==
24506 !! html/php
24507 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24508 <ul>
24509 <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>
24510 <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>
24511 <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>
24512 <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>
24513 <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>
24514 </ul>
24515 </div>
24516
24517 <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>
24518 <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>
24519 <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>
24520 <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>
24521 <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>
24522
24523 !! html/parsoid
24524 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24525 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span> <span dir="ltr">C++</span> </h2>
24526 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span> <span dir="rtl">זבנג!</span> </h2>
24527 <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>
24528 <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>
24529 <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>
24530 !! end
24531
24532 !! test
24533 T74884: bdi element in ToC
24534 !! wikitext
24535 __TOC__
24536 == <bdi>test</bdi> ==
24537 !! html/php
24538 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24539 <ul>
24540 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
24541 </ul>
24542 </div>
24543
24544 <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>
24545
24546 !! html/parsoid
24547 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24548 <h2 id="test" data-parsoid='{}'> <bdi>test</bdi> </h2>
24549 !! end
24550
24551 !! test
24552 T35715: s/strike element in ToC
24553 !! wikitext
24554 __TOC__
24555 == <s>test</s> test <strike>test</strike> ==
24556 !! html/php
24557 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24558 <ul>
24559 <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>
24560 </ul>
24561 </div>
24562
24563 <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>
24564
24565 !! html/parsoid
24566 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24567 <h2 id="test_test_test" data-parsoid='{}'> <s>test</s> test <strike>test</strike> </h2>
24568 !! end
24569
24570 # Note that the html output does not have the <p></p>, but the
24571 # html+tidy output *does*. This is because the empty <p></p> is
24572 # removed by the sanitizer, but only when tidy is *not* enabled (!).
24573 !! test
24574 Empty <p> tag in TOC, removed by Sanitizer (T92892)
24575 !! wikitext
24576 __TOC__
24577 == x ==
24578 !! html/php
24579 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24580 <ul>
24581 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
24582 </ul>
24583 </div>
24584
24585 <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>
24586
24587 !! html/php+tidy
24588 <p></p>
24589 <div id="toc" class="toc">
24590 <div class="toctitle" lang="en" dir="ltr" xml:lang="en">
24591 <h2>Contents</h2>
24592 </div>
24593 <ul>
24594 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
24595 </ul>
24596 </div>
24597 <p></p>
24598 <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>
24599 !! html/parsoid
24600 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24601 <h2 id="x" data-parsoid='{}'> x </h2>
24602 !! end
24603
24604 !! article
24605 MediaWiki:T34057
24606 !! text
24607 == {{int:headline_sample}} ==
24608 !! endarticle
24609
24610 !! test
24611 T34057: Title needed when expanding <h> nodes.
24612 !! options
24613 title=[[Main Page]]
24614 !! wikitext
24615 {{int:T34057}}
24616 !! html
24617 <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>
24618
24619 !! end
24620
24621 !! test
24622 Strip marker in urlencode
24623 !! wikitext
24624 {{urlencode:x<nowiki/>y}}
24625 {{urlencode:x<nowiki/>y|wiki}}
24626 {{urlencode:x<nowiki/>y|path}}
24627 {{urlencode:x<pre id="one">two</pre>y}}
24628 !! html/php
24629 <p>xy
24630 xy
24631 xy
24632 xy
24633 </p>
24634 !! end
24635
24636 !! test
24637 Strip marker in lc
24638 !! wikitext
24639 {{lc:x<nowiki/>y}}
24640 !! html
24641 <p>xy
24642 </p>
24643 !! end
24644
24645 !! test
24646 Strip marker in uc
24647 !! wikitext
24648 {{uc:x<nowiki/>y}}
24649 !! html
24650 <p>XY
24651 </p>
24652 !! end
24653
24654 !! test
24655 Strip marker in formatNum
24656 !! wikitext
24657 {{formatnum:1<nowiki/>2}}
24658 {{formatnum:1<nowiki/>2|R}}
24659 !! html
24660 <p>12
24661 12
24662 </p>
24663 !! end
24664
24665 !! test
24666 Check noCommafy in formatNum
24667 !! options
24668 language=be-tarask
24669 !! wikitext
24670 {{formatnum:123456.78}}
24671 {{formatnum:123456.78|NOSEP}}
24672 !! html
24673 <p>123 456,78
24674 123456.78
24675 </p>
24676 !! end
24677
24678 !! test
24679 Wrong option for formatNum (T58199)
24680 !! wikitext
24681 {{formatnum:1,234.56|Random}}
24682 {{formatnum:1,234.56|EVERYTHING}}
24683 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
24684 !! html
24685 <p>1,234.56
24686 1,234.56
24687 1,234.56
24688 </p>
24689 !! end
24690
24691 !! test
24692 Strip marker in grammar
24693 !! options
24694 language=fi
24695 !! wikitext
24696 {{grammar:elative|foo<nowiki/>bar}}
24697 !! html
24698 <p>foobarista
24699 </p>
24700 !! end
24701
24702 !! test
24703 Strip marker in padleft
24704 !! wikitext
24705 {{padleft:|2|x<nowiki/>y}}
24706 !! html
24707 <p>xy
24708 </p>
24709 !! end
24710
24711 !! test
24712 Strip marker in padright
24713 !! wikitext
24714 {{padright:|2|x<nowiki/>y}}
24715 !! html
24716 <p>xy
24717 </p>
24718 !! end
24719
24720 !! test
24721 Strip marker in anchorencode
24722 !! wikitext
24723 {{anchorencode:x<nowiki/>y}}
24724 !! html/php
24725 <p>xy
24726 </p>
24727 !! html/parsoid
24728 <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>
24729 !! end
24730
24731 !! test
24732 nowiki inside link inside heading (T20295)
24733 !! wikitext
24734 ==[[foo|x<nowiki>y</nowiki>z]]==
24735 !! html
24736 <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>
24737
24738 !! end
24739
24740 !! test
24741 new support for bdi element (T33817)
24742 !! wikitext
24743 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24744 !! html
24745 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24746
24747 !!end
24748
24749 !! test
24750 Ignore pipe between table row attributes
24751 !! wikitext
24752 {|
24753 | quux
24754 |- id=foo | style='color: red'
24755 | bar
24756 |}
24757 !! html
24758 <table>
24759 <tr>
24760 <td> quux
24761 </td></tr>
24762 <tr id="foo" style="color: red">
24763 <td> bar
24764 </td></tr></table>
24765
24766 !! end
24767
24768 !!test
24769 Language parser function
24770 !! wikitext
24771 {{#language:ar}}
24772 !! html
24773 <p>العربية
24774 </p>
24775 !! end
24776
24777 !!test
24778 Padleft and padright as substr
24779 !! wikitext
24780 {{padleft:|3|abcde}}
24781 {{padright:|3|abcde}}
24782 !! html
24783 <p>abc
24784 abc
24785 </p>
24786 !! end
24787
24788 !!test
24789 Special parser function
24790 !! wikitext
24791 {{#special:RandomPage}}
24792 {{#special:BaDtItLe}}
24793 {{#special:Foobar}}
24794 !! html
24795 <p>Special:Random
24796 Special:Badtitle
24797 Special:Foobar
24798 </p>
24799 !! end
24800
24801 !!test
24802 T36939 - Case insensitive link parsing ([HttP://])
24803 !! wikitext
24804 [HttP://MediaWiki.Org/]
24805 !! html/php
24806 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
24807 </p>
24808 !! html/parsoid
24809 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/"></a></p>
24810 !! end
24811
24812 !!test
24813 T36939 - Case insensitive link parsing ([HttP:// title])
24814 !! wikitext
24815 [HttP://MediaWiki.Org/ MediaWiki]
24816 !! html
24817 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
24818 </p>
24819 !! end
24820
24821 !!test
24822 T36939 - Case insensitive link parsing (HttP://)
24823 !! wikitext
24824 HttP://MediaWiki.Org/
24825 !! html/php
24826 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
24827 </p>
24828 !! html/parsoid
24829 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
24830 !! end
24831
24832 !!test
24833 Disable TOC
24834 !! options
24835 notoc
24836 !! wikitext
24837 Lead
24838 == Section 1 ==
24839 == Section 2 ==
24840 == Section 3 ==
24841 == Section 4 ==
24842 == Section 5 ==
24843 !! html
24844 <p>Lead
24845 </p>
24846
24847 <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>
24848 <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>
24849 <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>
24850 <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>
24851 <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>
24852
24853 !! end
24854
24855
24856 ###
24857 ### Parsoid-specific tests
24858 ### Parsoid-PHP parser incompatibilities
24859 ###
24860 !!test
24861 1. SOL-sensitive wikitext tokens as template-args
24862 !!options
24863 parsoid=wt2html,wt2wt
24864 !! wikitext
24865 {{echo|*a}}
24866 {{echo|#a}}
24867 {{echo|:a}}
24868 !! html
24869 <span about="#mwt1" typeof="mw:Transclusion">
24870 </span><ul about="#mwt1"><li>a</li>
24871 </ul>
24872 <span about="#mwt2" typeof="mw:Transclusion">
24873 </span><ol about="#mwt2"><li>a</li>
24874 </ol>
24875 <span about="#mwt3" typeof="mw:Transclusion">
24876 </span><dl about="#mwt3"><dd>a</dd>
24877 </dl>
24878 !!end
24879
24880 #### -----------------------------------------------------------------
24881 #### Parsoid-specific functionality tests
24882 #### -----------------------------------------------------------------
24883
24884 # T65642/T68749: Formatting elt fixup around images is cleaned up.
24885 # We know wt2wt will fail, but we expect selser to pass.
24886 # Due to the nature of our testing, wt2wt and selser tests will enter the
24887 # blacklist and we'll catch selser regressions based on changes to the
24888 # blacklist entries for selser tests.
24889 !! test
24890 1. Bad treebuilder fixup of formatting elt is cleaned up
24891 !! options
24892 parsoid=wt2html,wt2wt
24893 !! wikitext
24894 {|
24895 |
24896 <small>
24897 [[Image:Foobar.jpg|right|Test]]
24898 </small>
24899 |}
24900 !! html/parsoid
24901 <table>
24902 <tbody><tr><td>
24903 <small>
24904 <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>
24905 </small>
24906 </td></tr>
24907 </tbody></table>
24908 !! end
24909
24910 !! test
24911 2. Bad treebuilder fixup of formatting elt is cleaned up
24912 !! options
24913 parsoid=wt2html,wt2wt
24914 !! wikitext
24915 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
24916
24917 <small>[[Image:Foobar.jpg|right|300px]]</small>
24918 !! html/parsoid
24919
24920 <p><b>foo</b></p>
24921 <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>
24922 <p><b>bar</b></p>
24923 <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>
24924 !! end
24925
24926 !! test
24927 3. Bad treebuilder fixup of formatting elt is cleaned up
24928 !! options
24929 parsoid=wt2html,wt2wt
24930 !! wikitext
24931 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
24932 !! html/parsoid
24933 <p><small><b>foo</b></small></p>
24934 <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>
24935 <p><small><b>bar</b></small></p>
24936 !! end
24937
24938 !! test
24939 4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
24940 !! options
24941 parsoid=wt2html,wt2wt
24942 !! wikitext
24943 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
24944 !! html/parsoid
24945 <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>
24946 !! end
24947
24948 #### ----------------------------------------------------------------
24949 #### Parsoid-only testing of Parsoid's impl of LST
24950 #### Not implemented yet, see
24951 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
24952 #### ----------------------------------------------------------------
24953
24954 ## We still need to support serializing the older format while content is stored.
24955 !! test
24956 LST Sections: Backwards compatibility
24957 !! options
24958 parsoid={
24959 "suppressErrors": true,
24960 "modes": ["html2wt"]
24961 }
24962 !! wikitext
24963 <section begin="2011-05-16" />
24964 <section end="2014-04-10 (MW 1.23wmf22)" />
24965 !! html/parsoid
24966 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
24967 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
24968 !! end
24969
24970 !! test
24971 LST Sections: Newfangled approach
24972 !! wikitext
24973 <section begin="2011-05-16" />
24974 <section end="2014-04-10 (MW 1.23wmf22)" />
24975 !! html/parsoid
24976 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'>
24977 </span>
24978 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null}'>
24979 </span></p>
24980 !! end
24981
24982 #--------- Test stripping of empty nodes in template content ----------
24983
24984 !! test
24985 Empty LI and TR nodes should be stripped from template content
24986 !! wikitext
24987 {{EmptyLITest}}
24988 {{EmptyTRTest}}
24989 !! html/parsoid
24990 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
24991 <li>a</li>
24992 <li>b</li>
24993 </ul>
24994 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
24995 <tbody>
24996 <tr>
24997 <td>foo</td>
24998 </tr>
24999 <tr>
25000 <td>bar</td>
25001 </tr>
25002 </tbody>
25003 </table>
25004 !! end
25005
25006 !! test
25007 Empty LI and TR nodes should not be stripped from top-level content
25008 !! wikitext
25009 * a
25010 *
25011 * b
25012 {|
25013 |-
25014 |-
25015 |foo
25016 |}
25017 !! html/parsoid
25018 <ul>
25019 <li> a</li>
25020 <li class='mw-empty-elt'></li>
25021 <li> b</li>
25022 </ul>
25023 <table>
25024 <tbody>
25025 <tr class='mw-empty-elt'></tr>
25026 <tr>
25027 <td>foo</td>
25028 </tr>
25029 </tbody>
25030 </table>
25031 !! end
25032
25033 !! test
25034 Empty TR nodes should not be stripped if they have any attributes set
25035 !! wikitext
25036 {{EmptyTRWithHTMLAttrTest}}
25037 !! html/parsoid
25038 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
25039 <tr align='center'></tr>
25040 <tr><td>foo</td></tr>
25041 <tr align='center'></tr>
25042 <tr><td>bar</td></tr>
25043 </table>
25044 !! end
25045
25046 #### ----------------------------------------------------------------
25047 #### The following section of tests are primarily to test
25048 #### wikitext escaping capabilities of Parsoid. Given that
25049 #### escaping can be done any number of ways, the wikitext (input)
25050 #### is always adjusted to reflect how Parsoid adds nowiki
25051 #### escape tags.
25052 ####
25053 #### We are marking several tests as parsoid-only since the
25054 #### HTML in the result section is different from what the
25055 #### PHP parser generates for it.
25056 #### ----------------------------------------------------------------
25057
25058
25059 #### --------------- Headings ---------------
25060 #### 0. Unnested
25061 #### 1. Nested inside html <h1>=foo=</h1>
25062 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
25063 #### 3. Nested inside html with wikitext split by html tags
25064 #### 4. No escape needed
25065 #### 5. Empty headings <h1></h1>
25066 #### 6. Heading chars in SOL context
25067 #### ----------------------------------------
25068 !! test
25069 Headings: 0. Unnested
25070 !! options
25071 parsoid=html2wt
25072 !! html/parsoid
25073 <p>=foo=</p>
25074
25075 <p> =foo=
25076 <!--cmt-->
25077 =foo=</p>
25078
25079 <p>=foo<i>a</i>=</p>
25080 !! wikitext
25081 <nowiki>=foo=</nowiki>
25082
25083 <nowiki> </nowiki>=foo=
25084 <!--cmt-->
25085 <nowiki>=foo=</nowiki>
25086
25087 =foo''a''<nowiki>=</nowiki>
25088 !!end
25089
25090 # New headings and existing headings are handled differently
25091 !! test
25092 Headings: 1. Nested inside html
25093 !! options
25094 parsoid=html2wt
25095 !! html/parsoid
25096 <h1>=foo=</h1>
25097 <h2>=foo=</h2>
25098 <h3>=foo=</h3>
25099
25100 <h1 data-parsoid=''>=foo=</h1>
25101 <h2 data-parsoid=''>=foo=</h2>
25102 <h3 data-parsoid=''>=foo=</h3>
25103 <h4 data-parsoid=''>=foo=</h4>
25104 <h5 data-parsoid=''>=foo=</h5>
25105 <h6 data-parsoid=''>=foo=</h6>
25106 !! wikitext
25107 = =foo= =
25108
25109 == =foo= ==
25110
25111 === =foo= ===
25112
25113 =<nowiki>=foo=</nowiki>=
25114 ==<nowiki>=foo=</nowiki>==
25115 ===<nowiki>=foo=</nowiki>===
25116 ====<nowiki>=foo=</nowiki>====
25117 =====<nowiki>=foo=</nowiki>=====
25118 ======<nowiki>=foo=</nowiki>======
25119
25120 !!end
25121
25122 !! test
25123 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
25124 !! options
25125 parsoid=html2wt
25126 !! html/parsoid
25127 <h1>foo</h1>*bar
25128 <h1>foo</h1>=bar
25129 <h1>foo</h1>=bar=
25130 !! wikitext
25131 = foo =
25132 <nowiki>*</nowiki>bar
25133
25134 = foo =
25135 =bar
25136
25137 = foo =
25138 <nowiki>=bar=</nowiki>
25139 !!end
25140
25141 !! test
25142 Headings: 3. Nested inside html with wikitext split by html tags
25143 !! options
25144 parsoid=html2wt
25145 !! html/parsoid
25146 <h1>=<b>bold</b>foo=</h1>
25147 !! wikitext
25148 = ='''bold'''foo= =
25149 !!end
25150
25151 !! test
25152 Headings: 4a. No escaping needed (testing just h1 and h2)
25153 !! options
25154 parsoid=html2wt
25155 !! html/parsoid
25156 <h1>=foo</h1>
25157 <h1>foo=</h1>
25158 <h1> =foo= </h1>
25159 <h1>=foo= bar</h1>
25160 <h2>=foo</h2>
25161 <h2>foo=</h2>
25162 <h1>=</h1>
25163 <h1><i>=</i>foo=</h1>
25164 !! wikitext
25165 = =foo =
25166
25167 = foo= =
25168
25169 = =foo= =
25170
25171 = =foo= bar =
25172
25173 == =foo ==
25174
25175 == foo= ==
25176
25177 = = =
25178
25179 = ''=''foo= =
25180 !!end
25181
25182 !! test
25183 Headings: 4b. No escaping needed (inside p-tags)
25184 !! options
25185 parsoid=html2wt
25186 !! html/parsoid
25187 <p>=foo= x
25188 =foo= <s></s>
25189 </p>
25190 !! wikitext
25191 =foo= x
25192 =foo= <s></s>
25193 !! html/php
25194 <p>=foo= x
25195 =foo= <s></s>
25196 </p>
25197 !!end
25198
25199 !! test
25200 Headings: 4c. Short headings (1)
25201 !! options
25202 parsoid=html2wt
25203 !! html/parsoid
25204 <p>===
25205 </p>
25206 !! wikitext
25207 <nowiki>===</nowiki>
25208 !! html/php
25209 <p>===
25210 </p>
25211 !! end
25212
25213 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
25214 !! test
25215 Headings: 4d. Short headings (2)
25216 !! options
25217 parsoid=wt2html,html2html
25218 !! wikitext
25219 =
25220 ==
25221 ===
25222 ====
25223 =====
25224 !! html/php
25225 <p>=
25226 ==
25227 </p>
25228 <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>
25229 <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>
25230 <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>
25231
25232 !! html/parsoid
25233 <p>=
25234 ==</p>
25235 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
25236 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
25237 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
25238 !! end
25239
25240 !! test
25241 Headings: 5. Empty headings
25242 !! options
25243 parsoid=html2wt
25244 !! html/parsoid
25245 <h1 data-parsoid='{}'></h1>
25246
25247 <h2 data-parsoid='{}'></h2>
25248
25249 <h3 data-parsoid='{}'></h3>
25250
25251 <h4 data-parsoid='{}'></h4>
25252
25253 <h5 data-parsoid='{}'></h5>
25254
25255 <h6 data-parsoid='{}'></h6>
25256 !! wikitext
25257 =<nowiki/>=
25258
25259 ==<nowiki/>==
25260
25261 ===<nowiki/>===
25262
25263 ====<nowiki/>====
25264
25265 =====<nowiki/>=====
25266
25267 ======<nowiki/>======
25268 !!end
25269
25270 !! test
25271 Headings: 6a. Heading chars in SOL context (with trailing spaces)
25272 !! options
25273 parsoid=html2wt
25274 !! html/parsoid
25275 <p>=a=</p>
25276
25277 <p>=a=</p>
25278
25279 <p>=a=</p>
25280 !! wikitext
25281 <nowiki>=a=</nowiki>
25282
25283 <nowiki>=a=</nowiki>
25284
25285 <nowiki>=a=</nowiki>
25286 !!end
25287
25288 !! test
25289 Headings: 6b. Heading chars in SOL context (with trailing newlines)
25290 !! options
25291 parsoid=html2wt
25292 !! html/parsoid
25293 <p>=a=
25294 b</p>
25295
25296 <p>=a=
25297 b</p>
25298
25299 <p>=a=
25300 b</p>
25301 !! wikitext
25302 <nowiki>=a=</nowiki>
25303 b
25304
25305 <nowiki>=a=</nowiki>
25306 b
25307
25308 <nowiki>=a=</nowiki>
25309 b
25310 !!end
25311
25312 !! test
25313 Headings: 6c. Heading chars in SOL context (leading newline break)
25314 !! options
25315 parsoid=html2wt
25316 !! html/parsoid
25317 <p>a
25318 =b=</p>
25319 !! wikitext
25320 a
25321 <nowiki>=b=</nowiki>
25322 !!end
25323
25324 !! test
25325 Headings: 6d. Heading chars in SOL context (with interspersed comments)
25326 !! options
25327 parsoid=html2wt
25328 !! html/parsoid
25329 <!--c0--><p>=a=</p>
25330
25331 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
25332 !! wikitext
25333 <!--c0--><nowiki>=a=</nowiki>
25334
25335 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
25336 !!end
25337
25338 !! test
25339 Headings: 6d. Heading chars in SOL context (No escaping needed)
25340 !! options
25341 parsoid=html2wt
25342 !! html/parsoid
25343 =a=<div>b</div>
25344 !! wikitext
25345 =a=<div>b</div>
25346 !!end
25347
25348 !! test
25349 Headings: 7. Insert a newline between new content and headings
25350 !! options
25351 parsoid=html2wt
25352 !! html/parsoid
25353 <h2>NEW</h2>
25354 <p>new</p>
25355 <h2 data-parsoid='{}'>A</h2>
25356 <p data-parsoid='{}'>a</p>
25357 !! wikitext
25358 == NEW ==
25359 new
25360
25361 ==A==
25362 a
25363
25364 !! end
25365
25366 #### --------------- Lists ---------------
25367 #### 0. Outside nests (*foo, etc.)
25368 #### 1. Nested inside html <ul><li>*foo</li></ul>
25369 #### 2. Inside definition lists
25370 #### 3. Only bullets at start should be escaped
25371 #### 4. No escapes needed
25372 #### 5. No unnecessary escapes
25373 #### 6. Escape bullets in SOL position
25374 #### 7. Escape bullets in a multi-line context
25375 #### ----------------------------------------
25376
25377 !! test
25378 Lists: 0. Outside nests
25379 !! options
25380 parsoid=html2wt
25381 !! html/parsoid
25382 <p>*foo</p>
25383
25384 <p>#foo</p>
25385
25386 <p>;Foo:bar</p>
25387 !! wikitext
25388 <nowiki>*</nowiki>foo
25389
25390 <nowiki>#</nowiki>foo
25391
25392 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
25393 !!end
25394
25395 ## Making these next 3 tests Parsoid-only since they are html2wt tests
25396 ## to test wikitext escaping, and insignificant whitespace diffs
25397 ## cause PHP parser tests to barf
25398 !! test
25399 Lists: 1. Nested inside html (No unnecessary escapes)
25400 !! options
25401 parsoid=html2wt
25402 !! html/parsoid
25403 <ul>
25404 <li>*foo</li>
25405 <li>#foo</li>
25406 <li>:foo</li>
25407 <li>;foo</li>
25408 <li data-parsoid='{}'>*foo</li>
25409 <li data-parsoid='{}'>#foo</li>
25410 <li data-parsoid='{}'>:foo</li>
25411 <li data-parsoid='{}'>;foo</li>
25412 </ul>
25413
25414 <ol>
25415 <li>*foo</li>
25416 <li>#foo</li>
25417 <li>:foo</li>
25418 <li>;foo</li>
25419 <li data-parsoid='{}'>*foo</li>
25420 <li data-parsoid='{}'>#foo</li>
25421 <li data-parsoid='{}'>:foo</li>
25422 <li data-parsoid='{}'>;foo</li>
25423 </ol>
25424 !! wikitext
25425 * *foo
25426 * #foo
25427 * :foo
25428 * ;foo
25429 *<nowiki>*foo</nowiki>
25430 *<nowiki>#foo</nowiki>
25431 *<nowiki>:foo</nowiki>
25432 *<nowiki>;foo</nowiki>
25433
25434 # *foo
25435 # #foo
25436 # :foo
25437 # ;foo
25438 #<nowiki>*foo</nowiki>
25439 #<nowiki>#foo</nowiki>
25440 #<nowiki>:foo</nowiki>
25441 #<nowiki>;foo</nowiki>
25442 !!end
25443
25444 !! test
25445 Lists: 2. Inside definition lists
25446 !! options
25447 parsoid=html2wt
25448 !! html/parsoid
25449 <dl><dt>;foo</dt></dl>
25450 <dl><dt>:foo</dt></dl>
25451 <dl><dt>:foo</dt>
25452 <dd>bar</dd></dl>
25453 <dl><dd>:foo</dd></dl>
25454 !! wikitext
25455 ; ;foo
25456
25457 ; <nowiki>:foo</nowiki>
25458
25459 ; <nowiki>:foo</nowiki>
25460 : bar
25461
25462 : :foo
25463 !!end
25464
25465 !! test
25466 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
25467 !! options
25468 parsoid=html2wt
25469 !! html/parsoid
25470 <ul>
25471 <li>*foo*bar</li>
25472 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
25473 </ul>
25474 !! wikitext
25475 * *foo*bar
25476 *<nowiki>*foo</nowiki>''it''*bar
25477 !!end
25478
25479 !! test
25480 Lists: 4. No escapes needed
25481 !! options
25482 parsoid=html2wt
25483 !! html/parsoid
25484 <ul>
25485 <li>foo*bar
25486 </li>
25487 </ul>
25488 <ul>
25489 <li><i>foo</i>*bar
25490 </li>
25491 </ul>
25492 <ul>
25493 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
25494 </li>
25495 </ul>
25496 <ul>
25497 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
25498 </li>
25499 </ul>
25500 !! wikitext
25501 *foo*bar
25502
25503 *''foo''*bar
25504
25505 *[[Foo]]: bar
25506
25507 *[[Foo]]*bar
25508 !!end
25509
25510 !! test
25511 Lists: 5. No unnecessary escapes
25512 !! options
25513 parsoid=html2wt
25514 !! html/parsoid
25515 <ul><li> bar <span>[[foo]]</span></li></ul>
25516 <ul><li> =bar <span>[[foo]]</span></li></ul>
25517 <ul><li> [[bar <span>[[foo]]</span></li></ul>
25518 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
25519 <ul><li> =bar <span>foo]]</span>=</li></ul>
25520 <ul><li> <s></s>: a</li></ul>
25521 <ul><li> <i>* foo</i></li></ul>
25522
25523 !! wikitext
25524 * bar <span><nowiki>[[foo]]</nowiki></span>
25525
25526 * =bar <span><nowiki>[[foo]]</nowiki></span>
25527
25528 * [[bar <span><nowiki>[[foo]]</nowiki></span>
25529
25530 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
25531
25532 * =bar <span>foo]]</span>=
25533
25534 * <s></s>: a
25535
25536 * ''* foo''
25537 !!end
25538
25539 !! test
25540 Lists: 6. Escape bullets in SOL position
25541 !! options
25542 parsoid=html2wt
25543 !! html/parsoid
25544 <p><!--cmt-->*foo</p>
25545 !! wikitext
25546 <!--cmt--><nowiki>*</nowiki>foo
25547 !!end
25548
25549 !! test
25550 Lists: 7. Escape bullets in a multi-line context
25551 !! options
25552 parsoid=html2wt
25553 !! html/parsoid
25554 <p>a
25555 *b
25556 </p>
25557 !! wikitext
25558 a
25559 <nowiki>*</nowiki>b
25560 !!end
25561
25562 !! test
25563 Lists: 8. Escape colons only if not present in tags
25564 !! options
25565 parsoid=html2wt
25566 !! html/parsoid
25567 <dl><dt>a:b<i>c:d</i></dt></dl>
25568 !! wikitext
25569 ; <nowiki>a:b</nowiki>''c:d''
25570 !! end
25571
25572 #### --------------- HRs ---------------
25573 #### 1. Single line
25574 #### -----------------------------------
25575
25576 !! test
25577 HRs: 1. Single line
25578 !! options
25579 parsoid=html2wt
25580 !! html/parsoid
25581 <hr />----
25582 <hr />=foo=
25583 <hr />*foo
25584 !! wikitext
25585 ----<nowiki>----</nowiki>
25586 ----=foo=
25587 ----*foo
25588 !! end
25589
25590 #### --------------- Tables ---------------
25591 #### 1a. Simple example
25592 #### 1b. No escaping needed (!foo)
25593 #### 1c. No escaping needed (|foo)
25594 #### 1d. No escaping needed (|}foo)
25595 ####
25596 #### 2a. Nested in td (<td>foo|bar</td>)
25597 #### 2b. Nested in td (<td>foo||bar</td>)
25598 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
25599 ####
25600 #### 3a. Nested in th (<th>foo!bar</th>)
25601 #### 3b. Nested in th (<th>foo!!bar</th>)
25602 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
25603 ####
25604 #### 4a. Escape -
25605 #### 4b. Escape +
25606 #### 4c. No escaping needed
25607 #### --------------------------------------
25608
25609 !! test
25610 Tables: 1a. Simple example
25611 !! options
25612 parsoid=html2wt
25613 !! html/parsoid
25614 <p>{|
25615 |}
25616 </p>
25617 !! wikitext
25618 <nowiki>{|</nowiki>
25619 |}
25620 !! end
25621
25622 !! test
25623 Tables: 1b. No escaping needed
25624 !! options
25625 parsoid=html2wt
25626 !! html/parsoid
25627 <p>!foo
25628 </p>
25629 !! wikitext
25630 !foo
25631 !! end
25632
25633 !! test
25634 Tables: 1c. No escaping needed
25635 !! options
25636 parsoid=html2wt
25637 !! html/parsoid
25638 <p>|foo
25639 </p>
25640 !! wikitext
25641 |foo
25642 !! end
25643
25644 !! test
25645 Tables: 1d. No escaping needed
25646 !! options
25647 parsoid=html2wt
25648 !! html/parsoid
25649 <p>|}foo
25650 </p>
25651 !! wikitext
25652 |}foo
25653 !! end
25654
25655 !! test
25656 Tables: 2a. Nested in td
25657 !! options
25658 parsoid=html2wt
25659 !! html/parsoid
25660 <table><tbody><tr>
25661 <td>foo|bar</td></tr>
25662 <tr><td>x<div>a|b</div></td>
25663 </tbody></table>
25664 !! wikitext
25665 {|
25666 |<nowiki>foo|bar</nowiki>
25667 |-
25668 |x<div><nowiki>a|b</nowiki></div>
25669 |}
25670 !! html/php+tidy
25671 <table>
25672 <tr>
25673 <td>foo|bar</td>
25674 </tr>
25675 <tr>
25676 <td>x
25677 <div>a|b</div>
25678 </td>
25679 </tr>
25680 </table>
25681 !! end
25682
25683 !! test
25684 Tables: 2b. Nested in td
25685 !! options
25686 parsoid=html2wt
25687 !! html/parsoid
25688 <table><tbody><tr>
25689 <td>foo||bar</td>
25690 <td>a<i>b||c</i></td>
25691 <td>a<i><div>b||c</div></i></td>
25692 </tr></tbody></table>
25693 !! wikitext
25694 {|
25695 |<nowiki>foo||bar</nowiki>
25696 |a''<nowiki>b||c</nowiki>''
25697 |a''<div><nowiki>b||c</nowiki></div>''
25698 |}
25699 !! html/php
25700 <table>
25701 <tr>
25702 <td>foo||bar
25703 </td>
25704 <td>a<i>b||c</i>
25705 </td>
25706 <td>a<i><div>b||c</div></i>
25707 </td></tr></table>
25708
25709 !! end
25710
25711 !! test
25712 Tables: 2c. Nested in td -- no escaping needed
25713 !! options
25714 parsoid=html2wt
25715 !! html/*
25716 <table>
25717 <tr>
25718 <td>foo!!bar
25719 </td></tr></table>
25720
25721 !! wikitext
25722 {|
25723 |foo!!bar
25724 |}
25725 !! end
25726
25727 !! test
25728 Tables: 3a. Nested in th
25729 !! options
25730 parsoid=html2wt
25731 !! html/*
25732 <table>
25733 <tr>
25734 <th>foo!bar
25735 </th></tr></table>
25736
25737 !! wikitext
25738 {|
25739 !foo!bar
25740 |}
25741 !! end
25742
25743 !! test
25744 Tables: 3b. Nested in th
25745 !! options
25746 parsoid=html2wt
25747 !! html/parsoid
25748 <table><tbody>
25749 <tr><th>foo!!bar</th>
25750 <th><i>foo|bar</i></th>
25751 <th><i>foo!!bar</i></th>
25752 <th><i><span>foo!!bar</span></i></th>
25753 </tr></tbody></table>
25754 !! wikitext
25755 {|
25756 !<nowiki>foo!!bar</nowiki>
25757 !''<nowiki>foo|bar</nowiki>''
25758 !''<nowiki>foo!!bar</nowiki>''
25759 !''<span><nowiki>foo!!bar</nowiki></span>''
25760 |}
25761 !! html/php
25762 <table>
25763 <tr>
25764 <th>foo!!bar
25765 </th>
25766 <th><i>foo|bar</i>
25767 </th>
25768 <th><i>foo!!bar</i>
25769 </th>
25770 <th><i><span>foo!!bar</span></i>
25771 </th></tr></table>
25772
25773 !! end
25774
25775 !! test
25776 Tables: 3c. Nested in th
25777 !! options
25778 parsoid=html2wt
25779 !! html/parsoid
25780 <table><tbody>
25781 <tr><th>foo||bar</th>
25782 <th><span typeof="mw:Nowiki">foo||bar</span></th>
25783 </tr></tbody></table>
25784 !! wikitext
25785 {|
25786 !<nowiki>foo||bar</nowiki>
25787 !<nowiki>foo||bar</nowiki>
25788 |}
25789 !! html/php
25790 <table>
25791 <tr>
25792 <th>foo||bar
25793 </th>
25794 <th>foo||bar
25795 </th></tr></table>
25796
25797 !! end
25798
25799 !! test
25800 Tables: 4a. Escape -
25801 !! options
25802 parsoid=html2wt
25803 !! html/*
25804 <table>
25805 <tr>
25806 <th>-bar
25807 </th></tr>
25808 <tr>
25809 <td>-bar
25810 </td></tr></table>
25811
25812 !! wikitext
25813 {|
25814 !-bar
25815 |-
25816 |<nowiki>-bar</nowiki>
25817 |}
25818 !! end
25819
25820 !! test
25821 Tables: 4b. Escape +
25822 !! options
25823 parsoid=html2wt
25824 !! html/*
25825 <table>
25826 <tr>
25827 <th>+bar
25828 </th></tr>
25829 <tr>
25830 <td>+bar
25831 </td></tr></table>
25832
25833 !! wikitext
25834 {|
25835 !+bar
25836 |-
25837 |<nowiki>+bar</nowiki>
25838 |}
25839 !! end
25840
25841 !! test
25842 Tables: 4c. No escaping needed
25843 !! options
25844 parsoid=html2wt
25845 !! html/parsoid
25846 <table><tbody>
25847 <tr><td>foo-bar</td><td>foo+bar</td></tr>
25848 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
25849 <tr><td>foo
25850 <p>bar|baz
25851 +bar
25852 -bar</p></td></tr>
25853 <tr><td>x
25854 <div>a|b</div></td>
25855 </tbody></table>
25856 !! wikitext
25857 {|
25858 |foo-bar
25859 |foo+bar
25860 |-
25861 |''foo''-bar
25862 |''foo''+bar
25863 |-
25864 |foo
25865 bar|baz
25866 +bar
25867 -bar
25868 |-
25869 |x
25870 <div>a|b</div>
25871 |}
25872 !! html/php
25873 <table>
25874 <tr>
25875 <td>foo-bar
25876 </td>
25877 <td>foo+bar
25878 </td></tr>
25879 <tr>
25880 <td><i>foo</i>-bar
25881 </td>
25882 <td><i>foo</i>+bar
25883 </td></tr>
25884 <tr>
25885 <td>foo
25886 <p>bar|baz
25887 +bar
25888 -bar
25889 </p>
25890 </td></tr>
25891 <tr>
25892 <td>x
25893 <div>a|b</div>
25894 </td></tr></table>
25895
25896 !! end
25897
25898 !! test
25899 Tables: 4d. No escaping needed
25900 !! options
25901 parsoid=html2wt
25902 !! html/parsoid
25903 <table>
25904 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
25905 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
25906 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
25907 </tbody></table>
25908 !! wikitext
25909 {|
25910 |[[Foo]]-bar
25911 ||+1
25912 ||-2
25913 |}
25914 !! html/php
25915 <table>
25916 <tr>
25917 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
25918 </td>
25919 <td>+1
25920 </td>
25921 <td>-2
25922 </td></tr></table>
25923
25924 !! end
25925
25926 !! test
25927 T97430: Don't emit empty nowiki pairs around marker meta tags
25928 !! options
25929 parsoid=html2wt
25930 !! html/parsoid
25931 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25932 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
25933 !! wikitext
25934 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25935 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
25936 !! end
25937
25938 !! test
25939 Unclosed xmlish element in table line shouldn't eat end delimiters
25940 !! options
25941 parsoid=html2wt
25942 !! html/parsoid
25943 <table>
25944 <tbody><tr><td> &lt;foo</td>
25945 <td> bar></td></tr>
25946 </tbody></table>
25947 !! wikitext
25948 {|
25949 | <foo
25950 | bar>
25951 |}
25952 !! html/php
25953 <table>
25954 <tr>
25955 <td> &lt;foo
25956 </td>
25957 <td> bar&gt;
25958 </td></tr></table>
25959
25960 !! end
25961
25962 #### --------------- Links ----------------
25963 #### 1. Quote marks in link text
25964 #### 2. Wikilinks: Escapes needed
25965 #### 3. Wikilinks: No escapes needed
25966 #### 4. Extlinks: Escapes needed
25967 #### 5. Extlinks: No escapes needed
25968 #### --------------------------------------
25969 !! test
25970 Links 1. WikiLinks: No escapes needed
25971 !! options
25972 parsoid=html2wt
25973 !! html/parsoid
25974 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
25975 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
25976 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
25977 !! wikitext
25978 [[Foo|Foo''boo'']]
25979 [[Foo|[Foobar]]]
25980 [[Foo|x [Foobar] x]]
25981 !! html/php
25982 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
25983 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
25984 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
25985 </p>
25986 !! end
25987
25988 !! test
25989 Links 2. WikiLinks: Escapes needed
25990 !! options
25991 parsoid=html2wt
25992 !! html/parsoid
25993 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
25994 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
25995 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
25996 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
25997 <a href="Foo" rel="mw:WikiLink">|Bar</a>
25998 <a href="Foo" rel="mw:WikiLink">]]bar</a>
25999 <a href="Foo" rel="mw:WikiLink">[[bar</a>
26000 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
26001 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
26002 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
26003 !! wikitext
26004 [[Foo|<nowiki>Foobar]</nowiki>]]
26005 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
26006 [[Foo|<nowiki>[[Bar]]</nowiki>]]
26007 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
26008 [[Foo|<nowiki>|Bar</nowiki>]]
26009 [[Foo|<nowiki>]]bar</nowiki>]]
26010 [[Foo|<nowiki>[[bar</nowiki>]]
26011 [[Foo|<nowiki>x [[ y</nowiki>]]
26012 [[Foo|<nowiki>x ]] y</nowiki>]]
26013 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
26014 !! html/php
26015 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
26016 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
26017 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
26018 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
26019 <a href="/wiki/Foo" title="Foo">|Bar</a>
26020 <a href="/wiki/Foo" title="Foo">]]bar</a>
26021 <a href="/wiki/Foo" title="Foo">[[bar</a>
26022 <a href="/wiki/Foo" title="Foo">x [[ y</a>
26023 <a href="/wiki/Foo" title="Foo">x ]] y</a>
26024 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
26025 </p>
26026 !! end
26027
26028 !! test
26029 Links 3. WikiLinks: No escapes needed
26030 !! options
26031 parsoid=html2wt
26032 !! html/parsoid
26033 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
26034 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
26035 !! wikitext
26036 [[Foo|[Foobar]]
26037 [[Foo|foo|bar]]
26038 !! html/php
26039 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
26040 <a href="/wiki/Foo" title="Foo">foo|bar</a>
26041 </p>
26042 !! end
26043
26044 !! test
26045 Links 4. ExtLinks: Escapes needed
26046 !! options
26047 parsoid=html2wt
26048 !! html/parsoid
26049 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
26050 <a rel="mw:ExtLink" href="http://google.com">google]</a>
26051 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
26052 <p>[http://google.com]</p>
26053 <p>[http://google.com google]</p>
26054 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
26055 <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>
26056 !! wikitext
26057 [http://google.com <nowiki>[google]</nowiki>]
26058 [http://google.com <nowiki>google]</nowiki>]
26059 [http://google.com <nowiki>goog] le</nowiki>]
26060
26061 <nowiki>[http://google.com]</nowiki>
26062
26063 <nowiki>[http://google.com google]</nowiki>
26064
26065 [http://google.com<nowiki>]</nowiki>
26066
26067 [{{echo|http://google.com}}<nowiki>]</nowiki>
26068 !! html/php
26069 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
26070 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
26071 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
26072 </p><p>[http://google.com]
26073 </p><p>[http://google.com google]
26074 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
26075 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
26076 </p>
26077 !! end
26078
26079 !! test
26080 Links 5. ExtLinks: No escapes needed
26081 !! options
26082 parsoid=html2wt
26083 !! html/parsoid
26084 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
26085 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
26086 !! wikitext
26087 [http://google.com [google]
26088
26089 [[http://google.com]]
26090 !! html/php
26091 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
26092 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
26093 </p>
26094 !! end
26095
26096 !! test
26097 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
26098 !! options
26099 parsoid=html2wt
26100 !! html/parsoid
26101 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
26102 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
26103 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
26104 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
26105 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
26106 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
26107 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
26108 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
26109 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
26110 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
26111 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
26112 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
26113 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
26114 </p>
26115 !! wikitext
26116 x<nowiki/>http://example.com<nowiki/>y
26117 http://example.com<nowiki/>?x
26118 http://example.com<nowiki/>&x
26119 http://example.com<nowiki/>'x
26120 http://example.com<nowiki/>,x
26121 http://example.com<nowiki/>.x
26122 http://example.com<nowiki/>;x
26123 http://example.com<nowiki/>:x
26124 http://example.com<nowiki/>;x
26125 http://example.com<nowiki/>!x
26126 http://example.com<nowiki/>=x
26127 http://example.com<nowiki/>(x)
26128 http://example.com(x<nowiki/>)
26129 !! end
26130
26131 !! test
26132 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
26133 !! options
26134 parsoid=html2wt
26135 !! html/parsoid
26136 <p>x
26137 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
26138 y
26139 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
26140 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
26141 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
26142 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
26143 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
26144 </p>
26145 !! wikitext
26146 x
26147 http://example.com
26148 y
26149 "http://example.com"
26150 (http://example.com)
26151 (http://example.com) foo
26152 http://example.com,
26153 http://example.com, foo
26154 !! html/php
26155 <p>x
26156 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
26157 y
26158 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
26159 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
26160 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
26161 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
26162 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
26163 </p>
26164 !! end
26165
26166 !! test
26167 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
26168 !! options
26169 parsoid=html2wt
26170 !! html/parsoid
26171 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
26172 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
26173 !! wikitext
26174 http://example.com.,;:!?\
26175 -http://example.com:
26176 !! html/php
26177 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
26178 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
26179 </p>
26180 !! end
26181
26182 !! test
26183 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
26184 !! options
26185 parsoid=html2wt
26186 !! html/parsoid
26187 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
26188 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
26189 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
26190 !! wikitext
26191 RFC 123<nowiki/>4
26192 RFC 123<nowiki/>y
26193 X<nowiki/>RFC 123<nowiki/>y
26194 !! end
26195
26196 !! test
26197 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
26198 !! options
26199 parsoid=html2wt
26200 !! html/parsoid
26201 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
26202 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
26203 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
26204 </p>
26205 !! wikitext
26206 RFC 123?foo
26207 RFC 123&foo
26208 -RFC 123-
26209 !! html/php
26210 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
26211 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
26212 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
26213 </p>
26214 !! end
26215
26216 !! test
26217 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
26218 !! options
26219 parsoid=html2wt
26220 !! html/parsoid
26221 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
26222 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
26223 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
26224 !! wikitext
26225 PMID 123<nowiki/>4
26226 PMID 123<nowiki/>y
26227 X<nowiki/>PMID 123<nowiki/>y
26228 !! end
26229
26230 !! test
26231 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
26232 !! options
26233 parsoid=html2wt
26234 !! html/parsoid
26235 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
26236 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
26237 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
26238 </p>
26239 !! wikitext
26240 PMID 123?foo
26241 PMID 123&foo
26242 -PMID 123-
26243 !! html/php
26244 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
26245 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
26246 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
26247 </p>
26248 !! end
26249
26250 !! test
26251 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
26252 !! options
26253 parsoid=html2wt
26254 !! html/parsoid
26255 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
26256 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
26257 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
26258 </p>
26259 !! wikitext
26260 ISBN 1234567890<nowiki/>1
26261 ISBN 1234567890<nowiki/>x
26262 a<nowiki/>ISBN 1234567890<nowiki/>b
26263 !! end
26264
26265 !! test
26266 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
26267 !! options
26268 parsoid=html2wt
26269 !! html/parsoid
26270 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
26271 !! wikitext
26272 -ISBN 1234567890's
26273 !! html/php
26274 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
26275 </p>
26276 !! end
26277
26278 !! test
26279 Links 14. Protect link-like plain text. (Parsoid bug T78425)
26280 !! options
26281 parsoid=html2wt
26282 !! html/*
26283 <p>this is not a link: http://example.com
26284 </p>
26285 !! wikitext
26286 this is not a link: <nowiki>http://example.com</nowiki>
26287 !! end
26288
26289 !! test
26290 Links 15. Link trails can't become link prefixes.
26291 !! options
26292 language=is
26293 parsoid=html2wt
26294 !! html/parsoid
26295 <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>
26296 !! wikitext
26297 [[Söfnuður]]-[[00]]
26298 !! html/php
26299 <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>
26300 </p>
26301 !! end
26302
26303 #### --------------- Quotes ---------------
26304 #### 1. Quotes inside <b> and <i>
26305 #### 2. Link fragments separated by <i> and <b> tags
26306 #### 3. Link fragments inside <i> and <b>
26307 #### 4. No escaping needed
26308 #### --------------------------------------
26309 !! test
26310 1a. Quotes inside <b> and <i>
26311 !! options
26312 parsoid=html2wt
26313 !! html/*
26314 <p><i>'foo'</i>
26315 <i>''foo''</i>
26316 <i>'''foo'''</i>
26317 <i>foo</i>'s
26318 <b>'foo'</b>
26319 <b>''foo''</b>
26320 <b>'''foo'''</b>
26321 <b>foo'<i>bar'</i>baz</b>
26322 <b>foo</b>'s
26323 '<i>foo</i>
26324 <i>foo</i>'
26325 <i>foo'</i>'
26326 '<i>foo</i>'
26327 '<b>foo</b>
26328 <b>foo</b>'
26329 '<b>foo</b>'
26330 <i>fools'<span> errand</span></i>
26331 <i><span>fool</span>'s errand</i>
26332 '<i>foo</i> bar '<i>baz</i>
26333 a|!*#-:;+-~[]{}b'<i>x</i>
26334 </p>
26335 !! wikitext
26336 ''<nowiki/>'foo'''
26337 ''<nowiki>''foo''</nowiki>''
26338 ''<nowiki>'''foo'''</nowiki>''
26339 ''foo''<nowiki/>'s
26340 '''<nowiki/>'foo''''
26341 '''<nowiki>''foo''</nowiki>'''
26342 '''<nowiki>'''foo'''</nowiki>'''
26343 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
26344 '''foo'''<nowiki/>'s
26345 '''foo''
26346 ''foo''<nowiki/>'
26347 ''foo'''<nowiki/>'
26348 '''foo''<nowiki/>'
26349 ''''foo'''
26350 '''foo'''<nowiki/>'
26351 ''''foo'''<nowiki/>'
26352 ''fools'<span> errand</span>''
26353 ''<span>fool</span>'s errand''
26354 '<nowiki/>''foo'' bar '''baz''
26355 a|!*#-:;+-~[]{}b'''x''
26356 !! end
26357
26358 !! test
26359 1b. Quotes inside <b> and <i> with other tags on same line
26360 !! options
26361 parsoid=html2wt
26362 !! html/parsoid
26363 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26364 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26365 <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>
26366 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
26367 '<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>
26368 '<i>foo</i> <div title="name">test</div>
26369 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
26370 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
26371 <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>
26372 </ol>
26373 !! wikitext
26374 '''a'' foo ''[[bar]]''
26375 ''a''' foo ''[[bar]]''
26376 ''a''' foo '''{{echo|[[bar]]}}'''
26377 [[foo]] x'''[[bar]]''
26378 '''foo'' <ref>test</ref>
26379 '''foo'' <div title="name">test</div>
26380 '''foo'' and <br> bar
26381 <references />
26382 !! end
26383
26384 !! test
26385 2. Link fragments separated by <i> and <b> tags
26386 !! options
26387 parsoid=html2wt
26388 !! html/parsoid
26389 <p>[[<i>foo</i>hello]]</p>
26390 <p>[[<b>foo</b>hello]]</p>
26391 !! wikitext
26392 [[''foo''<nowiki>hello]]</nowiki>
26393
26394 [['''foo'''<nowiki>hello]]</nowiki>
26395 !! end
26396
26397 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
26398 # this is one of the shortcomings of this format
26399 !! test
26400 3. Link fragments inside <i> and <b>
26401 !! options
26402 parsoid=html2wt
26403 !! html/parsoid
26404 <p><i>[[foo</i>]]</p>
26405 <p><b>[[foo</b>]]</p>
26406 !! wikitext
26407 ''[[foo''<nowiki>]]</nowiki>
26408
26409 '''[[foo'''<nowiki>]]</nowiki>
26410 !! end
26411
26412 !! test
26413 4. No escaping needed
26414 !! options
26415 parsoid=html2wt
26416 !! html/parsoid
26417 <p>'<span><i>bar</i></span>'
26418 '<span><b>bar</b></span>'
26419 'a:b'foo
26420 </p>
26421 !! wikitext
26422 '<span>''bar''</span>'
26423 '<span>'''bar'''</span>'
26424 'a:b'foo
26425 !! end
26426
26427 #### ----------- Paragraphs ---------------
26428 #### 1. No unnecessary escapes
26429 #### --------------------------------------
26430
26431 !! test
26432 1. No unnecessary escapes
26433 !! options
26434 parsoid=html2wt
26435 !! html/parsoid
26436 <p>bar <span>[[foo]]</span>
26437 </p><p>=bar <span>[[foo]]</span>
26438 </p><p>[[bar <span>[[foo]]</span>
26439 </p><p>]]bar <span>[[foo]]</span>
26440 </p><p>=bar <span>foo]]</span>=
26441 </p>
26442 !! wikitext
26443 bar <span><nowiki>[[foo]]</nowiki></span>
26444
26445 =bar <span><nowiki>[[foo]]</nowiki></span>
26446
26447 [[bar <span><nowiki>[[foo]]</nowiki></span>
26448
26449 ]]bar <span><nowiki>[[foo]]</nowiki></span>
26450
26451 =bar <span>foo]]</span><nowiki>=</nowiki>
26452 !!end
26453
26454 #### ----------------------- PRE --------------------------
26455 #### 1. Leading whitespace in SOL context should be escaped
26456 #### ------------------------------------------------------
26457 !! test
26458 1. Leading whitespace in SOL context should be escaped
26459 !! options
26460 parsoid=html2wt
26461 !! html/parsoid
26462 <p> a</p>
26463
26464 <p> a</p>
26465
26466 <p> a(tab)</p>
26467
26468 <p> a
26469 <!--cmt-->
26470 a</p>
26471
26472 <p>a
26473 b</p>
26474
26475 <p>a
26476 b</p>
26477
26478 <p>a
26479 b</p>
26480 !! wikitext
26481 <nowiki> </nowiki>a
26482
26483 <nowiki> </nowiki> a
26484
26485 a(tab)
26486
26487 <nowiki> </nowiki> a
26488 <!--cmt-->
26489 <nowiki> </nowiki>a
26490
26491 a
26492 <nowiki> </nowiki>b
26493
26494 a
26495 b
26496
26497 a
26498 b
26499 !! html/php
26500 <p> a
26501 </p><p> a
26502 </p><p> a(tab)
26503 </p><p> a
26504 a
26505 </p><p>a
26506 b
26507 </p><p>a
26508 b
26509 </p><p>a
26510 b
26511 </p>
26512 !! end
26513
26514 !! test
26515 2. Leading whitespace in non-indent-pre contexts should not be escaped
26516 !! options
26517 parsoid=html2wt
26518 !! html/parsoid
26519 <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>
26520 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
26521 <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>
26522 b</span></li>
26523 </ol>
26524 !! wikitext
26525 foo <ref>''a''
26526 b</ref>
26527 <references />
26528 !! end
26529
26530 !! test
26531 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
26532 !! options
26533 parsoid=html2wt
26534 !! html/parsoid
26535 <blockquote>
26536 <p>
26537 a
26538 <span>b</span>
26539 c</p>
26540 </blockquote>
26541 !! wikitext
26542 <blockquote>
26543 a
26544 <span>b</span>
26545 c
26546 </blockquote>
26547 !! end
26548
26549 !! test
26550 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
26551 !! options
26552 parsoid=html2wt
26553 !! html/parsoid
26554 <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>
26555 !! wikitext
26556 [[File:Foobar.jpg|thumb|caption]]
26557 !! end
26558
26559 !! test
26560 5. Nowiki escaping should account for indent-pres
26561 !! options
26562 parsoid=html2wt
26563 !! html/parsoid
26564 <pre>==foo==</pre>
26565 !! wikitext
26566 ==foo==
26567 !! end
26568
26569 !!test
26570 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
26571 !! options
26572 parsoid=html2wt
26573 !! html/parsoid
26574 <pre>
26575 * foo
26576 * bar
26577 </pre>
26578 !! wikitext
26579 * foo
26580 * bar
26581 !! end
26582
26583 #### --------------- Behavior Switches --------------------
26584
26585 !! test
26586 1. Valid behavior switches should be escaped
26587 !! options
26588 parsoid=html2wt
26589 !! html/parsoid
26590 __TOC__
26591 <i>__TOC__</i>
26592 !! wikitext
26593 <nowiki>__TOC__</nowiki>
26594 ''<nowiki>__TOC__</nowiki>''
26595 !! end
26596
26597 !! test
26598 2. Invalid behavior switches should not be escaped
26599 !! options
26600 parsoid=html2wt
26601 !! html/parsoid
26602 __TOO__
26603 __|__
26604 !! wikitext
26605 __TOO__
26606 __|__
26607 !! end
26608
26609 # We use indent-pre as an indirect way to test for sol-transparent behavior.
26610 !! test
26611 Behavior switches should be SOL-transparent
26612 !! options
26613 parsoid=html2wt
26614 !! html/parsoid
26615 <meta property="mw:PageProp/toc" />
26616
26617 <!-- this one's bogus -->
26618 <pre>__TOO__</pre>
26619
26620 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
26621
26622 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
26623 !! wikitext
26624 __TOC__
26625
26626 <!-- this one's bogus -->
26627 __TOO__
26628
26629 __TOC__ foo
26630
26631 __TOC__
26632 bar
26633 !! end
26634
26635 #### --------------- HTML tags ---------------
26636 #### 1. a tags
26637 #### 2. other tags
26638 #### 3. multi-line html tag
26639 #### 4. extension tags
26640 #### -----------------------------------------
26641 !! test
26642 1. a tags
26643 !! options
26644 parsoid=html2wt
26645 !! html/parsoid
26646 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
26647 !! wikitext
26648 <a href="http://google.com">google</a>
26649 !! end
26650
26651 !! test
26652 2. other tags
26653 !! options
26654 parsoid=html2wt
26655 !! html/parsoid
26656 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
26657 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
26658 <li> &lt;td&gt;</li></ul>
26659
26660 !! wikitext
26661 * <nowiki><div>foo</div></nowiki>
26662 * <nowiki><div style="color:red">foo</div></nowiki>
26663 * <nowiki><td></nowiki>
26664 !! end
26665
26666 !! test
26667 3. multi-line html tag
26668 !! options
26669 parsoid=html2wt
26670 !! html/parsoid
26671 <p>&lt;div
26672 &gt;foo&lt;/div
26673 &gt;
26674 </p>
26675 !! wikitext
26676 <nowiki><div
26677 >foo</div
26678 ></nowiki>
26679 !! end
26680
26681 !! test
26682 4. extension tags
26683 !! options
26684 parsoid=html2wt
26685 !! html/parsoid
26686 <p>&lt;ref&gt;foo&lt;/ref&gt;
26687 </p><p>&lt;ref&gt;bar
26688 </p><p>baz&lt;/ref&gt;
26689 </p>
26690 !! wikitext
26691 <nowiki><ref>foo</ref></nowiki>
26692
26693 <nowiki><ref>bar</nowiki>
26694
26695 baz<nowiki></ref></nowiki>
26696 !! end
26697
26698 #### --------------- Others ---------------
26699 !! test
26700 Escaping nowikis
26701 !! options
26702 parsoid=html2wt
26703 !! html/parsoid
26704 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
26705 </p>
26706 !! wikitext
26707 &lt;nowiki&gt;foo&lt;/nowiki&gt;
26708 !! end
26709
26710 ## The quote-char in the input is necessary for triggering the bug
26711 !! test
26712 (T54035) Nowiki-escaping should not get tripped by " :" in text
26713 !! options
26714 parsoid=html2wt
26715 !! html/parsoid
26716 <p>foo's bar :</p>
26717 !! wikitext
26718 foo's bar :
26719 !! end
26720
26721 #----------- End of wikitext escaping tests --------------
26722
26723 !! test
26724
26725 Tag-like HTML structures are passed through as text
26726 !! wikitext
26727 <x y>
26728
26729 <x.y>
26730
26731 <x-y>
26732
26733 1>2
26734
26735 x<y
26736
26737 a>b
26738
26739 1<d e>f
26740 !! html
26741 <p>&lt;x y&gt;
26742 </p><p>&lt;x.y&gt;
26743 </p><p>&lt;x-y&gt;
26744 </p><p>1&gt;2
26745 </p><p>x&lt;y
26746 </p><p>a&gt;b
26747 </p><p>1&lt;d e&gt;f
26748 </p>
26749 !! end
26750
26751 !! test
26752 HTML tag with necessary entities in attributes
26753 !! wikitext
26754 <span title="&amp;amp;">foo</span>
26755 !! html
26756 <p><span title="&amp;amp;">foo</span>
26757 </p>
26758 !! end
26759
26760 !! test
26761 HTML tag with 'unnecessary' entity encoding in attributes
26762 !! wikitext
26763 <span title="&amp;">foo</span>
26764 !! html
26765 <p><span title="&amp;">foo</span>
26766 </p>
26767 !! end
26768
26769 !! test
26770 HTML tag with broken attribute value quoting
26771 !! options
26772 parsoid=wt2html,html2html
26773 !! wikitext
26774 <span title="Hello world>Foo</span>
26775 !! html/php
26776 <p><span title="Hello world">Foo</span>
26777 </p>
26778 !! html/parsoid
26779 <p><span title="Hello world">Foo</span></p>
26780 !! end
26781
26782 !! test
26783 Self-closed tag with broken attribute value quoting
26784 !! options
26785 parsoid=wt2html,html2html
26786 !! wikitext
26787 <div title="Hello world />Foo
26788 !! html/php+tidy
26789 <div title="Hello world"></div>
26790 <p>Foo</p>
26791 !! html/parsoid
26792 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
26793 !! end
26794
26795 !! test
26796 Table with broken attribute value quoting
26797 !! options
26798 parsoid=wt2html,html2html
26799 !! wikitext
26800 {|
26801 | title="Hello world|Foo
26802 |}
26803 !! html/php
26804 <table>
26805 <tr>
26806 <td title="Hello world">Foo
26807 </td></tr></table>
26808
26809 !! html/parsoid
26810 <table>
26811 <tr>
26812 <td title="Hello world">Foo
26813 </td></tr></table>
26814
26815 !! end
26816
26817 !! test
26818 Table with broken attribute value quoting on consecutive lines
26819 !! options
26820 parsoid=wt2html,html2html
26821 !! wikitext
26822 {|
26823 | title="Hello world|Foo
26824 | style="color:red|Bar
26825 |}
26826 !! html/php
26827 <table>
26828 <tr>
26829 <td title="Hello world">Foo
26830 </td>
26831 <td style="color:red">Bar
26832 </td></tr></table>
26833
26834 !! html/parsoid
26835 <table><tbody>
26836 <tr>
26837 <td title="Hello world">Foo
26838 </td><td style="color: red">Bar
26839 </td></tr></tbody></table>
26840
26841 !! end
26842
26843 !!test
26844 Accept empty td cell attribute
26845 !! wikitext
26846 {|
26847 | align="center" | foo || |
26848 |}
26849 !! html
26850 <table>
26851 <tr>
26852 <td align="center"> foo </td>
26853 <td>
26854 </td></tr></table>
26855
26856 !!end
26857
26858 !!test
26859 Non-empty attributes in th-cells
26860 !! wikitext
26861 {|
26862 ! Foo !! style="color: red" | Bar
26863 |}
26864 !! html
26865 <table>
26866 <tr>
26867 <th> Foo </th>
26868 <th style="color: red"> Bar
26869 </th></tr></table>
26870
26871 !!end
26872
26873 !!test
26874 Accept empty attributes in th-cells
26875 !! wikitext
26876 {|
26877 !| foo !!| bar
26878 |}
26879 !! html
26880 <table>
26881 <tr>
26882 <th> foo </th>
26883 <th> bar
26884 </th></tr></table>
26885
26886 !!end
26887
26888 !!test
26889 Empty table rows go away
26890 !! wikitext
26891 {|
26892 | Hello
26893 | there
26894 |- class="foo"
26895 |-
26896 |}
26897 !! html
26898 <table>
26899 <tr>
26900 <td> Hello
26901 </td>
26902 <td> there
26903 </td></tr>
26904
26905 </table>
26906
26907 !! end
26908
26909 ###
26910 ### Parsoid-centric tests for testing RTing of inter-element separators
26911 ### Edge cases not tested by existing parser tests and specific to
26912 ### Parsoid-specific serialization strategies.
26913 ###
26914
26915 !!test
26916 RT-ed inter-element separators should be valid separators
26917 !! wikitext
26918 {|
26919 |- [[foo]]
26920 |}
26921 !! html/php
26922 <table>
26923
26924 </table>
26925
26926 !! html/parsoid
26927 <table>
26928 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
26929 </tbody></table>
26930 !!end
26931
26932 # Parsoid-only since PHP parser relies on Tidy for correct output
26933 !!test
26934 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
26935 !!options
26936 parsoid
26937 !! wikitext
26938 {|
26939 |<small>foo
26940 bar
26941 |}
26942
26943 {|
26944 |<small>foo<small>
26945 |}
26946 !! html
26947 <table>
26948 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
26949 <p>bar</p></small></td></tr>
26950 </tbody></table>
26951
26952 <table>
26953 <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>
26954 </tbody></table>
26955 !!end
26956
26957 # Note that the "style" attribute is really a template parameter here.
26958 # The = would have to be {{=}} if you wanted the literal.
26959 !!test
26960 Empty TD followed by TD with tpl-generated attribute
26961 !! wikitext
26962 {|
26963 |-
26964 |
26965 |{{echo|style='color:red'}}|foo
26966 |}
26967 !! html
26968 <table>
26969
26970 <tr>
26971 <td>
26972 </td>
26973 <td>foo
26974 </td></tr></table>
26975
26976 !!end
26977
26978 !!test
26979 Indented table with an empty td
26980 !! wikitext
26981 {|
26982 |-
26983 |
26984 |foo
26985 |}
26986 !! html
26987 <table>
26988
26989 <tr>
26990 <td>
26991 </td>
26992 <td>foo
26993 </td></tr></table>
26994
26995 !!end
26996
26997 ## We have some newline diffs RT-ing this edge case
26998 ## and it is not important enough -- we seem to be emitting
26999 ## at most 2 newlines after a </tr> and this is unrelated to
27000 ## the issue from T85627 that this is testing.
27001 !!test
27002 Indented table with blank lines in between (T85627)
27003 !! options
27004 parsoid=wt2html
27005 !! wikitext
27006 {|
27007 |foo
27008
27009
27010 |}
27011 !! html
27012 <table>
27013
27014 <tr>
27015 <td>foo
27016 </td></tr></table>
27017
27018 !!end
27019
27020 !!test
27021 Indented block & table
27022 !! wikitext
27023 <div>foo</div>
27024 {|
27025 |foo
27026 |}
27027 !! html/php
27028 <div>foo</div>
27029 <table>
27030 <tr>
27031 <td>foo
27032 </td></tr></table>
27033
27034 !! html/parsoid
27035 <div data-parsoid='{"stx":"html"}'>foo</div>
27036 <table><tbody>
27037 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
27038 </tbody></table>
27039 !!end
27040
27041 !! test
27042 Indent and comment before table row
27043 !! wikitext
27044 {|
27045 <!--hi-->|-
27046 | there
27047 |}
27048 !! html/php
27049 <table>
27050
27051 <tr>
27052 <td> there
27053 </td></tr></table>
27054
27055 !! html/parsoid
27056 <table>
27057 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
27058 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
27059 </tbody></table>
27060 !! end
27061
27062 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
27063 !!test
27064 Empty TR followed by a template-generated TR
27065 !!options
27066 parsoid
27067 !! wikitext
27068 {|
27069 |-
27070 {{echo|<tr><td>foo</td></tr>}}
27071 |}
27072 !! html
27073 <table>
27074 <tbody>
27075 <tr class='mw-empty-elt'></tr>
27076 <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}}]}'>
27077 <td>foo</td></tr>
27078 </tbody></table>
27079 !!end
27080
27081 ## PHP and parsoid output differ for this, and since this is primarily
27082 ## for testing Parsoid's serializer, marking this Parsoid only
27083 !!test
27084 Empty TR followed by mixed-ws-comment line should RT correctly
27085 !!options
27086 parsoid
27087 !! wikitext
27088 {|
27089 |-
27090 <!--c-->
27091 |-
27092 <!--c--> <!--d-->
27093 |}
27094 !! html
27095 <table>
27096 <tbody>
27097 <tr class='mw-empty-elt'></tr>
27098 <!--c-->
27099 <tr>
27100 <!--c--> </tr><!--d-->
27101 </tbody></table>
27102
27103 !!end
27104
27105 !!test
27106 Multi-line image caption generated by templates with/without trailing newlines
27107 !! wikitext
27108 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
27109 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
27110 !! html/parsoid
27111 <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>
27112 <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>
27113 !!end
27114
27115 !! test
27116 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
27117 !! options
27118 parsoid=html2wt
27119 !! html/parsoid
27120 <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>
27121
27122 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
27123 !! wikitext
27124 <includeonly>foo</includeonly>
27125 new para
27126
27127 [[Category:Foo]]
27128
27129 = new heading =
27130 !! end
27131
27132 ## PHP emits broken html for this, and since this is primarily
27133 ## a Parsoid serializer test, marking this Parsoid only
27134 !!test
27135 Improperly nested inline or quotes tags with whitespace in between
27136 !! wikitext
27137 <span> <s>x</span> </s>
27138 ''' ''x''' ''
27139 !! html/parsoid
27140 <p><span> <s>x</s></span><s> </s>
27141 <b> <i>x</i></b><i> </i>
27142 </p>
27143 !!end
27144
27145 !!test
27146 Encapsulate protected attributes from wt
27147 !! wikitext
27148 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
27149
27150 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
27151 | ok
27152 |}
27153 !! html/parsoid
27154 <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>
27155
27156 <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">
27157 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'> ok</td></tr>
27158 </tbody></table>
27159 !!end
27160
27161 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
27162 ## Having nested or stray pre tags results in the attempt to add duplicates,
27163 ## causing an assertion fail. This test tries to prevent that situation.
27164 !!test
27165 Ensure ParagraphWrapper can deal with stray closing pre tags
27166 !!options
27167 parsoid=wt2html
27168 !! wikitext
27169 plain text</pre>
27170 !! html/parsoid
27171 plain text
27172 !!end
27173
27174 !!test
27175 1. Ensure fostered text content is wrapped in element nodes
27176 !!options
27177 parsoid=wt2html
27178 !! wikitext
27179 <table>hi</table><table>ho</table>
27180 !! html/parsoid
27181 <p>hi</p>
27182 <table></table>
27183 <p>ho</p>
27184 <table></table>
27185 !!end
27186
27187 !!test
27188 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
27189 !!options
27190 parsoid=wt2html,wt2wt
27191 !! wikitext
27192 <table>
27193 <tr> || ||
27194 <td> a
27195 </table>
27196 !! html/parsoid
27197 <p> || ||
27198 </p><table>
27199 <tbody><tr><td> a</td></tr>
27200 </tbody></table>
27201 !!end
27202
27203 !!test
27204 Encapsulation properly handles null DSR information from foster box
27205 !!options
27206 parsoid=wt2html,wt2wt
27207 !! wikitext
27208 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
27209 !! html/parsoid
27210 <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>
27211 !!end
27212
27213 !!test
27214 1. Encapsulate foster-parented transclusion content
27215 !!options
27216 parsoid=wt2wt,wt2html
27217 !! wikitext
27218 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
27219 !! html/parsoid
27220 <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>
27221 <tbody>
27222 <tr>
27223 <td>bar</td>
27224 </tr>
27225 </tbody>
27226 </table>
27227 !!end
27228
27229 !!test
27230 2. Encapsulate foster-parented transclusion content
27231 !!options
27232 parsoid=wt2wt,wt2html
27233 !! wikitext
27234 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
27235 !! html/parsoid
27236 <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>
27237 <table>
27238 <tbody>
27239 <tr>
27240 <td>bar</td>
27241 </tr>
27242 </tbody>
27243 </table>
27244 !!end
27245
27246 !!test
27247 3. Encapsulate foster-parented transclusion content
27248 !!options
27249 parsoid=wt2wt,wt2html
27250 !! wikitext
27251 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
27252 !! html/parsoid
27253 <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;]}">
27254 <p>foo</p>
27255 </div>
27256 <table>
27257 <tbody>
27258 <tr>
27259 <td>bar</td>
27260 </tr>
27261 </tbody>
27262 </table>
27263 !!end
27264
27265 !!test
27266 4. Encapsulate foster-parented transclusion content
27267 !!options
27268 parsoid=wt2wt,wt2html
27269 !! wikitext
27270 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
27271 !! html/parsoid
27272 <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;]}">
27273 <p>foo</p>
27274 </div>
27275 <table>
27276 <tbody>
27277 <tr>
27278 <td>bar</td>
27279 </tr>
27280 </tbody>
27281 </table>
27282 !!end
27283
27284 !!test
27285 5. Encapsulate foster-parented transclusion content
27286 !!options
27287 parsoid=wt2wt,wt2html
27288 !! wikitext
27289 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
27290 !! html/parsoid
27291 <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>
27292 <table>
27293 <tbody>
27294 <tr>
27295 <td>
27296 <div>
27297 <p>foo</p>
27298 </div>
27299 </td>
27300 </tr>
27301 </tbody>
27302 </table>
27303 !!end
27304
27305 !!test
27306 6. Encapsulate foster-parented transclusion content
27307 !!options
27308 parsoid=wt2wt,wt2html
27309 !! wikitext
27310 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
27311 !! html/parsoid
27312 <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>
27313 <table>
27314 <tbody>
27315 <tr>
27316 <td>
27317 <div>
27318 <p>foo</p>
27319 </div>
27320 </td>
27321 </tr>
27322 </tbody>
27323 </table>
27324 <p>ok</p>
27325 !!end
27326
27327 !!test
27328 7. Encapsulate foster-parented transclusion content
27329 !!options
27330 parsoid=wt2wt,wt2html
27331 !! wikitext
27332 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
27333 !! html/parsoid
27334 <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>
27335 <table>
27336 <tbody>
27337 <tr>
27338 <td>bar</td>
27339 </tr>
27340 </tbody>
27341 </table>
27342 !!end
27343
27344 # Note that the wt is broken on purpose: the = should be {{=}} if you
27345 # don't want it to be a template parameter key.
27346 !!test
27347 8. Encapsulate foster-parented transclusion content
27348 !!options
27349 parsoid=wt2wt,wt2html
27350 !! wikitext
27351 {{echo|a
27352 }}{|{{echo|style='color:red'}}
27353 |-
27354 |b
27355 |}
27356 !! html/parsoid
27357 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}'>a</p>
27358 <span> </span>
27359 <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>
27360 <table>
27361 <tbody>
27362 <tr>
27363 <td>b</td>
27364 </tr>
27365 </tbody>
27366 </table>
27367 !!end
27368
27369 !!test
27370 9. Encapsulate foster-parented transclusion content
27371 !!options
27372 parsoid=wt2wt,wt2html
27373 !! wikitext
27374 <table>{{echo|hi</table>hello}}
27375 !! html/parsoid
27376 <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>
27377 !!end
27378
27379 !!test
27380 Table in fosterable position
27381 !!options
27382 parsoid=wt2html
27383 !! wikitext
27384 {{OpenTable}}
27385 <div>
27386 {|
27387 |}
27388 </div>
27389 |}
27390 !! html/parsoid
27391 <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">
27392 </span>
27393 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
27394
27395 <table>
27396 </table>
27397 !!end
27398
27399 # Parsoid only for T66747
27400 !! test
27401 Properly encapsulate empty-content transclusions in fosterable positions
27402 !! wikitext
27403 <table>
27404 {{#if:|
27405 <td>foo</td>
27406 }}
27407 </table>
27408 !! html/parsoid
27409 <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"}]]}'>
27410
27411 </table>
27412 !! end
27413
27414 !! test
27415 Always encapsulate foster box when template range is expanded to table
27416 !! options
27417 parsoid=wt2wt
27418 !! wikitext
27419 {|
27420 hello
27421 {{OpenTable}}
27422 |}
27423 !! html/parsoid
27424
27425 !! end
27426
27427 !! test
27428 T115289: Unclosed table
27429 !! wikitext
27430 {{echo|<table>}}<!--c-->[[Category:Two]]
27431 !! html/parsoid
27432 <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>
27433 !! end
27434
27435 !! test
27436 T115289: Don't migrate newlines out of tables with fostered content
27437 !! wikitext
27438 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
27439 !! html/parsoid
27440 <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>
27441 !! end
27442
27443 !! test
27444 T73074: More fostering fun
27445 !! wikitext
27446 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
27447 !! html/parsoid
27448 <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>
27449 !! end
27450
27451 !!test
27452 Support <object> element with .data attribute
27453 !!options
27454 parsoid=html2wt
27455 !! html/parsoid
27456 <object data="test.swf"></object>
27457 !! wikitext
27458 <object data="test.swf"></object>
27459 !!end
27460
27461 !! test
27462 Don't block XML namespace declaration
27463 !! wikitext
27464 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27465 !! html/php
27466 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27467 </p>
27468 !! html/parsoid
27469 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
27470 !! end
27471
27472 # -----------------------------------------------------------------
27473 # The following section of tests are primarily to spec requirements
27474 # around Parsoid's serialization (old, new, edited content)
27475 #
27476 # All these tests are marked Parsoid html2wt and html2html only
27477 # ----------------------------------------------------------------
27478
27479 !! test
27480 Ignore rel attribute in a-tags during serialization to url-links
27481 !! options
27482 parsoid=html2wt
27483 !! html/parsoid
27484 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
27485 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
27486 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
27487 !! wikitext
27488 http://en.wikipedia.org/wiki/Foobar
27489 http://en.wikipedia.org/wiki/Foobar
27490 http://en.wikipedia.org/wiki/Foobar
27491 !! end
27492
27493 # 'mi' is a localinterwiki prefix as well as a language
27494 !! test
27495 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
27496 !! options
27497 parsoid=html2wt
27498 !! html/parsoid
27499 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
27500 !! wikitext
27501 [[Foo]]
27502 !! end
27503
27504 !! test
27505 Parsoid should accept interwiki shortcuts
27506 !! options
27507 parsoid=html2wt
27508 !! html/parsoid
27509 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
27510 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
27511 <a href='./fr:Foo'>Foo</a></p>
27512 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
27513 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
27514 <a href='fr%3AFoo'>Foo</a></p>
27515 <p><a href='FR%3AFoo'>Foo</a>
27516 <a href='./FR:Foo'>Foo</a></p>
27517 !! wikitext
27518 [[:fr:Foo|Foo]]
27519 [[:fr:Foo|Foo]]
27520 [[:fr:Foo|Foo]]
27521
27522 [[:fr:Foo|Foo]]
27523 [[:fr:Foo|Foo]]
27524 [[:fr:Foo|Foo]]
27525
27526 [[:fr:Foo|Foo]]
27527 [[:fr:Foo|Foo]]
27528 !! end
27529
27530 !! test
27531 Parsoid should not accept invalid interwiki shortcuts
27532 !! options
27533 parsoid=html2wt
27534 !! html/parsoid
27535 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
27536 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
27537 <a href='news:Foo'>Foo</a></p>
27538 !! wikitext
27539 [news:Foo Foo]
27540 [news:Foo Foo]
27541 [news:Foo Foo]
27542 !! end
27543
27544 # See T93839
27545 !! test
27546 New wikilinks should be serialized properly
27547 !! options
27548 parsoid=html2wt
27549 !! html/parsoid
27550 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
27551 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
27552 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
27553 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
27554 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
27555 !! wikitext
27556 [[Foo]]
27557 [[Foo]]
27558 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
27559 http://en.wikipedia.org/wiki/Foo
27560 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
27561 !! end
27562
27563 !! test
27564 New wiki links (href variations)
27565 !! options
27566 parsoid=html2wt
27567 !! html/parsoid
27568 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27569 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
27570 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
27571 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
27572 !! wikitext
27573 [[Foo_bar]]
27574 [[Foo_bar]]
27575 [[Foo_bar]]
27576 [[Toxine bactérienne]]
27577 !! end
27578
27579 !! test
27580 New wiki links (content string variations)
27581 !! options
27582 parsoid=html2wt
27583 !! html/parsoid
27584 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27585 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
27586 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
27587 !! wikitext
27588 [[Foo_bar]]
27589 [[Foo bar]]
27590 [[Foo_bar|./Foo_bar]]
27591 !! end
27592
27593 !! test
27594 New category links (href variations)
27595 !! options
27596 parsoid=html2wt
27597 !! html/parsoid
27598 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
27599 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
27600 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
27601 !! wikitext
27602 [[Category:Toxine bactérienne]]
27603 [[Category:Toxine bactérienne]]
27604 [[Category:Toxine bactérienne]]
27605 !! end
27606
27607 !! test
27608 New sol transparent links don't need indent-pre nowiki protection
27609 !! options
27610 parsoid=html2wt
27611 language=de
27612 !! html/parsoid
27613 <link rel="mw:PageProp/redirect" href="./Main_Page">
27614 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
27615 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
27616 !! wikitext
27617 #WEITERLEITUNG [[Main Page]]
27618 <!-- this is good --> [[Category:Good]]
27619 <!-- this is great --> [[Kategorie:Great]]
27620 !! end
27621
27622 !! test
27623 New interlanguage links (href variations)
27624 !! options
27625 parsoid=html2wt
27626 !! html/parsoid
27627 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
27628 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
27629 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
27630 !! wikitext
27631 [[es:Toxine bactérienne]]
27632 [[es:Toxine_bactérienne]]
27633 [[es:Toxine_bactérienne]]
27634 !! end
27635
27636 !! test
27637 Image: Modifying size of an image (1)
27638 !! options
27639 parsoid={
27640 "modes": ["wt2wt"],
27641 "changes": [
27642 ["img[height]", "attr", "height", "22"],
27643 ["img[width]", "attr", "width", "200"]
27644 ]
27645 }
27646 !! wikitext
27647 [[Image:Foobar.jpg|230x230px]]
27648 !! wikitext/edited
27649 [[Image:Foobar.jpg|200x200px]]
27650 !!end
27651
27652 !! test
27653 Image: Modifying size of an image (2)
27654 !! options
27655 parsoid={
27656 "modes": ["wt2wt"],
27657 "changes": [
27658 ["img[height]", "attr", "height", "100"],
27659 ["img[width]", "attr", "width", "500"]
27660 ]
27661 }
27662 !! wikitext
27663 [[Image:Foobar.jpg|230x230px]]
27664 !! wikitext/edited
27665 [[Image:Foobar.jpg|500x500px]]
27666 !!end
27667
27668 # Change in size is ignored so long as class='mw-default-size'
27669 !! test
27670 Image: Modifying size of an image (3)
27671 !! options
27672 parsoid={
27673 "modes": ["wt2wt"],
27674 "changes": [
27675 ["figure[class]", "removeClass", "mw-default-size"],
27676 ["figure img", "attr", "height", "19"],
27677 ["figure img", "attr", "width", "170"]
27678 ]
27679 }
27680 !! wikitext
27681 [[Image:Foobar.jpg|thumb]]
27682 !! wikitext/edited
27683 [[Image:Foobar.jpg|thumb|170x170px]]
27684 !!end
27685
27686 !! test
27687 Image: Modifying alignment of an image (T50665)
27688 !! options
27689 parsoid={
27690 "modes": ["wt2wt"],
27691 "changes": [
27692 ["figure[class]", "removeClass", "mw-halign-right"],
27693 ["figure[class]", "addClass", "mw-halign-left"]
27694 ]
27695 }
27696 !! wikitext
27697 [[Image:Foobar.jpg|thumb|caption|right]]
27698 !! wikitext/edited
27699 [[Image:Foobar.jpg|thumb|caption|left]]
27700 !! end
27701
27702 !! test
27703 Image: Modifying mw-default-size of an frameless image (T64805)
27704 !! options
27705 parsoid={
27706 "modes": ["wt2wt"],
27707 "changes": [
27708 ["figure.mw-default-size", "removeClass", "mw-default-size"]
27709 ]
27710 }
27711 !! wikitext
27712 [[Image:Foobar.jpg|frameless|right]]
27713 !! wikitext/edited
27714 [[Image:Foobar.jpg|frameless|right|220x220px]]
27715 !! end
27716
27717 !! test
27718 Image: Modifying valign of an image (T51221)
27719 !! options
27720 parsoid={
27721 "modes": ["wt2wt"],
27722 "changes": [
27723 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
27724 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
27725 ]
27726 }
27727 !! wikitext
27728 [[File:Foobar.jpg|20px|middle]]
27729 !! wikitext/edited
27730 [[File:Foobar.jpg|20px|text-top]]
27731 !! end
27732
27733 !! test
27734 Image: Modifying alt attribute of an image (T58400)
27735 !! options
27736 parsoid={
27737 "modes": ["wt2wt"],
27738 "changes": [
27739 ["img[alt]", "attr", "alt", "some alternate edited text"]
27740 ]
27741 }
27742 !! wikitext
27743 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
27744 !! wikitext/edited
27745 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
27746 !!end
27747
27748 !! test
27749 Image: Modifying caption of an image
27750 !! options
27751 parsoid={
27752 "modes": ["wt2wt"],
27753 "changes": [
27754 ["figcaption", "text", "new caption"]
27755 ]
27756 }
27757 !! wikitext
27758 [[Image:Foobar.jpg|thumb|original caption]]
27759 !! wikitext/edited
27760 [[Image:Foobar.jpg|thumb|new caption]]
27761 !!end
27762
27763 !! test
27764 Image: empty alt attribute (T50924)
27765 !! options
27766 parsoid
27767 !! wikitext
27768 [[File:Foobar.jpg|thumb|alt=|bar]]
27769 !! html
27770 <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>
27771 !! end
27772
27773 !! test
27774 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
27775 !! options
27776 parsoid=html2wt
27777 language=ar
27778 disabled
27779 !! html/parsoid
27780 <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>
27781 !! wikitext
27782 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
27783 !! end
27784
27785 !! test
27786 Image: Block level image should have \n before and after
27787 !! wikitext
27788 123
27789 [[File:Foobar.jpg|right|thumb|150x150px]]
27790 456
27791 !! html/parsoid
27792 <p>123</p>
27793 <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>
27794 <p>456</p>
27795 !! end
27796
27797 !! test
27798 Image: New block level image should have \n before and after (existing content)
27799 !! wikitext
27800 123
27801 [[File:Foobar.jpg|right|thumb|150x150px]]
27802 456
27803 !! html/parsoid
27804 <p>123</p>
27805 <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>
27806 <p>456</p>
27807 !! end
27808
27809 !! test
27810 Image: upright option (parsoid)
27811 !! wikitext
27812 [[File:Foobar.jpg|thumb|upright|caption]]
27813 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
27814 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
27815 !! html/parsoid
27816 <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>
27817 <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>
27818 <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>
27819 !! end
27820
27821 !! test
27822 Image: upright option is ignored on inline and frame images (parsoid)
27823 !! wikitext
27824 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
27825 !! html/parsoid
27826 <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>
27827 !! end
27828
27829 !! test
27830 Image: in template parameter with empty parameter
27831 !! wikitext
27832 {{echo|[[File:Foobar.jpg|link=]]}}
27833 !! html/parsoid
27834 <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>
27835 !! end
27836
27837 !! test
27838 Image: from basic HTML (1)
27839 !! options
27840 parsoid=html2wt
27841 !! html/parsoid
27842 <span typeof="mw:Image">
27843 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27844 </span>
27845 !! wikitext
27846 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27847 !! end
27848
27849 !! test
27850 Image: from basic HTML (2)
27851 !! options
27852 parsoid=html2wt
27853 !! html/parsoid
27854 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27855 !! wikitext
27856 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27857 !! end
27858
27859 !! test
27860 Image: from basic HTML (3)
27861 !! options
27862 parsoid=html2wt
27863 !! html/parsoid
27864 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
27865 !! wikitext
27866 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
27867 !! end
27868
27869 !! test
27870 Image: from basic HTML (4)
27871 !! options
27872 parsoid=html2wt
27873 !! html/parsoid
27874 <img src="./File:Foobar.jpg">
27875 !! wikitext
27876 [[File:Foobar.jpg|link=]]
27877 !! end
27878
27879 !! test
27880 Image: Invalid title as link
27881 !! wikitext
27882 [[File:Foobar.jpg|link=<]]
27883 !! html/php
27884 <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>
27885 </p>
27886 !! html/parsoid
27887 <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>
27888 !! end
27889
27890 !! test
27891 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
27892 !! options
27893 parsoid=html2wt
27894 !! html/parsoid
27895 <ul>
27896 <li><p>foo</p></li>
27897 </ul>
27898 !! wikitext
27899 * foo
27900 !! end
27901
27902 !! test
27903 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
27904 !! options
27905 parsoid=html2wt
27906 !! html/parsoid
27907 <ul> <li>foo</li></ul>
27908 !! wikitext
27909 * foo
27910 !! end
27911
27912 !! test
27913 Don't strip leading whitespace when handling indent-pre suppressing tags
27914 !! options
27915 parsoid=html2wt
27916 !! html/parsoid
27917 <table>
27918 <tr><td> indented row</td></tr>
27919 </table>
27920 <blockquote><p>
27921 <b>This is very bold of you!</b>
27922 </p>
27923 <table><tr><td>
27924 indented cell (no pre-wrapping!)
27925 </td></tr></table>
27926 </blockquote>
27927 <p>foo</p>
27928 <div>bar</div>
27929 !! wikitext
27930 {|
27931 | indented row
27932 |}
27933 <blockquote>
27934 '''This is very bold of you!'''
27935
27936 {|
27937 |
27938 indented cell (no pre-wrapping!)
27939 |}
27940 </blockquote>
27941 foo
27942 <div>bar</div>
27943 !! end
27944
27945 !! test
27946 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
27947 !! options
27948 parsoid=html2wt
27949 !! html/parsoid
27950 <p>foo</p>
27951 <span>bar</span>
27952
27953 <span>foo2
27954 </span>bar2
27955
27956 <div>foo</div>
27957 <span>bar</span>
27958
27959 <div>
27960 <span>foo</span>
27961 </div>
27962 !! wikitext
27963 foo
27964
27965 <span>bar</span>
27966
27967 <span>foo2
27968 <nowiki> </nowiki></span>bar2
27969
27970 <div>foo</div>
27971 <nowiki> </nowiki><span>bar</span>
27972
27973 <div>
27974 <nowiki> </nowiki><span>foo</span>
27975 </div>
27976 !! end
27977
27978 !! test
27979 Lists: Dont insert newlines in a serialized list item.
27980 !! options
27981 parsoid=html2wt
27982 !! html/parsoid
27983 <ul><li>a<br>b</li><li>c</li></ul>
27984 !! wikitext
27985 * a<br>b
27986 * c
27987 !! end
27988
27989 !! test
27990 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
27991 !! options
27992 parsoid={
27993 "modes": ["html2wt"],
27994 "scrubWikitext": false
27995 }
27996 !! html/parsoid
27997 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
27998 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
27999
28000 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
28001 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
28002
28003 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
28004
28005 <h2><meta property="mw:PageProp/toc" /> ok</h2>
28006 !! wikitext
28007 == hello there [[Category:A1]] ==
28008
28009 == [[Category:A2]] hi pal ==
28010
28011 == <!--foo--> [[Category:A3]] how goes it ==
28012
28013 == it goes well [[Category:A4]] <!--bar--> ==
28014
28015 ==howdy [[Category:A5]]==
28016
28017 == __TOC__ ok ==
28018 !! end
28019
28020 !! test
28021 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
28022 !! options
28023 parsoid={
28024 "modes": ["html2wt"],
28025 "scrubWikitext": true
28026 }
28027 !! html/parsoid
28028 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
28029 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
28030
28031 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
28032 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
28033
28034 <h2><meta property="mw:PageProp/toc" /> ok</h2>
28035 !! wikitext
28036 == hello there ==
28037 [[Category:A1]]
28038 [[Category:A2]]
28039
28040 == hi pal ==
28041
28042 <!--foo--> [[Category:A3]]
28043
28044 == how goes it ==
28045
28046 == it goes well ==
28047 [[Category:A4]] <!--bar-->
28048
28049 __TOC__
28050
28051 == ok ==
28052 !! end
28053
28054 !! test
28055 Headings: Don't hoist metas that come from templates
28056 !! options
28057 parsoid={
28058 "modes": ["html2wt"],
28059 "scrubWikitext": true
28060 }
28061 !! html/parsoid
28062 <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>
28063 !! wikitext
28064 == {{echo|foo [[Category:Foo]]}} ==
28065 !! end
28066
28067 !! test
28068 Headings: Category in ref isn't hoisted
28069 !! options
28070 parsoid={
28071 "modes": ["html2wt"],
28072 "scrubWikitext": true
28073 }
28074 !! html/parsoid
28075 <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>
28076
28077 <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>
28078 !! wikitext
28079 == foo <ref>bar
28080 [[Category:Baz]] </ref> ==
28081
28082 <references />
28083 !! end
28084
28085 !! test
28086 Parsoid: Serialize positional parameters with = in them as named parameter
28087 !! options
28088 parsoid=html2wt
28089 !! html/parsoid
28090 <p about="#mwt1" typeof="mw:Transclusion"
28091 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
28092
28093 <p about="#mwt1" typeof="mw:Transclusion"
28094 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
28095
28096 <!--Orig params with data-parsoid has heuristics for handling = chars-->
28097 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
28098 <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>
28099 !! wikitext
28100 {{echo|1=f=oo}}
28101
28102 {{echo|1=f=oo|2=bar}}
28103
28104 <!--Orig params with data-parsoid has heuristics for handling = chars-->
28105 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
28106 {{echo|<nowiki>f=oo</nowiki>|bar}}
28107 !! end
28108
28109 !! test
28110 Parsoid: Serialize positional parameters with = in extlink as named parameter
28111 !! options
28112 parsoid=html2wt
28113 !! html/parsoid
28114 <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>
28115 !! wikitext
28116 {{echo|1=http://stuff?is=ok}}
28117 !! end
28118
28119 !! test
28120 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
28121 !! options
28122 parsoid=html2wt
28123 !! html/parsoid
28124 <div>a<p>b</p></div>
28125 <div>a
28126 <p>b</p></div>
28127 <div>
28128 a
28129 <p>b</p></div>
28130 !! wikitext
28131 <div>a
28132 b
28133 </div>
28134 <div>a
28135 b
28136 </div>
28137 <div>
28138 a
28139
28140 b
28141 </div>
28142 !! end
28143
28144 !! test
28145 Substrings resembling wikitext in hrefs should not get nowiki escapes
28146 !! options
28147 parsoid=html2wt
28148 !! html/parsoid
28149 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
28150 !! wikitext
28151 [[Foo''bar''baz]]
28152 !! end
28153
28154 !! test
28155 Enforce single-line context in the serializer
28156 !! options
28157 parsoid=html2wt
28158 !! html/parsoid
28159 <h2>testing
28160 123</h2>
28161
28162 <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">
28163 </span><span about="#mwt1">you</span> </h2>
28164
28165 <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>
28166
28167 <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
28168 there</span></li></ol>
28169
28170 <ul><li>asd
28171 sdf</li></ul>
28172
28173 <ul><li>foo
28174 bar
28175 baz</li>
28176 <li>foo <b>bar</b>
28177 baz</li></ul>
28178
28179 <dl><dt>hi
28180 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
28181 ho</dd></dl>
28182
28183 <dl><dd> <table>
28184 <tbody><tr><td> ha
28185 ha
28186 ha</td></tr>
28187 </tbody></table></dd></dl>
28188 !! wikitext
28189 == testing 123 ==
28190
28191 == hi {{bogus|there
28192 you}} ==
28193
28194 == foo <ref>hello
28195 there</ref> ==
28196
28197 <references />
28198
28199 * asd sdf
28200
28201 * foo bar baz
28202 * foo '''bar''' baz
28203
28204 ; hi ho : hi ho
28205
28206 : {|
28207 | ha
28208 ha
28209 ha
28210 |}
28211 !! end
28212
28213 !! test
28214 Serialize new placeholder space without spans
28215 !! options
28216 parsoid=html2wt
28217 !! html/parsoid
28218 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
28219
28220 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
28221
28222 <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>
28223 !! wikitext
28224 foo : bar
28225
28226 foo : bar
28227
28228 <ref>foo : bar</ref>ok
28229 !! end
28230
28231
28232 #-----------------------
28233 # Tag minimization tests
28234 #-----------------------
28235
28236 !! test
28237 1. I/B quote minimization: wikitext-only tags should be combined
28238 !! options
28239 parsoid=html2wt
28240 !! html/parsoid
28241 <p><i>A</i><i>B</i></p>
28242 <p><b>A</b><b>B</b></p>
28243 <p><i>A</i><b><i>B</i></b></p>
28244 <p><b>A</b><i><b>B</b></i></p>
28245 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
28246 <p><i><b>A</b></i><i><b>B</b></i></p>
28247 <p><i><b>A</b></i><b><i>B</i></b></p>
28248 <p><b><i>A</i></b><i><b>B</b></i></p>
28249 !! wikitext
28250 ''AB''
28251
28252 '''AB'''
28253
28254 ''A'''B'''''
28255
28256 '''A''B'''''
28257
28258 '''A''BC''D'''
28259
28260 '''''AB'''''
28261
28262 '''''AB'''''
28263
28264 '''''AB'''''
28265 !! end
28266
28267 !! test
28268 2. I/B quote minimization: wikitext and html tags should not be combined
28269 !! options
28270 parsoid=html2wt
28271 !! html/parsoid
28272 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
28273 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
28274 !! wikitext
28275 ''A''<i>B</i>
28276
28277 ''A''<nowiki/>'''<i>B</i>'''
28278 !! end
28279
28280 !! test
28281 3. I/B quote minimization: templated content stops minimization
28282 !! options
28283 parsoid=html2wt
28284 !! html/parsoid
28285 <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>
28286 <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>
28287 !! wikitext
28288 ''A''{{echo|''B''}}
28289
28290 ''A''{{echo|'''''B'''''}}
28291 !! end
28292
28293 !! test
28294 4. I/B quote minimization: new content should be mimimized with adjacent old content
28295 !! options
28296 parsoid=html2wt
28297 !! html/parsoid
28298 <p><i>A</i><i>B</i></p>
28299 <p><b>A</b><b>B</b></p>
28300 <p><i>A</i><b><i>B</i></b></p>
28301 !! wikitext
28302 ''AB''
28303
28304 '''AB'''
28305
28306 ''A'''B'''''
28307 !! end
28308
28309 !! test
28310 5a. Merge adjacent quote nodes if they've been edited
28311 !! options
28312 parsoid={
28313 "modes": ["wt2wt", "selser"],
28314 "changes": [
28315 ["p", "contents", "remove", ":contains('b')"]
28316 ]
28317 }
28318 !! wikitext
28319 ''a''b''c''
28320 !! wikitext/edited
28321 ''ac''
28322 !! end
28323
28324 !! test
28325 5b. Merge adjacent quote nodes if they've been edited
28326 !! options
28327 parsoid={
28328 "modes": ["wt2wt", "selser"],
28329 "changes": [
28330 ["#x", "remove"]
28331 ]
28332 }
28333 !! wikitext
28334 ''a''<span id="x">b</span>''c''
28335 !! wikitext/edited
28336 ''ac''
28337 !! end
28338
28339 !! test
28340 1. Merge adjacent link nodes as long as at least one element is new
28341 !! options
28342 parsoid={
28343 "modes": ["html2wt"],
28344 "scrubWikitext": true
28345 }
28346 !! html/parsoid
28347 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28348 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28349 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
28350 !! wikitext
28351 [[Football]]
28352 [[Football]]
28353 [[Football|Foot]][[Football|ball]]
28354 !! end
28355
28356 !! test
28357 2. Merge adjacent link nodes and enable additional normalizations
28358 !! options
28359 parsoid={
28360 "modes": ["html2wt"],
28361 "scrubWikitext": true
28362 }
28363 !! html/parsoid
28364 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
28365 !! wikitext
28366 [[Football|''Football'']]
28367 !! end
28368
28369 !! test
28370 3. Don't merge adjacent link nodes if scrubWikitext is false
28371 !! options
28372 parsoid={
28373 "modes": ["html2wt"],
28374 "scrubWikitext": false
28375 }
28376 !! html/parsoid
28377 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28378 !! wikitext
28379 [[Football|Foot]][[Football|ball]]
28380 !! end
28381
28382 #------------------------------
28383 # End of tag minimization tests
28384 #------------------------------
28385
28386 !!test
28387 T56262: New entities
28388 !! options
28389 parsoid=html2wt
28390 !! html/parsoid
28391 <span typeof="mw:Entity">&nbsp;</span>
28392 !! wikitext
28393 &nbsp;
28394 !! end
28395
28396 ## Note that there is no wikitext output for 'unknownproperty' ##
28397 ## Unknown magic words are silently dropped ##
28398
28399 !! test
28400 Magic words
28401 !! options
28402 parsoid=html2wt
28403 !! html/parsoid
28404 <meta property='mw:PageProp/toc' />
28405 <meta property='mw:PageProp/notoc' />
28406 <meta property='mw:PageProp/forcetoc' />
28407 <meta property='mw:PageProp/index' />
28408 <meta property='mw:PageProp/noindex' />
28409 <meta property='mw:PageProp/nogallery' />
28410 <meta property='mw:PageProp/noeditsection' />
28411 <meta property='mw:PageProp/notitleconvert' />
28412 <meta property='mw:PageProp/nocontentconvert' />
28413 <meta property='mw:PageProp/unknownproperty' />
28414 !! wikitext
28415 __TOC__
28416 __NOTOC__
28417 __FORCETOC__
28418 __INDEX__
28419 __NOINDEX__
28420 __NOGALLERY__
28421 __NOEDITSECTION__
28422 __NOTITLECONVERT__
28423 __NOCONTENTCONVERT__
28424 !! end
28425
28426 !! test
28427 Consecutive <pre>s should not get merged
28428 !! options
28429 parsoid=html2wt,html2html
28430 !! html/parsoid
28431 <pre>a</pre><pre>b</pre>
28432
28433 <pre>c
28434 </pre><pre>
28435 d</pre>
28436
28437 <pre>e
28438
28439 </pre><pre>
28440
28441 f</pre>
28442 !! wikitext
28443 a
28444
28445 b
28446
28447 c
28448
28449 d
28450
28451 e
28452
28453
28454
28455 f
28456 !! end
28457
28458 !! test
28459 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
28460 !! options
28461 parsoid=html2wt
28462 !! html/parsoid
28463 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
28464 !! wikitext
28465 [[Special:BookSources/1234567890|ISBN 1234567895]]
28466 !! end
28467
28468 !! test
28469 Edited RFC links not serializable as RFC links should serialize as extlinks
28470 !! options
28471 parsoid=html2wt
28472 !! html/parsoid
28473 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
28474 !! wikitext
28475 [https://tools.ietf.org/html/rfc123 New RFC]
28476 !! end
28477
28478 !! test
28479 Edited PMID links not serializable as PMID links should serialize as extlinks
28480 !! options
28481 parsoid=html2wt
28482 !! html/parsoid
28483 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
28484 !! wikitext
28485 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
28486 !! end
28487
28488 !! test
28489 WTS of autolinks with trailing/surrounding context
28490 !! options
28491 parsoid=html2wt
28492 !! html/parsoid
28493 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
28494 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
28495 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
28496 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
28497 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
28498 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
28499 !! wikitext
28500 http://cscott.net'''foo'''
28501
28502 http://cscott.net<b>foo</b>
28503
28504 '''http://cscott.net'''
28505
28506 '''http://cscott.net '''
28507
28508 '''http://cscott.net<nowiki/>x'''
28509
28510 http://cscott.net<nowiki/>x
28511 !! end
28512
28513 !! test
28514 WTS of autolinks with nowikis (round-trip)
28515 !! wikitext
28516 x<nowiki/>http://cscott.net<nowiki/>x
28517 !! html/parsoid
28518 <p>x<a rel="mw:ExtLink" href="http://cscott.net">http://cscott.net</a>x</p>
28519 !! end
28520
28521 # this is the "easy" test because it leaves in place all the
28522 # data-parsoid information indicating this is an autolink
28523 !! test
28524 WTS of autolinks with escapes (editing)
28525 !! options
28526 parsoid={
28527 "modes": ["wt2wt"],
28528 "changes": [
28529 [ "span", "remove" ]
28530 ]
28531 }
28532 !! wikitext
28533 x<nowiki/>http://cscott.net<nowiki/>x
28534 !! wikitext/edited
28535 x<nowiki/>http://cscott.net<nowiki/>x
28536 !! end
28537
28538 !! test
28539 WTS of edited autolink-like text (T103364)
28540 !! options
28541 parsoid={
28542 "modes": ["wt2wt"],
28543 "changes": [
28544 [ "span[typeof]", "removeAttr", "typeof" ]
28545 ]
28546 }
28547 !! wikitext
28548 Not a link: <nowiki>http://example.com</nowiki>.
28549 !! wikitext/edited
28550 Not a link: <span><nowiki>http://example.com</nowiki></span>.
28551 !! end
28552
28553 !! test
28554 WTS of newly-authored autolink-like text (T103364)
28555 !! options
28556 parsoid=html2wt
28557 !! html/parsoid
28558 <p>http://example.com is not a link.</p>
28559 !! wikitext
28560 <nowiki>http://example.com</nowiki> is not a link.
28561 !! end
28562
28563 !! test
28564 WTS of autolink-like text after an autolink (T108563)
28565 !! options
28566 parsoid=html2wt
28567 !! html/parsoid
28568 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
28569 !! wikitext
28570 http://example.com <nowiki>http://example.com</nowiki> is not a link.
28571 !! end
28572
28573 !! test
28574 Magic links inside links (not autolinked)
28575 !! wikitext
28576 [[Foo|http://example.com]]
28577 [[Foo|RFC 1234]]
28578 [[Foo|PMID 1234]]
28579 [[Foo|ISBN 123456789x]]
28580
28581 [http://foo.com http://example.com]
28582 [http://foo.com RFC 1234]
28583 [http://foo.com PMID 1234]
28584 [http://foo.com ISBN 123456789x]
28585 !! html+tidy
28586 <p><a href="/wiki/Foo" title="Foo">http://example.com</a> <a href="/wiki/Foo" title="Foo">RFC 1234</a> <a href="/wiki/Foo" title="Foo">PMID 1234</a> <a href="/wiki/Foo" title="Foo">ISBN 123456789x</a></p>
28587 <p><a rel="nofollow" class="external text" href="http://foo.com">http://example.com</a> <a rel="nofollow" class="external text" href="http://foo.com">RFC 1234</a> <a rel="nofollow" class="external text" href="http://foo.com">PMID 1234</a> <a rel="nofollow" class="external text" href="http://foo.com">ISBN 123456789x</a></p>
28588 !! html/parsoid
28589 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
28590 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
28591 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
28592 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
28593
28594 <p><a rel="mw:ExtLink" href="http://foo.com">http://example.com</a>
28595 <a rel="mw:ExtLink" href="http://foo.com">RFC 1234</a>
28596 <a rel="mw:ExtLink" href="http://foo.com">PMID 1234</a>
28597 <a rel="mw:ExtLink" href="http://foo.com">ISBN 123456789x</a></p>
28598 !! end
28599
28600 !! test
28601 Magic links inside image captions (autolinked)
28602 !! wikitext
28603 [[File:Foobar.jpg|thumb|http://example.com]]
28604 [[File:Foobar.jpg|thumb|RFC 1234]]
28605 [[File:Foobar.jpg|thumb|PMID 1234]]
28606 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
28607 !! html+tidy
28608 <div class="thumb tright">
28609 <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>
28610 <div class="thumbcaption">
28611 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28612 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div>
28613 </div>
28614 </div>
28615 <div class="thumb tright">
28616 <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>
28617 <div class="thumbcaption">
28618 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28619 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a></div>
28620 </div>
28621 </div>
28622 <div class="thumb tright">
28623 <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>
28624 <div class="thumbcaption">
28625 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28626 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a></div>
28627 </div>
28628 </div>
28629 <div class="thumb tright">
28630 <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>
28631 <div class="thumbcaption">
28632 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28633 <a href="/wiki/Special:BookSources/123456789X" class="internal mw-magiclink-isbn">ISBN 123456789x</a></div>
28634 </div>
28635 </div>
28636 !! html/parsoid
28637 <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>
28638 <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>
28639 <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>
28640 <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>
28641 !! end
28642
28643 !! test
28644 WTS of magic word text (T109371)
28645 !! options
28646 parsoid=html2wt
28647 !! html/parsoid
28648 <p>RFC 1234</p>
28649 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
28650 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
28651 !! wikitext
28652 <nowiki>RFC 1234</nowiki>
28653
28654 [http://foo.com RFC 1234]
28655
28656 [[Foo|RFC 1234]]
28657 !! end
28658
28659 !! test
28660 Edited Redirect link should emit a non-piped wikitext link
28661 !! options
28662 parsoid=html2wt
28663 !! html/parsoid
28664 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
28665 !! wikitext
28666 #REDIRECT [[Bar]]
28667 !! end
28668
28669 !! test
28670 T75121: Infer extension name from typeOf if data-mw is not present
28671 !! options
28672 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28673 !! html/parsoid
28674 <div typeOf="mw:Extension/foo"></div>
28675 !! wikitext
28676 <foo />
28677 !! end
28678
28679 # Note that the <p> wrapping isn't present in PHP parser output
28680 # The important thing for this test is that P-wrapping doesn't
28681 # interfere with the <nowiki> protection for leading - in <td>
28682 # (which isn't necessary for <th>).
28683 !! test
28684 T88318: p-wrapped dash in table.
28685 !! options
28686 parsoid=html2wt,wt2wt
28687 !! html/parsoid
28688 <table><tbody>
28689 <tr><th><p>-</p></th><th><p>- </p></th></tr>
28690 <tr><td><p>-</p></td><td><p>- </p></td></tr>
28691 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
28692 </tbody></table>
28693 !! wikitext
28694 {|
28695 !-
28696 !-
28697 |-
28698 |<nowiki>-</nowiki>
28699 |<nowiki>- </nowiki>
28700 |-
28701 |<small>-</small>
28702 |<br>
28703 -
28704 |<br>
28705 -
28706 |}
28707 !! html/php+tidy
28708 <table>
28709 <tr>
28710 <th>-</th>
28711 <th>-</th>
28712 </tr>
28713 <tr>
28714 <td>-</td>
28715 <td>-</td>
28716 </tr>
28717 <tr>
28718 <td><small>-</small></td>
28719 <td><br />
28720 <p>-</p>
28721 </td>
28722 <td><br />
28723 <p>-</p>
28724 </td>
28725 </tr>
28726 </table>
28727 !! end
28728
28729 !! test
28730 T149209: WTS: Handle newlines in table cells properly
28731 !! options
28732 parsoid=html2wt
28733 !! html/parsoid
28734 <table>
28735 <tbody>
28736 <tr><td>a
28737 b
28738 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
28739 <tr><td><p>x</p>
28740 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
28741 </tbody></table>
28742 <table>
28743 <tbody>
28744 <tr><th>a
28745 b
28746 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
28747 <tr><th><p>x</h>
28748 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
28749 </tbody></table>
28750 !! wikitext
28751 {|
28752 |a
28753 b
28754 |c
28755 |-
28756 |x
28757 {{!}}y
28758 |}
28759 {|
28760 !a
28761 b
28762 !c
28763 |-
28764 !x
28765 !y
28766 |}
28767 !! end
28768
28769 !! test
28770 T149209: Selser: Handle newlines in table cells properly
28771 !! options
28772 parsoid={
28773 "modes": ["selser"],
28774 "changes": [
28775 [ "#h1", "html", "a\nb\n" ],
28776 [ "#h2", "html", "a\nb\n" ],
28777 [ "#c1", "html", "a\nb\n" ],
28778 [ "#c2", "html", "<p>a</p>" ],
28779 [ "#c3", "html", "<p>a</p>" ],
28780 [ "#c4", "html", "edit-me<p>a</p>" ]
28781 ]
28782 }
28783 !! wikitext
28784 {|
28785 ! id="h1" |edit-me!!1
28786 |-
28787 ! id="h2" |edit-me||2
28788 |-
28789 | id="c1" |edit-me||3
28790 |-
28791 | id="c2" |edit-me||4
28792 |-
28793 | id="c3" |edit-me||p||q||r
28794 |-
28795 | id="c4" |edit-me||p||q||r
28796 |}
28797 !! wikitext/edited
28798 {|
28799 ! id="h1" |a
28800 b
28801 !1
28802 |-
28803 ! id="h2" |a
28804 b
28805 !2
28806 |-
28807 | id="c1" |a
28808 b
28809 |3
28810 |-
28811 | id="c2" |a
28812 |4
28813 |-
28814 | id="c3" |a
28815 |p||q||r
28816 |-
28817 | id="c4" |edit-me
28818 a
28819 |p||q||r
28820 |}
28821 !! end
28822
28823 !! test
28824 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
28825 !! options
28826 parsoid=html2wt
28827 !! html/parsoid
28828 <table id='mwAb'>
28829 <td id='mwAc'>foo</td>
28830 <td id='serialize-this'>bar</td>
28831 </table>
28832 !! wikitext
28833 {|
28834 |foo
28835 | id="serialize-this" |bar
28836 |}
28837 !! end
28838
28839 !! test
28840 Parsoid-like element ids should not be serialized to wikitext unless shadowed
28841 !! options
28842 parsoid=html2wt
28843 !! html/parsoid
28844 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
28845 !! wikitext
28846 <div id="hello">ok</div>
28847 !! end
28848
28849 !! test
28850 WTS change modes
28851 !! options
28852 parsoid={
28853 "modes": ["wt2wt"],
28854 "changes": [
28855 [ "#xyz", "before", "<b>before</b> stuff " ],
28856 [ "#xyz", "after", " stuff <i>after</i>" ],
28857 [ "#xyz", "html", "x <b>y</b> z" ]
28858 ]
28859 }
28860 !! wikitext
28861 <span id="xyz">hello</span>
28862 !! wikitext/edited
28863 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
28864 !! end
28865
28866 !! test
28867 Never serialize a-tag as html, regardless of what data-parsoid has to say
28868 !! options
28869 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28870 !! html/parsoid
28871 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
28872 !! wikitext
28873 [[Foo]]
28874 !! end
28875
28876 ## SSS FIXME: This is broken output nevertheless.
28877 ## What might be a reasonable non-broken output for this?
28878 ## This is an edge case unlikely to be seen in production
28879 ## that I am not wasting more time on this right now.
28880 !! test
28881 Never serialize a-tag as html, no matter what attributes it has
28882 !! options
28883 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28884 !! html/parsoid
28885 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
28886 !! wikitext
28887 [http://boo.org http://boohoo.org]
28888 !! end
28889
28890 # Misnested is an indication that selser can reuse the source but these have
28891 # shown to sneak through on occasion. See T101768.
28892 # The original wikitext here is: [http://test.com [[one]] two three]
28893 !! test
28894 Strip span tags added to mark misnested links
28895 !! options
28896 parsoid=html2wt
28897 !! html/parsoid
28898 <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>
28899 !! wikitext
28900 [http://test.com][[one]] two three
28901 !! end
28902
28903 !! test
28904 Catch regression when unpacking misnested links
28905 !! options
28906 parsoid=wt2html
28907 !! wikitext
28908 {{echo|hi}}[http://example.com [[ho]]]
28909 !! html/parsoid
28910 <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>
28911 !! end
28912
28913 !! test
28914 Catch regression when unpacking with trailing content
28915 !! wikitext
28916 {{echo|Foo <references/> bar}}
28917 !! html/parsoid
28918 <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>
28919 !! end
28920
28921 !! test
28922 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
28923 !! options
28924 parsoid=html2wt
28925 !! html/parsoid
28926 <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|}"]}'>
28927 <tbody><tr><td>d
28928 </td></tr>
28929 </tbody></table>
28930 !! wikitext
28931 {{echo|a}}
28932 {|{{echo|c
28933 {{!}}d
28934 }}
28935 |}
28936 !! end
28937
28938 ## This test verifies the presence and computation of this attribute indirectly
28939 ## by making an edit and ensuring that the serialization is correct (which it would be
28940 ## only if firstWikitextNode is properly set).
28941 !! test
28942 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
28943 !! options
28944 parsoid= {
28945 "modes": ["wt2wt"],
28946 "changes": [
28947 [ "div#x", "remove" ],
28948 [ "div", "before", "<div>new</div>" ]
28949 ]
28950 }
28951 !! wikitext
28952 <div id="x">foo</div>
28953 {|
28954 {{echo|<div>boo</div>
28955 {{!}}b}}
28956 |c
28957 |}
28958 !! wikitext/edited
28959
28960 <div>new</div>
28961 {|
28962 {{echo|<div>boo</div>
28963 {{!}}b}}
28964 |c
28965 |}
28966 !! end
28967
28968 # --------------------------------------------
28969 # Tests spec'ing wikitext serialization norms |
28970 # --------------------------------------------
28971
28972 !! test
28973 Serialize multi-line indent-pre starting with wikitext syntax
28974 !! options
28975 parsoid=html2wt
28976 !! html/parsoid
28977 <pre>* 1
28978 ** 2
28979 * 3</pre>
28980 !! wikitext
28981 * 1
28982 ** 2
28983 * 3
28984 !! end
28985
28986 !! test
28987 1. Categories should always be serialized on their own line
28988 !! options
28989 parsoid=html2wt
28990 !! html/parsoid
28991 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
28992 !! wikitext
28993 foo
28994 [[Category:Foo]]
28995 bar
28996 !! end
28997
28998 !! test
28999 2. Categories that are part of templates should not introduce a line break
29000 !! wikitext
29001 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
29002 !! html/parsoid
29003 <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>
29004 !! end
29005
29006 # Careful while editing these next 2 tests. There are \u200f characters
29007 # before and after the <link> tags in the HTML and following some
29008 # of the categories in wikitext
29009 # Do not remove these characters in edits.
29010 #
29011 # As part of the serialization, these bidi characters will get stripped.
29012 !! test
29013 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
29014 !! options
29015 parsoid={
29016 "modes": ["html2wt"],
29017 "scrubWikitext": true
29018 }
29019 !! html/parsoid
29020 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
29021 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
29022 !! wikitext
29023 [[קטגוריה:טקסים]]
29024 [[קטגוריה: שיטות משפט]]
29025 !! end
29026
29027 !! test
29028 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
29029 !! options
29030 parsoid={
29031 "modes": ["html2wt"],
29032 "scrubWikitext": true
29033 }
29034 !! html/parsoid
29035 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
29036 !! wikitext
29037 [[קטגוריה:טקסים]]
29038 ‏y
29039 !! end
29040
29041 !! test
29042 Lists: Add space after bullets
29043 !! options
29044 parsoid=html2wt
29045 !! html/parsoid
29046 <ul>
29047 <li>foo</li>
29048 <li> bar</li>
29049 <li><span> baz</span></li>
29050 </ul>
29051 !! wikitext
29052 * foo
29053 * bar
29054 * <span> baz</span>
29055 !! end
29056
29057 !! test
29058 1. Headings: Add space before/after == (T53744)
29059 !! options
29060 parsoid=html2wt
29061 !! html/parsoid
29062 <h2>foo</h2>
29063 <h2> bar</h2>
29064 <h2>baz </h2>
29065 <h2><span> baz</span></h2>
29066 !! wikitext
29067 == foo ==
29068
29069 == bar ==
29070
29071 == baz ==
29072
29073 == <span> baz</span> ==
29074 !! end
29075
29076 !! test
29077 2. Headings: Add space before/after == even after hoisted content
29078 !! options
29079 parsoid={
29080 "modes": ["html2wt"],
29081 "scrubWikitext": true
29082 }
29083 !! html/parsoid
29084 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
29085 !! wikitext
29086 [[Category:A2]]
29087
29088 == ok ==
29089 !! end
29090
29091 !! test
29092 1. Headings: suppress newly created empty headings
29093 !! options
29094 parsoid={
29095 "modes": ["html2wt"],
29096 "scrubWikitext": true
29097 }
29098 !! html/parsoid
29099 <h2></h2>
29100 !! wikitext
29101 !! end
29102
29103 !! test
29104 2. Headings: don't suppress empty headings if scrubWikitext is false
29105 !! options
29106 parsoid=html2wt
29107 !! html/parsoid
29108 <h2></h2>
29109 !! wikitext
29110 ==<nowiki/>==
29111 !! end
29112
29113 !! test
29114 3. Headings: suppress empty headings on edits
29115 !! options
29116 parsoid={
29117 "modes": ["selser"],
29118 "scrubWikitext": true,
29119 "changes": [
29120 [ "#x", "remove"]
29121 ]
29122 }
29123 !! wikitext
29124 ==<span id="x">foo</span>==
29125 !! wikitext/edited
29126 !! end
29127
29128 !! test
29129 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
29130 !! options
29131 parsoid={
29132 "modes": ["html2wt"],
29133 "scrubWikitext": true
29134 }
29135 !! html/parsoid
29136 <h2>foo<br/>bar</h2>
29137 <h2>foo <span><br/>bar</span> baz</h2>
29138 !! wikitext
29139 == foo bar ==
29140
29141 == foo <span> bar</span> baz ==
29142 !! end
29143
29144 !! test
29145 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
29146 !! options
29147 parsoid={
29148 "modes": ["html2wt"],
29149 "scrubWikitext": false
29150 }
29151 !! html/parsoid
29152 <h2>foo<br/>bar</h2>
29153 !! wikitext
29154 == foo<br> bar ==
29155 !! end
29156
29157 !! test
29158 1. WT Quote Tags: suppress newly created empty style tags
29159 !! options
29160 parsoid={
29161 "modes": ["html2wt"],
29162 "scrubWikitext": true
29163 }
29164 !! html/parsoid
29165 <i></i><b></b>
29166 !! wikitext
29167 !! end
29168
29169 !! test
29170 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
29171 !! options
29172 parsoid=html2wt
29173 !! html/parsoid
29174 <i></i><b></b>
29175 !! wikitext
29176 ''<nowiki/>'''''<nowiki/>'''
29177 !! end
29178
29179 !! test
29180 3. WT Quote Tags: suppress empty style tags on edits
29181 !! options
29182 parsoid={
29183 "modes": ["selser"],
29184 "scrubWikitext": true,
29185 "changes": [
29186 [ "#x", "remove"]
29187 ]
29188 }
29189 !! wikitext
29190 '''<span id="x">foo</span>'''
29191 !! wikitext/edited
29192 !! end
29193
29194 !! test
29195 1. Anchors: suppress newly created empty anchors
29196 !! options
29197 parsoid={
29198 "modes": ["html2wt"],
29199 "scrubWikitext": true
29200 }
29201 !! html/parsoid
29202 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
29203 !! wikitext
29204 !! end
29205
29206 !! test
29207 2. Anchors: don't suppress empty anchors if scrubWikitext is false
29208 !! options
29209 parsoid={
29210 "modes": ["html2wt"],
29211 "scrubWikitext": false
29212 }
29213 !! html/parsoid
29214 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
29215 !! wikitext
29216 [[Test|<nowiki/>]]
29217 !! end
29218
29219 !! test
29220 3. Anchors: suppress empty anchors on edits
29221 !! options
29222 parsoid={
29223 "modes": ["selser"],
29224 "scrubWikitext": true,
29225 "changes": [
29226 [ "#x", "remove"]
29227 ]
29228 }
29229 !! wikitext
29230 [[Test|<span id="x">foo</span>]]
29231 !! wikitext/edited
29232 !! end
29233
29234 !! test
29235 3a. Anchors: do not suppress numbered extlinks
29236 !! options
29237 parsoid={
29238 "modes": ["wt2wt"],
29239 "scrubWikitext": true
29240 }
29241 !! wikitext
29242 [http://foo.com]
29243 !! html/parsoid
29244 <a rel="mw:ExtLink" href="http://foo.com"></a>
29245 !! end
29246
29247 !! test
29248 3b. Anchors: do not suppress numbered extlinks
29249 !! options
29250 parsoid={
29251 "modes": ["wt2wt"],
29252 "scrubWikitext": true,
29253 "changes": [
29254 [ "#x", "remove"]
29255 ]
29256 }
29257 !! wikitext
29258 [http://foo.com <span id="x">foo</span>]
29259 !! wikitext/edited
29260 [http://foo.com]
29261 !! end
29262
29263 !!test
29264 Normalizations should be restricted to edited content
29265 !!options
29266 parsoid={
29267 "modes": ["selser"],
29268 "scrubWikitext": true,
29269 "changes": [
29270 [ "h1", "before", "<i></i>"]
29271 ]
29272 }
29273 !!wikitext
29274 a
29275 = =
29276 b
29277 !!wikitext/edited
29278 a
29279 = =
29280 b
29281 !!end
29282
29283 !! test
29284 1. Multiple normalizations (html2wt)
29285 !! options
29286 parsoid={
29287 "modes": ["html2wt"],
29288 "scrubWikitext": true
29289 }
29290 !! html
29291 <h2><i></i></h2>
29292 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
29293 </a><b><i></i></b>x</p>
29294 !! wikitext
29295
29296 [[foo]]
29297 x
29298
29299 !! end
29300
29301 !! test
29302 2. Multiple normalizations (selser)
29303 !! options
29304 parsoid={
29305 "modes": ["selser"],
29306 "scrubWikitext": true,
29307 "changes": [
29308 [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
29309 ]
29310 }
29311 !! wikitext
29312 <span id="x">foo</span>
29313 !! wikitext/edited
29314 <span id="x">foo</span>
29315
29316 x
29317 !! end
29318
29319 !! test
29320 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
29321 !! options
29322 parsoid={
29323 "modes": ["html2wt"],
29324 "scrubWikitext": true
29325 }
29326 !! html/parsoid
29327 <p> hi</p>
29328 <p> hello</p>
29329 !! wikitext
29330 hi
29331
29332 hello
29333 !! end
29334
29335 !! test
29336 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
29337 !! options
29338 parsoid=html2wt
29339 !! html/parsoid
29340 <p> hi</p>
29341 <p> hello</p>
29342 !! wikitext
29343 <nowiki> </nowiki>hi
29344
29345 <nowiki> </nowiki> hello
29346 !! end
29347
29348 !! test
29349 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
29350 !! options
29351 parsoid={
29352 "modes": ["html2wt"],
29353 "scrubWikitext": true
29354 }
29355 !! html/parsoid
29356 <p>Foo
29357 bar
29358 baz</p>
29359
29360 <table><tr><td>Foo
29361 bar
29362 baz bang</td></tr></table>
29363
29364 <p><!--boo--> foo
29365 bar</p>
29366
29367 <p> foo
29368 bar<span>boo</span></p>
29369 !! wikitext
29370 Foo
29371 bar
29372 baz
29373
29374 {|
29375 |Foo
29376 bar
29377 baz bang
29378 |}
29379
29380 <!--boo-->foo
29381 bar
29382
29383 foo
29384 bar<span>boo</span>
29385 !! end
29386
29387 !! test
29388 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
29389 !! options
29390 parsoid={
29391 "modes": ["selser"],
29392 "scrubWikitext": true,
29393 "changes": [
29394 [ "p", "html", " a\n b" ]
29395 ]
29396 }
29397 !! wikitext
29398 xyz
29399 !! wikitext/edited
29400 a
29401 b
29402 !! end
29403
29404 !! test
29405 1. New links that end in spaces
29406 !! options
29407 parsoid={
29408 "modes": ["html2wt"],
29409 "scrubWikitext": false
29410 }
29411 !! html/parsoid
29412 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29413 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29414 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29415 !! wikitext
29416 [[Berlin ]]<nowiki/>is the capital of Germany.
29417
29418 [[Foo ]]'''bar'''
29419
29420 [[Boston ]] is a city.
29421 !! end
29422
29423 !! test
29424 2. New links that end in spaces
29425 !! options
29426 parsoid={
29427 "modes": ["html2wt"],
29428 "scrubWikitext": true
29429 }
29430 !! html/parsoid
29431 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29432 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29433 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29434 !! wikitext
29435 [[Berlin]] is the capital of Germany.
29436
29437 [[Foo]] '''bar'''
29438
29439 [[Boston]] is a city.
29440 !! end
29441
29442 !! test
29443 1. Table cells with escapable prefixes
29444 !! options
29445 parsoid={
29446 "modes": ["html2wt"],
29447 "scrubWikitext": false
29448 }
29449 !! html
29450 <table>
29451 <tr><td>a</td></tr>
29452 <tr><td>-</td></tr>
29453 <tr><td>+</td></tr>
29454 </table>
29455 !! wikitext
29456 {|
29457 |a
29458 |-
29459 |<nowiki>-</nowiki>
29460 |-
29461 |<nowiki>+</nowiki>
29462 |}
29463 !! end
29464
29465 !! test
29466 2. Table cells with escapable prefixes
29467 !! options
29468 parsoid={
29469 "modes": ["html2wt"],
29470 "scrubWikitext": true
29471 }
29472 !! html
29473 <table>
29474 <tr><td>a</td></tr>
29475 <tr><td>-</td></tr>
29476 <tr><td>+</td></tr>
29477 </table>
29478 !! wikitext
29479 {|
29480 |a
29481 |-
29482 | -
29483 |-
29484 | +
29485 |}
29486 !! end
29487
29488 !! test
29489 3a. Table cells with escapable prefixes after edits
29490 !! options
29491 parsoid={
29492 "modes": ["selser"],
29493 "scrubWikitext": true,
29494 "changes": [
29495 [ "table tbody tr:first-child td:first-child", "remove"]
29496 ]
29497 }
29498 !! wikitext
29499 {|
29500 |a||-
29501 |}
29502 !! wikitext/edited
29503 {|
29504 | -
29505 |}
29506 !! end
29507
29508 !! test
29509 3b. Table cells with escapable prefixes after edits
29510 !! options
29511 parsoid={
29512 "modes": ["selser"],
29513 "scrubWikitext": true,
29514 "changes": [
29515 [ "table tbody tr:first-child td:first-child", "html", "-" ],
29516 [ "#x", "remove" ]
29517 ]
29518 }
29519 !! wikitext
29520 {|
29521 |pqr
29522 |<span id="x">foo</span>+
29523 |}
29524 !! wikitext/edited
29525 {|
29526 | -
29527 | +
29528 |}
29529 !! end
29530
29531 # FIXME: This test will fail because
29532 # normalization doesn't realize that the id attribute
29533 # will eliminate the escapable scenario
29534 !! test
29535 4a. Table cells without escapable prefixes after edits
29536 !! options
29537 parsoid={
29538 "modes": ["selser"],
29539 "scrubWikitext": true,
29540 "changes": [
29541 [ "#x", "html", "-" ]
29542 ]
29543 }
29544 !! wikitext
29545 {|
29546 | id="x" |abcd
29547 |}
29548 !! wikitext/edited
29549 {|
29550 | id="x" |-
29551 |}
29552 !! end
29553
29554 ## This tests normalizer's ability to discriminate between
29555 ## cells having identical content.
29556 !! test
29557 4b. Table cells without escapable prefixes after edits
29558 !! options
29559 parsoid={
29560 "modes": ["selser"],
29561 "scrubWikitext": true,
29562 "changes": [
29563 [ "td", "html", "-" ]
29564 ]
29565 }
29566 !! wikitext
29567 {|
29568 |a||b
29569 |}
29570 !! wikitext/edited
29571 {|
29572 | -||-
29573 |}
29574 !! end
29575
29576 ## This tests normalizer's ability to not be tripped by
29577 ## comments (and whitespace)
29578 !! test
29579 4c. Table cells without escapable prefixes after edits
29580 !! options
29581 parsoid={
29582 "modes": ["selser"],
29583 "scrubWikitext": true,
29584 "changes": [
29585 [ "table tbody tr td:first-child", "remove" ]
29586 ]
29587 }
29588 !! wikitext
29589 {|
29590 |-
29591 <!--foo--> |a||-
29592 |}
29593 !! wikitext/edited
29594 {|
29595 |-
29596 <!--foo--> | -
29597 |}
29598 !! end
29599
29600 ## This tests normalizer's ability to handle HTML cells
29601 !! test
29602 4d. Table cells without escapable prefixes after edits
29603 !! options
29604 parsoid={
29605 "modes": ["selser"],
29606 "scrubWikitext": true,
29607 "changes": [
29608 [ "td", "html", "-" ]
29609 ]
29610 }
29611 !! wikitext
29612 <table>
29613 <tr><td>a</td></tr>
29614 </table>
29615 !! wikitext/edited
29616 <table>
29617 <tr><td>-</td></tr>
29618 </table>
29619 !! end
29620
29621 ## T111151 Remove font elements without attributes
29622 !! test
29623 5a. font tags without attributes should be dropped in scrubWikitext mode
29624 !! options
29625 parsoid={
29626 "modes": ["html2wt"],
29627 "scrubWikitext": true
29628 }
29629 !! html
29630 <font>foo</font>
29631 <font><font>bar</font></font>
29632 <font class="x">boo</font>
29633 !! wikitext
29634 foo
29635 bar
29636 <font class="x">boo</font>
29637 !! end
29638
29639 !! test
29640 5b. font tags should not be dropped without scrubWikitext being enabled
29641 !! options
29642 parsoid={
29643 "modes": ["html2wt"],
29644 "scrubWikitext": false
29645 }
29646 !! html
29647 <font>foo</font>
29648 !! wikitext
29649 <font>foo</font>
29650 !! end
29651
29652 !! test
29653 Escape nowiki DOM elements
29654 !! options
29655 parsoid=html2wt
29656 !! html/parsoid
29657 <nowiki><i>foo</i></nowiki>
29658 !! wikitext
29659 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
29660 !! end
29661
29662 # This is meant to be an interim fix while we go about figuring out
29663 # how to not introduce these trailing <nowiki/>s in the first place.
29664 !! test
29665 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
29666 !! options
29667 parsoid=html2wt
29668 !! html/parsoid
29669 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
29670 y</p>
29671 <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>
29672 <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>
29673 !! wikitext
29674 x
29675 y
29676
29677 {{echo|
29678 1 = <nowiki/>}}
29679
29680 {{echo|
29681 1 = <nowiki/>
29682 }}
29683 !! end
29684
29685 # ---------------------------------------------------
29686 # End of tests spec'ing wikitext serialization norms |
29687 # ---------------------------------------------------
29688
29689 # T104032
29690 !! test
29691 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
29692 !! options
29693 parsoid=html2wt
29694 !! html/parsoid
29695 a<p>b</p>
29696 <b>c</b><p>d</p>
29697 <table><tr>
29698 <td>a<p>b</p></td>
29699 <td><b>c</b><p>d</p></td>
29700 </tr></table>
29701 !! wikitext
29702 a
29703
29704 b
29705
29706 '''c'''
29707
29708 d
29709 {|
29710 |a
29711 b
29712 |'''c'''
29713 d
29714 |}
29715 !! end
29716
29717 !! test
29718 Anchor without href scenarios
29719 !! options
29720 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29721 !! html/parsoid
29722 <a class="bc"></a>
29723 <a class="no">dice</a>
29724 <a name="foo"></a>
29725 !! wikitext
29726
29727 dice
29728 <span name="foo"></span>
29729 !! end
29730
29731 !! test
29732 New transclusion added after a list should be serialized after the list
29733 !! options
29734 parsoid=html2wt
29735 !! html/parsoid
29736 <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>
29737 !! wikitext
29738 * a
29739 {{echo|foo}}
29740 !! end
29741
29742 # -----------------------------------------------------------------
29743 # End of section for Parsoid-only html2wt tests for serialization
29744 # of new content
29745 # -----------------------------------------------------------------
29746
29747 # -----------------------------------------------------------------
29748 # The following section of tests are primarily to spec behavior of
29749 # the selective serializer. All these tests have manual selser
29750 # changes. The automated selser changes for all tests handle the
29751 # wide variation of changes, but these tests here capture specs
29752 # deterministically.
29753 # ----------------------------------------------------------------
29754
29755 ## T90517
29756 !! test
29757 Selser: New comments should not be lost
29758 !! options
29759 parsoid={
29760 "modes": ["selser"],
29761 "changes": [
29762 [ "#a", "after", "<!--c1-->" ],
29763 [ "#b", "before", "<!--c2-->" ]
29764 ]
29765 }
29766 !! wikitext
29767 <span id="a">a</span>
29768
29769 <span id="b">b</span>
29770 !! wikitext/edited
29771 <span id="a">a</span><!--c1-->
29772
29773 <!--c2--><span id="b">b</span>
29774 !! end
29775
29776 ## T89383
29777 !! test
29778 Selser: Check for validity of DSR before using it
29779 !! options
29780 parsoid={
29781 "modes": ["selser"],
29782 "changes": [
29783 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
29784 ]
29785 }
29786 !! wikitext
29787 <span id="a">a</span>
29788 !! wikitext/edited
29789 {{DISPLAYTITLE:foo}}
29790 <span id="a">a</span>
29791 !! end
29792
29793 !! test
29794 1. DOMDiff: Changes to <ref> content should be looked up using id
29795 !! options
29796 parsoid={
29797 "modes": ["selser"],
29798 "changes": [
29799 ["#X", "after", "bar"],
29800 ["#Y", "after", "baz"]
29801 ]
29802 }
29803 !! wikitext
29804 X <ref><span id="X">foo</span></ref>
29805 Y <ref name="a" />
29806 <references>
29807 <ref name="a"><span id="Y">foo</span></ref>
29808 </references>
29809 !! wikitext/edited
29810 X <ref><span id="X">foo</span>bar</ref>
29811 Y <ref name="a" />
29812 <references>
29813 <ref name="a"><span id="Y">foo</span>baz</ref>
29814 </references>
29815 !! end
29816
29817 !! test
29818 2. DOMDiff: Changes to <ref> content should be looked up using id
29819 !! options
29820 parsoid={
29821 "modes": ["selser"],
29822 "changes": [
29823 ["#Z", "after", "bar"]
29824 ]
29825 }
29826 !! wikitext
29827 A <ref>foo bar for a</ref>
29828 B <ref group="X" name="b" />
29829
29830 <references />
29831
29832 <references group="X">
29833 <ref name="b"><span id="Z">foo</span></ref>
29834 </references>
29835 !! wikitext/edited
29836 A <ref>foo bar for a</ref>
29837 B <ref group="X" name="b" />
29838
29839 <references />
29840
29841 <references group="X">
29842 <ref name="b"><span id="Z">foo</span>bar</ref>
29843 </references>
29844 !! end
29845
29846 !! test
29847 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
29848 !! options
29849 parsoid={
29850 "modes": ["selser"],
29851 "changes": [
29852 [ "div:first-child", "text", "bar" ]
29853 ]
29854 }
29855 !! wikitext
29856 <div style="{{1x|color:red;}}%">foo</div>
29857 !! wikitext/edited
29858 <div style="{{1x|color:red;}}%">bar</div>
29859 !! end
29860
29861 !! test
29862 Empty LI (T49673)
29863 !! wikitext
29864 * a
29865 *
29866 *
29867 * b
29868 !! html/php+tidy
29869 <ul>
29870 <li>a</li>
29871 <li class="mw-empty-elt"></li>
29872 <li class="mw-empty-elt"></li>
29873 <li>b</li>
29874 </ul>
29875 !! end
29876
29877 !! test
29878 Thumbnail output
29879 !! wikitext
29880 [[File:Thumb.png|thumb]]
29881 !! html/php+tidy
29882 <div class="thumb tright">
29883 <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>
29884 <div class="thumbcaption">
29885 <div class="magnify"><a href="/wiki/File:Thumb.png" class="internal" title="Enlarge"></a></div>
29886 </div>
29887 </div>
29888 </div>
29889 !! end
29890
29891 !! test
29892 unclosed internal link XSS (T137264)
29893 !! wikitext
29894 [[#%3Cscript%3Ealert(1)%3C/script%3E|
29895 !! html/php
29896 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
29897 </p>
29898 !! html/parsoid
29899 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
29900 !! end
29901
29902 # Use $wgRawHtml to inject a <style> tag, since you normally can't in wikitext
29903 # (Parsoid doesn't support $wgRawHtml==true)
29904 !! test
29905 Validating that <style> isn't eaten by tidy (T167349)
29906 !! options
29907 wgRawHtml=1
29908 !! wikitext
29909 <div class="foo">
29910 <html><style>.foo::before { content: "<foo>"; }</style></html>
29911 <html><style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style></html>
29912 </div>
29913 !! html/php+tidy
29914 <div class="foo">
29915 <style>.foo::before { content: "<foo>"; }</style>
29916 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
29917 </div>
29918 !! end
29919
29920 !! test
29921 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
29922 !! config
29923 wgFragmentMode=[ 'html5', 'legacy' ]
29924 !! wikitext
29925 == A&B&amp;C&amp;amp;D&amp;amp;amp;E ==
29926 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
29927 !! html/php
29928 <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>
29929 <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>
29930 </p>
29931 !! html/parsoid
29932 <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>
29933 <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>
29934 !! end
29935
29936 !! test
29937 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
29938 !! config
29939 wgFragmentMode=[ 'legacy' ]
29940 !! wikitext
29941 == A&B&amp;C&amp;amp;D&amp;amp;amp;E ==
29942 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
29943 !! html/php
29944 <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>
29945 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
29946 </p>
29947 !! end
29948
29949 !! test
29950 Decoding of HTML entities in embedded HTML tags
29951 !! wikitext
29952 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
29953 !! html/php
29954 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
29955
29956 !! html/parsoid
29957 <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>
29958 !! end
29959
29960 !! test
29961 Decoding of HTML entities in indicator names for IDs (T104196)
29962 !! options
29963 parsoid=wt2html,html2html
29964 showindicators
29965 !! wikitext
29966 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
29967 !! html/php
29968 1&2&3&amp;4&amp;amp;5=Indicator
29969
29970 !! html/parsoid
29971 <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>
29972 !! end
29973
29974 # this version of the test strips out the ambiguity so Parsoid rts cleanly
29975 !! test
29976 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
29977 !! options
29978 showindicators
29979 !! wikitext
29980 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
29981 !! html/php
29982 1&2&3&amp;4&amp;amp;5=Indicator
29983
29984 !! html/parsoid
29985 <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>
29986 !! end
29987
29988 # This fragment mode is what Parsoid supports.
29989 !! test
29990 HTML5 ids: fallback to legacy
29991 !! config
29992 wgFragmentMode=[ 'html5', 'legacy' ]
29993 !! wikitext
29994 == Foo bar ==
29995
29996 == foo Bar ==
29997
29998 == Тест ==
29999
30000 == Тест ==
30001
30002 == тест ==
30003
30004 == Hey < # " > % : ' ==
30005 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30006
30007 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30008
30009 <!-- These two links should produce identical HTML -->
30010 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30011
30012 !! html/php
30013 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
30014 <ul>
30015 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30016 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30017 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
30018 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
30019 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
30020 <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>
30021 </ul>
30022 </div>
30023
30024 <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>
30025 <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>
30026 <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>
30027 <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>
30028 <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>
30029 <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>
30030 <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>
30031 </p><p>💩 <span id="💩"></span>
30032 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
30033 </p>
30034 !! html/parsoid
30035 <h2 id="Foo_bar"> Foo bar </h2>
30036
30037 <h2 id="foo_Bar_2"> foo Bar </h2>
30038
30039 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span> Тест </h2>
30040
30041 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span> Тест </h2>
30042
30043 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span> тест </h2>
30044
30045 <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>
30046 <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>
30047
30048 <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>
30049
30050 <!-- These two links should produce identical HTML -->
30051 <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>
30052 !! end
30053
30054 # Parsoid doesn't support this mode
30055 !! test
30056 HTML5 ids: legacy with a fallback to modern
30057 !! config
30058 wgFragmentMode=[ 'legacy', 'html5' ]
30059 !! wikitext
30060 == Foo bar ==
30061
30062 == foo Bar ==
30063
30064 == Тест ==
30065
30066 == Тест ==
30067
30068 == тест ==
30069
30070 == Hey < # " > % : ' ==
30071 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30072
30073 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30074
30075 <!-- These two links should produce identical HTML -->
30076 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30077
30078 !! html/php
30079 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
30080 <ul>
30081 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30082 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30083 <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>
30084 <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>
30085 <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>
30086 <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>
30087 </ul>
30088 </div>
30089
30090 <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>
30091 <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>
30092 <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>
30093 <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>
30094 <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>
30095 <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>
30096 <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>
30097 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
30098 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
30099 </p>
30100 !! end
30101
30102 # Parsoid doesn't support this mode.
30103 !! test
30104 HTML5 ids: no legacy
30105 !! config
30106 wgFragmentMode=[ 'html5' ]
30107 !! wikitext
30108 == Foo bar ==
30109
30110 == foo Bar ==
30111
30112 == Тест ==
30113
30114 == Тест ==
30115
30116 == тест ==
30117
30118 == Hey < # " > % : ' ==
30119 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30120
30121 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30122
30123 <!-- These two links should produce identical HTML -->
30124 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30125
30126 !! html/php
30127 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
30128 <ul>
30129 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30130 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30131 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
30132 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
30133 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
30134 <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>
30135 </ul>
30136 </div>
30137
30138 <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>
30139 <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>
30140 <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>
30141 <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>
30142 <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>
30143 <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>
30144 <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>
30145 </p><p>💩 <span id="💩"></span>
30146 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
30147 </p>
30148 !! end
30149
30150 !! test
30151 T90902: Normalize weird characters in section IDs
30152 !! config
30153 wgFragmentMode=[ 'html5', 'legacy' ]
30154 !! wikitext
30155 == Foo&nbsp;bar ==
30156 [[#Foo&nbsp;bar]]
30157
30158 !! html/php
30159 <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>
30160 <p><a href="#Foo_bar">#Foo&#160;bar</a>
30161 </p>
30162 !! end
30163
30164 !! test
30165 T51672: Test for brackets in attributes of elements in external link texts
30166 !! wikitext
30167 [http://example.com/ link <span title="title with [brackets]">span</span>]
30168 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
30169
30170 !! html/php
30171 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
30172 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
30173 </p>
30174 !! html/parsoid
30175 <p><a rel="mw:ExtLink" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
30176 <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>
30177 !! end
30178
30179 !! test
30180 T72875: Test for brackets in attributes of elements in internal link texts
30181 !! wikitext
30182 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
30183 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
30184
30185 !! html/php
30186 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
30187 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
30188 </p>
30189 !! html/parsoid
30190 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
30191 <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>
30192 !! end
30193
30194 !! test
30195 T179544: {{anchorencode:}} output should be always usable in links
30196 !! config
30197 wgFragmentMode=[ 'html5' ]
30198 !! wikitext
30199 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
30200 !! html/php
30201 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
30202 </p>
30203 !! html/parsoid
30204 <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>
30205 !! end
30206
30207 ## ------------------------------
30208 ## Parsoid section-wrapping tests
30209 ## ------------------------------
30210 !! test
30211 Section wrapping for well-nested sections (no leading content)
30212 !! options
30213 parsoid={
30214 "wrapSections": true
30215 }
30216 !! wikitext
30217 = 1 =
30218 a
30219
30220 = 2 =
30221 b
30222
30223 == 2.1 ==
30224 c
30225
30226 == 2.2 ==
30227 d
30228
30229 === 2.2.1 ===
30230 e
30231
30232 = 3 =
30233 f
30234 !! html/parsoid
30235 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30236 <p>a</p>
30237
30238 </section><section data-mw-section-id="2"><h1 id="2"> 2 </h1>
30239 <p>b</p>
30240
30241 <section data-mw-section-id="3"><h2 id="2.1"> 2.1 </h2>
30242 <p>c</p>
30243
30244 </section><section data-mw-section-id="4"><h2 id="2.2"> 2.2 </h2>
30245 <p>d</p>
30246
30247 <section data-mw-section-id="5"><h3 id="2.2.1"> 2.2.1 </h3>
30248 <p>e</p>
30249
30250 </section></section></section><section data-mw-section-id="6"><h1 id="3"> 3 </h1>
30251 <p>f</p>
30252
30253 </section>
30254 !! end
30255
30256 !! test
30257 Section wrapping for well-nested sections (with leading content)
30258 !! options
30259 parsoid={
30260 "wrapSections": true
30261 }
30262 !! wikitext
30263 Para 1.
30264
30265 Para 2 with a <div>nested in it</div>
30266
30267 Para 3.
30268
30269 = 1 =
30270 a
30271
30272 = 2 =
30273 b
30274
30275 == 2.1 ==
30276 c
30277 !! html/parsoid
30278 <section data-mw-section-id="0"><p>Para 1.</p>
30279
30280 <p>Para 2 with a </p><div>nested in it</div>
30281
30282 <p>Para 3.</p>
30283
30284 </section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30285 <p>a</p>
30286
30287 </section><section data-mw-section-id="2"><h1 id="2"> 2 </h1>
30288 <p>b</p>
30289
30290 <section data-mw-section-id="3"><h2 id="2.1"> 2.1 </h2>
30291 <p>c</p>
30292
30293 </section></section>
30294 !! end
30295
30296 !! test
30297 Section wrapping with template-generated sections (good nesting 1)
30298 !! options
30299 parsoid={
30300 "wrapSections": true
30301 }
30302 !! wikitext
30303 = 1 =
30304 a
30305
30306 {{echo|1=
30307 == 1.1 ==
30308 b
30309 }}
30310
30311 == 1.2 ==
30312 c
30313
30314 = 2 =
30315 d
30316 !! html/parsoid
30317 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30318 <p>a</p>
30319
30320 <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">
30321 </span><p about="#mwt1">b</p>
30322 </section><section data-mw-section-id="3"><h2 id="1.2"> 1.2 </h2>
30323 <p>c</p>
30324
30325 </section></section><section data-mw-section-id="4"><h1 id="2"> 2 </h1>
30326 <p>d</p></section>
30327 !! end
30328
30329 # In this example, the template scope is mildly expanded to incorporate the
30330 # trailing newline after the transclusion since that is part of section 1.1.1
30331 !! test
30332 Section wrapping with template-generated sections (good nesting 2)
30333 !! options
30334 parsoid={
30335 "wrapSections": true,
30336 "modes": ["wt2html", "wt2wt"]
30337 }
30338 !! wikitext
30339 = 1 =
30340 a
30341
30342 {{echo|1=
30343 == 1.1 ==
30344 b
30345 === 1.1.1 ===
30346 d
30347 }}
30348 = 2 =
30349 e
30350 !! html/parsoid
30351 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30352 <p>a</p>
30353
30354 <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">
30355 </span><p about="#mwt1">b</p><span about="#mwt1">
30356 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1"> 1.1.1 </h3><span about="#mwt1">
30357 </span><p about="#mwt1">d</p><span about="#mwt1">
30358 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2"> 2 </h1>
30359 <p>e</p></section>
30360 !! end
30361
30362 # In this example, the template scope is mildly expanded to incorporate the
30363 # trailing newline after the transclusion since that is part of section 1.2.1
30364 !! test
30365 Section wrapping with template-generated sections (good nesting 3)
30366 !! options
30367 parsoid={
30368 "wrapSections": true,
30369 "modes": ["wt2html", "wt2wt"]
30370 }
30371 !! wikitext
30372 = 1 =
30373 a
30374
30375 {{echo|1=
30376 x
30377 == 1.1 ==
30378 b
30379 ==1.2==
30380 c
30381 ===1.2.1===
30382 d
30383 }}
30384 = 2 =
30385 e
30386 !! html/parsoid
30387 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
30388 <p>a</p>
30389
30390 <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">
30391 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1"> 1.1 </h2><span about="#mwt1">
30392 </span><p about="#mwt1">b</p><span about="#mwt1">
30393 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
30394 </span><p about="#mwt1">c</p><span about="#mwt1">
30395 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
30396 </span><p about="#mwt1">d</p><span about="#mwt1">
30397 </span></section></section></section><section data-mw-section-id="5"><h1 id="2"> 2 </h1>
30398 <p>e</p></section>
30399 !! end
30400
30401 # Because of section-wrapping and template-wrapping interactions,
30402 # the scope of the template is expanded so that the template markup
30403 # is valid in the presence of <section> tags.
30404 # This exercises the s1 is null scenario in the wrapSections code
30405 !! test
30406 Section wrapping with template-generated sections (bad nesting 1)
30407 !! options
30408 parsoid={
30409 "wrapSections": true
30410 }
30411 !! wikitext
30412 <div>
30413 a
30414
30415 {{echo|
30416 = 1 =
30417 b
30418 }}
30419
30420 c
30421 </div>
30422 !! html/parsoid
30423 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
30424 <p>a</p>
30425
30426 <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"]}'>
30427 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1"> 1 </h1><span about="#mwt1">
30428 </span><p about="#mwt1">b
30429 </p><span about="#mwt1">
30430
30431 </span><p about="#mwt1">c</p><span about="#mwt1">
30432 </span></section></div></section>
30433 !! end
30434
30435 # Because of section-wrapping and template-wrapping interactions,
30436 # the scope of the template is expanded so that the template markup
30437 # is valid in the presence of <section> tags.
30438 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
30439 !! test
30440 Section wrapping with template-generated sections (bad nesting 2)
30441 !! options
30442 parsoid={
30443 "wrapSections": true
30444 }
30445 !! wikitext
30446 = 1 =
30447 a
30448
30449 {{echo|1=
30450 = 2 =
30451 b
30452 == 2.1 ==
30453 c
30454 }}
30455
30456 d
30457
30458 = 3 =
30459 e
30460 !! html/parsoid
30461 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30462 <p>a</p>
30463
30464 </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">
30465 </span><p about="#mwt1">b</p><span about="#mwt1">
30466 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1"> 2.1 </h2><span about="#mwt1">
30467 </span><p about="#mwt1">c</p><span about="#mwt1">
30468
30469 </span><p about="#mwt1">d</p><span about="#mwt1">
30470
30471 </span></section></section><section data-mw-section-id="4"><h1 id="3"> 3 </h1>
30472 <p>e</p></section>
30473 !! end
30474
30475 # Because of section-wrapping and template-wrapping interactions,
30476 # additional template wrappers are added to <section> tags
30477 # so that template wrapping semantics are valid whether section
30478 # tags are retained or stripped. But, the template scope can expand
30479 # greatly when accounting for section tags.
30480 # This exercises the s1 and s2 are in different subtrees scenario
30481 !! test
30482 Section wrapping with template-generated sections (bad nesting 3)
30483 !! options
30484 parsoid={
30485 "wrapSections": true,
30486 "modes": ["wt2html", "wt2wt"]
30487 }
30488 !! wikitext
30489 = 1 =
30490 a
30491
30492 {{echo|1=
30493 == 1.2 ==
30494 b
30495 = 2 =
30496 c
30497 }}
30498
30499 d
30500
30501 = 3 =
30502 e
30503 !! html/parsoid
30504 <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>
30505 <p>a</p>
30506
30507 <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">
30508 </span><p about="#mwt1">b</p><span about="#mwt1">
30509 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2"> 2 </h1><span about="#mwt1">
30510 </span><p about="#mwt1">c</p>
30511
30512 <p>d</p>
30513 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3"> 3 </h1>
30514 <p>e</p></section>
30515 !! end
30516
30517 !! test
30518 Section wrapping with uneditable lead section + div wrapping multiple sections
30519 !! options
30520 parsoid={
30521 "wrapSections": true
30522 }
30523 !! wikitext
30524 foo
30525
30526 <div style="border:1px solid red;">
30527 = 1 =
30528 a
30529
30530 == 1.1 ==
30531 b
30532
30533 = 2 =
30534 c
30535 </div>
30536
30537 = 3 =
30538 d
30539
30540 == 3.1 ==
30541 e
30542 !! html/parsoid
30543 <section data-mw-section-id="-1"><p>foo</p>
30544
30545 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
30546 <section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30547 <p>a</p>
30548
30549 <section data-mw-section-id="2"><h2 id="1.1"> 1.1 </h2>
30550 <p>b</p>
30551
30552 </section></section><section data-mw-section-id="-1"><h1 id="2"> 2 </h1>
30553 <p>c</p>
30554 </section></div>
30555
30556 </section><section data-mw-section-id="4"><h1 id="3"> 3 </h1>
30557 <p>d</p>
30558
30559 <section data-mw-section-id="5"><h2 id="3.1"> 3.1 </h2>
30560 <p>e</p>
30561 </section></section>
30562 !! end
30563
30564 !! test
30565 Section wrapping with editable lead section + div overlapping multiple sections
30566 !! options
30567 parsoid={
30568 "wrapSections": true
30569 }
30570 !! wikitext
30571 foo
30572
30573 = 1 =
30574 a
30575 <div style="border:1px solid red;">
30576 b
30577
30578 == 1.1 ==
30579 c
30580
30581 = 2 =
30582 d
30583 </div>
30584 e
30585
30586 = 3 =
30587 f
30588
30589 == 3.1 ==
30590 g
30591 !! html/parsoid
30592 <section data-mw-section-id="0"><p>foo</p>
30593
30594 </section><section data-mw-section-id="-1"><h1 id="1"> 1 </h1>
30595 <p>a</p>
30596 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
30597 <p>b</p>
30598
30599 <section data-mw-section-id="2"><h2 id="1.1"> 1.1 </h2>
30600 <p>c</p>
30601
30602 </section><section data-mw-section-id="-1"><h1 id="2"> 2 </h1>
30603 <p>d</p>
30604 </section></div>
30605 <p>e</p>
30606
30607 </section><section data-mw-section-id="4"><h1 id="3"> 3 </h1>
30608 <p>f</p>
30609
30610 <section data-mw-section-id="5"><h2 id="3.1"> 3.1 </h2>
30611 <p>g</p>
30612 </section></section>
30613 !! end
30614
30615 !! test
30616 HTML header tags should not be wrapped in section tags
30617 !! options
30618 parsoid={
30619 "wrapSections": true
30620 }
30621 !! wikitext
30622 foo
30623
30624 <h1>a</h1>
30625
30626 = b =
30627
30628 <h1>c</h1>
30629
30630 = d =
30631 !! html/parsoid
30632 <section data-mw-section-id="0"><p>foo</p>
30633
30634 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
30635
30636 </section><section data-mw-section-id="1"><h1 id="b"> b </h1>
30637
30638 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
30639
30640 </section><section data-mw-section-id="2"><h1 id="d"> d </h1></section>
30641 !! end
30642
30643 !! test
30644 Lead section containing only whitespace and comments.
30645 !! options
30646 parsoid={
30647 "wrapSections": true
30648 }
30649 !! wikitext
30650
30651 <!-- this is a comment, presumably significant to editors -->
30652 = 1 =
30653 a
30654
30655 = 2 =
30656 b
30657 !! html/parsoid
30658 <section data-mw-section-id="0" data-parsoid="{}">
30659 <!-- this is a comment, presumably significant to editors -->
30660 </section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30661 <p>a</p>
30662
30663 </section><section data-mw-section-id="2"><h1 id="2"> 2 </h1>
30664 <p>b</p></section>
30665 !! end
30666
30667 !! test
30668 Pseudo-sections emitted by templates should have id -2
30669 !! options
30670 parsoid={
30671 "wrapSections": true
30672 }
30673 !! wikitext
30674 foo
30675 {{echo|<div>
30676 == a ==
30677 == b ==
30678 </div>
30679 }}
30680 !! html/parsoid
30681 <section data-mw-section-id="-1"><p>foo</p>
30682 </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}}]}'>
30683 <section data-mw-section-id="-1"><h2 id="a"> a </h2>
30684 </section><section data-mw-section-id="-1"><h2 id="b"> b </h2>
30685 </section></div><span about="#mwt1">
30686 </span></section>
30687 !! end