Add HTML attributes lang and dir to toctitle
[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 ###
12637 ### Token Stream Patcher tests
12638 ###
12639 ### These tests won't always pass wt2wt and other modes because
12640 ### on serialization, the table will be output on a new line.
12641 ### For now, we are blacklisting them, and using this to test selser.
12642 ###
12643
12644 !!test
12645 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12646 !!options
12647 parsoid=wt2html,wt2wt
12648 !!wikitext
12649 {{echo|}}{| width = '100%'
12650 |foo
12651 |}
12652 !!html/parsoid
12653 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12654 <tbody><tr><td>foo</td></tr>
12655 </tbody></table>
12656 !!end
12657
12658 ## We used to, but no longer wt2wt this test since the default serializer
12659 ## will normalize the include directives to serialize on their own line.
12660 ## Selser will take care of preserving formatting in scenarios where they
12661 ## intermingled with other wikitext.
12662 !!test
12663 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12664 !!options
12665 parsoid=wt2html
12666 !!wikitext
12667 <includeonly>a</includeonly>{| {{{b}}}
12668 |c
12669 |}
12670 !!html/parsoid
12671 <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":""}]]}'>
12672 <tbody><tr><td>c</td></tr>
12673 </tbody></table>
12674 !!end
12675
12676 !! test
12677 Table wikitext syntax outside wiki-tables
12678 !! wikitext
12679 a
12680 |+ not a caption
12681 ! not a table heading
12682 |- not a table row
12683 | not a table cell
12684 | class="foo bar" | baz
12685 b
12686 |}
12687 |-
12688 c
12689 !! html
12690 <p>a
12691 |+ not a caption
12692 ! not a table heading
12693 |- not a table row
12694 | not a table cell
12695 | class="foo bar" | baz
12696 b
12697 |}
12698 |-
12699 c
12700 </p>
12701 !! end
12702
12703 ###
12704 ### Testing parsing of templates where a template arg
12705 ### has the same name as the template itself.
12706 ###
12707
12708 !! article
12709 Template:quote
12710 !! text
12711 {{{quote|{{{1}}}}}}
12712 !! endarticle
12713
12714 !!test
12715 Templates: Template Name/Arg clash: 1. Use of positional param
12716 !! wikitext
12717 {{quote|foo}}
12718 !! html
12719 <p>foo
12720 </p>
12721 !!end
12722
12723 !!test
12724 Templates: Template Name/Arg clash: 2. Use of named param
12725 !! wikitext
12726 {{quote|quote=foo}}
12727 !! html
12728 <p>foo
12729 </p>
12730 !!end
12731
12732 !!test
12733 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12734 !! wikitext
12735 {{quote|quote}}
12736 !! html
12737 <p>quote
12738 </p>
12739 !!end
12740
12741 ###
12742 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12743 ###
12744
12745 !!test
12746 Templates: 1. Simple use
12747 !! wikitext
12748 {{echo|Foo}}
12749 !! html
12750 <p>Foo
12751 </p>
12752 !!end
12753
12754 !!test
12755 Templates: 2. Inside a block tag
12756 !! wikitext
12757 <div>{{echo|Foo}}</div>
12758 <blockquote>{{echo|Foo}}</blockquote>
12759 !! html
12760 <div>Foo</div>
12761 <blockquote>Foo</blockquote>
12762
12763 !! html+tidy
12764 <div>Foo</div>
12765 <blockquote>
12766 <p>Foo</p>
12767 </blockquote>
12768 !!end
12769
12770 !!test
12771 Templates: P-wrapping: 1a. Templates on consecutive lines
12772 !! wikitext
12773 {{echo|Foo}}
12774 {{echo|bar}}
12775 !! html
12776 <p>Foo
12777 bar
12778 </p>
12779 !!end
12780
12781 !!test
12782 Templates: P-wrapping: 1b. Templates on consecutive lines
12783 !! wikitext
12784 Foo
12785
12786 {{echo|bar}}
12787 {{echo|baz}}
12788 !! html
12789 <p>Foo
12790 </p><p>bar
12791 baz
12792 </p>
12793 !!end
12794
12795 !!test
12796 Templates: P-wrapping: 1c. Templates on consecutive lines
12797 !! wikitext
12798 {{echo|Foo}}
12799 {{echo|bar}} <div>baz</div>
12800 !! html
12801 <p>Foo
12802 </p>
12803 bar <div>baz</div>
12804
12805 !! html+tidy
12806 <p>Foo</p>
12807 <p>bar</p>
12808 <div>baz</div>
12809 !! end
12810
12811 !!test
12812 Templates: P-wrapping: 1d. Template preceded by comment-only line
12813 !!options
12814 parsoid
12815 !! wikitext
12816 <!-- foo -->
12817 {{echo|Bar}}
12818 !! html
12819 <!-- foo -->
12820
12821 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
12822 !!end
12823
12824 !!test
12825 Templates: Inline Text: 1. Multiple template uses
12826 !! wikitext
12827 {{echo|Foo}}bar{{echo|baz}}
12828 !! html
12829 <p>Foobarbaz
12830 </p>
12831 !!end
12832
12833 !!test
12834 Templates: Inline Text: 2. Back-to-back template uses
12835 !! wikitext
12836 {{echo|Foo}}{{echo|bar}}
12837 !! html
12838 <p>Foobar
12839 </p>
12840 !!end
12841
12842 !!test
12843 Templates: Block Tags: 1. Multiple template uses
12844 !! wikitext
12845 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
12846 !! html
12847 <div>Foo</div><div>bar</div><div>baz</div>
12848
12849 !!end
12850
12851 !!test
12852 Templates: Block Tags: 2. Back-to-back template uses
12853 !! wikitext
12854 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
12855 !! html
12856 <div>Foo</div><div>bar</div>
12857
12858 !!end
12859
12860 # This is an edge case relating to paragraph wrapping.
12861 !!test
12862 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
12863 !! wikitext
12864 {{echo|a
12865 b</p>}}
12866 !! html/parsoid
12867 <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
12868 b</p>
12869 !!end
12870
12871 !!test
12872 Templates: Links: 1. Simple example
12873 !! wikitext
12874 {{echo|[[Foo|bar]]}}
12875 !! html
12876 <p><a href="/wiki/Foo" title="Foo">bar</a>
12877 </p>
12878 !!end
12879
12880 !!test
12881 Templates: Links: 2. Generation of link href
12882 !! wikitext
12883 [[{{echo|Foo}}|bar]]
12884 !! html
12885 <p><a href="/wiki/Foo" title="Foo">bar</a>
12886 </p>
12887 !!end
12888
12889 !!test
12890 Templates: Links: 3. Generation of part of a link href
12891 !! wikitext
12892 [[Fo{{echo|o}}|bar]]
12893
12894 [[Foo{{echo|bar}}]]
12895
12896 [[Foo{{echo|bar}}baz]]
12897
12898 [[Foo{{echo|bar}}|bar]]
12899
12900 [[:Foo{{echo|bar}}]]
12901
12902 [[:Foo{{echo|bar}}|bar]]
12903 !! html
12904 <p><a href="/wiki/Foo" title="Foo">bar</a>
12905 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12906 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
12907 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12908 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12909 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12910 </p>
12911 !!end
12912
12913 !!test
12914 Templates: Links: 4. Multiple templates generating link href
12915 !! wikitext
12916 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
12917 !! html
12918 <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>
12920 !!end
12921
12922 !!test
12923 Templates: Links: 5. Generation of link text
12924 !! wikitext
12925 [[Foo|{{echo|bar}}]]
12926 !! html
12927 <p><a href="/wiki/Foo" title="Foo">bar</a>
12928 </p>
12929 !!end
12930
12931 !!test
12932 Templates: Links: 5. Nested templates (only outermost template should be marked)
12933 !! wikitext
12934 {{echo|[[{{echo|Foo}}|bar]]}}
12935 !! html
12936 <p><a href="/wiki/Foo" title="Foo">bar</a>
12937 </p>
12938 !!end
12939
12940 !!test
12941 Templates: HTML Tag: 1. Generation of HTML attr. key
12942 !! wikitext
12943 <div {{echo|style}}="color:red;">foo</div>
12944 !! html
12945 <div style="color:red;">foo</div>
12946
12947 !!end
12948
12949 !!test
12950 Templates: HTML Tag: 2. Generation of HTML attr. value
12951 !! wikitext
12952 <div style={{echo|'color:red;'}}>foo</div>
12953 !! html
12954 <div style="color:red;">foo</div>
12955
12956 !!end
12957
12958 !!test
12959 Templates: HTML Tag: 3. Generation of HTML attr key and value
12960 !! wikitext
12961 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
12962 !! html
12963 <div style="color:red;">foo</div>
12964
12965 !!end
12966
12967 !!test
12968 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
12969 !! wikitext
12970 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
12971 !! html
12972 <div title="This is a long title with just one piece templated">foo</div>
12973
12974 !!end
12975
12976 !!test
12977 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
12978 !! wikitext
12979 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
12980 !! html
12981 <div title="This is a long title with just one piece templated">foo</div>
12982
12983 !!end
12984
12985 !!test
12986 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
12987 !! wikitext
12988 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
12989 !! html
12990 <div title="This is a long title with just one piece templated">foo</div>
12991
12992 !!end
12993
12994 # SSS FIXME: While it is great we added support for all this,
12995 # do we want to make this part of the spec? Maybe we want to
12996 # deprecate this kind of usage in the future?
12997 !!test
12998 Templates: HTML Tag: 7. Generation of partial attribute key string
12999 !! wikitext
13000 <div st{{echo|yle}}="color:red;">foo</div>
13001 !! html
13002 <div style="color:red;">foo</div>
13003
13004 !!end
13005
13006 !! test
13007 Templates: HTML Tag: 8. Template-generated attribute (k=v)
13008 !! wikitext
13009 <div {{echo|1=id="v1"}}>bar</div>
13010 !! html
13011 <div id="v1">bar</div>
13012
13013 !!end
13014
13015 !! test
13016 Templates: HTML Tag: 9. Multiple template-generated attributes
13017 !! wikitext
13018 <div {{echo|1=id="v1" title="foo"}}>bar</div>
13019 !! html
13020 <div id="v1" title="foo">bar</div>
13021
13022 !!end
13023
13024 !! test
13025 Templates: Support for templates generating attributes and content
13026 !! wikitext
13027 {| {{mixed_attr_content_template}}
13028 |-
13029 |bar
13030 |}
13031 !! html/php
13032 <table style="color:red;" title="T48811">
13033
13034 <tr>
13035 <td>foo
13036 </td></tr>
13037 <tr>
13038 <td>bar
13039 </td></tr></table>
13040
13041 !! html/parsoid
13042 <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|}"]}'>
13043 <tbody><tr>
13044 <td>foo</td></tr>
13045 <tr>
13046 <td>bar</td></tr>
13047 </tbody></table>
13048 !!end
13049
13050 !! test
13051 1. Entities and nowikis inside templated attributes should be handled correctly
13052 !! wikitext
13053 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
13054 !! html/php
13055 <div style="background:#f9f9f9;">foo</div>
13056
13057 !! html/parsoid
13058 <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>
13059 !! end
13060
13061 !! test
13062 2. Entities and nowikis inside templated attributes should be handled correctly
13063 !! wikitext
13064 {|
13065 |{{table_attribs_3}}
13066 |}
13067 !! html/php
13068 <table>
13069 <tr>
13070 <td style="background:#f9f9f9;">Foo
13071 </td></tr></table>
13072
13073 !! html/parsoid
13074 <table>
13075 <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>
13076 </tbody></table>
13077 !! end
13078
13079 !! test
13080 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13081 !! wikitext
13082 {{tbl-start}}
13083 |{{table_attribs_3}}
13084 {{tbl-end}}
13085 !! html/php
13086 <table>
13087 <tr>
13088 <td style="background:#f9f9f9;">Foo
13089 </td></tr></table>
13090
13091 !! html/parsoid
13092 <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}}]}'>
13093 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
13094 </tbody></table>
13095 !! end
13096
13097 # T107622
13098 !! test
13099 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13100 !! wikitext
13101 {|
13102 | {{table_attribs_6}} hi
13103 |}
13104 !! html/php
13105 <table>
13106 <tr>
13107 <td style="background: red;"> hi
13108 </td></tr></table>
13109
13110 !! html/parsoid
13111 <table>
13112 <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>
13113 </tbody></table>
13114 !! end
13115
13116 !!test
13117 Templates: HTML Tables: 1. Generating start of a HTML table
13118 !! wikitext
13119 {{echo|<table><tr><td>foo</td>}}</tr></table>
13120 !! html
13121 <table><tr><td>foo</td></tr></table>
13122
13123 !!end
13124
13125 !!test
13126 Templates: HTML Tables: 2a. Generating middle of a HTML table
13127 !! wikitext
13128 <table><tr>{{echo|<td>foo</td>}}</tr></table>
13129 !! html
13130 <table><tr><td>foo</td></tr></table>
13131
13132 !!end
13133
13134 !!test
13135 Templates: HTML Tables: 2b. Generating middle of a HTML table
13136 !! wikitext
13137 <table>{{echo|<tr><td>foo</td></tr>}}</table>
13138 !! html
13139 <table><tr><td>foo</td></tr></table>
13140
13141 !!end
13142
13143 !!test
13144 Templates: HTML Tables: 3. Generating end of a HTML table
13145 !! wikitext
13146 <table><tr>{{echo|<td>foo</td></tr></table>}}
13147 !! html
13148 <table><tr><td>foo</td></tr></table>
13149
13150 !!end
13151
13152 !!test
13153 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13154 !! wikitext
13155 {{echo|<table>}}<tr><td>foo</td></tr></table>
13156 !! html
13157 <table><tr><td>foo</td></tr></table>
13158
13159 !!end
13160
13161 !!test
13162 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13163 !! wikitext
13164 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13165 !! html
13166 <table><tr><td>foo</td></tr></table>
13167
13168 !!end
13169
13170 !!test
13171 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13172 !! wikitext
13173 <table><tr>{{echo|<td>}}foo</td></tr></table>
13174 !! html
13175 <table><tr><td>foo</td></tr></table>
13176
13177 !!end
13178
13179 !!test
13180 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13181 !! wikitext
13182 <table><tr><td>foo{{echo|</td>}}</tr></table>
13183 !! html
13184 <table><tr><td>foo</td></tr></table>
13185
13186 !!end
13187
13188 !!test
13189 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13190 !! wikitext
13191 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13192 !! html
13193 <table><tr><td>foo</td></tr></table>
13194
13195 !!end
13196
13197 !!test
13198 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13199 !! wikitext
13200 <table><tr><td>foo</td></tr>{{echo|</table>}}
13201 !! html
13202 <table><tr><td>foo</td></tr></table>
13203
13204 !!end
13205
13206 !!test
13207 Templates: HTML Tables: 5. Proper fostering of categories from inside
13208 !!options
13209 parsoid=wt2html,wt2wt
13210 !! wikitext
13211 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13212 <!--Two categories (T52330)-->
13213 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13214 !! html
13215 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13216 <!--Two categories (T52330)-->
13217 <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>
13218 !!end
13219
13220 !!test
13221 Templates: Wiki Tables: 1a. Fostering of entire template content
13222 !! wikitext
13223 {|
13224 {{echo|a}}
13225 |}
13226 !! html
13227 <table>
13228 a
13229 <tr><td></td></tr></table>
13230
13231 !! html+tidy
13232 <p>a</p>
13233 <table>
13234 <tr>
13235 <td></td>
13236 </tr>
13237 </table>
13238 !! end
13239
13240 !!test
13241 Templates: Wiki Tables: 1b. Fostering of entire template content
13242 !! wikitext
13243 {|
13244 {{echo|<div>}}
13245 foo
13246 {{echo|</div>}}
13247 |}
13248 !! html
13249 <table>
13250 <div>
13251 <p>foo
13252 </p>
13253 </div>
13254 <tr><td></td></tr></table>
13255
13256 !! html+tidy
13257 <div>
13258 <p>foo</p>
13259 </div>
13260 <table>
13261 <tr>
13262 <td></td>
13263 </tr>
13264 </table>
13265 !! end
13266
13267 !!test
13268 Templates: Wiki Tables: 2. Fostering of partial template content
13269 !! wikitext
13270 {|
13271 {{echo|a
13272 <div>b</div>}}
13273 |}
13274 !! html
13275 <table>
13276 a
13277 <div>b</div>
13278 <tr><td></td></tr></table>
13279
13280 !! html+tidy
13281 <p>a</p>
13282 <div>b</div>
13283 <table>
13284 <tr>
13285 <td></td>
13286 </tr>
13287 </table>
13288 !! end
13289
13290 !!test
13291 Templates: Wiki Tables: 3. td-content via multiple templates
13292 !! wikitext
13293 {|
13294 {{echo|{{pipe}}a}}{{echo|b}}
13295 |}
13296 !! html
13297 <table>
13298 <tr>
13299 <td>ab
13300 </td></tr></table>
13301
13302 !!end
13303
13304 !!test
13305 Templates: Wiki Tables: 4. Templated tags, no content
13306 !! wikitext
13307 {{tbl-start}}
13308 {{tbl-end}}
13309 !! html
13310 <table>
13311 <tr><td></td></tr></table>
13312
13313 !!end
13314
13315 !!test
13316 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13317 !! wikitext
13318 {{tbl-start}}
13319 |foo
13320 {{tbl-end}}
13321 !! html
13322 <table>
13323 <tr>
13324 <td>foo
13325 </td></tr></table>
13326
13327 !!end
13328
13329 !!test
13330 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13331 !! wikitext
13332 {{tbl-start}}
13333 {{!}}foo
13334 {{tbl-end}}
13335 !! html
13336 <table>
13337 <tr>
13338 <td>foo
13339 </td></tr></table>
13340
13341 !!end
13342
13343 ## This test case is very specific to Parsoid's internals
13344 ## and is hence only tested for Parsoid's code. Parsoid uses
13345 ## a <meta> marker tag for <ref> tags and they are expanded
13346 ## much later. We are verifying that this <meta> tag usage
13347 ## doesn't prevent foster parenting.
13348 !!test
13349 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13350 !!wikitext
13351 {{PartialTable}}<ref>foo</ref>
13352 |}
13353
13354 <references />
13355 !!html/parsoid
13356 <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">
13357 <tbody>
13358 </tbody></table>
13359
13360 <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>
13361 !!end
13362
13363 !! test
13364 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13365 !! wikitext
13366 {{echo|
13367 {{{!}}
13368 {{!}}-}}
13369 <onlyinclude>
13370 |foo
13371 </onlyinclude>
13372 {{!}}}
13373 !! html/parsoid
13374 <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{{!}}}"]}'>
13375 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13376 <tbody><tr>
13377
13378 <td>foo
13379 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13380 </tbody></table>
13381 !! end
13382
13383 !!test
13384 Templates: Lists: Multi-line list-items via templates
13385 !! wikitext
13386 *{{echo|a {{nonexistent|
13387 unused}}}}
13388 *{{echo|b {{nonexistent|
13389 unused}}}}
13390 !! html
13391 <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>
13392 <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>
13393
13394 !!end
13395
13396 !!test
13397 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13398 !! wikitext
13399 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13400 !! html
13401 <p><i>ab</i>c<i>d</i>e
13402 </p>
13403 !!end
13404
13405 !!test
13406 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13407 (PHP parser generates misnested html)
13408 !! wikitext
13409 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13410 !! html/parsoid
13411 <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>
13412 !!end
13413
13414 !!test
13415 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13416 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13417 !! options
13418 parsoid=wt2html,wt2wt
13419 !! wikitext
13420 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13421 !! html
13422 <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>
13423 <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>
13424 <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>
13425 !!end
13426
13427 !!test
13428 Templates: Ugly nesting: 4. Divs opened/closed across templates
13429 !! wikitext
13430 a<div>b{{echo|c</div>d}}e
13431 !! html
13432 a<div>bc</div>de
13433
13434 !! html+tidy
13435 <p>a</p>
13436 <div>bc</div>
13437 <p>de</p>
13438 !! end
13439
13440 !!test
13441 Templates: Ugly templates: 1. Navbox template parses badly leading to table misnesting
13442 (Parsoid-centric)
13443 !! options
13444 parsoid
13445 !! wikitext
13446 {|
13447 |{{echo|foo</table>}}
13448 |bar
13449 |}
13450 !! html
13451 <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|}"]}'>
13452
13453 <tbody>
13454 <tr>
13455 <td>foo</td></tr></tbody></table><span about="#mwt1">
13456 </span><span about="#mwt1">|bar</span><span about="#mwt1">
13457 |}</span>
13458 !!end
13459
13460 !!test
13461 Templates: Ugly templates: 2. Navbox template parses badly leading to table misnesting
13462 (Parsoid-centric)
13463 !! options
13464 parsoid
13465 !! wikitext
13466 <table>
13467 <tr>
13468 <td>
13469 <table>
13470 <tr>
13471 <td>1. {{echo|foo </table>}}</td>
13472 <td> bar </td>
13473 <td>2. {{echo|baz </table>}}</td>
13474 </tr>
13475 <tr>
13476 <td>abc</td>
13477 </tr>
13478 </table>
13479 </td>
13480 </tr>
13481 <tr>
13482 <td>xyz</td>
13483 </tr>
13484 </table>
13485 !! html
13486 <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>"]}'>
13487 <tbody><tr>
13488 <td>
13489 <table>
13490 <tbody><tr>
13491 <td>1. foo </td></tr></tbody></table></td>
13492 <td> bar </td>
13493 <td>2. baz </td></tr></tbody></table><span about="#mwt2">
13494 </span><span about="#mwt2">
13495 </span><span about="#mwt2">
13496 </span><span about="#mwt2">abc</span><span about="#mwt2">
13497 </span><span about="#mwt2">
13498 </span><span about="#mwt2">
13499 </span><span about="#mwt2">
13500 </span><span about="#mwt2">
13501 </span><span about="#mwt2">
13502 </span><span about="#mwt2">xyz</span><span about="#mwt2">
13503 </span><span about="#mwt2">
13504 </span>
13505 !!end
13506
13507 !! test
13508 Templates: Ugly templates: 3. newline-only template parameter
13509 !! wikitext
13510 foo {{echo|
13511 }}
13512 !! html
13513 <p>foo
13514 </p>
13515 !! end
13516
13517 # This looks like a bug: a single newline triggers p/br for some reason.
13518 !! test
13519 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13520 !! wikitext
13521 {{echo|
13522 }}
13523 !! html
13524 <p><br />
13525 </p>
13526 !! end
13527
13528 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13529 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13530 !! test
13531 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13532 !! wikitext
13533 {{echo|<table>}}
13534 {{echo|<div>foo}}
13535 {{echo|</table>}}
13536 !! html/parsoid
13537 <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
13538 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13539 </table>
13540 !! end
13541
13542 # T66017 -- ugly wikitext with fostered content generates two template ranges
13543 # that are "identical" and generate nesting cycles in the algorithm
13544 !! test
13545 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13546 !! wikitext
13547 {{echo|<table><tr><td><table>}}
13548 {{echo|<div>}}
13549 {{echo|</div>}}
13550 !! html/parsoid
13551 <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"}'>
13552 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13553 </table></td></tr></tbody></table>
13554 !! end
13555
13556 !! test
13557 Templates: Parameters substituted at the top-level
13558 !! wikitext
13559 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13560
13561 {{{foo|bar|baz}}}
13562 !! html/php
13563 <p><i>who</i> me? <b>never!</b>
13564 </p><p>bar
13565 </p>
13566 !! html/parsoid
13567 <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>
13568
13569 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13570 !! end
13571
13572 !! test
13573 Templates: Param with empty arg in the final position
13574 !! wikitext
13575 {{{hi|}}}
13576 !! html/parsoid
13577 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13578 !! end
13579
13580 !!test
13581 Parser Functions: 1. Simple example
13582 !! wikitext
13583 {{uc:foo}}
13584 !! html
13585 <p>FOO
13586 </p>
13587 !!end
13588
13589 !!test
13590 Parser Functions: 2. Nested use (only outermost should be marked up)
13591 !! wikitext
13592 {{uc:{{lc:FOO}}}}
13593 !! html
13594 <p>FOO
13595 </p>
13596 !!end
13597
13598 ###
13599 ### Pre-save transform tests
13600 ###
13601 !! test
13602 pre-save transform: subst:
13603 !! options
13604 pst
13605 !! wikitext
13606 {{subst:test}}
13607 !! html/php
13608 This is a test template
13609 !! end
13610
13611 !! test
13612 pre-save transform: normal template
13613 !! options
13614 pst
13615 !! wikitext
13616 {{test}}
13617 !! html/php
13618 {{test}}
13619 !! end
13620
13621 !! test
13622 pre-save transform: nonexistent template
13623 !! options
13624 pst
13625 !! wikitext
13626 {{thistemplatedoesnotexist}}
13627 !! html/php
13628 {{thistemplatedoesnotexist}}
13629 !! end
13630
13631 !! test
13632 pre-save transform: subst magic variables
13633 !! options
13634 pst
13635 !! wikitext
13636 {{subst:SITENAME}}
13637 !! html/php
13638 MediaWiki
13639 !! end
13640
13641 # This is T2089, which I fixed. -- wtm
13642 !! test
13643 pre-save transform: subst: templates with parameters
13644 !! options
13645 pst
13646 !! wikitext
13647 {{subst:paramtest|param="something else"}}
13648 !! html/php
13649 This is a test template with parameter "something else"
13650 !! end
13651
13652 !! article
13653 Template:nowikitest
13654 !! text
13655 <nowiki>'''not wiki'''</nowiki>
13656 !! endarticle
13657
13658 !! test
13659 pre-save transform: nowiki in subst (T3188)
13660 !! options
13661 pst
13662 !! wikitext
13663 {{subst:nowikitest}}
13664 !! html/php
13665 <nowiki>'''not wiki'''</nowiki>
13666 !! end
13667
13668 !! article
13669 Template:commenttest
13670 !! text
13671 This template has <!-- a comment --> in it.
13672 !! endarticle
13673
13674 !! test
13675 pre-save transform: comment in subst (T3936)
13676 !! options
13677 pst
13678 !! wikitext
13679 {{subst:commenttest}}
13680 !! html/php
13681 This template has <!-- a comment --> in it.
13682 !! end
13683
13684 !! test
13685 pre-save transform: unclosed tag
13686 !! options
13687 pst
13688 !! wikitext
13689 <nowiki>'''not wiki'''
13690 !! html/php
13691 <nowiki>'''not wiki'''
13692 !! end
13693
13694 !! test
13695 pre-save transform: mixed tag case
13696 !! options
13697 pst
13698 !! wikitext
13699 <NOwiki>'''not wiki'''</noWIKI>
13700 !! html/php
13701 <NOwiki>'''not wiki'''</noWIKI>
13702 !! end
13703
13704 !! test
13705 pre-save transform: unclosed comment in <nowiki>
13706 !! options
13707 pst
13708 !! wikitext
13709 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13710 !! html/php
13711 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13712 !!end
13713
13714 # Leading @ in this template definition works around a limitation
13715 # in parsoid's parserTests which otherwise strips the <span> from the
13716 # result (confusing it for a template wrapper)
13717 !! article
13718 Template:dangerous
13719 !!text
13720 @<span onmouseover="alert('crap')">Oh no</span>
13721 !!endarticle
13722
13723 !!test
13724 (confirming safety of fix for subst T3936)
13725 !! wikitext
13726 {{Template:dangerous}}
13727 !! html
13728 <p>@<span>Oh no</span>
13729 </p>
13730 !! end
13731
13732 !! test
13733 pre-save transform: comment containing gallery (T7024)
13734 !! options
13735 pst
13736 !! wikitext
13737 <!-- <gallery>data</gallery> -->
13738 !! html/php
13739 <!-- <gallery>data</gallery> -->
13740 !!end
13741
13742 !! test
13743 pre-save transform: comment containing extension
13744 !! options
13745 pst
13746 !! wikitext
13747 <!-- <tag>data</tag> -->
13748 !! html/php
13749 <!-- <tag>data</tag> -->
13750 !!end
13751
13752 !! test
13753 pre-save transform: comment containing nowiki
13754 !! options
13755 pst
13756 !! wikitext
13757 <!-- <nowiki>data</nowiki> -->
13758 !! html/php
13759 <!-- <nowiki>data</nowiki> -->
13760 !!end
13761
13762 !! test
13763 pre-save transform: <noinclude> in subst (T5298)
13764 !! options
13765 pst
13766 !! wikitext
13767 {{subst:Includes}}
13768 !! html/php
13769 Foobar
13770 !! end
13771
13772 !! test
13773 pre-save transform: <onlyinclude> in subst (T5298)
13774 !! options
13775 pst
13776 !! wikitext
13777 {{subst:Includes2}}
13778 !! html/php
13779 Foo
13780 !! end
13781
13782 !! article
13783 Template:SubstTest
13784 !!text
13785 {{<includeonly>subst:</includeonly>Includes}}
13786 !! endarticle
13787
13788 !! article
13789 Template:SafeSubstTest
13790 !! text
13791 {{<includeonly>safesubst:</includeonly>Includes}}
13792 !! endarticle
13793
13794 !! test
13795 T24297: safesubst: works during PST
13796 !! options
13797 pst
13798 !! wikitext
13799 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
13800 !! html/php
13801 FoobarFoobar
13802 !! end
13803
13804 !! test
13805 T24297: safesubst: works during normal parse
13806 !! wikitext
13807 {{SafeSubstTest}}
13808 !! html
13809 <p>Foobar
13810 </p>
13811 !! end
13812
13813 !! test
13814 subst: does not work during normal parse
13815 !! wikitext
13816 {{SubstTest}}
13817 !! html
13818 <p>{{subst:Includes}}
13819 </p>
13820 !! end
13821
13822 !! test
13823 pre-save transform: context links ("pipe trick")
13824 !! options
13825 pst
13826 !! wikitext
13827 [[Article (context)|]]
13828 [[Bar:Article|]]
13829 [[:Bar:Article|]]
13830 [[Bar:Article (context)|]]
13831 [[:Bar:Article (context)|]]
13832 [[|Article]]
13833 [[|Article (context)]]
13834 [[Bar:X (Y) Z|]]
13835 [[:Bar:X (Y) Z|]]
13836 !! html/php
13837 [[Article (context)|Article]]
13838 [[Bar:Article|Article]]
13839 [[:Bar:Article|Article]]
13840 [[Bar:Article (context)|Article]]
13841 [[:Bar:Article (context)|Article]]
13842 [[Article]]
13843 [[Article (context)]]
13844 [[Bar:X (Y) Z|X (Y) Z]]
13845 [[:Bar:X (Y) Z|X (Y) Z]]
13846 !! end
13847
13848 !! test
13849 pre-save transform: context links ("pipe trick") with interwiki prefix
13850 !! options
13851 pst
13852 !! wikitext
13853 [[interwiki:Article|]]
13854 [[:interwiki:Article|]]
13855 [[interwiki:Bar:Article|]]
13856 [[:interwiki:Bar:Article|]]
13857 !! html/php
13858 [[interwiki:Article|Article]]
13859 [[:interwiki:Article|Article]]
13860 [[interwiki:Bar:Article|Bar:Article]]
13861 [[:interwiki:Bar:Article|Bar:Article]]
13862 !! end
13863
13864 !! test
13865 pre-save transform: context links ("pipe trick") with parens in title
13866 !! options
13867 pst title=[[Somearticle (context)]]
13868 !! wikitext
13869 [[|Article]]
13870 !! html/php
13871 [[Article (context)|Article]]
13872 !! end
13873
13874 !! test
13875 pre-save transform: context links ("pipe trick") with comma in title
13876 !! options
13877 pst title=[[Someplace, Somewhere]]
13878 !! wikitext
13879 [[|Otherplace]]
13880 [[Otherplace, Elsewhere|]]
13881 [[Otherplace, Elsewhere, Anywhere|]]
13882 !! html/php
13883 [[Otherplace, Somewhere|Otherplace]]
13884 [[Otherplace, Elsewhere|Otherplace]]
13885 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
13886 !! end
13887
13888 !! test
13889 pre-save transform: context links ("pipe trick") with parens and comma
13890 !! options
13891 pst title=[[Someplace (IGNORED), Somewhere]]
13892 !! wikitext
13893 [[|Otherplace]]
13894 [[Otherplace (place), Elsewhere|]]
13895 !! html/php
13896 [[Otherplace, Somewhere|Otherplace]]
13897 [[Otherplace (place), Elsewhere|Otherplace]]
13898 !! end
13899
13900 !! test
13901 pre-save transform: context links ("pipe trick") with comma and parens
13902 !! options
13903 pst title=[[Who, me? (context)]]
13904 !! wikitext
13905 [[|Yes, you.]]
13906 [[Me, Myself, and I (1937 song)|]]
13907 !! html/php
13908 [[Yes, you. (context)|Yes, you.]]
13909 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
13910 !! end
13911
13912 !! test
13913 pre-save transform: context links ("pipe trick") with namespace
13914 !! options
13915 pst title=[[Ns:Somearticle]]
13916 !! wikitext
13917 [[|Article]]
13918 !! html/php
13919 [[Ns:Article|Article]]
13920 !! end
13921
13922 !! test
13923 pre-save transform: context links ("pipe trick") with namespace and parens
13924 !! options
13925 pst title=[[Ns:Somearticle (context)]]
13926 !! wikitext
13927 [[|Article]]
13928 !! html/php
13929 [[Ns:Article (context)|Article]]
13930 !! end
13931
13932 !! test
13933 pre-save transform: context links ("pipe trick") with namespace and comma
13934 !! options
13935 pst title=[[Ns:Somearticle, Context, Whatever]]
13936 !! wikitext
13937 [[|Article]]
13938 !! html/php
13939 [[Ns:Article, Context, Whatever|Article]]
13940 !! end
13941
13942 !! test
13943 pre-save transform: context links ("pipe trick") with namespace, comma and parens
13944 !! options
13945 pst title=[[Ns:Somearticle, Context (context)]]
13946 !! wikitext
13947 [[|Article]]
13948 !! html/php
13949 [[Ns:Article (context)|Article]]
13950 !! end
13951
13952 !! test
13953 pre-save transform: context links ("pipe trick") with namespace, parens and comma
13954 !! options
13955 pst title=[[Ns:Somearticle (IGNORED), Context]]
13956 !! wikitext
13957 [[|Article]]
13958 !! html/php
13959 [[Ns:Article, Context|Article]]
13960 !! end
13961
13962 !! test
13963 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
13964 !! options
13965 pst
13966 !! wikitext
13967 [[Article(context)|]]
13968 [[Bar:Article(context)|]]
13969 [[:Bar:Article(context)|]]
13970 [[|Article(context)]]
13971 [[Bar:X(Y)Z|]]
13972 [[:Bar:X(Y)Z|]]
13973 !! html/php
13974 [[Article(context)|Article]]
13975 [[Bar:Article(context)|Article]]
13976 [[:Bar:Article(context)|Article]]
13977 [[Article(context)]]
13978 [[Bar:X(Y)Z|X(Y)Z]]
13979 [[:Bar:X(Y)Z|X(Y)Z]]
13980 !! end
13981
13982 !! test
13983 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
13984 !! options
13985 pst
13986 !! wikitext
13987 [[Article (context)|]]
13988 [[Bar:Article (context)|]]
13989 [[:Bar:Article (context)|]]
13990 [[|Article (context)]]
13991 [[Bar:X (Y) Z|]]
13992 [[:Bar:X (Y) Z|]]
13993 !! html/php
13994 [[Article (context)|Article]]
13995 [[Bar:Article (context)|Article]]
13996 [[:Bar:Article (context)|Article]]
13997 [[Article (context)]]
13998 [[Bar:X (Y) Z|X (Y) Z]]
13999 [[:Bar:X (Y) Z|X (Y) Z]]
14000 !! end
14001
14002 !! test
14003 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
14004 !! options
14005 pst
14006 !! wikitext
14007 [[Article(context)|]]
14008 [[Bar:Article(context)|]]
14009 [[:Bar:Article(context)|]]
14010 [[|Article(context)]]
14011 [[Bar:X(Y)Z|]]
14012 [[:Bar:X(Y)Z|]]
14013 !! html/php
14014 [[Article(context)|Article]]
14015 [[Bar:Article(context)|Article]]
14016 [[:Bar:Article(context)|Article]]
14017 [[Article(context)]]
14018 [[Bar:X(Y)Z|X(Y)Z]]
14019 [[:Bar:X(Y)Z|X(Y)Z]]
14020 !! end
14021
14022 !! test
14023 pre-save transform: context links ("pipe trick") with commas (T23660)
14024 !! options
14025 pst
14026 !! wikitext
14027 [[Article (context), context|]]
14028 [[Article (context),context|]]
14029 [[Bar:Article (context), context|]]
14030 [[Bar:Article (context),context|]]
14031 [[:Bar:Article (context), context|]]
14032 [[:Bar:Article (context),context|]]
14033 !! html/php
14034 [[Article (context), context|Article]]
14035 [[Article (context),context|Article]]
14036 [[Bar:Article (context), context|Article]]
14037 [[Bar:Article (context),context|Article]]
14038 [[:Bar:Article (context), context|Article]]
14039 [[:Bar:Article (context),context|Article]]
14040 !! end
14041
14042 !! test
14043 Parsoid: backwards pipe trick
14044 !! wikitext
14045 [[|'''bar''']]
14046 !! html/php
14047 <p>[[|<b>bar</b>]]
14048 </p>
14049 !! html/parsoid
14050 <p>[[|<b>bar</b>]]</p>
14051 !! end
14052
14053 !! test
14054 pre-save transform: trim trailing empty lines
14055 !! options
14056 pst
14057 !! wikitext
14058 Empty lines are trimmed
14059
14060
14061
14062
14063 !! html/php
14064 Empty lines are trimmed
14065 !! end
14066
14067 !! test
14068 pre-save transform: Signature expansion
14069 !! options
14070 pst
14071 !! wikitext
14072 * ~~~
14073 * ~~~~
14074 * ~~~~~
14075 * <noinclude>~~~</noinclude>
14076 * <includeonly>~~~</includeonly>
14077 * <onlyinclude>~~~</onlyinclude>
14078 !! html/php
14079 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
14080 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14081 * 00:02, 1 January 1970 (UTC)
14082 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
14083 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
14084 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
14085 !! end
14086
14087
14088 !! test
14089 ParserOutput flags from signature expansion (T84843)
14090 !! options
14091 pst
14092 showflags
14093 !! wikitext
14094 ~~~~
14095 !! html/php
14096 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14097 flags=user-signature
14098 !! end
14099
14100
14101 !! test
14102 pre-save transform: Signature expansion in nowiki tags (T2093)
14103 !! options
14104 pst disabled
14105 !! wikitext
14106 Shall not expand:
14107
14108 <nowiki>~~~~</nowiki>
14109
14110 <includeonly><nowiki>~~~~</nowiki></includeonly>
14111
14112 <noinclude><nowiki>~~~~</nowiki></noinclude>
14113
14114 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14115
14116 {{subst:Foo}} shall be converted to FOO
14117
14118 As well as inside noinclude/onlyinclude
14119 <noinclude>{{subst:Foo}}</noinclude>
14120 <onlyinclude>{{subst:Foo}}</onlyinclude>
14121
14122 But not inside includeonly
14123 <includeonly>{{subst:Foo}}</includeonly>
14124 !! html/php
14125 Shall not expand:
14126
14127 <nowiki>~~~~</nowiki>
14128
14129 <includeonly><nowiki>~~~~</nowiki></includeonly>
14130
14131 <noinclude><nowiki>~~~~</nowiki></noinclude>
14132
14133 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14134
14135 FOO shall be converted to FOO
14136
14137 As well as inside noinclude/onlyinclude
14138 <noinclude>FOO</noinclude>
14139 <onlyinclude>FOO</onlyinclude>
14140
14141 But not inside includeonly
14142 <includeonly>{{subst:Foo}}</includeonly>
14143 !! end
14144
14145 !! test
14146 Parsoid: Recognize nowiki with trailing space in tags
14147 !! options
14148 parsoid=wt2html
14149 !! wikitext
14150 <nowiki ><div>[[foo]]</nowiki >
14151
14152 a<nowiki / >b
14153
14154 c<nowiki />d
14155
14156 e<nowiki/ >f
14157 !! html
14158 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14159 <p>ab</p>
14160 <p>cd</p>
14161 <p>ef</p>
14162 !! end
14163
14164 !! test
14165 Parsoid: Recognize nowiki with odd capitalization
14166 !! options
14167 parsoid=wt2html
14168 !! wikitext
14169 <noWikI ><div>[[foo]]</Nowiki >
14170 !! html
14171 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14172 !! end
14173
14174
14175 !! test
14176 Parsoid: Escape nowiki with trailing space in tags
14177 !! options
14178 parsoid=html2wt
14179 !! html/parsoid
14180 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14181 <p>a&lt;nowiki /&gt;b</p>
14182 <p>c&lt;nowiki/ &gt;d</p>
14183 !! wikitext
14184 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14185
14186 a&lt;nowiki /&gt;b
14187
14188 c&lt;nowiki/ &gt;d
14189 !! end
14190
14191 !! test
14192 Parsoid: Escape weird noWikI capitalizations
14193 !! options
14194 parsoid=html2wt
14195 !! html/parsoid
14196 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14197 !! wikitext
14198 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14199 !! end
14200
14201 ###
14202 ### Message transform tests
14203 ###
14204 !! test
14205 message transform: magic variables
14206 !! options
14207 msg
14208 !! wikitext
14209 {{SITENAME}}
14210 !! html
14211 MediaWiki
14212 !! end
14213
14214 !! test
14215 message transform: should not transform wiki markup
14216 !! options
14217 msg
14218 !! wikitext
14219 ''test''
14220 !! html
14221 ''test''
14222 !! end
14223
14224 !! test
14225 message transform: <noinclude> in transcluded template (T6926)
14226 !! options
14227 msg
14228 !! wikitext
14229 {{Includes}}
14230 !! html
14231 Foobar
14232 !! end
14233
14234 !! test
14235 message transform: <onlyinclude> in transcluded template (T6926)
14236 !! options
14237 msg
14238 !! wikitext
14239 {{Includes2}}
14240 !! html
14241 Foo
14242 !! end
14243
14244 !! test
14245 {{#special:}} page name, known
14246 !! options
14247 msg
14248 !! wikitext
14249 {{#special:Recentchanges}}
14250 !! html
14251 Special:RecentChanges
14252 !! end
14253
14254 !! test
14255 {{#special:}} page name with subpage, known
14256 !! options
14257 msg
14258 !! wikitext
14259 {{#special:Recentchanges/param}}
14260 !! html
14261 Special:RecentChanges/param
14262 !! end
14263
14264 !! test
14265 {{#special:}} page name, unknown
14266 !! options
14267 msg
14268 !! wikitext
14269 {{#special:foobar nonexistent}}
14270 !! html
14271 Special:Foobar nonexistent
14272 !! end
14273
14274 !! test
14275 {{#speciale:}} page name, known
14276 !! options
14277 msg
14278 !! wikitext
14279 {{#speciale:Recentchanges}}
14280 !! html
14281 Special:RecentChanges
14282 !! end
14283
14284 !! test
14285 {{#speciale:}} page name with subpage, known
14286 !! options
14287 msg
14288 !! wikitext
14289 {{#speciale:Recentchanges/param}}
14290 !! html
14291 Special:RecentChanges/param
14292 !! end
14293
14294 !! test
14295 {{#speciale:}} page name, unknown
14296 !! options
14297 msg
14298 !! wikitext
14299 {{#speciale:foobar nonexistent}}
14300 !! html
14301 Special:Foobar_nonexistent
14302 !! end
14303
14304 ###
14305 ### Images
14306 ###
14307 ### For Parsoid-specific tests, see
14308 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14309
14310 !! test
14311 Simple image
14312 !! options
14313 parsoid=wt2html,wt2wt,html2html
14314 !! wikitext
14315 [[Image:foobar.jpg]]
14316 !! html/php
14317 <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>
14318 </p>
14319 !! html/parsoid
14320 <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>
14321 !! end
14322
14323 !! test
14324 Serialize simple image with span wrapper
14325 !! options
14326 parsoid=html2wt
14327 !! html/parsoid
14328 <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>
14329 !! wikitext
14330 [[File:Foobar.jpg]]
14331 !! end
14332
14333 !! test
14334 Simple image (using File: namespace, now canonical)
14335 !! wikitext
14336 [[File:Foobar.jpg]]
14337 !! html/php
14338 <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>
14339 </p>
14340 !! html/parsoid
14341 <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>
14342 !! end
14343
14344 !! test
14345 Right-aligned image
14346 !! wikitext
14347 [[File:Foobar.jpg|right]]
14348 !! html/php
14349 <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>
14350
14351 !! html/parsoid
14352 <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>
14353 !! end
14354
14355 !! test
14356 Image with caption
14357 !! wikitext
14358 [[File:Foobar.jpg|right|Caption text]]
14359 !! html/php
14360 <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>
14361
14362 !! html/parsoid
14363 <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>
14364 !! end
14365
14366 !! test
14367 Image with caption, T55312 #1
14368 !! wikitext
14369 [[File:Foobar.jpg|right|Caption page stuff]]
14370 !! html/php
14371 <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>
14372
14373 !! html/parsoid
14374 <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>
14375 !! end
14376
14377 !! test
14378 Image with caption, T55312 #2
14379 !! wikitext
14380 [[File:Foobar.jpg|right|Caption page=]]
14381 !! html/php
14382 <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>
14383
14384 !! html/parsoid
14385 <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>
14386 !! end
14387
14388 !! test
14389 Image with caption, T55312 #3
14390 !! wikitext
14391 [[File:Foobar.jpg|right|Caption page=stuff]]
14392 !! html/php
14393 <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>
14394
14395 !! html/parsoid
14396 <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>
14397 !! end
14398
14399 !! test
14400 Image caption with pipe entity
14401 !! wikitext
14402 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14403 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14404 !! html/php
14405 <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>
14406 <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>
14407
14408 !! html/parsoid
14409 <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>
14410 <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>
14411 !! end
14412
14413 !! test
14414 Allow empty links in image captions (T62753)
14415 !! options
14416 thumbsize=220
14417 !! wikitext
14418 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14419 [[]]
14420 [[Link2]]
14421 ]]
14422 !! html/php
14423 <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>
14424
14425 !! html/parsoid
14426 <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>
14427 [[]]
14428 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14429 </figcaption></figure>
14430 !! end
14431
14432 !! test
14433 Titles in unlinked images (T23454)
14434 !! wikitext
14435 [[File:Foobar.jpg|link=|stuff]]
14436 !! html/php
14437 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
14438 </p>
14439 !! end
14440
14441 !! test
14442 Link with empty target
14443 !! wikitext
14444 [[]]
14445 !! html
14446 <p>[[]]
14447 </p>
14448 !! end
14449
14450 !! test
14451 Image with link trail
14452 !! wikitext
14453 Linktrails should not work for images: [[File:Foobar.jpg]]s
14454 !! html/php
14455 <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
14456 </p>
14457 !! html/parsoid
14458 <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>
14459 !! end
14460
14461 !! test
14462 Image with empty attribute
14463 !! options
14464 parsoid=wt2html,wt2wt,html2html
14465 !! wikitext
14466 [[File:Foobar.jpg|right||Caption text]]
14467 !! html/php
14468 <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>
14469
14470 !! html/parsoid
14471 <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>
14472 !! end
14473
14474 !! test
14475 1. Block image with individual attributes from templates
14476 !! wikitext
14477 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14478 !! html/php
14479 <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>
14480
14481 !! html/parsoid
14482 <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>
14483 !! end
14484
14485 !! test
14486 2. Block Image with individual attributes from templates
14487 !! wikitext
14488 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14489 !! html/php
14490 <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>
14491
14492 !! html/parsoid
14493 <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>
14494 !! end
14495
14496 !! test
14497 3. Inline image with individual attributes from templates
14498 !! wikitext
14499 [[File:Foobar.jpg|{{echo|50px}}]]
14500 !! html/php
14501 <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>
14502 </p>
14503 !! html/parsoid
14504 <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>
14505 !! end
14506
14507 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14508 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14509 !! test
14510 Image with multiple attributes from the same template
14511 !! wikitext
14512 [[File:Foobar.jpg|{{image_attribs}}]]
14513 !! html/php
14514 <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>
14515
14516 !! html/parsoid
14517 <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>
14518 !! end
14519
14520 !! test
14521 Image with link tails
14522 !! options
14523 thumbsize=220
14524 !! wikitext
14525 123[[File:Foobar.jpg]]456
14526 123[[File:Foobar.jpg|right]]456
14527 123[[File:Foobar.jpg|thumb]]456
14528 !! html/php
14529 <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
14530 </p>
14531 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
14532 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
14533
14534 !! html/php+tidy
14535 <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>
14536 <p>123</p>
14537 <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>
14538 <p>456 123</p>
14539 <div class="thumb tright">
14540 <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>
14541 <div class="thumbcaption">
14542 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
14543 </div>
14544 </div>
14545 </div>
14546 <p>456</p>
14547 !! html/parsoid
14548 <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>
14549 <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>
14550 <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>
14551 !! end
14552
14553 !! test
14554 Image with multiple captions -- only last one is accepted
14555 !! wikitext
14556 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14557 !! html/php
14558 <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>
14559
14560 !! html/parsoid
14561 <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>
14562 !! end
14563
14564 !! test
14565 Image with multiple widths -- use last
14566 !! wikitext
14567 [[File:Foobar.jpg|200px|300px|caption]]
14568 !! html/php
14569 <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>
14570 </p>
14571 !! html/parsoid
14572 <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>
14573 !! end
14574
14575 !! test
14576 Image with multiple alignments -- use first (T50664)
14577 !! options
14578 thumbsize=220
14579 !! wikitext
14580 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14581
14582 [[File:Foobar.jpg|middle|text-top|caption]]
14583 !! html/php
14584 <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>
14585 <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>
14586 </p>
14587 !! html/parsoid
14588 <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>
14589 <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>
14590 !! end
14591
14592 !! test
14593 Image with width attribute at different positions
14594 !! wikitext
14595 [[File:Foobar.jpg|200px|right|Caption]]
14596 [[File:Foobar.jpg|right|200px|Caption]]
14597 [[File:Foobar.jpg|right|Caption|200px]]
14598 !! html/php
14599 <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>
14600 <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>
14601 <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>
14602
14603 !! html/parsoid
14604 <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>
14605 <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>
14606 <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>
14607 !! end
14608
14609 # a sad bit of backward-compatibility
14610 !! test
14611 Image with size specified with pxpx (T15500, T53628)
14612 !! options
14613 parsoid=wt2html,wt2wt,html2html
14614 !! wikitext
14615 [[File:Foobar.jpg|20pxpx]]
14616 [[File:Foobar.jpg|200x20pxpx]]
14617 !! html/php
14618 <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>
14619 <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>
14620 </p>
14621 !! html/parsoid
14622 <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>
14623 !! end
14624
14625 !! test
14626 Image with link parameter, wiki target
14627 !! wikitext
14628 [[File:Foobar.jpg|link=Main Page]]
14629 !! html/php
14630 <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>
14631 </p>
14632 !! html/parsoid
14633 <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>
14634 !! end
14635
14636 # parsoid T51293 (part 1)
14637 !! test
14638 Image with link parameter, URL target
14639 !! wikitext
14640 [[File:Foobar.jpg|link=http://example.com/]]
14641 !! html/php
14642 <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>
14643 </p>
14644 !! html/parsoid
14645 <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>
14646 !! end
14647
14648 # parsoid T51293 (part 2)
14649 !! test
14650 Image with link parameter, protocol-less URL target
14651 !! wikitext
14652 [[File:Foobar.jpg|link=//example.com/]]
14653 !! html/php
14654 <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>
14655 </p>
14656 !! html/parsoid
14657 <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>
14658 !! end
14659
14660 !! test
14661 Escaping non-block captions (T107435)
14662 !! options
14663 parsoid={
14664 "modes": ["wt2wt"],
14665 "changes": [
14666 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14667 ]
14668 }
14669 !! wikitext
14670 [[Image:Foobar.jpg|caption]]
14671 !! wikitext/edited
14672 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14673 !! end
14674
14675 # wgExternalLinkTarget not supported by Parsoid
14676 !! test
14677 Image with link parameter, wgExternalLinkTarget
14678 !! wikitext
14679 [[Image:foobar.jpg|link=http://example.com/]]
14680 !! config
14681 wgExternalLinkTarget='foobar'
14682 !! html/php
14683 <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>
14684 </p>
14685 !! end
14686
14687 !! test
14688 Image with link parameter, wgNoFollowLinks set to false
14689 !! wikitext
14690 [[Image:foobar.jpg|link=http://example.com/]]
14691 !! config
14692 wgNoFollowLinks=false
14693 !! html
14694 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14695 </p>
14696 !! end
14697
14698 !! test
14699 Image with link parameter, wgNoFollowDomainExceptions
14700 !! wikitext
14701 [[Image:foobar.jpg|link=http://example.com/]]
14702 !! config
14703 wgNoFollowDomainExceptions='example.com'
14704 !! html
14705 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14706 </p>
14707 !! end
14708
14709 # wgExternalLinkTarget not supported by Parsoid
14710 !! test
14711 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14712 !! wikitext
14713 [[Image:foobar.jpg|link=http://example.com/|Title]]
14714 !! config
14715 wgExternalLinkTarget='foobar'
14716 !! html/php
14717 <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>
14718 </p>
14719 !! end
14720
14721 !! test
14722 Image with empty link parameter
14723 !! wikitext
14724 [[File:Foobar.jpg|link=]]
14725 !! html/php
14726 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14727 </p>
14728 !! html/parsoid
14729 <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>
14730 !! end
14731
14732 !! test
14733 Image with link parameter (wiki target) and unnamed parameter
14734 !! wikitext
14735 [[File:Foobar.jpg|link=Main_Page|Title]]
14736 !! html/php
14737 <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>
14738 </p>
14739 !! html/parsoid
14740 <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>
14741 !! end
14742
14743 !! test
14744 Image with link parameter (URL target) and unnamed parameter
14745 !! wikitext
14746 [[File:Foobar.jpg|link=http://example.com/|Title]]
14747 !! html/php
14748 <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>
14749 </p>
14750 !! html/parsoid
14751 <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>
14752 !! end
14753
14754 !! test
14755 Thumbnail image with link parameter
14756 !! options
14757 thumbsize=220
14758 parsoid=wt2html,wt2wt,html2html
14759 !! wikitext
14760 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14761 !! html/php
14762 <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>
14763
14764 !! html/parsoid
14765 <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>
14766 !! end
14767
14768 !! test
14769 Manually-specified thumbnail image
14770 !! options
14771 thumbsize=220
14772 !! wikitext
14773 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14774 !! html/php
14775 <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>
14776
14777 !! html/parsoid
14778 <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>
14779 !! end
14780
14781 !! test
14782 Manually-specified thumbnail image with explicit link to wiki page
14783 !! options
14784 thumbsize=220
14785 parsoid=wt2html,wt2wt,html2html
14786 !! wikitext
14787 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14788 !! html/php
14789 <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>
14790
14791 !! html/parsoid
14792 <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>
14793 !! end
14794
14795 !! test
14796 Manually-specified thumbnail image with explicit link to url
14797 !! options
14798 thumbsize=220
14799 parsoid=wt2html,wt2wt,html2html
14800 !! wikitext
14801 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14802 !! html/php
14803 <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>
14804
14805 !! html/parsoid
14806 <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>
14807 !! end
14808
14809 !! test
14810 Manually-specified thumbnail image with explicit no link
14811 !! options
14812 thumbsize=220
14813 parsoid=wt2html,wt2wt,html2html
14814 !! wikitext
14815 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14816 !! html/php
14817 <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>
14818
14819 !! html/parsoid
14820 <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>
14821 !! end
14822
14823 !! test
14824 Manually-specified thumbnail image with explicit link and alt text
14825 !! options
14826 thumbsize=220
14827 parsoid=wt2html,wt2wt,html2html
14828 !! wikitext
14829 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14830 !! html/php
14831 <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>
14832
14833 !! html/parsoid
14834 <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>
14835 !! end
14836
14837 !! test
14838 Image with frame and link
14839 !! options
14840 parsoid=wt2html,wt2wt,html2html
14841 !! wikitext
14842 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14843 !! html/php
14844 <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>
14845
14846 !! html/parsoid
14847 <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>
14848 !! end
14849
14850 !! test
14851 Image with frame and link and explicit alt
14852 !! options
14853 parsoid=wt2html,wt2wt,html2html
14854 !! wikitext
14855 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
14856 !! html/php
14857 <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>
14858
14859 !! html/parsoid
14860 <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>
14861 !! end
14862
14863 !! test
14864 Image with wiki markup in implicit alt
14865 !! wikitext
14866 [[Image:Foobar.jpg|testing '''bold''' in alt]]
14867
14868 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
14869 !! html/php
14870 <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>
14871 </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>
14872 </p>
14873 !! html/parsoid
14874 <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>
14875
14876 <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>
14877 !! end
14878
14879 !! test
14880 Alt image option should handle most kinds of wikitext without barfing
14881 !! wikitext
14882 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
14883 !! html/php
14884 <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>
14885
14886 !! html/parsoid
14887 <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>
14888 !! end
14889
14890 !! test
14891 Image with table with attributes in caption
14892 !! options
14893 parsoid=wt2html,html2html
14894 !! wikitext
14895 [[File:Foobar.jpg|thumb|
14896 {| class="123" |
14897 |- class="456" |
14898 | ha
14899 |}
14900 ]]
14901 !! html/parsoid
14902 <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>
14903 <table class="123">
14904 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
14905 <td> ha</td></tr>
14906 </tbody></table>
14907 </figcaption></figure>
14908 !! end
14909
14910 !! test
14911 Image with table with rows from templates in caption
14912 !! wikitext
14913 [[File:Foobar.jpg|thumb|
14914 {|
14915 {{echo|{{!}} hi}}
14916 |}
14917 ]]
14918 !! html/parsoid
14919 <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>
14920 <table>
14921 <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>
14922 </tbody></table>
14923 </figcaption></figure>
14924 !! end
14925
14926 !! test
14927 Image with nested tables in caption
14928 !! wikitext
14929 [[File:Foobar.jpg|thumb|Foo<br />
14930 {|
14931 |
14932 {|
14933 |z
14934 |}
14935 |}
14936 ]]
14937 !! html/parsoid
14938 <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}'/>
14939 <table>
14940 <tbody><tr><td>
14941 <table>
14942 <tbody><tr><td>z</td></tr>
14943 </tbody></table></td></tr>
14944 </tbody></table>
14945 </figcaption></figure>
14946 !! end
14947
14948 ###################
14949 # Conflicting image format options.
14950 # First option specified should 'win'.
14951 # All three cases in each test should be identical.
14952
14953 !! test
14954 Image with 'frameless' first.
14955 !! options
14956 parsoid=wt2html,wt2wt,html2html
14957 !! wikitext
14958 [[File:Foobar.jpg|frameless|caption]]
14959
14960 [[File:Foobar.jpg|frameless|frame|caption]]
14961
14962 [[File:Foobar.jpg|frameless|thumb|caption]]
14963 !! html/php
14964 <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>
14965 </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>
14966 </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>
14967 </p>
14968 !! html/parsoid
14969 <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>
14970 <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>
14971 <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>
14972 !! end
14973
14974 !! test
14975 Image with 'frame' first.
14976 !! options
14977 parsoid=wt2html,wt2wt,html2html
14978 !! wikitext
14979 [[File:Foobar.jpg|frame|caption]]
14980 [[File:Foobar.jpg|frame|frameless|caption]]
14981 [[File:Foobar.jpg|frame|thumb|caption]]
14982 !! html/php
14983 <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>
14984 <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>
14985 <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>
14986
14987 !! html/parsoid
14988 <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>
14989 <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>
14990 <figure class="mw-default-size" typeof="mw:Image/Frame"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>caption</figcaption></figure>
14991 !! end
14992
14993 !! test
14994 Image with 'thumb' first.
14995 !! options
14996 parsoid=wt2html,wt2wt,html2html
14997 !! wikitext
14998 [[File:Foobar.jpg|thumb|caption]]
14999 [[File:Foobar.jpg|thumb|frameless|caption]]
15000 [[File:Foobar.jpg|thumb|frame|caption]]
15001 !! html/php
15002 <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>
15003 <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>
15004 <div class="thumb tright"><div class="thumbinner" style="width:182px;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" width="180" height="20" class="thumbimage" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a> <div class="thumbcaption"><div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>caption</div></div></div>
15005
15006 !! html/parsoid
15007 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a><figcaption>caption</figcaption></figure>
15008 <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>
15009 <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>
15010 !! end
15011
15012 ###################
15013 # Image sizing.
15014 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
15015 # and https://phabricator.wikimedia.org/T64258
15016 # Foobar has actual size of 1941x220
15017 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
15018 # a scalable format.
15019 # 2. Framed images always ignore size options; always render at default size.
15020 # 3. "Unspecified format" and border are the only types which can be
15021 # enlarged.
15022
15023 !! test
15024 Image: unspecified format and border enlarge
15025 !! options
15026 parsoid=wt2html,wt2wt,html2html
15027 !! wikitext
15028 [[File:Foobar.jpg|2000px]]
15029
15030 [[File:Foobar.jpg|border|2000px]]
15031 !! html/php
15032 <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>
15033 </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>
15034 </p>
15035 !! html/parsoid
15036 <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>
15037 <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>
15038 !! end
15039
15040 !! test
15041 Image: "unspecified format" and border reduce
15042 !! options
15043 parsoid=wt2html,wt2wt,html2html
15044 !! wikitext
15045 [[File:Foobar.jpg|1000px]]
15046
15047 [[File:Foobar.jpg|border|1000px]]
15048 !! html/php
15049 <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>
15050 </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>
15051 </p>
15052 !! html/parsoid
15053 <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>
15054 <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>
15055 !! end
15056
15057 !! test
15058 Image: thumbs reduce
15059 !! options
15060 parsoid=wt2html,wt2wt,html2html
15061 !! wikitext
15062 [[File:Foobar.jpg|thumb|50px]]
15063 !! html/php
15064 <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>
15065
15066 !! html/parsoid
15067 <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>
15068 !! end
15069
15070 !! test
15071 Image: bitmap thumbs can't be enlarged past original size, but vector can.
15072 !! options
15073 parsoid=wt2html,wt2wt,html2html
15074 !! wikitext
15075 [[File:Foobar.jpg|thumb|2000px]]
15076
15077 [[File:Foobar.svg|thumb|2000px]]
15078 !! html/php
15079 <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>
15080 <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>
15081
15082 !! html/parsoid
15083 <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>
15084 <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>
15085 !! end
15086
15087 !! test
15088 Image: frameless can reduce in size
15089 !! options
15090 parsoid=wt2html,wt2wt,html2html
15091 !! wikitext
15092 [[File:Foobar.jpg|frameless|50px]]
15093 !! html/php
15094 <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>
15095 </p>
15096 !! html/parsoid
15097 <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>
15098 !! end
15099
15100 !! test
15101 Image: bitmap frameless can't be enlarged past original size, but vector can
15102 !! options
15103 parsoid=wt2html,wt2wt,html2html
15104 !! wikitext
15105 [[File:Foobar.jpg|frameless|2000px]]
15106
15107 [[File:Foobar.svg|frameless|2000px]]
15108 !! html/php
15109 <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>
15110 </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>
15111 </p>
15112 !! html/parsoid
15113 <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>
15114 <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>
15115 !! end
15116
15117 !! test
15118 Image: framed images are always unscaled.
15119 !! options
15120 parsoid=wt2html,wt2wt,html2html
15121 !! wikitext
15122 [[File:Foobar.jpg|frame]]
15123
15124 [[File:Foobar.jpg|frame|50px]]
15125
15126 [[File:Foobar.jpg|frame|50x50px]]
15127
15128 [[File:Foobar.jpg|frame|2000px]]
15129 !! html/php
15130 <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>
15131 <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>
15132 <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>
15133 <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>
15134
15135 !! html/parsoid
15136 <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>
15137 <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>
15138 <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>
15139 <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>
15140 !! end
15141
15142 ###################
15143
15144 !! test
15145 Link to image page- image page normally doesn't exists, hence edit link
15146 Add test with existing image page
15147 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
15148 !! wikitext
15149 [[:Image:test]]
15150 !! html
15151 <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>
15152 </p>
15153 !! end
15154
15155 !! test
15156 T20784 Link to non-existent image page with caption should use caption as link text
15157 !! wikitext
15158 [[:Image:test|caption]]
15159 !! html
15160 <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>
15161 </p>
15162 !! end
15163
15164 !! test
15165 Frameless image caption with a free URL
15166 !! wikitext
15167 [[File:Foobar.jpg|http://example.com]]
15168 !! html/php
15169 <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>
15170 </p>
15171 !! html/parsoid
15172 <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>
15173 !! end
15174
15175 !! test
15176 Thumbnail image caption with a free URL
15177 !! options
15178 thumbsize=220
15179 !! wikitext
15180 [[File:Foobar.jpg|thumb|http://example.com]]
15181 !! html/php
15182 <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>
15183
15184 !! html/parsoid
15185 <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>
15186 !! end
15187
15188 !! test
15189 Thumbnail image caption with a free URL and explicit alt
15190 !! options
15191 thumbsize=220
15192 parsoid=wt2html,wt2wt,html2html
15193 !! wikitext
15194 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
15195 !! html/php
15196 <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>
15197
15198 !! html/parsoid
15199 <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>
15200 !! end
15201
15202 !! test
15203 SVG thumbnails with no language set
15204 !! options
15205 !! wikitext
15206 [[File:Foobar.svg|thumb|caption]]
15207 !! html/php
15208 <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>
15209
15210 !! html/parsoid
15211 <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>
15212 !! end
15213
15214 !! test
15215 SVG thumbnails with language de
15216 !! options
15217 parsoid=wt2html,wt2wt,html2html
15218 !! wikitext
15219 [[File:Foobar.svg|thumb|caption|lang=de]]
15220 !! html/php
15221 <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>
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" lang="de" 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 invalid language code
15229 !! options
15230 parsoid=wt2html,wt2wt,html2html
15231 !! wikitext
15232 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
15233 !! html/php
15234 <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>
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" data-file-width="240" data-file-height="180" data-file-type="drawing" height="165" width="220"/></a><figcaption>lang=invalid:language:code</figcaption></figure>
15238 !! end
15239
15240 !! test
15241 T3887: A ISBN with a thumbnail
15242 !! wikitext
15243 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15244 !! html/php
15245 <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>
15246
15247 !! html/parsoid
15248 <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>
15249 !! end
15250
15251 !! test
15252 T3887: A RFC with a thumbnail
15253 !! wikitext
15254 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15255 !! html/php
15256 <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>
15257
15258 !! html/parsoid
15259 <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>
15260 !! end
15261
15262 !! test
15263 T3887: A mailto link with a thumbnail
15264 !! wikitext
15265 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15266 !! html/php
15267 <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>
15268
15269 !! html/parsoid
15270 <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>
15271 !! end
15272
15273 # Pending resolution to T2368
15274 !! test
15275 T2648: Frameless image caption with a link
15276 !! wikitext
15277 [[File:Foobar.jpg|text with a [[link]] in it]]
15278 !! html/php
15279 <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>
15280 </p>
15281 !! html/parsoid
15282 <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>
15283 !! end
15284
15285 !! test
15286 T2648: Frameless image caption with a link (suffix)
15287 !! wikitext
15288 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15289 !! html/php
15290 <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>
15291 </p>
15292 !! html/parsoid
15293 <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>
15294 !! end
15295
15296 !! test
15297 T2648: Frameless image caption with an interwiki link
15298 !! wikitext
15299 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15300 !! html/php
15301 <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>
15302 </p>
15303 !! html/parsoid
15304 <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>
15305 !! end
15306
15307 !! test
15308 T2648: Frameless image caption with a piped interwiki link
15309 !! wikitext
15310 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15311 !! html/php
15312 <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>
15313 </p>
15314 !! html/parsoid
15315 <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>
15316 !! end
15317
15318 !! test
15319 T107474: Frameless image caption with <nowiki>
15320 !! wikitext
15321 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15322 !! html/parsoid
15323 <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>
15324 !! end
15325
15326 !! test
15327 Escape HTML special chars in image alt text
15328 !! wikitext
15329 [[File:Foobar.jpg|& < > "]]
15330 !! html/php
15331 <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>
15332 </p>
15333 !! html/parsoid
15334 <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>
15335 !! end
15336
15337 !! test
15338 Escape HTML special chars in image alt text with LanguageConverter
15339 !! options
15340 language=zh
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 Entities in file name and attributes
15352 !! wikitext
15353 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
15354 !! html/php
15355 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
15356 </p>
15357 !! html/parsoid
15358 <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>
15359 !! end
15360
15361 !! test
15362 T2499: Alt text should have &#1234;, not &amp;1234;
15363 !! wikitext
15364 [[File:Foobar.jpg|&#9792;]]
15365 !! html/php
15366 <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>
15367 </p>
15368 !! html/parsoid
15369 <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>
15370 !! end
15371
15372 !! test
15373 Broken image caption with link
15374 !! options
15375 parsoid=wt2html,wt2wt,html2html
15376 !! wikitext
15377 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
15378 !! html/php
15379 <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.
15380 </p>
15381 !! html/parsoid
15382 <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>
15383 !! end
15384
15385 !! test
15386 Image caption containing another image
15387 !! wikitext
15388 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
15389 !! html/php
15390 <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>
15391
15392 !! html/parsoid
15393 <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>
15394 !! end
15395
15396 !! test
15397 Image: caption containing a newline
15398 !! wikitext
15399 [[File:Foobar.jpg|This
15400 *is some text]]
15401 !! html/php
15402 <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>
15403 </p>
15404 !! html/parsoid
15405 <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>
15406 !!end
15407
15408 !!test
15409 Image: caption containing leading space
15410 (The leading space should not trigger nowiki escaping in wt2wt mode)
15411 !! wikitext
15412 [[File:Foobar.jpg|thumb| bar]]
15413 !! html/php
15414 <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>
15415
15416 !! html/parsoid
15417 <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>
15418 !!end
15419
15420 !! test
15421 Image: caption containing a table
15422 !! options
15423 parsoid=wt2html,wt2wt,html2html
15424 !! wikitext
15425 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
15426 {|
15427 ! Foo !! Bar
15428 |-
15429 | Foo1 || Bar1
15430 |}
15431 and some more text.]]
15432 !! html/php
15433 <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>
15434
15435 !! html/parsoid
15436 <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
15437 <table>
15438 <tbody>
15439 <tr><th>Foo </th><th>Bar</th></tr>
15440 <tr>
15441 <td>Foo1 </td>
15442 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
15443 !! end
15444
15445 !! test
15446 T5090: External links other than http: in image captions
15447 !! wikitext
15448 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
15449 !! html/php
15450 <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>
15451
15452 !! html/parsoid
15453 <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>
15454 !! end
15455
15456 !! test
15457 Custom class
15458 !! options
15459 parsoid=wt2html,wt2wt,html2html
15460 !! wikitext
15461 [[Image:foobar.jpg|a|class=b]]
15462 !! html/php
15463 <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>
15464 </p>
15465 !! html/parsoid
15466 <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>
15467 !! end
15468
15469 !! test
15470 Localized image handling (1).
15471 !! options
15472 parsoid=wt2html,wt2wt,html2html
15473 language=es
15474 !! wikitext
15475 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
15476 !! html/php
15477 <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>
15478
15479 !! html/parsoid
15480 <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>
15481 !! end
15482
15483 !! test
15484 Localized image handling (2).
15485 !! options
15486 thumbsize=220
15487 parsoid=wt2html,wt2wt,html2html
15488 language=es
15489 !! wikitext
15490 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
15491 !! html/php
15492 <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>
15493
15494 !! html/parsoid
15495 <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>
15496 !! end
15497
15498 !! test
15499 Localized image handling (3).
15500 !! options
15501 language=fa
15502 parsoid=html2wt
15503 !! html/parsoid
15504 <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>
15505 !! wikitext
15506 [[File:Foobar.jpg|بندانگشتی]]
15507 !! end
15508
15509 !! test
15510 "border", "frameless" and "class" attributes on an image.
15511 !! options
15512 thumbsize=220
15513 parsoid=wt2html,wt2wt,html2html
15514 !! wikitext
15515 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
15516 !! html/php
15517 <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>
15518 </p>
15519 !! html/parsoid
15520 <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>
15521 !! end
15522
15523 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
15524 !! test
15525 Invalid image attributes (T64500)
15526 !! options
15527 thumbsize=220
15528 parsoid=wt2html,wt2wt,html2html
15529 !! wikitext
15530 [[File:Foobar.jpg|thumb|float|left|caption]]
15531
15532 [[File:Foobar.jpg|thumb|righ|caption]]
15533
15534 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
15535 !! html/php
15536 <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>
15537 <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>
15538 <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>
15539
15540 !! html/parsoid
15541 <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>
15542 <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>
15543 <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>
15544 !! end
15545
15546 !! article
15547 File:Barfoo.jpg
15548 !! text
15549 #REDIRECT [[File:Barfoo.jpg]]
15550 !! endarticle
15551
15552 # FIXME: Parsoid should run this test -- but we'd need to teach the
15553 # mockAPI about the redirected Barfoo.jpg image.
15554 !! test
15555 Redirected image
15556 !! wikitext
15557 [[Image:Barfoo.jpg]]
15558 !! html/php
15559 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
15560 </p>
15561 !! end
15562
15563 !! test
15564 Missing image with uploads disabled
15565 !! options
15566 wgEnableUploads=0
15567 !! wikitext
15568 [[File:Foobaz.jpg]]
15569 !! html/php
15570 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
15571 </p>
15572 !! html/parsoid
15573 <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>
15574 !! end
15575
15576 # Parsoid-specific testing for images
15577 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
15578 # Currently imperfect due to a flaw in the Parsoid testrunner
15579 # Work in progress
15580 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
15581 # image tests.
15582
15583 !! test
15584 Parsoid-specific image handling - simple image with size and middle alignment
15585 !! wikitext
15586 [[File:Foobar.jpg|middle|50px]]
15587 !! html/parsoid
15588 <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>
15589 !! end
15590
15591 !! test
15592 Parsoid-specific image handling - simple image with size, middle alignment,
15593 non-standard namespace alias
15594 !! options
15595 parsoid=wt2wt,wt2html,html2html
15596 !! wikitext
15597 [[Image:Foobar.jpg|middle|50px]]
15598 !! html/parsoid
15599 <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>
15600 !! end
15601
15602 !! test
15603 Parsoid-specific image handling - simple image with size and middle alignment
15604 (existing content)
15605 !! wikitext
15606 [[File:Foobar.jpg|50px|middle]]
15607 !! html/parsoid
15608 <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>
15609 !! end
15610
15611 !! test
15612 Parsoid-specific image handling - simple image with size and middle alignment
15613 and non-standard namespace name
15614 !! options
15615 parsoid=wt2html,wt2wt,html2html
15616 !! wikitext
15617 [[Image:Foobar.jpg|50px|middle]]
15618 !! html/parsoid
15619 <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>
15620 !! end
15621
15622 !! test
15623 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
15624 !! wikitext
15625 [[File:Foobar.jpg|500x10px|baseline|caption]]
15626 !! html/parsoid
15627 <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>
15628 !! end
15629
15630 !! test
15631 Parsoid-specific image handling - simple image with border and size spec
15632 !! wikitext
15633 [[File:Foobar.jpg|50px|border|caption]]
15634 !! html/parsoid
15635 <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>
15636 !! end
15637
15638 !! test
15639 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15640 !! wikitext
15641 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
15642 !! html/parsoid
15643 <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>
15644 !! end
15645
15646 !! test
15647 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15648 (existing content)
15649 !! wikitext
15650 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
15651 !! html/parsoid
15652 <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>
15653 !! end
15654
15655 !! test
15656 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
15657 !! wikitext
15658 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
15659 !! html/parsoid
15660 <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>
15661 !! end
15662
15663 !! test
15664 Parsoid-specific image handling - thumbnail with specific size, halign,
15665 valign, and caption (existing content)
15666 !! wikitext
15667 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
15668 !! html/parsoid
15669 <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>
15670 !! end
15671
15672 !! test
15673 Parsoid-specific image handling - framed image with specific size and caption
15674 (size is ignored)
15675 !! options
15676 parsoid=wt2html,wt2wt,html2html
15677 !! wikitext
15678 [[File:Foobar.jpg|frame|500x50px|caption]]
15679 !! html/parsoid
15680 <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>
15681 !! end
15682
15683 !! test
15684 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption
15685 (size is ignored)
15686 !! options
15687 parsoid=wt2html,wt2wt,html2html
15688 !! wikitext
15689 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
15690 !! html/parsoid
15691 <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>
15692 !! end
15693
15694 !! test
15695 Parsoid-specific image handling - frameless image with specific size, border, and caption
15696 !! wikitext
15697 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
15698 !! html/parsoid
15699 <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>
15700 !! end
15701
15702 !! test
15703 Parsoid-specific image handling - simple image with a formatted caption
15704 !! wikitext
15705 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
15706 !! html/parsoid
15707 <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>
15708 !! end
15709
15710 !! test
15711 Parsoid-specific image handling - caption with a template in it
15712 !! wikitext
15713 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
15714 !! html/parsoid
15715 <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>
15716 !! end
15717
15718 !! test
15719 Parsoid-specific image handling - caption with unbalanced tags in it
15720 !! options
15721 parsoid=wt2html,wt2wt,html2html
15722 !! wikitext
15723 foo
15724 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
15725 bar
15726 !! html/parsoid
15727 <p>foo</p>
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 <center>unbalanced tag in it.</center></figcaption></figure>
15729 <p>bar</p>
15730 !! end
15731
15732 !! test
15733 Parsoid-specific image handling - empty caption (1)
15734 !! options
15735 parsoid=wt2html,wt2wt
15736 !! wikitext
15737 [[File:Foobar.jpg|thumb|]]
15738 !! html/parsoid
15739 <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>
15740 !! end
15741
15742 # empty captions don't get serialized unless we're in the "round trip" case
15743 !! test
15744 Parsoid-specific image handling - empty caption (2)
15745 !! options
15746 parsoid=html2wt
15747 !! html/parsoid
15748 <figure class="mw-default-size" typeof="mw:Image/Thumb">
15749 <a href="./File:Foobar.jpg">
15750 <img resource="./File:Foobar.jpg"
15751 src="//example.com/images/3/3a/Foobar.jpg"
15752 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
15753 height="25" width="220"/>
15754 </a>
15755 <figcaption></figcaption>
15756 </figure>
15757 !! wikitext
15758 [[File:Foobar.jpg|thumb]]
15759 !! end
15760
15761 !! test
15762 Parsoid-specific image handling - whitespace caption
15763 !! wikitext
15764 [[File:Foobar.jpg|thumb| ]]
15765 !! html/parsoid
15766 <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>
15767 !! end
15768
15769 !! test
15770 Parsoid-specific image handling - lang option
15771 !! wikitext
15772 foo
15773 [[File:Foobar.svg|lang=de|caption]]
15774 bar
15775 !! html/parsoid
15776 <p>foo
15777 <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>
15778 bar</p>
15779 !! end
15780
15781 ## Edge case bugs in Parsoid from T93580
15782 !! test
15783 T93580: 1. Templated <ref> inside block images
15784 !! wikitext
15785 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
15786
15787 <references />
15788 !! html/parsoid
15789 <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>
15790
15791 <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>
15792 !! end
15793
15794 !! test
15795 T93580: 2. <ref> inside inline images
15796 !! wikitext
15797 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
15798
15799 <references />
15800 !! html/parsoid
15801 <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>
15802
15803 <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>
15804 !! end
15805
15806 !! test
15807 T93580: 3. Templated <ref> inside inline images
15808 !! wikitext
15809 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
15810
15811 <references />
15812 !! html/parsoid
15813 <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>
15814
15815 <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>
15816 !! end
15817
15818 ###
15819 ### Subpages
15820 ###
15821 !! article
15822 Subpage test/subpage
15823 !! text
15824 foo
15825 !! endarticle
15826
15827 !! test
15828 Subpage link
15829 !! options
15830 subpage title=[[Subpage test]]
15831 !! wikitext
15832 [[/subpage]]
15833 !! html
15834 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
15835 </p>
15836 !! end
15837
15838 !! test
15839 Subpage noslash link
15840 !! options
15841 subpage title=[[Subpage test]]
15842 !! wikitext
15843 [[/subpage/]]
15844 !! html
15845 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
15846 </p>
15847 !! end
15848
15849 !! article
15850 Subpage test/1/2/subpage
15851 !! text
15852 blah
15853 !! endarticle
15854
15855 !! test
15856 Relative subpage noslash link
15857 !! options
15858 parsoid=wt2wt,wt2html,html2html
15859 subpage title=[[Subpage test/1/2/3/4]]
15860 !! wikitext
15861 [[../../subpage/]]
15862
15863 [[../../subpage]]
15864 !! html/php
15865 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
15866 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
15867 </p>
15868 !! html/parsoid
15869 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
15870 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
15871 !! end
15872
15873 !! test
15874 Parsoid: dot-slash prefixed wikilinks
15875 !! wikitext
15876 [[./foo]]
15877
15878 [[././bar]]
15879
15880 [[././baz/]]
15881 !! html/php
15882 <p>[[./foo]]
15883 </p><p>[[././bar]]
15884 </p><p>[[././baz/]]
15885 </p>
15886 !! html/parsoid
15887 <p>[[./foo]]
15888 </p><p>[[././bar]]
15889 </p><p>[[././baz/]]
15890 </p>
15891 !! end
15892
15893 !! test
15894 Render invalid page names as plain text (T53090)
15895 !! wikitext
15896 [[./../foo|bar]]
15897 [[foo�|bar]]
15898 [[foo/.|bar]]
15899 [[foo/..|bar]]
15900 [[foo~~~bar]]
15901 [[foo>bar]]
15902 [[foo[bar]]
15903 [[.]]
15904 [[..]]
15905 [[foo././bar]]
15906 [[foo[http://example.com]xyz]]
15907
15908 [[{{echo|./../foo}}|bar]]
15909 [[{{echo|foo/.}}|bar]]
15910 [[{{echo|foo/..}}|bar]]
15911 [[{{echo|foo~~~~bar}}]]
15912 [[{{echo|foo>bar}}]]
15913 [[{{echo|foo././bar}}]]
15914 [[{{echo|foo{bar}}]]
15915 [[{{echo|foo}bar}}]]
15916 [[{{echo|foo[bar}}]]
15917 [[{{echo|foo]bar}}]]
15918 [[{{echo|foo<bar}}]]
15919 !!html/php
15920 <p>[[./../foo|bar]]
15921 [[foo�|bar]]
15922 [[foo/.|bar]]
15923 [[foo/..|bar]]
15924 [[foo~~~bar]]
15925 [[foo&gt;bar]]
15926 [[foo[bar]]
15927 [[.]]
15928 [[..]]
15929 [[foo././bar]]
15930 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
15931 </p><p>[[./../foo|bar]]
15932 [[foo/.|bar]]
15933 [[foo/..|bar]]
15934 [[foo~~~~bar]]
15935 [[foo&gt;bar]]
15936 [[foo././bar]]
15937 [[foo{bar]]
15938 [[foo}bar]]
15939 [[foo[bar]]
15940 [[foo]bar]]
15941 [[foo&lt;bar]]
15942 </p>
15943 !!html/parsoid
15944 <p>[[./../foo|bar]]
15945 [[foo�|bar]]
15946 [[foo/.|bar]]
15947 [[foo/..|bar]]
15948 [[foo~~~bar]]
15949 [[foo>bar]]
15950 [[foo[bar]]
15951 [[.]]
15952 [[..]]
15953 [[foo././bar]]
15954 [[foo<a rel="mw:ExtLink" href="http://example.com"></a>xyz]]</p>
15955
15956 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
15957 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
15958 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
15959 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
15960 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
15961 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
15962 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
15963 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
15964 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
15965 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
15966 [[<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>
15967 !!end
15968
15969 !! test
15970 Disabled subpages
15971 !! wikitext
15972 [[/subpage]]
15973 !! html
15974 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
15975 </p>
15976 !! end
15977
15978 !! test
15979 T2561: {{/Subpage}}
15980 !! options
15981 subpage title=[[Page]]
15982 !! wikitext
15983 {{/Subpage}}
15984 !! html
15985 <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>
15986 </p>
15987 !! end
15988
15989 ###
15990 ### Categories
15991 ###
15992 !! article
15993 Category:MediaWiki User's Guide
15994 !! text
15995 blah
15996 !! endarticle
15997
15998 !! test
15999 Link to category
16000 !! wikitext
16001 [[:Category:MediaWiki User's Guide]]
16002 !! html
16003 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
16004 </p>
16005 !! end
16006
16007 !! test
16008 Simple category
16009 !! options
16010 cat
16011 !! wikitext
16012 [[Category:MediaWiki User's Guide]]
16013 !! html/php
16014 cat=MediaWiki_User's_Guide sort=
16015 !! html/parsoid
16016 <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"}}'/>
16017 !! end
16018
16019 !! test
16020 PAGESINCATEGORY invalid title fatal (r33546 fix)
16021 !! wikitext
16022 {{PAGESINCATEGORY:<bogus>}}
16023 !! html
16024 <p>0
16025 </p>
16026 !! end
16027
16028 !! test
16029 Category with different sort key
16030 !! options
16031 cat
16032 !! wikitext
16033 [[Category:MediaWiki User's Guide|Foo]]
16034 !! html/php
16035 cat=MediaWiki_User's_Guide sort=Foo
16036 !! html/parsoid
16037 <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"}}'/>
16038 !! end
16039
16040 !! test
16041 Category with identical sort key
16042 !! options
16043 cat
16044 !! wikitext
16045 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16046 !! html/php
16047 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
16048 !! html/parsoid
16049 <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"}}'/>
16050 !! end
16051
16052 !! test
16053 Category with empty sort key
16054 !! options
16055 cat
16056 pst
16057 !! wikitext
16058 [[Category:MediaWiki User's Guide|]]
16059 !! html/php
16060 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16061 !! end
16062
16063 !! test
16064 Category with empty sort key and parentheses
16065 !! options
16066 cat
16067 pst
16068 !! wikitext
16069 [[Category:Foo (bar)|]]
16070 !! html/php
16071 [[Category:Foo (bar)|Foo]]
16072 !! end
16073
16074 !! test
16075 Category with link tail
16076 !! options
16077 cat
16078 pst
16079 !! wikitext
16080 123[[Category:Foo]]456
16081 !! html/php
16082 123[[Category:Foo]]456
16083 !! end
16084
16085 !! test
16086 Category with template
16087 !! options
16088 cat
16089 pst
16090 !! wikitext
16091 [[Category:{{echo|Foo}}]]
16092 !! html/php
16093 [[Category:{{echo|Foo}}]]
16094 !! end
16095
16096 !! test
16097 Category with template in sort key
16098 !! options
16099 cat
16100 pst
16101 !! wikitext
16102 [[Category:Foo|{{echo|Bar}}]]
16103 !! html/php
16104 [[Category:Foo|{{echo|Bar}}]]
16105 !! end
16106
16107 !! test
16108 Category with template in sort key and title
16109 !! options
16110 cat
16111 pst
16112 !! wikitext
16113 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16114 !! html/php
16115 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16116 !! end
16117
16118 ## We used to, but no longer wt2wt this test since the default serializer
16119 ## will normalize all categories to serialize on their own line.
16120 ## This wikitext usage is going to be fairly uncommon in production and
16121 ## selser will take care of preserving formatting in those scenarios.
16122 !! test
16123 Category / paragraph interactions
16124 !! options
16125 parsoid=wt2html
16126 !! wikitext
16127 Foo [[Category:Baz]] Bar
16128
16129 Foo [[Category:Baz]]
16130 Bar
16131
16132 Foo
16133 [[Category:Baz]]
16134 Bar
16135
16136 Foo
16137 [[Category:Baz]] Bar
16138
16139 Foo
16140 [[Category:Baz]]
16141 [[Category:Baz]]
16142 [[Category:Baz]]
16143 Bar
16144
16145 [[Category:Baz]]
16146 [[Category:Baz]]
16147 [[Category:Baz]]
16148
16149 [[Category:Baz]]
16150 {{echo|[[Category:Baz]]}}
16151 [[Category:Baz]]
16152 !! html/php
16153 <p>Foo Bar
16154 </p><p>Foo
16155 Bar
16156 </p><p>Foo
16157 Bar
16158 </p><p>Foo Bar
16159 </p><p>Foo
16160 Bar
16161 </p>
16162 !! html/parsoid
16163 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16164 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16165 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16166 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16167 <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>
16168 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
16169 !! end
16170
16171 ## We used to, but no longer wt2wt this test since the default serializer
16172 ## will normalize all categories to serialize on their own line.
16173 ## This wikitext usage is going to be fairly uncommon in production and
16174 ## selser will take care of preserving formatting in those scenarios.
16175 ##
16176 ## The whitespace on the empty line is part of the test. Please do not delete
16177 !! test
16178 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16179 !! options
16180 parsoid=wt2html
16181 !! wikitext
16182 This
16183
16184 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16185
16186 {{echo|[[Category:Foo]] and so should this!}}
16187 !! html/php
16188 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16189 </p>
16190 !! html/parsoid
16191 <p>This
16192
16193 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16194
16195 <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>
16196 !! end
16197
16198 ## Parsoid will not try to wt2wt this while preserving newlines because
16199 ## it suppresses excess newlines within list items -- and we don't want to
16200 ## introduce a special case just for categories, which is, in reality somewhat
16201 ## odd behavior -- categories are unlikely to be used in list items like this
16202 ## in top-level pages and are only likely to show up in template-generated
16203 ## list items where this RT-ing is a non-issue.
16204 ##
16205 ## The whitespace on the empty line is part of the test. Please do not delete
16206 !! test
16207 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16208 !! options
16209 parsoid=wt2html
16210 !! wikitext
16211 * This
16212
16213 [[Category:Foo]] and this should be part of the same list item
16214 * So should this
16215
16216 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16217 !! html
16218 <ul><li>This and this should be part of the same list item</li>
16219 <li>So should this and this should be part of the same list item</li></ul>
16220 !! html/parsoid
16221 <ul>
16222 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16223 <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>
16224 </ul>
16225 !! end
16226
16227 ## Newlines and categories that follow the last item of a list
16228 ## are treated differently because this (list followed by categories)
16229 ## is an extremely common pattern on wikis.
16230 !! test
16231 3. Categories and newlines: newline suppression for last list item should RT properly
16232 !! wikitext
16233 * a
16234 * b
16235
16236 [[Category:Foo]]
16237
16238 [[Category:Bar]]
16239 [[Category:Baz]]
16240 !! html/parsoid
16241 <ul><li> a</li>
16242 <li> b</li></ul>
16243
16244 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16245
16246 <link rel="mw:PageProp/Category" href="./Category:Bar" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16247 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16248 !! end
16249
16250 !! test
16251 4. Categories and newlines: newline suppression for last list item should RT properly
16252 !! wikitext
16253 * a
16254 **** b
16255
16256 [[Category:Foo]]
16257 !! html/parsoid
16258 <ul><li> a
16259 <ul><li><ul><li><ul><li> b</li></ul></li></ul></li></ul></li></ul>
16260
16261 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16262 !! end
16263
16264 ## only wt2html for this to make sure the algo only applies to the rightmost path
16265 !! test
16266 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16267 !! options
16268 parsoid=wt2html
16269 !! wikitext
16270 * a
16271 ** b
16272 [[Category:Foo]]
16273 * c
16274 ** d
16275 [[Category:Foo]]
16276 !! html/parsoid
16277 <ul><li> a
16278 <ul><li> b
16279 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16280 <li> c
16281 <ul><li> d</li></ul></li></ul>
16282 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16283 !! end
16284
16285 ## We used to, but no longer wt2wt this test since the default serializer
16286 ## will normalize all categories to serialize on their own line.
16287 ## This wikitext usage is going to be fairly uncommon in production and
16288 ## selser will take care of preserving formatting in those scenarios.
16289 !! test
16290 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16291 !! options
16292 parsoid=wt2html
16293 !! wikitext
16294 * a [[Category:Foo]]
16295 !! html/parsoid
16296 <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>
16297 !! end
16298
16299 # This test also demonstrates because of newline+category tunneling
16300 # through the list hander, template wrapping doesn't expand to the
16301 # containing list when the list item swallows the category.
16302 !! test
16303 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16304 !! wikitext
16305 * {{echo|a
16306 [[Category:Foo]]}}
16307 !! html/parsoid
16308 <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
16309 </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>
16310 !! end
16311
16312 !! test
16313 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
16314 !! wikitext
16315 * a
16316
16317 {{echo|[[Category:Foo]]
16318 [[Category:Bar]]}}
16319 [[Category:Baz]]
16320 !! html/parsoid
16321 <ul><li> a</li></ul>
16322
16323 <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">
16324 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16325 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16326 !! end
16327
16328 !! test
16329 9. Categories and newlines: should behave properly with linkprefix (T87753)
16330 !! options
16331 language=ar
16332 !! wikitext
16333 foo bar
16334 foo bar
16335 [[تصنيف:Foo]]
16336 [[تصنيف:Bar]]
16337 !! html/php
16338 <p>foo bar
16339 foo bar
16340 </p>
16341 !! html/parsoid
16342 <p>foo bar
16343 foo bar</p>
16344 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
16345 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
16346 !! end
16347
16348 !! test
16349 10. No regressions on internal links following category (T174639)
16350 !! options
16351 parsoid=wt2html,html2html
16352 !! wikitext
16353 [[Category:Foo]]<div>a
16354
16355 [[Foo]]</div>
16356 !! html/php
16357 <div>a
16358 <a href="/wiki/Foo" title="Foo">Foo</a></div>
16359
16360 !! html/parsoid
16361 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
16362
16363 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
16364 !! end
16365
16366 # Note that Parsoid differs slightly from PHP due to T175421
16367 !! test
16368 11. Special case where only newlines separate links (T175416)
16369 !! options
16370 parsoid=wt2html,html2html
16371 !! wikitext
16372 [[Category:Foo]]
16373
16374 [[Foo]][[es:Alimento]]
16375
16376 [[Foo]]
16377 !! html/php
16378 <p><br />
16379 <a href="/wiki/Foo" title="Foo">Foo</a>
16380 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
16381 </p>
16382 !! html/parsoid
16383 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16384
16385 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16386
16387 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
16388 !! end
16389
16390 !! test
16391 Category links with multiple namespaces
16392 !! wikitext
16393 [[Category:Project:Foo]]
16394 !! html/parsoid
16395 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
16396 !! end
16397
16398 !! test
16399 Parsoid: Serialize link to category page with colon escape
16400 !! options
16401 parsoid
16402 !! wikitext
16403
16404 [[:Category:Foo]]
16405 [[:Category:Foo|Bar]]
16406 !! html
16407 <p>
16408 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
16409 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
16410 </p>
16411 !! end
16412
16413 # We used to, but no longer wt2wt this test since the default serializer
16414 # will normalize all categories to serialize on their own line.
16415 # This wikitext usage is going to be fairly uncommon in production and
16416 # selser will take care of preventing whitespace insertion if this
16417 # occurs in an article.
16418 #
16419 # html2html disabled for the same reason (whitespace insertion between
16420 # x and y).
16421 #
16422 # html2wt disabled because it localizes the "Category" namespace.
16423 !! test
16424 Link prefix/suffixes aren't applied to category links
16425 !! options
16426 parsoid=wt2html
16427 language=is
16428 !! wikitext
16429 x[[Category:Foo]]y
16430 !! html/php
16431 <p>xy
16432 </p>
16433 !! html/parsoid
16434 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
16435 !! end
16436
16437 !! test
16438 Link prefix/suffixes aren't applied to language links
16439 !! options
16440 parsoid=wt2html
16441 language=is
16442 !! wikitext
16443 x[[es:Foo]]y
16444 !! html/php
16445 <p>xy
16446 </p>
16447 !! html/parsoid
16448 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
16449 !! end
16450
16451 !! test
16452 Parsoid: Serialize link to file page with colon escape
16453 !! options
16454 parsoid
16455 !! wikitext
16456
16457 [[:File:Foo.png]]
16458 [[:File:Foo.png|Bar]]
16459 !! html
16460 <p>
16461 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
16462 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
16463 </p>
16464 !! end
16465
16466 !! test
16467 Parsoid: Serialize a genuine category link without colon escape
16468 !! options
16469 parsoid
16470 !! wikitext
16471 [[Category:Foo]]
16472 [[Category:Foo|Bar]]
16473 !! html
16474 <link rel="mw:PageProp/Category" href="./Category:Foo">
16475 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
16476 !! end
16477
16478 !! test
16479 Normalize hrefs properly before testing for invalid link targets (T72894)
16480 !! options
16481 parsoid=html2wt
16482 !! html/parsoid
16483 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
16484 !! wikitext
16485 [[Category:Toxine bactérienne]]
16486 !! end
16487
16488 !! test
16489 Parsoid: Defaultsort
16490 !! wikitext
16491 {{DEFAULTSORT:Foo}}
16492 !! html/parsoid
16493 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
16494 !! end
16495
16496 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
16497 # But, this is a limitation of our representation and is documented in
16498 # TemplateHandler.js in processSpecialMagicWord
16499 !! test
16500 Parsoid: Defaultsort (template-generated)
16501 !! wikitext
16502 {{{{echo|DEFAULTSORT}}:Foo}}
16503 !! html/parsoid
16504 <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"}]]}'/>
16505 !! end
16506
16507 ###
16508 ### Inter-language links
16509 ###
16510 !! test
16511 Interlanguage links
16512 !! options
16513 ill
16514 !! wikitext
16515 [[es:Alimento]]
16516 [[fr:Nourriture]]
16517 [[zh:食品]]
16518 !! html/php
16519 es:Alimento fr:Nourriture zh:食品
16520 !! html/parsoid
16521 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16522 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
16523 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
16524 !! end
16525
16526 !! test
16527 Duplicate interlanguage links (T26502)
16528 !! options
16529 ill
16530 !! wikitext
16531 [[es:1]]
16532 [[es:2]]
16533 [[fr:1]]
16534 [[fr:2]]
16535 !! html/php
16536 es:1 fr:1
16537 !! html/parsoid
16538 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
16539 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
16540 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
16541 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
16542 !! end
16543
16544 ###
16545 ### Sections
16546 ###
16547 !! test
16548 Basic section headings
16549 !! wikitext
16550 == Headline 1 ==
16551 Some text
16552
16553 ==Headline 2==
16554 More
16555 ===Smaller headline===
16556 Blah blah
16557 !! html
16558 <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>
16559 <p>Some text
16560 </p>
16561 <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>
16562 <p>More
16563 </p>
16564 <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>
16565 <p>Blah blah
16566 </p>
16567 !! end
16568
16569 !! test
16570 Section headings with TOC
16571 !! wikitext
16572 == Headline 1 ==
16573 === Subheadline 1 ===
16574 ===== Skipping a level =====
16575 ====== Skipping a level ======
16576
16577 == Headline 2 ==
16578 Some text
16579 ===Another headline===
16580 !! html
16581 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16582 <ul>
16583 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
16584 <ul>
16585 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
16586 <ul>
16587 <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>
16588 <ul>
16589 <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>
16590 </ul>
16591 </li>
16592 </ul>
16593 </li>
16594 </ul>
16595 </li>
16596 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
16597 <ul>
16598 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
16599 </ul>
16600 </li>
16601 </ul>
16602 </div>
16603
16604 <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>
16605 <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>
16606 <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>
16607 <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>
16608 <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>
16609 <p>Some text
16610 </p>
16611 <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>
16612
16613 !! end
16614
16615 !! test
16616 TOC anchors don't collide
16617 !! wikitext
16618 __FORCETOC__
16619 == Headline 2 ==
16620 == Headline ==
16621 == Headline 2 ==
16622 == Headline ==
16623 !! html/php
16624 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16625 <ul>
16626 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
16627 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
16628 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
16629 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
16630 </ul>
16631 </div>
16632
16633 <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>
16634 <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>
16635 <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>
16636 <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>
16637
16638 !! end
16639
16640 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
16641 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
16642 !! test
16643 Handling of sections up to level 6 and beyond
16644 !! options
16645 parsoid=wt2html
16646 !! wikitext
16647 = Level 1 Heading=
16648 == Level 2 Heading==
16649 === Level 3 Heading===
16650 ==== Level 4 Heading====
16651 ===== Level 5 Heading=====
16652 ====== Level 6 Heading======
16653 ======= Level 7 Heading=======
16654 ======== Level 8 Heading========
16655 ========= Level 9 Heading=========
16656 ========== Level 10 Heading==========
16657 !! html/php
16658 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16659 <ul>
16660 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
16661 <ul>
16662 <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>
16663 <ul>
16664 <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>
16665 <ul>
16666 <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>
16667 <ul>
16668 <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>
16669 <ul>
16670 <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>
16671 <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>
16672 <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>
16673 <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>
16674 <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>
16675 </ul>
16676 </li>
16677 </ul>
16678 </li>
16679 </ul>
16680 </li>
16681 </ul>
16682 </li>
16683 </ul>
16684 </li>
16685 </ul>
16686 </div>
16687
16688 <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>
16689 <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>
16690 <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>
16691 <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>
16692 <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>
16693 <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>
16694 <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>
16695 <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>
16696 <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>
16697 <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>
16698
16699 !! html/parsoid
16700 <h1 id="Level_1_Heading" data-parsoid='{}'> Level 1 Heading</h1>
16701 <h2 id="Level_2_Heading" data-parsoid='{}'> Level 2 Heading</h2>
16702 <h3 id="Level_3_Heading" data-parsoid='{}'> Level 3 Heading</h3>
16703 <h4 id="Level_4_Heading" data-parsoid='{}'> Level 4 Heading</h4>
16704 <h5 id="Level_5_Heading" data-parsoid='{}'> Level 5 Heading</h5>
16705 <h6 id="Level_6_Heading" data-parsoid='{}'> Level 6 Heading</h6>
16706 <h6 id="=_Level_7_Heading=" data-parsoid='{}'><span id=".3D_Level_7_Heading.3D" typeof="mw:FallbackId"></span>= Level 7 Heading=</h6>
16707 <h6 id="==_Level_8_Heading==" data-parsoid='{}'><span id=".3D.3D_Level_8_Heading.3D.3D" typeof="mw:FallbackId"></span>== Level 8 Heading==</h6>
16708 <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>
16709 <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>
16710 !! end
16711
16712 !! test
16713 TOC regression (T11764)
16714 !! wikitext
16715 == title 1 ==
16716 === title 1.1 ===
16717 ==== title 1.1.1 ====
16718 === title 1.2 ===
16719 == title 2 ==
16720 === title 2.1 ===
16721 !! html
16722 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16723 <ul>
16724 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16725 <ul>
16726 <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>
16727 <ul>
16728 <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>
16729 </ul>
16730 </li>
16731 <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>
16732 </ul>
16733 </li>
16734 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16735 <ul>
16736 <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>
16737 </ul>
16738 </li>
16739 </ul>
16740 </div>
16741
16742 <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>
16743 <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>
16744 <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>
16745 <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>
16746 <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>
16747 <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>
16748
16749 !! end
16750
16751 !! test
16752 TOC for heading containing <span id="..."></span> (T96153)
16753 !! wikitext
16754 __FORCETOC__
16755 ==<span id="old-anchor"></span>New title==
16756 !! html/php
16757 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16758 <ul>
16759 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
16760 </ul>
16761 </div>
16762
16763 <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>
16764
16765 !! end
16766
16767 !! test
16768 TOC with wgMaxTocLevel=3 (T8204)
16769 !! options
16770 wgMaxTocLevel=3
16771 !! wikitext
16772 == title 1 ==
16773 === title 1.1 ===
16774 ==== title 1.1.1 ====
16775 === title 1.2 ===
16776 == title 2 ==
16777 === title 2.1 ===
16778 !! html
16779 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16780 <ul>
16781 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16782 <ul>
16783 <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>
16784 <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>
16785 </ul>
16786 </li>
16787 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16788 <ul>
16789 <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>
16790 </ul>
16791 </li>
16792 </ul>
16793 </div>
16794
16795 <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>
16796 <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>
16797 <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>
16798 <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>
16799 <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>
16800 <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>
16801
16802 !! end
16803
16804 !! test
16805 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
16806 !! options
16807 wgMaxTocLevel=3
16808 !! wikitext
16809 ==Section 1==
16810 ===Section 1.1===
16811 ====Section 1.1.1====
16812 ====Section 1.1.1.1====
16813 ==Section 2==
16814 !! html
16815 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16816 <ul>
16817 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
16818 <ul>
16819 <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>
16820 </ul>
16821 </li>
16822 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
16823 </ul>
16824 </div>
16825
16826 <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>
16827 <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>
16828 <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>
16829 <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>
16830 <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>
16831
16832 !! end
16833
16834
16835 !! test
16836 Resolving duplicate section names
16837 !! wikitext
16838 == Foo bar ==
16839 == Foo bar ==
16840 !! html
16841 <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>
16842 <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>
16843
16844 !! end
16845
16846 !! test
16847 Resolving duplicate section names with differing case (T12721)
16848 !! wikitext
16849 == Foo bar ==
16850 == Foo Bar ==
16851 !! html
16852 <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>
16853 <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>
16854
16855 !! end
16856
16857 !! article
16858 Template:sections
16859 !! text
16860 ===Section 1===
16861 ==Section 2==
16862 !! endarticle
16863
16864 !! test
16865 Template with sections, __NOTOC__
16866 !! wikitext
16867 __NOTOC__
16868 ==Section 0==
16869 {{sections}}
16870 ==Section 4==
16871 !! html
16872 <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>
16873 <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>
16874 <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>
16875 <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>
16876
16877 !! end
16878
16879 !! test
16880 __NOEDITSECTION__ keyword
16881 !! wikitext
16882 __NOEDITSECTION__
16883 ==Section 1==
16884 ==Section 2==
16885 !! html
16886 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
16887 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
16888
16889 !! end
16890
16891 !! test
16892 Link inside a section heading
16893 !! wikitext
16894 ==Section with a [[Main Page|link]] in it==
16895 !! html
16896 <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>
16897
16898 !! end
16899
16900 !! test
16901 TOC regression (T14077)
16902 !! wikitext
16903 __TOC__
16904 == title 1 ==
16905 === title 1.1 ===
16906 == title 2 ==
16907 !! html
16908 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16909 <ul>
16910 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16911 <ul>
16912 <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>
16913 </ul>
16914 </li>
16915 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
16916 </ul>
16917 </div>
16918
16919 <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>
16920 <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>
16921 <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>
16922
16923 !! end
16924
16925 !! test
16926 T3219 URL next to image (good)
16927 !! wikitext
16928 http://example.com [[File:Foobar.jpg]]
16929 !! html/php
16930 <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>
16931 </p>
16932 !! html/parsoid
16933 <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>
16934 !!end
16935
16936 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
16937 !! test
16938 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
16939 !! options
16940 parsoid=wt2html,html2html
16941 !! wikitext
16942 ===
16943 The line above must have a trailing space!
16944 === <!--
16945 --> <!-- -->
16946 But just in case it doesn't...
16947 !! html/php
16948 <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>
16949 <p>The line above must have a trailing space!
16950 </p>
16951 <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>
16952 <p>But just in case it doesn't...
16953 </p>
16954 !! html/parsoid
16955 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
16956 <p>The line above must have a trailing space!</p>
16957 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
16958 --> <!-- -->
16959 <p>But just in case it doesn't...</p>
16960 !! end
16961
16962 !! test
16963 Header with special characters (T27462)
16964 !! wikitext
16965 The tooltips shall not show entities to the user (ie. be double escaped)
16966
16967 == text > text ==
16968 section 1
16969
16970 == text < text ==
16971 section 2
16972
16973 == text & text ==
16974 section 3
16975
16976 == text ' text ==
16977 section 4
16978
16979 == text " text ==
16980 section 5
16981 !! html/php
16982 <p>The tooltips shall not show entities to the user (ie. be double escaped)
16983 </p>
16984 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
16985 <ul>
16986 <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>
16987 <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>
16988 <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>
16989 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
16990 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
16991 </ul>
16992 </div>
16993
16994 <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>
16995 <p>section 1
16996 </p>
16997 <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>
16998 <p>section 2
16999 </p>
17000 <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>
17001 <p>section 3
17002 </p>
17003 <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>
17004 <p>section 4
17005 </p>
17006 <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>
17007 <p>section 5
17008 </p>
17009 !! html/parsoid
17010 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
17011
17012 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span> text > text </h2>
17013 <p>section 1</p>
17014
17015 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span> text &lt; text </h2>
17016 <p>section 2</p>
17017
17018 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span> text &amp; text </h2>
17019 <p>section 3</p>
17020
17021 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span> text ' text </h2>
17022 <p>section 4</p>
17023
17024 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span> text " text </h2>
17025 <p>section 5</p>
17026 !! end
17027
17028 !! test
17029 Header with space, plus and underscore as entity
17030 !! wikitext
17031 Id should not contain + for spaces
17032
17033 == Space between Text ==
17034 section 1
17035
17036 == Space-Entity&#32;between&#32;Text ==
17037 section 2
17038
17039 == Plus+between+Text ==
17040 section 3
17041
17042 == Plus-Entity&#43;between&#43;Text ==
17043 section 4
17044
17045 == Underscore_between_Text ==
17046 section 5
17047
17048 == Underscore-Entity&#95;between&#95;Text ==
17049 section 6
17050
17051 [[#Space between Text]]
17052 [[#Space-Entity&#32;between&#32;Text]]
17053 [[#Plus+between+Text]]
17054 [[#Plus-Entity&#43;between&#43;Text]]
17055 [[#Underscore_between_Text]]
17056 [[#Underscore-Entity&#95;between&#95;Text]]
17057 !! html/php
17058 <p>Id should not contain + for spaces
17059 </p>
17060 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
17061 <ul>
17062 <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>
17063 <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>
17064 <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>
17065 <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>
17066 <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>
17067 <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>
17068 </ul>
17069 </div>
17070
17071 <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>
17072 <p>section 1
17073 </p>
17074 <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>
17075 <p>section 2
17076 </p>
17077 <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>
17078 <p>section 3
17079 </p>
17080 <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>
17081 <p>section 4
17082 </p>
17083 <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>
17084 <p>section 5
17085 </p>
17086 <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>
17087 <p>section 6
17088 </p><p><a href="#Space_between_Text">#Space between Text</a>
17089 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
17090 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
17091 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
17092 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
17093 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
17094 </p>
17095 !! html/parsoid
17096 <p>Id should not contain + for spaces</p>
17097
17098 <h2 id="Space_between_Text"> Space between Text </h2>
17099 <p>section 1</p>
17100
17101 <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>
17102 <p>section 2</p>
17103
17104 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span> Plus+between+Text </h2>
17105 <p>section 3</p>
17106
17107 <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>
17108 <p>section 4</p>
17109
17110 <h2 id="Underscore_between_Text"> Underscore_between_Text </h2>
17111 <p>section 5</p>
17112
17113 <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>
17114 <p>section 6</p>
17115
17116 <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>
17117 <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>
17118 <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>
17119 <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>
17120 <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>
17121 <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>
17122 !! end
17123
17124 # Parsoid html2wt disabled because it adds padding spaces around =
17125 !! test
17126 Headers with excess '=' characters
17127 (Are similar tests necessary beyond the 1st level?)
17128 !! options
17129 parsoid=wt2html,wt2wt,html2html
17130 !! wikitext
17131 =foo==
17132 ==foo=
17133 =''italic'' heading==
17134 ==''italic'' heading=
17135 !! html/php
17136 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
17137 <ul>
17138 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
17139 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
17140 <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>
17141 <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>
17142 </ul>
17143 </div>
17144
17145 <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>
17146 <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>
17147 <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>
17148 <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>
17149
17150 !! html/parsoid
17151 <h1 id="foo="><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
17152 <h1 id="=foo"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
17153 <h1 id="italic_heading="><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
17154 <h1 id="=italic_heading"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
17155 !! end
17156
17157 !! test
17158 HTML headers vs TOC (T25393)
17159 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17160 !! wikitext
17161 <h1>Header 1</h1>
17162 == Header 1.1 ==
17163 == Header 1.2 ==
17164
17165 <h1>Header 2
17166 </h1>
17167 == Header 2.1 ==
17168 == Header 2.2 ==
17169 __NOEDITSECTION__
17170 !! html/php
17171 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
17172 <ul>
17173 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17174 <ul>
17175 <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>
17176 <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>
17177 </ul>
17178 </li>
17179 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17180 <ul>
17181 <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>
17182 <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>
17183 </ul>
17184 </li>
17185 </ul>
17186 </div>
17187
17188 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17189 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17190 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17191 <h1><span class="mw-headline" id="Header_2">Header 2</span></h1>
17192 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17193 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17194
17195 !! html/parsoid
17196 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
17197 <h2 id="Header_1.1" data-parsoid='{}'> Header 1.1 </h2>
17198 <h2 id="Header_1.2" data-parsoid='{}'> Header 1.2 </h2>
17199
17200 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
17201 </h1>
17202 <h2 id="Header_2.1" data-parsoid='{}'> Header 2.1 </h2>
17203 <h2 id="Header_2.2" data-parsoid='{}'> Header 2.2 </h2>
17204 <meta property="mw:PageProp/noeditsection"/>
17205 !! end
17206
17207 !! test
17208 Single-line or multiline-comments can follow headings
17209 !! options
17210 parsoid=wt2html,wt2wt
17211 !! wikitext
17212 ==foo==<!---->
17213 ==bar==<!--c1-->
17214 ==baz==<!--
17215 c2
17216 c3-->
17217 !! html/php
17218 <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>
17219 <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>
17220 <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>
17221
17222 !! html/parsoid
17223 <h2 id="foo">foo</h2><!---->
17224 <h2 id="bar">bar</h2><!--c1-->
17225 <h2 id="baz">baz</h2><!--
17226 c2
17227 c3-->
17228 !! end
17229
17230 !! test
17231 T3219 URL next to image (broken)
17232 !! wikitext
17233 http://example.com[[File:Foobar.jpg]]
17234 !! html/php
17235 <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>
17236 </p>
17237 !! html/parsoid
17238 <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>
17239 !!end
17240
17241 !! test
17242 T3186 news: in the middle of text
17243 !! wikitext
17244 http://en.wikinews.org/wiki/Wikinews:Workplace
17245 !! html
17246 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
17247 </p>
17248 !!end
17249
17250
17251 !! test
17252 Namespaced link must have a title
17253 !! wikitext
17254 [[Project:]]
17255 !! html
17256 <p>[[Project:]]
17257 </p>
17258 !!end
17259
17260 !! test
17261 Namespaced link must have a title (bad fragment version)
17262 !! wikitext
17263 [[Project:#fragment]]
17264 !! html
17265 <p>[[Project:#fragment]]
17266 </p>
17267 !!end
17268
17269
17270 ###
17271 ### HTML tags and HTML attributes
17272 ###
17273
17274 !! test
17275 div with no attributes
17276 !! wikitext
17277 <div>HTML rocks</div>
17278 !! html
17279 <div>HTML rocks</div>
17280
17281 !! end
17282
17283 !! test
17284 div with double-quoted attribute
17285 !! wikitext
17286 <div id="rock">HTML rocks</div>
17287 !! html
17288 <div id="rock">HTML rocks</div>
17289
17290 !! end
17291
17292 !! test
17293 div with single-quoted attribute
17294 !! wikitext
17295 <div id='rock'>HTML rocks</div>
17296 !! html
17297 <div id="rock">HTML rocks</div>
17298
17299 !! end
17300
17301 !! test
17302 div with unquoted attribute
17303 !! wikitext
17304 <div id=rock>HTML rocks</div>
17305 !! html
17306 <div id="rock">HTML rocks</div>
17307
17308 !! end
17309
17310 !! test
17311 div with illegal double attributes
17312 !! wikitext
17313 <div id="a" id="b">HTML rocks</div>
17314 !! html
17315 <div id="b">HTML rocks</div>
17316
17317 !!end
17318
17319 !! test
17320 div with empty attribute value, space before equals
17321 !! options
17322 parsoid=wt2html,html2html
17323 !! wikitext
17324 <div class =>HTML rocks</div>
17325 !! html/php
17326 <div class="">HTML rocks</div>
17327
17328 !! html/parsoid
17329 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17330 !! end
17331
17332 !! test
17333 div with multiple empty attribute values
17334 !! config
17335 wgFragmentMode=[ 'html5', 'legacy' ]
17336 !! options
17337 parsoid=wt2html,html2html
17338 !! wikitext
17339 <div id= title=>HTML rocks</div>
17340 !! html/php
17341 <div id="title=">HTML rocks</div>
17342
17343 !! html/parsoid
17344 <div id="title=" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17345 !! end
17346
17347 !! test
17348 table with multiple empty attribute values
17349 !! options
17350 parsoid=wt2html,html2html
17351 !! wikitext
17352 {| title= id=
17353 | hi
17354 |}
17355 !! html/php
17356 <table title="id=">
17357 <tr>
17358 <td> hi
17359 </td></tr></table>
17360
17361 !! html/parsoid
17362 <table title="id=">
17363 <tbody><tr><td> hi</td></tr>
17364 </tbody></table>
17365 !! end
17366
17367 !! test
17368 div with braces in attribute value
17369 !! wikitext
17370 <div title="{}">Foo</div>
17371 !! html/php
17372 <div title="&#123;&#125;">Foo</div>
17373
17374 !! html/parsoid
17375 <div title="{}">Foo</div>
17376 !! end
17377
17378 !! test
17379 div with empty attribute value, no space before equals
17380 !! options
17381 parsoid=wt2html,html2html
17382 !! wikitext
17383 <div class=>HTML rocks</div>
17384 !! html/php
17385 <div class="">HTML rocks</div>
17386
17387 !! html/parsoid
17388 <div class="">HTML rocks</div>
17389 !! end
17390
17391 !! test
17392 HTML multiple attributes correction
17393 !! wikitext
17394 <p class="error" class="awesome">Awesome!</p>
17395 !! html
17396 <p class="awesome">Awesome!</p>
17397
17398 !!end
17399
17400 !! test
17401 Table multiple attributes correction
17402 !! wikitext
17403 {|
17404 !+ class="error" class="awesome"| status
17405 |}
17406 !! html
17407 <table>
17408 <tr>
17409 <th class="awesome"> status
17410 </th></tr></table>
17411
17412 !!end
17413
17414 !! test
17415 DIV IN UPPERCASE
17416 !! wikitext
17417 <DIV ID="x">HTML ROCKS</DIV>
17418 !! html
17419 <div id="x">HTML ROCKS</div>
17420
17421 !!end
17422
17423 !! test
17424 Non-ASCII pseudo-tags are rendered as text
17425 !! wikitext
17426 <khyô>
17427 !! html
17428 <p>&lt;khyô&gt;
17429 </p>
17430 !! end
17431
17432 !! test
17433 Pseudo-tag with URL 'name' renders as url link
17434 !! wikitext
17435 <http://example.com/>
17436 !! html
17437 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
17438 </p>
17439 !! end
17440
17441 !! test
17442 text with amp in the middle of nowhere
17443 !! wikitext
17444 Remember AT&T?
17445 !! html
17446 <p>Remember AT&amp;T?
17447 </p>
17448 !! end
17449
17450 !! test
17451 text with character entity: eacute
17452 !! wikitext
17453 I always thought &eacute; was a cute letter.
17454 !! html
17455 <p>I always thought &#233; was a cute letter.
17456 </p>
17457 !! html+tidy
17458 <p>I always thought é was a cute letter.</p>
17459 !! end
17460
17461 !! test
17462 text with entity-escaped character entity-like string: eacute
17463 !! wikitext
17464 I always thought &amp;eacute; was a cute letter.
17465 !! html
17466 <p>I always thought &amp;eacute; was a cute letter.
17467 </p>
17468 !! end
17469
17470 !! test
17471 text with undefined character entity: xacute
17472 !! wikitext
17473 I always thought &xacute; was a cute letter.
17474 !! html
17475 <p>I always thought &amp;xacute; was a cute letter.
17476 </p>
17477 !! end
17478
17479 !! test
17480 HTML5 tags
17481 !! wikitext
17482 <data value="5">five</data>
17483 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17484 <mark>This highlighted text</mark>
17485 !! html
17486 <p><data value="5">five</data>
17487 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17488 <mark>This highlighted text</mark>
17489 </p>
17490 !! end
17491
17492 !! test
17493 HTML tag with leading space is parsed as text
17494 !! wikitext
17495 < div>foo< /div>
17496 !! html
17497 <p>&lt; div&gt;foo&lt; /div&gt;
17498 </p>
17499 !! end
17500
17501 ## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
17502 ## the HTML5 parsing spec.
17503 !! test
17504 Element with broken attribute syntax
17505 !! options
17506 parsoid=wt2html
17507 !! wikitext
17508 <div style=" style="123">hi</div>
17509 <div =>ho</div>
17510 !! html/php
17511 <div style="123">hi</div>
17512 <div>ho</div>
17513
17514 !! html/parsoid
17515 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
17516 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
17517 !! end
17518
17519 ###
17520 ### Nesting tests (see T43545, T52604, T53081)
17521 ###
17522
17523 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
17524 # Note that html2wt is considerably more difficult if we use <b> in
17525 # the test case, instead of <small>
17526 !! test
17527 Ensure that HTML adoption agency algorithm is properly implemented.
17528 !! wikitext
17529 <small>X<small>Y</small>Z</small>
17530 !! html
17531 <p><small>X<small>Y</small>Z</small>
17532 </p>
17533 !! end
17534
17535 # This was T43545 in the PHP parser.
17536 # Note that tidy doesn't handle this correctly.
17537 !! test
17538 Nesting of <kbd>
17539 !! wikitext
17540 <kbd>X<kbd>Y</kbd>Z</kbd>
17541 !! html
17542 <p><kbd>X<kbd>Y</kbd>Z</kbd>
17543 </p>
17544 !! end
17545
17546 # The following cases were T53081 in the PHP parser.
17547 # Note that there are some other nestable tags (b, i, etc) which are
17548 # not covered; see T53081 for discussion.
17549
17550 # Note that tidy doesn't handle this correctly.
17551 !! test
17552 Nesting of <em>
17553 !! wikitext
17554 <em>X<em>Y</em>Z</em>
17555 !! html
17556 <p><em>X<em>Y</em>Z</em>
17557 </p>
17558 !! end
17559
17560 # Note that tidy doesn't handle this correctly.
17561 !! test
17562 Nesting of <strong>
17563 !! wikitext
17564 <strong>X<strong>Y</strong>Z</strong>
17565 !! html
17566 <p><strong>X<strong>Y</strong>Z</strong>
17567 </p>
17568 !! end
17569
17570 !! test
17571 Nesting of <q>
17572 !! wikitext
17573 <q>X<q>Y</q>Z</q>
17574 !! html+tidy
17575 <p><q>X<q>Y</q>Z</q></p>
17576 !! end
17577
17578 # Note that tidy doesn't handle this correctly.
17579 !! test
17580 Nesting of <ruby>
17581 !! wikitext
17582 <ruby>X<ruby>Y</ruby>Z</ruby>
17583 !! html
17584 <p><ruby>X<ruby>Y</ruby>Z</ruby>
17585 </p>
17586 !! end
17587
17588 # Note that tidy doesn't handle this correctly.
17589 !! test
17590 Nesting of <bdo>
17591 !! wikitext
17592 <bdo>X<bdo>Y</bdo>Z</bdo>
17593 !! html
17594 <p><bdo>X<bdo>Y</bdo>Z</bdo>
17595 </p>
17596 !! end
17597
17598
17599 ###
17600 ### Media links
17601 ###
17602
17603 !! test
17604 Media link
17605 !! wikitext
17606 [[Media:Foobar.jpg]]
17607 [[Media:Video.ogv]]
17608 [[:Media:Video.ogv]]
17609 !! html/php
17610 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
17611 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17612 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17613 </p>
17614 !! html/parsoid
17615 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
17616 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv">Media:Video.ogv</a>
17617 <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>
17618 !! end
17619
17620 !! test
17621 Media link with text
17622 !! wikitext
17623 [[Media:Foobar.jpg|A neat file to look at]]
17624 !! html/php
17625 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
17626 </p>
17627 !! html/parsoid
17628 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
17629 !! end
17630
17631 # FIXME: this is still bad HTML tag nesting
17632 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
17633 !! test
17634 Media link with nasty text
17635 !! wikitext
17636 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
17637 !! html/php
17638 <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>
17639
17640 !! html+php/tidy
17641 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link</a></p>
17642 <div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div>
17643 !! html/parsoid
17644 <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>
17645
17646 !! end
17647
17648 !! test
17649 Media link to nonexistent file (T3702)
17650 !! wikitext
17651 [[Media:No such.jpg]]
17652 [[Media:No_such file.jpg]]
17653 !! html/php
17654 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
17655 <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>
17656 </p>
17657 !! html/parsoid
17658 <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>
17659 <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>
17660 !! end
17661
17662 !! test
17663 Image link to nonexistent file (T3850 - good)
17664 !! wikitext
17665 [[File:No_such.jpg]]
17666 !! html/php
17667 <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>
17668 </p>
17669 !! html/parsoid
17670 <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>
17671 !! end
17672
17673 !! test
17674 :Image link to nonexistent file (T3850 - bad)
17675 !! wikitext
17676 [[:Image:No such.jpg]]
17677 !! html/php
17678 <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>
17679 </p>
17680 !! html/parsoid
17681 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
17682 !! end
17683
17684 !! test
17685 Character reference normalization in link text (T3938)
17686 !! wikitext
17687 [[Main Page|this&that]]
17688 !! html
17689 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
17690 </p>
17691 !!end
17692
17693 !! article
17694 אַ
17695 !! text
17696 Test for unicode normalization
17697
17698 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
17699 !! endarticle
17700
17701 !! test
17702 (T21451) Links should refer to the normalized form.
17703 !! wikitext
17704 [[&#xFB2E;]]
17705 [[&#x5d0;&#x5b7;]]
17706 [[&#x5d0;ַ]]
17707 [[א&#x5b7;]]
17708 [[אַ]]
17709 !! html
17710 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
17711 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
17712 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
17713 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
17714 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
17715 </p>
17716 !! end
17717
17718 !! test
17719 Empty attribute crash test (T4067)
17720 !! wikitext
17721 <font color="">foo</font>
17722 !! html
17723 <p><font color="">foo</font>
17724 </p>
17725 !! end
17726
17727 !! test
17728 Empty attribute crash test single-quotes (T4067)
17729 !! wikitext
17730 <font color=''>foo</font>
17731 !! html
17732 <p><font color="">foo</font>
17733 </p>
17734 !! end
17735
17736 !! test
17737 Attribute test: equals, then nothing
17738 !! options
17739 parsoid=wt2html,html2html
17740 !! wikitext
17741 <font color=>foo</font>
17742 !! html/php
17743 <p><font color="">foo</font>
17744 </p>
17745 !! html/parsoid
17746 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
17747 !! end
17748
17749 !! test
17750 Attribute test: unquoted value
17751 !! options
17752 parsoid=wt2html,html2html
17753 !! wikitext
17754 <font color=x>foo</font>
17755 !! html/php
17756 <p><font color="x">foo</font>
17757 </p>
17758 !! html/parsoid
17759 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
17760 !! end
17761
17762 !! test
17763 Attribute test: unquoted but illegal value (hash)
17764 !! wikitext
17765 <font color=#x>foo</font>
17766 !! html
17767 <p><font color="#x">foo</font>
17768 </p>
17769 !! end
17770
17771 # Parsoid does not serialize to empty attribute syntax,
17772 # so wt2wt and html2wt cases are skipped
17773 !! test
17774 Attribute test: no value (T54330)
17775 !! options
17776 parsoid=wt2html,html2html
17777 !! wikitext
17778 <font color>foo</font>
17779 !! html/php
17780 <p><font color="">foo</font>
17781 </p>
17782 !! html/parsoid
17783 <p><font color="">foo</font></p>
17784 !! end
17785
17786 !! test
17787 T4095: link with three closing brackets
17788 !! wikitext
17789 [[Main Page]]]
17790 !! html/php
17791 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
17792 </p>
17793 !! html/parsoid
17794 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
17795 !! end
17796
17797 !! test
17798 T4095: link with pipe and three closing brackets
17799 !! wikitext
17800 [[Main Page|link]]]
17801 !! html/php
17802 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
17803 </p>
17804 !! html/parsoid
17805 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
17806 !! end
17807
17808 !! test
17809 T4095: link with pipe and three closing brackets, version 2
17810 !! wikitext
17811 [[Main Page|[http://example.com/]]]
17812 !! html/php
17813 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
17814 </p>
17815 !! html/parsoid
17816 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
17817 !! end
17818
17819
17820 ###
17821 ### Safety
17822 ###
17823
17824 !! article
17825 Template:Dangerous attribute
17826 !! text
17827 " onmouseover="alert(document.cookie)
17828 !! endarticle
17829
17830 !! article
17831 Template:Dangerous style attribute
17832 !! text
17833 border-size: expression(alert(document.cookie))
17834 !! endarticle
17835
17836 !! article
17837 Template:Div style
17838 !! text
17839 <div style="float: right; {{{1}}}">Magic div</div>
17840 !! endarticle
17841
17842 !! test
17843 T4304: HTML attribute safety (safe template; regression T4309)
17844 !! wikitext
17845 <div title="{{test}}"></div>
17846 !! html/php
17847 <div title="This is a test template"></div>
17848
17849 !! html/parsoid
17850 <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>
17851 !! end
17852
17853 # Parsoid has enough context to handle this case
17854 !! test
17855 T4304: HTML attribute safety (dangerous template; 2309)
17856 !! wikitext
17857 <div title="{{dangerous attribute}}"></div>
17858 !! html/php
17859 <div title=""></div>
17860
17861 !! html/parsoid
17862 <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>
17863 !! end
17864
17865 !! test
17866 T4304: HTML attribute safety (dangerous style template; 2309)
17867 !! wikitext
17868 <div style="{{dangerous style attribute}}"></div>
17869 !! html/php
17870 <div style="/* insecure input */"></div>
17871
17872 !! html/parsoid
17873 <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>
17874 !! end
17875
17876 !! test
17877 T4304: HTML attribute safety (safe parameter; 2309)
17878 !! wikitext
17879 {{div style|width: 200px}}
17880 !! html/php
17881 <div style="float: right; width: 200px">Magic div</div>
17882
17883 !! html/parsoid
17884 <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>
17885 !! end
17886
17887 !! test
17888 T4304: HTML attribute safety (unsafe parameter; 2309)
17889 !! wikitext
17890 {{div style|width: expression(alert(document.cookie))}}
17891 !! html/php
17892 <div style="/* insecure input */">Magic div</div>
17893
17894 !! html/parsoid
17895 <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>
17896 !! end
17897
17898 ## Parsoid output here differs; needs investigation.
17899 !! test
17900 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
17901 !! wikitext
17902 {{div style|"><script>alert(document.cookie)</script>}}
17903 !! html
17904 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17905
17906 !! end
17907
17908 ## Parsoid output here differs; needs investigation.
17909 !! test
17910 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
17911 !! wikitext
17912 {{div style|" ><script>alert(document.cookie)</script>}}
17913 !! html
17914 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17915
17916 !! end
17917
17918 !! test
17919 T4304: HTML attribute safety (link)
17920 !! wikitext
17921 <div title="[[Main Page]]"></div>
17922 !! html/php
17923 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
17924
17925 !! html/parsoid
17926 <div title="[[Main Page]]"></div>
17927 !! end
17928
17929 !! test
17930 T4304: HTML attribute safety (italics)
17931 !! wikitext
17932 <div title="''foobar''"></div>
17933 !! html
17934 <div title="&#39;&#39;foobar&#39;&#39;"></div>
17935
17936 !! end
17937
17938 !! test
17939 T4304: HTML attribute safety (bold)
17940 !! wikitext
17941 <div title="'''foobar'''"></div>
17942 !! html
17943 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
17944
17945 !! end
17946
17947 !! test
17948 T4304: HTML attribute safety (ISBN)
17949 !! wikitext
17950 <div title="ISBN 1234567890"></div>
17951 !! html
17952 <div title="&#73;SBN 1234567890"></div>
17953
17954 !! end
17955
17956 !! test
17957 T4304: HTML attribute safety (RFC)
17958 !! wikitext
17959 <div title="RFC 1234"></div>
17960 !! html
17961 <div title="&#82;FC 1234"></div>
17962
17963 !! end
17964
17965 !! test
17966 T4304: HTML attribute safety (PMID)
17967 !! wikitext
17968 <div title="PMID 1234567890"></div>
17969 !! html
17970 <div title="&#80;MID 1234567890"></div>
17971
17972 !! end
17973
17974 !! test
17975 T4304: HTML attribute safety (web link)
17976 !! wikitext
17977 <div title="http://example.com/"></div>
17978 !! html
17979 <div title="http&#58;//example.com/"></div>
17980
17981 !! end
17982
17983 !! test
17984 T4304: HTML attribute safety (named web link)
17985 !! wikitext
17986 <div title="[http://example.com/ link]"></div>
17987 !! html/php
17988 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
17989
17990 !! html/parsoid
17991 <div title="[http://example.com/ link]"></div>
17992 !! end
17993
17994 !! test
17995 T5244: HTML attribute safety (extension; safe)
17996 !! wikitext
17997 <div style="<nowiki>background:blue</nowiki>"></div>
17998 !! html/php
17999 <div style="background:blue"></div>
18000
18001 !! html/parsoid
18002 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
18003 !! end
18004
18005 !! test
18006 T5244: HTML attribute safety (extension; unsafe)
18007 !! wikitext
18008 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
18009 !! html/php
18010 <div style="/* insecure input */"></div>
18011
18012 !! html/parsoid
18013 <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>
18014 !! end
18015
18016 # More MSIE fun discovered by Tom Gilder
18017
18018 !! test
18019 MSIE CSS safety test: spurious slash
18020 !! wikitext
18021 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
18022 !! html/php
18023 <div style="/* insecure input */">evil</div>
18024
18025 !! html/parsoid
18026 <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>
18027 !! end
18028
18029 !! test
18030 MSIE CSS safety test: hex code
18031 !! wikitext
18032 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
18033 !! html/php
18034 <div style="/* insecure input */">evil</div>
18035
18036 !! html/parsoid
18037 <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>
18038 !! end
18039
18040 !! test
18041 MSIE CSS safety test: comment in url
18042 !! wikitext
18043 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
18044 !! html/php
18045 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
18046
18047 !! html/parsoid
18048 <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>
18049 !! end
18050
18051 !! test
18052 MSIE CSS safety test: comment in expression
18053 !! wikitext
18054 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
18055 !! html/php
18056 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
18057
18058 !! html/parsoid
18059 <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>
18060 !! end
18061
18062 !! test
18063 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
18064 !! wikitext
18065 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
18066 !! html/php
18067 <p style="/* invalid control char */">A</p>
18068
18069 !! html/parsoid
18070 <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>
18071 !! end
18072
18073 !! test
18074 MSIE 6 CSS safety test: Fullwidth (T57332)
18075 !! wikitext
18076 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
18077 <div style="top:EXPRESSION(alert())">B</div>
18078 !! html/php
18079 <p style="/* insecure input */">A</p>
18080 <div style="/* insecure input */">B</div>
18081
18082 !! html/parsoid
18083 <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>
18084 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
18085 !! end
18086
18087 !! test
18088 MSIE 6 CSS safety test: IPA extensions (T57332)
18089 !! wikitext
18090 <div style="background-image:uʀʟ(javascript:alert())">A</div>
18091 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
18092 !! html/php
18093 <div style="/* insecure input */">A</div>
18094 <p style="/* insecure input */">B</p>
18095
18096 !! html/parsoid
18097 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
18098 <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>
18099 !! end
18100
18101 !! test
18102 MSIE 6 CSS safety test: sup/sub script (T57332)
18103 !! wikitext
18104 <div style="background-image:url⁽javascript:alert())">A</div>
18105 <div style="background-image:url₍javascript:alert())">B</div>
18106 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
18107 !! html/php
18108 <div style="/* insecure input */">A</div>
18109 <div style="/* insecure input */">B</div>
18110 <p style="/* insecure input */">C</p>
18111
18112 !! html/parsoid
18113 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
18114 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
18115 <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>
18116 !! end
18117
18118 !! test
18119 Opera -o-link CSS
18120 !! options
18121 parsoid=wt2html,html2html
18122 !! wikitext
18123 <div
18124 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;"
18125 style="-o-link:attr(title);-o-link-source:current">X</div>
18126 !! html/php
18127 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
18128
18129 !! html/parsoid
18130 <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>
18131 !! end
18132
18133 !! test
18134 MSIE 6 CSS safety test: Repetition markers (T57332)
18135 !! wikitext
18136 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
18137 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
18138 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
18139 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
18140 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
18141 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
18142 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
18143 !! html/php
18144 <p style="/* insecure input */">A</p>
18145 <p style="/* insecure input */">B</p>
18146 <p style="/* insecure input */">C</p>
18147 <p style="/* insecure input */">D</p>
18148 <p style="/* insecure input */">E</p>
18149 <p style="/* insecure input */">F</p>
18150 <p style="/* insecure input */">G</p>
18151
18152 !! html/parsoid
18153 <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>
18154 <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>
18155 <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>
18156 <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>
18157 <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>
18158 <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>
18159 <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>
18160 !! end
18161
18162 !! test
18163 Table attribute legitimate extension
18164 !! wikitext
18165 {|
18166 !+ style="<nowiki>color:blue</nowiki>"| status
18167 |}
18168 !! html
18169 <table>
18170 <tr>
18171 <th style="color:blue"> status
18172 </th></tr></table>
18173
18174 !!end
18175
18176 !! test
18177 Table attribute safety
18178 !! wikitext
18179 {|
18180 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
18181 |}
18182 !! html
18183 <table>
18184 <tr>
18185 <th style="/* insecure input */"> status
18186 </th></tr></table>
18187
18188 !! end
18189
18190 !! test
18191 CSS line continuation 1
18192 !! wikitext
18193 <div style="background-image: u\&#10;rl(test.jpg);"></div>
18194 !! html
18195 <div style="/* insecure input */"></div>
18196
18197 !! end
18198
18199 !! test
18200 CSS line continuation 2
18201 !! wikitext
18202 <div style="background-image: u\&#13;rl(test.jpg); "></div>
18203 !! html
18204 <div style="/* invalid control char */"></div>
18205
18206 !! end
18207
18208 !! article
18209 Template:Identity
18210 !! text
18211 {{{1}}}
18212 !! endarticle
18213
18214 !! test
18215 Expansion of multi-line templates in attribute values (T8255)
18216 !! wikitext
18217 <div style="background: {{identity|#00FF00}}">-</div>
18218 !! html
18219 <div style="background: #00FF00">-</div>
18220
18221 !! end
18222
18223 !! test
18224 Expansion of multi-line templates in attribute values (T8255 sanity check)
18225 !! wikitext
18226 <div style="background:
18227 #00FF00">-</div>
18228 !! html/php
18229 <div style="background: #00FF00">-</div>
18230
18231 !! html/parsoid
18232 <div style="background:
18233 #00FF00">-</div>
18234 !! end
18235
18236 !! test
18237 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
18238 !! wikitext
18239 <div style="background: &#10;#00FF00">-</div>
18240 !! html
18241 <div style="background: &#10;#00FF00">-</div>
18242
18243 !! end
18244
18245 !! test
18246 Tags which are hidden from Tidy cannot pass through the Sanitizer
18247 !! wikitext
18248 <mw:toc><script>alert();</script></mw:toc>
18249 !! html+tidy
18250 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;</p>
18251 !! end
18252
18253 ###
18254 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
18255 ###
18256
18257 !! test
18258 Parser hook: empty input
18259 !! wikitext
18260 <tag></tag>
18261 !! html/php
18262 <pre>
18263 ''
18264 array (
18265 )
18266 </pre>
18267
18268 !! html/parsoid
18269 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18270 !! end
18271
18272 ## Don't expect parsoid to rt this form.
18273 !! test
18274 Parser hook: empty input using terminated empty elements
18275 !! options
18276 parsoid=wt2html,html2html
18277 !! wikitext
18278 <tag/>
18279 !! html/php
18280 <pre>
18281 NULL
18282 array (
18283 )
18284 </pre>
18285
18286 !! html/parsoid
18287 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18288 !! end
18289
18290 !! test
18291 Parser hook: empty input using terminated empty elements (space before)
18292 !! wikitext
18293 <tag />
18294 !! html/php
18295 <pre>
18296 NULL
18297 array (
18298 )
18299 </pre>
18300
18301 !! html/parsoid
18302 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18303 !! end
18304
18305 !! test
18306 Parser hook: basic input
18307 !! wikitext
18308 <tag>input</tag>
18309 !! html/php
18310 <pre>
18311 'input'
18312 array (
18313 )
18314 </pre>
18315
18316 !! html/parsoid
18317 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18318 !! end
18319
18320 ## Don't expect parsoid to rt this form.
18321 !! test
18322 Parser hook: case insensitive
18323 !! options
18324 parsoid=wt2html,html2html
18325 !! wikitext
18326 <TAG>input</TAG>
18327 !! html/php
18328 <pre>
18329 'input'
18330 array (
18331 )
18332 </pre>
18333
18334 !! html/parsoid
18335 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18336 !! end
18337
18338 ## Don't expect parsoid to rt this form.
18339 !! test
18340 Parser hook: case insensitive, redux
18341 !! options
18342 parsoid=wt2html,html2html
18343 !! wikitext
18344 <TaG>input</TAg>
18345 !! html/php
18346 <pre>
18347 'input'
18348 array (
18349 )
18350 </pre>
18351
18352 !! html/parsoid
18353 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18354 !! end
18355
18356 !! test
18357 Parser hook: nested tags
18358 !! wikitext
18359 <tag><tag></tag></tag>
18360 !! html/php
18361 <pre>
18362 '<tag>'
18363 array (
18364 )
18365 </pre>&lt;/tag&gt;
18366
18367 !! html/parsoid
18368 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}' data-parsoid='{}' about="#mwt2"></pre>&lt;/tag>
18369 !! end
18370
18371 !! test
18372 Parser hook: basic arguments
18373 !! wikitext
18374 <tag width="200" height="100" depth="50" square=""></tag>
18375 !! html/php
18376 <pre>
18377 ''
18378 array (
18379 'width' => '200',
18380 'height' => '100',
18381 'depth' => '50',
18382 'square' => '',
18383 )
18384 </pre>
18385
18386 !! html/parsoid
18387 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18388 !! end
18389
18390 ## Don't expect parsoid to rt this form.
18391 !! test
18392 Parser hook: basic arguments, variations
18393 !! options
18394 parsoid=wt2html,html2html
18395 !! wikitext
18396 <tag width=200 height = "100" depth = '50' square></tag>
18397 !! html/php
18398 <pre>
18399 ''
18400 array (
18401 'width' => '200',
18402 'height' => '100',
18403 'depth' => '50',
18404 'square' => '',
18405 )
18406 </pre>
18407
18408 !! html/parsoid
18409 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18410 !! end
18411
18412 !! test
18413 Parser hook: argument containing a forward slash (T7344)
18414 !! wikitext
18415 <tag filename="/tmp/bla"></tag>
18416 !! html/php
18417 <pre>
18418 ''
18419 array (
18420 'filename' => '/tmp/bla',
18421 )
18422 </pre>
18423
18424 !! html/parsoid
18425 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18426 !! end
18427
18428 ## Don't expect parsoid to rt this form.
18429 !! test
18430 Parser hook: empty input using terminated empty elements (T4374)
18431 !! options
18432 parsoid=wt2html,html2html
18433 !! wikitext
18434 <tag foo=bar/>text
18435 !! html/php
18436 <pre>
18437 NULL
18438 array (
18439 'foo' => 'bar',
18440 )
18441 </pre>text
18442
18443 !! html/parsoid
18444 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text
18445 !! end
18446
18447 ## </tag> should be output literally since there is no matching tag that begins it
18448 ## Don't expect parsoid to rt this form.
18449 !! test
18450 Parser hook: basic arguments using terminated empty elements (T4374)
18451 !! options
18452 parsoid=wt2html
18453 !! wikitext
18454 <tag width=200 height = "100" depth = '50' square/>
18455 other stuff
18456 </tag>
18457 !! html/php
18458 <pre>
18459 NULL
18460 array (
18461 'width' => '200',
18462 'height' => '100',
18463 'depth' => '50',
18464 'square' => '',
18465 )
18466 </pre>
18467 <p>other stuff
18468 &lt;/tag&gt;
18469 </p>
18470 !! html/parsoid
18471 <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
18472 &lt;/tag></p>
18473 !! end
18474
18475 ## Don't expect parsoid to rt this form.
18476 !! test
18477 Parser hook: Don't allow unclosed extension tags
18478 !! options
18479 parsoid=wt2html
18480 !! wikitext
18481 test <tag>123
18482
18483 this is a '''test'''
18484 !! html/php
18485 <p>test &lt;tag&gt;123
18486 </p><p>this is a <b>test</b>
18487 </p>
18488 !! html/parsoid
18489 <p>test &lt;tag>123</p>
18490
18491 <p>this is a <b>test</b></p>
18492 !! end
18493
18494 ###
18495 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
18496 ###
18497
18498 !! test
18499 Parser hook: static parser hook not inside a comment
18500 !! wikitext
18501 <statictag>hello, world</statictag>
18502
18503 <statictag action="flush" />
18504 !! html/php
18505 <p><br />
18506 hello, world
18507 </p>
18508 !! html/parsoid
18509 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
18510 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p>
18511 !! end
18512
18513 !! test
18514 Parser hook: static parser hook inside a comment
18515 !! wikitext
18516 <!-- <statictag>hello, world</statictag> -->
18517 <statictag action="flush" />
18518 !! html/php
18519 <p><br />
18520 </p>
18521 !! html/parsoid
18522 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
18523 <p typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about='#mwt2'></p>
18524 !! end
18525
18526 # Nested template calls; this case was broken by Parser.php rev 1.506,
18527 # since reverted.
18528
18529 !! article
18530 Template:One-parameter
18531 !! text
18532 (My parameter is: {{{1}}})
18533 !! endarticle
18534
18535 !! article
18536 Template:Map-one-parameter
18537 !! text
18538 {{{{{1}}}|{{{2}}}}}
18539 !! endarticle
18540
18541 !! test
18542 Nested template calls
18543 !! wikitext
18544 {{Map-one-parameter|One-parameter|param}}
18545 !! html
18546 <p>(My parameter is: param)
18547 </p>
18548 !! end
18549
18550
18551 ###
18552 ### Sanitizer
18553 ###
18554
18555 # HTML+Tidy strips out empty tags completely. Parsoid doesn't.
18556 # FIXME: Wikitext for this first test doesn't match its title.
18557 !! test
18558 Sanitizer: Closing of open tags
18559 !! wikitext
18560 <s></s><table></table>
18561 !! html/php+tidy
18562
18563 !! html/parsoid
18564 <s></s><table></table>
18565 !! end
18566
18567 !! test
18568 Sanitizer: Closing of open but not closed tags
18569 !! wikitext
18570 <s>foo
18571 !! html
18572 <p><s>foo</s>
18573 </p>
18574 !! end
18575
18576 !! test
18577 Sanitizer: Closing of closed but not open tags
18578 !! options
18579 parsoid=wt2html
18580 !! wikitext
18581 </s>
18582 !! html/php+tidy
18583 !! html/parsoid
18584 !! end
18585
18586 !! test
18587 Sanitizer: Closing of closed but not open table tags
18588 !! options
18589 parsoid=wt2html
18590 !! wikitext
18591 Table not started</td></tr></table>
18592 !! html/php+tidy
18593 <p>Table not started</p>
18594 !! html/parsoid
18595 <p>Table not started</p>
18596 !! end
18597
18598 !! test
18599 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
18600 !! config
18601 wgFragmentMode=[ 'html5', 'legacy' ]
18602 !! wikitext
18603 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18604 !! html/php
18605 <p><span id="æ:_v">byte</span><a href="#æ:_v">backlink</a>
18606 </p>
18607 !! html/parsoid
18608 <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>
18609 !! end
18610
18611 !! test
18612 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id="" (legacy)
18613 !! config
18614 wgFragmentMode=[ 'legacy' ]
18615 !! wikitext
18616 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18617 !! html/php
18618 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
18619 </p>
18620 !! end
18621
18622 # In HTML5, the restrictions are that id must contain at least one character,
18623 # and must not contain any space characters.
18624 !! test
18625 Sanitizer: Validating the contents of the id attribute (T6515)
18626 !! options
18627 disabled
18628 !! wikitext
18629 <br id="" /><br id="a space" />
18630 !! html
18631 Something ...
18632 !! end
18633
18634 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
18635 !! test
18636 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
18637 !! options
18638 disabled
18639 !! wikitext
18640 <br id="foo" /><br id="foo" />
18641 !! html
18642 Something need to be done. foo-2 ?
18643 !! end
18644
18645 !! test
18646 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
18647 !! wikitext
18648 <div itemscope>
18649 <meta itemprop="hello" content="world">
18650 <meta http-equiv="refresh" content="5">
18651 <meta itemprop="hello" http-equiv="refresh" content="5">
18652 <link itemprop="hello" href="{{SERVER}}">
18653 <link rel="stylesheet" href="{{SERVER}}">
18654 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
18655 </div>
18656 !! html
18657 <div itemscope="">
18658 <p> <meta itemprop="hello" content="world" />
18659 &lt;meta http-equiv="refresh" content="5"&gt;
18660 <meta itemprop="hello" content="5" />
18661 <link itemprop="hello" href="http&#58;//example.org" />
18662 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
18663 <link itemprop="hello" href="http&#58;//example.org" />
18664 </p>
18665 </div>
18666
18667 !! end
18668
18669 !! test
18670 Sanitizer: Strip comments from CSS attributes
18671 !! options
18672 parsoid=wt2html,wt2wt
18673 !! wikitext
18674 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
18675 !! html/php
18676 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
18677 </p>
18678 !! html/parsoid
18679 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
18680 !! end
18681
18682 !! test
18683 Sanitizer: Avoid unnecessary percent encoded characters in interwiki links
18684 !! wikitext
18685 [[meatball:Soft"Security]]
18686 !! html/php
18687 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Soft%22Security" class="extiw" title="meatball:Soft&quot;Security">meatball:Soft"Security</a>
18688 </p>
18689 !! html/parsoid
18690 <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>
18691 !! end
18692
18693 !! test
18694 Sanitizer: angle brackets are invalid, even in interwiki links (T182338)
18695 !! wikitext
18696 [[meatball:Foo<Bar]]
18697 [[meatball:Foo>Bar]]
18698 [[meatball:Foo&lt;bar]]
18699 [[meatball:Foo&gt;bar]]
18700 !! html/php
18701 <p>[[meatball:Foo&lt;Bar]]
18702 [[meatball:Foo&gt;Bar]]
18703 [[meatball:Foo&lt;bar]]
18704 [[meatball:Foo&gt;bar]]
18705 </p>
18706 !! html/parsoid
18707 <p>[[meatball:Foo&lt;Bar]]
18708 [[meatball:Foo>Bar]]
18709 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span>bar]]
18710 [[meatball:Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;gt;","srcContent":">"}'>></span>bar]]</p>
18711 !! end
18712
18713 !! test
18714 Language converter: output gets cut off unexpectedly (T7757)
18715 !! options
18716 language=zh
18717 !! wikitext
18718 this bit is safe: }-
18719
18720 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
18721
18722 then we get cut off here: }-
18723
18724 all additional text is vanished
18725 !! html/php
18726 <p>this bit is safe: }-
18727 </p><p>but if we add a conversion instance: xxx
18728 </p><p>then we get cut off here: }-
18729 </p><p>all additional text is vanished
18730 </p>
18731 !! html/parsoid
18732 <p>this bit is safe: }-</p>
18733 <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>
18734 <p>then we get cut off here: }-</p>
18735 <p>all additional text is vanished</p>
18736 !! end
18737
18738 !! test
18739 Language converter glossary rules inside attributes (T119158)
18740 !! options
18741 language=sr variant=sr-el
18742 !! wikitext
18743 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
18744
18745 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
18746 !! html/php
18747 <p>
18748 </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>
18749 </p>
18750 !! html/parsoid
18751 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
18752
18753 <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>
18754 !! end
18755
18756 !! test
18757 Self closed html pairs (T7487)
18758 !! wikitext
18759 <center><font id="bug" />Centered text</center>
18760 <div><font id="bug2" />In div text</div>
18761 !! html+tidy
18762 <center><font id="bug"></font>Centered text</center>
18763 <div><font id="bug2"></font>In div text</div>
18764 !! end
18765
18766 #
18767 #
18768 #
18769
18770 !! test
18771 Punctuation: nbsp before exclamation
18772 !! wikitext
18773 C'est grave !
18774 !! html
18775 <p>C'est grave&#160;!
18776 </p>
18777 !! end
18778
18779 !! test
18780 Punctuation: CSS !important (T13874)
18781 !! wikitext
18782 <div style="width:50% !important">important</div>
18783 !! html
18784 <div style="width:50% !important">important</div>
18785
18786 !!end
18787
18788 !! test
18789 Punctuation: CSS ! important (T13874; with space after)
18790 !! wikitext
18791 <div style="width:50% ! important">important</div>
18792 !! html
18793 <div style="width:50% ! important">important</div>
18794
18795 !!end
18796
18797 !! test
18798 HTML bullet list, closed tags (T7497)
18799 !! wikitext
18800 <ul>
18801 <li>One</li>
18802 <li>Two</li>
18803 </ul>
18804 !! html/php
18805 <ul>
18806 <li>One</li>
18807 <li>Two</li>
18808 </ul>
18809
18810 !! html/parsoid
18811 <ul data-parsoid='{"stx":"html"}'>
18812 <li data-parsoid='{"stx":"html"}'>One</li>
18813 <li data-parsoid='{"stx":"html"}'>Two</li>
18814 </ul>
18815
18816 !! end
18817
18818 !! test
18819 HTML bullet list, unclosed tags (T7497)
18820 !! wikitext
18821 <ul>
18822 <li>One
18823 <li>Two
18824 </ul>
18825 !! html/php+tidy
18826 <ul>
18827 <li>One</li>
18828 <li>Two</li>
18829 </ul>
18830 !! html/parsoid
18831 <ul data-parsoid='{"stx":"html"}'>
18832 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18833 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18834 </ul>
18835
18836 !! end
18837
18838 !! test
18839 HTML ordered list, closed tags (T7497)
18840 !! wikitext
18841 <ol>
18842 <li>One</li>
18843 <li>Two</li>
18844 </ol>
18845 !! html/php
18846 <ol>
18847 <li>One</li>
18848 <li>Two</li>
18849 </ol>
18850
18851 !! html/parsoid
18852 <ol data-parsoid='{"stx":"html"}'>
18853 <li data-parsoid='{"stx":"html"}'>One</li>
18854 <li data-parsoid='{"stx":"html"}'>Two</li>
18855 </ol>
18856
18857 !! end
18858
18859 !! test
18860 HTML ordered list, unclosed tags (T7497)
18861 !! options
18862 !! wikitext
18863 <ol>
18864 <li>One
18865 <li>Two
18866 </ol>
18867 !! html/php+tidy
18868 <ol>
18869 <li>One</li>
18870 <li>Two</li>
18871 </ol>
18872 !! html/parsoid
18873 <ol data-parsoid='{"stx":"html"}'>
18874 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18875 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18876 </ol>
18877
18878 !! end
18879
18880 !! test
18881 HTML nested bullet list, closed tags (T7497)
18882 !! wikitext
18883 <ul>
18884 <li>One</li>
18885 <li>Two:
18886 <ul>
18887 <li>Sub-one</li>
18888 <li>Sub-two</li>
18889 </ul>
18890 </li>
18891 </ul>
18892 !! html/php
18893 <ul>
18894 <li>One</li>
18895 <li>Two:
18896 <ul>
18897 <li>Sub-one</li>
18898 <li>Sub-two</li>
18899 </ul>
18900 </li>
18901 </ul>
18902
18903 !! html/parsoid
18904 <ul data-parsoid='{"stx":"html"}'>
18905 <li data-parsoid='{"stx":"html"}'>One</li>
18906 <li data-parsoid='{"stx":"html"}'>Two:
18907 <ul data-parsoid='{"stx":"html"}'>
18908 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
18909 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
18910 </ul>
18911 </li>
18912 </ul>
18913 !! end
18914
18915 !! test
18916 HTML nested bullet list, open tags (T7497)
18917 !! wikitext
18918 <ul>
18919 <li>One
18920 <li>Two:
18921 <ul>
18922 <li>Sub-one
18923 <li>Sub-two
18924 </ul>
18925 </ul>
18926 !! html/php+tidy
18927 <ul>
18928 <li>One</li>
18929 <li>Two:
18930 <ul>
18931 <li>Sub-one</li>
18932 <li>Sub-two</li>
18933 </ul>
18934 </li>
18935 </ul>
18936 !! html/parsoid
18937 <ul>
18938 <li>One
18939 </li>
18940 <li>Two:
18941 <ul>
18942 <li>Sub-one
18943 </li>
18944 <li>Sub-two
18945 </li>
18946 </ul>
18947 </li>
18948 </ul>
18949
18950 !! end
18951
18952 !! test
18953 HTML nested ordered list, closed tags (T7497)
18954 !! wikitext
18955 <ol>
18956 <li>One</li>
18957 <li>Two:
18958 <ol>
18959 <li>Sub-one</li>
18960 <li>Sub-two</li>
18961 </ol>
18962 </li>
18963 </ol>
18964 !! html
18965 <ol>
18966 <li>One</li>
18967 <li>Two:
18968 <ol>
18969 <li>Sub-one</li>
18970 <li>Sub-two</li>
18971 </ol>
18972 </li>
18973 </ol>
18974
18975 !! end
18976
18977 !! test
18978 HTML nested ordered list, open tags (T7497)
18979 !! wikitext
18980 <ol>
18981 <li>One
18982 <li>Two:
18983 <ol>
18984 <li>Sub-one
18985 <li>Sub-two
18986 </ol>
18987 </ol>
18988 !! html/php
18989 <ol>
18990 <li>One
18991 <li>Two:
18992 <ol>
18993 <li>Sub-one
18994 <li>Sub-two
18995 </ol>
18996 </ol>
18997
18998 !! html/parsoid
18999 <ol>
19000 <li>One
19001 </li>
19002 <li>Two:
19003 <ol>
19004 <li>Sub-one
19005 </li>
19006 <li>Sub-two
19007 </li>
19008 </ol>
19009 </li>
19010 </ol>
19011
19012 !! end
19013
19014 !! test
19015 HTML ordered list item with parameters oddity
19016 !! wikitext
19017 <ol><li id="fragment">One</li>
19018 </ol>
19019 !! html
19020 <ol><li id="fragment">One</li>
19021 </ol>
19022
19023 !! end
19024
19025 # parsoid doesn't explicitly mark autonumbered links, see T55505
19026 !!test
19027 T7918: autonumbering
19028 !! wikitext
19029 [http://first/] [http://second] [ftp://ftp]
19030
19031 ftp://inlineftp
19032
19033 [mailto:enclosed@mail.tld With target]
19034
19035 [mailto:enclosed@mail.tld]
19036
19037 mailto:inline@mail.tld
19038 !! html/php
19039 <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>
19040 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
19041 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
19042 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
19043 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
19044 </p>
19045 !! html/parsoid
19046 <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>
19047 <p><a rel="mw:ExtLink" href="ftp://inlineftp">ftp://inlineftp</a></p>
19048 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld">With target</a></p>
19049 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld"></a></p>
19050 <p><a rel="mw:ExtLink" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
19051 !! end
19052
19053
19054 #
19055 # Security and HTML correctness
19056 # From Nick Jenkins' fuzz testing
19057 #
19058
19059 !! test
19060 Fuzz testing: Parser13
19061 !! wikitext
19062 {|
19063 | http://a|
19064 !! html
19065 <table>
19066 <tr>
19067 <td>
19068 </td>
19069 </tr>
19070 </table>
19071
19072 !! end
19073
19074 # Note that Parsoid output differs from the PHP parser here: the PHP
19075 # parser breaks the URL for the magic word, while in Parsoid the URL
19076 # production takes precedence.
19077 !! test
19078 Fuzz testing: Parser14
19079 !! wikitext
19080 == onmouseover= ==
19081 http://__TOC__
19082 !! html/php
19083 <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>
19084 http://<div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
19085 <ul>
19086 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
19087 </ul>
19088 </div>
19089
19090
19091 !! html/php+tidy
19092 <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>
19093 <p>http://</p>
19094 <div id="toc" class="toc">
19095 <div class="toctitle" lang="en" dir="ltr" xml:lang="en">
19096 <h2>Contents</h2>
19097 </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 <p></p>
19103 !! html/parsoid
19104 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span> onmouseover= </h2>
19105 <p><a rel="mw:ExtLink" href="http://__TOC__" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
19106 !! end
19107
19108 !! test
19109 Fuzz testing: Parser14-table
19110 !! options
19111 parsoid=wt2html,html2html
19112 !! wikitext
19113 ==a==
19114 {| STYLE=__TOC__
19115 !! html
19116 <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>
19117 <table style="&#95;_TOC&#95;_">
19118 <tr><td></td></tr>
19119 </table>
19120
19121 !! html+tidy
19122 <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>
19123 <table style="__TOC__">
19124 <tr>
19125 <td></td>
19126 </tr>
19127 </table>
19128 !! html/parsoid
19129 <h2 id="a">a</h2>
19130 <table style="__TOC__"></table>
19131 !! end
19132
19133 # Known to produce bogus xml (extra </td>)
19134 !! test
19135 Fuzz testing: Parser16
19136 !! wikitext
19137 {|
19138 !https://||||||
19139 !! html
19140 <table>
19141 <tr>
19142 <th>https://</th>
19143 <th></th>
19144 <th></th>
19145 <th>
19146 </td>
19147 </tr>
19148 </table>
19149
19150 !! html+tidy
19151 <table>
19152 <tr>
19153 <th>https://</th>
19154 <th></th>
19155 <th></th>
19156 <th></th>
19157 </tr>
19158 </table>
19159 !! end
19160
19161 !! test
19162 Fuzz testing: Parser21
19163 !! wikitext
19164 {|
19165 ! irc://{{ftp://a" onmouseover="alert('hello world');"
19166 |
19167 !! html
19168 <table>
19169 <tr>
19170 <th> <a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
19171 </th>
19172 <td>
19173 </td>
19174 </tr>
19175 </table>
19176
19177 !! end
19178
19179 !! test
19180 Fuzz testing: Parser22
19181 !! wikitext
19182 http://===r:::https://b
19183
19184 {|
19185 !! html
19186 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
19187 </p>
19188 <table>
19189 <tr><td></td></tr>
19190 </table>
19191
19192 !! end
19193
19194 # Known to produce bad XML for now
19195 !! test
19196 Fuzz testing: Parser24
19197 !! options
19198 parsoid=wt2html
19199 !! wikitext
19200 {|
19201 {{{|
19202 <u CLASS=
19203 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
19204 <br style="onmouseover='alert(document.cookie);' " />
19205
19206 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19207 |
19208 !! html/php
19209 <table>
19210 {{{|
19211 <u class="&#124;">}}}} &gt;
19212 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19213
19214 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19215 <tr>
19216 <td></u>
19217 </td>
19218 </tr>
19219 </table>
19220
19221 !! html/parsoid
19222 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
19223 <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>"}'/>}}}} >
19224 <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}'>
19225
19226
19227
19228 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table>
19229 !! end
19230
19231 # Note: the current result listed for this is not what the original one was,
19232 # but the original bug was JavaScript injection, which is fixed in any case.
19233 # It's not clear that the original result listed was any more correct than the
19234 # current one. Original result:
19235 # <p>{{{|
19236 # </p>
19237 # <li class="&#124;&#124;">
19238 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19239 !!test
19240 Fuzz testing: Parser25 (T8055)
19241 !! wikitext
19242 {{{
19243 |
19244 <LI CLASS=||
19245 >
19246 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
19247 !! html/php
19248 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19249 </p>
19250 !! html/parsoid
19251 <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"]}'>
19252 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
19253 !! end
19254
19255 !!test
19256 Fuzz testing: URL adjacent extension (with space, clean)
19257 !! wikitext
19258 http://example.com <nowiki>junk</nowiki>
19259 !! html/php
19260 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
19261 </p>
19262 !! html/parsoid
19263 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a> <span typeof="mw:Nowiki">junk</span></p>
19264 !! end
19265
19266 !!test
19267 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
19268 !! wikitext
19269 http://example.com<nowiki>junk</nowiki>
19270 !! html/php
19271 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
19272 </p>
19273 !! html/parsoid
19274 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a><span typeof="mw:Nowiki">junk</span></p>
19275 !! end
19276
19277 !! test
19278 Fuzz testing: URL adjacent extension (no space, dirty; pre)
19279 !! wikitext
19280 http://example.com<pre>junk</pre>
19281 !! html/php
19282 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
19283
19284 !! html/php+tidy
19285 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p>
19286 <pre>
19287 junk
19288 </pre>
19289 !! html/parsoid
19290 <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>
19291 !! end
19292
19293 !! test
19294 Fuzz testing: image with bogus manual thumbnail
19295 !! wikitext
19296 [[Image:foobar.jpg|thumbnail= ]]
19297 !! html/php
19298 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
19299
19300 !! html/parsoid
19301 <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>
19302 !! end
19303
19304 # Parsoid will emit the newline literally in wt2wt; see next test case.
19305 !! test
19306 Fuzz testing: encoded newline in generated HTML replacements (T8577)
19307 !! options
19308 parsoid=wt2html
19309 !! wikitext
19310 <pre dir="&#10;"></pre>
19311 !! html/php
19312 <pre dir="&#10;"></pre>
19313
19314 !! html/parsoid
19315 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19316 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19317 !! end
19318
19319 !! test
19320 Fuzz testing: encoded newline in generated HTML replacements, html2wt (T8577)
19321 !! options
19322 parsoid=html2wt
19323 !! html/parsoid
19324 <pre typeof="mw:Extension/pre" about="#mwt2" dir="
19325 " data-mw='{"name":"pre","attrs":{"dir":"\n"},"body":{"extsrc":""}}'></pre>
19326 !! wikitext
19327 <pre dir="
19328 "></pre>
19329 !! html/php
19330 <pre dir=""></pre>
19331
19332 !! end
19333
19334 !! test
19335 Templates in extension attributes are not expanded
19336 !! wikitext
19337 <pre dir="{{echo|ltr}}"></pre>
19338 !! html/php
19339 <pre dir="{{echo|ltr}}"></pre>
19340
19341 !! html/parsoid
19342 <pre typeof="mw:Extension/pre" about="#mwt2" dir="{{echo|ltr}}" data-mw='{"name":"pre","attrs":{"dir":"{{echo|ltr}}"},"body":{"extsrc":""}}'></pre>
19343 !! end
19344
19345 !! test
19346 Parsing optional HTML elements (T8171)
19347 !! options
19348 !! wikitext
19349 <table>
19350 <tr>
19351 <td> Some tabular data</td>
19352 <td> More tabular data ...
19353 <td> And yet som tabular data</td>
19354 </tr>
19355 </table>
19356 !! html
19357 <table>
19358 <tr>
19359 <td> Some tabular data</td>
19360 <td> More tabular data ...
19361 </td><td> And yet som tabular data</td>
19362 </tr>
19363 </table>
19364
19365 !! end
19366
19367 !! test
19368 Correct handling of <td>, <tr> (T8171)
19369 !! options
19370 !! wikitext
19371 <table>
19372 <tr>
19373 <td> Some tabular data</td>
19374 <td> More tabular data ...</td>
19375 <td> And yet som tabular data</td>
19376 </tr>
19377 </table>
19378 !! html
19379 <table>
19380 <tr>
19381 <td> Some tabular data</td>
19382 <td> More tabular data ...</td>
19383 <td> And yet som tabular data</td>
19384 </tr>
19385 </table>
19386
19387 !! end
19388
19389
19390 !! test
19391 Parsing crashing regression (fr:JavaScript)
19392 !! wikitext
19393 </body></x>
19394 !! html
19395 <p>&lt;/body&gt;&lt;/x&gt;
19396 </p>
19397 !! end
19398
19399 !! test
19400 Inline wiki vs wiki block nesting
19401 !! wikitext
19402 '''Bold paragraph
19403
19404 New wiki paragraph
19405 !! html
19406 <p><b>Bold paragraph</b>
19407 </p><p>New wiki paragraph
19408 </p>
19409 !! end
19410
19411 # FIXME: The current php output is documented
19412 # and desired output is the parsoid target.
19413 !! test
19414 Inline HTML vs wiki block nesting
19415 !! wikitext
19416 <b>Bold paragraph
19417
19418 New wiki paragraph
19419 !! html/php
19420 <p><b>Bold paragraph
19421 </p><p>New wiki paragraph</b>
19422 </p>
19423 !! html/parsoid
19424 <p><b>Bold paragraph</b>
19425 </p><p>New wiki paragraph
19426 </p>
19427 !! end
19428
19429 # Original result was this:
19430 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
19431 # </p>
19432 # While that might be marginally more intuitive, maybe, the six-apostrophe
19433 # construct is clearly pathological and the result stated here (which is what
19434 # the parser actually does) is about as reasonable as anything.
19435 !!test
19436 Mixing markup for italics and bold
19437 !! options
19438 !! wikitext
19439 '''bold''''''bold''bolditalics'''''
19440 !! html
19441 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
19442 </p>
19443 !! end
19444
19445
19446 !! article
19447 Xyzzyx
19448 !! text
19449 Article for special page transclusion test
19450 !! endarticle
19451
19452 !! test
19453 Special page transclusion
19454 !! options
19455 !! wikitext
19456 {{Special:Prefixindex/Xyzzyx}}
19457 !! html
19458 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19459 </ul>
19460
19461 !! end
19462
19463 !! test
19464 Special page transclusion twice (T7021)
19465 !! options
19466 !! wikitext
19467 {{Special:Prefixindex/Xyzzyx}}
19468 {{Special:Prefixindex/Xyzzyx}}
19469 !! html
19470 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19471 </ul>
19472 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19473 </ul>
19474
19475 !! end
19476
19477 !! test
19478 Transclusion of default MediaWiki message
19479 !! wikitext
19480 {{MediaWiki:Mainpage}}
19481 !! html
19482 <p>Main Page
19483 </p>
19484 !! end
19485
19486 !! test
19487 Transclusion of nonexistent MediaWiki message
19488 !! wikitext
19489 {{MediaWiki:Mainpagexxx}}
19490 !! html
19491 <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>
19492 </p>
19493 !! end
19494
19495 !! test
19496 Transclusion of MediaWiki message with underscore
19497 !! wikitext
19498 {{MediaWiki:history_short}}
19499 !! html
19500 <p>History
19501 </p>
19502 !! end
19503
19504 !! test
19505 Transclusion of MediaWiki message with space
19506 !! wikitext
19507 {{MediaWiki:history short}}
19508 !! html
19509 <p>History
19510 </p>
19511 !! end
19512
19513 !! test
19514 Invalid header with following text
19515 !! wikitext
19516 = x = y
19517 !! html
19518 <p>= x = y
19519 </p>
19520 !! end
19521
19522
19523 !! test
19524 Section extraction test (section 0)
19525 !! options
19526 section=0
19527 !! wikitext
19528 start
19529 ==a==
19530 ===aa===
19531 ====aaa====
19532 ==b==
19533 ===ba===
19534 ===bb===
19535 ====bba====
19536 ===bc===
19537 ==c==
19538 ===ca===
19539 !! html/php
19540 start
19541 !! end
19542
19543 !! test
19544 Section extraction test (section 1)
19545 !! options
19546 section=1
19547 !! wikitext
19548 start
19549 ==a==
19550 ===aa===
19551 ====aaa====
19552 ==b==
19553 ===ba===
19554 ===bb===
19555 ====bba====
19556 ===bc===
19557 ==c==
19558 ===ca===
19559 !! html/php
19560 ==a==
19561 ===aa===
19562 ====aaa====
19563 !! end
19564
19565 !! test
19566 Section extraction test (section 2)
19567 !! options
19568 section=2
19569 !! wikitext
19570 start
19571 ==a==
19572 ===aa===
19573 ====aaa====
19574 ==b==
19575 ===ba===
19576 ===bb===
19577 ====bba====
19578 ===bc===
19579 ==c==
19580 ===ca===
19581 !! html/php
19582 ===aa===
19583 ====aaa====
19584 !! end
19585
19586 !! test
19587 Section extraction test (section 3)
19588 !! options
19589 section=3
19590 !! wikitext
19591 start
19592 ==a==
19593 ===aa===
19594 ====aaa====
19595 ==b==
19596 ===ba===
19597 ===bb===
19598 ====bba====
19599 ===bc===
19600 ==c==
19601 ===ca===
19602 !! html/php
19603 ====aaa====
19604 !! end
19605
19606 !! test
19607 Section extraction test (section 4)
19608 !! options
19609 section=4
19610 !! wikitext
19611 start
19612 ==a==
19613 ===aa===
19614 ====aaa====
19615 ==b==
19616 ===ba===
19617 ===bb===
19618 ====bba====
19619 ===bc===
19620 ==c==
19621 ===ca===
19622 !! html/php
19623 ==b==
19624 ===ba===
19625 ===bb===
19626 ====bba====
19627 ===bc===
19628 !! end
19629
19630 !! test
19631 Section extraction test (section 5)
19632 !! options
19633 section=5
19634 !! wikitext
19635 start
19636 ==a==
19637 ===aa===
19638 ====aaa====
19639 ==b==
19640 ===ba===
19641 ===bb===
19642 ====bba====
19643 ===bc===
19644 ==c==
19645 ===ca===
19646 !! html/php
19647 ===ba===
19648 !! end
19649
19650 !! test
19651 Section extraction test (section 6)
19652 !! options
19653 section=6
19654 !! wikitext
19655 start
19656 ==a==
19657 ===aa===
19658 ====aaa====
19659 ==b==
19660 ===ba===
19661 ===bb===
19662 ====bba====
19663 ===bc===
19664 ==c==
19665 ===ca===
19666 !! html/php
19667 ===bb===
19668 ====bba====
19669 !! end
19670
19671 !! test
19672 Section extraction test (section 7)
19673 !! options
19674 section=7
19675 !! wikitext
19676 start
19677 ==a==
19678 ===aa===
19679 ====aaa====
19680 ==b==
19681 ===ba===
19682 ===bb===
19683 ====bba====
19684 ===bc===
19685 ==c==
19686 ===ca===
19687 !! html/php
19688 ====bba====
19689 !! end
19690
19691 !! test
19692 Section extraction test (section 8)
19693 !! options
19694 section=8
19695 !! wikitext
19696 start
19697 ==a==
19698 ===aa===
19699 ====aaa====
19700 ==b==
19701 ===ba===
19702 ===bb===
19703 ====bba====
19704 ===bc===
19705 ==c==
19706 ===ca===
19707 !! html/php
19708 ===bc===
19709 !! end
19710
19711 !! test
19712 Section extraction test (section 9)
19713 !! options
19714 section=9
19715 !! wikitext
19716 start
19717 ==a==
19718 ===aa===
19719 ====aaa====
19720 ==b==
19721 ===ba===
19722 ===bb===
19723 ====bba====
19724 ===bc===
19725 ==c==
19726 ===ca===
19727 !! html/php
19728 ==c==
19729 ===ca===
19730 !! end
19731
19732 !! test
19733 Section extraction test (section 10)
19734 !! options
19735 section=10
19736 !! wikitext
19737 start
19738 ==a==
19739 ===aa===
19740 ====aaa====
19741 ==b==
19742 ===ba===
19743 ===bb===
19744 ====bba====
19745 ===bc===
19746 ==c==
19747 ===ca===
19748 !! html/php
19749 ===ca===
19750 !! end
19751
19752 !! test
19753 Section extraction test (nonexistent section 11)
19754 !! options
19755 section=11
19756 !! wikitext
19757 start
19758 ==a==
19759 ===aa===
19760 ====aaa====
19761 ==b==
19762 ===ba===
19763 ===bb===
19764 ====bba====
19765 ===bc===
19766 ==c==
19767 ===ca===
19768 !! html/php
19769 !! end
19770
19771 !! test
19772 Section extraction test with bogus heading (section 1)
19773 !! options
19774 section=1
19775 !! wikitext
19776 ==a==
19777 ==bogus== not a legal section
19778 ==b==
19779 !! html/php
19780 ==a==
19781 ==bogus== not a legal section
19782 !! end
19783
19784 !! test
19785 Section extraction test with bogus heading (section 2)
19786 !! options
19787 section=2
19788 !! wikitext
19789 ==a==
19790 ==bogus== not a legal section
19791 ==b==
19792 !! html/php
19793 ==b==
19794 !! end
19795
19796 !! test
19797 Section extraction test with comment after heading (section 1)
19798 !! options
19799 section=1
19800 !! wikitext
19801 ==a==
19802 ==b== <!-- -->
19803 ==c==
19804 !! html/php
19805 ==a==
19806 !! end
19807
19808 !! test
19809 Section extraction test with comment after heading (section 2)
19810 !! options
19811 section=2
19812 !! wikitext
19813 ==a==
19814 ==b== <!-- -->
19815 ==c==
19816 !! html/php
19817 ==b== <!-- -->
19818 !! end
19819
19820 !! test
19821 Section extraction test with bogus <nowiki> heading (section 1)
19822 !! options
19823 section=1
19824 !! wikitext
19825 ==a==
19826 ==bogus== <nowiki>not a legal section</nowiki>
19827 ==b==
19828 !! html/php
19829 ==a==
19830 ==bogus== <nowiki>not a legal section</nowiki>
19831 !! end
19832
19833 !! test
19834 Section extraction test with bogus <nowiki> heading (section 2)
19835 !! options
19836 section=2
19837 !! wikitext
19838 ==a==
19839 ==bogus== <nowiki>not a legal section</nowiki>
19840 ==b==
19841 !! html/php
19842 ==b==
19843 !! end
19844
19845 # Formerly testing for T4587, now resolved by the use of unmarked sections
19846 # instead of respecting commented sections
19847 !! test
19848 Section extraction prefixed by comment (section 1)
19849 !! options
19850 section=1
19851 !! wikitext
19852 <!-- -->==sec1==
19853 ==sec2==
19854 !! html/php
19855 ==sec2==
19856 !!end
19857
19858 !! test
19859 Section extraction prefixed by comment (section 2)
19860 !! options
19861 section=2
19862 !! wikitext
19863 <!-- -->==sec1==
19864 ==sec2==
19865 !! html/php
19866
19867 !!end
19868
19869 # Formerly testing for T4607, now resolved by the use of unmarked sections
19870 # instead of respecting HTML-style headings
19871 !! test
19872 Section extraction, mixed wiki and html (section 1)
19873 !! options
19874 section=1
19875 !! wikitext
19876 <h2>unmarked</h2>
19877 unmarked
19878 ==1==
19879 one
19880 ==2==
19881 two
19882 !! html/php
19883 ==1==
19884 one
19885 !! end
19886
19887 !! test
19888 Section extraction, mixed wiki and html (section 2)
19889 !! options
19890 section=2
19891 !! wikitext
19892 <h2>unmarked</h2>
19893 unmarked
19894 ==1==
19895 one
19896 ==2==
19897 two
19898 !! html/php
19899 ==2==
19900 two
19901 !! end
19902
19903
19904 # Formerly testing for T5342
19905 !! test
19906 Section extraction, heading surrounded by <noinclude>
19907 !! options
19908 section=1
19909 !! wikitext
19910 <noinclude>==unmarked==</noinclude>
19911 ==marked==
19912 !! html/php
19913 ==marked==
19914 !!end
19915
19916 # Test behavior of T21910
19917 !! test
19918 Sectiion with all-equals
19919 !! options
19920 section=2
19921 !! wikitext
19922 ===
19923 The line above must have a trailing space
19924 === <!--
19925 --> <!-- -->
19926 But just in case it doesn't...
19927 !! html/php
19928 === <!--
19929 --> <!-- -->
19930 But just in case it doesn't...
19931 !! end
19932
19933 !! test
19934 Section replacement test (section 0)
19935 !! options
19936 replace=0,"xxx"
19937 !! wikitext
19938 start
19939 ==a==
19940 ===aa===
19941 ====aaa====
19942 ==b==
19943 ===ba===
19944 ===bb===
19945 ====bba====
19946 ===bc===
19947 ==c==
19948 ===ca===
19949 !! html/php
19950 xxx
19951
19952 ==a==
19953 ===aa===
19954 ====aaa====
19955 ==b==
19956 ===ba===
19957 ===bb===
19958 ====bba====
19959 ===bc===
19960 ==c==
19961 ===ca===
19962 !! end
19963
19964 !! test
19965 Section replacement test (section 1)
19966 !! options
19967 replace=1,"xxx"
19968 !! wikitext
19969 start
19970 ==a==
19971 ===aa===
19972 ====aaa====
19973 ==b==
19974 ===ba===
19975 ===bb===
19976 ====bba====
19977 ===bc===
19978 ==c==
19979 ===ca===
19980 !! html/php
19981 start
19982 xxx
19983
19984 ==b==
19985 ===ba===
19986 ===bb===
19987 ====bba====
19988 ===bc===
19989 ==c==
19990 ===ca===
19991 !! end
19992
19993 !! test
19994 Section replacement test (section 2)
19995 !! options
19996 replace=2,"xxx"
19997 !! wikitext
19998 start
19999 ==a==
20000 ===aa===
20001 ====aaa====
20002 ==b==
20003 ===ba===
20004 ===bb===
20005 ====bba====
20006 ===bc===
20007 ==c==
20008 ===ca===
20009 !! html/php
20010 start
20011 ==a==
20012 xxx
20013
20014 ==b==
20015 ===ba===
20016 ===bb===
20017 ====bba====
20018 ===bc===
20019 ==c==
20020 ===ca===
20021 !! end
20022
20023 !! test
20024 Section replacement test (section 3)
20025 !! options
20026 replace=3,"xxx"
20027 !! wikitext
20028 start
20029 ==a==
20030 ===aa===
20031 ====aaa====
20032 ==b==
20033 ===ba===
20034 ===bb===
20035 ====bba====
20036 ===bc===
20037 ==c==
20038 ===ca===
20039 !! html/php
20040 start
20041 ==a==
20042 ===aa===
20043 xxx
20044
20045 ==b==
20046 ===ba===
20047 ===bb===
20048 ====bba====
20049 ===bc===
20050 ==c==
20051 ===ca===
20052 !! end
20053
20054 !! test
20055 Section replacement test (section 4)
20056 !! options
20057 replace=4,"xxx"
20058 !! wikitext
20059 start
20060 ==a==
20061 ===aa===
20062 ====aaa====
20063 ==b==
20064 ===ba===
20065 ===bb===
20066 ====bba====
20067 ===bc===
20068 ==c==
20069 ===ca===
20070 !! html/php
20071 start
20072 ==a==
20073 ===aa===
20074 ====aaa====
20075 xxx
20076
20077 ==c==
20078 ===ca===
20079 !! end
20080
20081 !! test
20082 Section replacement test (section 5)
20083 !! options
20084 replace=5,"xxx"
20085 !! wikitext
20086 start
20087 ==a==
20088 ===aa===
20089 ====aaa====
20090 ==b==
20091 ===ba===
20092 ===bb===
20093 ====bba====
20094 ===bc===
20095 ==c==
20096 ===ca===
20097 !! html/php
20098 start
20099 ==a==
20100 ===aa===
20101 ====aaa====
20102 ==b==
20103 xxx
20104
20105 ===bb===
20106 ====bba====
20107 ===bc===
20108 ==c==
20109 ===ca===
20110 !! end
20111
20112 !! test
20113 Section replacement test (section 6)
20114 !! options
20115 replace=6,"xxx"
20116 !! wikitext
20117 start
20118 ==a==
20119 ===aa===
20120 ====aaa====
20121 ==b==
20122 ===ba===
20123 ===bb===
20124 ====bba====
20125 ===bc===
20126 ==c==
20127 ===ca===
20128 !! html/php
20129 start
20130 ==a==
20131 ===aa===
20132 ====aaa====
20133 ==b==
20134 ===ba===
20135 xxx
20136
20137 ===bc===
20138 ==c==
20139 ===ca===
20140 !! end
20141
20142 !! test
20143 Section replacement test (section 7)
20144 !! options
20145 replace=7,"xxx"
20146 !! wikitext
20147 start
20148 ==a==
20149 ===aa===
20150 ====aaa====
20151 ==b==
20152 ===ba===
20153 ===bb===
20154 ====bba====
20155 ===bc===
20156 ==c==
20157 ===ca===
20158 !! html/php
20159 start
20160 ==a==
20161 ===aa===
20162 ====aaa====
20163 ==b==
20164 ===ba===
20165 ===bb===
20166 xxx
20167
20168 ===bc===
20169 ==c==
20170 ===ca===
20171 !! end
20172
20173 !! test
20174 Section replacement test (section 8)
20175 !! options
20176 replace=8,"xxx"
20177 !! wikitext
20178 start
20179 ==a==
20180 ===aa===
20181 ====aaa====
20182 ==b==
20183 ===ba===
20184 ===bb===
20185 ====bba====
20186 ===bc===
20187 ==c==
20188 ===ca===
20189 !! html/php
20190 start
20191 ==a==
20192 ===aa===
20193 ====aaa====
20194 ==b==
20195 ===ba===
20196 ===bb===
20197 ====bba====
20198 xxx
20199
20200 ==c==
20201 ===ca===
20202 !!end
20203
20204 !! test
20205 Section replacement test (section 9)
20206 !! options
20207 replace=9,"xxx"
20208 !! wikitext
20209 start
20210 ==a==
20211 ===aa===
20212 ====aaa====
20213 ==b==
20214 ===ba===
20215 ===bb===
20216 ====bba====
20217 ===bc===
20218 ==c==
20219 ===ca===
20220 !! html/php
20221 start
20222 ==a==
20223 ===aa===
20224 ====aaa====
20225 ==b==
20226 ===ba===
20227 ===bb===
20228 ====bba====
20229 ===bc===
20230 xxx
20231 !! end
20232
20233 !! test
20234 Section replacement test (section 10)
20235 !! options
20236 replace=10,"xxx"
20237 !! wikitext
20238 start
20239 ==a==
20240 ===aa===
20241 ====aaa====
20242 ==b==
20243 ===ba===
20244 ===bb===
20245 ====bba====
20246 ===bc===
20247 ==c==
20248 ===ca===
20249 !! html/php
20250 start
20251 ==a==
20252 ===aa===
20253 ====aaa====
20254 ==b==
20255 ===ba===
20256 ===bb===
20257 ====bba====
20258 ===bc===
20259 ==c==
20260 xxx
20261 !! end
20262
20263 !! test
20264 Section replacement test with initial whitespace (T15728)
20265 !! options
20266 replace=2,"xxx"
20267 !! wikitext
20268 Preformatted initial line
20269 ==a==
20270 ===a===
20271 !! html/php
20272 Preformatted initial line
20273 ==a==
20274 xxx
20275 !! end
20276
20277
20278 !! test
20279 Section extraction, heading followed by pre with 20 spaces (T8398)
20280 !! options
20281 section=1
20282 !! wikitext
20283 ==a==
20284 a
20285 !! html/php
20286 ==a==
20287 a
20288 !! end
20289
20290 !! test
20291 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
20292 !! options
20293 section=1
20294 !! wikitext
20295 ==a==
20296 a
20297 !! html/php
20298 ==a==
20299 a
20300 !! end
20301
20302
20303 !! test
20304 Section extraction, <pre> around bogus header (T12309)
20305 !! options
20306 section=2
20307 !! wikitext
20308 == Section One ==
20309 <pre>
20310 =======
20311 </pre>
20312
20313 == Section Two ==
20314 stuff
20315 !! html/php
20316 == Section Two ==
20317 stuff
20318 !! end
20319
20320 !! test
20321 Section replacement, <pre> around bogus header (T12309)
20322 !! options
20323 replace=2,"xxx"
20324 !! wikitext
20325 == Section One ==
20326 <pre>
20327 =======
20328 </pre>
20329
20330 == Section Two ==
20331 stuff
20332 !! html/php
20333 == Section One ==
20334 <pre>
20335 =======
20336 </pre>
20337
20338 xxx
20339 !! end
20340
20341 !! test
20342 Handling of &#x0A; in URLs
20343 !! wikitext
20344 ** irc://&#x0A;a
20345 !! html/php
20346 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
20347
20348 !! html/parsoid
20349 <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>
20350 !! end
20351
20352 !! test
20353 Handling of %0A in URLs
20354 !! wikitext
20355 ** irc://%0Aa
20356 !! html/php
20357 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
20358
20359 !! html/parsoid
20360 <ul><li><ul><li> <a rel="mw:ExtLink" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
20361 !! end
20362
20363 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
20364 !! test
20365 5 quotes, code coverage +1 line
20366 !! options
20367 parsoid=wt2html
20368 !! wikitext
20369 '''''
20370 !! html/php
20371 !! html/parsoid
20372 <b><i></i></b>
20373 !! end
20374
20375 # same html as previous, but wikitext adjusted to match parsoid html2wt
20376 # note that wt2html and html2html will put the <i> before the <b>
20377 !! test
20378 5 quotes, code coverage +1 line w/ nowiki (1)
20379 !! options
20380 parsoid=wt2wt,html2wt
20381 !! wikitext
20382 '''''<nowiki/>'''''
20383 !! html/php
20384 <p><i></i>
20385 </p>
20386 !! html/parsoid
20387 <p><b><i></i></b></p>
20388 !! end
20389
20390 # same as previous, just swapping the <i> and <b>
20391 !! test
20392 5 quotes, code coverage +1 line w/ nowiki (2)
20393 !! wikitext
20394 '''''<nowiki/>'''''
20395 !! html/php
20396 <p><i></i>
20397 </p>
20398 !! html/parsoid
20399 <p><i><b></b></i></p>
20400 !! end
20401
20402 !! test
20403 Special:Search page linking.
20404 !! wikitext
20405 {{Special:search}}
20406 !! html
20407 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
20408 </p>
20409 !! end
20410
20411 !! test
20412 {{!}} is a magic word
20413 !! wikitext
20414 {{!}} is a magic word there and {{!}} is still a magic word here
20415 | is not a magic word here but {{!}} is still a magic word here
20416 !! html/php
20417 <p>| is a magic word there and | is still a magic word here
20418 | is not a magic word here but | is still a magic word here
20419 </p>
20420 !! html/parsoid
20421 <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
20422 | 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>
20423 !! end
20424
20425 !! test
20426 Say the magic word
20427 !! options
20428 title=[[Parser test]]
20429 !! wikitext
20430 * {{PAGENAME}}
20431 * {{PAGENAMEE}}
20432 * {{FULLPAGENAME}}
20433 * {{FULLPAGENAMEE}}
20434 * {{BASEPAGENAME}}
20435 * {{BASEPAGENAMEE}}
20436 * {{SUBPAGENAME}}
20437 * {{SUBPAGENAMEE}}
20438 * {{ROOTPAGENAME}}
20439 * {{ROOTPAGENAMEE}}
20440 * {{TALKPAGENAME}}
20441 * {{TALKPAGENAMEE}}
20442 * {{SUBJECTPAGENAME}}
20443 * {{SUBJECTPAGENAMEE}}
20444 * {{NAMESPACEE}}
20445 * {{NAMESPACE}}
20446 * {{NAMESPACENUMBER}}
20447 * {{TALKSPACE}}
20448 * {{TALKSPACEE}}
20449 * {{SUBJECTSPACE}}
20450 * {{SUBJECTSPACEE}}
20451 * {{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
20452 !! html
20453 <ul><li> Parser test</li>
20454 <li> Parser_test</li>
20455 <li> Parser test</li>
20456 <li> Parser_test</li>
20457 <li> Parser test</li>
20458 <li> Parser_test</li>
20459 <li> Parser test</li>
20460 <li> Parser_test</li>
20461 <li> Parser test</li>
20462 <li> Parser_test</li>
20463 <li> Talk:Parser test</li>
20464 <li> Talk:Parser_test</li>
20465 <li> Parser test</li>
20466 <li> Parser_test</li>
20467 <li> </li>
20468 <li> </li>
20469 <li> 0</li>
20470 <li> Talk</li>
20471 <li> Talk</li>
20472 <li> </li>
20473 <li> </li>
20474 <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>
20475
20476 !! end
20477 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
20478
20479 !! test
20480 Gallery with valid attributes
20481 !! wikitext
20482 <gallery type="123" summary="345">
20483 File:File:Foobar.jpg
20484 </gallery>
20485 !! html/php
20486 <ul class="gallery mw-gallery-traditional" type="123">
20487 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20488 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
20489 <div class="gallerytext">
20490 </div>
20491 </div></li>
20492 </ul>
20493
20494 !! html/parsoid
20495 <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"}}'>
20496 <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>
20497 </ul>
20498 !! end
20499
20500 ## Parsoid thinks the "centre" here is a property, not a caption.
20501 !! test
20502 Gallery
20503 !! options
20504 parsoid={
20505 "modes": ["wt2html"],
20506 "nativeGallery": true
20507 }
20508 !! wikitext
20509 <gallery>
20510 image1.png |
20511 image2.gif|||||
20512
20513 image3|
20514 image4 |300px| centre
20515 image5.svg| http://///////
20516 [[x|xx]]]]
20517 * image6
20518 </gallery>
20519 !! html/php
20520 <ul class="gallery mw-gallery-traditional">
20521 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20522 <div class="thumb" style="height: 150px;">Image1.png</div>
20523 <div class="gallerytext">
20524 </div>
20525 </div></li>
20526 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20527 <div class="thumb" style="height: 150px;">Image2.gif</div>
20528 <div class="gallerytext">
20529 </div>
20530 </div></li>
20531 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20532 <div class="thumb" style="height: 150px;">Image3</div>
20533 <div class="gallerytext">
20534 </div>
20535 </div></li>
20536 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20537 <div class="thumb" style="height: 150px;">Image4</div>
20538 <div class="gallerytext">
20539 <pre>centre
20540 </pre>
20541 </div>
20542 </div></li>
20543 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20544 <div class="thumb" style="height: 150px;">Image5.svg</div>
20545 <div class="gallerytext">
20546 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
20547 </p>
20548 </div>
20549 </div></li>
20550 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20551 <div class="thumb" style="height: 150px;">* image6</div>
20552 <div class="gallerytext">
20553 </div>
20554 </div></li>
20555 </ul>
20556
20557 !! html/parsoid
20558 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20559 <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>
20560 <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>
20561 <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>
20562 <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>
20563 <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>
20564 <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>
20565 </ul>
20566 !! end
20567
20568 !! test
20569 Gallery (with options, html)
20570 !! options
20571 parsoid={
20572 "modes": ["wt2html", "html2html"],
20573 "nativeGallery": true
20574 }
20575 !! wikitext
20576 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20577 File:Nonexistent.jpg|caption
20578 File:Nonexistent.jpg
20579 image:foobar.jpg|some '''caption''' [[Main Page]]
20580 image:foobar.jpg
20581 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20582 </gallery>
20583 !! html/php
20584 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20585 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20586 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20587 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20588 <div class="gallerytext">
20589 <p>caption
20590 </p>
20591 </div>
20592 </div></li>
20593 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20594 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20595 <div class="gallerytext">
20596 </div>
20597 </div></li>
20598 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20599 <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>
20600 <div class="gallerytext">
20601 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20602 </p>
20603 </div>
20604 </div></li>
20605 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20606 <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>
20607 <div class="gallerytext">
20608 </div>
20609 </div></li>
20610 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20611 <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>
20612 <div class="gallerytext">
20613 <p>blabla.
20614 </p>
20615 </div>
20616 </div></li>
20617 </ul>
20618
20619 !! html/parsoid
20620 <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":{}}'>
20621 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20622 <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>
20623 <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>
20624 <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>
20625 <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>
20626 <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>
20627 </ul>
20628 !! end
20629
20630 !! test
20631 Gallery (with options, extsrc)
20632 !! options
20633 parsoid={
20634 "nativeGallery": false
20635 }
20636 !! wikitext
20637 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20638 File:Nonexistent.jpg|caption
20639 File:Nonexistent.jpg
20640 image:foobar.jpg|some '''caption''' [[Main Page]]
20641 image:foobar.jpg
20642 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20643 </gallery>
20644 !! html/php
20645 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20646 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20647 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20648 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20649 <div class="gallerytext">
20650 <p>caption
20651 </p>
20652 </div>
20653 </div></li>
20654 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20655 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20656 <div class="gallerytext">
20657 </div>
20658 </div></li>
20659 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20660 <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>
20661 <div class="gallerytext">
20662 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20663 </p>
20664 </div>
20665 </div></li>
20666 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20667 <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>
20668 <div class="gallerytext">
20669 </div>
20670 </div></li>
20671 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20672 <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>
20673 <div class="gallerytext">
20674 <p>blabla.
20675 </p>
20676 </div>
20677 </div></li>
20678 </ul>
20679
20680 !! html/parsoid
20681 <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"}}'>
20682 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20683 <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>
20684 <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>
20685 <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>
20686 <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>
20687 <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>
20688 </ul>
20689 !! end
20690
20691 !! test
20692 Gallery with link that has fragment
20693 !! options
20694 parsoid={
20695 "modes": ["wt2html", "html2html"],
20696 "nativeGallery": true
20697 }
20698 !! wikitext
20699 <gallery>
20700 image:foobar.jpg|link=Main_Page
20701 image:foobar.jpg|link=Main_Page#section
20702 image:foobar.jpg|link=Main Page#section|caption
20703 </gallery>
20704 !! html/php
20705 <ul class="gallery mw-gallery-traditional">
20706 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20707 <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>
20708 <div class="gallerytext">
20709 </div>
20710 </div></li>
20711 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20712 <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>
20713 <div class="gallerytext">
20714 </div>
20715 </div></li>
20716 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20717 <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>
20718 <div class="gallerytext">
20719 <p>caption
20720 </p>
20721 </div>
20722 </div></li>
20723 </ul>
20724
20725 !! html/parsoid
20726 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20727 <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>
20728 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./Main_Page#section"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li>
20729 <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>
20730 </ul>
20731 !! end
20732
20733 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
20734 !! test
20735 Gallery with template inside caption
20736 !! options
20737 parsoid={
20738 "nativeGallery": true
20739 }
20740 !! wikitext
20741 <gallery caption="{{echo|hi}}">
20742 File:Foobar.jpg|{{echo|ho}}
20743 </gallery>
20744 !! html/php
20745 <ul class="gallery mw-gallery-traditional">
20746 <li class='gallerycaption'>{{echo|hi}}</li>
20747 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20748 <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>
20749 <div class="gallerytext">
20750 <p>ho
20751 </p>
20752 </div>
20753 </div></li>
20754 </ul>
20755
20756 !! html/parsoid
20757 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20758 <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>
20759 <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>
20760 </ul>
20761 !! end
20762
20763 !! test
20764 Gallery with wikitext inside caption
20765 !! options
20766 parsoid={
20767 "nativeGallery": true
20768 }
20769 !! wikitext
20770 <gallery>
20771 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
20772 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
20773 </gallery>
20774 !! html/php
20775 <ul class="gallery mw-gallery-traditional">
20776 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20777 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="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>
20778 <div class="gallerytext">
20779 <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>
20780 </p>
20781 </div>
20782 </div></li>
20783 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20784 <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>
20785 <div class="gallerytext">
20786 <p>This is a test template
20787 </p>
20788 </div>
20789 </div></li>
20790 </ul>
20791
20792 !! html/parsoid
20793 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20794 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img alt="galleryalt" resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"><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>
20795 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img 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>
20796 </ul>
20797 !! end
20798
20799 !! test
20800 Gallery (with showfilename option)
20801 !! options
20802 parsoid={
20803 "nativeGallery": true
20804 }
20805 !! wikitext
20806 <gallery showfilename="">
20807 File:Nonexistent.jpg|caption
20808 File:Nonexistent.jpg
20809 File:Foobar.jpg|some '''caption''' [[Main Page]]
20810 File:Foobar.jpg
20811 </gallery>
20812 !! html/php
20813 <ul class="gallery mw-gallery-traditional">
20814 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20815 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20816 <div class="gallerytext">
20817 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20818 caption
20819 </p>
20820 </div>
20821 </div></li>
20822 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20823 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20824 <div class="gallerytext">
20825 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20826 </p>
20827 </div>
20828 </div></li>
20829 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20830 <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>
20831 <div class="gallerytext">
20832 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20833 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20834 </p>
20835 </div>
20836 </div></li>
20837 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20838 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/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>
20839 <div class="gallerytext">
20840 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20841 </p>
20842 </div>
20843 </div></li>
20844 </ul>
20845
20846 !! html/parsoid
20847 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
20848 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"><a href="./File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">File:Nonexistent.jpg</a>caption</div></li>
20849 <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>
20850 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"><a href="./File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">File:Foobar.jpg</a>some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li>
20851 <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>
20852 </ul>
20853 !! end
20854
20855 ## Should Parsoid be preserving these variations? See T151367
20856 !! test
20857 Gallery (with namespace-less filenames)
20858 !! options
20859 parsoid={
20860 "modes": ["wt2html", "html2html"],
20861 "nativeGallery": true
20862 }
20863 !! wikitext
20864 <gallery>
20865 File:Nonexistent.jpg
20866 Nonexistent.jpg
20867 image:foobar.jpg
20868 foobar.jpg
20869 </gallery>
20870 !! html/php
20871 <ul class="gallery mw-gallery-traditional">
20872 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20873 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20874 <div class="gallerytext">
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 </div>
20881 </div></li>
20882 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20883 <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>
20884 <div class="gallerytext">
20885 </div>
20886 </div></li>
20887 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20888 <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>
20889 <div class="gallerytext">
20890 </div>
20891 </div></li>
20892 </ul>
20893
20894 !! html/parsoid
20895 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20896 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Error mw:Image"><a href="./File:Nonexistent.jpg"><img resource="./File:Nonexistent.jpg" src="./Special:FilePath/Nonexistent.jpg" height="120" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li>
20897 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw: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>
20898 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="14" width="120"/></a></figure-inline></div><div class="gallerytext"></div></li>
20899 <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>
20900 </ul>
20901 !! end
20902
20903 !! test
20904 Gallery override link with wikilink (T36852)
20905 !! options
20906 parsoid={
20907 "nativeGallery": true
20908 }
20909 !! wikitext
20910 <gallery>
20911 File:Foobar.jpg|alt=galleryalt|link=Wikilink
20912 </gallery>
20913 !! html/php
20914 <ul class="gallery mw-gallery-traditional">
20915 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20916 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/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>
20917 <div class="gallerytext">
20918 </div>
20919 </div></li>
20920 </ul>
20921
20922 !! html/parsoid
20923 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-parsoid='{"dsr":[0,70,2,2]}' data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20924 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><figure-inline typeof="mw:Image"><a href="./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>
20925 </ul>
20926 !! end
20927
20928 !! test
20929 Gallery override link with absolute external link (T36852)
20930 !! options
20931 parsoid={
20932 "nativeGallery": true
20933 }
20934 !! wikitext
20935 <gallery>
20936 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
20937 </gallery>
20938 !! html/php
20939 <ul class="gallery mw-gallery-traditional">
20940 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20941 <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>
20942 <div class="gallerytext">
20943 </div>
20944 </div></li>
20945 </ul>
20946
20947 !! html/parsoid
20948 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20949 <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>
20950 </ul>
20951 !! end
20952
20953 !! test
20954 Gallery override link with absolute external link with LanguageConverter
20955 !! options
20956 language=zh
20957 !! input
20958 <gallery>
20959 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
20960 </gallery>
20961 !! result
20962 <ul class="gallery mw-gallery-traditional">
20963 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20964 <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>
20965 <div class="gallerytext">
20966 <p>caption
20967 </p>
20968 </div>
20969 </div></li>
20970 </ul>
20971
20972 !! end
20973
20974 !! test
20975 Gallery override link with malicious javascript (T36852)
20976 !! options
20977 parsoid={
20978 "modes": ["wt2html", "html2html"],
20979 "nativeGallery": true
20980 }
20981 !! wikitext
20982 <gallery>
20983 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
20984 </gallery>
20985 !! html/php
20986 <ul class="gallery mw-gallery-traditional">
20987 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20988 <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>
20989 <div class="gallerytext">
20990 </div>
20991 </div></li>
20992 </ul>
20993
20994 !! html/parsoid
20995 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20996 <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>
20997 </ul>
20998 !! end
20999
21000 # Note that parsoid uses the invalid link as a caption, PHP does not.
21001 !! test
21002 Gallery with invalid title as link (T45964)
21003 !! options
21004 parsoid={
21005 "modes": ["wt2html", "html2html"],
21006 "nativeGallery": true
21007 }
21008 !! wikitext
21009 <gallery>
21010 File:Foobar.jpg|link=<
21011 </gallery>
21012 !! html/php
21013 <ul class="gallery mw-gallery-traditional">
21014 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21015 <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>
21016 <div class="gallerytext">
21017 </div>
21018 </div></li>
21019 </ul>
21020
21021 !! html/parsoid
21022 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
21023 <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>
21024 </ul>
21025 !! end
21026
21027 !! test
21028 Serialize gallery without attrs in data-mw
21029 !! options
21030 parsoid={
21031 "modes": ["html2wt"],
21032 "nativeGallery": true
21033 }
21034 !! html/parsoid
21035 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
21036 <li class="gallerycaption">123</li>
21037 <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>
21038 </ul>
21039 !! wikitext
21040 <gallery caption="123">
21041 File:Test.png
21042 </gallery>
21043 !! end
21044
21045 !! test
21046 Gallery with class and style attributes
21047 !! options
21048 parsoid={
21049 "nativeGallery": true
21050 }
21051 !! wikitext
21052 <gallery class="center" style="text-align: center;">
21053 File:Foobar.jpg
21054 </gallery>
21055 !! html/php
21056 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
21057 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21058 <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>
21059 <div class="gallerytext">
21060 </div>
21061 </div></li>
21062 </ul>
21063
21064 !! html/parsoid
21065 <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":{}}'>
21066 <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>
21067 </ul>
21068 !! end
21069
21070 !! test
21071 Gallery in slideshow mode
21072 !! options
21073 parsoid={
21074 "nativeGallery": true
21075 }
21076 !! wikitext
21077 <gallery mode="slideshow" showthumbnails="">
21078 File:Foobar.jpg
21079 </gallery>
21080 !! html/php
21081 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
21082 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21083 <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>
21084 <div class="gallerytext">
21085 </div>
21086 </div></li>
21087 </ul>
21088
21089 !! html/parsoid
21090 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
21091 <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>
21092 </ul>
21093 !! end
21094
21095 !! test
21096 HTML Hex character encoding (spells the word "JavaScript")
21097 !! options
21098 parsoid=wt2html,wt2wt,html2html
21099 !! wikitext
21100 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
21101 !! html/php
21102 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
21103 </p>
21104 !! html/php+tidy
21105 <p>JavaScript</p>
21106 !! html/parsoid
21107 <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>
21108 !! end
21109
21110 !! test
21111 HTML Hex character encoding bogus encoding (T28437 regression check)
21112 !! wikitext
21113 &#xsee;&#XSEE;
21114 !! html/php
21115 <p>&amp;#xsee;&amp;#XSEE;
21116 </p>
21117 !! html/parsoid
21118 <p>&amp;#xsee;&amp;#XSEE;</p>
21119 !! end
21120
21121 !! test
21122 HTML Hex character encoding mixed case
21123 !! options
21124 parsoid=wt2html,wt2wt,html2html
21125 !! wikitext
21126 &#xEE;&#Xee;
21127 !! html/php
21128 <p>&#xee;&#xee;
21129 </p>
21130 !! html/php+tidy
21131 <p>îî</p>
21132 !! html/parsoid
21133 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
21134 !! end
21135
21136 # See: https://www.w3.org/TR/html5/syntax.html#character-references
21137 # Note that U+000C (form feed) is not a valid XML character, so
21138 # it is banned even though allowed in HTML5.
21139 !! test
21140 Illegal character references (T106578)
21141 !! wikitext
21142 ; Null: &#00;
21143 ; FF: &#xC;
21144 ; CR: &#xD;
21145 ; Control (low): &#8;
21146 ; Control (high): &#x7F; &#x9F;
21147 ; Surrogate: &#xD83D;&#xDCA9;
21148 ; This is an okay astral character: &#x1F4A9;
21149 !! html+tidy
21150 <dl>
21151 <dt>Null</dt>
21152 <dd>&amp;#00;</dd>
21153 <dt>FF</dt>
21154 <dd>&amp;#xC;</dd>
21155 <dt>CR</dt>
21156 <dd>&amp;#xD;</dd>
21157 <dt>Control (low)</dt>
21158 <dd>&amp;#8;</dd>
21159 <dt>Control (high)</dt>
21160 <dd>&amp;#x7F; &amp;#x9F;</dd>
21161 <dt>Surrogate</dt>
21162 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
21163 <dt>This is an okay astral character</dt>
21164 <dd>💩</dd>
21165 </dl>
21166 !! end
21167
21168 !! test
21169 __FORCETOC__ override
21170 !! wikitext
21171 __NEWSECTIONLINK__
21172 __FORCETOC__
21173 !! html/php
21174 <p><br />
21175 </p>
21176 !! end
21177
21178 !! test
21179 ISBN code coverage
21180 !! wikitext
21181 ISBN 978-0-1234-56&#x20;789
21182 !! html
21183 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
21184 </p>
21185 !! html+tidy
21186 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a> 789</p>
21187 !! html/parsoid
21188 <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>
21189 !! end
21190
21191 !! test
21192 ISBN followed by 5 spaces
21193 !! wikitext
21194 ISBN
21195 !! html
21196 <p>ISBN
21197 </p>
21198 !! end
21199
21200 !! test
21201 Double ISBN
21202 !! wikitext
21203 ISBN ISBN 1234567890
21204 !! html/php
21205 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21206 </p>
21207 !! html/parsoid
21208 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21209 !! end
21210
21211 # Uppercase X and lowercase x as well
21212 !! test
21213 ISBN with an X
21214 !! wikitext
21215 ISBN 3-462-04561-X
21216 ISBN 3-462-04561-x
21217 ISBN 080442957X
21218 ISBN 080442957x
21219 ISBN 978080442957X
21220 ISBN 978080442957x
21221 !! html/php
21222 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
21223 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
21224 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
21225 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
21226 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
21227 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
21228 </p>
21229 !! html/parsoid
21230 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
21231 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
21232 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
21233 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
21234 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
21235 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
21236 !! end
21237
21238 !! test
21239 ISBN with empty prefix (parsoid test)
21240 !! wikitext
21241 ISBN 1234567890
21242 !! html/php
21243 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21244 </p>
21245 !! html/parsoid
21246 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
21247 !! end
21248
21249 !! test
21250 T24905: <abbr> followed by ISBN followed by </a>
21251 !! wikitext
21252 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
21253 !! html/php
21254 <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>
21255 </p>
21256 !! html/parsoid
21257 <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>
21258 !! end
21259
21260 !! test
21261 Double RFC
21262 !! wikitext
21263 RFC RFC 1234
21264 !! html
21265 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
21266 </p>
21267 !! end
21268
21269 !! test
21270 Double RFC with a wiki link
21271 !! wikitext
21272 RFC [[RFC 1234]]
21273 !! html
21274 <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>
21275 </p>
21276 !! end
21277
21278 !! test
21279 RFC code coverage
21280 !! wikitext
21281 RFC 983&#x20;987
21282 !! html
21283 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
21284 </p>
21285 !! html+tidy
21286 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a> 987</p>
21287 !! end
21288
21289 !! test
21290 Centre-aligned image
21291 !! wikitext
21292 [[Image:foobar.jpg|centre]]
21293 !! html
21294 <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>
21295
21296 !!end
21297
21298 !! test
21299 None-aligned image
21300 !! wikitext
21301 [[Image:foobar.jpg|none]]
21302 !! html
21303 <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>
21304
21305 !!end
21306
21307 !! test
21308 Width + Height sized image (using px) (height is ignored)
21309 !! wikitext
21310 [[Image:foobar.jpg|640x480px]]
21311 !! html
21312 <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>
21313 </p>
21314 !!end
21315
21316 !! test
21317 Width-sized image (using px, no following whitespace)
21318 !! wikitext
21319 [[Image:foobar.jpg|640px]]
21320 !! html
21321 <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>
21322 </p>
21323 !!end
21324
21325 !! test
21326 Width-sized image (using px, with following whitespace - test regression from r39467)
21327 !! wikitext
21328 [[Image:foobar.jpg|640px ]]
21329 !! html
21330 <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>
21331 </p>
21332 !!end
21333
21334 !! test
21335 Width-sized image (using px, with preceding whitespace - test regression from r39467)
21336 !! wikitext
21337 [[Image:foobar.jpg| 640px]]
21338 !! html
21339 <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>
21340 </p>
21341 !!end
21342
21343 !! test
21344 Image with page parameter
21345 !! options
21346 djvu
21347 !! wikitext
21348 [[File:LoremIpsum.djvu|page=2]]
21349 !! html/php
21350 <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>
21351 </p>
21352 !! html/parsoid
21353 <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>
21354 !! end
21355
21356 !! test
21357 Another italics / bold test
21358 !! wikitext
21359 ''' ''x'
21360 !! html
21361 <pre>'<i> </i>x'
21362 </pre>
21363 !!end
21364
21365 # FIXME: The php output seems broken. It's interleaving some open/close tags.
21366 !! test
21367 dt/dd/dl test
21368 !! wikitext
21369 :;;;::
21370 !! html/php
21371 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
21372
21373 !! html/parsoid
21374 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
21375
21376 !!end
21377
21378 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
21379 !! test
21380 Images with the "|" character in the comment
21381 !! wikitext
21382 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
21383 !! html/php
21384 <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>
21385
21386 !! html/parsoid
21387 <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>
21388 !! end
21389
21390 !! test
21391 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
21392 !! wikitext
21393 <html><script>alert(1);</script></html>
21394 !! html
21395 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
21396 </p>
21397 !! end
21398
21399 !! test
21400 HTML with raw HTML ($wgRawHtml==true)
21401 !! options
21402 wgRawHtml=1
21403 !! wikitext
21404 <html><script>alert(1);</script></html>
21405 !! html/php
21406 <p><script>alert(1);</script>
21407 </p>
21408 !! end
21409
21410 !! test
21411 Parents of subpages, one level up
21412 !! options
21413 subpage title=[[Subpage test/L1/L2/L3]]
21414 !! wikitext
21415 [[../|L2]]
21416 !! html
21417 <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>
21418 </p>
21419 !! end
21420
21421
21422 !! test
21423 Parents of subpages, one level up, not named
21424 !! options
21425 subpage title=[[Subpage test/L1/L2/L3]]
21426 !! wikitext
21427 [[../]]
21428 !! html
21429 <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>
21430 </p>
21431 !! end
21432
21433
21434
21435 !! test
21436 Parents of subpages, two levels up
21437 !! options
21438 subpage title=[[Subpage test/L1/L2/L3]]
21439 !! wikitext
21440 [[../../|L1]]2
21441
21442 [[../../|L1]]l
21443 !! html
21444 <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
21445 </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>
21446 </p>
21447 !! end
21448
21449 !! test
21450 Parents of subpages, two levels up, without trailing slash or name.
21451 !! options
21452 subpage title=[[Subpage test/L1/L2/L3]]
21453 !! wikitext
21454 [[../..]]
21455 !! html
21456 <p>[[../..]]
21457 </p>
21458 !! end
21459
21460 !! test
21461 Parents of subpages, two levels up, with lots of extra trailing slashes.
21462 !! options
21463 subpage title=[[Subpage test/L1/L2/L3]]
21464 !! wikitext
21465 [[../../////]]
21466 !! html
21467 <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>
21468 </p>
21469 !! end
21470
21471 !! article
21472 Subpage test/L1/L2/L3Sibling
21473 !! text
21474 Sibling article
21475 !! endarticle
21476
21477 !! test
21478 Transclusion of a sibling page (one level up)
21479 !! options
21480 subpage title=[[Subpage test/L1/L2/L3]]
21481 !! wikitext
21482 {{../L3Sibling}}
21483 !! html
21484 <p>Sibling article
21485 </p>
21486 !! end
21487
21488 !! test
21489 Transclusion of a child page
21490 !! options
21491 subpage title=[[Subpage test/L1/L2]]
21492 !! wikitext
21493 {{/L3Sibling}}
21494 !! html
21495 <p>Sibling article
21496 </p>
21497 !! end
21498
21499 # This is wt2html only in Parsoid because we add <nowiki>
21500 # because of {{..}} and we don't expect to fix that to
21501 # eliminate the nowikis selective for {{..}} markup.
21502 !! test
21503 Non-transclusion because of too many up levels
21504 !! options
21505 subpage title=[[Subpage test/L1/L2/L3]]
21506 parsoid=wt2html
21507 !! wikitext
21508 {{../../../../More than parent}}
21509 !! html/php
21510 <p>{{../../../../More than parent}}
21511 </p>
21512 !! html/parsoid
21513 <p>{{../../../../More than parent}}</p>
21514 !! end
21515
21516 !! test
21517 Definition list code coverage
21518 !! wikitext
21519 ; title : def
21520 ; title : def
21521 ;title: def
21522 !! html/php
21523 <dl><dt> title &#160;</dt>
21524 <dd> def</dd>
21525 <dt> title&#160;</dt>
21526 <dd> def</dd>
21527 <dt>title</dt>
21528 <dd> def</dd></dl>
21529
21530 !! html/parsoid
21531 <dl><dt> title <span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21532 <dt> title<span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21533 <dt>title</dt><dd> def</dd></dl>
21534 !! end
21535
21536 !! test
21537 Don't fall for the self-closing div
21538 !! wikitext
21539 <div>hello world</div/>
21540 !! html
21541 <div>hello world</div>
21542
21543 !! end
21544
21545 !! test
21546 MSGNW magic word
21547 !! wikitext
21548 {{MSGNW:msg}}
21549 !! html/php
21550 <p>&#91;&#91;:Template:Msg&#93;&#93;
21551 </p>
21552 !! end
21553
21554 !! test
21555 RAW magic word
21556 !! wikitext
21557 {{RAW:QUERTY}}
21558 !! html
21559 <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>
21560 </p>
21561 !! end
21562
21563 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
21564 !! test
21565 Always escape literal '>' in output, not just after '<'
21566 !! wikitext
21567 ><>
21568 !! html
21569 <p>&gt;&lt;&gt;
21570 </p>
21571 !! end
21572
21573 !! test
21574 Template caching
21575 !! wikitext
21576 {{Test}}
21577 {{Test}}
21578 !! html
21579 <p>This is a test template
21580 This is a test template
21581 </p>
21582 !! end
21583
21584
21585 !! article
21586 MediaWiki:Fake
21587 !! text
21588 ==header==
21589 !! endarticle
21590
21591 !! test
21592 Inclusion of !userCanEdit() content
21593 !! wikitext
21594 {{MediaWiki:Fake}}
21595 !! html
21596 <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>
21597
21598 !! end
21599
21600
21601 !! test
21602 Out-of-order TOC heading levels
21603 !! wikitext
21604 ==2==
21605 ======6======
21606 ===3===
21607 =1=
21608 =====5=====
21609 ==2==
21610 !! html
21611 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
21612 <ul>
21613 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
21614 <ul>
21615 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
21616 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
21617 </ul>
21618 </li>
21619 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
21620 <ul>
21621 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
21622 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
21623 </ul>
21624 </li>
21625 </ul>
21626 </div>
21627
21628 <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>
21629 <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>
21630 <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>
21631 <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>
21632 <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>
21633 <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>
21634
21635 !! end
21636
21637
21638 !! test
21639 ISBN with a dummy number
21640 !! wikitext
21641 ISBN ---
21642 !! html
21643 <p>ISBN ---
21644 </p>
21645 !! end
21646
21647
21648 !! test
21649 ISBN with space-delimited number
21650 !! wikitext
21651 ISBN 92 9017 032 8
21652 !! html/php
21653 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
21654 </p>
21655 !! html/parsoid
21656 <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>
21657 !! end
21658
21659
21660 !! test
21661 ISBN with multiple spaces, no number
21662 !! wikitext
21663 ISBN foo
21664 !! html
21665 <p>ISBN foo
21666 </p>
21667 !! end
21668
21669
21670 !! test
21671 ISBN length
21672 !! wikitext
21673 ISBN 123456789
21674
21675 ISBN 1234567890
21676
21677 ISBN 12345678901
21678 !! html/php
21679 <p>ISBN 123456789
21680 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21681 </p><p>ISBN 12345678901
21682 </p>
21683 !! html/parsoid
21684 <p>ISBN 123456789</p>
21685
21686 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21687
21688 <p>ISBN 12345678901</p>
21689 !! end
21690
21691
21692 !! test
21693 ISBN with trailing year (T9110)
21694 !! wikitext
21695 ISBN 1-234-56789-0 - 2006
21696
21697 ISBN 1 234 56789 0 - 2006
21698 !! html/php
21699 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
21700 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
21701 </p>
21702 !! html/parsoid
21703 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
21704
21705 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
21706 !! end
21707
21708
21709 !! test
21710 anchorencode
21711 !! config
21712 wgFragmentMode=[ 'html5', 'legacy' ]
21713 !! wikitext
21714 {{anchorencode:foo bar©#%n}}
21715 !! html/php
21716 <p>foo_bar©#%n
21717 </p>
21718 !! html/parsoid
21719 <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>
21720 !! end
21721
21722 !! test
21723 anchorencode (legacy)
21724 !! config
21725 wgFragmentMode=[ 'legacy' ]
21726 !! wikitext
21727 {{anchorencode:foo bar©#%n}}
21728 !! html/php
21729 <p>foo_bar.C2.A9.23.25n
21730 </p>
21731 !! end
21732
21733 !! test
21734 anchorencode trims spaces
21735 !! config
21736 wgFragmentMode=[ 'html5', 'legacy' ]
21737 !! wikitext
21738 {{anchorencode: __pretty__please__}}
21739 !! html/php
21740 <p>pretty_please
21741 </p>
21742 !! html/parsoid
21743 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: __pretty__please__","function":"anchorencode"},"params":{},"i":0}}]}'>pretty_please</p>
21744 !! end
21745
21746 !! test
21747 anchorencode deals with links
21748 !! config
21749 wgFragmentMode=[ 'html5', 'legacy' ]
21750 !! wikitext
21751 {{anchorencode: [[hello|world]] [[hi]]}}
21752 !! html/php
21753 <p>world_hi
21754 </p>
21755 !! html/parsoid
21756 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: [[hello|world]] [[hi]]","function":"anchorencode"},"params":{},"i":0}}]}'>world_hi</p>
21757 !! end
21758
21759 !! test
21760 anchorencode deals with templates
21761 !! config
21762 wgFragmentMode=[ 'html5', 'legacy' ]
21763 !! wikitext
21764 {{anchorencode: {{Foo}} x}}
21765 !! html/php
21766 <p>FOO_x
21767 </p>
21768 !! html/parsoid
21769 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode: {{Foo}} x","function":"anchorencode"},"params":{},"i":0}}]}'>FOO_x</p>
21770 !! end
21771
21772 !! test
21773 anchorencode encodes like the TOC generator: (T20431)
21774 !! config
21775 wgFragmentMode=[ 'html5', 'legacy' ]
21776 !! wikitext
21777 === _ +:.3A%3A _ &&amp;]] x ===
21778 {{anchorencode: _ +:.3A%3A _ &&amp;]] x}}
21779 __NOEDITSECTION__
21780 !! html/php
21781 <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>
21782 <p>+:.3A%3A_&amp;&amp;&#93;&#93;_x
21783 </p>
21784 !! html/parsoid
21785 <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>
21786 <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>
21787 <meta property="mw:PageProp/noeditsection"/>
21788 !! end
21789
21790 !! test
21791 anchorencode encodes like the TOC generator: (T20431) (legacy)
21792 !! config
21793 wgFragmentMode=[ 'legacy' ]
21794 !! wikitext
21795 === _ +:.3A%3A&&amp;]] ===
21796 {{anchorencode: _ +:.3A%3A&&amp;]] }}
21797 __NOEDITSECTION__
21798 !! html/php
21799 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
21800 <p>.2B:.3A.253A.26.26.5D.5D
21801 </p>
21802 !! end
21803
21804 !! test
21805 T8200: blockquotes and paragraph formatting
21806 !! wikitext
21807 <blockquote>
21808 foo
21809 </blockquote>
21810
21811 bar
21812
21813 baz
21814 !! html
21815 <blockquote>
21816 <p>foo
21817 </p>
21818 </blockquote>
21819 <p>bar
21820 </p>
21821 <pre>baz
21822 </pre>
21823 !! end
21824
21825 !! test
21826 T10293: Use of center tag ruins paragraph formatting
21827 !! wikitext
21828 <center>
21829 foo
21830 </center>
21831
21832 bar
21833
21834 baz
21835 !! html
21836 <center>
21837 <p>foo
21838 </p>
21839 </center>
21840 <p>bar
21841 </p>
21842 <pre>baz
21843 </pre>
21844 !! end
21845
21846 !!test
21847 Parsing of overlapping (improperly nested) inline html tags
21848 !! wikitext
21849 <span><s>x</span></s>
21850 !! html/php
21851 <p><span><s>x&lt;/span&gt;</s></span>
21852 </p>
21853 !! html/parsoid
21854 <p><span><s>x</s></span>
21855 </p>
21856 !!end
21857
21858 ###
21859 ### Language variants related tests
21860 ###
21861
21862 # Parsoid does not mark self-links.
21863 # Parsoid does not convert links; PHP will do any necessary redirects.
21864
21865 !! test
21866 Self-link in language variants
21867 !! options
21868 title=[[Dunav]] language=sr
21869 !! wikitext
21870 Both [[Dunav]] and [[Дунав]] are names for this river.
21871 !! html/php
21872 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
21873 </p>
21874 !! html/parsoid
21875 <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>
21876 !! end
21877
21878 !! article
21879 Дуна
21880 !! text
21881 content
21882 !! endarticle
21883
21884 !! test
21885 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
21886 !! options
21887 title=[[Duna]] language=sr
21888 !! wikitext
21889 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
21890 !! html/php
21891 <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.
21892 </p>
21893 !! html/parsoid
21894 <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>
21895 !! end
21896
21897 !! test
21898 Link to a section of a variant of this title shouldn't be parsed as self-link
21899 !! options
21900 title=[[Duna]] language=sr
21901 !! wikitext
21902 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
21903 !! html/php
21904 <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.
21905 </p>
21906 !! html/parsoid
21907 <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>
21908 !! end
21909
21910 !! test
21911 Link to pages in language variants
21912 !! options
21913 language=sr
21914 !! wikitext
21915 Main Page can be written as [[Маин Паге]]
21916 !! html/php
21917 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
21918 </p>
21919 !! html/parsoid
21920 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
21921 !! end
21922
21923
21924 !! test
21925 Multiple links to pages in language variants
21926 !! options
21927 language=sr
21928 !! wikitext
21929 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
21930 !! html/php
21931 <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>.
21932 </p>
21933 !! html/parsoid
21934 <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>
21935 !! end
21936
21937
21938 !! test
21939 Simple template in language variants
21940 !! options
21941 language=sr
21942 !! wikitext
21943 {{тест}}
21944 !! html/php
21945 <p>This is a test template
21946 </p>
21947 !! end
21948
21949
21950 !! test
21951 Template with explicit namespace in language variants
21952 !! options
21953 language=sr
21954 !! wikitext
21955 {{Template:тест}}
21956 !! html/php
21957 <p>This is a test template
21958 </p>
21959 !! end
21960
21961
21962 !! test
21963 Basic test for template parameter in language variants
21964 !! options
21965 language=sr
21966 !! wikitext
21967 {{парамтест|param=foo}}
21968 !! html/php
21969 <p>This is a test template with parameter foo
21970 </p>
21971 !! end
21972
21973 !! test
21974 Simple category in language variants
21975 !! options
21976 language=sr cat
21977 !! wikitext
21978 [[Category:МедиаWики Усер'с Гуиде]]
21979 !! html/php
21980 cat=МедиаWики_Усер'с_Гуиде sort=
21981 !! html/parsoid
21982 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
21983 !! end
21984
21985 !! article
21986 Category:分类
21987 !! text
21988 blah
21989 !! endarticle
21990
21991 !! article
21992 Category:分類
21993 !! text
21994 blah
21995 !! endarticle
21996
21997 ## We used to, but no longer wt2wt this test since the default serializer
21998 ## will normalize all categories to serialize on their own line.
21999 ## This wikitext usage is going to be fairly uncommon in production and
22000 ## selser will take care of preserving formatting in those scenarios.
22001 !! test
22002 Don't convert blue categorylinks to another variant (T35210)
22003 !! options
22004 cat
22005 language=zh
22006 parsoid=wt2html
22007 !! wikitext
22008 [[A]][[Category:分类]]
22009 !! html/php
22010 cat=分类 sort=
22011 !! html/parsoid
22012 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
22013 <link rel="mw:PageProp/Category" href="./Category:分类"/>
22014 !! end
22015
22016 !! test
22017 Stripping -{}- tags (language variants)
22018 !! options
22019 language=sr
22020 !! wikitext
22021 Latin proverb: -{Ne nuntium necare}-
22022 !! html/php
22023 <p>Latin proverb: Ne nuntium necare
22024 </p>
22025 !! html/parsoid
22026 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22027 !! end
22028
22029
22030 !! test
22031 Prevent conversion with -{}- tags (language variants)
22032 !! options
22033 language=sr variant=sr-ec
22034 !! wikitext
22035 Latinski: -{Ne nuntium necare}-
22036 !! html/php
22037 <p>Латински: Ne nuntium necare
22038 </p>
22039 !! html/parsoid
22040 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22041 !! end
22042
22043
22044 !! test
22045 Prevent conversion of text with -{}- tags (language variants)
22046 !! options
22047 language=sr variant=sr-ec
22048 !! wikitext
22049 Latinski: -{Ne nuntium necare}-
22050 !! html/php
22051 <p>Латински: Ne nuntium necare
22052 </p>
22053 !! html/parsoid
22054 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
22055 !! end
22056
22057
22058 !! test
22059 Prevent conversion of links with -{}- tags (language variants)
22060 !! options
22061 language=sr variant=sr-ec
22062 !! wikitext
22063 -{[[Main Page]]}-
22064 !! html/php
22065 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22066 </p>
22067 !! html/parsoid
22068 <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>
22069 !! end
22070
22071
22072 !! test
22073 -{}- tags within headlines (within html for parserConvert())
22074 !! config
22075 wgFragmentMode=[ 'html5', 'legacy' ]
22076 !! options
22077 language=sr variant=sr-ec
22078 !! wikitext
22079 == -{Naslov}- ==
22080
22081 Note that even an unprotected headline ID is not affected by language
22082 conversion:
22083
22084 == Latinski ==
22085 !! html/php
22086 <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>
22087 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
22088 цонверсион:
22089 </p>
22090 <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>
22091
22092 !! html/parsoid
22093 <h2 id="-{Naslov}-"><span id="-.7BNaslov.7D-" typeof="mw:FallbackId"></span> <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span> </h2>
22094
22095 <p>Note that even an unprotected headline ID is not affected by language
22096 conversion:</p>
22097
22098 <h2 id="Latinski">Latinski</h2>
22099 !! end
22100
22101 !! test
22102 Explicit definition of language variant alternatives
22103 !! options
22104 language=zh variant=zh-tw
22105 !! wikitext
22106 -{zh:China;zh-tw:Taiwan}-, not China
22107 !! html/php
22108 <p>Taiwan, not China
22109 </p>
22110 !! html/parsoid
22111 <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>
22112 !! end
22113
22114 !! test
22115 Filter syntax for language variants
22116 !! options
22117 language=zh variant=zh-tw
22118 !! wikitext
22119 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
22120 !! html/php
22121 <p>fooblog, WEBJOURNAL, WEBLOGquux
22122 </p>
22123 !! html/parsoid
22124 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
22125 !! end
22126
22127 # Note that Parsoid post-processing for language variants needs to
22128 # update the `title` attribute here, based on the mw:ExpandedAttrs property
22129 !! test
22130 Conversion around HTML tags
22131 !! options
22132 language=sr variant=sr-ec
22133 !! wikitext
22134 -{H|span=>sr-ec:script;title=>sr-ec:src}-
22135 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
22136 !! html/php
22137 <p>
22138 <span title="ЛаCтин">ски</span>
22139 </p>
22140 !! html/parsoid
22141 <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"}]}'/>
22142 <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>
22143 !! end
22144
22145 !! test
22146 Explicit session-wise two-way language variant mapping (A flag and - flag)
22147 !! options
22148 language=zh variant=zh-tw
22149 !! wikitext
22150 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
22151
22152 Taiwan is not China.
22153
22154 But -{A|zh:China; zh-tw:Taiwan}- is China,
22155
22156 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
22157
22158 and -{China}- is China.
22159 !! html/php
22160 <p>This is Taiwan, but we'll forget that now.
22161 </p><p>Taiwan is not China.
22162 </p><p>But Taiwan is Taiwan,
22163 </p><p>(This should be stripped!)
22164 </p><p>and China is China.
22165 </p>
22166 !! html/parsoid
22167 <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>
22168 <p>Taiwan is not China.</p>
22169 <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>
22170 <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>
22171 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
22172 !! end
22173
22174 !! test
22175 Explicit session-wise one-way language variant mapping (A flag and - flag)
22176 !! options
22177 language=zh variant=zh-tw
22178 !! wikitext
22179 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
22180
22181 COUNTRY is China or Taiwan.
22182
22183 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
22184
22185 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22186
22187 and -{COUNTRY}- is COUNTRY.
22188 !! html/php
22189 <p>This is Taiwan, but we'll forget that now.
22190 </p><p>COUNTRY is China or Taiwan.
22191 </p><p>But Taiwan is Taiwan,
22192 </p><p>(This should be stripped!)
22193 </p><p>and COUNTRY is COUNTRY.
22194 </p>
22195 !! html/parsoid
22196 <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>
22197 <p>COUNTRY is China or Taiwan.</p>
22198 <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>
22199 <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>
22200 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
22201 !! end
22202
22203 !! test
22204 Explicit session-wise two-way language variant mapping (H flag for hide)
22205 !! options
22206 language=zh variant=zh-tw
22207 !! wikitext
22208 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
22209
22210 Taiwan is China.
22211 !! html/php
22212 <p>(This should be stripped!)
22213 </p><p>Taiwan is Taiwan.
22214 </p>
22215 !! html/parsoid
22216 <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>
22217 <p>Taiwan is China.</p>
22218 !! end
22219
22220 !! test
22221 Explicit session-wise one-way language variant mapping (H flag for hide)
22222 !! options
22223 language=zh variant=zh-tw
22224 !! wikitext
22225 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
22226
22227 COUNTRY is Taiwan or China.
22228 !! html/php
22229 <p>(This should be stripped!)
22230 </p><p>Taiwan is Taiwan or China.
22231 </p>
22232 !! html/parsoid
22233 <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>
22234 <p>COUNTRY is Taiwan or China.</p>
22235 !! end
22236
22237 ## Note that parsoid test runner does not support 'showtitle' option.
22238 !! test
22239 Adding explicit conversion rule for title (T flag)
22240 !! options
22241 language=zh variant=zh-tw showtitle
22242 !! wikitext
22243 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
22244
22245 Taiwan is China.
22246 !! html/php
22247 Taiwan
22248 <p>Should be stripped!
22249 </p><p>Taiwan is China.
22250 </p>
22251 !! html/parsoid
22252 <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>
22253 <p>Taiwan is China.</p>
22254 !! end
22255
22256 !! test
22257 Code coverage: T combined with H flag
22258 !! options
22259 language=zh variant=zh-tw showtitle
22260 !! wikitext
22261 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
22262
22263 Taiwan is China.
22264 !! html/php
22265 Taiwan
22266 <p>Should be stripped!
22267 </p><p>Taiwan is Taiwan.
22268 </p>
22269 !! html/parsoid
22270 <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>
22271 <p>Taiwan is China.</p>
22272 !! end
22273
22274 !! test
22275 Code coverage: T with no variants
22276 !! options
22277 language=zh variant=zh-tw showtitle
22278 !! wikitext
22279 -{H|zh:China; zh-tw:Taiwan}-
22280 Taiwan is China.-{T|Taiwan is China}-
22281 !! html/php
22282 Taiwan is China
22283 <p>
22284 Taiwan is Taiwan.
22285 </p>
22286 !! html/parsoid
22287 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22288 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
22289 !! end
22290
22291 !! test
22292 Code coverage: rules with no variants
22293 !! options
22294 language=zh variant=zh-tw
22295 !! wikitext
22296 -{H|zh:China; zh-tw:Taiwan}-
22297 Taiwan is China.
22298 -{H|China}-
22299 Taiwan is China.
22300 !! html/php
22301 <p>
22302 Taiwan is Taiwan.
22303
22304 Taiwan is China.
22305 </p>
22306 !! html/parsoid
22307 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22308 Taiwan is China.
22309 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
22310 Taiwan is China.</p>
22311 !! end
22312
22313
22314 !! test
22315 Code coverage: D flag for conversion rule
22316 !! options
22317 language=zh variant=zh-tw
22318 !! wikitext
22319 -{D|zh-cn:XA; zh-tw:YA}-
22320 -{A;D|zh-cn:XB; zh-tw:YB}-
22321 -{D;H|zh-cn:XC; zh-tw:YC}-
22322
22323 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
22324
22325 -{D|0=>zh-tw:1}-
22326 -{A;D|2=>zh-tw:3}-
22327 -{D;H|4=>zh-tw:5}-
22328
22329 XA XB XC YA YB YC FOO BAR BAT 012345
22330 !! html/php
22331 <p>大陆:XA;台灣:YA;
22332
22333 大陆:XC;台灣:YC;
22334 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
22335 </p><p>0⇒台灣:1;
22336
22337 4⇒台灣:5;
22338 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
22339 </p>
22340 !! html/parsoid
22341 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
22342 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
22343 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
22344 <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>
22345 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
22346 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
22347 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
22348 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
22349 !! end
22350
22351 !! test
22352 Code coverage: N flag for conversion rule
22353 !! options
22354 language=zh variant=zh-cn
22355 !! wikitext
22356 -{N|zh-cn}-
22357
22358 -{N|zh-tw}-
22359
22360 -{N|sr-ec}-
22361 !! html/php
22362 <p>大陆
22363 </p><p>台灣
22364 </p><p>српски (ћирилица)‎
22365 </p>
22366 !! html/parsoid
22367 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
22368 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
22369 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
22370 !! end
22371
22372 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
22373 !! test
22374 Code coverage: N flag for conversion rule (wt2html only)
22375 !! options
22376 language=zh variant=zh-cn
22377 parsoid=wt2html,html2html
22378 !! wikitext
22379 -{D;N|en}-
22380 !! html/php
22381 <p>English
22382 </p>
22383 !! html/parsoid
22384 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
22385 !! end
22386
22387 !! test
22388 Testing that changing the language variant here in the tests actually works
22389 !! options
22390 language=zh variant=zh showtitle
22391 !! wikitext
22392 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22393 !! html/php
22394 China
22395 <p>Should be stripped!
22396 </p>
22397 !! html/parsoid
22398 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
22399 !! end
22400
22401 !! test
22402 Recursive conversion of alt and title attrs shouldn't clear converter state
22403 !! options
22404 language=zh variant=zh-cn
22405 showtitle
22406 !! wikitext
22407 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
22408 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
22409 !! html/php
22410 China
22411 <p>
22412 Should be stripped<span title="Exclamation">!</span>
22413 </p>
22414 !! html/parsoid
22415 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
22416 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>
22417 !! end
22418
22419 !! test
22420 T26072: more test on conversion rule for title
22421 !! options
22422 language=zh variant=zh-tw showtitle
22423 !! wikitext
22424 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22425
22426 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
22427 !! html/php
22428 Taiwan
22429 <p>This should be stripped!
22430 </p><p>This won't take interferes with the title rule.
22431 </p>
22432 !! html/parsoid
22433 <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>
22434 <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>
22435 !! end
22436
22437 !! test
22438 Partly disable title conversion if variant == main language code
22439 !! options
22440 language=zh variant=zh title=[[ZH]] showtitle
22441 !! wikitext
22442 -{T|zh-cn:CN;zh-tw:TW}-
22443 !! html/php
22444 ZH
22445 <p>
22446 </p>
22447 !! html/parsoid
22448 <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>
22449 !! end
22450
22451 !! test
22452 Partly disable title conversion if variant == main language code, more
22453 !! options
22454 language=zh variant=zh title=[[ZH]] showtitle
22455 !! wikitext
22456 -{T|TW}-
22457 !! html/php
22458 ZH
22459 <p>
22460 </p>
22461 !! html/parsoid
22462 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
22463 !! end
22464
22465 !! test
22466 Raw output of variant escape tags (R flag)
22467 !! options
22468 language=zh variant=zh-tw
22469 !! wikitext
22470 Raw: -{R|zh:China;zh-tw:Taiwan}-
22471 !! html/php
22472 <p>Raw: zh:China;zh-tw:Taiwan
22473 </p>
22474 !! html/parsoid
22475 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
22476 !! end
22477
22478 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
22479 !! test
22480 Raw output of variant escape tags (R flag) (wt2html only)
22481 !! options
22482 language=zh variant=zh-tw
22483 parsoid=wt2html,html2html
22484 !! wikitext
22485 -{Variant}- -{D|syntax}- -{D;R|options}-
22486 !! html/php
22487 <p>Variant syntax options
22488 </p>
22489 !! html/parsoid
22490 <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>
22491 !! end
22492
22493 !! test
22494 Nested markup inside raw output of variant escape tags (R flag)
22495 !! options
22496 language=zh variant=zh-tw
22497 !! wikitext
22498 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
22499 !! html/php
22500 <p>Nested raw: nested Taiwan nested
22501 </p>
22502 !! html/parsoid
22503 <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>
22504 !! end
22505
22506 !! test
22507 Nested markup and spaces inside raw output of variant escape tags (R flag)
22508 !! options
22509 language=zh variant=zh-tw
22510 !! wikitext
22511 X-{ outer -{ inner }- outer }-X
22512 !! html/php
22513 <p>X outer inner outer X
22514 </p>
22515 !! html/parsoid
22516 <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>
22517 !! end
22518
22519 !! test
22520 Templates inside raw output of variant escape tags (R flag)
22521 !! options
22522 language=zh variant=zh-tw
22523 !! wikitext
22524 Nested raw: -{R|nested {{echo|hi}} templates}-
22525 !! html/php
22526 <p>Nested raw: nested hi templates
22527 </p>
22528 !! html/parsoid
22529 <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>
22530 !! end
22531
22532 !! test
22533 Strings evaluating false shouldn't be ignored by Language converter (T51072)
22534 !! options
22535 language=zh variant=zh-cn
22536 !! input
22537 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
22538 !! html/php
22539 <p>0
22540 </p>
22541 !! html/parsoid
22542 <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>
22543 !! end
22544
22545 !! test
22546 Conversion rules from [numeric-only string] to [something else] (T48634)
22547 !! options
22548 language=zh variant=zh-cn
22549 !! input
22550 -{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
22551 !! html/php
22552 <p>D12345EE12345
22553 </p>
22554 !! html/parsoid
22555 <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>
22556 !! end
22557
22558 !! test
22559 Two-way converter rule entries with an empty value should be ignored (T53551)
22560 !! options
22561 language=zh variant=zh-cn
22562 !! input
22563 -{H|zh-cn:foo;zh-tw:;}-foobar
22564 !! html/php
22565 <p>foobar
22566 </p>
22567 !! html/parsoid
22568 <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>
22569 !! end
22570
22571 !! test
22572 One-way converter rule entries with an empty "from" string should be ignored (T53551)
22573 !! options
22574 language=zh variant=zh-cn
22575 !! input
22576 -{H|=>zh-cn:foo;}-foobar
22577 !! html/php
22578 <p>foobar
22579 </p>
22580 !! html/parsoid
22581 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
22582 !! end
22583
22584 !! test
22585 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
22586 !! options
22587 language=zh variant=zh-cn
22588 !! input
22589 -{H|}-foobar
22590 !! html/php
22591 <p>foobar
22592 </p>
22593 !! html/parsoid
22594 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
22595 !! end
22596
22597 !! test
22598 Nested using of manual convert syntax
22599 !! options
22600 language=zh variant=zh-hk
22601 !! wikitext
22602 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
22603 !! html/php
22604 <p>Nested: Hello Hong Kong!
22605 </p>
22606 !! html/parsoid
22607 <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>
22608 !! end
22609
22610 !! test
22611 HTML markups with conversion syntax in attribs, nested in other conversion blocks
22612 !! options
22613 language=zh variant=zh-cn
22614 !! wikitext
22615 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
22616 !! html/php
22617 <p><span title="X">A</span>
22618 </p>
22619 !! html/parsoid
22620 <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>
22621 !! end
22622
22623 !! test
22624 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
22625 !! options
22626 language=zh variant=zh-cn
22627 !! wikitext
22628 -{<span title="-{X}-">A</span>}-
22629 !! html/php+disabled
22630 <p><span title="X">A</span>
22631 </p>
22632 !! html/parsoid
22633 <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>
22634 !! end
22635
22636 # Parsoid and PHP disagree on how to parse this example: Parsoid
22637 # insists that the content of a language converter element be a valid
22638 # DOM fragment or attribute string
22639 !! test
22640 Language converter markup with block content
22641 !! options
22642 language=zh variant=zh-cn
22643 !! wikitext
22644 <span>a-{b<div>c}-d
22645
22646 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
22647
22648 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
22649 !! html/php+tidy
22650 <p><span>ab</span></p>
22651 <div><span>cd <span>ab</span></span>
22652 <div><span>cd <span>ad</span></span></div>
22653 </div>
22654 !! html/parsoid
22655 <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>
22656
22657 <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>
22658
22659 <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>
22660 !! end
22661
22662 !! test
22663 LanguageConverter selser (1)
22664 !! options
22665 language=zh variant=zh-cn
22666 parsoid={
22667 "modes": ["wt2wt", "selser"],
22668 "changes": [
22669 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22670 ]
22671 }
22672 !! wikitext
22673 -{raw}-
22674 !! wikitext/edited
22675 -{edited}-
22676 !! end
22677
22678 !! test
22679 LanguageConverter selser (2)
22680 !! options
22681 language=zh variant=zh-cn
22682 parsoid={
22683 "modes": ["wt2wt", "selser"],
22684 "changes": [
22685 ["span[class='x']", "contents", "text", "-{foo}-"],
22686 ["a", "contents", "text", "-{"],
22687 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
22688 ]
22689 }
22690 !! wikitext
22691 <span class="x">TEXT1</span>
22692 [http://example.com TEXT2]
22693 [[Foo|TEXT3]]
22694 {{echo|TEXT4}}
22695 !! wikitext/edited
22696 <span class="x"><nowiki>-{foo}-</nowiki></span>
22697 [http://example.com -{]
22698 [[Foo|<nowiki>-{</nowiki>]]
22699 {{1x|<nowiki>-{</nowiki>}}
22700 !! end
22701
22702 # Tests LanguageVariantText in ConstrainedText
22703 !! test
22704 LanguageConverter selser (3)
22705 !! options
22706 language=zh variant=zh-cn
22707 parsoid={
22708 "modes": ["wt2wt", "selser"],
22709 "changes": [
22710 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
22711 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22712 ]
22713 }
22714 !! wikitext
22715 {|
22716 |-
22717 |<span>Foo</span>
22718 |}
22719 !! wikitext/edited
22720 {|
22721 |-
22722 |<nowiki/>-{edited}-
22723 |}
22724 !! end
22725
22726 # Tests LanguageVariantText._fromSelSer
22727 !! test
22728 LanguageConverter selser (4)
22729 !! options
22730 language=zh variant=zh-cn
22731 parsoid={
22732 "modes": ["wt2wt", "selser"],
22733 "changes": [
22734 ["td > span.x", "remove"]
22735 ]
22736 }
22737 !! wikitext
22738 {|
22739 |-
22740 |<span class="x">Foo</span>-{Bar}-
22741 ||<span class="x">Foo</span>-{Bar}-
22742 |}
22743 !! wikitext/edited
22744 {|
22745 |-
22746 |<nowiki/>-{Bar}-
22747 ||-{Bar}-
22748 |}
22749 !! end
22750
22751 # Since Parsoid is starting to emit canonical wikitext for links,
22752 # [http://example.com http://example.com] will not RT back to that
22753 # form anymore.
22754 # Parsoid does not language-convert links (it is done in a
22755 # post-processing step)
22756 !! test
22757 Proper conversion of text in external links
22758 !! options
22759 language=sr variant=sr-ec
22760 parsoid=wt2html
22761 !! wikitext
22762 http://www.google.com
22763 gopher://www.google.com
22764 [http://www.google.com http://www.google.com]
22765 [gopher://www.google.com gopher://www.google.com]
22766 [https://www.google.com irc://www.google.com]
22767 [ftp://www.google.com www.google.com/ftp://dir]
22768 [//www.google.com www.google.com]
22769 !! html/php
22770 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22771 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22772 <a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22773 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22774 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
22775 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
22776 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
22777 </p>
22778 !! html/parsoid
22779 <p><a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
22780 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
22781 <a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
22782 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
22783 <a rel="mw:ExtLink" href="https://www.google.com">irc://www.google.com</a>
22784 <a rel="mw:ExtLink" href="ftp://www.google.com">www.google.com/ftp://dir</a>
22785 <a rel="mw:ExtLink" href="//www.google.com">www.google.com</a></p>
22786 !! end
22787
22788 !! test
22789 Do not convert roman numbers to language variants
22790 !! options
22791 language=sr variant=sr-ec
22792 !! wikitext
22793 Fridrih IV je car.
22794 !! html/php
22795 <p>Фридрих IV је цар.
22796 </p>
22797 !! html/parsoid
22798 <p>Fridrih IV je car.</p>
22799 !! end
22800
22801 !! test
22802 Unclosed language converter markup "-{"
22803 !! options
22804 language=sr
22805 !! wikitext
22806 -{T|hello
22807 !! html
22808 <p>-{T|hello
22809 </p>
22810 !! end
22811
22812 !! test
22813 Don't convert raw rule "-{R|=&gt;}-" to "=>"
22814 !! options
22815 language=sr
22816 !! wikitext
22817 -{R|=&gt;}-
22818 !! html/php
22819 <p>=&gt;
22820 </p>
22821 !! html/parsoid
22822 <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>
22823 !!end
22824
22825 !! test
22826 Don't break link parsing if language converter markup is in the caption.
22827 !! options
22828 language=sr variant=sr-ec
22829 !! wikitext
22830 [[Main Page|-{R|main page}-]]
22831 !! html/php
22832 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
22833 </p>
22834 !! html/parsoid
22835 <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>
22836 !! end
22837
22838 !! test
22839 T146304: Don't break template parsing if language converter markup is in the parameter.
22840 !! options
22841 language=sr variant=sr-ec
22842 !! wikitext
22843 {{echo|-{R|foo}-}}
22844 !! html/php
22845 <p>foo
22846 </p>
22847 !! html/parsoid
22848 <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>
22849 !! end
22850
22851 !! test
22852 T146305: Don't break image parsing if language converter markup is in the caption.
22853 !! options
22854 language=sr
22855 !! wikitext
22856 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
22857 !! html/php
22858 <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>
22859
22860 !! html/parsoid
22861 <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>
22862 !! end
22863
22864 !! test
22865 T146305: Don't break image parsing if nested language converter markup is in the caption.
22866 !! options
22867 language=zh variant=zh-cn
22868 !! wikitext
22869 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
22870 !! html/php
22871 <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>
22872
22873 !! html/parsoid
22874 <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>
22875 !! end
22876
22877 # XXX html2wt disabled because rich markup in alt is not preserved.
22878 !! test
22879 Don't break gallery if language converter markup is inside.
22880 !! options
22881 language=zh
22882 !! wikitext
22883 <gallery>
22884 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
22885 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
22886 </gallery>
22887 !! html/php
22888 <ul class="gallery mw-gallery-traditional">
22889 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22890 <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>
22891 <div class="gallerytext">
22892 <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>
22893 </p>
22894 </div>
22895 </div></li>
22896 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22897 <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>
22898 <div class="gallerytext">
22899 <p>This is a test template
22900 </p>
22901 </div>
22902 </div></li>
22903 </ul>
22904
22905 !! html/parsoid
22906 <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"}}'>
22907 <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>
22908 <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>
22909 </ul>
22910 !! end
22911
22912 !! test
22913 T153135: Don't break list handling if language converter markup is in the item.
22914 !! options
22915 language=zh variant=zh-cn
22916 !! wikitext
22917 ;-{zh-cn:AAA;zh-tw:BBB}-
22918 ;-{R|foo:bar}-
22919 !! html/php
22920 <dl><dt>AAA</dt>
22921 <dt>foo:bar</dt></dl>
22922
22923 !! html/parsoid
22924 <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>
22925 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
22926 </dl>
22927 !! end
22928
22929 // Note that parsoid does not protect colons unless language converter
22930 // markup is properly nested, because it is a backtracking parser.
22931 !! test
22932 T153135: Unclosed markup in definition list (code coverage)
22933 !! options
22934 language=zh variant=zh-cn
22935 !! wikitext
22936 ;<b>foo:bar
22937 ;-{zh-cn:AAA
22938 !! html/php+tidy
22939 <dl>
22940 <dt><b>foo:bar</b></dt>
22941 <dt><b>-{zh-cn:AAA</b></dt>
22942 </dl>
22943 !! html/parsoid
22944 <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}'>
22945 <dt data-parsoid='{"dsr":[12,20,1,0]}'>-{zh-cn</dt>
22946 <dd data-parsoid='{"stx":"row","dsr":[20,24,1,0]}'>AAA</dd>
22947 </b></dl>
22948 !! end
22949
22950 !! test
22951 T153135: Nested language converter markup in definition list (code coverage)
22952 !! options
22953 language=zh variant=zh-cn
22954 !! wikitext
22955 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
22956 !! html/php
22957 <dl><dt>AAA foo:bar bat:baz</dt>
22958 <dd>def</dd></dl>
22959
22960 !! html/parsoid
22961 <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>
22962 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
22963 </dl>
22964 !! end
22965
22966 # html2wt mode disabled due to <nowiki> insertion.
22967 !! test
22968 T153140: Don't break table handling if language converter markup is in the cell.
22969 !! options
22970 language=sr variant=sr-ec
22971 parsoid=wt2html,wt2wt,html2html
22972 !! wikitext
22973 {|
22974 |-
22975 | -{R|B}-
22976 |}
22977 !! html/php
22978 <table>
22979
22980 <tr>
22981 <td> B
22982 </td></tr></table>
22983
22984 !! html/parsoid
22985 <table>
22986 <tbody>
22987 <tr>
22988 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
22989 </tr>
22990 </tbody>
22991 </table>
22992 !! end
22993
22994 !! test
22995 Language converter tricky html2wt cases (1)
22996 !! options
22997 language=sr
22998 parsoid=html2wt,wt2wt
22999 !! html/parsoid
23000 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
23001 !! wikitext
23002 -{<nowiki>}-</nowiki>}-
23003 !! html/php
23004 <p>&#125;-
23005 </p>
23006 !! end
23007
23008 !! test
23009 Language converter tricky html2wt cases (2)
23010 !! options
23011 language=sr
23012 parsoid=html2wt,wt2wt
23013 !! html/parsoid
23014 <p>-{foo}-</p>
23015 !! wikitext
23016 <nowiki>-{foo}-</nowiki>
23017 !! html/php
23018 <p>-&#123;foo&#125;-
23019 </p>
23020 !! end
23021
23022 !! test
23023 Language converter tricky html2wt cases (3)
23024 !! options
23025 language=sr
23026 parsoid=html2wt,wt2wt
23027 !! html/parsoid
23028 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
23029 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
23030 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
23031 !! wikitext
23032 -{R||}-
23033
23034 -{R|R|raw}-
23035
23036 -{<nowiki>-{foo}-</nowiki>}-
23037 !! html/php
23038 <p>|
23039 </p><p>R|raw
23040 </p><p>-&#123;foo&#125;-
23041 </p>
23042 !! end
23043
23044 !! test
23045 Language converter tricky html2wt cases (4)
23046 !! options
23047 language=sr
23048 parsoid=html2wt,wt2wt
23049 !! html/parsoid
23050 <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>
23051 !! wikitext
23052 -{R|{{echo|hey}}}-
23053 !! html/php
23054 <p>hey
23055 </p>
23056 !! end
23057
23058 # Note that the <nowiki> escaping added by parsoid for source text,
23059 # destination text, and language names only works on the PHP side
23060 # for *destination text*. (HTML entity escaping wouldn't work
23061 # any better.) This is probably a bug, at least for source texts.
23062 # (For language names PHP uses a precise regexp based on the languages
23063 # it currently knows have variants, which is fragile since this set
23064 # can grow/shrink over time.)
23065 !! test
23066 Language converter tricky html2wt cases (5)
23067 !! options
23068 language=zh variant=zh-cn
23069 !! html/parsoid
23070 <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>
23071 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
23072 <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>
23073 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
23074 <p>a:b=>c xyz</p>
23075 !! wikitext
23076 -{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
23077
23078 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
23079
23080 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
23081
23082 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
23083
23084 a:b=>c xyz
23085 !! html/php+disabled
23086 <p>foobat;xyz=&gt;zh-cn:abc
23087 </p><p>A
23088 </p><p>0;zh-tw:bar
23089 </p><p>abc
23090 </p><p>a:b=&gt;c 0;zh-tw:bar
23091 </p>
23092 !! end
23093
23094 !! test
23095 T179579: Nowiki and lc interaction
23096 !! options
23097 parsoid=wt2html
23098 language=sr
23099 !! wikitext
23100 -{</nowiki>123}-
23101
23102 -{123<nowiki>|</nowiki>456}-
23103 !! html/parsoid
23104 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
23105
23106 <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>
23107 !! end
23108
23109 !! test
23110 T2529: Uncovered bullet
23111 !! wikitext
23112 * Foo {{bullet}}
23113 !! html
23114 <ul><li> Foo </li>
23115 <li> Bar</li></ul>
23116
23117 !! end
23118
23119 # Plain MediaWiki does not remove empty lists, but tidy actually does.
23120 # Templates in Wikipedia rely on this behavior, as tidy has always been
23121 # enabled there. These tests are normally run *without* tidy, so specify the
23122 # full output here.
23123 # To test realistic parsing behavior, apply a tidy-like transformation to both
23124 # the expected output and your parser's output.
23125 !! test
23126 T2529: Uncovered bullet leaving empty list, normally removed by tidy
23127 !! wikitext
23128 ******* Foo {{bullet}}
23129 !! html
23130 <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>
23131 <li> Bar</li></ul>
23132
23133 !! end
23134
23135 !! test
23136 T2529: Uncovered table already at line-start
23137 !! wikitext
23138 x
23139
23140 {{table}}
23141 y
23142 !! html
23143 <p>x
23144 </p>
23145 <table>
23146 <tr>
23147 <td> 1 </td>
23148 <td> 2
23149 </td></tr>
23150 <tr>
23151 <td> 3 </td>
23152 <td> 4
23153 </td></tr></table>
23154 <p>y
23155 </p>
23156 !! end
23157
23158 !! test
23159 T2529: Uncovered bullet in parser function result
23160 !! wikitext
23161 * Foo {{lc:{{bullet}} }}
23162 !! html
23163 <ul><li> Foo </li>
23164 <li> bar</li></ul>
23165
23166 !! end
23167
23168 !! test
23169 T7678: Double-parsed template argument
23170 !! wikitext
23171 {{lc:{{{1}}}|hello}}
23172 !! html
23173 <p>{{{1}}}
23174 </p>
23175 !! end
23176
23177 !! test
23178 T7678: Double-parsed template invocation
23179 !! wikitext
23180 {{lc:{{paramtest {{!}} param = hello }} }}
23181 !! html
23182 <p>{{paramtest | param = hello }}
23183 </p>
23184 !! end
23185
23186 !! test
23187 Case insensitivity of parser functions for non-ASCII characters (T10143)
23188 !! options
23189 language=cs
23190 title=[[Main Page]]
23191 !! wikitext
23192 {{PRVNÍVELKÉ:ěščř}}
23193 {{prvnívelké:ěščř}}
23194 {{PRVNÍMALÉ:ěščř}}
23195 {{prvnímalé:ěščř}}
23196 {{MALÁ:ěščř}}
23197 {{malá:ěščř}}
23198 {{VELKÁ:ěščř}}
23199 {{velká:ěščř}}
23200 !! html
23201 <p>Ěščř
23202 Ěščř
23203 ěščř
23204 ěščř
23205 ěščř
23206 ěščř
23207 ĚŠČŘ
23208 ĚŠČŘ
23209 </p>
23210 !! end
23211
23212 !! test
23213 Morwen/13: Unclosed link followed by heading
23214 !! wikitext
23215 [[link
23216 ==heading==
23217 !! html
23218 <p>[[link
23219 </p>
23220 <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>
23221
23222 !! end
23223
23224 !! test
23225 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
23226 !! wikitext
23227 {{foo|
23228 =heading=
23229 !! html
23230 <p>{{foo|
23231 </p>
23232 <h1><span class="mw-headline" id="heading">heading</span></h1>
23233
23234 !! end
23235
23236 !! test
23237 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
23238 !! wikitext
23239 {{foo|
23240 ==heading==
23241 !! html
23242 <p>{{foo|
23243 </p>
23244 <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>
23245
23246 !! end
23247
23248 !! test
23249 Tildes in comments
23250 !! options
23251 pst
23252 !! wikitext
23253 <!-- ~~~~ -->
23254 !! html/php
23255 <!-- ~~~~ -->
23256 !! end
23257
23258 !! test
23259 Paragraphs inside divs (no extra line breaks)
23260 !! wikitext
23261 <div>Line one
23262
23263 Line two</div>
23264 !! html
23265 <div>Line one
23266 Line two</div>
23267
23268 !! end
23269
23270 !! test
23271 Paragraphs inside divs (extra line break on open)
23272 !! wikitext
23273 <div>
23274 Line one
23275
23276 Line two</div>
23277 !! html
23278 <div>
23279 <p>Line one
23280 </p>
23281 Line two</div>
23282
23283 !! end
23284
23285 !! test
23286 Paragraphs inside divs (extra line break on close)
23287 !! wikitext
23288 <div>Line one
23289
23290 Line two
23291 </div>
23292 !! html
23293 <div>Line one
23294 <p>Line two
23295 </p>
23296 </div>
23297
23298 !! end
23299
23300 !! test
23301 Paragraphs inside divs (extra line break on open and close)
23302 !! wikitext
23303 <div>
23304 Line one
23305
23306 Line two
23307 </div>
23308 !! html
23309 <div>
23310 <p>Line one
23311 </p><p>Line two
23312 </p>
23313 </div>
23314
23315 !! end
23316
23317 !! test
23318 Nesting tags, paragraphs on lines which begin with <div>
23319 !! wikitext
23320 <div></div><strong>A
23321 B</strong>
23322 !! html/php+tidy
23323 <p><strong>A</strong></p>
23324 <p><strong>B</strong></p>
23325 !! html/parsoid
23326 <div></div>
23327 <p><strong>A
23328 B</strong>
23329 </p>
23330 !! end
23331
23332 # T8200: <blockquote> should behave like <div> with respect to line breaks
23333 !! test
23334 T8200: paragraphs inside blockquotes (no extra line breaks)
23335 !! wikitext
23336 <blockquote>Line one
23337
23338 Line two</blockquote>
23339 !! html
23340 <blockquote>Line one
23341 Line two</blockquote>
23342
23343 !! html+tidy
23344 <blockquote>
23345 <p>Line one Line two</p>
23346 </blockquote>
23347 !! end
23348
23349 !! test
23350 T8200: paragraphs inside blockquotes (extra line break on open)
23351 !! wikitext
23352 <blockquote>
23353 Line one
23354
23355 Line two</blockquote>
23356 !! html
23357 <blockquote>
23358 <p>Line one
23359 </p>
23360 Line two</blockquote>
23361
23362 !! html+tidy
23363 <blockquote>
23364 <p>Line one</p>
23365 Line two</blockquote>
23366 !! end
23367
23368 !! test
23369 T8200: paragraphs inside blockquotes (extra line break on close)
23370 !! wikitext
23371 <blockquote>Line one
23372
23373 Line two
23374 </blockquote>
23375 !! html
23376 <blockquote>Line one
23377 <p>Line two
23378 </p>
23379 </blockquote>
23380
23381 !! html+tidy
23382 <blockquote>
23383 <p>Line one</p>
23384 <p>Line two</p>
23385 </blockquote>
23386 !! end
23387
23388 !! test
23389 T8200: paragraphs inside blockquotes (extra line break on open and close)
23390 !! wikitext
23391 <blockquote>
23392 Line one
23393
23394 Line two
23395 </blockquote>
23396 !! html
23397 <blockquote>
23398 <p>Line one
23399 </p><p>Line two
23400 </p>
23401 </blockquote>
23402
23403 !! html+tidy
23404 <blockquote>
23405 <p>Line one</p>
23406 <p>Line two</p>
23407 </blockquote>
23408 !! end
23409
23410 !! test
23411 Paragraphs inside blockquotes/divs (no extra line breaks)
23412 !! wikitext
23413 <blockquote><div>Line one
23414
23415 Line two</div></blockquote>
23416 !! html
23417 <blockquote><div>Line one
23418 Line two</div></blockquote>
23419
23420 !! end
23421
23422 !! test
23423 Paragraphs inside blockquotes/divs (extra line break on open)
23424 !! wikitext
23425 <blockquote><div>
23426 Line one
23427
23428 Line two</div></blockquote>
23429 !! html
23430 <blockquote><div>
23431 <p>Line one
23432 </p>
23433 Line two</div></blockquote>
23434
23435 !! end
23436
23437 !! test
23438 Paragraphs inside blockquotes/divs (extra line break on close)
23439 !! wikitext
23440 <blockquote><div>Line one
23441
23442 Line two
23443 </div></blockquote>
23444 !! html
23445 <blockquote><div>Line one
23446 <p>Line two
23447 </p>
23448 </div></blockquote>
23449
23450 !! end
23451
23452 !! test
23453 Paragraphs inside blockquotes/divs (extra line break on open and close)
23454 !! wikitext
23455 <blockquote><div>
23456 Line one
23457
23458 Line two
23459 </div></blockquote>
23460 !! html
23461 <blockquote><div>
23462 <p>Line one
23463 </p><p>Line two
23464 </p>
23465 </div></blockquote>
23466
23467 !! end
23468
23469 !! test
23470 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
23471 !! options
23472 wgLinkHolderBatchSize=0
23473 !! wikitext
23474 [[meatball:1]]
23475 [[meatball:2]]
23476 [[meatball:3]]
23477 !! html
23478 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
23479 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
23480 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
23481 </p>
23482 !! end
23483
23484 !! test
23485 Free external link invading image caption
23486 !! wikitext
23487 [[Image:Foobar.jpg|thumb|http://x|hello]]
23488 !! html
23489 <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>
23490
23491 !! end
23492
23493 !! test
23494 T17196: localised external link numbers
23495 !! options
23496 language=fa
23497 !! wikitext
23498 [http://en.wikipedia.org/]
23499 !! html/php
23500 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
23501 </p>
23502 !! html/parsoid
23503 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/"></a></p>
23504 !! end
23505
23506 !! test
23507 Multibyte character in padleft
23508 !! wikitext
23509 {{padleft:-Hello|7|Æ}}
23510 !! html
23511 <p>Æ-Hello
23512 </p>
23513 !! end
23514
23515 !! test
23516 Multibyte character in padright
23517 !! wikitext
23518 {{padright:Hello-|7|Æ}}
23519 !! html
23520 <p>Hello-Æ
23521 </p>
23522 !! end
23523
23524 !!test
23525 formatdate parser function
23526 !! wikitext
23527 {{#formatdate:2009-03-24}}
23528 !! html
23529 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
23530 </p>
23531 !! end
23532
23533 !!test
23534 formatdate parser function, with default format
23535 !! wikitext
23536 {{#formatdate:2009-03-24|mdy}}
23537 !! html
23538 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
23539 </p>
23540 !! end
23541
23542 !! test
23543 Spacing of numbers in formatted dates
23544 !! wikitext
23545 {{#formatdate:January 15}}
23546 !! html
23547 <p><span class="mw-formatted-date" title="01-15">January 15</span>
23548 </p>
23549 !! end
23550
23551 !! test
23552 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
23553 !! options
23554 language=nl title=[[MediaWiki:Common.css]]
23555 !! wikitext
23556 {{#formatdate:2009-03-24|dmy}}
23557 !! html
23558 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
23559 </p>
23560 !! end
23561
23562 #
23563 #
23564 #
23565
23566 #
23567 # Edit comments
23568 #
23569
23570 !! test
23571 Edit comment with link
23572 !! options
23573 comment
23574 !! wikitext
23575 I like the [[Main Page]] a lot
23576 !! html/php
23577 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
23578 !!end
23579
23580 !! test
23581 Edit comment with link and link text
23582 !! options
23583 comment
23584 !! wikitext
23585 I like the [[Main Page|best pages]] a lot
23586 !! html/php
23587 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23588 !!end
23589
23590 !! test
23591 Edit comment with link and link text with suffix
23592 !! options
23593 comment
23594 !! wikitext
23595 I like the [[Main Page|best page]]s a lot
23596 !! html/php
23597 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23598 !!end
23599
23600 !! test
23601 Edit comment with section link (non-local, eg in history list)
23602 !! options
23603 comment title=[[Main Page]]
23604 !! wikitext
23605 /* External links */ removed bogus entries
23606 !! html/php
23607 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23608 !!end
23609
23610 !! test
23611 Edit comment with section link and text before it (non-local, eg in history list)
23612 !! options
23613 comment title=[[Main Page]]
23614 !! wikitext
23615 pre-comment text /* External links */ removed bogus entries
23616 !! html/php
23617 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>
23618 !!end
23619
23620 !! test
23621 Edit comment with section link (local, eg in diff view)
23622 !! options
23623 comment local title=[[Main Page]]
23624 !! wikitext
23625 /* External links */ removed bogus entries
23626 !! html/php
23627 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23628 !!end
23629
23630 !! test
23631 Edit comment with subpage link (T16080)
23632 !! options
23633 comment
23634 subpage
23635 title=[[Subpage test]]
23636 !! wikitext
23637 Poked at a [[/subpage]] here...
23638 !! html/php
23639 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
23640 !!end
23641
23642 !! test
23643 Edit comment with subpage link and link text (T16080)
23644 !! options
23645 comment
23646 subpage
23647 title=[[Subpage test]]
23648 !! wikitext
23649 Poked at a [[/subpage|neat little page]] here...
23650 !! html/php
23651 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
23652 !!end
23653
23654 !! test
23655 Edit comment with bogus subpage link in non-subpage NS (T16080)
23656 !! options
23657 comment
23658 title=[[Subpage test]]
23659 !! wikitext
23660 Poked at a [[/subpage]] here...
23661 !! html/php
23662 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...
23663 !!end
23664
23665 !! test
23666 Edit comment with bare anchor link (local, as on diff)
23667 !! options
23668 comment
23669 local
23670 title=[[Main Page]]
23671 !! wikitext
23672 [[#section]]
23673 !! html/php
23674 <a href="#section">#section</a>
23675 !! end
23676
23677 !! test
23678 Edit comment with bare anchor link (non-local, as on history)
23679 !! options
23680 comment
23681 title=[[Main Page]]
23682 !! wikitext
23683 [[#section]]
23684 !! html/php
23685 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
23686 !! end
23687
23688 !! test
23689 Anchor starting with underscore
23690 !! options
23691 title=[[Foo]]
23692 !! wikitext
23693 [[#_ref|One]]
23694 !! html/php
23695 <p><a href="#_ref">One</a>
23696 </p>
23697 !! html/parsoid
23698 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
23699 !! end
23700
23701 !! test
23702 Id starting with underscore
23703 !! wikitext
23704 <div id="_ref"></div>
23705 !! html/*
23706 <div id="_ref"></div>
23707
23708 !! end
23709
23710 !! test
23711 Edit comment with link with more than one pipe (T99346)
23712 !! options
23713 comment
23714 !! wikitext
23715 [[Main Page|Many|pipes]]
23716 !! html/php
23717 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
23718 !! end
23719
23720 !! test
23721 Complex edit comment with link with more than one pipe (T99346)
23722 !! options
23723 comment
23724 !! wikitext
23725 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
23726 !! html/php
23727 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;
23728 !! end
23729
23730 !! test
23731 Space normalisation on autocomment (T24784)
23732 !! options
23733 comment
23734 title=[[Main Page]]
23735 !! wikitext
23736 /* __hello__world__ */
23737 !! html/php
23738 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
23739 !! end
23740
23741 !! test
23742 percent-encoding and + signs in comments (T28410)
23743 !! options
23744 comment
23745 !! wikitext
23746 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
23747 !! html/php
23748 <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>
23749 !! end
23750
23751 # Parsoid doesn't support this yet: see T75581
23752 # but it *should* omit the 'src' attribute if the image is bad.
23753 # PHP side of tests was disabled in
23754 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
23755 # because of issues in the PHP parserTests infrastructure
23756 # (but the output below is indeed what the PHP side emits)
23757 !! test
23758 Bad images - basic functionality
23759 !! wikitext
23760 [[File:Bad.jpg]]
23761 !! DISABLED/html/php
23762 !! html/parsoid
23763 <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>
23764 !! end
23765
23766 !! test
23767 Bad images - T18039: text after bad image disappears
23768 !! wikitext
23769 Foo bar
23770 [[File:Bad.jpg]]
23771 Bar foo
23772 !! DISABLED/html/php
23773 <p>Foo bar
23774 </p><p>Bar foo
23775 </p>
23776 !! html/parsoid
23777 <p>Foo bar
23778 <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>
23779 Bar foo</p>
23780 !! end
23781
23782 !! test
23783 Verify that displaytitle works (T24501) no displaytitle
23784 !! options
23785 showtitle
23786 !! config
23787 wgAllowDisplayTitle=true
23788 wgRestrictDisplayTitle=false
23789 !! wikitext
23790 this is not the the title
23791 !! html/php
23792 Parser test
23793 <p>this is not the the title
23794 </p>
23795 !! end
23796
23797 !! test
23798 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
23799 !! options
23800 showtitle
23801 title=[[Screen]]
23802 !! config
23803 wgAllowDisplayTitle=true
23804 wgRestrictDisplayTitle=false
23805 !! wikitext
23806 this is not the the title
23807 {{DISPLAYTITLE:whatever}}
23808 !! html/php
23809 whatever
23810 <p>this is not the the title
23811 </p>
23812 !! end
23813
23814 !! test
23815 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
23816 !! options
23817 showtitle
23818 title=[[Screen]]
23819 !! config
23820 wgAllowDisplayTitle=true
23821 wgRestrictDisplayTitle=true
23822 !! wikitext
23823 this is not the the title
23824 {{DISPLAYTITLE:whatever}}
23825 !! html/php
23826 Screen
23827 <p>this is not the the title
23828 </p>
23829 !! end
23830
23831 !! test
23832 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
23833 !! options
23834 showtitle
23835 title=[[Screen]]
23836 !! config
23837 wgAllowDisplayTitle=true
23838 wgRestrictDisplayTitle=true
23839 !! wikitext
23840 this is not the the title
23841 {{DISPLAYTITLE:screen}}
23842 !! html/php
23843 screen
23844 <p>this is not the the title
23845 </p>
23846 !! end
23847
23848 !! test
23849 Verify that displaytitle works (T24501) AllowDisplayTitle=false
23850 !! options
23851 showtitle
23852 title=[[Screen]]
23853 !! config
23854 wgAllowDisplayTitle=false
23855 !! wikitext
23856 this is not the the title
23857 {{DISPLAYTITLE:screen}}
23858 !! html/php
23859 Screen
23860 <p>this is not the the title
23861 <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>
23862 </p>
23863 !! end
23864
23865 !! test
23866 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
23867 !! options
23868 showtitle
23869 title=[[Screen]]
23870 !! config
23871 wgAllowDisplayTitle=false
23872 !! wikitext
23873 this is not the the title
23874 !! html/php
23875 Screen
23876 <p>this is not the the title
23877 </p>
23878 !! end
23879
23880 !! test
23881 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
23882 !! options
23883 showtitle
23884 title=[[Screen]]
23885 !! config
23886 wgAllowDisplayTitle=true
23887 wgRestrictDisplayTitle=true
23888 !! wikitext
23889 this is not the the title
23890 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
23891 !! html/php
23892 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
23893 <p>this is not the the title
23894 </p>
23895 !! end
23896
23897 !! test
23898 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
23899 !! options
23900 showtitle
23901 title=[[Screen]]
23902 !! config
23903 wgAllowDisplayTitle=true
23904 wgRestrictDisplayTitle=true
23905 !! wikitext
23906 this is not the the title
23907 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
23908 !! html/php
23909 <span style="color: red;">s</span>creen
23910 <p>this is not the the title
23911 </p>
23912 !! end
23913
23914 !! test
23915 Page status indicators: Empty name is invalid
23916 !! options
23917 showindicators
23918 !! wikitext
23919 <indicator name=" "></indicator>
23920 <indicator></indicator>
23921 !! html/php
23922 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23923 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23924 </p>
23925 !! end
23926
23927 !! test
23928 Page status indicators: Weird syntaxes that are okay
23929 !! options
23930 showindicators
23931 !! wikitext
23932 <indicator name="empty" />
23933 <indicator name="name"></indicator>
23934 !! html/php
23935 empty=
23936 name=
23937 <p><br />
23938 </p>
23939 !! end
23940
23941 !! test
23942 Page status indicators: Torture test
23943 !! options
23944 showindicators
23945 !! wikitext
23946 <indicator name="01">hello world</indicator>
23947 <indicator name="02">[[Main Page]]</indicator>
23948 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
23949 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
23950 <indicator name="05">* foo
23951 * bar</indicator>
23952 <indicator name="06"><nowiki>foo</nowiki></indicator>
23953 <indicator name="07"> Preformatted</indicator>
23954 <indicator name="08"><div>Broken tag</indicator>
23955 <indicator name="09">{| class=wikitable
23956 | cell
23957 |}</indicator>
23958 <indicator name="10">Two
23959
23960 paragraphs</indicator>
23961 !! html/php
23962 01=hello world
23963 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
23964 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" />
23965 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>
23966 05=<ul><li> foo</li>
23967 <li> bar</li></ul>
23968
23969 06=foo
23970 07=<pre>Preformatted
23971 </pre>
23972 08=<div>Broken tag</div>
23973
23974 09=<table class="wikitable">
23975 <tr>
23976 <td> cell
23977 </td></tr></table>
23978
23979 10=<p>Two
23980 </p><p>paragraphs
23981 </p>
23982 <p><br />
23983 </p><p><br />
23984 </p><p><br />
23985 </p><p><br />
23986 </p><p><br />
23987 </p>
23988 !! end
23989
23990 !! test
23991 preload: check <noinclude> and <includeonly>
23992 !! options
23993 preload
23994 !! wikitext
23995 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
23996 !! html/php
23997 Hello kind world.
23998 !! end
23999
24000 !! test
24001 preload: check <onlyinclude>
24002 !! options
24003 preload
24004 !! wikitext
24005 Goodbye <onlyinclude>Hello world</onlyinclude>
24006 !! html/php
24007 Hello world
24008 !! end
24009
24010 !! test
24011 preload: can pass tags through if we want to
24012 !! options
24013 preload
24014 !! wikitext
24015 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
24016 !! html/php
24017 <includeonly>Hello world</includeonly>
24018 !! end
24019
24020 !! test
24021 preload: check that it doesn't try to do tricks
24022 !! options
24023 preload
24024 !! wikitext
24025 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24026 !! html/php
24027 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
24028 !! end
24029
24030 !! test
24031 Play a bit with r67090 and T5158
24032 !! wikitext
24033 <div style="width:50% !important">&nbsp;</div>
24034 <div style="width:50%&nbsp;!important">&nbsp;</div>
24035 <div style="width:50%&#160;!important">&nbsp;</div>
24036 <div style="border : solid;">&nbsp;</div>
24037 !! html/php
24038 <div style="width:50% !important">&#160;</div>
24039 <div style="width:50% !important">&#160;</div>
24040 <div style="width:50% !important">&#160;</div>
24041 <div style="border&#160;: solid;">&#160;</div>
24042
24043 !! html/parsoid
24044 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24045 <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>
24046 <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>
24047 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
24048
24049 !! end
24050
24051 !! test
24052 HTML5 data attributes
24053 !! wikitext
24054 <span data-foo="bar">Baz</span>
24055 <p data-abc-def_hij="">Quuz</p>
24056 !! html/php
24057 <p><span data-foo="bar">Baz</span>
24058 </p>
24059 <p data-abc-def_hij="">Quuz</p>
24060
24061 !! html/parsoid
24062 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
24063 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
24064 !! end
24065
24066 !! test
24067 Strip reserved data attributes
24068 !! wikitext
24069 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
24070 !! html/php
24071 <div data-ok="fred">d</div>
24072
24073 !! html/parsoid
24074 <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>
24075 !! end
24076
24077 !! test
24078 percent-encoding and + signs in internal links (T28410)
24079 !! wikitext
24080 [[User:+%]] [[Page+title%]]
24081 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
24082 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
24083 [[%33%45]] [[%33%45+]]
24084 !! html/php
24085 <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>
24086 <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>
24087 <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>
24088 <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>
24089 </p>
24090 !! html/parsoid
24091 <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>
24092 <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>
24093 <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>
24094 <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>
24095 !! end
24096
24097 !! test
24098 Special characters in embedded file links (T29679)
24099 !! wikitext
24100 [[File:Contains & ampersand.jpg]]
24101 [[File:Does not exist.jpg|Title with & ampersand]]
24102 !! html/php
24103 <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>
24104 <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>
24105 </p>
24106 !! html/parsoid
24107 <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>
24108 <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>
24109 !! end
24110
24111 !! test
24112 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
24113 !! wikitext
24114 Text&apos;s been normalized?
24115 !! html
24116 <p>Text&#39;s been normalized?
24117 </p>
24118 !! end
24119
24120 !! test
24121 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
24122 !! wikitext
24123 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
24124 !! html
24125 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
24126 </p>
24127 !! end
24128
24129 !! test
24130 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
24131 !! wikitext
24132 [http://www.example.org/ ideograms]
24133 !! html
24134 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
24135 </p>
24136 !! end
24137
24138 !! test
24139 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
24140 !! wikitext
24141 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
24142 !! html
24143 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
24144 </p>
24145 !! end
24146
24147 !! article
24148 Mediawiki:loop1
24149 !! text
24150 {{Identical|A}}
24151 !! endarticle
24152
24153 !! article
24154 Mediawiki:loop2
24155 !! text
24156 {{Identical|B}}
24157 !! endarticle
24158
24159 !! article
24160 Template:Identical
24161 !! text
24162 {{int:loop1}}
24163 {{int:loop2}}
24164 !! endarticle
24165
24166 !! test
24167 T33098 Template which includes system messages which includes the template
24168 !! wikitext
24169 {{Identical}}
24170 !! html
24171 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24172 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
24173 </p>
24174 !! end
24175
24176 !! test
24177 T33490 Turkish: ucfirst 'blah'
24178 !! options
24179 language=tr
24180 !! wikitext
24181 {{ucfirst:blah}}
24182 !! html
24183 <p>Blah
24184 </p>
24185 !! end
24186
24187 !! test
24188 T33490 Turkish: ucfirst 'ix'
24189 !! options
24190 language=tr
24191 !! wikitext
24192 {{ucfirst:ix}}
24193 !! html
24194 <p>İx
24195 </p>
24196 !! end
24197
24198 !! test
24199 T33490 Turkish: lcfirst 'BLAH'
24200 !! options
24201 language=tr
24202 !! wikitext
24203 {{lcfirst:BLAH}}
24204 !! html
24205 <p>bLAH
24206 </p>
24207 !! end
24208
24209 !! test
24210 T33490 Turkish: ucfırst (with a dotless i)
24211 !! options
24212 language=tr
24213 !! wikitext
24214 {{ucfırst:blah}}
24215 !! html
24216 <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>
24217 </p>
24218 !! end
24219
24220 !! test
24221 T33490 ucfırst (with a dotless i) with English language
24222 !! options
24223 language=en
24224 !! wikitext
24225 {{ucfırst:blah}}
24226 !! html
24227 <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>
24228 </p>
24229 !! end
24230
24231 # Note that Parsoid doesn't emit an explicit TOC.
24232 # Note also that the html2wt direction tends to emit an extra newline
24233 # between the __TOC__ magicword and the first heading unless *both*
24234 # the <meta> and the <h2> have a data-parsoid attribute set (even if
24235 # it's "{}").
24236
24237 !! test
24238 T28375: TOC with italics
24239 !! options
24240 title=[[Main Page]]
24241 !! wikitext
24242 __TOC__
24243 == ''Lost'' episodes ==
24244 !! html/php
24245 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24246 <ul>
24247 <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>
24248 </ul>
24249 </div>
24250
24251 <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>
24252
24253 !! html/parsoid
24254 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24255 <h2 id="Lost_episodes" data-parsoid='{}'> <i>Lost</i> episodes </h2>
24256 !! end
24257
24258 !! test
24259 T28375: TOC with bold
24260 !! options
24261 title=[[Main Page]]
24262 !! wikitext
24263 __TOC__
24264 == '''should be bold''' then normal text ==
24265 !! html/php
24266 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24267 <ul>
24268 <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>
24269 </ul>
24270 </div>
24271
24272 <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>
24273
24274 !! html/parsoid
24275 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24276 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'> <b>should be bold</b> then normal text </h2>
24277 !! end
24278
24279 !! test
24280 T35845: Headings become cursive in TOC when they contain an image
24281 !! options
24282 title=[[Main Page]]
24283 !! wikitext
24284 __TOC__
24285 == Image [[Image:foobar.jpg]] ==
24286 !! html/php
24287 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24288 <ul>
24289 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
24290 </ul>
24291 </div>
24292
24293 <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>
24294
24295 !! html/parsoid
24296 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24297 <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>
24298 !! end
24299
24300 !! test
24301 T35845 (2): Headings become bold in TOC when they contain a blockquote
24302 !! options
24303 title=[[Main Page]]
24304 !! wikitext
24305 __TOC__
24306 == <blockquote>Quote</blockquote> ==
24307 !! html/php
24308 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24309 <ul>
24310 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24311 </ul>
24312 </div>
24313
24314 <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>
24315
24316 !! html/php+tidy
24317 <p></p>
24318 <div id="toc" class="toc">
24319 <div class="toctitle" lang="en" dir="ltr" xml:lang="en">
24320 <h2>Contents</h2>
24321 </div>
24322 <ul>
24323 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24324 </ul>
24325 </div>
24326 <p></p>
24327 <h2><span class="mw-headline" id="Quote"></span></h2>
24328 <blockquote>
24329 <p><span class="mw-headline" id="Quote">Quote</span></p>
24330 </blockquote>
24331 <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>
24332 !! html/parsoid
24333 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24334 <h2 id="Quote" data-parsoid='{}'> <blockquote>Quote</blockquote> </h2>
24335 !! end
24336
24337 !! test
24338 Unclosed tags in TOC
24339 !! config
24340 wgFragmentMode=[ 'html5', 'legacy' ]
24341 !! options
24342 title=[[Main Page]]
24343 !! wikitext
24344 __TOC__
24345 == Proof: 2 < 3 ==
24346 <small>Hanc marginis exiguitas non caperet.</small>
24347 QED
24348 !! html/php
24349 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24350 <ul>
24351 <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>
24352 </ul>
24353 </div>
24354
24355 <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>
24356 <p><small>Hanc marginis exiguitas non caperet.</small>
24357 QED
24358 </p>
24359 !! html/parsoid
24360 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24361 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span> Proof: 2 &lt; 3 </h2>
24362 <p><small>Hanc marginis exiguitas non caperet.</small>
24363 QED</p>
24364 !! end
24365
24366 !! test
24367 Multiple tags in TOC
24368 !! wikitext
24369 __TOC__
24370 == <i>Foo</i> <b>Bar</b> ==
24371
24372 == <i>Foo</i> <blockquote>Bar</blockquote> ==
24373 !! html/php
24374 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24375 <ul>
24376 <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>
24377 <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>
24378 </ul>
24379 </div>
24380
24381 <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>
24382 <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>
24383
24384 !! html/php+tidy
24385 <p></p>
24386 <div id="toc" class="toc">
24387 <div class="toctitle" lang="en" dir="ltr" xml:lang="en">
24388 <h2>Contents</h2>
24389 </div>
24390 <ul>
24391 <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>
24392 <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>
24393 </ul>
24394 </div>
24395 <p></p>
24396 <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>
24397 <h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i></span></h2>
24398 <blockquote>
24399 <p><span class="mw-headline" id="Foo_Bar_2">Bar</span></p>
24400 </blockquote>
24401 <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>
24402 !! html/parsoid
24403 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24404 <h2 id="Foo_Bar" data-parsoid='{}'> <i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b> </h2>
24405
24406 <h2 id="Foo_Bar_2" data-parsoid='{}'> <i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote> </h2>
24407 !! end
24408
24409 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
24410 # html5 tag parsing.
24411 !! test
24412 Tags with parameters in TOC
24413 !! options
24414 parsoid=wt2html
24415 !! wikitext
24416 __TOC__
24417 == <sup class="in-h2">Hello</sup> ==
24418
24419 == <sup class="a > b">Evilbye</sup> ==
24420 !! html/php
24421 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24422 <ul>
24423 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
24424 <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>
24425 </ul>
24426 </div>
24427
24428 <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>
24429 <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>
24430
24431 !! html/parsoid
24432 <meta property="mw:PageProp/toc" />
24433 <h2 id="Hello"> <sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup> </h2>
24434
24435 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span> <sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup> </h2>
24436 !! end
24437
24438 !! test
24439 span tags with directionality in TOC
24440 !! wikitext
24441 __TOC__
24442 == <span dir="ltr">C++</span> ==
24443
24444 == <span dir="rtl">זבנג!</span> ==
24445
24446 == <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> ==
24447
24448 == <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> ==
24449
24450 == <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> ==
24451 !! html/php
24452 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24453 <ul>
24454 <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>
24455 <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>
24456 <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>
24457 <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>
24458 <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>
24459 </ul>
24460 </div>
24461
24462 <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>
24463 <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>
24464 <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>
24465 <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>
24466 <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>
24467
24468 !! html/parsoid
24469 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24470 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span> <span dir="ltr">C++</span> </h2>
24471 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span> <span dir="rtl">זבנג!</span> </h2>
24472 <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>
24473 <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>
24474 <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>
24475 !! end
24476
24477 !! test
24478 T74884: bdi element in ToC
24479 !! wikitext
24480 __TOC__
24481 == <bdi>test</bdi> ==
24482 !! html/php
24483 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24484 <ul>
24485 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
24486 </ul>
24487 </div>
24488
24489 <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>
24490
24491 !! html/parsoid
24492 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24493 <h2 id="test" data-parsoid='{}'> <bdi>test</bdi> </h2>
24494 !! end
24495
24496 !! test
24497 T35715: s/strike element in ToC
24498 !! wikitext
24499 __TOC__
24500 == <s>test</s> test <strike>test</strike> ==
24501 !! html/php
24502 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24503 <ul>
24504 <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>
24505 </ul>
24506 </div>
24507
24508 <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>
24509
24510 !! html/parsoid
24511 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24512 <h2 id="test_test_test" data-parsoid='{}'> <s>test</s> test <strike>test</strike> </h2>
24513 !! end
24514
24515 # Note that the html output does not have the <p></p>, but the
24516 # html+tidy output *does*. This is because the empty <p></p> is
24517 # removed by the sanitizer, but only when tidy is *not* enabled (!).
24518 !! test
24519 Empty <p> tag in TOC, removed by Sanitizer (T92892)
24520 !! wikitext
24521 __TOC__
24522 == x ==
24523 !! html/php
24524 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
24525 <ul>
24526 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
24527 </ul>
24528 </div>
24529
24530 <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>
24531
24532 !! html/php+tidy
24533 <p></p>
24534 <div id="toc" class="toc">
24535 <div class="toctitle" lang="en" dir="ltr" xml:lang="en">
24536 <h2>Contents</h2>
24537 </div>
24538 <ul>
24539 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
24540 </ul>
24541 </div>
24542 <p></p>
24543 <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>
24544 !! html/parsoid
24545 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24546 <h2 id="x" data-parsoid='{}'> x </h2>
24547 !! end
24548
24549 !! article
24550 MediaWiki:T34057
24551 !! text
24552 == {{int:headline_sample}} ==
24553 !! endarticle
24554
24555 !! test
24556 T34057: Title needed when expanding <h> nodes.
24557 !! options
24558 title=[[Main Page]]
24559 !! wikitext
24560 {{int:T34057}}
24561 !! html
24562 <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>
24563
24564 !! end
24565
24566 !! test
24567 Strip marker in urlencode
24568 !! wikitext
24569 {{urlencode:x<nowiki/>y}}
24570 {{urlencode:x<nowiki/>y|wiki}}
24571 {{urlencode:x<nowiki/>y|path}}
24572 {{urlencode:x<pre id="one">two</pre>y}}
24573 !! html/php
24574 <p>xy
24575 xy
24576 xy
24577 xy
24578 </p>
24579 !! end
24580
24581 !! test
24582 Strip marker in lc
24583 !! wikitext
24584 {{lc:x<nowiki/>y}}
24585 !! html
24586 <p>xy
24587 </p>
24588 !! end
24589
24590 !! test
24591 Strip marker in uc
24592 !! wikitext
24593 {{uc:x<nowiki/>y}}
24594 !! html
24595 <p>XY
24596 </p>
24597 !! end
24598
24599 !! test
24600 Strip marker in formatNum
24601 !! wikitext
24602 {{formatnum:1<nowiki/>2}}
24603 {{formatnum:1<nowiki/>2|R}}
24604 !! html
24605 <p>12
24606 12
24607 </p>
24608 !! end
24609
24610 !! test
24611 Check noCommafy in formatNum
24612 !! options
24613 language=be-tarask
24614 !! wikitext
24615 {{formatnum:123456.78}}
24616 {{formatnum:123456.78|NOSEP}}
24617 !! html
24618 <p>123 456,78
24619 123456.78
24620 </p>
24621 !! end
24622
24623 !! test
24624 Wrong option for formatNum (T58199)
24625 !! wikitext
24626 {{formatnum:1,234.56|Random}}
24627 {{formatnum:1,234.56|EVERYTHING}}
24628 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
24629 !! html
24630 <p>1,234.56
24631 1,234.56
24632 1,234.56
24633 </p>
24634 !! end
24635
24636 !! test
24637 Strip marker in grammar
24638 !! options
24639 language=fi
24640 !! wikitext
24641 {{grammar:elative|foo<nowiki/>bar}}
24642 !! html
24643 <p>foobarista
24644 </p>
24645 !! end
24646
24647 !! test
24648 Strip marker in padleft
24649 !! wikitext
24650 {{padleft:|2|x<nowiki/>y}}
24651 !! html
24652 <p>xy
24653 </p>
24654 !! end
24655
24656 !! test
24657 Strip marker in padright
24658 !! wikitext
24659 {{padright:|2|x<nowiki/>y}}
24660 !! html
24661 <p>xy
24662 </p>
24663 !! end
24664
24665 !! test
24666 Strip marker in anchorencode
24667 !! wikitext
24668 {{anchorencode:x<nowiki/>y}}
24669 !! html/php
24670 <p>xy
24671 </p>
24672 !! html/parsoid
24673 <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>
24674 !! end
24675
24676 !! test
24677 nowiki inside link inside heading (T20295)
24678 !! wikitext
24679 ==[[foo|x<nowiki>y</nowiki>z]]==
24680 !! html
24681 <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>
24682
24683 !! end
24684
24685 !! test
24686 new support for bdi element (T33817)
24687 !! wikitext
24688 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24689 !! html
24690 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24691
24692 !!end
24693
24694 !! test
24695 Ignore pipe between table row attributes
24696 !! wikitext
24697 {|
24698 | quux
24699 |- id=foo | style='color: red'
24700 | bar
24701 |}
24702 !! html
24703 <table>
24704 <tr>
24705 <td> quux
24706 </td></tr>
24707 <tr id="foo" style="color: red">
24708 <td> bar
24709 </td></tr></table>
24710
24711 !! end
24712
24713 !!test
24714 Language parser function
24715 !! wikitext
24716 {{#language:ar}}
24717 !! html
24718 <p>العربية
24719 </p>
24720 !! end
24721
24722 !!test
24723 Padleft and padright as substr
24724 !! wikitext
24725 {{padleft:|3|abcde}}
24726 {{padright:|3|abcde}}
24727 !! html
24728 <p>abc
24729 abc
24730 </p>
24731 !! end
24732
24733 !!test
24734 Special parser function
24735 !! wikitext
24736 {{#special:RandomPage}}
24737 {{#special:BaDtItLe}}
24738 {{#special:Foobar}}
24739 !! html
24740 <p>Special:Random
24741 Special:Badtitle
24742 Special:Foobar
24743 </p>
24744 !! end
24745
24746 !!test
24747 T36939 - Case insensitive link parsing ([HttP://])
24748 !! wikitext
24749 [HttP://MediaWiki.Org/]
24750 !! html/php
24751 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
24752 </p>
24753 !! html/parsoid
24754 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/"></a></p>
24755 !! end
24756
24757 !!test
24758 T36939 - Case insensitive link parsing ([HttP:// title])
24759 !! wikitext
24760 [HttP://MediaWiki.Org/ MediaWiki]
24761 !! html
24762 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
24763 </p>
24764 !! end
24765
24766 !!test
24767 T36939 - Case insensitive link parsing (HttP://)
24768 !! wikitext
24769 HttP://MediaWiki.Org/
24770 !! html/php
24771 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
24772 </p>
24773 !! html/parsoid
24774 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
24775 !! end
24776
24777 !!test
24778 Disable TOC
24779 !! options
24780 notoc
24781 !! wikitext
24782 Lead
24783 == Section 1 ==
24784 == Section 2 ==
24785 == Section 3 ==
24786 == Section 4 ==
24787 == Section 5 ==
24788 !! html
24789 <p>Lead
24790 </p>
24791
24792 <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>
24793 <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>
24794 <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>
24795 <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>
24796 <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>
24797
24798 !! end
24799
24800
24801 ###
24802 ### Parsoid-specific tests
24803 ### Parsoid-PHP parser incompatibilities
24804 ###
24805 !!test
24806 1. SOL-sensitive wikitext tokens as template-args
24807 !!options
24808 parsoid=wt2html,wt2wt
24809 !! wikitext
24810 {{echo|*a}}
24811 {{echo|#a}}
24812 {{echo|:a}}
24813 !! html
24814 <span about="#mwt1" typeof="mw:Transclusion">
24815 </span><ul about="#mwt1"><li>a</li>
24816 </ul>
24817 <span about="#mwt2" typeof="mw:Transclusion">
24818 </span><ol about="#mwt2"><li>a</li>
24819 </ol>
24820 <span about="#mwt3" typeof="mw:Transclusion">
24821 </span><dl about="#mwt3"><dd>a</dd>
24822 </dl>
24823 !!end
24824
24825 #### -----------------------------------------------------------------
24826 #### Parsoid-specific functionality tests
24827 #### -----------------------------------------------------------------
24828
24829 # T65642/T68749: Formatting elt fixup around images is cleaned up.
24830 # We know wt2wt will fail, but we expect selser to pass.
24831 # Due to the nature of our testing, wt2wt and selser tests will enter the
24832 # blacklist and we'll catch selser regressions based on changes to the
24833 # blacklist entries for selser tests.
24834 !! test
24835 1. Bad treebuilder fixup of formatting elt is cleaned up
24836 !! options
24837 parsoid=wt2html,wt2wt
24838 !! wikitext
24839 {|
24840 |
24841 <small>
24842 [[Image:Foobar.jpg|right|Test]]
24843 </small>
24844 |}
24845 !! html/parsoid
24846 <table>
24847 <tbody><tr><td>
24848 <small>
24849 <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>
24850 </small>
24851 </td></tr>
24852 </tbody></table>
24853 !! end
24854
24855 !! test
24856 2. Bad treebuilder fixup of formatting elt is cleaned up
24857 !! options
24858 parsoid=wt2html,wt2wt
24859 !! wikitext
24860 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
24861
24862 <small>[[Image:Foobar.jpg|right|300px]]</small>
24863 !! html/parsoid
24864
24865 <p><b>foo</b></p>
24866 <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>
24867 <p><b>bar</b></p>
24868 <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>
24869 !! end
24870
24871 !! test
24872 3. Bad treebuilder fixup of formatting elt is cleaned up
24873 !! options
24874 parsoid=wt2html,wt2wt
24875 !! wikitext
24876 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
24877 !! html/parsoid
24878 <p><small><b>foo</b></small></p>
24879 <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>
24880 <p><small><b>bar</b></small></p>
24881 !! end
24882
24883 !! test
24884 4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
24885 !! options
24886 parsoid=wt2html,wt2wt
24887 !! wikitext
24888 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
24889 !! html/parsoid
24890 <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>
24891 !! end
24892
24893 #### ----------------------------------------------------------------
24894 #### Parsoid-only testing of Parsoid's impl of LST
24895 #### Not implemented yet, see
24896 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
24897 #### ----------------------------------------------------------------
24898
24899 ## We still need to support serializing the older format while content is stored.
24900 !! test
24901 LST Sections: Backwards compatibility
24902 !! options
24903 parsoid={
24904 "suppressErrors": true,
24905 "modes": ["html2wt"]
24906 }
24907 !! wikitext
24908 <section begin="2011-05-16" />
24909 <section end="2014-04-10 (MW 1.23wmf22)" />
24910 !! html/parsoid
24911 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
24912 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
24913 !! end
24914
24915 !! test
24916 LST Sections: Newfangled approach
24917 !! wikitext
24918 <section begin="2011-05-16" />
24919 <section end="2014-04-10 (MW 1.23wmf22)" />
24920 !! html/parsoid
24921 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'>
24922 </span>
24923 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null}'>
24924 </span></p>
24925 !! end
24926
24927 #--------- Test stripping of empty nodes in template content ----------
24928
24929 !! test
24930 Empty LI and TR nodes should be stripped from template content
24931 !! wikitext
24932 {{EmptyLITest}}
24933 {{EmptyTRTest}}
24934 !! html/parsoid
24935 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
24936 <li>a</li>
24937 <li>b</li>
24938 </ul>
24939 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
24940 <tbody>
24941 <tr>
24942 <td>foo</td>
24943 </tr>
24944 <tr>
24945 <td>bar</td>
24946 </tr>
24947 </tbody>
24948 </table>
24949 !! end
24950
24951 !! test
24952 Empty LI and TR nodes should not be stripped from top-level content
24953 !! wikitext
24954 * a
24955 *
24956 * b
24957 {|
24958 |-
24959 |-
24960 |foo
24961 |}
24962 !! html/parsoid
24963 <ul>
24964 <li> a</li>
24965 <li class='mw-empty-elt'></li>
24966 <li> b</li>
24967 </ul>
24968 <table>
24969 <tbody>
24970 <tr class='mw-empty-elt'></tr>
24971 <tr>
24972 <td>foo</td>
24973 </tr>
24974 </tbody>
24975 </table>
24976 !! end
24977
24978 !! test
24979 Empty TR nodes should not be stripped if they have any attributes set
24980 !! wikitext
24981 {{EmptyTRWithHTMLAttrTest}}
24982 !! html/parsoid
24983 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
24984 <tr align='center'></tr>
24985 <tr><td>foo</td></tr>
24986 <tr align='center'></tr>
24987 <tr><td>bar</td></tr>
24988 </table>
24989 !! end
24990
24991 #### ----------------------------------------------------------------
24992 #### The following section of tests are primarily to test
24993 #### wikitext escaping capabilities of Parsoid. Given that
24994 #### escaping can be done any number of ways, the wikitext (input)
24995 #### is always adjusted to reflect how Parsoid adds nowiki
24996 #### escape tags.
24997 ####
24998 #### We are marking several tests as parsoid-only since the
24999 #### HTML in the result section is different from what the
25000 #### PHP parser generates for it.
25001 #### ----------------------------------------------------------------
25002
25003
25004 #### --------------- Headings ---------------
25005 #### 0. Unnested
25006 #### 1. Nested inside html <h1>=foo=</h1>
25007 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
25008 #### 3. Nested inside html with wikitext split by html tags
25009 #### 4. No escape needed
25010 #### 5. Empty headings <h1></h1>
25011 #### 6. Heading chars in SOL context
25012 #### ----------------------------------------
25013 !! test
25014 Headings: 0. Unnested
25015 !! options
25016 parsoid=html2wt
25017 !! html/parsoid
25018 <p>=foo=</p>
25019
25020 <p> =foo=
25021 <!--cmt-->
25022 =foo=</p>
25023
25024 <p>=foo<i>a</i>=</p>
25025 !! wikitext
25026 <nowiki>=foo=</nowiki>
25027
25028 <nowiki> </nowiki>=foo=
25029 <!--cmt-->
25030 <nowiki>=foo=</nowiki>
25031
25032 =foo''a''<nowiki>=</nowiki>
25033 !!end
25034
25035 # New headings and existing headings are handled differently
25036 !! test
25037 Headings: 1. Nested inside html
25038 !! options
25039 parsoid=html2wt
25040 !! html/parsoid
25041 <h1>=foo=</h1>
25042 <h2>=foo=</h2>
25043 <h3>=foo=</h3>
25044
25045 <h1 data-parsoid=''>=foo=</h1>
25046 <h2 data-parsoid=''>=foo=</h2>
25047 <h3 data-parsoid=''>=foo=</h3>
25048 <h4 data-parsoid=''>=foo=</h4>
25049 <h5 data-parsoid=''>=foo=</h5>
25050 <h6 data-parsoid=''>=foo=</h6>
25051 !! wikitext
25052 = =foo= =
25053
25054 == =foo= ==
25055
25056 === =foo= ===
25057
25058 =<nowiki>=foo=</nowiki>=
25059 ==<nowiki>=foo=</nowiki>==
25060 ===<nowiki>=foo=</nowiki>===
25061 ====<nowiki>=foo=</nowiki>====
25062 =====<nowiki>=foo=</nowiki>=====
25063 ======<nowiki>=foo=</nowiki>======
25064
25065 !!end
25066
25067 !! test
25068 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
25069 !! options
25070 parsoid=html2wt
25071 !! html/parsoid
25072 <h1>foo</h1>*bar
25073 <h1>foo</h1>=bar
25074 <h1>foo</h1>=bar=
25075 !! wikitext
25076 = foo =
25077 <nowiki>*</nowiki>bar
25078
25079 = foo =
25080 =bar
25081
25082 = foo =
25083 <nowiki>=bar=</nowiki>
25084 !!end
25085
25086 !! test
25087 Headings: 3. Nested inside html with wikitext split by html tags
25088 !! options
25089 parsoid=html2wt
25090 !! html/parsoid
25091 <h1>=<b>bold</b>foo=</h1>
25092 !! wikitext
25093 = ='''bold'''foo= =
25094 !!end
25095
25096 !! test
25097 Headings: 4a. No escaping needed (testing just h1 and h2)
25098 !! options
25099 parsoid=html2wt
25100 !! html/parsoid
25101 <h1>=foo</h1>
25102 <h1>foo=</h1>
25103 <h1> =foo= </h1>
25104 <h1>=foo= bar</h1>
25105 <h2>=foo</h2>
25106 <h2>foo=</h2>
25107 <h1>=</h1>
25108 <h1><i>=</i>foo=</h1>
25109 !! wikitext
25110 = =foo =
25111
25112 = foo= =
25113
25114 = =foo= =
25115
25116 = =foo= bar =
25117
25118 == =foo ==
25119
25120 == foo= ==
25121
25122 = = =
25123
25124 = ''=''foo= =
25125 !!end
25126
25127 !! test
25128 Headings: 4b. No escaping needed (inside p-tags)
25129 !! options
25130 parsoid=html2wt
25131 !! html/parsoid
25132 <p>=foo= x
25133 =foo= <s></s>
25134 </p>
25135 !! wikitext
25136 =foo= x
25137 =foo= <s></s>
25138 !! html/php
25139 <p>=foo= x
25140 =foo= <s></s>
25141 </p>
25142 !!end
25143
25144 !! test
25145 Headings: 4c. Short headings (1)
25146 !! options
25147 parsoid=html2wt
25148 !! html/parsoid
25149 <p>===
25150 </p>
25151 !! wikitext
25152 <nowiki>===</nowiki>
25153 !! html/php
25154 <p>===
25155 </p>
25156 !! end
25157
25158 # in the html2wt direction we emit '= = =' or '=<nowiki>=</nowiki>='
25159 !! test
25160 Headings: 4d. Short headings (2)
25161 !! options
25162 parsoid=wt2html,html2html
25163 !! wikitext
25164 =
25165 ==
25166 ===
25167 ====
25168 =====
25169 !! html/php
25170 <p>=
25171 ==
25172 </p>
25173 <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>
25174 <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>
25175 <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>
25176
25177 !! html/parsoid
25178 <p>=
25179 ==</p>
25180 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
25181 <h1 id="=="><span id=".3D.3D" typeof="mw:FallbackId"></span>==</h1>
25182 <h2 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h2>
25183 !! end
25184
25185 !! test
25186 Headings: 5. Empty headings
25187 !! options
25188 parsoid=html2wt
25189 !! html/parsoid
25190 <h1 data-parsoid='{}'></h1>
25191
25192 <h2 data-parsoid='{}'></h2>
25193
25194 <h3 data-parsoid='{}'></h3>
25195
25196 <h4 data-parsoid='{}'></h4>
25197
25198 <h5 data-parsoid='{}'></h5>
25199
25200 <h6 data-parsoid='{}'></h6>
25201 !! wikitext
25202 =<nowiki/>=
25203
25204 ==<nowiki/>==
25205
25206 ===<nowiki/>===
25207
25208 ====<nowiki/>====
25209
25210 =====<nowiki/>=====
25211
25212 ======<nowiki/>======
25213 !!end
25214
25215 !! test
25216 Headings: 6a. Heading chars in SOL context (with trailing spaces)
25217 !! options
25218 parsoid=html2wt
25219 !! html/parsoid
25220 <p>=a=</p>
25221
25222 <p>=a=</p>
25223
25224 <p>=a=</p>
25225 !! wikitext
25226 <nowiki>=a=</nowiki>
25227
25228 <nowiki>=a=</nowiki>
25229
25230 <nowiki>=a=</nowiki>
25231 !!end
25232
25233 !! test
25234 Headings: 6b. Heading chars in SOL context (with trailing newlines)
25235 !! options
25236 parsoid=html2wt
25237 !! html/parsoid
25238 <p>=a=
25239 b</p>
25240
25241 <p>=a=
25242 b</p>
25243
25244 <p>=a=
25245 b</p>
25246 !! wikitext
25247 <nowiki>=a=</nowiki>
25248 b
25249
25250 <nowiki>=a=</nowiki>
25251 b
25252
25253 <nowiki>=a=</nowiki>
25254 b
25255 !!end
25256
25257 !! test
25258 Headings: 6c. Heading chars in SOL context (leading newline break)
25259 !! options
25260 parsoid=html2wt
25261 !! html/parsoid
25262 <p>a
25263 =b=</p>
25264 !! wikitext
25265 a
25266 <nowiki>=b=</nowiki>
25267 !!end
25268
25269 !! test
25270 Headings: 6d. Heading chars in SOL context (with interspersed comments)
25271 !! options
25272 parsoid=html2wt
25273 !! html/parsoid
25274 <!--c0--><p>=a=</p>
25275
25276 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
25277 !! wikitext
25278 <!--c0--><nowiki>=a=</nowiki>
25279
25280 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
25281 !!end
25282
25283 !! test
25284 Headings: 6d. Heading chars in SOL context (No escaping needed)
25285 !! options
25286 parsoid=html2wt
25287 !! html/parsoid
25288 =a=<div>b</div>
25289 !! wikitext
25290 =a=<div>b</div>
25291 !!end
25292
25293 !! test
25294 Headings: 7. Insert a newline between new content and headings
25295 !! options
25296 parsoid=html2wt
25297 !! html/parsoid
25298 <h2>NEW</h2>
25299 <p>new</p>
25300 <h2 data-parsoid='{}'>A</h2>
25301 <p data-parsoid='{}'>a</p>
25302 !! wikitext
25303 == NEW ==
25304 new
25305
25306 ==A==
25307 a
25308
25309 !! end
25310
25311 #### --------------- Lists ---------------
25312 #### 0. Outside nests (*foo, etc.)
25313 #### 1. Nested inside html <ul><li>*foo</li></ul>
25314 #### 2. Inside definition lists
25315 #### 3. Only bullets at start should be escaped
25316 #### 4. No escapes needed
25317 #### 5. No unnecessary escapes
25318 #### 6. Escape bullets in SOL position
25319 #### 7. Escape bullets in a multi-line context
25320 #### ----------------------------------------
25321
25322 !! test
25323 Lists: 0. Outside nests
25324 !! options
25325 parsoid=html2wt
25326 !! html/parsoid
25327 <p>*foo</p>
25328
25329 <p>#foo</p>
25330
25331 <p>;Foo:bar</p>
25332 !! wikitext
25333 <nowiki>*</nowiki>foo
25334
25335 <nowiki>#</nowiki>foo
25336
25337 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
25338 !!end
25339
25340 ## Making these next 3 tests Parsoid-only since they are html2wt tests
25341 ## to test wikitext escaping, and insignificant whitespace diffs
25342 ## cause PHP parser tests to barf
25343 !! test
25344 Lists: 1. Nested inside html (No unnecessary escapes)
25345 !! options
25346 parsoid=html2wt
25347 !! html/parsoid
25348 <ul>
25349 <li>*foo</li>
25350 <li>#foo</li>
25351 <li>:foo</li>
25352 <li>;foo</li>
25353 <li data-parsoid='{}'>*foo</li>
25354 <li data-parsoid='{}'>#foo</li>
25355 <li data-parsoid='{}'>:foo</li>
25356 <li data-parsoid='{}'>;foo</li>
25357 </ul>
25358
25359 <ol>
25360 <li>*foo</li>
25361 <li>#foo</li>
25362 <li>:foo</li>
25363 <li>;foo</li>
25364 <li data-parsoid='{}'>*foo</li>
25365 <li data-parsoid='{}'>#foo</li>
25366 <li data-parsoid='{}'>:foo</li>
25367 <li data-parsoid='{}'>;foo</li>
25368 </ol>
25369 !! wikitext
25370 * *foo
25371 * #foo
25372 * :foo
25373 * ;foo
25374 *<nowiki>*foo</nowiki>
25375 *<nowiki>#foo</nowiki>
25376 *<nowiki>:foo</nowiki>
25377 *<nowiki>;foo</nowiki>
25378
25379 # *foo
25380 # #foo
25381 # :foo
25382 # ;foo
25383 #<nowiki>*foo</nowiki>
25384 #<nowiki>#foo</nowiki>
25385 #<nowiki>:foo</nowiki>
25386 #<nowiki>;foo</nowiki>
25387 !!end
25388
25389 !! test
25390 Lists: 2. Inside definition lists
25391 !! options
25392 parsoid=html2wt
25393 !! html/parsoid
25394 <dl><dt>;foo</dt></dl>
25395 <dl><dt>:foo</dt></dl>
25396 <dl><dt>:foo</dt>
25397 <dd>bar</dd></dl>
25398 <dl><dd>:foo</dd></dl>
25399 !! wikitext
25400 ; ;foo
25401
25402 ; <nowiki>:foo</nowiki>
25403
25404 ; <nowiki>:foo</nowiki>
25405 : bar
25406
25407 : :foo
25408 !!end
25409
25410 !! test
25411 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
25412 !! options
25413 parsoid=html2wt
25414 !! html/parsoid
25415 <ul>
25416 <li>*foo*bar</li>
25417 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
25418 </ul>
25419 !! wikitext
25420 * *foo*bar
25421 *<nowiki>*foo</nowiki>''it''*bar
25422 !!end
25423
25424 !! test
25425 Lists: 4. No escapes needed
25426 !! options
25427 parsoid=html2wt
25428 !! html/parsoid
25429 <ul>
25430 <li>foo*bar
25431 </li>
25432 </ul>
25433 <ul>
25434 <li><i>foo</i>*bar
25435 </li>
25436 </ul>
25437 <ul>
25438 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
25439 </li>
25440 </ul>
25441 <ul>
25442 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
25443 </li>
25444 </ul>
25445 !! wikitext
25446 *foo*bar
25447
25448 *''foo''*bar
25449
25450 *[[Foo]]: bar
25451
25452 *[[Foo]]*bar
25453 !!end
25454
25455 !! test
25456 Lists: 5. No unnecessary escapes
25457 !! options
25458 parsoid=html2wt
25459 !! html/parsoid
25460 <ul><li> bar <span>[[foo]]</span></li></ul>
25461 <ul><li> =bar <span>[[foo]]</span></li></ul>
25462 <ul><li> [[bar <span>[[foo]]</span></li></ul>
25463 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
25464 <ul><li> =bar <span>foo]]</span>=</li></ul>
25465 <ul><li> <s></s>: a</li></ul>
25466 <ul><li> <i>* foo</i></li></ul>
25467
25468 !! wikitext
25469 * bar <span><nowiki>[[foo]]</nowiki></span>
25470
25471 * =bar <span><nowiki>[[foo]]</nowiki></span>
25472
25473 * [[bar <span><nowiki>[[foo]]</nowiki></span>
25474
25475 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
25476
25477 * =bar <span>foo]]</span>=
25478
25479 * <s></s>: a
25480
25481 * ''* foo''
25482 !!end
25483
25484 !! test
25485 Lists: 6. Escape bullets in SOL position
25486 !! options
25487 parsoid=html2wt
25488 !! html/parsoid
25489 <p><!--cmt-->*foo</p>
25490 !! wikitext
25491 <!--cmt--><nowiki>*</nowiki>foo
25492 !!end
25493
25494 !! test
25495 Lists: 7. Escape bullets in a multi-line context
25496 !! options
25497 parsoid=html2wt
25498 !! html/parsoid
25499 <p>a
25500 *b
25501 </p>
25502 !! wikitext
25503 a
25504 <nowiki>*</nowiki>b
25505 !!end
25506
25507 !! test
25508 Lists: 8. Escape colons only if not present in tags
25509 !! options
25510 parsoid=html2wt
25511 !! html/parsoid
25512 <dl><dt>a:b<i>c:d</i></dt></dl>
25513 !! wikitext
25514 ; <nowiki>a:b</nowiki>''c:d''
25515 !! end
25516
25517 #### --------------- HRs ---------------
25518 #### 1. Single line
25519 #### -----------------------------------
25520
25521 !! test
25522 HRs: 1. Single line
25523 !! options
25524 parsoid=html2wt
25525 !! html/parsoid
25526 <hr />----
25527 <hr />=foo=
25528 <hr />*foo
25529 !! wikitext
25530 ----<nowiki>----</nowiki>
25531 ----=foo=
25532 ----*foo
25533 !! end
25534
25535 #### --------------- Tables ---------------
25536 #### 1a. Simple example
25537 #### 1b. No escaping needed (!foo)
25538 #### 1c. No escaping needed (|foo)
25539 #### 1d. No escaping needed (|}foo)
25540 ####
25541 #### 2a. Nested in td (<td>foo|bar</td>)
25542 #### 2b. Nested in td (<td>foo||bar</td>)
25543 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
25544 ####
25545 #### 3a. Nested in th (<th>foo!bar</th>)
25546 #### 3b. Nested in th (<th>foo!!bar</th>)
25547 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
25548 ####
25549 #### 4a. Escape -
25550 #### 4b. Escape +
25551 #### 4c. No escaping needed
25552 #### --------------------------------------
25553
25554 !! test
25555 Tables: 1a. Simple example
25556 !! options
25557 parsoid=html2wt
25558 !! html/parsoid
25559 <p>{|
25560 |}
25561 </p>
25562 !! wikitext
25563 <nowiki>{|</nowiki>
25564 |}
25565 !! end
25566
25567 !! test
25568 Tables: 1b. No escaping needed
25569 !! options
25570 parsoid=html2wt
25571 !! html/parsoid
25572 <p>!foo
25573 </p>
25574 !! wikitext
25575 !foo
25576 !! end
25577
25578 !! test
25579 Tables: 1c. No escaping needed
25580 !! options
25581 parsoid=html2wt
25582 !! html/parsoid
25583 <p>|foo
25584 </p>
25585 !! wikitext
25586 |foo
25587 !! end
25588
25589 !! test
25590 Tables: 1d. No escaping needed
25591 !! options
25592 parsoid=html2wt
25593 !! html/parsoid
25594 <p>|}foo
25595 </p>
25596 !! wikitext
25597 |}foo
25598 !! end
25599
25600 !! test
25601 Tables: 2a. Nested in td
25602 !! options
25603 parsoid=html2wt
25604 !! html/parsoid
25605 <table><tbody><tr>
25606 <td>foo|bar</td></tr>
25607 <tr><td>x<div>a|b</div></td>
25608 </tbody></table>
25609 !! wikitext
25610 {|
25611 |<nowiki>foo|bar</nowiki>
25612 |-
25613 |x<div><nowiki>a|b</nowiki></div>
25614 |}
25615 !! html/php+tidy
25616 <table>
25617 <tr>
25618 <td>foo|bar</td>
25619 </tr>
25620 <tr>
25621 <td>x
25622 <div>a|b</div>
25623 </td>
25624 </tr>
25625 </table>
25626 !! end
25627
25628 !! test
25629 Tables: 2b. Nested in td
25630 !! options
25631 parsoid=html2wt
25632 !! html/parsoid
25633 <table><tbody><tr>
25634 <td>foo||bar</td>
25635 <td>a<i>b||c</i></td>
25636 <td>a<i><div>b||c</div></i></td>
25637 </tr></tbody></table>
25638 !! wikitext
25639 {|
25640 |<nowiki>foo||bar</nowiki>
25641 |a''<nowiki>b||c</nowiki>''
25642 |a''<div><nowiki>b||c</nowiki></div>''
25643 |}
25644 !! html/php
25645 <table>
25646 <tr>
25647 <td>foo||bar
25648 </td>
25649 <td>a<i>b||c</i>
25650 </td>
25651 <td>a<i><div>b||c</div></i>
25652 </td></tr></table>
25653
25654 !! end
25655
25656 !! test
25657 Tables: 2c. Nested in td -- no escaping needed
25658 !! options
25659 parsoid=html2wt
25660 !! html/*
25661 <table>
25662 <tr>
25663 <td>foo!!bar
25664 </td></tr></table>
25665
25666 !! wikitext
25667 {|
25668 |foo!!bar
25669 |}
25670 !! end
25671
25672 !! test
25673 Tables: 3a. Nested in th
25674 !! options
25675 parsoid=html2wt
25676 !! html/*
25677 <table>
25678 <tr>
25679 <th>foo!bar
25680 </th></tr></table>
25681
25682 !! wikitext
25683 {|
25684 !foo!bar
25685 |}
25686 !! end
25687
25688 !! test
25689 Tables: 3b. Nested in th
25690 !! options
25691 parsoid=html2wt
25692 !! html/parsoid
25693 <table><tbody>
25694 <tr><th>foo!!bar</th>
25695 <th><i>foo|bar</i></th>
25696 <th><i>foo!!bar</i></th>
25697 <th><i><span>foo!!bar</span></i></th>
25698 </tr></tbody></table>
25699 !! wikitext
25700 {|
25701 !<nowiki>foo!!bar</nowiki>
25702 !''<nowiki>foo|bar</nowiki>''
25703 !''<nowiki>foo!!bar</nowiki>''
25704 !''<span><nowiki>foo!!bar</nowiki></span>''
25705 |}
25706 !! html/php
25707 <table>
25708 <tr>
25709 <th>foo!!bar
25710 </th>
25711 <th><i>foo|bar</i>
25712 </th>
25713 <th><i>foo!!bar</i>
25714 </th>
25715 <th><i><span>foo!!bar</span></i>
25716 </th></tr></table>
25717
25718 !! end
25719
25720 !! test
25721 Tables: 3c. Nested in th
25722 !! options
25723 parsoid=html2wt
25724 !! html/parsoid
25725 <table><tbody>
25726 <tr><th>foo||bar</th>
25727 <th><span typeof="mw:Nowiki">foo||bar</span></th>
25728 </tr></tbody></table>
25729 !! wikitext
25730 {|
25731 !<nowiki>foo||bar</nowiki>
25732 !<nowiki>foo||bar</nowiki>
25733 |}
25734 !! html/php
25735 <table>
25736 <tr>
25737 <th>foo||bar
25738 </th>
25739 <th>foo||bar
25740 </th></tr></table>
25741
25742 !! end
25743
25744 !! test
25745 Tables: 4a. Escape -
25746 !! options
25747 parsoid=html2wt
25748 !! html/*
25749 <table>
25750 <tr>
25751 <th>-bar
25752 </th></tr>
25753 <tr>
25754 <td>-bar
25755 </td></tr></table>
25756
25757 !! wikitext
25758 {|
25759 !-bar
25760 |-
25761 |<nowiki>-bar</nowiki>
25762 |}
25763 !! end
25764
25765 !! test
25766 Tables: 4b. Escape +
25767 !! options
25768 parsoid=html2wt
25769 !! html/*
25770 <table>
25771 <tr>
25772 <th>+bar
25773 </th></tr>
25774 <tr>
25775 <td>+bar
25776 </td></tr></table>
25777
25778 !! wikitext
25779 {|
25780 !+bar
25781 |-
25782 |<nowiki>+bar</nowiki>
25783 |}
25784 !! end
25785
25786 !! test
25787 Tables: 4c. No escaping needed
25788 !! options
25789 parsoid=html2wt
25790 !! html/parsoid
25791 <table><tbody>
25792 <tr><td>foo-bar</td><td>foo+bar</td></tr>
25793 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
25794 <tr><td>foo
25795 <p>bar|baz
25796 +bar
25797 -bar</p></td></tr>
25798 <tr><td>x
25799 <div>a|b</div></td>
25800 </tbody></table>
25801 !! wikitext
25802 {|
25803 |foo-bar
25804 |foo+bar
25805 |-
25806 |''foo''-bar
25807 |''foo''+bar
25808 |-
25809 |foo
25810 bar|baz
25811 +bar
25812 -bar
25813 |-
25814 |x
25815 <div>a|b</div>
25816 |}
25817 !! html/php
25818 <table>
25819 <tr>
25820 <td>foo-bar
25821 </td>
25822 <td>foo+bar
25823 </td></tr>
25824 <tr>
25825 <td><i>foo</i>-bar
25826 </td>
25827 <td><i>foo</i>+bar
25828 </td></tr>
25829 <tr>
25830 <td>foo
25831 <p>bar|baz
25832 +bar
25833 -bar
25834 </p>
25835 </td></tr>
25836 <tr>
25837 <td>x
25838 <div>a|b</div>
25839 </td></tr></table>
25840
25841 !! end
25842
25843 !! test
25844 Tables: 4d. No escaping needed
25845 !! options
25846 parsoid=html2wt
25847 !! html/parsoid
25848 <table>
25849 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
25850 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
25851 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
25852 </tbody></table>
25853 !! wikitext
25854 {|
25855 |[[Foo]]-bar
25856 ||+1
25857 ||-2
25858 |}
25859 !! html/php
25860 <table>
25861 <tr>
25862 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
25863 </td>
25864 <td>+1
25865 </td>
25866 <td>-2
25867 </td></tr></table>
25868
25869 !! end
25870
25871 !! test
25872 T97430: Don't emit empty nowiki pairs around marker meta tags
25873 !! options
25874 parsoid=html2wt
25875 !! html/parsoid
25876 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25877 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
25878 !! wikitext
25879 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25880 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
25881 !! end
25882
25883 !! test
25884 Unclosed xmlish element in table line shouldn't eat end delimiters
25885 !! options
25886 parsoid=html2wt
25887 !! html/parsoid
25888 <table>
25889 <tbody><tr><td> &lt;foo</td>
25890 <td> bar></td></tr>
25891 </tbody></table>
25892 !! wikitext
25893 {|
25894 | <foo
25895 | bar>
25896 |}
25897 !! html/php
25898 <table>
25899 <tr>
25900 <td> &lt;foo
25901 </td>
25902 <td> bar&gt;
25903 </td></tr></table>
25904
25905 !! end
25906
25907 #### --------------- Links ----------------
25908 #### 1. Quote marks in link text
25909 #### 2. Wikilinks: Escapes needed
25910 #### 3. Wikilinks: No escapes needed
25911 #### 4. Extlinks: Escapes needed
25912 #### 5. Extlinks: No escapes needed
25913 #### --------------------------------------
25914 !! test
25915 Links 1. WikiLinks: No escapes needed
25916 !! options
25917 parsoid=html2wt
25918 !! html/parsoid
25919 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
25920 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
25921 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
25922 !! wikitext
25923 [[Foo|Foo''boo'']]
25924 [[Foo|[Foobar]]]
25925 [[Foo|x [Foobar] x]]
25926 !! html/php
25927 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
25928 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
25929 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
25930 </p>
25931 !! end
25932
25933 !! test
25934 Links 2. WikiLinks: Escapes needed
25935 !! options
25936 parsoid=html2wt
25937 !! html/parsoid
25938 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
25939 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
25940 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
25941 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
25942 <a href="Foo" rel="mw:WikiLink">|Bar</a>
25943 <a href="Foo" rel="mw:WikiLink">]]bar</a>
25944 <a href="Foo" rel="mw:WikiLink">[[bar</a>
25945 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
25946 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
25947 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
25948 !! wikitext
25949 [[Foo|<nowiki>Foobar]</nowiki>]]
25950 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
25951 [[Foo|<nowiki>[[Bar]]</nowiki>]]
25952 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
25953 [[Foo|<nowiki>|Bar</nowiki>]]
25954 [[Foo|<nowiki>]]bar</nowiki>]]
25955 [[Foo|<nowiki>[[bar</nowiki>]]
25956 [[Foo|<nowiki>x [[ y</nowiki>]]
25957 [[Foo|<nowiki>x ]] y</nowiki>]]
25958 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
25959 !! html/php
25960 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
25961 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
25962 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
25963 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
25964 <a href="/wiki/Foo" title="Foo">|Bar</a>
25965 <a href="/wiki/Foo" title="Foo">]]bar</a>
25966 <a href="/wiki/Foo" title="Foo">[[bar</a>
25967 <a href="/wiki/Foo" title="Foo">x [[ y</a>
25968 <a href="/wiki/Foo" title="Foo">x ]] y</a>
25969 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
25970 </p>
25971 !! end
25972
25973 !! test
25974 Links 3. WikiLinks: No escapes needed
25975 !! options
25976 parsoid=html2wt
25977 !! html/parsoid
25978 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
25979 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
25980 !! wikitext
25981 [[Foo|[Foobar]]
25982 [[Foo|foo|bar]]
25983 !! html/php
25984 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
25985 <a href="/wiki/Foo" title="Foo">foo|bar</a>
25986 </p>
25987 !! end
25988
25989 !! test
25990 Links 4. ExtLinks: Escapes needed
25991 !! options
25992 parsoid=html2wt
25993 !! html/parsoid
25994 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
25995 <a rel="mw:ExtLink" href="http://google.com">google]</a>
25996 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
25997 <p>[http://google.com]</p>
25998 <p>[http://google.com google]</p>
25999 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
26000 <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>
26001 !! wikitext
26002 [http://google.com <nowiki>[google]</nowiki>]
26003 [http://google.com <nowiki>google]</nowiki>]
26004 [http://google.com <nowiki>goog] le</nowiki>]
26005
26006 <nowiki>[http://google.com]</nowiki>
26007
26008 <nowiki>[http://google.com google]</nowiki>
26009
26010 [http://google.com<nowiki>]</nowiki>
26011
26012 [{{echo|http://google.com}}<nowiki>]</nowiki>
26013 !! html/php
26014 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
26015 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
26016 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
26017 </p><p>[http://google.com]
26018 </p><p>[http://google.com google]
26019 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
26020 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
26021 </p>
26022 !! end
26023
26024 !! test
26025 Links 5. ExtLinks: No escapes needed
26026 !! options
26027 parsoid=html2wt
26028 !! html/parsoid
26029 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
26030 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
26031 !! wikitext
26032 [http://google.com [google]
26033
26034 [[http://google.com]]
26035 !! html/php
26036 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
26037 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
26038 </p>
26039 !! end
26040
26041 !! test
26042 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
26043 !! options
26044 parsoid=html2wt
26045 !! html/parsoid
26046 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
26047 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
26048 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
26049 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
26050 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
26051 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
26052 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
26053 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
26054 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
26055 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
26056 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
26057 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
26058 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
26059 </p>
26060 !! wikitext
26061 x<nowiki/>http://example.com<nowiki/>y
26062 http://example.com<nowiki/>?x
26063 http://example.com<nowiki/>&x
26064 http://example.com<nowiki/>'x
26065 http://example.com<nowiki/>,x
26066 http://example.com<nowiki/>.x
26067 http://example.com<nowiki/>;x
26068 http://example.com<nowiki/>:x
26069 http://example.com<nowiki/>;x
26070 http://example.com<nowiki/>!x
26071 http://example.com<nowiki/>=x
26072 http://example.com<nowiki/>(x)
26073 http://example.com(x<nowiki/>)
26074 !! end
26075
26076 !! test
26077 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
26078 !! options
26079 parsoid=html2wt
26080 !! html/parsoid
26081 <p>x
26082 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
26083 y
26084 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
26085 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
26086 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
26087 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
26088 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
26089 </p>
26090 !! wikitext
26091 x
26092 http://example.com
26093 y
26094 "http://example.com"
26095 (http://example.com)
26096 (http://example.com) foo
26097 http://example.com,
26098 http://example.com, foo
26099 !! html/php
26100 <p>x
26101 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
26102 y
26103 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
26104 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
26105 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
26106 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
26107 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
26108 </p>
26109 !! end
26110
26111 !! test
26112 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
26113 !! options
26114 parsoid=html2wt
26115 !! html/parsoid
26116 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
26117 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
26118 !! wikitext
26119 http://example.com.,;:!?\
26120 -http://example.com:
26121 !! html/php
26122 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
26123 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
26124 </p>
26125 !! end
26126
26127 !! test
26128 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
26129 !! options
26130 parsoid=html2wt
26131 !! html/parsoid
26132 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
26133 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
26134 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
26135 !! wikitext
26136 RFC 123<nowiki/>4
26137 RFC 123<nowiki/>y
26138 X<nowiki/>RFC 123<nowiki/>y
26139 !! end
26140
26141 !! test
26142 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
26143 !! options
26144 parsoid=html2wt
26145 !! html/parsoid
26146 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
26147 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
26148 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
26149 </p>
26150 !! wikitext
26151 RFC 123?foo
26152 RFC 123&foo
26153 -RFC 123-
26154 !! html/php
26155 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
26156 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
26157 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
26158 </p>
26159 !! end
26160
26161 !! test
26162 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
26163 !! options
26164 parsoid=html2wt
26165 !! html/parsoid
26166 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
26167 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
26168 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
26169 !! wikitext
26170 PMID 123<nowiki/>4
26171 PMID 123<nowiki/>y
26172 X<nowiki/>PMID 123<nowiki/>y
26173 !! end
26174
26175 !! test
26176 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
26177 !! options
26178 parsoid=html2wt
26179 !! html/parsoid
26180 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
26181 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
26182 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
26183 </p>
26184 !! wikitext
26185 PMID 123?foo
26186 PMID 123&foo
26187 -PMID 123-
26188 !! html/php
26189 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
26190 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
26191 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
26192 </p>
26193 !! end
26194
26195 !! test
26196 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
26197 !! options
26198 parsoid=html2wt
26199 !! html/parsoid
26200 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
26201 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
26202 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
26203 </p>
26204 !! wikitext
26205 ISBN 1234567890<nowiki/>1
26206 ISBN 1234567890<nowiki/>x
26207 a<nowiki/>ISBN 1234567890<nowiki/>b
26208 !! end
26209
26210 !! test
26211 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
26212 !! options
26213 parsoid=html2wt
26214 !! html/parsoid
26215 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
26216 !! wikitext
26217 -ISBN 1234567890's
26218 !! html/php
26219 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
26220 </p>
26221 !! end
26222
26223 !! test
26224 Links 14. Protect link-like plain text. (Parsoid bug T78425)
26225 !! options
26226 parsoid=html2wt
26227 !! html/*
26228 <p>this is not a link: http://example.com
26229 </p>
26230 !! wikitext
26231 this is not a link: <nowiki>http://example.com</nowiki>
26232 !! end
26233
26234 !! test
26235 Links 15. Link trails can't become link prefixes.
26236 !! options
26237 language=is
26238 parsoid=html2wt
26239 !! html/parsoid
26240 <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>
26241 !! wikitext
26242 [[Söfnuður]]-[[00]]
26243 !! html/php
26244 <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>
26245 </p>
26246 !! end
26247
26248 #### --------------- Quotes ---------------
26249 #### 1. Quotes inside <b> and <i>
26250 #### 2. Link fragments separated by <i> and <b> tags
26251 #### 3. Link fragments inside <i> and <b>
26252 #### 4. No escaping needed
26253 #### --------------------------------------
26254 !! test
26255 1a. Quotes inside <b> and <i>
26256 !! options
26257 parsoid=html2wt
26258 !! html/*
26259 <p><i>'foo'</i>
26260 <i>''foo''</i>
26261 <i>'''foo'''</i>
26262 <i>foo</i>'s
26263 <b>'foo'</b>
26264 <b>''foo''</b>
26265 <b>'''foo'''</b>
26266 <b>foo'<i>bar'</i>baz</b>
26267 <b>foo</b>'s
26268 '<i>foo</i>
26269 <i>foo</i>'
26270 <i>foo'</i>'
26271 '<i>foo</i>'
26272 '<b>foo</b>
26273 <b>foo</b>'
26274 '<b>foo</b>'
26275 <i>fools'<span> errand</span></i>
26276 <i><span>fool</span>'s errand</i>
26277 '<i>foo</i> bar '<i>baz</i>
26278 a|!*#-:;+-~[]{}b'<i>x</i>
26279 </p>
26280 !! wikitext
26281 ''<nowiki/>'foo'''
26282 ''<nowiki>''foo''</nowiki>''
26283 ''<nowiki>'''foo'''</nowiki>''
26284 ''foo''<nowiki/>'s
26285 '''<nowiki/>'foo''''
26286 '''<nowiki>''foo''</nowiki>'''
26287 '''<nowiki>'''foo'''</nowiki>'''
26288 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
26289 '''foo'''<nowiki/>'s
26290 '''foo''
26291 ''foo''<nowiki/>'
26292 ''foo'''<nowiki/>'
26293 '''foo''<nowiki/>'
26294 ''''foo'''
26295 '''foo'''<nowiki/>'
26296 ''''foo'''<nowiki/>'
26297 ''fools'<span> errand</span>''
26298 ''<span>fool</span>'s errand''
26299 '<nowiki/>''foo'' bar '''baz''
26300 a|!*#-:;+-~[]{}b'''x''
26301 !! end
26302
26303 !! test
26304 1b. Quotes inside <b> and <i> with other tags on same line
26305 !! options
26306 parsoid=html2wt
26307 !! html/parsoid
26308 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26309 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
26310 <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>
26311 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
26312 '<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>
26313 '<i>foo</i> <div title="name">test</div>
26314 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
26315 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
26316 <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>
26317 </ol>
26318 !! wikitext
26319 '''a'' foo ''[[bar]]''
26320 ''a''' foo ''[[bar]]''
26321 ''a''' foo '''{{echo|[[bar]]}}'''
26322 [[foo]] x'''[[bar]]''
26323 '''foo'' <ref>test</ref>
26324 '''foo'' <div title="name">test</div>
26325 '''foo'' and <br> bar
26326 <references />
26327 !! end
26328
26329 !! test
26330 2. Link fragments separated by <i> and <b> tags
26331 !! options
26332 parsoid=html2wt
26333 !! html/parsoid
26334 <p>[[<i>foo</i>hello]]</p>
26335 <p>[[<b>foo</b>hello]]</p>
26336 !! wikitext
26337 [[''foo''<nowiki>hello]]</nowiki>
26338
26339 [['''foo'''<nowiki>hello]]</nowiki>
26340 !! end
26341
26342 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
26343 # this is one of the shortcomings of this format
26344 !! test
26345 3. Link fragments inside <i> and <b>
26346 !! options
26347 parsoid=html2wt
26348 !! html/parsoid
26349 <p><i>[[foo</i>]]</p>
26350 <p><b>[[foo</b>]]</p>
26351 !! wikitext
26352 ''[[foo''<nowiki>]]</nowiki>
26353
26354 '''[[foo'''<nowiki>]]</nowiki>
26355 !! end
26356
26357 !! test
26358 4. No escaping needed
26359 !! options
26360 parsoid=html2wt
26361 !! html/parsoid
26362 <p>'<span><i>bar</i></span>'
26363 '<span><b>bar</b></span>'
26364 'a:b'foo
26365 </p>
26366 !! wikitext
26367 '<span>''bar''</span>'
26368 '<span>'''bar'''</span>'
26369 'a:b'foo
26370 !! end
26371
26372 #### ----------- Paragraphs ---------------
26373 #### 1. No unnecessary escapes
26374 #### --------------------------------------
26375
26376 !! test
26377 1. No unnecessary escapes
26378 !! options
26379 parsoid=html2wt
26380 !! html/parsoid
26381 <p>bar <span>[[foo]]</span>
26382 </p><p>=bar <span>[[foo]]</span>
26383 </p><p>[[bar <span>[[foo]]</span>
26384 </p><p>]]bar <span>[[foo]]</span>
26385 </p><p>=bar <span>foo]]</span>=
26386 </p>
26387 !! wikitext
26388 bar <span><nowiki>[[foo]]</nowiki></span>
26389
26390 =bar <span><nowiki>[[foo]]</nowiki></span>
26391
26392 [[bar <span><nowiki>[[foo]]</nowiki></span>
26393
26394 ]]bar <span><nowiki>[[foo]]</nowiki></span>
26395
26396 =bar <span>foo]]</span><nowiki>=</nowiki>
26397 !!end
26398
26399 #### ----------------------- PRE --------------------------
26400 #### 1. Leading whitespace in SOL context should be escaped
26401 #### ------------------------------------------------------
26402 !! test
26403 1. Leading whitespace in SOL context should be escaped
26404 !! options
26405 parsoid=html2wt
26406 !! html/parsoid
26407 <p> a</p>
26408
26409 <p> a</p>
26410
26411 <p> a(tab)</p>
26412
26413 <p> a
26414 <!--cmt-->
26415 a</p>
26416
26417 <p>a
26418 b</p>
26419
26420 <p>a
26421 b</p>
26422
26423 <p>a
26424 b</p>
26425 !! wikitext
26426 <nowiki> </nowiki>a
26427
26428 <nowiki> </nowiki> a
26429
26430 a(tab)
26431
26432 <nowiki> </nowiki> a
26433 <!--cmt-->
26434 <nowiki> </nowiki>a
26435
26436 a
26437 <nowiki> </nowiki>b
26438
26439 a
26440 b
26441
26442 a
26443 b
26444 !! html/php
26445 <p> a
26446 </p><p> a
26447 </p><p> a(tab)
26448 </p><p> a
26449 a
26450 </p><p>a
26451 b
26452 </p><p>a
26453 b
26454 </p><p>a
26455 b
26456 </p>
26457 !! end
26458
26459 !! test
26460 2. Leading whitespace in non-indent-pre contexts should not be escaped
26461 !! options
26462 parsoid=html2wt
26463 !! html/parsoid
26464 <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>
26465 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
26466 <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>
26467 b</span></li>
26468 </ol>
26469 !! wikitext
26470 foo <ref>''a''
26471 b</ref>
26472 <references />
26473 !! end
26474
26475 !! test
26476 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
26477 !! options
26478 parsoid=html2wt
26479 !! html/parsoid
26480 <blockquote>
26481 <p>
26482 a
26483 <span>b</span>
26484 c</p>
26485 </blockquote>
26486 !! wikitext
26487 <blockquote>
26488 a
26489 <span>b</span>
26490 c
26491 </blockquote>
26492 !! end
26493
26494 !! test
26495 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
26496 !! options
26497 parsoid=html2wt
26498 !! html/parsoid
26499 <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>
26500 !! wikitext
26501 [[File:Foobar.jpg|thumb|caption]]
26502 !! end
26503
26504 !! test
26505 5. Nowiki escaping should account for indent-pres
26506 !! options
26507 parsoid=html2wt
26508 !! html/parsoid
26509 <pre>==foo==</pre>
26510 !! wikitext
26511 ==foo==
26512 !! end
26513
26514 !!test
26515 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
26516 !! options
26517 parsoid=html2wt
26518 !! html/parsoid
26519 <pre>
26520 * foo
26521 * bar
26522 </pre>
26523 !! wikitext
26524 * foo
26525 * bar
26526 !! end
26527
26528 #### --------------- Behavior Switches --------------------
26529
26530 !! test
26531 1. Valid behavior switches should be escaped
26532 !! options
26533 parsoid=html2wt
26534 !! html/parsoid
26535 __TOC__
26536 <i>__TOC__</i>
26537 !! wikitext
26538 <nowiki>__TOC__</nowiki>
26539 ''<nowiki>__TOC__</nowiki>''
26540 !! end
26541
26542 !! test
26543 2. Invalid behavior switches should not be escaped
26544 !! options
26545 parsoid=html2wt
26546 !! html/parsoid
26547 __TOO__
26548 __|__
26549 !! wikitext
26550 __TOO__
26551 __|__
26552 !! end
26553
26554 # We use indent-pre as an indirect way to test for sol-transparent behavior.
26555 !! test
26556 Behavior switches should be SOL-transparent
26557 !! options
26558 parsoid=html2wt
26559 !! html/parsoid
26560 <meta property="mw:PageProp/toc" />
26561
26562 <!-- this one's bogus -->
26563 <pre>__TOO__</pre>
26564
26565 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
26566
26567 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
26568 !! wikitext
26569 __TOC__
26570
26571 <!-- this one's bogus -->
26572 __TOO__
26573
26574 __TOC__ foo
26575
26576 __TOC__
26577 bar
26578 !! end
26579
26580 #### --------------- HTML tags ---------------
26581 #### 1. a tags
26582 #### 2. other tags
26583 #### 3. multi-line html tag
26584 #### 4. extension tags
26585 #### -----------------------------------------
26586 !! test
26587 1. a tags
26588 !! options
26589 parsoid=html2wt
26590 !! html/parsoid
26591 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
26592 !! wikitext
26593 <a href="http://google.com">google</a>
26594 !! end
26595
26596 !! test
26597 2. other tags
26598 !! options
26599 parsoid=html2wt
26600 !! html/parsoid
26601 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
26602 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
26603 <li> &lt;td&gt;</li></ul>
26604
26605 !! wikitext
26606 * <nowiki><div>foo</div></nowiki>
26607 * <nowiki><div style="color:red">foo</div></nowiki>
26608 * <nowiki><td></nowiki>
26609 !! end
26610
26611 !! test
26612 3. multi-line html tag
26613 !! options
26614 parsoid=html2wt
26615 !! html/parsoid
26616 <p>&lt;div
26617 &gt;foo&lt;/div
26618 &gt;
26619 </p>
26620 !! wikitext
26621 <nowiki><div
26622 >foo</div
26623 ></nowiki>
26624 !! end
26625
26626 !! test
26627 4. extension tags
26628 !! options
26629 parsoid=html2wt
26630 !! html/parsoid
26631 <p>&lt;ref&gt;foo&lt;/ref&gt;
26632 </p><p>&lt;ref&gt;bar
26633 </p><p>baz&lt;/ref&gt;
26634 </p>
26635 !! wikitext
26636 <nowiki><ref>foo</ref></nowiki>
26637
26638 <nowiki><ref>bar</nowiki>
26639
26640 baz<nowiki></ref></nowiki>
26641 !! end
26642
26643 #### --------------- Others ---------------
26644 !! test
26645 Escaping nowikis
26646 !! options
26647 parsoid=html2wt
26648 !! html/parsoid
26649 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
26650 </p>
26651 !! wikitext
26652 &lt;nowiki&gt;foo&lt;/nowiki&gt;
26653 !! end
26654
26655 ## The quote-char in the input is necessary for triggering the bug
26656 !! test
26657 (T54035) Nowiki-escaping should not get tripped by " :" in text
26658 !! options
26659 parsoid=html2wt
26660 !! html/parsoid
26661 <p>foo's bar :</p>
26662 !! wikitext
26663 foo's bar :
26664 !! end
26665
26666 #----------- End of wikitext escaping tests --------------
26667
26668 !! test
26669
26670 Tag-like HTML structures are passed through as text
26671 !! wikitext
26672 <x y>
26673
26674 <x.y>
26675
26676 <x-y>
26677
26678 1>2
26679
26680 x<y
26681
26682 a>b
26683
26684 1<d e>f
26685 !! html
26686 <p>&lt;x y&gt;
26687 </p><p>&lt;x.y&gt;
26688 </p><p>&lt;x-y&gt;
26689 </p><p>1&gt;2
26690 </p><p>x&lt;y
26691 </p><p>a&gt;b
26692 </p><p>1&lt;d e&gt;f
26693 </p>
26694 !! end
26695
26696 !! test
26697 HTML tag with necessary entities in attributes
26698 !! wikitext
26699 <span title="&amp;amp;">foo</span>
26700 !! html
26701 <p><span title="&amp;amp;">foo</span>
26702 </p>
26703 !! end
26704
26705 !! test
26706 HTML tag with 'unnecessary' entity encoding in attributes
26707 !! wikitext
26708 <span title="&amp;">foo</span>
26709 !! html
26710 <p><span title="&amp;">foo</span>
26711 </p>
26712 !! end
26713
26714 !! test
26715 HTML tag with broken attribute value quoting
26716 !! options
26717 parsoid=wt2html,html2html
26718 !! wikitext
26719 <span title="Hello world>Foo</span>
26720 !! html/php
26721 <p><span title="Hello world">Foo</span>
26722 </p>
26723 !! html/parsoid
26724 <p><span title="Hello world">Foo</span></p>
26725 !! end
26726
26727 !! test
26728 Self-closed tag with broken attribute value quoting
26729 !! options
26730 parsoid=wt2html,html2html
26731 !! wikitext
26732 <div title="Hello world />Foo
26733 !! html/php+tidy
26734 <div title="Hello world"></div>
26735 <p>Foo</p>
26736 !! html/parsoid
26737 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
26738 !! end
26739
26740 !! test
26741 Table with broken attribute value quoting
26742 !! options
26743 parsoid=wt2html,html2html
26744 !! wikitext
26745 {|
26746 | title="Hello world|Foo
26747 |}
26748 !! html/php
26749 <table>
26750 <tr>
26751 <td title="Hello world">Foo
26752 </td></tr></table>
26753
26754 !! html/parsoid
26755 <table>
26756 <tr>
26757 <td title="Hello world">Foo
26758 </td></tr></table>
26759
26760 !! end
26761
26762 !! test
26763 Table with broken attribute value quoting on consecutive lines
26764 !! options
26765 parsoid=wt2html,html2html
26766 !! wikitext
26767 {|
26768 | title="Hello world|Foo
26769 | style="color:red|Bar
26770 |}
26771 !! html/php
26772 <table>
26773 <tr>
26774 <td title="Hello world">Foo
26775 </td>
26776 <td style="color:red">Bar
26777 </td></tr></table>
26778
26779 !! html/parsoid
26780 <table><tbody>
26781 <tr>
26782 <td title="Hello world">Foo
26783 </td><td style="color: red">Bar
26784 </td></tr></tbody></table>
26785
26786 !! end
26787
26788 !!test
26789 Accept empty td cell attribute
26790 !! wikitext
26791 {|
26792 | align="center" | foo || |
26793 |}
26794 !! html
26795 <table>
26796 <tr>
26797 <td align="center"> foo </td>
26798 <td>
26799 </td></tr></table>
26800
26801 !!end
26802
26803 !!test
26804 Non-empty attributes in th-cells
26805 !! wikitext
26806 {|
26807 ! Foo !! style="color: red" | Bar
26808 |}
26809 !! html
26810 <table>
26811 <tr>
26812 <th> Foo </th>
26813 <th style="color: red"> Bar
26814 </th></tr></table>
26815
26816 !!end
26817
26818 !!test
26819 Accept empty attributes in th-cells
26820 !! wikitext
26821 {|
26822 !| foo !!| bar
26823 |}
26824 !! html
26825 <table>
26826 <tr>
26827 <th> foo </th>
26828 <th> bar
26829 </th></tr></table>
26830
26831 !!end
26832
26833 !!test
26834 Empty table rows go away
26835 !! wikitext
26836 {|
26837 | Hello
26838 | there
26839 |- class="foo"
26840 |-
26841 |}
26842 !! html
26843 <table>
26844 <tr>
26845 <td> Hello
26846 </td>
26847 <td> there
26848 </td></tr>
26849
26850 </table>
26851
26852 !! end
26853
26854 ###
26855 ### Parsoid-centric tests for testing RTing of inter-element separators
26856 ### Edge cases not tested by existing parser tests and specific to
26857 ### Parsoid-specific serialization strategies.
26858 ###
26859
26860 !!test
26861 RT-ed inter-element separators should be valid separators
26862 !! wikitext
26863 {|
26864 |- [[foo]]
26865 |}
26866 !! html/php
26867 <table>
26868
26869 </table>
26870
26871 !! html/parsoid
26872 <table>
26873 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
26874 </tbody></table>
26875 !!end
26876
26877 # Parsoid-only since PHP parser relies on Tidy for correct output
26878 !!test
26879 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
26880 !!options
26881 parsoid
26882 !! wikitext
26883 {|
26884 |<small>foo
26885 bar
26886 |}
26887
26888 {|
26889 |<small>foo<small>
26890 |}
26891 !! html
26892 <table>
26893 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
26894 <p>bar</p></small></td></tr>
26895 </tbody></table>
26896
26897 <table>
26898 <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>
26899 </tbody></table>
26900 !!end
26901
26902 # Note that the "style" attribute is really a template parameter here.
26903 # The = would have to be {{=}} if you wanted the literal.
26904 !!test
26905 Empty TD followed by TD with tpl-generated attribute
26906 !! wikitext
26907 {|
26908 |-
26909 |
26910 |{{echo|style='color:red'}}|foo
26911 |}
26912 !! html
26913 <table>
26914
26915 <tr>
26916 <td>
26917 </td>
26918 <td>foo
26919 </td></tr></table>
26920
26921 !!end
26922
26923 !!test
26924 Indented table with an empty td
26925 !! wikitext
26926 {|
26927 |-
26928 |
26929 |foo
26930 |}
26931 !! html
26932 <table>
26933
26934 <tr>
26935 <td>
26936 </td>
26937 <td>foo
26938 </td></tr></table>
26939
26940 !!end
26941
26942 ## We have some newline diffs RT-ing this edge case
26943 ## and it is not important enough -- we seem to be emitting
26944 ## at most 2 newlines after a </tr> and this is unrelated to
26945 ## the issue from T85627 that this is testing.
26946 !!test
26947 Indented table with blank lines in between (T85627)
26948 !! options
26949 parsoid=wt2html
26950 !! wikitext
26951 {|
26952 |foo
26953
26954
26955 |}
26956 !! html
26957 <table>
26958
26959 <tr>
26960 <td>foo
26961 </td></tr></table>
26962
26963 !!end
26964
26965 !!test
26966 Indented block & table
26967 !! wikitext
26968 <div>foo</div>
26969 {|
26970 |foo
26971 |}
26972 !! html/php
26973 <div>foo</div>
26974 <table>
26975 <tr>
26976 <td>foo
26977 </td></tr></table>
26978
26979 !! html/parsoid
26980 <div data-parsoid='{"stx":"html"}'>foo</div>
26981 <table><tbody>
26982 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
26983 </tbody></table>
26984 !!end
26985
26986 !! test
26987 Indent and comment before table row
26988 !! wikitext
26989 {|
26990 <!--hi-->|-
26991 | there
26992 |}
26993 !! html/php
26994 <table>
26995
26996 <tr>
26997 <td> there
26998 </td></tr></table>
26999
27000 !! html/parsoid
27001 <table>
27002 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
27003 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
27004 </tbody></table>
27005 !! end
27006
27007 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
27008 !!test
27009 Empty TR followed by a template-generated TR
27010 !!options
27011 parsoid
27012 !! wikitext
27013 {|
27014 |-
27015 {{echo|<tr><td>foo</td></tr>}}
27016 |}
27017 !! html
27018 <table>
27019 <tbody>
27020 <tr class='mw-empty-elt'></tr>
27021 <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}}]}'>
27022 <td>foo</td></tr>
27023 </tbody></table>
27024 !!end
27025
27026 ## PHP and parsoid output differ for this, and since this is primarily
27027 ## for testing Parsoid's serializer, marking this Parsoid only
27028 !!test
27029 Empty TR followed by mixed-ws-comment line should RT correctly
27030 !!options
27031 parsoid
27032 !! wikitext
27033 {|
27034 |-
27035 <!--c-->
27036 |-
27037 <!--c--> <!--d-->
27038 |}
27039 !! html
27040 <table>
27041 <tbody>
27042 <tr class='mw-empty-elt'></tr>
27043 <!--c-->
27044 <tr>
27045 <!--c--> </tr><!--d-->
27046 </tbody></table>
27047
27048 !!end
27049
27050 !!test
27051 Multi-line image caption generated by templates with/without trailing newlines
27052 !! wikitext
27053 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
27054 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
27055 !! html/parsoid
27056 <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>
27057 <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>
27058 !!end
27059
27060 !! test
27061 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
27062 !! options
27063 parsoid=html2wt
27064 !! html/parsoid
27065 <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>
27066
27067 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
27068 !! wikitext
27069 <includeonly>foo</includeonly>
27070 new para
27071
27072 [[Category:Foo]]
27073
27074 = new heading =
27075 !! end
27076
27077 ## PHP emits broken html for this, and since this is primarily
27078 ## a Parsoid serializer test, marking this Parsoid only
27079 !!test
27080 Improperly nested inline or quotes tags with whitespace in between
27081 !! wikitext
27082 <span> <s>x</span> </s>
27083 ''' ''x''' ''
27084 !! html/parsoid
27085 <p><span> <s>x</s></span><s> </s>
27086 <b> <i>x</i></b><i> </i>
27087 </p>
27088 !!end
27089
27090 !!test
27091 Encapsulate protected attributes from wt
27092 !! wikitext
27093 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
27094
27095 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
27096 | ok
27097 |}
27098 !! html/parsoid
27099 <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>
27100
27101 <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">
27102 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'> ok</td></tr>
27103 </tbody></table>
27104 !!end
27105
27106 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
27107 ## Having nested or stray pre tags results in the attempt to add duplicates,
27108 ## causing an assertion fail. This test tries to prevent that situation.
27109 !!test
27110 Ensure ParagraphWrapper can deal with stray closing pre tags
27111 !!options
27112 parsoid=wt2html
27113 !! wikitext
27114 plain text</pre>
27115 !! html/parsoid
27116 plain text
27117 !!end
27118
27119 !!test
27120 1. Ensure fostered text content is wrapped in element nodes
27121 !!options
27122 parsoid=wt2html
27123 !! wikitext
27124 <table>hi</table><table>ho</table>
27125 !! html/parsoid
27126 <p>hi</p>
27127 <table></table>
27128 <p>ho</p>
27129 <table></table>
27130 !!end
27131
27132 !!test
27133 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
27134 !!options
27135 parsoid=wt2html,wt2wt
27136 !! wikitext
27137 <table>
27138 <tr> || ||
27139 <td> a
27140 </table>
27141 !! html/parsoid
27142 <p> || ||
27143 </p><table>
27144 <tbody><tr><td> a</td></tr>
27145 </tbody></table>
27146 !!end
27147
27148 !!test
27149 Encapsulation properly handles null DSR information from foster box
27150 !!options
27151 parsoid=wt2html,wt2wt
27152 !! wikitext
27153 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
27154 !! html/parsoid
27155 <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>
27156 !!end
27157
27158 !!test
27159 1. Encapsulate foster-parented transclusion content
27160 !!options
27161 parsoid=wt2wt,wt2html
27162 !! wikitext
27163 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
27164 !! html/parsoid
27165 <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>
27166 <tbody>
27167 <tr>
27168 <td>bar</td>
27169 </tr>
27170 </tbody>
27171 </table>
27172 !!end
27173
27174 !!test
27175 2. Encapsulate foster-parented transclusion content
27176 !!options
27177 parsoid=wt2wt,wt2html
27178 !! wikitext
27179 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
27180 !! html/parsoid
27181 <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>
27182 <table>
27183 <tbody>
27184 <tr>
27185 <td>bar</td>
27186 </tr>
27187 </tbody>
27188 </table>
27189 !!end
27190
27191 !!test
27192 3. Encapsulate foster-parented transclusion content
27193 !!options
27194 parsoid=wt2wt,wt2html
27195 !! wikitext
27196 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
27197 !! html/parsoid
27198 <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;]}">
27199 <p>foo</p>
27200 </div>
27201 <table>
27202 <tbody>
27203 <tr>
27204 <td>bar</td>
27205 </tr>
27206 </tbody>
27207 </table>
27208 !!end
27209
27210 !!test
27211 4. Encapsulate foster-parented transclusion content
27212 !!options
27213 parsoid=wt2wt,wt2html
27214 !! wikitext
27215 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
27216 !! html/parsoid
27217 <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;]}">
27218 <p>foo</p>
27219 </div>
27220 <table>
27221 <tbody>
27222 <tr>
27223 <td>bar</td>
27224 </tr>
27225 </tbody>
27226 </table>
27227 !!end
27228
27229 !!test
27230 5. Encapsulate foster-parented transclusion content
27231 !!options
27232 parsoid=wt2wt,wt2html
27233 !! wikitext
27234 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
27235 !! html/parsoid
27236 <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>
27237 <table>
27238 <tbody>
27239 <tr>
27240 <td>
27241 <div>
27242 <p>foo</p>
27243 </div>
27244 </td>
27245 </tr>
27246 </tbody>
27247 </table>
27248 !!end
27249
27250 !!test
27251 6. Encapsulate foster-parented transclusion content
27252 !!options
27253 parsoid=wt2wt,wt2html
27254 !! wikitext
27255 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
27256 !! html/parsoid
27257 <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>
27258 <table>
27259 <tbody>
27260 <tr>
27261 <td>
27262 <div>
27263 <p>foo</p>
27264 </div>
27265 </td>
27266 </tr>
27267 </tbody>
27268 </table>
27269 <p>ok</p>
27270 !!end
27271
27272 !!test
27273 7. Encapsulate foster-parented transclusion content
27274 !!options
27275 parsoid=wt2wt,wt2html
27276 !! wikitext
27277 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
27278 !! html/parsoid
27279 <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>
27280 <table>
27281 <tbody>
27282 <tr>
27283 <td>bar</td>
27284 </tr>
27285 </tbody>
27286 </table>
27287 !!end
27288
27289 # Note that the wt is broken on purpose: the = should be {{=}} if you
27290 # don't want it to be a template parameter key.
27291 !!test
27292 8. Encapsulate foster-parented transclusion content
27293 !!options
27294 parsoid=wt2wt,wt2html
27295 !! wikitext
27296 {{echo|a
27297 }}{|{{echo|style='color:red'}}
27298 |-
27299 |b
27300 |}
27301 !! html/parsoid
27302 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}'>a</p>
27303 <span> </span>
27304 <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>
27305 <table>
27306 <tbody>
27307 <tr>
27308 <td>b</td>
27309 </tr>
27310 </tbody>
27311 </table>
27312 !!end
27313
27314 !!test
27315 9. Encapsulate foster-parented transclusion content
27316 !!options
27317 parsoid=wt2wt,wt2html
27318 !! wikitext
27319 <table>{{echo|hi</table>hello}}
27320 !! html/parsoid
27321 <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>
27322 !!end
27323
27324 !!test
27325 Table in fosterable position
27326 !!options
27327 parsoid=wt2html
27328 !! wikitext
27329 {{OpenTable}}
27330 <div>
27331 {|
27332 |}
27333 </div>
27334 |}
27335 !! html/parsoid
27336 <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">
27337 </span>
27338 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
27339
27340 <table>
27341 </table>
27342 !!end
27343
27344 # Parsoid only for T66747
27345 !! test
27346 Properly encapsulate empty-content transclusions in fosterable positions
27347 !! wikitext
27348 <table>
27349 {{#if:|
27350 <td>foo</td>
27351 }}
27352 </table>
27353 !! html/parsoid
27354 <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"}]]}'>
27355
27356 </table>
27357 !! end
27358
27359 !! test
27360 Always encapsulate foster box when template range is expanded to table
27361 !! options
27362 parsoid=wt2wt
27363 !! wikitext
27364 {|
27365 hello
27366 {{OpenTable}}
27367 |}
27368 !! html/parsoid
27369
27370 !! end
27371
27372 !! test
27373 T115289: Unclosed table
27374 !! wikitext
27375 {{echo|<table>}}<!--c-->[[Category:Two]]
27376 !! html/parsoid
27377 <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>
27378 !! end
27379
27380 !! test
27381 T115289: Don't migrate newlines out of tables with fostered content
27382 !! wikitext
27383 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
27384 !! html/parsoid
27385 <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>
27386 !! end
27387
27388 !! test
27389 T73074: More fostering fun
27390 !! wikitext
27391 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
27392 !! html/parsoid
27393 <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>
27394 !! end
27395
27396 !!test
27397 Support <object> element with .data attribute
27398 !!options
27399 parsoid=html2wt
27400 !! html/parsoid
27401 <object data="test.swf"></object>
27402 !! wikitext
27403 <object data="test.swf"></object>
27404 !!end
27405
27406 !! test
27407 Don't block XML namespace declaration
27408 !! wikitext
27409 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27410 !! html/php
27411 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27412 </p>
27413 !! html/parsoid
27414 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
27415 !! end
27416
27417 # -----------------------------------------------------------------
27418 # The following section of tests are primarily to spec requirements
27419 # around Parsoid's serialization (old, new, edited content)
27420 #
27421 # All these tests are marked Parsoid html2wt and html2html only
27422 # ----------------------------------------------------------------
27423
27424 !! test
27425 Ignore rel attribute in a-tags during serialization to url-links
27426 !! options
27427 parsoid=html2wt
27428 !! html/parsoid
27429 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
27430 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
27431 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
27432 !! wikitext
27433 http://en.wikipedia.org/wiki/Foobar
27434 http://en.wikipedia.org/wiki/Foobar
27435 http://en.wikipedia.org/wiki/Foobar
27436 !! end
27437
27438 # 'mi' is a localinterwiki prefix as well as a language
27439 !! test
27440 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
27441 !! options
27442 parsoid=html2wt
27443 !! html/parsoid
27444 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
27445 !! wikitext
27446 [[Foo]]
27447 !! end
27448
27449 !! test
27450 Parsoid should accept interwiki shortcuts
27451 !! options
27452 parsoid=html2wt
27453 !! html/parsoid
27454 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
27455 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
27456 <a href='./fr:Foo'>Foo</a></p>
27457 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
27458 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
27459 <a href='fr%3AFoo'>Foo</a></p>
27460 <p><a href='FR%3AFoo'>Foo</a>
27461 <a href='./FR:Foo'>Foo</a></p>
27462 !! wikitext
27463 [[:fr:Foo|Foo]]
27464 [[:fr:Foo|Foo]]
27465 [[:fr:Foo|Foo]]
27466
27467 [[:fr:Foo|Foo]]
27468 [[:fr:Foo|Foo]]
27469 [[:fr:Foo|Foo]]
27470
27471 [[:fr:Foo|Foo]]
27472 [[:fr:Foo|Foo]]
27473 !! end
27474
27475 !! test
27476 Parsoid should not accept invalid interwiki shortcuts
27477 !! options
27478 parsoid=html2wt
27479 !! html/parsoid
27480 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
27481 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
27482 <a href='news:Foo'>Foo</a></p>
27483 !! wikitext
27484 [news:Foo Foo]
27485 [news:Foo Foo]
27486 [news:Foo Foo]
27487 !! end
27488
27489 # See T93839
27490 !! test
27491 New wikilinks should be serialized properly
27492 !! options
27493 parsoid=html2wt
27494 !! html/parsoid
27495 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
27496 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
27497 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
27498 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
27499 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
27500 !! wikitext
27501 [[Foo]]
27502 [[Foo]]
27503 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
27504 http://en.wikipedia.org/wiki/Foo
27505 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
27506 !! end
27507
27508 !! test
27509 New wiki links (href variations)
27510 !! options
27511 parsoid=html2wt
27512 !! html/parsoid
27513 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27514 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
27515 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
27516 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
27517 !! wikitext
27518 [[Foo_bar]]
27519 [[Foo_bar]]
27520 [[Foo_bar]]
27521 [[Toxine bactérienne]]
27522 !! end
27523
27524 !! test
27525 New wiki links (content string variations)
27526 !! options
27527 parsoid=html2wt
27528 !! html/parsoid
27529 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27530 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
27531 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
27532 !! wikitext
27533 [[Foo_bar]]
27534 [[Foo bar]]
27535 [[Foo_bar|./Foo_bar]]
27536 !! end
27537
27538 !! test
27539 New category links (href variations)
27540 !! options
27541 parsoid=html2wt
27542 !! html/parsoid
27543 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
27544 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
27545 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
27546 !! wikitext
27547 [[Category:Toxine bactérienne]]
27548 [[Category:Toxine bactérienne]]
27549 [[Category:Toxine bactérienne]]
27550 !! end
27551
27552 !! test
27553 New sol transparent links don't need indent-pre nowiki protection
27554 !! options
27555 parsoid=html2wt
27556 language=de
27557 !! html/parsoid
27558 <link rel="mw:PageProp/redirect" href="./Main_Page">
27559 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
27560 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
27561 !! wikitext
27562 #WEITERLEITUNG [[Main Page]]
27563 <!-- this is good --> [[Category:Good]]
27564 <!-- this is great --> [[Kategorie:Great]]
27565 !! end
27566
27567 !! test
27568 New interlanguage links (href variations)
27569 !! options
27570 parsoid=html2wt
27571 !! html/parsoid
27572 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
27573 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
27574 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
27575 !! wikitext
27576 [[es:Toxine bactérienne]]
27577 [[es:Toxine_bactérienne]]
27578 [[es:Toxine_bactérienne]]
27579 !! end
27580
27581 !! test
27582 Image: Modifying size of an image (1)
27583 !! options
27584 parsoid={
27585 "modes": ["wt2wt"],
27586 "changes": [
27587 ["img[height]", "attr", "height", "22"],
27588 ["img[width]", "attr", "width", "200"]
27589 ]
27590 }
27591 !! wikitext
27592 [[Image:Foobar.jpg|230x230px]]
27593 !! wikitext/edited
27594 [[Image:Foobar.jpg|200x200px]]
27595 !!end
27596
27597 !! test
27598 Image: Modifying size of an image (2)
27599 !! options
27600 parsoid={
27601 "modes": ["wt2wt"],
27602 "changes": [
27603 ["img[height]", "attr", "height", "100"],
27604 ["img[width]", "attr", "width", "500"]
27605 ]
27606 }
27607 !! wikitext
27608 [[Image:Foobar.jpg|230x230px]]
27609 !! wikitext/edited
27610 [[Image:Foobar.jpg|500x500px]]
27611 !!end
27612
27613 # Change in size is ignored so long as class='mw-default-size'
27614 !! test
27615 Image: Modifying size of an image (3)
27616 !! options
27617 parsoid={
27618 "modes": ["wt2wt"],
27619 "changes": [
27620 ["figure[class]", "removeClass", "mw-default-size"],
27621 ["figure img", "attr", "height", "19"],
27622 ["figure img", "attr", "width", "170"]
27623 ]
27624 }
27625 !! wikitext
27626 [[Image:Foobar.jpg|thumb]]
27627 !! wikitext/edited
27628 [[Image:Foobar.jpg|thumb|170x170px]]
27629 !!end
27630
27631 !! test
27632 Image: Modifying alignment of an image (T50665)
27633 !! options
27634 parsoid={
27635 "modes": ["wt2wt"],
27636 "changes": [
27637 ["figure[class]", "removeClass", "mw-halign-right"],
27638 ["figure[class]", "addClass", "mw-halign-left"]
27639 ]
27640 }
27641 !! wikitext
27642 [[Image:Foobar.jpg|thumb|caption|right]]
27643 !! wikitext/edited
27644 [[Image:Foobar.jpg|thumb|caption|left]]
27645 !! end
27646
27647 !! test
27648 Image: Modifying mw-default-size of an frameless image (T64805)
27649 !! options
27650 parsoid={
27651 "modes": ["wt2wt"],
27652 "changes": [
27653 ["figure.mw-default-size", "removeClass", "mw-default-size"]
27654 ]
27655 }
27656 !! wikitext
27657 [[Image:Foobar.jpg|frameless|right]]
27658 !! wikitext/edited
27659 [[Image:Foobar.jpg|frameless|right|220x220px]]
27660 !! end
27661
27662 !! test
27663 Image: Modifying valign of an image (T51221)
27664 !! options
27665 parsoid={
27666 "modes": ["wt2wt"],
27667 "changes": [
27668 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
27669 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
27670 ]
27671 }
27672 !! wikitext
27673 [[File:Foobar.jpg|20px|middle]]
27674 !! wikitext/edited
27675 [[File:Foobar.jpg|20px|text-top]]
27676 !! end
27677
27678 !! test
27679 Image: Modifying alt attribute of an image (T58400)
27680 !! options
27681 parsoid={
27682 "modes": ["wt2wt"],
27683 "changes": [
27684 ["img[alt]", "attr", "alt", "some alternate edited text"]
27685 ]
27686 }
27687 !! wikitext
27688 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
27689 !! wikitext/edited
27690 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
27691 !!end
27692
27693 !! test
27694 Image: Modifying caption of an image
27695 !! options
27696 parsoid={
27697 "modes": ["wt2wt"],
27698 "changes": [
27699 ["figcaption", "text", "new caption"]
27700 ]
27701 }
27702 !! wikitext
27703 [[Image:Foobar.jpg|thumb|original caption]]
27704 !! wikitext/edited
27705 [[Image:Foobar.jpg|thumb|new caption]]
27706 !!end
27707
27708 !! test
27709 Image: empty alt attribute (T50924)
27710 !! options
27711 parsoid
27712 !! wikitext
27713 [[File:Foobar.jpg|thumb|alt=|bar]]
27714 !! html
27715 <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>
27716 !! end
27717
27718 !! test
27719 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
27720 !! options
27721 parsoid=html2wt
27722 language=ar
27723 disabled
27724 !! html/parsoid
27725 <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>
27726 !! wikitext
27727 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
27728 !! end
27729
27730 !! test
27731 Image: Block level image should have \n before and after
27732 !! wikitext
27733 123
27734 [[File:Foobar.jpg|right|thumb|150x150px]]
27735 456
27736 !! html/parsoid
27737 <p>123</p>
27738 <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>
27739 <p>456</p>
27740 !! end
27741
27742 !! test
27743 Image: New block level image should have \n before and after (existing content)
27744 !! wikitext
27745 123
27746 [[File:Foobar.jpg|right|thumb|150x150px]]
27747 456
27748 !! html/parsoid
27749 <p>123</p>
27750 <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>
27751 <p>456</p>
27752 !! end
27753
27754 !! test
27755 Image: upright option (parsoid)
27756 !! wikitext
27757 [[File:Foobar.jpg|thumb|upright|caption]]
27758 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
27759 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
27760 !! html/parsoid
27761 <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>
27762 <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>
27763 <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>
27764 !! end
27765
27766 !! test
27767 Image: upright option is ignored on inline and frame images (parsoid)
27768 !! wikitext
27769 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
27770 !! html/parsoid
27771 <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>
27772 !! end
27773
27774 !! test
27775 Image: in template parameter with empty parameter
27776 !! wikitext
27777 {{echo|[[File:Foobar.jpg|link=]]}}
27778 !! html/parsoid
27779 <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>
27780 !! end
27781
27782 !! test
27783 Image: from basic HTML (1)
27784 !! options
27785 parsoid=html2wt
27786 !! html/parsoid
27787 <span typeof="mw:Image">
27788 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27789 </span>
27790 !! wikitext
27791 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27792 !! end
27793
27794 !! test
27795 Image: from basic HTML (2)
27796 !! options
27797 parsoid=html2wt
27798 !! html/parsoid
27799 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27800 !! wikitext
27801 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27802 !! end
27803
27804 !! test
27805 Image: from basic HTML (3)
27806 !! options
27807 parsoid=html2wt
27808 !! html/parsoid
27809 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
27810 !! wikitext
27811 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
27812 !! end
27813
27814 !! test
27815 Image: from basic HTML (4)
27816 !! options
27817 parsoid=html2wt
27818 !! html/parsoid
27819 <img src="./File:Foobar.jpg">
27820 !! wikitext
27821 [[File:Foobar.jpg|link=]]
27822 !! end
27823
27824 !! test
27825 Image: Invalid title as link
27826 !! wikitext
27827 [[File:Foobar.jpg|link=<]]
27828 !! html/php
27829 <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>
27830 </p>
27831 !! html/parsoid
27832 <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>
27833 !! end
27834
27835 !! test
27836 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
27837 !! options
27838 parsoid=html2wt
27839 !! html/parsoid
27840 <ul>
27841 <li><p>foo</p></li>
27842 </ul>
27843 !! wikitext
27844 * foo
27845 !! end
27846
27847 !! test
27848 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
27849 !! options
27850 parsoid=html2wt
27851 !! html/parsoid
27852 <ul> <li>foo</li></ul>
27853 !! wikitext
27854 * foo
27855 !! end
27856
27857 !! test
27858 Don't strip leading whitespace when handling indent-pre suppressing tags
27859 !! options
27860 parsoid=html2wt
27861 !! html/parsoid
27862 <table>
27863 <tr><td> indented row</td></tr>
27864 </table>
27865 <blockquote><p>
27866 <b>This is very bold of you!</b>
27867 </p>
27868 <table><tr><td>
27869 indented cell (no pre-wrapping!)
27870 </td></tr></table>
27871 </blockquote>
27872 <p>foo</p>
27873 <div>bar</div>
27874 !! wikitext
27875 {|
27876 | indented row
27877 |}
27878 <blockquote>
27879 '''This is very bold of you!'''
27880
27881 {|
27882 |
27883 indented cell (no pre-wrapping!)
27884 |}
27885 </blockquote>
27886 foo
27887 <div>bar</div>
27888 !! end
27889
27890 !! test
27891 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
27892 !! options
27893 parsoid=html2wt
27894 !! html/parsoid
27895 <p>foo</p>
27896 <span>bar</span>
27897
27898 <span>foo2
27899 </span>bar2
27900
27901 <div>foo</div>
27902 <span>bar</span>
27903
27904 <div>
27905 <span>foo</span>
27906 </div>
27907 !! wikitext
27908 foo
27909
27910 <span>bar</span>
27911
27912 <span>foo2
27913 <nowiki> </nowiki></span>bar2
27914
27915 <div>foo</div>
27916 <nowiki> </nowiki><span>bar</span>
27917
27918 <div>
27919 <nowiki> </nowiki><span>foo</span>
27920 </div>
27921 !! end
27922
27923 !! test
27924 Lists: Dont insert newlines in a serialized list item.
27925 !! options
27926 parsoid=html2wt
27927 !! html/parsoid
27928 <ul><li>a<br>b</li><li>c</li></ul>
27929 !! wikitext
27930 * a<br>b
27931 * c
27932 !! end
27933
27934 !! test
27935 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
27936 !! options
27937 parsoid={
27938 "modes": ["html2wt"],
27939 "scrubWikitext": false
27940 }
27941 !! html/parsoid
27942 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
27943 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
27944
27945 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
27946 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
27947
27948 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
27949
27950 <h2><meta property="mw:PageProp/toc" /> ok</h2>
27951 !! wikitext
27952 == hello there [[Category:A1]] ==
27953
27954 == [[Category:A2]] hi pal ==
27955
27956 == <!--foo--> [[Category:A3]] how goes it ==
27957
27958 == it goes well [[Category:A4]] <!--bar--> ==
27959
27960 ==howdy [[Category:A5]]==
27961
27962 == __TOC__ ok ==
27963 !! end
27964
27965 !! test
27966 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
27967 !! options
27968 parsoid={
27969 "modes": ["html2wt"],
27970 "scrubWikitext": true
27971 }
27972 !! html/parsoid
27973 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
27974 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
27975
27976 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
27977 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
27978
27979 <h2><meta property="mw:PageProp/toc" /> ok</h2>
27980 !! wikitext
27981 == hello there ==
27982 [[Category:A1]]
27983 [[Category:A2]]
27984
27985 == hi pal ==
27986
27987 <!--foo--> [[Category:A3]]
27988
27989 == how goes it ==
27990
27991 == it goes well ==
27992 [[Category:A4]] <!--bar-->
27993
27994 __TOC__
27995
27996 == ok ==
27997 !! end
27998
27999 !! test
28000 Headings: Don't hoist metas that come from templates
28001 !! options
28002 parsoid={
28003 "modes": ["html2wt"],
28004 "scrubWikitext": true
28005 }
28006 !! html/parsoid
28007 <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>
28008 !! wikitext
28009 == {{echo|foo [[Category:Foo]]}} ==
28010 !! end
28011
28012 !! test
28013 Headings: Category in ref isn't hoisted
28014 !! options
28015 parsoid={
28016 "modes": ["html2wt"],
28017 "scrubWikitext": true
28018 }
28019 !! html/parsoid
28020 <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>
28021
28022 <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>
28023 !! wikitext
28024 == foo <ref>bar
28025 [[Category:Baz]] </ref> ==
28026
28027 <references />
28028 !! end
28029
28030 !! test
28031 Parsoid: Serialize positional parameters with = in them as named parameter
28032 !! options
28033 parsoid=html2wt
28034 !! html/parsoid
28035 <p about="#mwt1" typeof="mw:Transclusion"
28036 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
28037
28038 <p about="#mwt1" typeof="mw:Transclusion"
28039 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
28040
28041 <!--Orig params with data-parsoid has heuristics for handling = chars-->
28042 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
28043 <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>
28044 !! wikitext
28045 {{echo|1=f=oo}}
28046
28047 {{echo|1=f=oo|2=bar}}
28048
28049 <!--Orig params with data-parsoid has heuristics for handling = chars-->
28050 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
28051 {{echo|<nowiki>f=oo</nowiki>|bar}}
28052 !! end
28053
28054 !! test
28055 Parsoid: Serialize positional parameters with = in extlink as named parameter
28056 !! options
28057 parsoid=html2wt
28058 !! html/parsoid
28059 <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>
28060 !! wikitext
28061 {{echo|1=http://stuff?is=ok}}
28062 !! end
28063
28064 !! test
28065 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
28066 !! options
28067 parsoid=html2wt
28068 !! html/parsoid
28069 <div>a<p>b</p></div>
28070 <div>a
28071 <p>b</p></div>
28072 <div>
28073 a
28074 <p>b</p></div>
28075 !! wikitext
28076 <div>a
28077 b
28078 </div>
28079 <div>a
28080 b
28081 </div>
28082 <div>
28083 a
28084
28085 b
28086 </div>
28087 !! end
28088
28089 !! test
28090 Substrings resembling wikitext in hrefs should not get nowiki escapes
28091 !! options
28092 parsoid=html2wt
28093 !! html/parsoid
28094 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
28095 !! wikitext
28096 [[Foo''bar''baz]]
28097 !! end
28098
28099 !! test
28100 Enforce single-line context in the serializer
28101 !! options
28102 parsoid=html2wt
28103 !! html/parsoid
28104 <h2>testing
28105 123</h2>
28106
28107 <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">
28108 </span><span about="#mwt1">you</span> </h2>
28109
28110 <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>
28111
28112 <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
28113 there</span></li></ol>
28114
28115 <ul><li>asd
28116 sdf</li></ul>
28117
28118 <ul><li>foo
28119 bar
28120 baz</li>
28121 <li>foo <b>bar</b>
28122 baz</li></ul>
28123
28124 <dl><dt>hi
28125 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
28126 ho</dd></dl>
28127
28128 <dl><dd> <table>
28129 <tbody><tr><td> ha
28130 ha
28131 ha</td></tr>
28132 </tbody></table></dd></dl>
28133 !! wikitext
28134 == testing 123 ==
28135
28136 == hi {{bogus|there
28137 you}} ==
28138
28139 == foo <ref>hello
28140 there</ref> ==
28141
28142 <references />
28143
28144 * asd sdf
28145
28146 * foo bar baz
28147 * foo '''bar''' baz
28148
28149 ; hi ho : hi ho
28150
28151 : {|
28152 | ha
28153 ha
28154 ha
28155 |}
28156 !! end
28157
28158 !! test
28159 Serialize new placeholder space without spans
28160 !! options
28161 parsoid=html2wt
28162 !! html/parsoid
28163 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
28164
28165 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
28166
28167 <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>
28168 !! wikitext
28169 foo : bar
28170
28171 foo : bar
28172
28173 <ref>foo : bar</ref>ok
28174 !! end
28175
28176
28177 #-----------------------
28178 # Tag minimization tests
28179 #-----------------------
28180
28181 !! test
28182 1. I/B quote minimization: wikitext-only tags should be combined
28183 !! options
28184 parsoid=html2wt
28185 !! html/parsoid
28186 <p><i>A</i><i>B</i></p>
28187 <p><b>A</b><b>B</b></p>
28188 <p><i>A</i><b><i>B</i></b></p>
28189 <p><b>A</b><i><b>B</b></i></p>
28190 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
28191 <p><i><b>A</b></i><i><b>B</b></i></p>
28192 <p><i><b>A</b></i><b><i>B</i></b></p>
28193 <p><b><i>A</i></b><i><b>B</b></i></p>
28194 !! wikitext
28195 ''AB''
28196
28197 '''AB'''
28198
28199 ''A'''B'''''
28200
28201 '''A''B'''''
28202
28203 '''A''BC''D'''
28204
28205 '''''AB'''''
28206
28207 '''''AB'''''
28208
28209 '''''AB'''''
28210 !! end
28211
28212 !! test
28213 2. I/B quote minimization: wikitext and html tags should not be combined
28214 !! options
28215 parsoid=html2wt
28216 !! html/parsoid
28217 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
28218 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
28219 !! wikitext
28220 ''A''<i>B</i>
28221
28222 ''A''<nowiki/>'''<i>B</i>'''
28223 !! end
28224
28225 !! test
28226 3. I/B quote minimization: templated content stops minimization
28227 !! options
28228 parsoid=html2wt
28229 !! html/parsoid
28230 <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>
28231 <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>
28232 !! wikitext
28233 ''A''{{echo|''B''}}
28234
28235 ''A''{{echo|'''''B'''''}}
28236 !! end
28237
28238 !! test
28239 4. I/B quote minimization: new content should be mimimized with adjacent old content
28240 !! options
28241 parsoid=html2wt
28242 !! html/parsoid
28243 <p><i>A</i><i>B</i></p>
28244 <p><b>A</b><b>B</b></p>
28245 <p><i>A</i><b><i>B</i></b></p>
28246 !! wikitext
28247 ''AB''
28248
28249 '''AB'''
28250
28251 ''A'''B'''''
28252 !! end
28253
28254 !! test
28255 5a. Merge adjacent quote nodes if they've been edited
28256 !! options
28257 parsoid={
28258 "modes": ["wt2wt", "selser"],
28259 "changes": [
28260 ["p", "contents", "remove", ":contains('b')"]
28261 ]
28262 }
28263 !! wikitext
28264 ''a''b''c''
28265 !! wikitext/edited
28266 ''ac''
28267 !! end
28268
28269 !! test
28270 5b. Merge adjacent quote nodes if they've been edited
28271 !! options
28272 parsoid={
28273 "modes": ["wt2wt", "selser"],
28274 "changes": [
28275 ["#x", "remove"]
28276 ]
28277 }
28278 !! wikitext
28279 ''a''<span id="x">b</span>''c''
28280 !! wikitext/edited
28281 ''ac''
28282 !! end
28283
28284 !! test
28285 1. Merge adjacent link nodes as long as at least one element is new
28286 !! options
28287 parsoid={
28288 "modes": ["html2wt"],
28289 "scrubWikitext": true
28290 }
28291 !! html/parsoid
28292 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28293 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28294 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
28295 !! wikitext
28296 [[Football]]
28297 [[Football]]
28298 [[Football|Foot]][[Football|ball]]
28299 !! end
28300
28301 !! test
28302 2. Merge adjacent link nodes and enable additional normalizations
28303 !! options
28304 parsoid={
28305 "modes": ["html2wt"],
28306 "scrubWikitext": true
28307 }
28308 !! html/parsoid
28309 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
28310 !! wikitext
28311 [[Football|''Football'']]
28312 !! end
28313
28314 !! test
28315 3. Don't merge adjacent link nodes if scrubWikitext is false
28316 !! options
28317 parsoid={
28318 "modes": ["html2wt"],
28319 "scrubWikitext": false
28320 }
28321 !! html/parsoid
28322 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28323 !! wikitext
28324 [[Football|Foot]][[Football|ball]]
28325 !! end
28326
28327 #------------------------------
28328 # End of tag minimization tests
28329 #------------------------------
28330
28331 !!test
28332 T56262: New entities
28333 !! options
28334 parsoid=html2wt
28335 !! html/parsoid
28336 <span typeof="mw:Entity">&nbsp;</span>
28337 !! wikitext
28338 &nbsp;
28339 !! end
28340
28341 ## Note that there is no wikitext output for 'unknownproperty' ##
28342 ## Unknown magic words are silently dropped ##
28343
28344 !! test
28345 Magic words
28346 !! options
28347 parsoid=html2wt
28348 !! html/parsoid
28349 <meta property='mw:PageProp/toc' />
28350 <meta property='mw:PageProp/notoc' />
28351 <meta property='mw:PageProp/forcetoc' />
28352 <meta property='mw:PageProp/index' />
28353 <meta property='mw:PageProp/noindex' />
28354 <meta property='mw:PageProp/nogallery' />
28355 <meta property='mw:PageProp/noeditsection' />
28356 <meta property='mw:PageProp/notitleconvert' />
28357 <meta property='mw:PageProp/nocontentconvert' />
28358 <meta property='mw:PageProp/unknownproperty' />
28359 !! wikitext
28360 __TOC__
28361 __NOTOC__
28362 __FORCETOC__
28363 __INDEX__
28364 __NOINDEX__
28365 __NOGALLERY__
28366 __NOEDITSECTION__
28367 __NOTITLECONVERT__
28368 __NOCONTENTCONVERT__
28369 !! end
28370
28371 !! test
28372 Consecutive <pre>s should not get merged
28373 !! options
28374 parsoid=html2wt,html2html
28375 !! html/parsoid
28376 <pre>a</pre><pre>b</pre>
28377
28378 <pre>c
28379 </pre><pre>
28380 d</pre>
28381
28382 <pre>e
28383
28384 </pre><pre>
28385
28386 f</pre>
28387 !! wikitext
28388 a
28389
28390 b
28391
28392 c
28393
28394 d
28395
28396 e
28397
28398
28399
28400 f
28401 !! end
28402
28403 !! test
28404 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
28405 !! options
28406 parsoid=html2wt
28407 !! html/parsoid
28408 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
28409 !! wikitext
28410 [[Special:BookSources/1234567890|ISBN 1234567895]]
28411 !! end
28412
28413 !! test
28414 Edited RFC links not serializable as RFC links should serialize as extlinks
28415 !! options
28416 parsoid=html2wt
28417 !! html/parsoid
28418 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
28419 !! wikitext
28420 [https://tools.ietf.org/html/rfc123 New RFC]
28421 !! end
28422
28423 !! test
28424 Edited PMID links not serializable as PMID links should serialize as extlinks
28425 !! options
28426 parsoid=html2wt
28427 !! html/parsoid
28428 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
28429 !! wikitext
28430 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
28431 !! end
28432
28433 !! test
28434 WTS of autolinks with trailing/surrounding context
28435 !! options
28436 parsoid=html2wt
28437 !! html/parsoid
28438 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
28439 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
28440 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
28441 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
28442 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
28443 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
28444 !! wikitext
28445 http://cscott.net'''foo'''
28446
28447 http://cscott.net<b>foo</b>
28448
28449 '''http://cscott.net'''
28450
28451 '''http://cscott.net '''
28452
28453 '''http://cscott.net<nowiki/>x'''
28454
28455 http://cscott.net<nowiki/>x
28456 !! end
28457
28458 !! test
28459 WTS of autolinks with nowikis (round-trip)
28460 !! wikitext
28461 x<nowiki/>http://cscott.net<nowiki/>x
28462 !! html/parsoid
28463 <p>x<a rel="mw:ExtLink" href="http://cscott.net">http://cscott.net</a>x</p>
28464 !! end
28465
28466 # this is the "easy" test because it leaves in place all the
28467 # data-parsoid information indicating this is an autolink
28468 !! test
28469 WTS of autolinks with escapes (editing)
28470 !! options
28471 parsoid={
28472 "modes": ["wt2wt"],
28473 "changes": [
28474 [ "span", "remove" ]
28475 ]
28476 }
28477 !! wikitext
28478 x<nowiki/>http://cscott.net<nowiki/>x
28479 !! wikitext/edited
28480 x<nowiki/>http://cscott.net<nowiki/>x
28481 !! end
28482
28483 !! test
28484 WTS of edited autolink-like text (T103364)
28485 !! options
28486 parsoid={
28487 "modes": ["wt2wt"],
28488 "changes": [
28489 [ "span[typeof]", "removeAttr", "typeof" ]
28490 ]
28491 }
28492 !! wikitext
28493 Not a link: <nowiki>http://example.com</nowiki>.
28494 !! wikitext/edited
28495 Not a link: <span><nowiki>http://example.com</nowiki></span>.
28496 !! end
28497
28498 !! test
28499 WTS of newly-authored autolink-like text (T103364)
28500 !! options
28501 parsoid=html2wt
28502 !! html/parsoid
28503 <p>http://example.com is not a link.</p>
28504 !! wikitext
28505 <nowiki>http://example.com</nowiki> is not a link.
28506 !! end
28507
28508 !! test
28509 WTS of autolink-like text after an autolink (T108563)
28510 !! options
28511 parsoid=html2wt
28512 !! html/parsoid
28513 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
28514 !! wikitext
28515 http://example.com <nowiki>http://example.com</nowiki> is not a link.
28516 !! end
28517
28518 !! test
28519 Magic links inside links (not autolinked)
28520 !! wikitext
28521 [[Foo|http://example.com]]
28522 [[Foo|RFC 1234]]
28523 [[Foo|PMID 1234]]
28524 [[Foo|ISBN 123456789x]]
28525
28526 [http://foo.com http://example.com]
28527 [http://foo.com RFC 1234]
28528 [http://foo.com PMID 1234]
28529 [http://foo.com ISBN 123456789x]
28530 !! html+tidy
28531 <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>
28532 <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>
28533 !! html/parsoid
28534 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
28535 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
28536 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
28537 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
28538
28539 <p><a rel="mw:ExtLink" href="http://foo.com">http://example.com</a>
28540 <a rel="mw:ExtLink" href="http://foo.com">RFC 1234</a>
28541 <a rel="mw:ExtLink" href="http://foo.com">PMID 1234</a>
28542 <a rel="mw:ExtLink" href="http://foo.com">ISBN 123456789x</a></p>
28543 !! end
28544
28545 !! test
28546 Magic links inside image captions (autolinked)
28547 !! wikitext
28548 [[File:Foobar.jpg|thumb|http://example.com]]
28549 [[File:Foobar.jpg|thumb|RFC 1234]]
28550 [[File:Foobar.jpg|thumb|PMID 1234]]
28551 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
28552 !! html+tidy
28553 <div class="thumb tright">
28554 <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>
28555 <div class="thumbcaption">
28556 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28557 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div>
28558 </div>
28559 </div>
28560 <div class="thumb tright">
28561 <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>
28562 <div class="thumbcaption">
28563 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28564 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a></div>
28565 </div>
28566 </div>
28567 <div class="thumb tright">
28568 <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>
28569 <div class="thumbcaption">
28570 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28571 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a></div>
28572 </div>
28573 </div>
28574 <div class="thumb tright">
28575 <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>
28576 <div class="thumbcaption">
28577 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28578 <a href="/wiki/Special:BookSources/123456789X" class="internal mw-magiclink-isbn">ISBN 123456789x</a></div>
28579 </div>
28580 </div>
28581 !! html/parsoid
28582 <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>
28583 <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>
28584 <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>
28585 <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>
28586 !! end
28587
28588 !! test
28589 WTS of magic word text (T109371)
28590 !! options
28591 parsoid=html2wt
28592 !! html/parsoid
28593 <p>RFC 1234</p>
28594 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
28595 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
28596 !! wikitext
28597 <nowiki>RFC 1234</nowiki>
28598
28599 [http://foo.com RFC 1234]
28600
28601 [[Foo|RFC 1234]]
28602 !! end
28603
28604 !! test
28605 Edited Redirect link should emit a non-piped wikitext link
28606 !! options
28607 parsoid=html2wt
28608 !! html/parsoid
28609 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
28610 !! wikitext
28611 #REDIRECT [[Bar]]
28612 !! end
28613
28614 !! test
28615 T75121: Infer extension name from typeOf if data-mw is not present
28616 !! options
28617 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28618 !! html/parsoid
28619 <div typeOf="mw:Extension/foo"></div>
28620 !! wikitext
28621 <foo />
28622 !! end
28623
28624 # Note that the <p> wrapping isn't present in PHP parser output
28625 # The important thing for this test is that P-wrapping doesn't
28626 # interfere with the <nowiki> protection for leading - in <td>
28627 # (which isn't necessary for <th>).
28628 !! test
28629 T88318: p-wrapped dash in table.
28630 !! options
28631 parsoid=html2wt,wt2wt
28632 !! html/parsoid
28633 <table><tbody>
28634 <tr><th><p>-</p></th><th><p>- </p></th></tr>
28635 <tr><td><p>-</p></td><td><p>- </p></td></tr>
28636 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
28637 </tbody></table>
28638 !! wikitext
28639 {|
28640 !-
28641 !-
28642 |-
28643 |<nowiki>-</nowiki>
28644 |<nowiki>- </nowiki>
28645 |-
28646 |<small>-</small>
28647 |<br>
28648 -
28649 |<br>
28650 -
28651 |}
28652 !! html/php+tidy
28653 <table>
28654 <tr>
28655 <th>-</th>
28656 <th>-</th>
28657 </tr>
28658 <tr>
28659 <td>-</td>
28660 <td>-</td>
28661 </tr>
28662 <tr>
28663 <td><small>-</small></td>
28664 <td><br />
28665 <p>-</p>
28666 </td>
28667 <td><br />
28668 <p>-</p>
28669 </td>
28670 </tr>
28671 </table>
28672 !! end
28673
28674 !! test
28675 T149209: WTS: Handle newlines in table cells properly
28676 !! options
28677 parsoid=html2wt
28678 !! html/parsoid
28679 <table>
28680 <tbody>
28681 <tr><td>a
28682 b
28683 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
28684 <tr><td><p>x</p>
28685 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
28686 </tbody></table>
28687 <table>
28688 <tbody>
28689 <tr><th>a
28690 b
28691 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
28692 <tr><th><p>x</h>
28693 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
28694 </tbody></table>
28695 !! wikitext
28696 {|
28697 |a
28698 b
28699 |c
28700 |-
28701 |x
28702 {{!}}y
28703 |}
28704 {|
28705 !a
28706 b
28707 !c
28708 |-
28709 !x
28710 !y
28711 |}
28712 !! end
28713
28714 !! test
28715 T149209: Selser: Handle newlines in table cells properly
28716 !! options
28717 parsoid={
28718 "modes": ["selser"],
28719 "changes": [
28720 [ "#h1", "html", "a\nb\n" ],
28721 [ "#h2", "html", "a\nb\n" ],
28722 [ "#c1", "html", "a\nb\n" ],
28723 [ "#c2", "html", "<p>a</p>" ],
28724 [ "#c3", "html", "<p>a</p>" ],
28725 [ "#c4", "html", "edit-me<p>a</p>" ]
28726 ]
28727 }
28728 !! wikitext
28729 {|
28730 ! id="h1" |edit-me!!1
28731 |-
28732 ! id="h2" |edit-me||2
28733 |-
28734 | id="c1" |edit-me||3
28735 |-
28736 | id="c2" |edit-me||4
28737 |-
28738 | id="c3" |edit-me||p||q||r
28739 |-
28740 | id="c4" |edit-me||p||q||r
28741 |}
28742 !! wikitext/edited
28743 {|
28744 ! id="h1" |a
28745 b
28746 !1
28747 |-
28748 ! id="h2" |a
28749 b
28750 !2
28751 |-
28752 | id="c1" |a
28753 b
28754 |3
28755 |-
28756 | id="c2" |a
28757 |4
28758 |-
28759 | id="c3" |a
28760 |p||q||r
28761 |-
28762 | id="c4" |edit-me
28763 a
28764 |p||q||r
28765 |}
28766 !! end
28767
28768 !! test
28769 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
28770 !! options
28771 parsoid=html2wt
28772 !! html/parsoid
28773 <table id='mwAb'>
28774 <td id='mwAc'>foo</td>
28775 <td id='serialize-this'>bar</td>
28776 </table>
28777 !! wikitext
28778 {|
28779 |foo
28780 | id="serialize-this" |bar
28781 |}
28782 !! end
28783
28784 !! test
28785 Parsoid-like element ids should not be serialized to wikitext unless shadowed
28786 !! options
28787 parsoid=html2wt
28788 !! html/parsoid
28789 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
28790 !! wikitext
28791 <div id="hello">ok</div>
28792 !! end
28793
28794 !! test
28795 WTS change modes
28796 !! options
28797 parsoid={
28798 "modes": ["wt2wt"],
28799 "changes": [
28800 [ "#xyz", "before", "<b>before</b> stuff " ],
28801 [ "#xyz", "after", " stuff <i>after</i>" ],
28802 [ "#xyz", "html", "x <b>y</b> z" ]
28803 ]
28804 }
28805 !! wikitext
28806 <span id="xyz">hello</span>
28807 !! wikitext/edited
28808 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
28809 !! end
28810
28811 !! test
28812 Never serialize a-tag as html, regardless of what data-parsoid has to say
28813 !! options
28814 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28815 !! html/parsoid
28816 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
28817 !! wikitext
28818 [[Foo]]
28819 !! end
28820
28821 ## SSS FIXME: This is broken output nevertheless.
28822 ## What might be a reasonable non-broken output for this?
28823 ## This is an edge case unlikely to be seen in production
28824 ## that I am not wasting more time on this right now.
28825 !! test
28826 Never serialize a-tag as html, no matter what attributes it has
28827 !! options
28828 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28829 !! html/parsoid
28830 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
28831 !! wikitext
28832 [http://boo.org http://boohoo.org]
28833 !! end
28834
28835 # Misnested is an indication that selser can reuse the source but these have
28836 # shown to sneak through on occasion. See T101768.
28837 # The original wikitext here is: [http://test.com [[one]] two three]
28838 !! test
28839 Strip span tags added to mark misnested links
28840 !! options
28841 parsoid=html2wt
28842 !! html/parsoid
28843 <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>
28844 !! wikitext
28845 [http://test.com][[one]] two three
28846 !! end
28847
28848 !! test
28849 Catch regression when unpacking misnested links
28850 !! options
28851 parsoid=wt2html
28852 !! wikitext
28853 {{echo|hi}}[http://example.com [[ho]]]
28854 !! html/parsoid
28855 <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>
28856 !! end
28857
28858 !! test
28859 Catch regression when unpacking with trailing content
28860 !! wikitext
28861 {{echo|Foo <references/> bar}}
28862 !! html/parsoid
28863 <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>
28864 !! end
28865
28866 !! test
28867 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
28868 !! options
28869 parsoid=html2wt
28870 !! html/parsoid
28871 <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|}"]}'>
28872 <tbody><tr><td>d
28873 </td></tr>
28874 </tbody></table>
28875 !! wikitext
28876 {{echo|a}}
28877 {|{{echo|c
28878 {{!}}d
28879 }}
28880 |}
28881 !! end
28882
28883 ## This test verifies the presence and computation of this attribute indirectly
28884 ## by making an edit and ensuring that the serialization is correct (which it would be
28885 ## only if firstWikitextNode is properly set).
28886 !! test
28887 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
28888 !! options
28889 parsoid= {
28890 "modes": ["wt2wt"],
28891 "changes": [
28892 [ "div#x", "remove" ],
28893 [ "div", "before", "<div>new</div>" ]
28894 ]
28895 }
28896 !! wikitext
28897 <div id="x">foo</div>
28898 {|
28899 {{echo|<div>boo</div>
28900 {{!}}b}}
28901 |c
28902 |}
28903 !! wikitext/edited
28904
28905 <div>new</div>
28906 {|
28907 {{echo|<div>boo</div>
28908 {{!}}b}}
28909 |c
28910 |}
28911 !! end
28912
28913 # --------------------------------------------
28914 # Tests spec'ing wikitext serialization norms |
28915 # --------------------------------------------
28916
28917 !! test
28918 Serialize multi-line indent-pre starting with wikitext syntax
28919 !! options
28920 parsoid=html2wt
28921 !! html/parsoid
28922 <pre>* 1
28923 ** 2
28924 * 3</pre>
28925 !! wikitext
28926 * 1
28927 ** 2
28928 * 3
28929 !! end
28930
28931 !! test
28932 1. Categories should always be serialized on their own line
28933 !! options
28934 parsoid=html2wt
28935 !! html/parsoid
28936 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
28937 !! wikitext
28938 foo
28939 [[Category:Foo]]
28940 bar
28941 !! end
28942
28943 !! test
28944 2. Categories that are part of templates should not introduce a line break
28945 !! wikitext
28946 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
28947 !! html/parsoid
28948 <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>
28949 !! end
28950
28951 # Careful while editing these next 2 tests. There are \u200f characters
28952 # before and after the <link> tags in the HTML and following some
28953 # of the categories in wikitext
28954 # Do not remove these characters in edits.
28955 #
28956 # As part of the serialization, these bidi characters will get stripped.
28957 !! test
28958 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
28959 !! options
28960 parsoid={
28961 "modes": ["html2wt"],
28962 "scrubWikitext": true
28963 }
28964 !! html/parsoid
28965 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
28966 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
28967 !! wikitext
28968 [[קטגוריה:טקסים]]
28969 [[קטגוריה: שיטות משפט]]
28970 !! end
28971
28972 !! test
28973 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
28974 !! options
28975 parsoid={
28976 "modes": ["html2wt"],
28977 "scrubWikitext": true
28978 }
28979 !! html/parsoid
28980 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
28981 !! wikitext
28982 [[קטגוריה:טקסים]]
28983 ‏y
28984 !! end
28985
28986 !! test
28987 Lists: Add space after bullets
28988 !! options
28989 parsoid=html2wt
28990 !! html/parsoid
28991 <ul>
28992 <li>foo</li>
28993 <li> bar</li>
28994 <li><span> baz</span></li>
28995 </ul>
28996 !! wikitext
28997 * foo
28998 * bar
28999 * <span> baz</span>
29000 !! end
29001
29002 !! test
29003 1. Headings: Add space before/after == (T53744)
29004 !! options
29005 parsoid=html2wt
29006 !! html/parsoid
29007 <h2>foo</h2>
29008 <h2> bar</h2>
29009 <h2>baz </h2>
29010 <h2><span> baz</span></h2>
29011 !! wikitext
29012 == foo ==
29013
29014 == bar ==
29015
29016 == baz ==
29017
29018 == <span> baz</span> ==
29019 !! end
29020
29021 !! test
29022 2. Headings: Add space before/after == even after hoisted content
29023 !! options
29024 parsoid={
29025 "modes": ["html2wt"],
29026 "scrubWikitext": true
29027 }
29028 !! html/parsoid
29029 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
29030 !! wikitext
29031 [[Category:A2]]
29032
29033 == ok ==
29034 !! end
29035
29036 !! test
29037 1. Headings: suppress newly created empty headings
29038 !! options
29039 parsoid={
29040 "modes": ["html2wt"],
29041 "scrubWikitext": true
29042 }
29043 !! html/parsoid
29044 <h2></h2>
29045 !! wikitext
29046 !! end
29047
29048 !! test
29049 2. Headings: don't suppress empty headings if scrubWikitext is false
29050 !! options
29051 parsoid=html2wt
29052 !! html/parsoid
29053 <h2></h2>
29054 !! wikitext
29055 ==<nowiki/>==
29056 !! end
29057
29058 !! test
29059 3. Headings: suppress empty headings on edits
29060 !! options
29061 parsoid={
29062 "modes": ["selser"],
29063 "scrubWikitext": true,
29064 "changes": [
29065 [ "#x", "remove"]
29066 ]
29067 }
29068 !! wikitext
29069 ==<span id="x">foo</span>==
29070 !! wikitext/edited
29071 !! end
29072
29073 !! test
29074 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
29075 !! options
29076 parsoid={
29077 "modes": ["html2wt"],
29078 "scrubWikitext": true
29079 }
29080 !! html/parsoid
29081 <h2>foo<br/>bar</h2>
29082 <h2>foo <span><br/>bar</span> baz</h2>
29083 !! wikitext
29084 == foo bar ==
29085
29086 == foo <span> bar</span> baz ==
29087 !! end
29088
29089 !! test
29090 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
29091 !! options
29092 parsoid={
29093 "modes": ["html2wt"],
29094 "scrubWikitext": false
29095 }
29096 !! html/parsoid
29097 <h2>foo<br/>bar</h2>
29098 !! wikitext
29099 == foo<br> bar ==
29100 !! end
29101
29102 !! test
29103 1. WT Quote Tags: suppress newly created empty style tags
29104 !! options
29105 parsoid={
29106 "modes": ["html2wt"],
29107 "scrubWikitext": true
29108 }
29109 !! html/parsoid
29110 <i></i><b></b>
29111 !! wikitext
29112 !! end
29113
29114 !! test
29115 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
29116 !! options
29117 parsoid=html2wt
29118 !! html/parsoid
29119 <i></i><b></b>
29120 !! wikitext
29121 ''<nowiki/>'''''<nowiki/>'''
29122 !! end
29123
29124 !! test
29125 3. WT Quote Tags: suppress empty style tags on edits
29126 !! options
29127 parsoid={
29128 "modes": ["selser"],
29129 "scrubWikitext": true,
29130 "changes": [
29131 [ "#x", "remove"]
29132 ]
29133 }
29134 !! wikitext
29135 '''<span id="x">foo</span>'''
29136 !! wikitext/edited
29137 !! end
29138
29139 !! test
29140 1. Anchors: suppress newly created empty anchors
29141 !! options
29142 parsoid={
29143 "modes": ["html2wt"],
29144 "scrubWikitext": true
29145 }
29146 !! html/parsoid
29147 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
29148 !! wikitext
29149 !! end
29150
29151 !! test
29152 2. Anchors: don't suppress empty anchors if scrubWikitext is false
29153 !! options
29154 parsoid={
29155 "modes": ["html2wt"],
29156 "scrubWikitext": false
29157 }
29158 !! html/parsoid
29159 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
29160 !! wikitext
29161 [[Test|<nowiki/>]]
29162 !! end
29163
29164 !! test
29165 3. Anchors: suppress empty anchors on edits
29166 !! options
29167 parsoid={
29168 "modes": ["selser"],
29169 "scrubWikitext": true,
29170 "changes": [
29171 [ "#x", "remove"]
29172 ]
29173 }
29174 !! wikitext
29175 [[Test|<span id="x">foo</span>]]
29176 !! wikitext/edited
29177 !! end
29178
29179 !! test
29180 3a. Anchors: do not suppress numbered extlinks
29181 !! options
29182 parsoid={
29183 "modes": ["wt2wt"],
29184 "scrubWikitext": true
29185 }
29186 !! wikitext
29187 [http://foo.com]
29188 !! html/parsoid
29189 <a rel="mw:ExtLink" href="http://foo.com"></a>
29190 !! end
29191
29192 !! test
29193 3b. Anchors: do not suppress numbered extlinks
29194 !! options
29195 parsoid={
29196 "modes": ["wt2wt"],
29197 "scrubWikitext": true,
29198 "changes": [
29199 [ "#x", "remove"]
29200 ]
29201 }
29202 !! wikitext
29203 [http://foo.com <span id="x">foo</span>]
29204 !! wikitext/edited
29205 [http://foo.com]
29206 !! end
29207
29208 !!test
29209 Normalizations should be restricted to edited content
29210 !!options
29211 parsoid={
29212 "modes": ["selser"],
29213 "scrubWikitext": true,
29214 "changes": [
29215 [ "h1", "before", "<i></i>"]
29216 ]
29217 }
29218 !!wikitext
29219 a
29220 = =
29221 b
29222 !!wikitext/edited
29223 a
29224 = =
29225 b
29226 !!end
29227
29228 !! test
29229 1. Multiple normalizations (html2wt)
29230 !! options
29231 parsoid={
29232 "modes": ["html2wt"],
29233 "scrubWikitext": true
29234 }
29235 !! html
29236 <h2><i></i></h2>
29237 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
29238 </a><b><i></i></b>x</p>
29239 !! wikitext
29240
29241 [[foo]]
29242 x
29243
29244 !! end
29245
29246 !! test
29247 2. Multiple normalizations (selser)
29248 !! options
29249 parsoid={
29250 "modes": ["selser"],
29251 "scrubWikitext": true,
29252 "changes": [
29253 [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
29254 ]
29255 }
29256 !! wikitext
29257 <span id="x">foo</span>
29258 !! wikitext/edited
29259 <span id="x">foo</span>
29260
29261 x
29262 !! end
29263
29264 !! test
29265 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
29266 !! options
29267 parsoid={
29268 "modes": ["html2wt"],
29269 "scrubWikitext": true
29270 }
29271 !! html/parsoid
29272 <p> hi</p>
29273 <p> hello</p>
29274 !! wikitext
29275 hi
29276
29277 hello
29278 !! end
29279
29280 !! test
29281 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
29282 !! options
29283 parsoid=html2wt
29284 !! html/parsoid
29285 <p> hi</p>
29286 <p> hello</p>
29287 !! wikitext
29288 <nowiki> </nowiki>hi
29289
29290 <nowiki> </nowiki> hello
29291 !! end
29292
29293 !! test
29294 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
29295 !! options
29296 parsoid={
29297 "modes": ["html2wt"],
29298 "scrubWikitext": true
29299 }
29300 !! html/parsoid
29301 <p>Foo
29302 bar
29303 baz</p>
29304
29305 <table><tr><td>Foo
29306 bar
29307 baz bang</td></tr></table>
29308
29309 <p><!--boo--> foo
29310 bar</p>
29311
29312 <p> foo
29313 bar<span>boo</span></p>
29314 !! wikitext
29315 Foo
29316 bar
29317 baz
29318
29319 {|
29320 |Foo
29321 bar
29322 baz bang
29323 |}
29324
29325 <!--boo-->foo
29326 bar
29327
29328 foo
29329 bar<span>boo</span>
29330 !! end
29331
29332 !! test
29333 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
29334 !! options
29335 parsoid={
29336 "modes": ["selser"],
29337 "scrubWikitext": true,
29338 "changes": [
29339 [ "p", "html", " a\n b" ]
29340 ]
29341 }
29342 !! wikitext
29343 xyz
29344 !! wikitext/edited
29345 a
29346 b
29347 !! end
29348
29349 !! test
29350 1. New links that end in spaces
29351 !! options
29352 parsoid={
29353 "modes": ["html2wt"],
29354 "scrubWikitext": false
29355 }
29356 !! html/parsoid
29357 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29358 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29359 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29360 !! wikitext
29361 [[Berlin ]]<nowiki/>is the capital of Germany.
29362
29363 [[Foo ]]'''bar'''
29364
29365 [[Boston ]] is a city.
29366 !! end
29367
29368 !! test
29369 2. New links that end in spaces
29370 !! options
29371 parsoid={
29372 "modes": ["html2wt"],
29373 "scrubWikitext": true
29374 }
29375 !! html/parsoid
29376 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29377 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29378 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29379 !! wikitext
29380 [[Berlin]] is the capital of Germany.
29381
29382 [[Foo]] '''bar'''
29383
29384 [[Boston]] is a city.
29385 !! end
29386
29387 !! test
29388 1. Table cells with escapable prefixes
29389 !! options
29390 parsoid={
29391 "modes": ["html2wt"],
29392 "scrubWikitext": false
29393 }
29394 !! html
29395 <table>
29396 <tr><td>a</td></tr>
29397 <tr><td>-</td></tr>
29398 <tr><td>+</td></tr>
29399 </table>
29400 !! wikitext
29401 {|
29402 |a
29403 |-
29404 |<nowiki>-</nowiki>
29405 |-
29406 |<nowiki>+</nowiki>
29407 |}
29408 !! end
29409
29410 !! test
29411 2. Table cells with escapable prefixes
29412 !! options
29413 parsoid={
29414 "modes": ["html2wt"],
29415 "scrubWikitext": true
29416 }
29417 !! html
29418 <table>
29419 <tr><td>a</td></tr>
29420 <tr><td>-</td></tr>
29421 <tr><td>+</td></tr>
29422 </table>
29423 !! wikitext
29424 {|
29425 |a
29426 |-
29427 | -
29428 |-
29429 | +
29430 |}
29431 !! end
29432
29433 !! test
29434 3a. Table cells with escapable prefixes after edits
29435 !! options
29436 parsoid={
29437 "modes": ["selser"],
29438 "scrubWikitext": true,
29439 "changes": [
29440 [ "table tbody tr:first-child td:first-child", "remove"]
29441 ]
29442 }
29443 !! wikitext
29444 {|
29445 |a||-
29446 |}
29447 !! wikitext/edited
29448 {|
29449 | -
29450 |}
29451 !! end
29452
29453 !! test
29454 3b. Table cells with escapable prefixes after edits
29455 !! options
29456 parsoid={
29457 "modes": ["selser"],
29458 "scrubWikitext": true,
29459 "changes": [
29460 [ "table tbody tr:first-child td:first-child", "html", "-" ],
29461 [ "#x", "remove" ]
29462 ]
29463 }
29464 !! wikitext
29465 {|
29466 |pqr
29467 |<span id="x">foo</span>+
29468 |}
29469 !! wikitext/edited
29470 {|
29471 | -
29472 | +
29473 |}
29474 !! end
29475
29476 # FIXME: This test will fail because
29477 # normalization doesn't realize that the id attribute
29478 # will eliminate the escapable scenario
29479 !! test
29480 4a. Table cells without escapable prefixes after edits
29481 !! options
29482 parsoid={
29483 "modes": ["selser"],
29484 "scrubWikitext": true,
29485 "changes": [
29486 [ "#x", "html", "-" ]
29487 ]
29488 }
29489 !! wikitext
29490 {|
29491 | id="x" |abcd
29492 |}
29493 !! wikitext/edited
29494 {|
29495 | id="x" |-
29496 |}
29497 !! end
29498
29499 ## This tests normalizer's ability to discriminate between
29500 ## cells having identical content.
29501 !! test
29502 4b. Table cells without escapable prefixes after edits
29503 !! options
29504 parsoid={
29505 "modes": ["selser"],
29506 "scrubWikitext": true,
29507 "changes": [
29508 [ "td", "html", "-" ]
29509 ]
29510 }
29511 !! wikitext
29512 {|
29513 |a||b
29514 |}
29515 !! wikitext/edited
29516 {|
29517 | -||-
29518 |}
29519 !! end
29520
29521 ## This tests normalizer's ability to not be tripped by
29522 ## comments (and whitespace)
29523 !! test
29524 4c. Table cells without escapable prefixes after edits
29525 !! options
29526 parsoid={
29527 "modes": ["selser"],
29528 "scrubWikitext": true,
29529 "changes": [
29530 [ "table tbody tr td:first-child", "remove" ]
29531 ]
29532 }
29533 !! wikitext
29534 {|
29535 |-
29536 <!--foo--> |a||-
29537 |}
29538 !! wikitext/edited
29539 {|
29540 |-
29541 <!--foo--> | -
29542 |}
29543 !! end
29544
29545 ## This tests normalizer's ability to handle HTML cells
29546 !! test
29547 4d. Table cells without escapable prefixes after edits
29548 !! options
29549 parsoid={
29550 "modes": ["selser"],
29551 "scrubWikitext": true,
29552 "changes": [
29553 [ "td", "html", "-" ]
29554 ]
29555 }
29556 !! wikitext
29557 <table>
29558 <tr><td>a</td></tr>
29559 </table>
29560 !! wikitext/edited
29561 <table>
29562 <tr><td>-</td></tr>
29563 </table>
29564 !! end
29565
29566 ## T111151 Remove font elements without attributes
29567 !! test
29568 5a. font tags without attributes should be dropped in scrubWikitext mode
29569 !! options
29570 parsoid={
29571 "modes": ["html2wt"],
29572 "scrubWikitext": true
29573 }
29574 !! html
29575 <font>foo</font>
29576 <font><font>bar</font></font>
29577 <font class="x">boo</font>
29578 !! wikitext
29579 foo
29580 bar
29581 <font class="x">boo</font>
29582 !! end
29583
29584 !! test
29585 5b. font tags should not be dropped without scrubWikitext being enabled
29586 !! options
29587 parsoid={
29588 "modes": ["html2wt"],
29589 "scrubWikitext": false
29590 }
29591 !! html
29592 <font>foo</font>
29593 !! wikitext
29594 <font>foo</font>
29595 !! end
29596
29597 !! test
29598 Escape nowiki DOM elements
29599 !! options
29600 parsoid=html2wt
29601 !! html/parsoid
29602 <nowiki><i>foo</i></nowiki>
29603 !! wikitext
29604 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
29605 !! end
29606
29607 # This is meant to be an interim fix while we go about figuring out
29608 # how to not introduce these trailing <nowiki/>s in the first place.
29609 !! test
29610 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
29611 !! options
29612 parsoid=html2wt
29613 !! html/parsoid
29614 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
29615 y</p>
29616 <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>
29617 <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>
29618 !! wikitext
29619 x
29620 y
29621
29622 {{echo|
29623 1 = <nowiki/>}}
29624
29625 {{echo|
29626 1 = <nowiki/>
29627 }}
29628 !! end
29629
29630 # ---------------------------------------------------
29631 # End of tests spec'ing wikitext serialization norms |
29632 # ---------------------------------------------------
29633
29634 # T104032
29635 !! test
29636 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
29637 !! options
29638 parsoid=html2wt
29639 !! html/parsoid
29640 a<p>b</p>
29641 <b>c</b><p>d</p>
29642 <table><tr>
29643 <td>a<p>b</p></td>
29644 <td><b>c</b><p>d</p></td>
29645 </tr></table>
29646 !! wikitext
29647 a
29648
29649 b
29650
29651 '''c'''
29652
29653 d
29654 {|
29655 |a
29656 b
29657 |'''c'''
29658 d
29659 |}
29660 !! end
29661
29662 !! test
29663 Anchor without href scenarios
29664 !! options
29665 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29666 !! html/parsoid
29667 <a class="bc"></a>
29668 <a class="no">dice</a>
29669 <a name="foo"></a>
29670 !! wikitext
29671
29672 dice
29673 <span name="foo"></span>
29674 !! end
29675
29676 !! test
29677 New transclusion added after a list should be serialized after the list
29678 !! options
29679 parsoid=html2wt
29680 !! html/parsoid
29681 <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>
29682 !! wikitext
29683 * a
29684 {{echo|foo}}
29685 !! end
29686
29687 # -----------------------------------------------------------------
29688 # End of section for Parsoid-only html2wt tests for serialization
29689 # of new content
29690 # -----------------------------------------------------------------
29691
29692 # -----------------------------------------------------------------
29693 # The following section of tests are primarily to spec behavior of
29694 # the selective serializer. All these tests have manual selser
29695 # changes. The automated selser changes for all tests handle the
29696 # wide variation of changes, but these tests here capture specs
29697 # deterministically.
29698 # ----------------------------------------------------------------
29699
29700 ## T90517
29701 !! test
29702 Selser: New comments should not be lost
29703 !! options
29704 parsoid={
29705 "modes": ["selser"],
29706 "changes": [
29707 [ "#a", "after", "<!--c1-->" ],
29708 [ "#b", "before", "<!--c2-->" ]
29709 ]
29710 }
29711 !! wikitext
29712 <span id="a">a</span>
29713
29714 <span id="b">b</span>
29715 !! wikitext/edited
29716 <span id="a">a</span><!--c1-->
29717
29718 <!--c2--><span id="b">b</span>
29719 !! end
29720
29721 ## T89383
29722 !! test
29723 Selser: Check for validity of DSR before using it
29724 !! options
29725 parsoid={
29726 "modes": ["selser"],
29727 "changes": [
29728 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
29729 ]
29730 }
29731 !! wikitext
29732 <span id="a">a</span>
29733 !! wikitext/edited
29734 {{DISPLAYTITLE:foo}}
29735 <span id="a">a</span>
29736 !! end
29737
29738 !! test
29739 1. DOMDiff: Changes to <ref> content should be looked up using id
29740 !! options
29741 parsoid={
29742 "modes": ["selser"],
29743 "changes": [
29744 ["#X", "after", "bar"],
29745 ["#Y", "after", "baz"]
29746 ]
29747 }
29748 !! wikitext
29749 X <ref><span id="X">foo</span></ref>
29750 Y <ref name="a" />
29751 <references>
29752 <ref name="a"><span id="Y">foo</span></ref>
29753 </references>
29754 !! wikitext/edited
29755 X <ref><span id="X">foo</span>bar</ref>
29756 Y <ref name="a" />
29757 <references>
29758 <ref name="a"><span id="Y">foo</span>baz</ref>
29759 </references>
29760 !! end
29761
29762 !! test
29763 2. DOMDiff: Changes to <ref> content should be looked up using id
29764 !! options
29765 parsoid={
29766 "modes": ["selser"],
29767 "changes": [
29768 ["#Z", "after", "bar"]
29769 ]
29770 }
29771 !! wikitext
29772 A <ref>foo bar for a</ref>
29773 B <ref group="X" name="b" />
29774
29775 <references />
29776
29777 <references group="X">
29778 <ref name="b"><span id="Z">foo</span></ref>
29779 </references>
29780 !! wikitext/edited
29781 A <ref>foo bar for a</ref>
29782 B <ref group="X" name="b" />
29783
29784 <references />
29785
29786 <references group="X">
29787 <ref name="b"><span id="Z">foo</span>bar</ref>
29788 </references>
29789 !! end
29790
29791 !! test
29792 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
29793 !! options
29794 parsoid={
29795 "modes": ["selser"],
29796 "changes": [
29797 [ "div:first-child", "text", "bar" ]
29798 ]
29799 }
29800 !! wikitext
29801 <div style="{{1x|color:red;}}%">foo</div>
29802 !! wikitext/edited
29803 <div style="{{1x|color:red;}}%">bar</div>
29804 !! end
29805
29806 !! test
29807 Empty LI (T49673)
29808 !! wikitext
29809 * a
29810 *
29811 *
29812 * b
29813 !! html/php+tidy
29814 <ul>
29815 <li>a</li>
29816 <li class="mw-empty-elt"></li>
29817 <li class="mw-empty-elt"></li>
29818 <li>b</li>
29819 </ul>
29820 !! end
29821
29822 !! test
29823 Thumbnail output
29824 !! wikitext
29825 [[File:Thumb.png|thumb]]
29826 !! html/php+tidy
29827 <div class="thumb tright">
29828 <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>
29829 <div class="thumbcaption">
29830 <div class="magnify"><a href="/wiki/File:Thumb.png" class="internal" title="Enlarge"></a></div>
29831 </div>
29832 </div>
29833 </div>
29834 !! end
29835
29836 !! test
29837 unclosed internal link XSS (T137264)
29838 !! wikitext
29839 [[#%3Cscript%3Ealert(1)%3C/script%3E|
29840 !! html/php
29841 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
29842 </p>
29843 !! html/parsoid
29844 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
29845 !! end
29846
29847 # Use $wgRawHtml to inject a <style> tag, since you normally can't in wikitext
29848 # (Parsoid doesn't support $wgRawHtml==true)
29849 !! test
29850 Validating that <style> isn't eaten by tidy (T167349)
29851 !! options
29852 wgRawHtml=1
29853 !! wikitext
29854 <div class="foo">
29855 <html><style>.foo::before { content: "<foo>"; }</style></html>
29856 <html><style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style></html>
29857 </div>
29858 !! html/php+tidy
29859 <div class="foo">
29860 <style>.foo::before { content: "<foo>"; }</style>
29861 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
29862 </div>
29863 !! end
29864
29865 !! test
29866 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
29867 !! config
29868 wgFragmentMode=[ 'html5', 'legacy' ]
29869 !! wikitext
29870 == A&B&amp;C&amp;amp;D&amp;amp;amp;E ==
29871 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
29872 !! html/php
29873 <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>
29874 <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>
29875 </p>
29876 !! html/parsoid
29877 <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>
29878 <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>
29879 !! end
29880
29881 !! test
29882 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
29883 !! config
29884 wgFragmentMode=[ 'legacy' ]
29885 !! wikitext
29886 == A&B&amp;C&amp;amp;D&amp;amp;amp;E ==
29887 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
29888 !! html/php
29889 <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>
29890 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
29891 </p>
29892 !! end
29893
29894 !! test
29895 Decoding of HTML entities in embedded HTML tags
29896 !! wikitext
29897 <table class="1&2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
29898 !! html/php
29899 <table class="1&amp;2&amp;3&amp;amp;4&amp;amp;amp;5"><tr><td>x</td></tr></table>
29900
29901 !! html/parsoid
29902 <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>
29903 !! end
29904
29905 !! test
29906 Decoding of HTML entities in indicator names for IDs (T104196)
29907 !! options
29908 parsoid=wt2html,html2html
29909 showindicators
29910 !! wikitext
29911 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
29912 !! html/php
29913 1&2&3&amp;4&amp;amp;5=Indicator
29914
29915 !! html/parsoid
29916 <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>
29917 !! end
29918
29919 # this version of the test strips out the ambiguity so Parsoid rts cleanly
29920 !! test
29921 Decoding of HTML entities in indicator names for IDs (unambiguous) (T104196)
29922 !! options
29923 showindicators
29924 !! wikitext
29925 <indicator name="1&2&3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
29926 !! html/php
29927 1&2&3&amp;4&amp;amp;5=Indicator
29928
29929 !! html/parsoid
29930 <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>
29931 !! end
29932
29933 # This fragment mode is what Parsoid supports.
29934 !! test
29935 HTML5 ids: fallback to legacy
29936 !! config
29937 wgFragmentMode=[ 'html5', 'legacy' ]
29938 !! wikitext
29939 == Foo bar ==
29940
29941 == foo Bar ==
29942
29943 == Тест ==
29944
29945 == Тест ==
29946
29947 == тест ==
29948
29949 == Hey < # " > % : ' ==
29950 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
29951
29952 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
29953
29954 <!-- These two links should produce identical HTML -->
29955 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
29956
29957 !! html/php
29958 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
29959 <ul>
29960 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
29961 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
29962 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
29963 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
29964 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
29965 <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>
29966 </ul>
29967 </div>
29968
29969 <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>
29970 <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>
29971 <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>
29972 <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>
29973 <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>
29974 <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>
29975 <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>
29976 </p><p>💩 <span id="💩"></span>
29977 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
29978 </p>
29979 !! html/parsoid
29980 <h2 id="Foo_bar"> Foo bar </h2>
29981
29982 <h2 id="foo_Bar_2"> foo Bar </h2>
29983
29984 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span> Тест </h2>
29985
29986 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span> Тест </h2>
29987
29988 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span> тест </h2>
29989
29990 <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>
29991 <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>
29992
29993 <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>
29994
29995 <!-- These two links should produce identical HTML -->
29996 <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>
29997 !! end
29998
29999 # Parsoid doesn't support this mode
30000 !! test
30001 HTML5 ids: legacy with a fallback to modern
30002 !! config
30003 wgFragmentMode=[ 'legacy', 'html5' ]
30004 !! wikitext
30005 == Foo bar ==
30006
30007 == foo Bar ==
30008
30009 == Тест ==
30010
30011 == Тест ==
30012
30013 == тест ==
30014
30015 == Hey < # " > % : ' ==
30016 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30017
30018 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30019
30020 <!-- These two links should produce identical HTML -->
30021 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30022
30023 !! html/php
30024 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
30025 <ul>
30026 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30027 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30028 <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>
30029 <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>
30030 <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>
30031 <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>
30032 </ul>
30033 </div>
30034
30035 <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>
30036 <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>
30037 <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>
30038 <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>
30039 <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>
30040 <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>
30041 <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>
30042 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
30043 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
30044 </p>
30045 !! end
30046
30047 # Parsoid doesn't support this mode.
30048 !! test
30049 HTML5 ids: no legacy
30050 !! config
30051 wgFragmentMode=[ 'html5' ]
30052 !! wikitext
30053 == Foo bar ==
30054
30055 == foo Bar ==
30056
30057 == Тест ==
30058
30059 == Тест ==
30060
30061 == тест ==
30062
30063 == Hey < # " > % : ' ==
30064 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
30065
30066 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
30067
30068 <!-- These two links should produce identical HTML -->
30069 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
30070
30071 !! html/php
30072 <div id="toc" class="toc"><div class="toctitle" lang="en" dir="ltr"><h2>Contents</h2></div>
30073 <ul>
30074 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
30075 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
30076 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
30077 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
30078 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
30079 <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>
30080 </ul>
30081 </div>
30082
30083 <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>
30084 <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>
30085 <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>
30086 <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>
30087 <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>
30088 <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>
30089 <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>
30090 </p><p>💩 <span id="💩"></span>
30091 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
30092 </p>
30093 !! end
30094
30095 !! test
30096 T90902: Normalize weird characters in section IDs
30097 !! config
30098 wgFragmentMode=[ 'html5', 'legacy' ]
30099 !! wikitext
30100 == Foo&nbsp;bar ==
30101 [[#Foo&nbsp;bar]]
30102
30103 !! html/php
30104 <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>
30105 <p><a href="#Foo_bar">#Foo&#160;bar</a>
30106 </p>
30107 !! end
30108
30109 !! test
30110 T51672: Test for brackets in attributes of elements in external link texts
30111 !! wikitext
30112 [http://example.com/ link <span title="title with [brackets]">span</span>]
30113 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
30114
30115 !! html/php
30116 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
30117 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
30118 </p>
30119 !! html/parsoid
30120 <p><a rel="mw:ExtLink" href="http://example.com/">link <span title="title with [brackets]">span</span></a>
30121 <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>
30122 !! end
30123
30124 !! test
30125 T72875: Test for brackets in attributes of elements in internal link texts
30126 !! wikitext
30127 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
30128 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
30129
30130 !! html/php
30131 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
30132 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
30133 </p>
30134 !! html/parsoid
30135 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">link <span title="title with [[double brackets]]">span</span></a>
30136 <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>
30137 !! end
30138
30139 !! test
30140 T179544: {{anchorencode:}} output should be always usable in links
30141 !! config
30142 wgFragmentMode=[ 'html5' ]
30143 !! wikitext
30144 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
30145 !! html/php
30146 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
30147 </p>
30148 !! html/parsoid
30149 <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>
30150 !! end
30151
30152 ## ------------------------------
30153 ## Parsoid section-wrapping tests
30154 ## ------------------------------
30155 !! test
30156 Section wrapping for well-nested sections (no leading content)
30157 !! options
30158 parsoid={
30159 "wrapSections": true
30160 }
30161 !! wikitext
30162 = 1 =
30163 a
30164
30165 = 2 =
30166 b
30167
30168 == 2.1 ==
30169 c
30170
30171 == 2.2 ==
30172 d
30173
30174 === 2.2.1 ===
30175 e
30176
30177 = 3 =
30178 f
30179 !! html/parsoid
30180 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30181 <p>a</p>
30182
30183 </section><section data-mw-section-id="2"><h1 id="2"> 2 </h1>
30184 <p>b</p>
30185
30186 <section data-mw-section-id="3"><h2 id="2.1"> 2.1 </h2>
30187 <p>c</p>
30188
30189 </section><section data-mw-section-id="4"><h2 id="2.2"> 2.2 </h2>
30190 <p>d</p>
30191
30192 <section data-mw-section-id="5"><h3 id="2.2.1"> 2.2.1 </h3>
30193 <p>e</p>
30194
30195 </section></section></section><section data-mw-section-id="6"><h1 id="3"> 3 </h1>
30196 <p>f</p>
30197
30198 </section>
30199 !! end
30200
30201 !! test
30202 Section wrapping for well-nested sections (with leading content)
30203 !! options
30204 parsoid={
30205 "wrapSections": true
30206 }
30207 !! wikitext
30208 Para 1.
30209
30210 Para 2 with a <div>nested in it</div>
30211
30212 Para 3.
30213
30214 = 1 =
30215 a
30216
30217 = 2 =
30218 b
30219
30220 == 2.1 ==
30221 c
30222 !! html/parsoid
30223 <section data-mw-section-id="0"><p>Para 1.</p>
30224
30225 <p>Para 2 with a </p><div>nested in it</div>
30226
30227 <p>Para 3.</p>
30228
30229 </section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30230 <p>a</p>
30231
30232 </section><section data-mw-section-id="2"><h1 id="2"> 2 </h1>
30233 <p>b</p>
30234
30235 <section data-mw-section-id="3"><h2 id="2.1"> 2.1 </h2>
30236 <p>c</p>
30237
30238 </section></section>
30239 !! end
30240
30241 !! test
30242 Section wrapping with template-generated sections (good nesting 1)
30243 !! options
30244 parsoid={
30245 "wrapSections": true
30246 }
30247 !! wikitext
30248 = 1 =
30249 a
30250
30251 {{echo|1=
30252 == 1.1 ==
30253 b
30254 }}
30255
30256 == 1.2 ==
30257 c
30258
30259 = 2 =
30260 d
30261 !! html/parsoid
30262 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30263 <p>a</p>
30264
30265 <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">
30266 </span><p about="#mwt1">b</p>
30267 </section><section data-mw-section-id="3"><h2 id="1.2"> 1.2 </h2>
30268 <p>c</p>
30269
30270 </section></section><section data-mw-section-id="4"><h1 id="2"> 2 </h1>
30271 <p>d</p></section>
30272 !! end
30273
30274 # In this example, the template scope is mildly expanded to incorporate the
30275 # trailing newline after the transclusion since that is part of section 1.1.1
30276 !! test
30277 Section wrapping with template-generated sections (good nesting 2)
30278 !! options
30279 parsoid={
30280 "wrapSections": true,
30281 "modes": ["wt2html", "wt2wt"]
30282 }
30283 !! wikitext
30284 = 1 =
30285 a
30286
30287 {{echo|1=
30288 == 1.1 ==
30289 b
30290 === 1.1.1 ===
30291 d
30292 }}
30293 = 2 =
30294 e
30295 !! html/parsoid
30296 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30297 <p>a</p>
30298
30299 <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">
30300 </span><p about="#mwt1">b</p><span about="#mwt1">
30301 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1"> 1.1.1 </h3><span about="#mwt1">
30302 </span><p about="#mwt1">d</p><span about="#mwt1">
30303 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2"> 2 </h1>
30304 <p>e</p></section>
30305 !! end
30306
30307 # In this example, the template scope is mildly expanded to incorporate the
30308 # trailing newline after the transclusion since that is part of section 1.2.1
30309 !! test
30310 Section wrapping with template-generated sections (good nesting 3)
30311 !! options
30312 parsoid={
30313 "wrapSections": true,
30314 "modes": ["wt2html", "wt2wt"]
30315 }
30316 !! wikitext
30317 = 1 =
30318 a
30319
30320 {{echo|1=
30321 x
30322 == 1.1 ==
30323 b
30324 ==1.2==
30325 c
30326 ===1.2.1===
30327 d
30328 }}
30329 = 2 =
30330 e
30331 !! html/parsoid
30332 <section data-mw-section-id="0"></section><section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
30333 <p>a</p>
30334
30335 <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">
30336 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1"> 1.1 </h2><span about="#mwt1">
30337 </span><p about="#mwt1">b</p><span about="#mwt1">
30338 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
30339 </span><p about="#mwt1">c</p><span about="#mwt1">
30340 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
30341 </span><p about="#mwt1">d</p><span about="#mwt1">
30342 </span></section></section></section><section data-mw-section-id="5"><h1 id="2"> 2 </h1>
30343 <p>e</p></section>
30344 !! end
30345
30346 # Because of section-wrapping and template-wrapping interactions,
30347 # the scope of the template is expanded so that the template markup
30348 # is valid in the presence of <section> tags.
30349 # This exercises the s1 is null scenario in the wrapSections code
30350 !! test
30351 Section wrapping with template-generated sections (bad nesting 1)
30352 !! options
30353 parsoid={
30354 "wrapSections": true
30355 }
30356 !! wikitext
30357 <div>
30358 a
30359
30360 {{echo|
30361 = 1 =
30362 b
30363 }}
30364
30365 c
30366 </div>
30367 !! html/parsoid
30368 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
30369 <p>a</p>
30370
30371 <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"]}'>
30372 </span><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="1"> 1 </h1><span about="#mwt1">
30373 </span><p about="#mwt1">b
30374 </p><span about="#mwt1">
30375
30376 </span><p about="#mwt1">c</p><span about="#mwt1">
30377 </span></section></div></section>
30378 !! end
30379
30380 # Because of section-wrapping and template-wrapping interactions,
30381 # the scope of the template is expanded so that the template markup
30382 # is valid in the presence of <section> tags.
30383 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
30384 !! test
30385 Section wrapping with template-generated sections (bad nesting 2)
30386 !! options
30387 parsoid={
30388 "wrapSections": true
30389 }
30390 !! wikitext
30391 = 1 =
30392 a
30393
30394 {{echo|1=
30395 = 2 =
30396 b
30397 == 2.1 ==
30398 c
30399 }}
30400
30401 d
30402
30403 = 3 =
30404 e
30405 !! html/parsoid
30406 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30407 <p>a</p>
30408
30409 </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">
30410 </span><p about="#mwt1">b</p><span about="#mwt1">
30411 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1"> 2.1 </h2><span about="#mwt1">
30412 </span><p about="#mwt1">c</p><span about="#mwt1">
30413
30414 </span><p about="#mwt1">d</p><span about="#mwt1">
30415
30416 </span></section></section><section data-mw-section-id="4"><h1 id="3"> 3 </h1>
30417 <p>e</p></section>
30418 !! end
30419
30420 # Because of section-wrapping and template-wrapping interactions,
30421 # additional template wrappers are added to <section> tags
30422 # so that template wrapping semantics are valid whether section
30423 # tags are retained or stripped. But, the template scope can expand
30424 # greatly when accounting for section tags.
30425 # This exercises the s1 and s2 are in different subtrees scenario
30426 !! test
30427 Section wrapping with template-generated sections (bad nesting 3)
30428 !! options
30429 parsoid={
30430 "wrapSections": true,
30431 "modes": ["wt2html", "wt2wt"]
30432 }
30433 !! wikitext
30434 = 1 =
30435 a
30436
30437 {{echo|1=
30438 == 1.2 ==
30439 b
30440 = 2 =
30441 c
30442 }}
30443
30444 d
30445
30446 = 3 =
30447 e
30448 !! html/parsoid
30449 <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>
30450 <p>a</p>
30451
30452 <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">
30453 </span><p about="#mwt1">b</p><span about="#mwt1">
30454 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2"> 2 </h1><span about="#mwt1">
30455 </span><p about="#mwt1">c</p>
30456
30457 <p>d</p>
30458 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3"> 3 </h1>
30459 <p>e</p></section>
30460 !! end
30461
30462 !! test
30463 Section wrapping with uneditable lead section + div wrapping multiple sections
30464 !! options
30465 parsoid={
30466 "wrapSections": true
30467 }
30468 !! wikitext
30469 foo
30470
30471 <div style="border:1px solid red;">
30472 = 1 =
30473 a
30474
30475 == 1.1 ==
30476 b
30477
30478 = 2 =
30479 c
30480 </div>
30481
30482 = 3 =
30483 d
30484
30485 == 3.1 ==
30486 e
30487 !! html/parsoid
30488 <section data-mw-section-id="-1"><p>foo</p>
30489
30490 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
30491 <section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30492 <p>a</p>
30493
30494 <section data-mw-section-id="2"><h2 id="1.1"> 1.1 </h2>
30495 <p>b</p>
30496
30497 </section></section><section data-mw-section-id="-1"><h1 id="2"> 2 </h1>
30498 <p>c</p>
30499 </section></div>
30500
30501 </section><section data-mw-section-id="4"><h1 id="3"> 3 </h1>
30502 <p>d</p>
30503
30504 <section data-mw-section-id="5"><h2 id="3.1"> 3.1 </h2>
30505 <p>e</p>
30506 </section></section>
30507 !! end
30508
30509 !! test
30510 Section wrapping with editable lead section + div overlapping multiple sections
30511 !! options
30512 parsoid={
30513 "wrapSections": true
30514 }
30515 !! wikitext
30516 foo
30517
30518 = 1 =
30519 a
30520 <div style="border:1px solid red;">
30521 b
30522
30523 == 1.1 ==
30524 c
30525
30526 = 2 =
30527 d
30528 </div>
30529 e
30530
30531 = 3 =
30532 f
30533
30534 == 3.1 ==
30535 g
30536 !! html/parsoid
30537 <section data-mw-section-id="0"><p>foo</p>
30538
30539 </section><section data-mw-section-id="-1"><h1 id="1"> 1 </h1>
30540 <p>a</p>
30541 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
30542 <p>b</p>
30543
30544 <section data-mw-section-id="2"><h2 id="1.1"> 1.1 </h2>
30545 <p>c</p>
30546
30547 </section><section data-mw-section-id="-1"><h1 id="2"> 2 </h1>
30548 <p>d</p>
30549 </section></div>
30550 <p>e</p>
30551
30552 </section><section data-mw-section-id="4"><h1 id="3"> 3 </h1>
30553 <p>f</p>
30554
30555 <section data-mw-section-id="5"><h2 id="3.1"> 3.1 </h2>
30556 <p>g</p>
30557 </section></section>
30558 !! end
30559
30560 !! test
30561 HTML header tags should not be wrapped in section tags
30562 !! options
30563 parsoid={
30564 "wrapSections": true
30565 }
30566 !! wikitext
30567 foo
30568
30569 <h1>a</h1>
30570
30571 = b =
30572
30573 <h1>c</h1>
30574
30575 = d =
30576 !! html/parsoid
30577 <section data-mw-section-id="0"><p>foo</p>
30578
30579 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
30580
30581 </section><section data-mw-section-id="1"><h1 id="b"> b </h1>
30582
30583 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
30584
30585 </section><section data-mw-section-id="2"><h1 id="d"> d </h1></section>
30586 !! end
30587
30588 !! test
30589 Lead section containing only whitespace and comments.
30590 !! options
30591 parsoid={
30592 "wrapSections": true
30593 }
30594 !! wikitext
30595
30596 <!-- this is a comment, presumably significant to editors -->
30597 = 1 =
30598 a
30599
30600 = 2 =
30601 b
30602 !! html/parsoid
30603 <section data-mw-section-id="0" data-parsoid="{}">
30604 <!-- this is a comment, presumably significant to editors -->
30605 </section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30606 <p>a</p>
30607
30608 </section><section data-mw-section-id="2"><h1 id="2"> 2 </h1>
30609 <p>b</p></section>
30610 !! end