Merge "Avoid blocking locks during API edit stash generation"
[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 !! wikitext
550 == A <nowiki>B
551 C</nowiki> ==
552 !! html
553 <h2><span class="mw-headline" id="A_B.0AC">A B
554 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>
555
556 !! html/parsoid
557 <h2 id="A_B.0AC">A <span typeof="mw:Nowiki">B
558 C</span> </h2>
559 !! end
560
561 !! test
562 Parsing an URL
563 !! wikitext
564 http://fr.wikipedia.org/wiki/🍺
565 <!-- EasterEgg we love beer, better be able be able to link to it -->
566 !! html
567 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
568 </p>
569 !! end
570
571 # Note that the html+tidy output removes the spaces after the <li>,
572 # which is a bug (https://sourceforge.net/p/tidy/bugs/945/, etc).
573 # This is an issue for all tests with lists. We intentionally do
574 # *not* add html+tidy clauses for these, as we don't want to
575 # document/test the broken behavior. (Parsoid matches the non-tidy
576 # output in these cases.)
577
578 !! test
579 Simple list
580 !! wikitext
581 * Item 1
582 * Item 2
583 !! html
584 <ul><li> Item 1</li>
585 <li> Item 2</li></ul>
586
587 !! end
588
589 !! test
590 Italics and bold
591 !! wikitext
592 * plain
593 * plain''italic''plain
594 * plain''italic''plain''italic''plain
595 * plain'''bold'''plain
596 * plain'''bold'''plain'''bold'''plain
597 * plain''italic''plain'''bold'''plain
598 * plain'''bold'''plain''italic''plain
599 * plain''italic'''bold-italic'''italic''plain
600 * plain'''bold''bold-italic''bold'''plain
601 * plain'''''bold-italic'''italic''plain
602 * plain'''''bold-italic''bold'''plain
603 * plain''italic'''bold-italic'''''plain
604 * plain'''bold''bold-italic'''''plain
605 * plain l'''italic''plain
606 * plain l''''bold''' plain
607 !! html
608 <ul><li> plain</li>
609 <li> plain<i>italic</i>plain</li>
610 <li> plain<i>italic</i>plain<i>italic</i>plain</li>
611 <li> plain<b>bold</b>plain</li>
612 <li> plain<b>bold</b>plain<b>bold</b>plain</li>
613 <li> plain<i>italic</i>plain<b>bold</b>plain</li>
614 <li> plain<b>bold</b>plain<i>italic</i>plain</li>
615 <li> plain<i>italic<b>bold-italic</b>italic</i>plain</li>
616 <li> plain<b>bold<i>bold-italic</i>bold</b>plain</li>
617 <li> plain<i><b>bold-italic</b>italic</i>plain</li>
618 <li> plain<b><i>bold-italic</i>bold</b>plain</li>
619 <li> plain<i>italic<b>bold-italic</b></i>plain</li>
620 <li> plain<b>bold<i>bold-italic</i></b>plain</li>
621 <li> plain l'<i>italic</i>plain</li>
622 <li> plain l'<b>bold</b> plain</li></ul>
623
624 !! end
625
626 # this example taken from the [[simple:Moon]] article (T49326)
627 !! test
628 Italics and possessives (1)
629 !! wikitext
630 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
631 !! html
632 <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
633 </p>
634 !! end
635
636 # this example taken from [[en:Flaming Pie]] (T51926)
637 !! test
638 Italics and possessives (2)
639 !! wikitext
640 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
641 !! html
642 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
643 </p>
644 !! end
645
646 # this example taken from [[en:Dictionary]] (T51926)
647 !! test
648 Italics and possessives (3)
649 !! wikitext
650 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''.
651 !! html
652 <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>.
653 </p>
654 !! end
655
656
657 ###
658 ### 2-quote opening sequence tests
659 ###
660 !! test
661 Italics and bold: 2-quote opening sequence: (2,2)
662 !! wikitext
663 ''foo''
664 !! html
665 <p><i>foo</i>
666 </p>
667 !!end
668
669 !! test
670 Italics and bold: 2-quote opening sequence: (2,3)
671 !! wikitext
672 ''foo'''
673 !! html/*
674 <p><i>foo'</i>
675 </p>
676 !!end
677
678 !! test
679 Italics and bold: 2-quote opening sequence: (2,4)
680 !! options
681 parsoid=wt2html
682 !! wikitext
683 ''foo''''
684 !! html/*
685 <p><i>foo''</i>
686 </p>
687 !!end
688
689 # same html as previous, but wikitext adjusted to match parsoid html2wt
690 !! test
691 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
692 !! wikitext
693 ''foo<nowiki>''</nowiki>''
694 !! html
695 <p><i>foo''</i>
696 </p>
697 !! end
698
699 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
700 !! test
701 Italics and bold: 2-quote opening sequence: (2,5)
702 !! options
703 parsoid=wt2html
704 !! wikitext
705 ''foo'''''
706 !! html/php
707 <p><i>foo</i>
708 </p>
709 !! html/parsoid
710 <p><i>foo</i><b></b>
711 </p>
712 !!end
713
714 # same html as previous, but wikitext adjusted to match parsoid html2wt
715 !! test
716 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
717 !! wikitext
718 ''foo'''''<nowiki/>'''
719 !! html/php
720 <p><i>foo</i>
721 </p>
722 !! html/parsoid
723 <p><i>foo</i><b></b>
724 </p>
725 !! end
726
727
728 ###
729 ### 3-quote opening sequence tests
730 ###
731
732 !! test
733 Italics and bold: 3-quote opening sequence: (3,2)
734 !! wikitext
735 '''foo''
736 !! html/*
737 <p>'<i>foo</i>
738 </p>
739 !!end
740
741 !! test
742 Italics and bold: 3-quote opening sequence: (3,3)
743 !! wikitext
744 '''foo'''
745 !! html
746 <p><b>foo</b>
747 </p>
748 !!end
749
750 !! test
751 Italics and bold: 3-quote opening sequence: (3,4)
752 !! wikitext
753 '''foo''''
754 !! html/*
755 <p><b>foo'</b>
756 </p>
757 !!end
758
759 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
760 !! test
761 Italics and bold: 3-quote opening sequence: (3,5)
762 !! options
763 parsoid=wt2html
764 !! wikitext
765 '''foo'''''
766 !! html/php
767 <p><b>foo</b>
768 </p>
769 !! html/parsoid
770 <p><b>foo</b><i></i>
771 </p>
772 !!end
773
774 # same html as previous, but wikitext adjusted to match parsoid html2wt
775 !! test
776 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
777 !! wikitext
778 '''foo'''''<nowiki/>''
779 !! html/php
780 <p><b>foo</b>
781 </p>
782 !! html/parsoid
783 <p><b>foo</b><i></i>
784 </p>
785 !! end
786
787
788 ###
789 ### 4-quote opening sequence tests
790 ###
791
792 !! test
793 Italics and bold: 4-quote opening sequence: (4,2)
794 !! options
795 parsoid=wt2html
796 !! wikitext
797 ''''foo''
798 !! html/*
799 <p>''<i>foo</i>
800 </p>
801 !!end
802
803 # same html as previous, but wikitext adjusted to match parsoid html2wt
804 !! test
805 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
806 !! wikitext
807 <nowiki>''</nowiki>''foo''
808 !! html
809 <p>''<i>foo</i>
810 </p>
811 !! end
812
813 !! test
814 Italics and bold: 4-quote opening sequence: (4,3)
815 !! wikitext
816 ''''foo'''
817 !! html/*
818 <p>'<b>foo</b>
819 </p>
820 !!end
821
822 !! test
823 Italics and bold: 4-quote opening sequence: (4,4)
824 !! options
825 parsoid=wt2html
826 !! wikitext
827 ''''foo''''
828 !! html/*
829 <p>'<b>foo'</b>
830 </p>
831 !!end
832
833 # same html as previous, but wikitext adjusted to match parsoid html2wt
834 !! test
835 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
836 !! wikitext
837 '<nowiki/>'''foo''''
838 !! html
839 <p>'<b>foo'</b>
840 </p>
841 !! end
842
843 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
844 !! test
845 Italics and bold: 4-quote opening sequence: (4,5)
846 !! options
847 parsoid=wt2html
848 !! wikitext
849 ''''foo'''''
850 !! html/php
851 <p>'<b>foo</b>
852 </p>
853 !! html/parsoid
854 <p>'<b>foo</b><i></i>
855 </p>
856 !!end
857
858 # same html as previous, but wikitext adjusted to match parsoid html2wt
859 !! test
860 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
861 !! wikitext
862 '<nowiki/>'''foo'''''<nowiki/>''
863 !! html/php
864 <p>'<b>foo</b>
865 </p>
866 !! html/parsoid
867 <p>'<b>foo</b><i></i>
868 </p>
869 !! end
870
871
872 ###
873 ### 5-quote opening sequence tests
874 ###
875
876 !! test
877 Italics and bold: 5-quote opening sequence: (5,2)
878 !! options
879 parsoid=wt2html
880 !! wikitext
881 '''''foo''
882 !! html/*
883 <p><b><i>foo</i></b>
884 </p>
885 !!end
886
887 # same html as previous, but wikitext adjusted to match parsoid html2wt
888 !! test
889 Italics and bold: 5-quote opening sequence: (5,2+3)
890 !! wikitext
891 '''''foo'''''
892 !! html/*
893 <p><i><b>foo</b></i>
894 </p>
895 !! end
896
897 !! test
898 Italics and bold: 5-quote opening sequence: (5,3)
899 !! options
900 parsoid=wt2html
901 !! wikitext
902 '''''foo'''
903 !! html/*
904 <p><i><b>foo</b></i>
905 </p>
906 !!end
907
908 # same html as previous, but wikitext adjusted to match parsoid html2wt
909 !! test
910 Italics and bold: 5-quote opening sequence: (5,3+2)
911 !! wikitext
912 '''''foo'''''
913 !! html
914 <p><i><b>foo</b></i>
915 </p>
916 !! end
917
918 !! test
919 Italics and bold: 5-quote opening sequence: (5,4)
920 !! options
921 parsoid=wt2html
922 !! wikitext
923 '''''foo''''
924 !! html/*
925 <p><i><b>foo'</b></i>
926 </p>
927 !!end
928
929 !! test
930 Italics and bold: 5-quote opening sequence: (5,5)
931 !! wikitext
932 '''''foo'''''
933 !! html
934 <p><i><b>foo</b></i>
935 </p>
936 !!end
937
938 !! test
939 Italics and bold: 5-quote opening sequence: (5,6)
940 !! wikitext
941 '''''foo''''''
942 !! html/*
943 <p><i><b>foo'</b></i>
944 </p>
945 !! end
946
947 ###
948 ### multiple quote sequences in a line
949 ###
950
951 !! test
952 Italics and bold: multiple quote sequences: (2,4,2)
953 !! options
954 parsoid=wt2html
955 !! wikitext
956 ''foo''''bar''
957 !! html/*
958 <p><i>foo'<b>bar</b></i>
959 </p>
960 !! end
961
962 # same html as previous, but wikitext adjusted to match parsoid html2wt
963 !! test
964 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
965 !! wikitext
966 ''foo'<nowiki/>'''bar'''''
967 !! html
968 <p><i>foo'<b>bar</b></i>
969 </p>
970 !! end
971
972 !! test
973 Italics and bold: multiple quote sequences: (2,4,3)
974 !! options
975 parsoid=wt2html
976 !! wikitext
977 ''foo''''bar'''
978 !! html/*
979 <p><i>foo'<b>bar</b></i>
980 </p>
981 !! end
982
983 # same html as previous, but wikitext adjusted to match parsoid html2wt
984 !! test
985 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
986 !! wikitext
987 ''foo'<nowiki/>'''bar'''''
988 !! html
989 <p><i>foo'<b>bar</b></i>
990 </p>
991 !! end
992
993 !! test
994 Italics and bold: multiple quote sequences: (2,4,4)
995 !! options
996 parsoid=wt2html
997 !! wikitext
998 ''foo''''bar''''
999 !! html/*
1000 <p><i>foo'<b>bar'</b></i>
1001 </p>
1002 !! end
1003
1004 # same html as previous, but wikitext adjusted to match parsoid html2wt
1005 !! test
1006 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
1007 !! wikitext
1008 ''foo'<nowiki/>'''bar'<nowiki/>'''''
1009 !! html
1010 <p><i>foo'<b>bar'</b></i>
1011 </p>
1012 !! end
1013
1014 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1015 !! test
1016 Italics and bold: multiple quote sequences: (3,4,2)
1017 !! options
1018 parsoid=wt2html
1019 !! wikitext
1020 '''foo''''bar''
1021 !! html/php
1022 <p><b>foo'</b>bar
1023 </p>
1024 !! html/parsoid
1025 <p><b>foo'</b>bar<i></i>
1026 </p>
1027 !! end
1028
1029 # same html as previous, but wikitext adjusted to match parsoid html2wt
1030 !! test
1031 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1032 !! wikitext
1033 '''foo''''bar''<nowiki/>''
1034 !! html/php
1035 <p><b>foo'</b>bar
1036 </p>
1037 !! html/parsoid
1038 <p><b>foo'</b>bar<i></i>
1039 </p>
1040 !! end
1041
1042 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1043 !! test
1044 Italics and bold: multiple quote sequences: (3,4,3)
1045 !! options
1046 parsoid=wt2html
1047 !! wikitext
1048 '''foo''''bar'''
1049 !! html/php
1050 <p><b>foo'</b>bar
1051 </p>
1052 !! html/parsoid
1053 <p><b>foo'</b>bar<b></b>
1054 </p>
1055 !! end
1056
1057 # same html as previous, but wikitext adjusted to match parsoid html2wt
1058 !! test
1059 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1060 !! wikitext
1061 '''foo''''bar'''<nowiki/>'''
1062 !! html/php
1063 <p><b>foo'</b>bar
1064 </p>
1065 !! html/parsoid
1066 <p><b>foo'</b>bar<b></b>
1067 </p>
1068 !! end
1069
1070 ###
1071 ### other quote tests
1072 ###
1073 !! test
1074 Italics and bold: other quote tests: (2,3,5)
1075 !! wikitext
1076 ''this is about '''foo's family'''''
1077 !! html
1078 <p><i>this is about <b>foo's family</b></i>
1079 </p>
1080 !!end
1081
1082
1083 !! test
1084 Italics and bold: other quote tests: (2,(3,3),2)
1085 !! wikitext
1086 ''this is about '''foo's''' family''
1087 !! html
1088 <p><i>this is about <b>foo's</b> family</i>
1089 </p>
1090 !!end
1091
1092
1093 !! test
1094 Italics and bold: other quote tests: (3,2,3,2)
1095 !! options
1096 parsoid=wt2html
1097 !! wikitext
1098 '''this is about ''foo'''s family''
1099 !! html/*
1100 <p><b>this is about <i>foo</i></b><i>s family</i>
1101 </p>
1102 !!end
1103
1104
1105 # same html as previous, but wikitext adjusted to match parsoid html2wt
1106 !! test
1107 Italics and bold: other quote tests: (3,2,3+2+2,2)
1108 !! wikitext
1109 '''this is about ''foo'''''<nowiki/>''s family''
1110 !! html
1111 <p><b>this is about <i>foo</i></b><i>s family</i>
1112 </p>
1113 !! end
1114
1115
1116 !! test
1117 Italics and bold: other quote tests: (3,2,3,3)
1118 !! wikitext
1119 '''this is about ''foo'''s family'''
1120 !! html/*
1121 <p>'<i>this is about </i>foo<b>s family</b>
1122 </p>
1123 !!end
1124
1125
1126 !! test
1127 Italics and bold: other quote tests: (3,(2,2),3)
1128 !! wikitext
1129 '''this is about ''foo's'' family'''
1130 !! html
1131 <p><b>this is about <i>foo's</i> family</b>
1132 </p>
1133 !!end
1134
1135
1136 !! test
1137 Italicized possessive
1138 !! wikitext
1139 The ''[[Main Page]]'''s talk page.
1140 !! html/php
1141 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1142 </p>
1143 !! html/parsoid
1144 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1145 !! end
1146
1147 !! test
1148 Parsoid only: Quote balancing context should be restricted to td/th cells on the same wikitext line
1149 (Requires tidy for PHP parser output to be fixed up)
1150 !! options
1151 parsoid=wt2html,wt2wt
1152 !! wikitext
1153 {|
1154 !''a!!''b
1155 |''a||''b
1156 |}
1157 !! html/php+tidy
1158 <table>
1159 <tr>
1160 <th><i>a</i></th>
1161 <th><i>b</i></th>
1162 <td><i>a</i></td>
1163 <td><i>b</i></td>
1164 </tr>
1165 </table>
1166 !! html/parsoid
1167 <table>
1168 <tbody><tr><th><i>a</i></th><th><i>b</i></th>
1169 <td><i>a</i></td><td><i>b</i></td></tr>
1170 </tbody></table>
1171 !! end
1172
1173 ###
1174 ### Non-html5 tags
1175 ###
1176
1177 !! test
1178 Non-html5 tags should be accepted
1179 !! wikitext
1180 <center>''foo''</center>
1181 <big>''foo''</big>
1182 <font>''foo''</font>
1183 <strike>''foo''</strike>
1184 <tt>''foo''</tt>
1185 !! html
1186 <center><i>foo</i></center>
1187 <p><big><i>foo</i></big>
1188 <font><i>foo</i></font>
1189 <strike><i>foo</i></strike>
1190 <tt><i>foo</i></tt>
1191 </p>
1192 !! end
1193
1194 !! test
1195 <wbr> is valid wikitext (T54468)
1196 !! wikitext
1197 <wbr>
1198 !! html
1199 <p><wbr />
1200 </p>
1201 !! end
1202
1203 # <strike> is HTML4, <s> is HTML4/5.
1204 !! test
1205 <s> or <strike> for strikethrough
1206 !! wikitext
1207 <strike>strike</strike>
1208
1209 <s>s</s>
1210 !! html
1211 <p><strike>strike</strike>
1212 </p><p><s>s</s>
1213 </p>
1214 !! end
1215
1216 ## a not permitted
1217 ## i,b,br omitted
1218 !! test
1219 Text-level semantic html elements in wikitext
1220 !! wikitext
1221 <em>text</em>
1222 <strong>text</strong>
1223 <small>text</small>
1224 <s>text</s>
1225 <cite>text</cite>
1226 <q>text</q>
1227 <dfn>text</dfn>
1228 <abbr>text</abbr>
1229 <data>text</data>
1230 <time>text</time>
1231 <code>text</code>
1232 <var>text</var>
1233 <samp>text</samp>
1234 <kbd>text</kbd>
1235 <sub>text</sub>
1236 <u>text</u>
1237 <mark>text</mark>
1238 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1239 <bdi>text</bdi>
1240 <bdo>text</bdo>
1241 <span>text</span>
1242 <wbr />
1243 !! html
1244 <p><em>text</em>
1245 <strong>text</strong>
1246 <small>text</small>
1247 <s>text</s>
1248 <cite>text</cite>
1249 <q>text</q>
1250 <dfn>text</dfn>
1251 <abbr>text</abbr>
1252 <data>text</data>
1253 <time>text</time>
1254 <code>text</code>
1255 <var>text</var>
1256 <samp>text</samp>
1257 <kbd>text</kbd>
1258 <sub>text</sub>
1259 <u>text</u>
1260 <mark>text</mark>
1261 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1262 <bdi>text</bdi>
1263 <bdo>text</bdo>
1264 <span>text</span>
1265 <wbr />
1266 </p>
1267 !! end
1268
1269 # test cases taken from
1270 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1271 !! test
1272 Ruby markup (W3C-style)
1273 !! wikitext
1274 ; Mono-ruby for individual base characters
1275 : <ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1276 ; Group ruby
1277 : <ruby>今日<rt>きょう</rt></ruby>
1278 ; Jukugo ruby
1279 : <ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1280 ; Inline ruby
1281 : <ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1282 ; Double-sided ruby
1283 : <ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1284 <ruby>
1285 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1286 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1287 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1288 </ruby>
1289 !! html
1290 <dl><dt> Mono-ruby for individual base characters</dt>
1291 <dd> <ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1292 <dt> Group ruby</dt>
1293 <dd> <ruby>今日<rt>きょう</rt></ruby></dd>
1294 <dt> Jukugo ruby</dt>
1295 <dd> <ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1296 <dt> Inline ruby</dt>
1297 <dd> <ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1298 <dt> Double-sided ruby</dt>
1299 <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>
1300 <p><ruby>
1301 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1302 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1303 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1304 </ruby>
1305 </p>
1306 !! end
1307
1308 # The next two test different paths in the sanitizer.
1309 !! test
1310 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1311 !! wikitext
1312 <blockquote|>a</blockquote>
1313
1314 <b→> doesn't terminate </b→>
1315
1316 <bä> doesn't terminate </bä>
1317
1318 <boo> doesn't terminate </boo>
1319
1320 <s.foo> doesn't terminate </s.foo>
1321
1322 <sub-ID#1>
1323 !! html
1324 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1325 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1326 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1327 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1328 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1329 </p><p>&lt;sub-ID#1&gt;
1330 </p>
1331 !! end
1332
1333 # There is a tidy bug here: https://sourceforge.net/p/tidy/bugs/946/
1334 # If the non-word-character tag made it through the sanitizer, tidy
1335 # would munge it up.
1336 !! test
1337 Non-word characters don't terminate tag names + tidy
1338 !! wikitext
1339 <blockquote|>a</blockquote>
1340
1341 <b→> doesn't terminate </b→>
1342
1343 <bä> doesn't terminate </bä>
1344
1345 <boo> doesn't terminate </boo>
1346
1347 <s.foo> doesn't terminate </s.foo>
1348
1349 <sub-ID#1>
1350 !! html+tidy
1351 <p>&lt;blockquote|&gt;a</p>
1352 <p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;</p>
1353 <p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;</p>
1354 <p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;</p>
1355 <p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;</p>
1356 <p>&lt;sub-ID#1&gt;</p>
1357 !! end
1358
1359 ###
1360 ### See tests/parser/parserTestsParserHook.php for the <tåg> extension)
1361 ### This checks that HTML5 tags (with non-word characters in the tag
1362 ### name) make it safely through the parser -- the Sanitizer will
1363 ### munge them later, as it should.
1364 ###
1365 !! test
1366 Non-word characters are valid in extension tags (T19663)
1367 !! wikitext
1368 <tåg>tåg</tåg>
1369 !! html/php
1370 <pre>
1371 'tåg'
1372 array (
1373 )
1374 </pre>
1375
1376 !! html/parsoid
1377 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1378 !! end
1379
1380 !! test
1381 Isolated close tags should be treated as literal text (T54760)
1382 !! options
1383 parsoid=wt2html
1384 !! wikitext
1385 </b>
1386
1387 <s.foo>s</s>
1388 !! html/php+tidy
1389 <p>&lt;s.foo&gt;s</p>
1390 !! html/parsoid
1391 <p>&lt;s.foo&gt;s</p>
1392 !! end
1393
1394 ###
1395 ### Special characters
1396 ###
1397
1398 !! test
1399 Bare pipe character (T54363)
1400 !! wikitext
1401 |
1402 !! html
1403 <p>|
1404 </p>
1405 !! end
1406
1407 !! test
1408 Bare pipe character from a template (T54363)
1409 !! wikitext
1410 {{pipe}}
1411 !! html
1412 <p>|
1413 </p>
1414 !! end
1415
1416 ###
1417 ### <nowiki> test cases
1418 ###
1419
1420 !! test
1421 <nowiki> unordered list
1422 !! wikitext
1423 <nowiki>* This is not an unordered list item.</nowiki>
1424 !! html/php
1425 <p>* This is not an unordered list item.
1426 </p>
1427 !! html/parsoid
1428 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1429 !! end
1430
1431 !! test
1432 <nowiki> spacing
1433 !! wikitext
1434 <nowiki>Lorem ipsum dolor
1435
1436 sed abit.
1437 sed nullum.
1438
1439 :and a colon
1440 </nowiki>
1441 !! html/php
1442 <p>Lorem ipsum dolor
1443
1444 sed abit.
1445 sed nullum.
1446
1447 :and a colon
1448
1449 </p>
1450 !! html/parsoid
1451 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1452
1453 sed abit.
1454 sed nullum.
1455
1456 :and a colon
1457 </span></p>
1458 !! end
1459
1460 !! test
1461 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1462 !! wikitext
1463 <nowiki><span class="error"></nowiki>
1464 !! html/php
1465 <p>&lt;span class="error"&gt;
1466 </p>
1467 !! html/parsoid
1468 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1469 !! end
1470
1471 !! test
1472 nowiki 3
1473 !! wikitext
1474 :There is not nowiki.
1475 :There is <nowiki>nowiki</nowiki>.
1476
1477 #There is not nowiki.
1478 #There is <nowiki>nowiki</nowiki>.
1479
1480 *There is not nowiki.
1481 *There is <nowiki>nowiki</nowiki>.
1482 !! html/php
1483 <dl><dd>There is not nowiki.</dd>
1484 <dd>There is nowiki.</dd></dl>
1485 <ol><li>There is not nowiki.</li>
1486 <li>There is nowiki.</li></ol>
1487 <ul><li>There is not nowiki.</li>
1488 <li>There is nowiki.</li></ul>
1489
1490 !! html/parsoid
1491 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1492 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1493
1494 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1495 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1496
1497 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1498 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1499 !! end
1500
1501 !! test
1502 Entities inside <nowiki>
1503 !! wikitext
1504 <nowiki>&lt;</nowiki>
1505 !! html/php
1506 <p>&lt;
1507 </p>
1508 !! html/parsoid
1509 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1510 !! end
1511
1512 !! test
1513 Entities inside template parameters
1514 !! wikitext
1515 {{echo|&ndash;}}
1516 !! html/php+tidy
1517 <p>–</p>
1518 !! html/parsoid
1519 <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>
1520 !! end
1521
1522 !! test
1523 Properly escape nowiki when combined with other wiki markup
1524 !! options
1525 parsoid=html2wt
1526 !! html/parsoid
1527 <p>* &lt;/nowiki&gt; tag</p>
1528 !! wikitext
1529 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1530 !! end
1531
1532 !! test
1533 T93824: Put escaped HTML tags inside nowiki
1534 !! options
1535 parsoid=html2wt
1536 !! html/parsoid
1537 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1538 !! wikitext
1539 <nowiki><h2>foo</h2></nowiki>
1540 !! end
1541
1542 !! test
1543 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1544 !! options
1545 parsoid=html2wt
1546 !! html/parsoid
1547 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1548 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1549 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1550 !! wikitext
1551 This text: L'[[Foo]]
1552 This text: L<nowiki>''</nowiki>[[Foo]]
1553 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1554 !! end
1555
1556 # This test fails because wikitext whitespace is not normalized before comparing.
1557 !! test
1558 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1559 !! options
1560 parsoid=html2wt
1561 !! html/parsoid
1562 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1563 </p>
1564 !! wikitext
1565 This text : L<nowiki>''</nowiki>[[Foo]]
1566 !! end
1567
1568 # This test and the next one are html2wt only as they test that incorrect wikitext
1569 # passed in template arguments gets escaped or wrapped in nowikis where required.
1570 !! test
1571 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1572 !! options
1573 parsoid=html2wt
1574 !! html/parsoid
1575 <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>
1576 <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>
1577 !! wikitext
1578 {{echo|foo{{!}}bar}}
1579 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1580 !! end
1581
1582 !! test
1583 T53961: Output correct nowikis in template arguments
1584 !! options
1585 parsoid=html2wt
1586 !! html/parsoid
1587 <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>
1588 <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>
1589 <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>
1590 <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>
1591 <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>
1592 !! wikitext
1593 {{echo|a [ b}}
1594 {{echo|<nowiki>a }} b</nowiki>}}
1595 {{echo|<nowiki>a [[ b</nowiki>}}
1596 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1597 {{echo|a <nowiki>}</nowiki>}}
1598 !! end
1599
1600 !! test
1601 Cases where "!!" needs nowiki protection
1602 !! options
1603 parsoid=html2wt
1604 !! html/parsoid
1605 <table>
1606 <tr><th>this needs protection !! here</th></tr>
1607 </table>
1608
1609 <table>
1610 <tr><th>this does not need
1611 protection !! here</th></tr>
1612 </table>
1613 !! wikitext
1614 {|
1615 !<nowiki>this needs protection !! here</nowiki>
1616 |}
1617
1618 {|
1619 !this does not need
1620 protection !! here
1621 |}
1622 !! end
1623
1624 ###
1625 ### Comments
1626 ###
1627 !! test
1628 Comments and Indent-Pre
1629 !! wikitext
1630 <!-- comment 1 --> asdf
1631
1632 <!-- comment 1 --> asdf
1633 <!-- comment 2 -->
1634
1635 <!-- comment 1 --> asdf
1636 <!-- comment 2 -->xyz
1637
1638 <!-- comment 1 --> asdf
1639 <!-- comment 2 --> xyz
1640 !! html
1641 <pre>asdf
1642 </pre>
1643 <pre>asdf
1644 </pre>
1645 <pre>asdf
1646 </pre>
1647 <p>xyz
1648 </p>
1649 <pre>asdf
1650 xyz
1651 </pre>
1652 !! end
1653
1654 !! test
1655 Comment test 2a
1656 !! wikitext
1657 asdf
1658 <!-- comment 1 -->
1659 jkl
1660 !! html
1661 <p>asdf
1662 jkl
1663 </p>
1664 !! end
1665
1666 !! test
1667 Comment test 2b
1668 !! wikitext
1669 asdf
1670 <!-- comment 1 -->
1671
1672 jkl
1673 !! html
1674 <p>asdf
1675 </p><p>jkl
1676 </p>
1677 !! end
1678
1679 !! test
1680 Comment test 3
1681 !! wikitext
1682 asdf
1683 <!-- comment 1 -->
1684 <!-- comment 2 -->
1685 jkl
1686 !! html
1687 <p>asdf
1688 jkl
1689 </p>
1690 !! end
1691
1692 !! test
1693 Comment test 4
1694 !! wikitext
1695 asdf<!-- comment 1 -->jkl
1696 !! html
1697 <p>asdfjkl
1698 </p>
1699 !! end
1700
1701 !! test
1702 Comment spacing
1703 !! wikitext
1704 a
1705 <!-- foo --> b <!-- bar -->
1706 c
1707 !! html
1708 <p>a
1709 </p>
1710 <pre> b
1711 </pre>
1712 <p>c
1713 </p>
1714 !! end
1715
1716 !! test
1717 Comment whitespace
1718 !! wikitext
1719 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1720 !! html
1721
1722 !! end
1723
1724 !! test
1725 Comment semantics and delimiters
1726 !! wikitext
1727 <!-- --><!----><!-----><!------>
1728 !! html/php
1729
1730 !! html/parsoid
1731 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1732 !! end
1733
1734 !! test
1735 Comment semantics and delimiters, redux
1736 !! wikitext
1737 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1738 -- foo -- funky huh? ... -->
1739 !! html/php
1740
1741 !! html/parsoid
1742 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1743 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1744 !! end
1745
1746 !! test
1747 Comment semantics and delimiters: directors cut
1748 !! wikitext
1749 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1750 everything starting with < followed by !-- until the first -- and > we see,
1751 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1752 -->-->
1753 !! html/php
1754 <p>--&gt;
1755 </p>
1756 !! html/parsoid
1757 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1758 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1759 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1760 --><p>--></p>
1761 !! end
1762
1763 !! test
1764 Comment semantics: nesting
1765 !! wikitext
1766 <!--<!-- no, we're not going to do anything fancy here -->-->
1767 !! html/php
1768 <p>--&gt;
1769 </p>
1770 !! html/parsoid
1771 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1772 !! end
1773
1774 # Parsoid closes the unclosed comment, even if it means a slight
1775 # round-trip diff.
1776 !! test
1777 Comment semantics: unclosed comment at end
1778 !! options
1779 parsoid=wt2html,html2html
1780 !! wikitext
1781 <!--This comment will run out to the end of the document
1782 !! html/php
1783
1784 !! html/parsoid
1785 <!--This comment will run out to the end of the document-->
1786 !! end
1787
1788 !! test
1789 Comment semantics: normalize comments to play nice with XML and browsers
1790 !! wikitext
1791 <!-- Browsers --!> think this is closed -->
1792 <!--> This would normally be text -->
1793 <!---> As would this -->
1794 <!-- XML doesn't like trailing dashes -------->
1795 <!-- Nor doubled hyphens -- anywhere in the data -->
1796 But this is not a comment.
1797 !! html/php
1798 <p>But this is not a comment.
1799 </p>
1800 !! html/parsoid
1801 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1802 <!--&#x3E; This would normally be text -->
1803 <!--&#x2D;&#x3E; As would this -->
1804 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1805 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1806 <p>But this is not a comment.</p>
1807 !! end
1808
1809 !! test
1810 Comment semantics: round-trip even text which contains encoded -->
1811 !! wikitext
1812 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1813 !! html/parsoid
1814 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1815 !! end
1816
1817 !! test
1818 Comment in template title
1819 !! wikitext
1820 {{f<!---->oo}}
1821 !! html
1822 <p>FOO
1823 </p>
1824 !! end
1825
1826 !! test
1827 Comment on its own line post-expand
1828 !! wikitext
1829 a
1830 {{blank}}<!---->
1831 b
1832 !! html
1833 <p>a
1834 </p><p>b
1835 </p>
1836 !! end
1837
1838 !! test
1839 Comment on its own line post-expand with non-significant whitespace
1840 !! wikitext
1841 a
1842 {{blank}} <!---->
1843 b
1844 !! html
1845 <p>a
1846 </p><p>b
1847 </p>
1848 !! end
1849
1850 !! test
1851 Multiple comments should still parse as SOL-transparent
1852 !! options
1853 parsoid=wt2html,wt2wt
1854 !! wikitext
1855 <!--c1-->*a
1856 <!--c2--><!--c3--><!--c4-->*b
1857 !! html/php
1858 <ul><li>a</li>
1859 <li>b</li></ul>
1860
1861 !! html/parsoid
1862 <!--c1--><ul>
1863 <li>a
1864 </li>
1865 <!--c2--><!--c3--><!--c4-->
1866 <li>b
1867 </li>
1868 </ul>
1869 !! end
1870
1871 ## Make sure ">" gets escaped in comments to avoid XSS
1872 !! test
1873 IE conditional comments
1874 !! wikitext
1875 <!--[if lt IE 9]>
1876 <script>alert('hi');</script>
1877 <![endif]-->
1878 !! html/parsoid
1879 <!--[if lt IE 9]&#x3E;
1880 <script&#x3E;alert('hi');</script&#x3E;
1881 <![endif]-->
1882 !! end
1883
1884 ###
1885 ### paragraph wrapping tests
1886 ###
1887 !! test
1888 No block tags
1889 !! wikitext
1890 a
1891
1892 b
1893 !! html
1894 <p>a
1895 </p><p>b
1896 </p>
1897 !! end
1898
1899 !! test
1900 Block tag on one line (<div>)
1901 !! wikitext
1902 a <div>foo</div>
1903
1904 b
1905 !! html
1906 a <div>foo</div>
1907 <p>b
1908 </p>
1909 !! html+tidy
1910 <p>a</p>
1911 <div>foo</div>
1912 <p>b</p>
1913 !! end
1914
1915 !! test
1916 No p-wrappable content
1917 !! wikitext
1918 <span><div>x</div></span>
1919 <span><s><div>x</div></s></span>
1920 <small><em></em></small><span><s><div>x</div></s></span>
1921 !! html+tidy
1922 <div><span>x</span></div>
1923 <div><span><s>x</s></span></div>
1924 <div><span><s>x</s></span></div>
1925 !! html/parsoid
1926 <span><div>x</div></span>
1927 <span><s><div>x</div></s></span>
1928 <small><em></em></small><span><s><div>x</div></s></span>
1929 !! end
1930
1931 # T177612: Parsoid-only test
1932 !! test
1933 Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
1934 !! wikitext
1935 {{echo|<span><div>x</div></span>}}
1936 x
1937 !! html/parsoid
1938 <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>
1939 <p>x</p>
1940 !! end
1941
1942 !! test
1943 Block tag on one line (<blockquote>)
1944 !! wikitext
1945 a <blockquote>foo</blockquote>
1946
1947 b
1948 !! html
1949 a <blockquote>foo</blockquote>
1950 <p>b
1951 </p>
1952 !! html+tidy
1953 <p>a</p>
1954 <blockquote>
1955 <p>foo</p>
1956 </blockquote>
1957 <p>b</p>
1958 !! end
1959
1960 !! test
1961 Block tag on both lines (<div>)
1962 !! wikitext
1963 a <div>foo</div>
1964
1965 b <div>foo</div>
1966 !! html
1967 a <div>foo</div>
1968 b <div>foo</div>
1969
1970 !! html+tidy
1971 <p>a</p>
1972 <div>foo</div>
1973 <p>b</p>
1974 <div>foo</div>
1975 !! end
1976
1977 !! test
1978 Block tag on both lines (<blockquote>)
1979 !! wikitext
1980 a <blockquote>foo</blockquote>
1981
1982 b <blockquote>foo</blockquote>
1983 !! html
1984 a <blockquote>foo</blockquote>
1985 b <blockquote>foo</blockquote>
1986
1987 !! html+tidy
1988 <p>a</p>
1989 <blockquote>
1990 <p>foo</p>
1991 </blockquote>
1992 <p>b</p>
1993 <blockquote>
1994 <p>foo</p>
1995 </blockquote>
1996 !! end
1997
1998 !! test
1999 Multiple lines without block tags
2000 !! wikitext
2001 <div>foo</div> a
2002 b
2003 c
2004 d<!--foo--> e
2005 x <div>foo</div> z
2006 !! html
2007 <div>foo</div> a
2008 <p>b
2009 c
2010 d e
2011 </p>
2012 x <div>foo</div> z
2013
2014 !! html+tidy
2015 <div>foo</div>
2016 <p>a</p>
2017 <p>b c d e</p>
2018 <p>x</p>
2019 <div>foo</div>
2020 <p>z</p>
2021 !! end
2022
2023 # Tidy strips out the empty <div> tags. Parsoid doesn't.
2024 # So, we have a separate section for Parsoid. We don't want
2025 # to mimic this stripping behavior in Parsoid. It affects
2026 # editing experience and also requires us to maintain additional
2027 # info for RT-ing.
2028 !! test
2029 Empty lines between lines with block tags
2030 !! wikitext
2031 <div></div>
2032
2033
2034 <div></div>a
2035
2036 b
2037 <div>a</div>b
2038
2039 <div>b</div>d
2040
2041
2042 <div>e</div>
2043 !! html
2044 <div></div>
2045 <p><br />
2046 </p>
2047 <div></div>a
2048 <p>b
2049 </p>
2050 <div>a</div>b
2051 <div>b</div>d
2052 <p><br />
2053 </p>
2054 <div>e</div>
2055
2056 !! html+tidy
2057 <p><br /></p>
2058 <p>a</p>
2059 <p>b</p>
2060 <div>a</div>
2061 <p>b</p>
2062 <div>b</div>
2063 <p>d</p>
2064 <p><br /></p>
2065 <div>e</div>
2066 !! html/parsoid
2067 <div data-parsoid='{"stx":"html"}'></div>
2068
2069 <p><br /></p>
2070 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2071
2072 <p>b</p>
2073 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2074
2075 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2076
2077 <p><br /></p>
2078 <div data-parsoid='{"stx":"html"}'>e</div>
2079 !! end
2080
2081 ## PHP parser emits output which is broken
2082 !! test
2083 Unclosed HTML p-tags should be handled properly
2084 !! wikitext
2085 <div><p>foo</div>
2086 a
2087
2088 b
2089 !! html/php+tidy
2090 <div>
2091 <p>foo</p>
2092 </div>
2093 <p>a</p>
2094 <p>b</p>
2095 !! html/parsoid
2096 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2097 <p>a</p>
2098 <p>b</p>
2099 !! end
2100
2101 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2102 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2103 ## them for now.
2104 !! test
2105 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2106 !! options
2107 parsoid=wt2html
2108 !! wikitext
2109 a [[Category:A1]] [[Category:A2]]
2110 [[Category:A3]]
2111 [[Category:A4]]
2112 !! html/parsoid
2113 <p>a</p>
2114 <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"/>
2115 !! end
2116
2117 !! test
2118 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2119 !! options
2120 parsoid=wt2html
2121 !! wikitext
2122 [[Category:A1]]a
2123 !! html/parsoid
2124 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2125 !! end
2126
2127 ###
2128 ### Preformatted text
2129 ###
2130 !! test
2131 Preformatted text
2132 !! wikitext
2133 This is some
2134 Preformatted text
2135 With ''italic''
2136 And '''bold'''
2137 And a [[Main Page|link]]
2138 !! html
2139 <pre>This is some
2140 Preformatted text
2141 With <i>italic</i>
2142 And <b>bold</b>
2143 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2144 </pre>
2145 !! end
2146
2147 !! test
2148 Tabs don't trigger preformatted text
2149 !! wikitext
2150 This is not
2151 preformatted text.
2152 This is preformatted text.
2153 So is this.
2154 !! html/php
2155 <p> This is not
2156 preformatted text.
2157 </p>
2158 <pre>This is preformatted text.
2159 So is this.
2160 </pre>
2161 !! html/parsoid
2162 <p> This is not
2163 preformatted text.</p>
2164 <pre>This is preformatted text.
2165 So is this.</pre>
2166 !! end
2167
2168 !! test
2169 Space before tab needs nowiki pre protection
2170 !! options
2171 parsoid=html2wt
2172 !! html/parsoid
2173 <p> a</p>
2174 !! wikitext
2175 <nowiki> </nowiki> a
2176 !! end
2177
2178 !! test
2179 Ident preformatting with inline content
2180 !! wikitext
2181 a
2182 ''b''
2183 !! html
2184 <pre>a
2185 <i>b</i>
2186 </pre>
2187 !! end
2188
2189 !! test
2190 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2191 !! wikitext
2192 <pre><nowiki>
2193 <b>
2194 <cite>
2195 <em>
2196 </nowiki></pre>
2197 !! html
2198 <pre>
2199 &lt;b&gt;
2200 &lt;cite&gt;
2201 &lt;em&gt;
2202 </pre>
2203
2204 !! end
2205
2206 !! test
2207 Regression with preformatted in <center>
2208 !! wikitext
2209 <center>
2210 Blah
2211 </center>
2212 !! html
2213 <center>
2214 <pre>Blah
2215 </pre>
2216 </center>
2217
2218 !! end
2219
2220 !! test
2221 T54763: Preformatted in <blockquote>
2222 !! wikitext
2223 <blockquote>
2224 Blah
2225 {|
2226 |
2227 indented cell (no pre-wrapping!)
2228 |}
2229 </blockquote>
2230 !! html
2231 <blockquote>
2232 <p> Blah
2233 </p>
2234 <table>
2235 <tr>
2236 <td>
2237 <p> indented cell (no pre-wrapping!)
2238 </p>
2239 </td></tr></table>
2240 </blockquote>
2241
2242 !! end
2243
2244 !! test
2245 T53086: Double newlines in blockquotes should be turned into paragraphs
2246 !! wikitext
2247 <blockquote>
2248 Foo
2249
2250 Bar
2251 </blockquote>
2252 !! html
2253 <blockquote>
2254 <p>Foo
2255 </p><p>Bar
2256 </p>
2257 </blockquote>
2258
2259 !! end
2260
2261 !! test
2262 T17491: <ins>/<del> in blockquote
2263 !! wikitext
2264 <blockquote>
2265 Foo <del>bar</del> <ins>baz</ins> quux
2266 </blockquote>
2267 !! html
2268 <blockquote>
2269 <p>Foo <del>bar</del> <ins>baz</ins> quux
2270 </p>
2271 </blockquote>
2272
2273 !! end
2274
2275 # Note that the p-wrapping is newline sensitive, which could be
2276 # considered a bug: tidy will wrap only the 'Foo' in the example
2277 # below in a <p> tag. (see comment 23-25 of T8200)
2278 !! test
2279 T17491: <ins>/<del> in blockquote (2)
2280 !! wikitext
2281 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2282 </blockquote>
2283 !! html
2284 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2285 </blockquote>
2286
2287 !! html+tidy
2288 <blockquote>
2289 <p>Foo</p>
2290 <del>bar</del> <ins>baz</ins> quux</blockquote>
2291 !! end
2292
2293 !! test
2294 <pre> with attributes (T5202)
2295 !! wikitext
2296 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2297 !! html
2298 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2299
2300 !! end
2301
2302 !! test
2303 <pre> with width attribute (T5202)
2304 !! wikitext
2305 <pre width="8">Narrow screen goodies</pre>
2306 !! html
2307 <pre width="8">Narrow screen goodies</pre>
2308
2309 !! end
2310
2311 !! test
2312 <pre> with forbidden attribute (T5202)
2313 !! wikitext
2314 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2315 !! html
2316 <pre width="8">Narrow screen goodies</pre>
2317
2318 !! end
2319
2320 !! test
2321 Entities inside <pre>
2322 !! wikitext
2323 <pre>&lt;</pre>
2324 !! html
2325 <pre>&lt;</pre>
2326
2327 !! end
2328
2329 !! test
2330 <pre> with forbidden attribute values (T5202)
2331 !! wikitext
2332 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2333 !! html
2334 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2335
2336 !! end
2337
2338 !! test
2339 <nowiki> inside <pre> (T15238)
2340 !! wikitext
2341 <pre>
2342 <nowiki>
2343 </pre>
2344 <pre>
2345 <nowiki></nowiki>
2346 </pre>
2347 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2348 !! html
2349 <pre>
2350 &lt;nowiki&gt;
2351 </pre>
2352 <pre>
2353
2354 </pre>
2355 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2356
2357 !! end
2358
2359 !! test
2360 <nowiki> inside of #tag:pre
2361 !! wikitext
2362 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2363 !! html/php
2364 <pre>Foo &#8594;bar</pre>
2365
2366 !! html/parsoid
2367 <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>
2368 !! end
2369
2370 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2371 ## aren't enclosed in nowikis.
2372 !! test
2373 <nowiki> and <pre> preference (first one wins)
2374 !! options
2375 parsoid=wt2html
2376 !! wikitext
2377 <pre>
2378 <nowiki>
2379 </pre>
2380 </nowiki>
2381 </pre>
2382
2383 <nowiki>
2384 <pre>
2385 <nowiki>
2386 </pre>
2387 </nowiki>
2388 </pre>
2389
2390 !! html/php
2391 <pre>
2392 &lt;nowiki&gt;
2393 </pre>
2394 <p>&lt;/nowiki&gt;
2395 &lt;/pre&gt;
2396 </p><p>
2397 &lt;pre&gt;
2398 &lt;nowiki&gt;
2399 &lt;/pre&gt;
2400
2401 &lt;/pre&gt;
2402 </p>
2403 !! html/parsoid
2404 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2405 </pre>
2406 <p>&lt;/nowiki></p>
2407
2408
2409 <p><span typeof="mw:Nowiki">
2410 &lt;pre>
2411 &lt;nowiki>
2412 &lt;/pre>
2413 </span></p>
2414 !! end
2415
2416 !! test
2417 </pre> inside nowiki
2418 !! wikitext
2419 <nowiki></pre></nowiki>
2420 !! html
2421 <p>&lt;/pre&gt;
2422 </p>
2423 !! end
2424
2425 # Parsoid doesn't strip empty tags, like Tidy does.
2426 !! test
2427 Empty pre; pre inside other HTML tags (T56946)
2428 !! wikitext
2429 a
2430
2431 <div><pre>
2432 foo
2433 </pre></div>
2434 <pre></pre>
2435 !! html/php
2436 <p>a
2437 </p>
2438 <div><pre>
2439 foo
2440 </pre></div>
2441 <pre></pre>
2442
2443 !! html/php+tidy
2444 <p>a</p>
2445 <div>
2446 <pre>
2447 foo
2448 </pre></div>
2449 !! html/parsoid
2450 <p>a</p>
2451
2452 <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
2453 </pre></div>
2454 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2455 !! end
2456
2457 !! test
2458 HTML pre followed by indent-pre
2459 !! wikitext
2460 <pre>foo</pre>
2461 bar
2462 !! html
2463 <pre>foo</pre>
2464 <pre>bar
2465 </pre>
2466 !! end
2467
2468 # Note that tidy removes the empty <p> tags from the start and end.
2469 # Parsoid does not, by design.
2470 !! test
2471 Block tag pre
2472 !! wikitext
2473 <p><pre>foo</pre></p>
2474 !! html/php+tidy
2475 <pre>
2476 foo
2477 </pre>
2478 !! html/parsoid
2479 <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>
2480 !! end
2481
2482 !!test
2483 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2484 !! wikitext
2485 {{echo|}}
2486 !! html
2487
2488 !!end
2489
2490 !!test
2491 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2492 !! wikitext
2493 {{echo|
2494 foo}}
2495 !! html
2496 <p>foo
2497 </p>
2498 !!end
2499
2500 !! test
2501 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2502 !! wikitext
2503 {{echo|a
2504 b}}
2505 !! html
2506 <pre>a
2507 </pre>
2508 <p>b
2509 </p>
2510 !!end
2511
2512 !! test
2513 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2514 !! wikitext
2515 {{echo|a
2516 b
2517 c
2518 d
2519 e
2520 }}
2521 !! html
2522 <pre>a
2523 </pre>
2524 <p>b
2525 c
2526 </p>
2527 <pre>d
2528 </pre>
2529 <p>e
2530 </p>
2531 !!end
2532
2533 !!test
2534 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2535 !! wikitext
2536 {{echo| foo}}
2537
2538 {{echo| foo}}{{echo| bar}}
2539
2540 {{echo| foo}}
2541 {{echo| bar}}
2542
2543 {{echo|<!--cmt--> foo}}
2544
2545 <!--cmt-->{{echo| foo}}
2546
2547 {{echo|{{echo| }}bar}}
2548 !! html
2549 <pre>foo
2550 </pre>
2551 <pre>foo bar
2552 </pre>
2553 <pre>foo
2554 bar
2555 </pre>
2556 <pre>foo
2557 </pre>
2558 <pre>foo
2559 </pre>
2560 <pre>bar
2561 </pre>
2562 !!end
2563
2564 !! test
2565 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2566 !! wikitext
2567 {{echo| }}a
2568
2569 {{echo|
2570 }}a
2571
2572 {{echo|
2573 b}}
2574
2575 {{echo|a
2576 }}b
2577
2578 {{echo|a
2579 }} b
2580 !! html
2581 <pre>a
2582 </pre>
2583 <p><br />
2584 </p>
2585 <pre>a
2586 </pre>
2587 <p><br />
2588 </p>
2589 <pre>b
2590 </pre>
2591 <p>a
2592 </p>
2593 <pre>b
2594 </pre>
2595 <p>a
2596 </p>
2597 <pre>b
2598 </pre>
2599 !!end
2600
2601 ## Hmm, should Parsoid rt this?
2602 !! test
2603 Pres with newline attributes
2604 !! options
2605 parsoid=wt2html,html2html
2606 !! wikitext
2607 <pre class="one
2608 two">hi</pre>
2609 !! html/php
2610 <pre class="one two">hi</pre>
2611
2612 !! html/parsoid
2613 <pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2614 !! end
2615
2616 !! test
2617 Things that look like <pre> tags aren't treated as such
2618 !! wikitext
2619 Barack Obama <President> of the United States
2620 <President></President>
2621 !! html
2622 <p>Barack Obama &lt;President&gt; of the United States
2623 &lt;President&gt;&lt;/President&gt;
2624 </p>
2625 !! end
2626
2627 !! test
2628 Handle broken pre-like tags (T66025)
2629 !! options
2630 parsoid=wt2html
2631 !! wikitext
2632 {{echo|<pre <pre>x</pre>}}
2633
2634 <table><pre </table>
2635 !! html/php
2636 <pre>x</pre>
2637 <table>&lt;pre </table>
2638
2639 !! html/php+tidy
2640 <pre>
2641 x
2642 </pre>
2643 <p>&lt;pre</p>
2644 !! html/parsoid
2645 <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>
2646
2647
2648 <p>&lt;pre </p>
2649
2650 <table></table>
2651 !! end
2652
2653 !! test
2654 Parsoid: handle pre with space after attribute
2655 !! options
2656 parsoid=wt2html
2657 !! wikitext
2658 <pre style="width:50%;" >{{echo|foo}}</pre>
2659 !! html/php
2660 <pre style="width:50%;">{{echo|foo}}</pre>
2661
2662 !! html/parsoid
2663 <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>
2664 !! end
2665
2666 # TODO / maybe: fix wt2wt for this
2667 !! test
2668 Parsoid: Don't paragraph-wrap fosterable content
2669 !! options
2670 parsoid=wt2html
2671 !! wikitext
2672 {|
2673 <td></td>
2674 <td></td>
2675
2676
2677
2678 |}
2679 !! html
2680 <table>
2681
2682 <tbody>
2683 <tr>
2684 <td></td>
2685
2686 <td></td></tr>
2687
2688
2689
2690 </tbody></table>
2691 !! end
2692
2693 !! test
2694 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2695 !! options
2696 parsoid=wt2html
2697 !! wikitext
2698 {|
2699 <td>
2700 <td>
2701 </td>
2702
2703
2704
2705 |}
2706 !! html
2707 <table>
2708
2709 <tbody>
2710 <tr>
2711 <td></td>
2712
2713 <td>
2714 </td></tr>
2715
2716
2717
2718 </tbody></table>
2719 !! end
2720
2721
2722 #--------------------------------------------------------------------
2723 # Transclusion parameter whitespace stripping tests
2724 # Behavior is different for positional and named parameters
2725 #--------------------------------------------------------------------
2726 !! test
2727 Templates: Strip leading and trailing whitespace from named-param values
2728 !! wikitext
2729 {{echo|1= a }}
2730
2731 {{echo|1= {{echo|b}} }}
2732
2733 {{echo| 1 =
2734 c }}
2735
2736 {{echo| 1 =
2737 * d
2738 }}
2739 !! html
2740 <p>a
2741 </p><p>b
2742 </p><p>c
2743 </p>
2744 <ul><li> d</li></ul>
2745
2746 !! end
2747
2748 !! test
2749 Templates: Don't strip whitespace from positional-param values
2750 !! wikitext
2751 {{echo|a }}
2752
2753 {{echo|{{echo|b}} }}
2754
2755 {{echo| c
2756 }}
2757
2758 {{echo| {{echo|d}}
2759 }}
2760
2761 {{echo|
2762 e}}
2763
2764 {{echo|
2765 * f}}
2766
2767 {{echo|
2768 }}g
2769 !! html
2770 <p>a
2771 </p><p>b
2772 </p>
2773 <pre>c
2774 </pre>
2775 <p><br />
2776 </p>
2777 <pre>d
2778 </pre>
2779 <p><br />
2780 </p>
2781 <pre>e
2782 </pre>
2783 <p><br />
2784 </p>
2785 <ul><li> f</li></ul>
2786 <p><br />
2787 </p>
2788 <pre>g
2789 </pre>
2790 !! end
2791
2792 !! test
2793 Templates: Don't recognize targets split by newlines
2794 !! options
2795 parsoid=wt2html
2796 !! wikitext
2797 {{ech
2798 o|foo}}
2799 !! html/php
2800 <p>{{ech
2801 o|foo}}
2802 </p>
2803 !! html/parsoid
2804 <p>{{ech
2805 o|foo}}</p>
2806 !! end
2807
2808 !! test
2809 Templates: Recognize targets when newlines and comments don't split the target
2810 !! options
2811 parsoid=wt2html
2812 !! wikitext
2813 {{
2814 <!--X--> ech<!--X-->o<!--X-->
2815 <!--X--> <!--X-->
2816
2817 |foo}}
2818 !! html/php
2819 <p>foo
2820 </p>
2821 !! html/parsoid
2822 <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>
2823 !! end
2824
2825 !! test
2826 Templates: Handle empty comment-and-ws-only lines correctly
2827 !! wikitext
2828 {{echo|foo
2829 <!--should be ignored-->
2830 <!--should be ignored as well-->
2831 bar}}
2832 !! html/php
2833 <p>foo
2834 bar
2835 </p>
2836 !! html/parsoid
2837 <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>
2838 !! end
2839
2840 !! test
2841 Templates: Handle comments in the target
2842 !! wikitext
2843 {{echo
2844 <!-- should be ignored -->
2845 |foo}}
2846
2847 {{echo
2848 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
2849 |foo}}
2850
2851 {{echo<!-- should be ignored -->
2852 |foo}}
2853
2854 {{echo<!-- should be ignored -->|foo}}
2855
2856 {{<!-- should be ignored -->echo|foo}}
2857 !! html/php
2858 <p>foo
2859 </p><p>foo
2860 </p><p>foo
2861 </p><p>foo
2862 </p><p>foo
2863 </p>
2864 !! html/parsoid
2865 <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>
2866
2867 <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>
2868
2869 <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>
2870
2871 <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>
2872
2873 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
2874 !! end
2875
2876 !! test
2877 Templates: Handle comments in parameter names (T69657)
2878 !! wikitext
2879 {{echo|1
2880 <!-- should be ignored -->
2881 =foo}}
2882
2883 {{echo|
2884 <!-- should be ignored -->
2885 1 = foo}}
2886
2887 {{echo|1<!-- should be ignored -->=foo}}
2888
2889 {{echo|<!-- should be ignored -->1=foo}}
2890 !! html/php
2891 <p>foo
2892 </p><p>foo
2893 </p><p>foo
2894 </p><p>foo
2895 </p>
2896 !! html/parsoid
2897 <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>
2898
2899 <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>
2900
2901 <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>
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 -->1"}}},"i":0}}]}'>foo</p>
2904 !! end
2905
2906 !! test
2907 Templates: Other wikitext in parameter names (T69657)
2908 !! wikitext
2909 {{echo|''1''=foo}}
2910 !! html/php
2911 <p>{{{1}}}
2912 </p>
2913 !! html/parsoid
2914 <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>
2915 !! end
2916
2917 !! test
2918 Templates: With colons
2919 !! wikitext
2920 {{With: Colon}}
2921 !! html/php
2922 <p>Template with colon
2923 </p>
2924 !! html/parsoid
2925 <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>
2926 !! end
2927
2928 #--------------------------------------------------------------------
2929 # Transclusion parameter escaping tests
2930 #--------------------------------------------------------------------
2931
2932 !! test
2933 Templates: Parsoid parameter escaping test 1
2934 !! wikitext
2935 {{echo|[foo]|{{echo|[bar]}}}}
2936 !! html/php+tidy
2937 <p>[foo]</p>
2938 !! html/parsoid
2939 <p about="#mwt1" typeof="mw:Transclusion"
2940 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
2941 !! end
2942
2943 !! test
2944 Parsoid: Pipes in external links in template parameter
2945 !! wikitext
2946 {{echo|[{{echo|http://example.com}} link]}}
2947 !! html/php+tidy
2948 <p><a rel="nofollow" class="external text" href="http://example.com">link</a></p>
2949 !! html/parsoid
2950 <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>
2951 !! end
2952
2953 !! test
2954 Parsoid: pipe in transclusion parameter
2955 !! wikitext
2956 {{echo|http://foo.com/a&#124;b}}
2957 !! html/php+tidy
2958 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a></p>
2959 !! html/parsoid
2960 <p><a rel="mw:ExtLink" href="http://foo.com/a%7Cb" about="#mwt1"
2961 typeof="mw:Transclusion"
2962 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>
2963 !! end
2964
2965 !! test
2966 Parsoid: Pipe in external link target and content in template parameter
2967 !! options
2968 parsoid=html2wt,wt2wt
2969 !! wikitext
2970 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
2971 !! html/php+tidy
2972 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a|b</a></p>
2973 !! html/parsoid
2974 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
2975 typeof="mw:Transclusion"
2976 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
2977 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
2978 !! end
2979
2980 !! test
2981 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
2982 !! options
2983 parsoid
2984 !! wikitext
2985 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
2986 !! html
2987 <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>
2988 !! end
2989
2990 !! test
2991 Templates: Don't escape already nowiki-escaped text in template parameters
2992 !! options
2993 parsoid=html2wt,wt2wt
2994 !! wikitext
2995 {{echo|foo<nowiki>|</nowiki>bar}}
2996 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
2997 {{echo|<nowiki></nowiki>}}
2998 !! html/php+tidy
2999 <p>foo|bar &lt;div&gt;</p>
3000 !! html/parsoid
3001 <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>
3002 <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>
3003 <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>
3004 </p>
3005 !! end
3006
3007 ## T54824
3008 !! test
3009 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
3010 !! options
3011 parsoid=html2wt,wt2wt
3012 !! wikitext
3013 {{echo|{{echo|1=bar}}}}
3014 !! html/php+tidy
3015 <p>bar</p>
3016 !! html/parsoid
3017 <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>
3018 !! end
3019
3020 ## T58733
3021 !! test
3022 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
3023 !! wikitext
3024 {{echo|a : b}}
3025 !! html/php+tidy
3026 <p>a&#160;: b</p>
3027 !! html/parsoid
3028 <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>
3029 !! end
3030
3031 ## T73412
3032 !! test
3033 Templates: Preserve blank parameter names
3034 !! wikitext
3035 {{echo|=foo}}
3036 !! html/php+tidy
3037 <p>{{{1}}}</p>
3038 !! html/parsoid
3039 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3040 !! end
3041
3042 !! test
3043 Templates: Preserve blank parameter names in other positions
3044 !! wikitext
3045 {{blank_param|bar|=foo}}
3046 !! html/php+tidy
3047 <p>bar foo</p>
3048 !! html/parsoid
3049 <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
3050 foo</p>
3051 !! end
3052
3053 ###
3054 ### Parsoid-centric tests for testing RT edge cases for pre
3055 ###
3056
3057 !!test
3058 1a. Indent-Pre and Comments
3059 !! wikitext
3060 a
3061 <!--a-->
3062 c
3063 !! html
3064 <pre>a
3065 </pre>
3066 <p>c
3067 </p>
3068 !!end
3069
3070 !!test
3071 1b. Indent-Pre and Comments
3072 !! wikitext
3073 a
3074 <!--a-->
3075 c
3076 !! html
3077 <pre>a
3078 </pre>
3079 <p>c
3080 </p>
3081 !!end
3082
3083 !!test
3084 1c. Indent-Pre and Comments
3085 !! wikitext
3086 <!--a--> a
3087
3088 <!--a--> a
3089 !! html
3090 <pre> a
3091 </pre>
3092 <pre> a
3093 </pre>
3094 !!end
3095
3096 !!test
3097 1d. Indent-Pre and Comments
3098 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3099 !! wikitext
3100 <!--a--> a
3101
3102 <!--b-->b
3103 !! html
3104 <pre>a
3105 </pre>
3106 <pre>b
3107 </pre>
3108 !!end
3109
3110 !!test
3111 2a. Indent-Pre and tables
3112 !! wikitext
3113 {|
3114 |-
3115 !h1!!h2
3116 |foo||bar
3117 |}
3118 !! html
3119 <table>
3120
3121 <tr>
3122 <th>h1</th>
3123 <th>h2
3124 </th>
3125 <td>foo</td>
3126 <td>bar
3127 </td></tr></table>
3128
3129 !!end
3130
3131 !!test
3132 2b. Indent-Pre and tables
3133 !! wikitext
3134 {|
3135 |-
3136 |foo
3137 |}
3138 !! html
3139 <table>
3140
3141 <tr>
3142 <td>foo
3143 </td></tr></table>
3144
3145 !!end
3146
3147 !!test
3148 2c. Indent-Pre and tables (T44252)
3149 !! wikitext
3150 {|
3151 |+ foo
3152 ! | bar
3153 |}
3154 !! html
3155 <table>
3156 <caption> foo
3157 </caption>
3158 <tr>
3159 <th> bar
3160 </th></tr></table>
3161
3162 !!end
3163
3164 !!test
3165 2d. Indent-Pre and tables
3166 !! wikitext
3167 a
3168 {|
3169 | b
3170 |}
3171 !! html/php
3172 <pre>a
3173 </pre>
3174 <table>
3175 <tr>
3176 <td> b
3177 </td></tr></table>
3178
3179 !! html/parsoid
3180 <pre>a</pre>
3181 <table>
3182 <tbody><tr><td> b</td></tr>
3183 </tbody></table>
3184 !!end
3185
3186 !!test
3187 2e. Indent-Pre and table-line syntax
3188 !! wikitext
3189 a
3190 | b
3191 | c
3192 !! html/php
3193 <pre>a
3194 | b
3195 | c
3196 </pre>
3197 !!end
3198
3199 !!test
3200 2f. Indent-pre started by table-line syntax
3201 !! wikitext
3202 a
3203 | b
3204 | c
3205 !! html/php
3206 <p>a
3207 </p>
3208 <pre>| b
3209 | c
3210 </pre>
3211 !! html/parsoid
3212 <p>a</p>
3213 <pre>
3214 | b
3215 | c</pre>
3216 !!end
3217
3218 !! test
3219 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3220 !! wikitext
3221 <table>
3222 <tr>
3223 <td>
3224 Text that should be rendered preformatted
3225 </td>
3226 </tr>
3227 </table>
3228 !! html
3229 <table>
3230 <tr>
3231 <td>
3232 <pre>Text that should be rendered preformatted
3233 </pre>
3234 </td>
3235 </tr>
3236 </table>
3237
3238 !! end
3239
3240 !!test
3241 3a. Indent-Pre and block tags (single-line html)
3242 !! wikitext
3243 a <p> foo </p>
3244 b <div> foo </div>
3245 c <blockquote> foo </blockquote>
3246 <span> foo </span>
3247 !! html
3248 a <p> foo </p>
3249 b <div> foo </div>
3250 c <blockquote> foo </blockquote>
3251 <pre><span> foo </span>
3252 </pre>
3253 !! html/parsoid
3254 <p>a </p><p data-parsoid='{"stx":"html"}'> foo </p>
3255 <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3256 <p>c </p><blockquote data-parsoid='{"stx":"html"}'> foo </blockquote>
3257 <pre><span> foo </span>
3258 </pre>
3259 !! html+tidy
3260 <p>a</p>
3261 <p>foo</p>
3262 <p>b</p>
3263 <div>foo</div>
3264 <p>c</p>
3265 <blockquote>
3266 <p>foo</p>
3267 </blockquote>
3268 <pre>
3269 <span> foo </span>
3270 </pre>
3271 !! end
3272
3273 !!test
3274 3b. Indent-Pre and block tags (multi-line html)
3275 !! wikitext
3276 a <span>foo</span>
3277 b <div> foo </div>
3278 !! html
3279 <pre>a <span>foo</span>
3280 </pre>
3281 b <div> foo </div>
3282
3283 !! html/parsoid
3284 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3285 b <div data-parsoid='{"stx":"html"}'> foo </div>
3286 !! html+tidy
3287 <pre>
3288 a <span>foo</span>
3289 </pre>
3290 <p>b</p>
3291 <div>foo</div>
3292 !!end
3293
3294 !!test
3295 3c. Indent-Pre and block tags (pre-content on separate line)
3296 !! wikitext
3297 <p>
3298 foo
3299 </p>
3300
3301 <div>
3302 foo
3303 </div>
3304
3305 <center>
3306 foo
3307 </center>
3308
3309 <blockquote>
3310 foo
3311 </blockquote>
3312
3313 <blockquote>
3314 <pre>
3315 foo
3316 </pre>
3317 </blockquote>
3318
3319 <table><tr><td>
3320 foo
3321 </td></tr></table>
3322
3323 <ul><li>
3324 foo
3325 </li></ul>
3326
3327 !! html
3328 <p>
3329 foo
3330 </p>
3331 <div>
3332 <pre>foo
3333 </pre>
3334 </div>
3335 <center>
3336 <pre>foo
3337 </pre>
3338 </center>
3339 <blockquote>
3340 <p> foo
3341 </p>
3342 </blockquote>
3343 <blockquote>
3344 <pre>
3345 foo
3346 </pre>
3347 </blockquote>
3348 <table><tr><td>
3349 <pre>foo
3350 </pre>
3351 </td></tr></table>
3352 <ul><li>
3353 foo
3354 </li></ul>
3355
3356 !!end
3357
3358 !! test
3359 4. Indent-Pre and extension tags
3360 !! wikitext
3361 a <tag />
3362 !! html/php
3363 a <pre>
3364 NULL
3365 array (
3366 )
3367 </pre>
3368
3369 !! html/parsoid
3370 a <pre typeof="mw:Extension/tag" about="#mwt2" data-parsoid='{}' data-mw='{"name":"tag","attrs":{},"body":null}'></pre>
3371 !! end
3372
3373 !! test
3374 5. Indent-Pre and html pre
3375 !! wikitext
3376 <pre class="123">hi</pre>
3377 !! html/php
3378 <pre class="123">hi</pre>
3379
3380 !! html/parsoid
3381 <pre typeof="mw:Extension/pre" about="#mwt2" class="123" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3382 !! end
3383
3384 !!test
3385 Render paragraphs when indent-pre is suppressed in blocklevels
3386 !! wikitext
3387 <blockquote>
3388 foo
3389
3390 bar
3391 </blockquote>
3392 !! html
3393 <blockquote>
3394 <p> foo
3395 </p><p> bar
3396 </p>
3397 </blockquote>
3398
3399 !!end
3400
3401 !!test
3402 4. Multiple spaces at start-of-line
3403 !! wikitext
3404 <p> foo </p>
3405 foo
3406 {|
3407 |foo
3408 |}
3409 !! html
3410 <p> foo </p>
3411 <pre> foo
3412 </pre>
3413 <table>
3414 <tr>
3415 <td>foo
3416 </td></tr></table>
3417
3418 !!end
3419
3420 ## NOTE: the leading white-space chars on empty line are significant
3421 !! test
3422 5a. White-space in indent-pre
3423 !! wikitext
3424 a<br />
3425
3426 b
3427 !! html
3428 <pre>a<br />
3429
3430 b
3431 </pre>
3432 !! end
3433
3434 ## NOTE: the leading white-space chars on empty line are significant
3435 !! test
3436 5b. White-space in indent-pre
3437 !! wikitext
3438 a
3439
3440 b
3441
3442
3443 c
3444 !! html
3445 <pre>a
3446
3447 b
3448
3449
3450 c
3451 </pre>
3452 !! end
3453
3454 !! test
3455 5c. White-space in indent-pre
3456 !! wikitext
3457 ''a''
3458 ''b''
3459 ''c''
3460 !! html
3461 <pre><i>a</i>
3462 <i>b</i>
3463 <i>c</i>
3464 </pre>
3465 !! end
3466
3467 !! test
3468 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3469 !! wikitext
3470 a
3471
3472 <!-- continue -->
3473 b
3474
3475 c
3476
3477 d
3478 !! html
3479 <pre>a
3480
3481 b
3482 </pre>
3483 <pre>c
3484
3485 </pre>
3486 <p>d
3487 </p>
3488 !! end
3489
3490 !! test
3491 7a. Indent-pre and category links
3492 !! options
3493 parsoid=wt2html,wt2wt
3494 !! wikitext
3495 [[Category:foo]] <!-- No pre-wrapping -->
3496 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3497 !! html/php+tidy
3498 !! html/parsoid
3499 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3500 <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 -->
3501 !! end
3502
3503 ## We used to, but no longer wt2wt this test since the default serializer
3504 ## will normalize all categories to serialize on their own line.
3505 ## This wikitext usage is going to be fairly uncommon in production and
3506 ## selser will take care of preserving formatting in those scenarios.
3507 !! test
3508 7b. Indent-pre and category links
3509 !! options
3510 parsoid=wt2html
3511 !! wikitext
3512 [[Category:foo]] a
3513 [[Category:foo]] {{echo|b}}
3514 !! html/parsoid
3515 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3516 <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>
3517 !! end
3518
3519 !! test
3520 Indent-Pre: Newlines in comments shouldn't affect sol state
3521 !! wikitext
3522 a <!--
3523 foo
3524 --> b
3525 !! html/php+tidy
3526 <p>a b</p>
3527 !! html/parsoid
3528 <p>a <!--
3529 foo
3530 --> b</p>
3531 !! end
3532
3533 ###
3534 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3535 ###
3536
3537 !!test
3538 HTML-pre: 1. embedded newlines
3539 !! wikitext
3540 <pre>foo</pre>
3541
3542 <pre>
3543 foo
3544 </pre>
3545
3546 <pre>
3547
3548 foo
3549 </pre>
3550
3551 <pre>
3552
3553
3554 foo
3555 </pre>
3556 !! html/php+tidy
3557 <pre>
3558 foo
3559 </pre>
3560 <pre>
3561 foo
3562 </pre>
3563 <pre>
3564
3565 foo
3566 </pre>
3567 <pre>
3568
3569
3570 foo
3571 </pre>
3572 !! html/parsoid
3573 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3574
3575 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3576 </pre>
3577
3578 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3579
3580 foo
3581 </pre>
3582
3583 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3584
3585
3586 foo
3587 </pre>
3588 !!end
3589
3590 !! test
3591 HTML-pre: big spaces
3592 !! wikitext
3593 <pre>
3594
3595
3596
3597
3598 haha
3599
3600
3601
3602
3603 haha
3604
3605
3606
3607
3608 </pre>
3609 !! html/php+tidy
3610 <pre>
3611
3612
3613
3614
3615 haha
3616
3617
3618
3619
3620 haha
3621
3622
3623
3624
3625 </pre>
3626 !! html/parsoid
3627 <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"}}'>
3628
3629
3630
3631
3632 haha
3633
3634
3635
3636
3637 haha
3638
3639
3640
3641
3642 </pre>
3643 !! end
3644
3645 !!test
3646 HTML-pre: 2: indented text
3647 !! wikitext
3648 <pre>
3649 foo
3650 </pre>
3651 !! html
3652 <pre>
3653 foo
3654 </pre>
3655
3656 !!end
3657
3658 !!test
3659 HTML-pre: 3: other wikitext
3660 !! wikitext
3661 <pre>
3662 * foo
3663 # bar
3664 = no-h =
3665 '' no-italic ''
3666 [[ NoLink ]]
3667 </pre>
3668 !! html/php
3669 <pre>
3670 * foo
3671 # bar
3672 = no-h =
3673 '' no-italic ''
3674 [[ NoLink ]]
3675 </pre>
3676
3677 !! html/parsoid
3678 <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
3679 # bar
3680 = no-h =
3681 '' no-italic ''
3682 [[ NoLink ]]
3683 </pre>
3684 !!end
3685
3686 ###
3687 ### Definition lists
3688 ###
3689 !! test
3690 Simple definition
3691 !! wikitext
3692 ; name : Definition
3693 !! html
3694 <dl><dt> name&#160;</dt>
3695 <dd> Definition</dd></dl>
3696
3697 !! end
3698
3699 !! test
3700 Definition list for indentation only
3701 !! wikitext
3702 : Indented text
3703 !! html
3704 <dl><dd> Indented text</dd></dl>
3705
3706 !! end
3707
3708 !! test
3709 Definition list with no space
3710 !! wikitext
3711 ;name:Definition
3712 !! html
3713 <dl><dt>name</dt>
3714 <dd>Definition</dd></dl>
3715
3716 !!end
3717
3718 !! test
3719 Definition list with URL link
3720 !! wikitext
3721 ; http://example.com/ : definition
3722 !! html
3723 <dl><dt> <a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&#160;</dt>
3724 <dd> definition</dd></dl>
3725
3726 !! end
3727
3728 !! test
3729 Definition list with bracketed URL link
3730 !! wikitext
3731 ;[http://www.example.com/ Example]:Something about it
3732 !! html
3733 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
3734 <dd>Something about it</dd></dl>
3735
3736 !! end
3737
3738 !! test
3739 Definition list with wikilink containing colon
3740 !! wikitext
3741 ; [[Help:FAQ]]: The least-read page on Wikipedia
3742 !! html
3743 <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>
3744 <dd> The least-read page on Wikipedia</dd></dl>
3745
3746 !! end
3747
3748 # At Brion's and JeLuF's insistence... :)
3749 !! test
3750 Definition list with news link containing colon
3751 !! wikitext
3752 ; news:alt.wikipedia.rox: This isn't even a real newsgroup!
3753 !! html/php
3754 <dl><dt> <a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
3755 <dd> This isn't even a real newsgroup!</dd></dl>
3756
3757 !! html/parsoid
3758 <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>
3759 !! end
3760
3761 !! test
3762 Malformed definition list with colon
3763 !! wikitext
3764 ; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
3765 !! html
3766 <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>
3767
3768 !! end
3769
3770 !! test
3771 Definition lists: colon in external link text
3772 !! wikitext
3773 ; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
3774 !! html
3775 <dl><dt> <a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia&#160;: The Next Generation</a></dt>
3776 <dd> OK, I made that up</dd></dl>
3777
3778 !! end
3779
3780 !! test
3781 Definition lists: colon in HTML attribute
3782 !! wikitext
3783 ;<b style="display: inline">bold</b>
3784 !! html
3785 <dl><dt><b style="display: inline">bold</b></dt></dl>
3786
3787 !! end
3788
3789 !! test
3790 Definition lists: self-closed tag
3791 !! wikitext
3792 ;one<br/>two : two-line fun
3793 !! html
3794 <dl><dt>one<br />two&#160;</dt>
3795 <dd> two-line fun</dd></dl>
3796
3797 !! end
3798
3799 !! test
3800 Definition lists: ignore colons inside tags
3801 !! wikitext
3802 ;one <b>two : tag <i>fun:</i>:</b>: def
3803 !! html
3804 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
3805 <dd> def</dd></dl>
3806
3807 !! end
3808
3809 !! test
3810 Definition lists: excess closed tags
3811 !! wikitext
3812 ;one</b>two : bad tag fun
3813 !! html/php+tidy
3814 <dl>
3815 <dt>onetwo&#160;</dt>
3816 <dd>bad tag fun</dd>
3817 </dl>
3818 !! html/parsoid
3819 <dl>
3820 <dt>onetwo</dt>
3821 <dd>bad tag fun</dd>
3822 </dl>
3823 !! end
3824
3825 !! test
3826 T13748: Literal closing tags
3827 !! wikitext
3828 <dl>
3829 <dt>test 1</dt>
3830 <dd>test test test test test</dd>
3831 <dt>test 2</dt>
3832 <dd>test test test test test</dd>
3833 </dl>
3834 !! html
3835 <dl>
3836 <dt>test 1</dt>
3837 <dd>test test test test test</dd>
3838 <dt>test 2</dt>
3839 <dd>test test test test test</dd>
3840 </dl>
3841
3842 !! end
3843
3844 !! test
3845 Definition and unordered list using wiki syntax nested in unordered list using html tags.
3846 !! wikitext
3847 <ul><li>
3848 ; term : description
3849 * unordered
3850 </li></ul>
3851 !! html
3852 <ul><li>
3853 <dl><dt> term&#160;</dt>
3854 <dd> description</dd></dl>
3855 <ul><li> unordered</li></ul>
3856 </li></ul>
3857
3858 !! end
3859
3860 !! test
3861 Definition list with empty definition and following paragraph
3862 !! wikitext
3863 ; term:
3864 Paragraph text
3865 !! html
3866 <dl><dt> term</dt>
3867 <dd></dd></dl>
3868 <p>Paragraph text
3869 </p>
3870 !! end
3871
3872 !! test
3873 Nested definition lists using html syntax
3874 !! wikitext
3875 <dl><dt>x</dt>
3876 <dd>a</dd>
3877 <dd>b</dd></dl>
3878 !! html
3879 <dl><dt>x</dt>
3880 <dd>a</dd>
3881 <dd>b</dd></dl>
3882
3883 !! end
3884
3885 !! test
3886 Definition Lists: No nesting: Multiple dd's
3887 !! wikitext
3888 ;x
3889 :a
3890 :b
3891 !! html
3892 <dl><dt>x</dt>
3893 <dd>a</dd>
3894 <dd>b</dd></dl>
3895
3896 !! end
3897
3898 !! test
3899 Definition Lists: Indentation: Regular
3900 !! wikitext
3901 :i1
3902 ::i2
3903 :::i3
3904 !! html
3905 <dl><dd>i1
3906 <dl><dd>i2
3907 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3908
3909 !! end
3910
3911 !! test
3912 Definition Lists: Indentation: Missing 1st level
3913 !! wikitext
3914 ::i2
3915 :::i3
3916 !! html
3917 <dl><dd><dl><dd>i2
3918 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3919
3920 !! end
3921
3922 !! test
3923 Definition Lists: Indentation: Multi-level indent
3924 !! wikitext
3925 :::i3
3926 !! html
3927 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
3928
3929 !! end
3930
3931 !! test
3932 Definition Lists: Hacky use to indent tables
3933 !! wikitext
3934 ::{|
3935 |foo
3936 |bar
3937 |}
3938 this text
3939 should be left alone
3940 !! html
3941 <dl><dd><dl><dd><table>
3942 <tr>
3943 <td>foo
3944 </td>
3945 <td>bar
3946 </td></tr></table></dd></dl></dd></dl>
3947 <p>this text
3948 should be left alone
3949 </p>
3950 !! end
3951
3952 !! test
3953 Definition Lists: Hacky use to indent tables, with comments (T65979)
3954 !! wikitext
3955 <!-- foo -->
3956 ::{|
3957 |foo
3958 |bar
3959 |}<!-- bar -->
3960 this text
3961 should be left alone
3962 !! html/parsoid
3963 <!-- foo -->
3964 <dl><dd><dl><dd><table><tr>
3965 <td>foo</td>
3966 <td>bar</td>
3967 </tr></table><!-- bar --></dd></dl></dd></dl>
3968 <p>this text
3969 should be left alone</p>
3970 !! end
3971
3972 !! test
3973 Definition Lists: Hacky use to indent tables, with comment before table
3974 !! wikitext
3975 ::<!-- foo -->{|
3976 |foo
3977 |}
3978 !! html/parsoid
3979 <dl><dd><dl><dd><!-- foo --><table><tr>
3980 <td>foo</td>
3981 </tr></table></dd></dl></dd></dl>
3982 !! end
3983
3984 # The trailing whitespace in this test is to catch a regression in
3985 # Parsoid after T54473.
3986 !! test
3987 Definition Lists: Hacky use to indent tables (WS-insensitive)
3988 !! wikitext
3989 : {|
3990 |a
3991 |}
3992 !! html/php
3993 <dl><dd><table>
3994 <tr>
3995 <td>a
3996 </td></tr></table></dd></dl>
3997
3998 !! html/parsoid
3999 <dl><dd> <table>
4000 <tbody><tr><td>a</td></tr>
4001 </tbody></table> </dd></dl>
4002 !! end
4003
4004 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
4005 ## as an empty dt item. It also ignores all but the last ";" when followed
4006 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
4007 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
4008 ## ";"s.
4009 ##
4010 ## Ex: ";;t2 ::d2" is transformed into:
4011 ##
4012 ## <dl>
4013 ## <dt>t2 </dt>
4014 ## <dd>
4015 ## <dl>
4016 ## <dt></dt>
4017 ## <dd>d2</dd>
4018 ## </dl>
4019 ## </dd>
4020 ## </dl>
4021 ##
4022 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
4023 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
4024 ##
4025 ## <dl>
4026 ## <dt>
4027 ## <dl>
4028 ## <dt>t2 </dt>
4029 ## <dd>:d2</dd>
4030 ## </dl>
4031 ## </dt>
4032 ## </dl>
4033 ##
4034 ## All Parsoid only definition list tests have this difference.
4035 ##
4036 ## See also: https://phabricator.wikimedia.org/T8569
4037 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4038
4039 !! test
4040 Table / list interaction: indented table with lists in table contents
4041 !! wikitext
4042 :{|
4043 |-
4044 | a
4045 * b
4046 |-
4047 | c
4048 * d
4049 |}
4050 !! html
4051 <dl><dd><table>
4052
4053 <tr>
4054 <td> a
4055 <ul><li> b</li></ul>
4056 </td></tr>
4057 <tr>
4058 <td> c
4059 <ul><li> d</li></ul>
4060 </td></tr></table></dd></dl>
4061
4062 !! end
4063
4064 !!test
4065 Table / list interaction: lists nested in tables nested in indented lists
4066 !! wikitext
4067 :{|
4068 |
4069 :a
4070 :b
4071 |
4072 *c
4073 *d
4074 |}
4075
4076 *e
4077 *f
4078 !! html
4079 <dl><dd><table>
4080 <tr>
4081 <td>
4082 <dl><dd>a</dd>
4083 <dd>b</dd></dl>
4084 </td>
4085 <td>
4086 <ul><li>c</li>
4087 <li>d</li></ul>
4088 </td></tr></table></dd></dl>
4089 <ul><li>e</li>
4090 <li>f</li></ul>
4091
4092 !!end
4093
4094 !! test
4095 Definition Lists: Nesting: Multi-level (Parsoid only)
4096 !! options
4097 parsoid
4098 !! wikitext
4099 ;t1 :d1
4100 ;;t2 ::d2
4101 ;;;t3 :::d3
4102 !! html
4103 <dl>
4104 <dt>t1 </dt>
4105 <dd>d1</dd>
4106 <dt>
4107 <dl>
4108 <dt>t2 </dt>
4109 <dd>:d2</dd>
4110 <dt>
4111 <dl>
4112 <dt>t3 </dt>
4113 <dd>::d3</dd>
4114 </dl>
4115 </dt>
4116 </dl>
4117 </dt>
4118 </dl>
4119
4120
4121 !! end
4122
4123
4124 !! test
4125 Definition Lists: Nesting: Test 2 (Parsoid only)
4126 !! wikitext
4127 ;t1
4128 ::d2
4129 !! html/php+tidy
4130 <dl>
4131 <dt>t1</dt>
4132 <dd>
4133 <dl>
4134 <dd>d2</dd>
4135 </dl>
4136 </dd>
4137 </dl>
4138 !! html/parsoid
4139 <dl>
4140 <dt>t1</dt>
4141 <dd>
4142 <dl>
4143 <dd>d2</dd>
4144 </dl>
4145 </dd>
4146 </dl>
4147
4148 !! end
4149
4150
4151 !! test
4152 Definition Lists: Nesting: Test 3 (Parsoid only)
4153 !! wikitext
4154 :;t1
4155 ::::d2
4156 !! html/php+tidy
4157 <dl>
4158 <dd>
4159 <dl>
4160 <dt>t1</dt>
4161 <dd>
4162 <dl>
4163 <dd>
4164 <dl>
4165 <dd>d2</dd>
4166 </dl>
4167 </dd>
4168 </dl>
4169 </dd>
4170 </dl>
4171 </dd>
4172 </dl>
4173 !! html/parsoid
4174 <dl>
4175 <dd>
4176 <dl>
4177 <dt>t1</dt>
4178 <dd>
4179 <dl>
4180 <dd>
4181 <dl>
4182 <dd>d2</dd>
4183 </dl>
4184 </dd>
4185 </dl>
4186 </dd>
4187 </dl>
4188 </dd>
4189 </dl>
4190
4191 !! end
4192
4193
4194 !! test
4195 Definition Lists: Nesting: Test 4
4196 !! wikitext
4197 ::;t3
4198 :::d3
4199 !! html
4200 <dl><dd><dl><dd><dl><dt>t3</dt>
4201 <dd>d3</dd></dl></dd></dl></dd></dl>
4202
4203 !! end
4204
4205
4206 ## The Parsoid team believes the following three test exposes a
4207 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4208 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4209 ## It also exposes a "misfeature" in tidy, which doesn't like
4210 ## <dl> tags with a single <dt> child; it converts the <dt> into
4211 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4212 !! test
4213 Definition Lists: Mixed Lists: Test 1
4214 !! wikitext
4215 :;* foo
4216 ::* bar
4217 :; baz
4218 !! html/php
4219 <dl><dd><dl><dt><ul><li> foo</li>
4220 <li> bar</li></ul></dt></dl>
4221 <dl><dt> baz</dt></dl></dd></dl>
4222
4223 !! html/php+tidy
4224 <dl>
4225 <dd>
4226 <dl>
4227 <dd>
4228 <ul>
4229 <li>foo</li>
4230 <li>bar</li>
4231 </ul>
4232 </dd>
4233 </dl>
4234 <dl>
4235 <dt>baz</dt>
4236 </dl>
4237 </dd>
4238 </dl>
4239 !! html/parsoid
4240 <dl>
4241 <dd><dl>
4242 <dt><ul>
4243 <li> foo
4244 </li>
4245 </ul></dt>
4246 <dd><ul>
4247 <li> bar
4248 </li>
4249 </ul></dd>
4250 <dt> baz</dt>
4251 </dl></dd>
4252 </dl>
4253 !! end
4254
4255 !! test
4256 Definition Lists: Mixed Lists: Test 2
4257 !! wikitext
4258 *: d1
4259 *: d2
4260 !! html
4261 <ul><li><dl><dd> d1</dd>
4262 <dd> d2</dd></dl></li></ul>
4263
4264 !! end
4265
4266
4267 !! test
4268 Definition Lists: Mixed Lists: Test 3
4269 !! wikitext
4270 *::: d1
4271 *::: d2
4272 !! html
4273 <ul><li><dl><dd><dl><dd><dl><dd> d1</dd>
4274 <dd> d2</dd></dl></dd></dl></dd></dl></li></ul>
4275
4276 !! end
4277
4278
4279 !! test
4280 Definition Lists: Mixed Lists: Test 4
4281 !! wikitext
4282 *;d1 :d2
4283 *;d3 :d4
4284 !! html
4285 <ul><li><dl><dt>d1&#160;</dt>
4286 <dd>d2</dd>
4287 <dt>d3&#160;</dt>
4288 <dd>d4</dd></dl></li></ul>
4289
4290 !! end
4291
4292
4293 !! test
4294 Definition Lists: Mixed Lists: Test 5
4295 !! wikitext
4296 *:d1
4297 *:: d2
4298 !! html
4299 <ul><li><dl><dd>d1
4300 <dl><dd> d2</dd></dl></dd></dl></li></ul>
4301
4302 !! end
4303
4304
4305 !! test
4306 Definition Lists: Mixed Lists: Test 6
4307 !! wikitext
4308 #*:d1
4309 #*::: d3
4310 !! html
4311 <ol><li><ul><li><dl><dd>d1
4312 <dl><dd><dl><dd> d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4313
4314 !! end
4315
4316
4317 !! test
4318 Definition Lists: Mixed Lists: Test 7
4319 !! wikitext
4320 :* d1
4321 :* d2
4322 !! html
4323 <dl><dd><ul><li> d1</li>
4324 <li> d2</li></ul></dd></dl>
4325
4326 !! end
4327
4328
4329 !! test
4330 Definition Lists: Mixed Lists: Test 8
4331 !! wikitext
4332 :* d1
4333 ::* d2
4334 !! html
4335 <dl><dd><ul><li> d1</li></ul>
4336 <dl><dd><ul><li> d2</li></ul></dd></dl></dd></dl>
4337
4338 !! end
4339
4340
4341 !! test
4342 Definition Lists: Mixed Lists: Test 9
4343 !! wikitext
4344 *;foo :bar
4345 !! html
4346 <ul><li><dl><dt>foo&#160;</dt>
4347 <dd>bar</dd></dl></li></ul>
4348
4349 !! end
4350
4351
4352 !! test
4353 Definition Lists: Mixed Lists: Test 10
4354 !! wikitext
4355 *#;foo :bar
4356 !! html
4357 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4358 <dd>bar</dd></dl></li></ol></li></ul>
4359
4360 !! end
4361
4362 # This is a regression test for T175099
4363 # html/php+tidy is insufficient since Tidy covers up the bug.
4364 # But once Tidy is replaced with RemexHTML, html/php+tidy is good enough
4365 !! test
4366 Definition Lists: Mixed Lists: Test 11
4367 !! wikitext
4368 ; a
4369 :* b
4370 !! html/*
4371 <dl><dt> a</dt>
4372 <dd>
4373 <ul><li> b</li></ul></dd></dl>
4374
4375 !! end
4376
4377 # The Parsoid team disagrees with the PHP parser's seemingly-random
4378 # rules regarding dd/dt on the next two tests. Parsoid is more
4379 # consistent, and recognizes the shared nesting and keeps the
4380 # still-open tags around until the nesting is complete.
4381 # (And tidy again converts <dt> to <dd> before 'bar'.)
4382
4383 !! test
4384 Definition Lists: Mixed Lists: Test 12
4385 !! wikitext
4386 *#*#;*;;foo :bar
4387 *#*#;boo :baz
4388 !! html/php
4389 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4390 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4391 <dl><dt>boo&#160;</dt>
4392 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4393
4394 !! html/php+tidy
4395 <ul>
4396 <li>
4397 <ol>
4398 <li>
4399 <ul>
4400 <li>
4401 <ol>
4402 <li>
4403 <dl>
4404 <dt>foo&#160;</dt>
4405 <dd>
4406 <ul>
4407 <li>
4408 <dl>
4409 <dd>
4410 <dl>
4411 <dt>bar</dt>
4412 </dl>
4413 </dd>
4414 </dl>
4415 </li>
4416 </ul>
4417 </dd>
4418 </dl>
4419 <dl>
4420 <dt>boo&#160;</dt>
4421 <dd>baz</dd>
4422 </dl>
4423 </li>
4424 </ol>
4425 </li>
4426 </ul>
4427 </li>
4428 </ol>
4429 </li>
4430 </ul>
4431 !! html/parsoid
4432 <ul>
4433 <li>
4434 <ol>
4435 <li>
4436 <ul>
4437 <li>
4438 <ol>
4439 <li>
4440 <dl>
4441 <dt>
4442 <ul>
4443 <li>
4444 <dl>
4445 <dt>
4446 <dl>
4447 <dt>foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4448 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4449 </dl></dt>
4450 </dl></li>
4451 </ul></dt>
4452 <dt>boo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4453 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4454 </dl></li>
4455 </ol></li>
4456 </ul></li>
4457 </ol></li>
4458 </ul>
4459 !! end
4460
4461
4462 # Another case where tidy converts a <dt> to a <dd> (but Parsoid doesn't).
4463 # From whitelist:
4464 # * The test is wrong, there are two colons where there should be :;
4465 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4466 !! test
4467 Definition Lists: Weird Ones: Test 1
4468 !! wikitext
4469 *#;*::;; foo : bar (who uses this?)
4470 !! html/php
4471 <ul><li><ol><li><dl><dt> foo&#160;</dt>
4472 <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>
4473
4474 !! html/php+tidy
4475 <ul>
4476 <li>
4477 <ol>
4478 <li>
4479 <dl>
4480 <dt>foo&#160;</dt>
4481 <dd>
4482 <ul>
4483 <li>
4484 <dl>
4485 <dd>
4486 <dl>
4487 <dd>
4488 <dl>
4489 <dd>
4490 <dl>
4491 <dt>bar (who uses this?)</dt>
4492 </dl>
4493 </dd>
4494 </dl>
4495 </dd>
4496 </dl>
4497 </dd>
4498 </dl>
4499 </li>
4500 </ul>
4501 </dd>
4502 </dl>
4503 </li>
4504 </ol>
4505 </li>
4506 </ul>
4507 !! html/parsoid
4508 <ul>
4509 <li>
4510 <ol>
4511 <li>
4512 <dl>
4513 <dt>
4514 <ul>
4515 <li>
4516 <dl>
4517 <dd>
4518 <dl>
4519 <dd>
4520 <dl>
4521 <dt>
4522 <dl>
4523 <dt> foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span></dt>
4524 <dd data-parsoid='{"stx":"row"}'> bar (who uses this?)</dd>
4525 </dl></dt>
4526 </dl></dd>
4527 </dl></dd>
4528 </dl></li>
4529 </ul></dt>
4530 </dl></li>
4531 </ol></li>
4532 </ul>
4533 !! end
4534
4535 !! test
4536 Definition Lists: colons occurring in tags
4537 !! wikitext
4538 ;a:b
4539 ;'''a:b'''
4540 ;<i>a:b</i>
4541 ;<span>a:b</span>
4542 ;<div>a:b</div>
4543 ;<div>a
4544 :b</div>
4545 ;{{echo|a:b}}
4546 ;{{echo|''a:b''}}
4547 ;;;''a:b''
4548 !! html+tidy
4549 <dl>
4550 <dt>a</dt>
4551 <dd>b</dd>
4552 <dt><b>a:b</b></dt>
4553 <dt><i>a:b</i></dt>
4554 <dt><span>a:b</span></dt>
4555 <dd>
4556 <div>a:b</div>
4557 </dd>
4558 <dd>
4559 <div>a
4560 <dl>
4561 <dd>b</dd>
4562 </dl>
4563 </div>
4564 </dd>
4565 <dt>a</dt>
4566 <dd>b</dd>
4567 <dt><i>a:b</i></dt>
4568 </dl>
4569 <dl>
4570 <dd>
4571 <dl>
4572 <dd>
4573 <dl>
4574 <dt><i>a:b</i></dt>
4575 </dl>
4576 </dd>
4577 </dl>
4578 </dd>
4579 </dl>
4580 !! html/parsoid
4581 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4582 <dt><b>a:b</b></dt>
4583 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4584 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4585 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4586 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4587 <dd>b</dd>
4588 <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>
4589 <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>
4590 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4591 !! end
4592
4593 !! test
4594 Definition Lists: colons and tables 1
4595 !! wikitext
4596 :{|
4597 | x
4598 |}
4599 :{|
4600 | y
4601 |}
4602 !! html
4603 <dl><dd><table>
4604 <tr>
4605 <td> x
4606 </td></tr></table></dd></dl>
4607 <dl><dd><table>
4608 <tr>
4609 <td> y
4610 </td></tr></table></dd></dl>
4611
4612 !! end
4613
4614 # Parsoid's output (as documented below) differs from php's in this case.
4615 # This is probably a bug. If we fixup parsoid to match php's output, the
4616 # above test should pass and the below test case can be removed. It is
4617 # unclear which output is more desirable.
4618
4619 !! test
4620 Definition Lists: colons and tables 2
4621 !! wikitext
4622 :{|
4623 | x
4624 |}
4625 :{|
4626 | y
4627 |}
4628 !! html/parsoid
4629 <dl><dd><table>
4630 <tr>
4631 <td> x
4632 </td></tr></table></dd>
4633 <dd><table>
4634 <tr>
4635 <td> y
4636 </td></tr></table></dd></dl>
4637 !! end
4638
4639 !! test
4640 Definition Lists: template interaction
4641 !! wikitext
4642 ::{{definition_list}}
4643
4644 :one
4645 ::{{definition_list}}
4646 :::two
4647 :::three
4648 ::four
4649 !! html/parsoid
4650 <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">
4651 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4652
4653 <dl><dd data-parsoid='{}'>one
4654 <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">
4655 </span><dd about="#mwt2">two
4656 <dl><dd>two</dd>
4657 <dd>three</dd></dl></dd>
4658 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4659 !! end
4660
4661
4662 ###
4663 ### External links
4664 ###
4665 !! test
4666 External links: non-bracketed
4667 !! wikitext
4668 Non-bracketed: http://example.com
4669 !! html
4670 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4671 </p>
4672 !! end
4673
4674 # parsoid doesn't explicitly mark autonumbered links, see T55505
4675 !! test
4676 External links: numbered
4677 !! wikitext
4678 Numbered: [http://example.com]
4679 Numbered: [http://example.net]
4680 Numbered: [http://example.com]
4681 !! html/php
4682 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4683 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4684 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4685 </p>
4686 !! html/parsoid
4687 <p>Numbered: <a rel="mw:ExtLink" href="http://example.com"></a>
4688 Numbered: <a rel="mw:ExtLink" href="http://example.net"></a>
4689 Numbered: <a rel="mw:ExtLink" href="http://example.com"></a></p>
4690 !!end
4691
4692 !! test
4693 External links: specified text
4694 !! wikitext
4695 Specified text: [http://example.com link]
4696 !! html
4697 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4698 </p>
4699 !!end
4700
4701 !! test
4702 External links: trail
4703 !! wikitext
4704 Linktrails should not work for external links: [http://example.com link]s
4705 !! html
4706 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4707 </p>
4708 !! end
4709
4710 !! test
4711 External links: dollar sign in URL
4712 !! wikitext
4713 http://example.com/1$2345
4714 !! html
4715 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4716 </p>
4717 !! end
4718
4719 # parsoid doesn't explicitly mark autonumbered links, see T55505
4720 !! test
4721 External links: dollar sign in URL (autonumber)
4722 !! wikitext
4723 [http://example.com/1$2345]
4724 !! html/php
4725 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4726 </p>
4727 !! html/parsoid
4728 <p><a rel="mw:ExtLink" href="http://example.com/1$2345"></a></p>
4729 !!end
4730
4731 !! test
4732 External links: open square bracket forbidden in URL (T6377)
4733 !! options
4734 parsoid=wt2html,wt2wt,html2html
4735 !! wikitext
4736 http://example.com/1[2345
4737 !! html/php
4738 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4739 </p>
4740 !! html/parsoid
4741 <p><a rel="mw:ExtLink" href="http://example.com/1">http://example.com/1</a>[2345</p>
4742 !! end
4743
4744 !! test
4745 External links: open square bracket forbidden in URL (named) (T6377)
4746 !! options
4747 parsoid=wt2html,html2html
4748 !! wikitext
4749 [http://example.com/1[2345]
4750 !! html/php
4751 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4752 </p>
4753 !! html/parsoid
4754 <p><a rel="mw:ExtLink" href="http://example.com/1">[2345</a></p>
4755 !!end
4756
4757 # parsoid adds a space before the link name
4758 !! test
4759 External links: open square bracket forbidden in URL (named) (T6377)
4760 Parsoid variant.
4761 !! wikitext
4762 [http://example.com/1 [2345]
4763 !! html
4764 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4765 </p>
4766 !!end
4767
4768 !! test
4769 External links: nowiki in URL link text (T8230)
4770 !! wikitext
4771 [http://example.com/ <nowiki>''example site''</nowiki>]
4772 !! html
4773 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4774 </p>
4775 !! end
4776
4777 !! test
4778 External links: newline forbidden in text (T8230 regression check)
4779 !! wikitext
4780 [http://example.com/ first
4781 second]
4782 !! html
4783 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4784 second]
4785 </p>
4786 !!end
4787
4788 !! test
4789 External links: Pipe char between url and text
4790 !! wikitext
4791 [http://example.com | link]
4792 !! html
4793 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4794 </p>
4795 !!end
4796
4797 !! test
4798 External links: protocol-relative URL in brackets
4799 !! wikitext
4800 [//example.com/ Test]
4801 !! html
4802 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4803 </p>
4804 !! end
4805
4806 # parsoid doesn't explicitly mark autonumbered links, see T55505
4807 !! test
4808 External links: protocol-relative URL in brackets without text
4809 !! wikitext
4810 [//example.com]
4811 !! html/php
4812 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
4813 </p>
4814 !! html/parsoid
4815 <p><a rel="mw:ExtLink" href="//example.com"></a></p>
4816 !! end
4817
4818 !! test
4819 External links: protocol-relative URL in free text is left alone
4820 !! wikitext
4821 //example.com/Foo
4822 !! html
4823 <p>//example.com/Foo
4824 </p>
4825 !!end
4826
4827 !! test
4828 External links: protocol-relative URL in the middle of a word is left alone (T32269)
4829 !! wikitext
4830 foo//example.com/Foo
4831 !! html
4832 <p>foo//example.com/Foo
4833 </p>
4834 !! end
4835
4836 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
4837 !! test
4838 External links: with no contents
4839 !! options
4840 parsoid=wt2html,wt2wt
4841 !! wikitext
4842 [http://en.wikipedia.org/wiki/Foo]
4843
4844 [[wikipedia:Foo|Bar]]
4845
4846 [[wikipedia:Foo|<span>Bar</span>]]
4847 !! html/php
4848 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
4849 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
4850 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
4851 </p>
4852 !! html/parsoid
4853 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo"></a></p>
4854 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
4855 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
4856 !! end
4857
4858 !! test
4859 External links: Free with trailing punctuation
4860 !! wikitext
4861 http://example.com,
4862 http://example.com;
4863 http://example.com\
4864 http://example.com.
4865 http://example.com:
4866 http://example.com!
4867 http://example.com?
4868 http://example.com)
4869 http://example.com/url_with_(brackets)
4870 (http://example.com/url_without_brackets)
4871 http://example.com/url_with_entity&amp;
4872 http://example.com/url_with_entity&#x26;
4873 http://example.com/url_with_entity&#038;
4874 http://example.com/url_with_entity&nbsp;
4875 http://example.com/url_with_entity&#xA0;
4876 http://example.com/url_with_entity&#160;
4877 http://example.com/url_with_entity&lt;
4878 http://example.com/url_with_entity&#x3C;
4879 http://example.com/url_with_entity&#60;
4880 !! html/php
4881 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
4882 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
4883 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
4884 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
4885 <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/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4890 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4891 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4892 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4893 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4894 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4895 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
4896 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4897 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
4898 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
4899 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
4900 </p>
4901 !! html/parsoid
4902 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a>,
4903 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>;
4904 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>\
4905 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>.
4906 <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/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4911 (<a rel="mw:ExtLink" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4912 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4913 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4914 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4915 <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>
4916 <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>
4917 <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>
4918 <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>
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;#x3C;","srcContent":"&lt;"}'>&lt;</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;#60;","srcContent":"&lt;"}'>&lt;</span></p>
4921 !! end
4922
4923 !! test
4924 External links: tricky Parsoid html2html case
4925 !! options
4926 parsoid=wt2html,wt2wt,html2html
4927 !! wikitext
4928 http://example.com/url_with_entity&amp;amp;
4929 !! html/php
4930 <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>;
4931 </p>
4932 !! html/parsoid
4933 <p><a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;amp">http://example.com/url_with_entity&amp;amp</a>;</p>
4934 !! end
4935
4936 !! test
4937 External links: Free with trailing quotes (T113666)
4938 !! wikitext
4939 '''News:''' Stuff here
4940
4941 news:'a'b''c''d e
4942 !! html/php
4943 <p><b>News:</b> Stuff here
4944 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
4945 </p>
4946 !! html/parsoid
4947 <p><b>News:</b> Stuff here</p>
4948 <p><a rel="mw:ExtLink" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
4949 !! end
4950
4951 !! test
4952 External links: with entity
4953 !! wikitext
4954 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
4955 !! html/php
4956 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
4957 </p>
4958 !! html/parsoid
4959 <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>
4960 !! end
4961
4962 !! test
4963 External links: Lone protocols are never linked (T105697)
4964 !! wikitext
4965 http://
4966 http://;
4967 (http://)
4968 bitcoin:
4969 bitcoin:;
4970 (bitcoin:)
4971 !! html
4972 <p>http://
4973 http://;
4974 (http://)
4975 bitcoin:
4976 bitcoin:;
4977 (bitcoin:)
4978 </p>
4979 !! end
4980
4981 !! test
4982 External links: No preceding word characters allowed (T67278)
4983 !! wikitext
4984 NOPEhttp://example.com
4985 N0http://example.com
4986 ok:http://example.com
4987 ok-http://example.com
4988 !! html
4989 <p>NOPEhttp://example.com
4990 N0http://example.com
4991 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4992 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4993 </p>
4994 !! end
4995
4996 !! test
4997 External links: nofollow domain exception
4998 !! wikitext
4999 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
5000 !! html
5001 <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>.
5002 </p>
5003 !!end
5004
5005 !! test
5006 External image
5007 !! wikitext
5008 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5009 !! html
5010 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5011 </p>
5012 !! end
5013
5014 !! test
5015 External image from https
5016 !! wikitext
5017 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5018 !! html
5019 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
5020 </p>
5021 !! end
5022
5023 !! test
5024 External image (when not allowed)
5025 !! options
5026 wgAllowExternalImages=0
5027 !! wikitext
5028 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
5029 !! html
5030 <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>
5031 </p>
5032 !! end
5033
5034 !! test
5035 Link to non-http image, no img tag
5036 !! wikitext
5037 Link to non-http image, no img tag: ftp://example.com/test.jpg
5038 !! html
5039 <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>
5040 </p>
5041 !! end
5042
5043 !! test
5044 External links: terminating separator
5045 !! wikitext
5046 Terminating separator: http://example.com/thing,
5047 !! html
5048 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
5049 </p>
5050 !! end
5051
5052 !! test
5053 External links: intervening separator
5054 !! wikitext
5055 Intervening separator: http://example.com/1,2,3
5056 !! html
5057 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
5058 </p>
5059 !! end
5060
5061 !! test
5062 External links: old bug with URL in query
5063 !! wikitext
5064 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
5065 !! html
5066 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
5067 </p>
5068 !! end
5069
5070 !! test
5071 External links: old URL-in-URL bug, mixed protocols
5072 !! wikitext
5073 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
5074 !! html
5075 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
5076 </p>
5077 !!end
5078
5079 # Since Parsoid is starting to emit canonical wikitext for links,
5080 # [http://example.com http://example.com] will not RT back to that
5081 # form anymore.
5082 !! test
5083 External links: URL in text
5084 !! options
5085 parsoid=wt2html
5086 !! wikitext
5087 URL in text: [http://example.com http://example.com]
5088 !! html/php
5089 <p>URL in text: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5090 </p>
5091 !! html/parsoid
5092 <p>URL in text: <a rel="mw:ExtLink" href="http://example.com">http://example.com</a></p>
5093 !! end
5094
5095 !! test
5096 External links: Clickable images
5097 !! wikitext
5098 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5099 !! html/php
5100 <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>
5101 </p>
5102 !! html/parsoid
5103 <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>
5104 !! end
5105
5106 !! test
5107 External links: raw ampersand
5108 !! wikitext
5109 Old &amp; use: http://x&y
5110 !! html
5111 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5112 </p>
5113 !! end
5114
5115 !! test
5116 External links: encoded ampersand
5117 !! wikitext
5118 Old &amp; use: http://x&amp;y
5119 !! html/php
5120 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5121 </p>
5122 !! html/parsoid
5123 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y">http://x&amp;y</a></p>
5124 !! end
5125
5126 !! test
5127 External links: encoded equals (T8102)
5128 !! wikitext
5129 http://example.com/?foo&#61;bar
5130 !! html/php
5131 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5132 </p>
5133 !! html/parsoid
5134 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5135 !! end
5136
5137 ##
5138 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5139 ## does it number them. As discussed in T55505, we can identify
5140 ## autonumbered links via CSS.
5141 ##
5142
5143 !! test
5144 External links: [raw ampersand]
5145 !! wikitext
5146 Old &amp; use: [http://x&y]
5147 !! html/php
5148 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5149 </p>
5150 !! html/parsoid
5151 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y"></a></p>
5152 !! end
5153
5154 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5155 # mode will return the [raw ampersand] wikitext
5156 !! test
5157 External links: [encoded ampersand]
5158 !! options
5159 parsoid=wt2html,wt2wt,html2html
5160 !! wikitext
5161 Old &amp; use: [http://x&amp;y]
5162 !! html/php
5163 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5164 </p>
5165 !! html/parsoid
5166 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y"></a></p>
5167 !! end
5168
5169 !! test
5170 External links: [raw equals]
5171 !! wikitext
5172 [http://example.com/?foo=bar]
5173 !! html/php
5174 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5175 </p>
5176 !! html/parsoid
5177 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar"></a></p>
5178 !! end
5179
5180 # note that parsoid html is identical to [raw equals] case; so html2wt
5181 # mode will return the [raw equals] wikitext
5182 !! test
5183 External links: [encoded equals] (T8102)
5184 !! options
5185 parsoid=wt2html,wt2wt,html2html
5186 !! wikitext
5187 [http://example.com/?foo&#61;bar]
5188 !! html/php
5189 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5190 </p>
5191 !! html/parsoid
5192 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar"></a></p>
5193 !! end
5194
5195 # xxx parsoid strips the IDN character, so the round-trip tests will
5196 # obviously fail and are disabled. --cscott
5197 !! test
5198 External links: [IDN ignored character reference in hostname; strip it right off]
5199 !! options
5200 parsoid=wt2html,wt2wt,html2html
5201 !! wikitext
5202 [http://e&zwnj;xample.com/]
5203 !! html/php
5204 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5205 </p>
5206 !! html/parsoid
5207 <p><a rel="mw:ExtLink" href="http://example.com/"></a></p>
5208 !! end
5209
5210 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5211 # Where an external link could easily circumvent the sanitization of the text of
5212 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5213 # test demands a higher standard. That's a bit strange.
5214 #
5215 # Example:
5216 #
5217 # http://e‌xample.com -> [http://example.com|http://example.com]
5218 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5219 #
5220 # The first example is sanitized, but the second is not. Any security benefits
5221 # from this production are trivial to circumvent. Either remove this test and
5222 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5223 # the test accordingly.
5224 #
5225 # All our love,
5226 # The Parsoid team.
5227 # xxx parsoid strips the IDN character, so the round-trip tests will
5228 # obviously fail and are disabled. --cscott
5229 !! test
5230 External links: IDN ignored character reference in hostname; strip it right off
5231 !! options
5232 parsoid=wt2html,html2html
5233 !! wikitext
5234 http://e&zwnj;xample.com/
5235 !! html/php
5236 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5237 </p>
5238 !! html/parsoid
5239 <p><a rel="mw:ExtLink" href="http://example.com/">http://example.com/</a></p>
5240 !! end
5241
5242 !! test
5243 External links: www.jpeg.org (T2554)
5244 !! wikitext
5245 http://www.jpeg.org
5246 !! html
5247 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5248 </p>
5249 !! end
5250
5251 # parsoid doesn't explicitly mark autonumbered links, see T55505
5252 !! test
5253 External links: URL within URL (T2002)
5254 !! wikitext
5255 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5256 !! html/php
5257 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5258 </p>
5259 !! html/parsoid
5260 <p><a rel="mw:ExtLink" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp"></a></p>
5261 !! end
5262
5263 !! test
5264 T2361: URL inside bracketed URL
5265 !! wikitext
5266 [http://www.example.com/foo http://www.example.com/bar]
5267 !! html
5268 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5269 </p>
5270 !! end
5271
5272 !! test
5273 T2361: URL within URL, not bracketed
5274 !! wikitext
5275 http://www.example.com/foo?=http://www.example.com/bar
5276 !! html
5277 <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>
5278 </p>
5279 !! end
5280
5281 !! test
5282 T2289: ">"-token in URL-tail
5283 !! wikitext
5284 http://www.example.com/<hello>
5285 !! html
5286 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5287 </p>
5288 !!end
5289
5290 !! test
5291 T2289: literal ">"-token in URL-tail
5292 !! wikitext
5293 http://www.example.com/<b>html</b>
5294 !! html/php
5295 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5296 </p>
5297 !! html/parsoid
5298 <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>
5299 !! end
5300
5301 !! test
5302 T2289: ">"-token in bracketed URL
5303 !! wikitext
5304 [http://www.example.com/<hello> stuff]
5305 !! html
5306 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5307 </p>
5308 !!end
5309
5310 !! test
5311 T2289: literal ">"-token in bracketed URL
5312 !! wikitext
5313 [http://www.example.com/<b>html</b> stuff]
5314 !! html
5315 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5316 </p>
5317 !!end
5318
5319 !! test
5320 T2289: literal double quote at end of URL
5321 !! wikitext
5322 http://www.example.com/"hello"
5323 !! html
5324 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5325 </p>
5326 !!end
5327
5328 !! test
5329 T2289: literal double quote in bracketed URL
5330 !! wikitext
5331 [http://www.example.com/"hello" stuff]
5332 !! html
5333 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5334 </p>
5335 !!end
5336
5337 !! test
5338 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5339 !! wikitext
5340 [http://www.example.com test]
5341 !! html
5342 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5343 </p>
5344 !! end
5345
5346 !! test
5347 External links: link text with spaces
5348 !! wikitext
5349 [http://www.example.com a b c]
5350 [http://www.example.com ''a'' ''b'']
5351 !! html
5352 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5353 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5354 </p>
5355 !! end
5356
5357 !! test
5358 External links: wiki links within external link (T5695)
5359 !! options
5360 parsoid=wt2html,html2html
5361 !! wikitext
5362 [http://example.com [[wikilink]] embedded in ext link]
5363 !! html/php
5364 <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>
5365 </p>
5366 !! html/parsoid
5367 <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>
5368 !! end
5369
5370 !! test
5371 T2787: Links with one slash after the url protocol are invalid
5372 !! wikitext
5373 http:/example.com
5374
5375 [http:/example.com title]
5376 !! html
5377 <p>http:/example.com
5378 </p><p>[http:/example.com title]
5379 </p>
5380 !! end
5381
5382 !! test
5383 Bracketed external links with template-generated invalid target
5384 !! wikitext
5385 [{{echo|http:/example.com}} title]
5386 !! html
5387 <p>[http:/example.com title]
5388 </p>
5389 !! end
5390
5391 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5392 !! test
5393 Broken wikilinks (but not external links) prevent templates from closing
5394 !! options
5395 parsoid=wt2html
5396 !! wikitext
5397 [http://example.com x
5398
5399 {{echo|[http://example.com x}}
5400
5401 [[Foo
5402
5403 {{echo|[[Foo}}
5404 !! html/php
5405 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5406 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5407 </p><p>[[Foo
5408 </p><p>{{echo|[[Foo}}
5409 </p>
5410 !! html/parsoid
5411 <p>[<a rel="mw:ExtLink" href="http://example.com">http://example.com</a> x</p>
5412 <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>
5413 <p>[[Foo</p>
5414 <p>{{echo|[[Foo}}</p>
5415 !! end
5416
5417 !! test
5418 Wikilinks with embedded newlines are not broken
5419 !! wikitext
5420 {{echo|[[ Foo
5421 B
5422 C]]}}
5423 !! html/php
5424 <p>[[ Foo
5425 B
5426 C]]
5427 </p>
5428 !! html/parsoid
5429 <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>
5430 !! end
5431
5432 !! test
5433 Broken templates
5434 !! options
5435 parsoid=wt2html
5436 !! wikitext
5437 {{echo|[[Foo|}}]]
5438
5439 [[Foo|{{echo|]]}}
5440 !! html/php
5441 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5442 </p><p>[[Foo|]]
5443 </p>
5444 !! html/parsoid
5445 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5446 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5447 !! end
5448
5449 !! test
5450 T4702: Mismatched <i>, <b> and <a> tags are invalid
5451 !! wikitext
5452 ''[http://example.com text'']
5453 [http://example.com '''text]'''
5454 ''Something [http://example.com in italic'']
5455 ''Something [http://example.com mixed''''', even bold]'''
5456 '''''Now [http://example.com both''''']
5457 !! html
5458 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5459 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5460 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5461 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5462 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5463 </p>
5464 !! end
5465
5466
5467 !! test
5468 T6781: %26 in URL
5469 !! wikitext
5470 http://www.example.com/?title=AT%26T
5471 !! html/php
5472 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5473 </p>
5474 !! html/parsoid
5475 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a></p>
5476 !! end
5477
5478 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5479 # % is actually legal in HTML5. Any change in output would need testing though.
5480 !! test
5481 T6781, T7267: %25 in URL
5482 !! wikitext
5483 http://www.example.com/?title=100%25_Bran
5484 !! html/php
5485 <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>
5486 </p>
5487 !! html/parsoid
5488 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=100%25_Bran">http://www.example.com/?title=100%25_Bran</a></p>
5489 !! end
5490
5491 !! test
5492 T6781, T7267: %28, %29 in URL
5493 !! wikitext
5494 http://www.example.com/?title=Ben-Hur_%281959_film%29
5495 !! html/php
5496 <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>
5497 </p>
5498 !! html/parsoid
5499 <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>
5500 !! end
5501
5502
5503 !! test
5504 T6781: %26 in autonumber URL
5505 !! wikitext
5506 [http://www.example.com/?title=AT%26T]
5507 !! html/php
5508 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5509 </p>
5510 !! html/parsoid
5511 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T"></a></p>
5512 !! end
5513
5514 !! test
5515 T6781, T7267: %26 in autonumber URL
5516 !! wikitext
5517 [http://www.example.com/?title=100%25_Bran]
5518 !! html/php
5519 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5520 </p>
5521 !! html/parsoid
5522 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=100%25_Bran"></a></p>
5523 !! end
5524
5525 !! test
5526 T6781, T7267: %28, %29 in autonumber URL
5527 !! wikitext
5528 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5529 !! html/php
5530 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5531 </p>
5532 !! html/parsoid
5533 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5534 !! end
5535
5536
5537 !! test
5538 T6781: %26 in bracketed URL
5539 !! wikitext
5540 [http://www.example.com/?title=AT%26T link]
5541 !! html/php
5542 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5543 </p>
5544 !! html/parsoid
5545 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T">link</a></p>
5546 !! end
5547
5548 !! test
5549 T6781, T7267: %25 in bracketed URL
5550 !! wikitext
5551 [http://www.example.com/?title=100%25_Bran link]
5552 !! html
5553 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5554 </p>
5555 !! end
5556
5557 !! test
5558 T6781, T7267: %28, %29 in bracketed URL
5559 !! wikitext
5560 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5561 !! html/php
5562 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5563 </p>
5564 !! html/parsoid
5565 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5566 !! end
5567
5568 !! test
5569 External link containing a period in the anchor. (T65947)
5570 !! wikitext
5571 [//foo.org/bar#baz. bang]
5572
5573 [//foo.org/bar. bang]
5574 !! html/php
5575 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5576 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5577 </p>
5578 !! html/parsoid
5579 <p><a rel="mw:ExtLink" href="//foo.org/bar#baz.">bang</a></p>
5580 <p><a rel="mw:ExtLink" href="//foo.org/bar.">bang</a></p>
5581 !! end
5582
5583 !! test
5584 External link containing a single quote. (T65947)
5585 !! wikitext
5586 [//foo.org/bar'baz]
5587
5588 [//foo.org/bar'baz bang]
5589 !! html/php
5590 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar&#39;baz">[1]</a>
5591 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar&#39;baz">bang</a>
5592 </p>
5593 !! html/parsoid
5594 <p><a rel="mw:ExtLink" href="//foo.org/bar'baz"></a></p>
5595 <p><a rel="mw:ExtLink" href="//foo.org/bar'baz">bang</a></p>
5596 !! end
5597
5598 !! test
5599 External link containing double-single-quotes in text '' (T6598 sanity check)
5600 !! wikitext
5601 Some [http://example.com/ pretty ''italics'' and stuff]!
5602 !! html
5603 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5604 </p>
5605 !! end
5606
5607 !! test
5608 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5609 !! wikitext
5610 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5611 !! html
5612 <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>
5613 </p>
5614 !! end
5615
5616 !! test
5617 External link containing double-single-quotes with no space separating the url from text in italics
5618 !! wikitext
5619 [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]].]
5620 !! html/php
5621 <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>
5622 </p>
5623 !! html/php+tidy
5624 <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>
5625 !! html/parsoid
5626 <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>
5627 !! end
5628
5629 !! test
5630 External link with comments in link text
5631 !! wikitext
5632 [http://www.google.com Google <!-- comment -->]
5633 !! html/php
5634 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5635 </p>
5636 !! html/parsoid
5637 <p><a rel="mw:ExtLink" href="http://www.google.com">Google <!-- comment --></a></p>
5638 !! end
5639
5640 !! test
5641 External link to bare IPv4 address
5642 !! wikitext
5643 [http://192.168.0.1 Link]
5644 !! html/php
5645 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5646 </p>
5647 !! html/parsoid
5648 <p><a rel="mw:ExtLink" href="http://192.168.0.1">Link</a></p>
5649 !! end
5650
5651 !! test
5652 URL-encoding in URL functions (single parameter)
5653 !! wikitext
5654 {{localurl:Some page|amp=&}}
5655 !! html
5656 <p>/index.php?title=Some_page&amp;amp=&amp;
5657 </p>
5658 !! end
5659
5660 !! test
5661 URL-encoding in URL functions (multiple parameters)
5662 !! wikitext
5663 {{localurl:Some page|q=?&amp=&}}
5664 !! html
5665 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5666 </p>
5667 !! end
5668
5669 !! test
5670 Brackets in urls
5671 !! wikitext
5672 http://example.com/index.php?foozoid%5B%5D=bar
5673
5674 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5675 !! html/php
5676 <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>
5677 </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>
5678 </p>
5679 !! html/parsoid
5680 <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>
5681
5682 <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>
5683 !! end
5684
5685 !! test
5686 IPv6 urls, autolink format (T23261)
5687 !! wikitext
5688 http://[2404:130:0:1000::187:2]/index.php
5689
5690 Examples from RFC 2373, section 2.2:
5691 * http://[1080::8:800:200C:417A]/unicast
5692 * http://[FF01::101]/multicast
5693 * http://[::1]/loopback
5694 * http://[::]/unspecified
5695 * http://[::13.1.68.3]/ipv4compat
5696 * http://[::FFFF:129.144.52.38]/ipv4compat
5697
5698 Examples from RFC 2732, section 2:
5699 * http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5700 * http://[1080:0:0:0:8:800:200C:417A]/index.html
5701 * http://[3ffe:2a00:100:7031::1]
5702 * http://[1080::8:800:200C:417A]/foo
5703 * http://[::192.9.5.5]/ipng
5704 * http://[::FFFF:129.144.52.38]:80/index.html
5705 * http://[2010:836B:4179::836B:4179]
5706
5707 !! html/php
5708 <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>
5709 </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:
5710 </p>
5711 <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>
5712 <li> <a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5713 <li> <a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5714 <li> <a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5715 <li> <a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5716 <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>
5717 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5718 </p>
5719 <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>
5720 <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>
5721 <li> <a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5722 <li> <a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5723 <li> <a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5724 <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>
5725 <li> <a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5726
5727 !! html/parsoid
5728 <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>
5729
5730 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
5731 <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
5732 <li> <a rel="mw:ExtLink" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5733 <li> <a rel="mw:ExtLink" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5734 <li> <a rel="mw:ExtLink" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5735 <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5736 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
5737
5738 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
5739 <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>
5740 <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>
5741 <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5742 <li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5743 <li> <a rel="mw:ExtLink" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5744 <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>
5745 <li> <a rel="mw:ExtLink" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5746 !! end
5747
5748 !! test
5749 IPv6 urls, bracketed format (T23261)
5750 !! wikitext
5751 [http://[2404:130:0:1000::187:2]/index.php test]
5752
5753 Examples from RFC 2373, section 2.2:
5754 * [http://[1080::8:800:200C:417A] unicast]
5755 * [http://[FF01::101] multicast]
5756 * [http://[::1]/ loopback]
5757 * [http://[::] unspecified]
5758 * [http://[::13.1.68.3] ipv4compat]
5759 * [http://[::FFFF:129.144.52.38] ipv4compat]
5760
5761 Examples from RFC 2732, section 2:
5762 * [http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5763 * [http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5764 * [http://[3ffe:2a00:100:7031::1] 3]
5765 * [http://[1080::8:800:200C:417A]/foo 4]
5766 * [http://[::192.9.5.5]/ipng 5]
5767 * [http://[::FFFF:129.144.52.38]:80/index.html 6]
5768 * [http://[2010:836B:4179::836B:4179] 7]
5769
5770 !! html/php
5771 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5772 </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:
5773 </p>
5774 <ul><li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5775 <li> <a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5776 <li> <a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5777 <li> <a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5778 <li> <a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5779 <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5780 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5781 </p>
5782 <ul><li> <a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5783 <li> <a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5784 <li> <a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5785 <li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5786 <li> <a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5787 <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5788 <li> <a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5789
5790 !! html/parsoid
5791 <p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5792
5793 <p>Examples from <a href="https://tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
5794 <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5795 <li> <a rel="mw:ExtLink" href="http://[FF01::101]">multicast</a></li>
5796 <li> <a rel="mw:ExtLink" href="http://[::1]/">loopback</a></li>
5797 <li> <a rel="mw:ExtLink" href="http://[::]">unspecified</a></li>
5798 <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]">ipv4compat</a></li>
5799 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5800
5801 <p>Examples from <a href="https://tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
5802 <ul><li> <a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5803 <li> <a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5804 <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5805 <li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5806 <li> <a rel="mw:ExtLink" href="http://[::192.9.5.5]/ipng">5</a></li>
5807 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5808 <li> <a rel="mw:ExtLink" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5809 !! end
5810
5811 !! test
5812 Non-extlinks in brackets
5813 !! wikitext
5814 [foo]
5815 [foo bar]
5816 [foo ''bar'']
5817 [fool's] errand
5818 [fool's errand]
5819 [{{echo|foo}}]
5820 [{{echo|foo}} bar]
5821 [{{echo|foo}} ''bar'']
5822 [{{echo|foo}}l's] errand
5823 [{{echo|foo}}l's errand]
5824 [url={{echo|foo}}]
5825 [url=http://example.com]
5826 [http:// bare protocols don't count]
5827 !! html/php
5828 <p>[foo]
5829 [foo bar]
5830 [foo <i>bar</i>]
5831 [fool's] errand
5832 [fool's errand]
5833 [foo]
5834 [foo bar]
5835 [foo <i>bar</i>]
5836 [fool's] errand
5837 [fool's errand]
5838 [url=foo]
5839 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
5840 [http:// bare protocols don't count]
5841 </p>
5842 !! html/parsoid
5843 <p>[foo]
5844 [foo bar]
5845 [foo <i>bar</i>]
5846 [fool's] errand
5847 [fool's errand]
5848 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span>]
5849 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span> bar]
5850 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span> <i>bar</i>]
5851 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}l&#39;s"}'>fool's</span>] errand
5852 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}l&#39;s"}'>fool's</span> errand]
5853 [<span typeof="mw:Placeholder" data-parsoid='{"src":"url={{echo|foo}}"}'>url=foo</span>]
5854 [url=<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>]
5855 [http:// bare protocols don't count]</p>
5856 !! end
5857
5858 !! test
5859 Percent encoding in external links
5860 !! wikitext
5861 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
5862 !! html/php
5863 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
5864 </p>
5865 !! html/parsoid
5866 <p><a rel="mw:ExtLink"
5867 href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
5868 !! end
5869
5870 !! test
5871 Use url link syntax for links where the content is equal the link target
5872 !! wikitext
5873 http://example.com
5874 !! html/php
5875 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5876 </p>
5877 !! html/parsoid
5878 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></p>
5879 !! end
5880
5881 !! test
5882 Parenthesis in external links, especially URL links
5883 !! wikitext
5884 http://example.com)
5885
5886 http://example.com/test)
5887
5888 http://example.com/(test)
5889
5890 http://example.com/((test)
5891
5892 (http://example.com/(test))
5893
5894 (http://example.com/(test)))))
5895
5896 http://example.com/a)b
5897
5898 [http://example.com) foo]
5899 !! html/php
5900 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5901 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
5902 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
5903 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
5904 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</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/a)b">http://example.com/a)b</a>
5907 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
5908 </p>
5909 !! html/parsoid
5910 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a>)</p>
5911 <p><a rel="mw:ExtLink" href="http://example.com/test">http://example.com/test</a>)</p>
5912 <p><a rel="mw:ExtLink" href="http://example.com/(test)">http://example.com/(test)</a></p>
5913 <p><a rel="mw:ExtLink" href="http://example.com/((test)">http://example.com/((test)</a></p>
5914 <p>(<a rel="mw:ExtLink" href="http://example.com/(test))">http://example.com/(test))</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/a)b">http://example.com/a)b</a></p>
5917 <p><a rel="mw:ExtLink" href="http://example.com)">foo</a></p>
5918 !! end
5919
5920 !! test
5921 Parenthesis in external links, w/ transclusion or comment
5922 !! wikitext
5923 (http://example.com/{{echo|hi}})
5924
5925 (http://example.com<!-- hi -->)
5926 !! html/php
5927 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
5928 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5929 </p>
5930 !! html/parsoid
5931 <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>
5932
5933 <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>
5934 !! end
5935
5936 !! test
5937 Serialize <a> tags with invalid link targets as plain text
5938 !! options
5939 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
5940 !! html/parsoid
5941 <a rel="mw:WikiLink" href="[[foo]]">text</a>
5942 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
5943 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
5944 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
5945 !! wikitext
5946 text
5947 <nowiki>*</nowiki>text
5948 <nowiki>[[foo]]</nowiki>
5949 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
5950 !! end
5951
5952 !! test
5953 mw:ExtLink -vs- mw:WikiLink (T94723)
5954 !! options
5955 parsoid=html2wt
5956 !! html/parsoid
5957 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
5958 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
5959 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5960 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5961 <p>
5962 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5963 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5964 </p>
5965 !! wikitext
5966 [[Foo|Bar]]
5967 [[Foo|Bar]]
5968 [[:en:Foo|Bar]]
5969 [[:en:Foo|Bar]]
5970
5971 [[:en:European_Robin|European Robin]]
5972 [[:en:European_Robin|European Robin]]
5973 !! end
5974
5975 !! test
5976 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
5977 !! options
5978 parsoid=wt2wt
5979 !! wikitext
5980 [http://en.wikipedia.org/wiki/European_Robin European Robin]
5981 !! html/parsoid
5982 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
5983 !! end
5984
5985
5986 ###
5987 ### Quotes
5988 ###
5989
5990 !! test
5991 Quotes
5992 !! wikitext
5993 Normal text. '''Bold text.''' Normal text. ''Italic text.''
5994
5995 Normal text. '''''Bold italic text.''''' Normal text.
5996 !! html
5997 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
5998 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
5999 </p>
6000 !! end
6001
6002
6003 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
6004 # parser strips. The wikitext contains just the first half of the bold
6005 # quote pair.
6006 !! test
6007 Unclosed and unmatched quotes
6008 !! wikitext
6009 '''''Bold italic text '''with bold deactivated''' in between.'''''
6010
6011 '''''Bold italic text ''with italic deactivated'' in between.'''''
6012
6013 '''Bold text..
6014
6015 ..spanning two paragraphs (should not work).'''
6016
6017 '''Bold tag left open
6018
6019 ''Italic tag left open
6020
6021 Normal text.
6022
6023 <!-- Unmatching number of opening, closing tags: -->
6024 '''This year''''s election ''should'' beat '''last year''''s.
6025
6026 ''Tom'''s car is bigger than ''Susan'''s.
6027
6028 Plain ''italic'''s plain
6029 !! html/php
6030 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6031 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6032 </p><p><b>Bold text..</b>
6033 </p><p>..spanning two paragraphs (should not work).
6034 </p><p><b>Bold tag left open</b>
6035 </p><p><i>Italic tag left open</i>
6036 </p><p>Normal text.
6037 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6038 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6039 </p><p>Plain <i>italic'</i>s plain
6040 </p>
6041 !! html/parsoid
6042 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
6043 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
6044 </p><p><b>Bold text..</b>
6045 </p><p>..spanning two paragraphs (should not work).<b></b>
6046 </p><p><b>Bold tag left open</b>
6047 </p><p><i>Italic tag left open</i>
6048 </p><p>Normal text.
6049 </p>
6050 <!-- Unmatching number of opening, closing tags: -->
6051 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
6052 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
6053 </p><p>Plain <i>italic'</i>s plain
6054 </p>
6055 !! end
6056
6057 ###
6058 ### Tables
6059 ###
6060 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
6061 ###
6062
6063 # This should not produce <table></table> as <table><tr><td></td></tr></table>
6064 # is the bare minimum required by the spec, see:
6065 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
6066 # Parsoid team replies: empty table tags are legal in HTML5
6067 !! test
6068 A table with no data.
6069 !! options
6070 parsoid=wt2html
6071 !! wikitext
6072 {||}
6073 !! html/php
6074
6075 !! html/parsoid
6076 <table></table>
6077
6078 !! end
6079
6080 !! test
6081 A table with stray table end tags on start tag line (wt2html)
6082 !! options
6083 parsoid=wt2html
6084 !! wikitext
6085 {|style="color: red;"|}
6086
6087 {|style="color: red;" |}
6088 |foo
6089 |}
6090
6091 {|style="color: red;"|} id="foo"
6092 |foo
6093 |}
6094
6095 {|style="color: red;" |} id="foo"
6096 |foo
6097 |}
6098 !! html
6099 <table style="color: red;"></table>
6100
6101 <table style="color: red;">
6102 <tbody><tr>
6103 <td>foo</td>
6104 </tr></tbody>
6105 </table>
6106
6107 <table style="color: red;" id="foo">
6108 <tbody><tr>
6109 <td>foo</td>
6110 </tr></tbody>
6111 </table>
6112
6113 <table style="color: red;" id="foo">
6114 <tbody><tr>
6115 <td>foo</td>
6116 </tr></tbody>
6117 </table>
6118
6119 !! end
6120
6121 !! test
6122 A table with no data (take 2)
6123 !! wikitext
6124 {|
6125 |}
6126 !! html/parsoid
6127 <table></table>
6128 !! end
6129
6130 # A table with nothing but a caption is invalid XHTML, we might want to render
6131 # this as <p>caption</p>
6132 # Parsoid team replies: table with only a caption is legal in HTML5
6133 !! test
6134 A table with nothing but a caption
6135 !! wikitext
6136 {|
6137 |+ caption
6138 |}
6139 !! html/php
6140 <table>
6141 <caption> caption
6142 </caption><tr><td></td></tr></table>
6143
6144 !! html/parsoid
6145 <table><caption> caption</caption></table>
6146 !! end
6147
6148 !! test
6149 A table with caption with default-spaced attributes and a table row
6150 !! wikitext
6151 {|
6152 |+ style="color: red;" | caption1
6153 |-
6154 | foo
6155 |}
6156 !! html
6157 <table>
6158 <caption style="color: red;"> caption1
6159 </caption>
6160 <tr>
6161 <td> foo
6162 </td></tr></table>
6163
6164 !! end
6165
6166 !! test
6167 A table with captions with non-default spaced attributes and a table row
6168 !! wikitext
6169 {|
6170 |+style="color: red;"|caption2
6171 |+ style="color: red;"| caption3
6172 |-
6173 | foo
6174 |}
6175 !! html
6176 <table>
6177 <caption style="color: red;">caption2
6178 </caption>
6179 <caption style="color: red;"> caption3
6180 </caption>
6181 <tr>
6182 <td> foo
6183 </td></tr></table>
6184
6185 !! end
6186
6187 !! test
6188 Table td-cell syntax variations
6189 !! wikitext
6190 {|
6191 | foo bar foo | baz
6192 | foo bar foo || baz
6193 | style='color:red;' | baz
6194 | style='color:red;' || baz
6195 |}
6196 !! html
6197 <table>
6198 <tr>
6199 <td> baz
6200 </td>
6201 <td> foo bar foo </td>
6202 <td> baz
6203 </td>
6204 <td style="color:red;"> baz
6205 </td>
6206 <td> style='color:red;' </td>
6207 <td> baz
6208 </td></tr></table>
6209
6210 !! end
6211
6212 !! test
6213 Simple table
6214 !! wikitext
6215 {|
6216 | 1 || 2
6217 |-
6218 | 3 || 4
6219 |}
6220 !! html
6221 <table>
6222 <tr>
6223 <td> 1 </td>
6224 <td> 2
6225 </td></tr>
6226 <tr>
6227 <td> 3 </td>
6228 <td> 4
6229 </td></tr></table>
6230
6231 !! end
6232
6233 !! test
6234 Simple table but with multiple dashes for row wikitext
6235 !! wikitext
6236 {|
6237 | foo
6238 |-----
6239 | bar
6240 |}
6241 !! html
6242 <table>
6243 <tr>
6244 <td> foo
6245 </td></tr>
6246 <tr>
6247 <td> bar
6248 </td></tr></table>
6249
6250 !! end
6251
6252 !! test
6253 Multiplication table
6254 !! wikitext
6255 {| border="1" cellpadding="2"
6256 |+Multiplication table
6257 |-
6258 ! &times; !! 1 !! 2 !! 3
6259 |-
6260 ! 1
6261 | 1 || 2 || 3
6262 |-
6263 ! 2
6264 | 2 || 4 || 6
6265 |-
6266 ! 3
6267 | 3 || 6 || 9
6268 |-
6269 ! 4
6270 | 4 || 8 || 12
6271 |-
6272 ! 5
6273 | 5 || 10 || 15
6274 |}
6275 !! html
6276 <table border="1" cellpadding="2">
6277 <caption>Multiplication table
6278 </caption>
6279 <tr>
6280 <th> &#215; </th>
6281 <th> 1 </th>
6282 <th> 2 </th>
6283 <th> 3
6284 </th></tr>
6285 <tr>
6286 <th> 1
6287 </th>
6288 <td> 1 </td>
6289 <td> 2 </td>
6290 <td> 3
6291 </td></tr>
6292 <tr>
6293 <th> 2
6294 </th>
6295 <td> 2 </td>
6296 <td> 4 </td>
6297 <td> 6
6298 </td></tr>
6299 <tr>
6300 <th> 3
6301 </th>
6302 <td> 3 </td>
6303 <td> 6 </td>
6304 <td> 9
6305 </td></tr>
6306 <tr>
6307 <th> 4
6308 </th>
6309 <td> 4 </td>
6310 <td> 8 </td>
6311 <td> 12
6312 </td></tr>
6313 <tr>
6314 <th> 5
6315 </th>
6316 <td> 5 </td>
6317 <td> 10 </td>
6318 <td> 15
6319 </td></tr></table>
6320
6321 !! end
6322
6323 !! test
6324 Accept "||" in table headings
6325 !! wikitext
6326 {|
6327 !h1 || h2
6328 |}
6329 !! html
6330 <table>
6331 <tr>
6332 <th>h1 </th>
6333 <th> h2
6334 </th></tr></table>
6335
6336 !! end
6337
6338 !! test
6339 Accept "!!" in table data
6340 !! wikitext
6341 {|
6342 | Foo!! ||
6343 |}
6344 !! html
6345 <table>
6346 <tr>
6347 <td> Foo!! </td>
6348 <td>
6349 </td></tr></table>
6350
6351 !! html/parsoid
6352 <table>
6353 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx":"row","autoInsertedEnd":true}'></td></tr>
6354 </tbody></table>
6355 !! end
6356
6357 !! test
6358 Accept "||" in indented table headings
6359 !! wikitext
6360 :{|
6361 !h1 || h2
6362 |}
6363 !! html
6364 <dl><dd><table>
6365 <tr>
6366 <th>h1 </th>
6367 <th> h2
6368 </th></tr></table></dd></dl>
6369
6370 !! end
6371
6372 !! test
6373 Accept "!!" in templates
6374 !! wikitext
6375 {|
6376 !a {{echo|b!!c}}
6377 |}
6378 !! html/php
6379 <table>
6380 <tr>
6381 <th>a b</th>
6382 <th>c
6383 </th></tr></table>
6384
6385 !! html/parsoid
6386 <table>
6387 <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>
6388 !! end
6389
6390 !! test
6391 Accept "!!" in table headings after newline
6392 !! wikitext
6393 {|
6394 !a
6395 b!!c
6396 |}
6397 !! html/php
6398 <table>
6399 <tr>
6400 <th>a
6401 <p>b!!c
6402 </p>
6403 </th></tr></table>
6404
6405 !! html/parsoid
6406 <table>
6407 <tbody><tr><th>a
6408 <p>b!!c</p></th></tr>
6409 </tbody></table>
6410 !! end
6411
6412 !! test
6413 Accept "!!" in table data of mixed wikitext / html syntax
6414 !! wikitext
6415 {|
6416 !a
6417 <tr><td>b!!c</td></tr>
6418 |}
6419 !! html+tidy
6420 <table>
6421 <tr>
6422 <th>a</th>
6423 </tr>
6424 <tr>
6425 <td>b!!c</td>
6426 </tr>
6427 </table>
6428 !! html/parsoid
6429 <table>
6430 <tbody><tr><th>a</th></tr>
6431 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6432 </tbody></table>
6433 !! end
6434
6435 !! test
6436 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6437 !! wikitext
6438 {|
6439 !| h1
6440 || a
6441 |}
6442 !! html
6443 <table>
6444 <tr>
6445 <th> h1
6446 </th>
6447 <td> a
6448 </td></tr></table>
6449
6450 !! end
6451
6452 !!test
6453 Accept "| !" at start of line in tables (ignore !-attribute)
6454 !! wikitext
6455 {|
6456 |-
6457 | !style="color:red" | bar
6458 |}
6459 !! html
6460 <table>
6461
6462 <tr>
6463 <td> bar
6464 </td></tr></table>
6465
6466 !!end
6467
6468 !!test
6469 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 +/-
6470 !! wikitext
6471 {|
6472 |-
6473 |style='color:red;'|+1
6474 |style='color:blue;'|-1
6475 |-
6476 | 1 || 2 || 3
6477 | 1 ||+2 ||-3
6478 |-
6479 | +1
6480 | -1
6481 |}
6482 !! html
6483 <table>
6484
6485 <tr>
6486 <td style="color:red;">+1
6487 </td>
6488 <td style="color:blue;">-1
6489 </td></tr>
6490 <tr>
6491 <td> 1 </td>
6492 <td> 2 </td>
6493 <td> 3
6494 </td>
6495 <td> 1 </td>
6496 <td>+2 </td>
6497 <td>-3
6498 </td></tr>
6499 <tr>
6500 <td> +1
6501 </td>
6502 <td> -1
6503 </td></tr></table>
6504
6505 !!end
6506
6507 !! test
6508 Table rowspan
6509 !! wikitext
6510 {| border=1
6511 | Cell 1, row 1
6512 |rowspan=2| Cell 2, row 1 (and 2)
6513 | Cell 3, row 1
6514 |-
6515 | Cell 1, row 2
6516 | Cell 3, row 2
6517 |}
6518 !! html
6519 <table border="1">
6520 <tr>
6521 <td> Cell 1, row 1
6522 </td>
6523 <td rowspan="2"> Cell 2, row 1 (and 2)
6524 </td>
6525 <td> Cell 3, row 1
6526 </td></tr>
6527 <tr>
6528 <td> Cell 1, row 2
6529 </td>
6530 <td> Cell 3, row 2
6531 </td></tr></table>
6532
6533 !! end
6534
6535 !! test
6536 Nested table
6537 !! wikitext
6538 {| border=1
6539 | &alpha;
6540 |
6541 {| bgcolor=#ABCDEF border=2
6542 |nested
6543 |-
6544 |table
6545 |}
6546 |the original table again
6547 |}
6548 !! html
6549 <table border="1">
6550 <tr>
6551 <td> &#945;
6552 </td>
6553 <td>
6554 <table bgcolor="#ABCDEF" border="2">
6555 <tr>
6556 <td>nested
6557 </td></tr>
6558 <tr>
6559 <td>table
6560 </td></tr></table>
6561 </td>
6562 <td>the original table again
6563 </td></tr></table>
6564
6565 !! end
6566
6567 !! test
6568 Invalid attributes in table cell (T3830)
6569 !! wikitext
6570 {|
6571 |Cell:|broken
6572 |}
6573 !! html
6574 <table>
6575 <tr>
6576 <td>broken
6577 </td></tr></table>
6578
6579 !! end
6580
6581 !! test
6582 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6583 !! wikitext
6584 {|
6585 | title="foo" |bar
6586 | title="foo<nowiki>|</nowiki>" |bar
6587 | title="foo<nowiki>|</nowiki>" bar
6588 |}
6589 !! html/php
6590 <table>
6591 <tr>
6592 <td title="foo">bar
6593 </td>
6594 <td title="foo&#124;">bar
6595 </td>
6596 <td> title="foo|" bar
6597 </td></tr></table>
6598
6599 !! html/parsoid
6600 <table>
6601 <tbody><tr><td title="foo">bar</td>
6602 <td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
6603 <td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6604 </tbody></table>
6605 !! end
6606
6607 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6608 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6609 # *2wt modes will fail.
6610 !! test
6611 Table security: embedded pipes
6612 !! options
6613 parsoid=wt2html,html2html
6614 !! wikitext
6615 {|
6616 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6617 !! html/php
6618 <table>
6619 <tr>
6620 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6621 <td>]" onmouseover="alert(document.cookie)"&gt;test
6622 </td>
6623 </tr>
6624 </table>
6625
6626 !! html/parsoid
6627 <table><tbody>
6628 <tr>
6629 <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>
6630 !! end
6631
6632 !! test
6633 Element attributes with double ! should not be broken up by <th>
6634 !! wikitext
6635 {|
6636 ! hi <div class="!!">ha</div> ho
6637 |}
6638 !! html/php
6639 <table>
6640 <tr>
6641 <th> hi <div class="!!">ha</div> ho
6642 </th></tr></table>
6643
6644 !! html/parsoid
6645 <table>
6646 <tbody><tr><th> hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6647 </tbody></table>
6648 !! end
6649
6650 !! test
6651 ! and || in element attributes should not be parsed as <th>/<td>
6652 !! wikitext
6653 {|
6654 | <div style="color: red !important;" data-contrived="put this here ||">hi</div>
6655 |}
6656 !! html/php
6657 <table>
6658 <tr>
6659 <td> <div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
6660 </td></tr></table>
6661
6662 !! html/parsoid
6663 <table>
6664 <tbody><tr><td> <div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6665 </tbody></table>
6666 !! end
6667
6668 # FIXME: The output seems broken. Filed as T110268.
6669 !! test
6670 ! and || in td attributes should not be parsed as <th>/<td>
6671 !! options
6672 parsoid=wt2html
6673 !! wikitext
6674 {|
6675 | style="color: red !important;" data-contrived="put this here ||" | foo
6676 |}
6677 !! html/php
6678 <table>
6679 <tr>
6680 <td> style="color: red !important;" data-contrived="put this here </td>
6681 <td> foo
6682 </td></tr></table>
6683
6684 !! html/parsoid
6685 <table>
6686 <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>
6687 </tbody></table>
6688 !! end
6689
6690 !! test
6691 Break on | in element attribute in template
6692 !! options
6693 parsoid=wt2html,html2html
6694 !! wikitext
6695 {{echo|1=<div class="hi|ho">ha</div>}}
6696 !! html/php
6697 <p>ho"&gt;ha&lt;/div&gt;
6698 </p>
6699 !! html/parsoid
6700 <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>
6701 !! end
6702
6703 !! test
6704 Break on | in element attribute name in template
6705 !! wikitext
6706 {{echo|<div cla|ss="hiho">ha</div>}}
6707 !! html/parsoid
6708 <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>
6709 !! end
6710
6711 !! test
6712 Don't break on | in extension attribute in template
6713 !! wikitext
6714 {{echo|<ref name="hi|ho">ha</ref>}}
6715
6716 <references />
6717 !! html/parsoid
6718 <p><span about="#mwt2" class="mw-ref" id="cite_ref-hi.7Cho_1-0" rel="dc:references" typeof="mw:Transclusion mw:Extension/ref" data-parsoid='{"pi":[[{"k":"1"}]]}' 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.7Cho-1" style="counter-reset: mw-Ref 1;"><span class="mw-reflink-text">[1]</span></a></span></p>
6719
6720 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'><li about="#cite_note-hi.7Cho-1" id="cite_note-hi.7Cho-1"><a href="./Main_Page#cite_ref-hi.7Cho_1-0" rel="mw:referencedBy"><span class="mw-linkback-text">↑ </span></a> <span id="mw-reference-text-cite_note-hi.7Cho-1" class="mw-reference-text">ha</span></li></ol>
6721 !! end
6722
6723 ## We don't support roundtripping of these attributes in Parsoid.
6724 ## Selective serialization takes care of preventing dirty diffs.
6725 ## But, on edits, we dirty-diff the invalid attribute text.
6726 !! test
6727 Invalid text in table attributes should be discarded
6728 !! options
6729 parsoid=wt2html
6730 !! wikitext
6731 {| <span>boo</span> style='border:1px solid black'
6732 | <span>boo</span> style='color:blue' | 1
6733 |<span>boo</span> style='color:blue'| 2
6734 |}
6735 !! html/php
6736 <table style="border:1px solid black">
6737 <tr>
6738 <td style="color:blue"> 1
6739 </td>
6740 <td style="color:blue"> 2
6741 </td></tr></table>
6742
6743 !! html/parsoid
6744 <table style="border:1px solid black">
6745 <tr>
6746 <td style="color:blue"> 1</td>
6747 <td style="color:blue"> 2</td>
6748 </tr>
6749 </table>
6750 !! end
6751
6752 !! test
6753 Invalid text in table attributes should be preserved by selective serializer
6754 !! options
6755 parsoid={
6756 "modes": ["selser"],
6757 "changes": [
6758 ["td:first-child", "text", "abc"],
6759 ["td + td", "text", "xyz"]
6760 ]
6761 }
6762 !! wikitext
6763 {| <span>boo</span> style='border:1px solid black'
6764 | <span>boo</span> style='color:blue' | 1
6765 |<span>boo</span> style='color:blue'| 2
6766 |}
6767 !! wikitext/edited
6768 {| <span>boo</span> style='border:1px solid black'
6769 | <span>boo</span> style='color:blue' |abc
6770 |<span>boo</span> style='color:blue'|xyz
6771 |}
6772 !! end
6773
6774 !! test
6775 1. Template-generated table cell attributes and cell content
6776 !! wikitext
6777 {|
6778 |{{table_attribs}}
6779 | {{table_attribs}}
6780 || {{table_attribs_5}}
6781 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
6782 |align=center {{table_attribs}}
6783 | <!--foo--> align=center <!--bar--> {{table_attribs}}
6784 |}
6785 !! html
6786 <table>
6787 <tr>
6788 <td style="color:red;">Foo
6789 </td>
6790 <td style="color:red;">Foo
6791 </td>
6792 <td> style="color:red;"</td>
6793 <td>Bar
6794 </td>
6795 <td style="color:red;">Foo
6796 </td>
6797 <td align="center" style="color:red;">Foo
6798 </td>
6799 <td align="center" style="color:red;">Foo
6800 </td></tr></table>
6801
6802 !! end
6803
6804 !! test
6805 2. Template-generated table cell attributes and cell content
6806 !! wikitext
6807 {|
6808 |{{table_attribs_2}}
6809 |}
6810 !! html/php
6811 <table>
6812 <tr>
6813 <td style="color:red;">Foo
6814 </td>
6815 <td>Bar</td>
6816 <td>Baz
6817 </td></tr></table>
6818
6819 !! html/parsoid
6820 <table>
6821 <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>
6822 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
6823 </tbody></table>
6824 !! end
6825
6826 !! test
6827 3. Template-generated table cell attributes and cell content
6828 !! wikitext
6829 {|
6830 !align=center {{table_header_cells}}
6831 |-
6832 |align=center {{table_cells}}
6833 |}
6834 !! html/php
6835 <table>
6836 <tr>
6837 <th align="center" style="color:red;">Foo</th>
6838 <th style="color:red;"><i>Bar</i></th>
6839 <th style="color:brown;"><i>Foo</i> and Baz
6840 </th></tr>
6841 <tr>
6842 <td align="center" style="color:red;">Foo</td>
6843 <td style="color:red;"><i>Bar</i></td>
6844 <td style="color:brown;"><i>Foo</i> and Baz
6845 </td></tr></table>
6846
6847 !! html/parsoid
6848 <table>
6849 <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>
6850 <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>
6851 </tbody></table>
6852 !! end
6853
6854 !! test
6855 4. Template-generated table cell attributes and cell content inside a templated table
6856 !! wikitext
6857 {{tbl-start}}
6858 !align=center {{table_header_cells}}
6859 |-
6860 |align=center {{table_cells}}
6861 {{tbl-end}}
6862 !! html/php
6863 <table>
6864 <tr>
6865 <th align="center" style="color:red;">Foo</th>
6866 <th style="color:red;"><i>Bar</i></th>
6867 <th style="color:brown;"><i>Foo</i> and Baz
6868 </th></tr>
6869 <tr>
6870 <td align="center" style="color:red;">Foo</td>
6871 <td style="color:red;"><i>Bar</i></td>
6872 <td style="color:brown;"><i>Foo</i> and Baz
6873 </td></tr></table>
6874
6875 !! html/parsoid
6876 <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}}]}'>
6877 <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>
6878 <tr>
6879 <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>
6880 </tbody></table>
6881 !! end
6882
6883 ## Edge case fix to prevent future regressions
6884 !! test
6885 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
6886 !! wikitext
6887 {|
6888 |{{table_attribs_7}}
6889 |}
6890 <references />
6891 !! html/parsoid
6892 <table>
6893 <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>
6894 </tbody></table>
6895 <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>
6896 !! end
6897
6898 !! test
6899 Table with row followed by newlines and table heading
6900 !! options
6901 parsoid=wt2html,html2html
6902 !! wikitext
6903 {|
6904 |-
6905
6906 ! foo
6907 |}
6908 !! html/*
6909 <table>
6910
6911
6912 <tr>
6913 <th> foo
6914 </th></tr></table>
6915
6916 !! end
6917
6918 !! test
6919 Table with empty line following the start tag
6920 !! options
6921 parsoid=wt2html,html2html
6922 !! wikitext
6923 {|
6924
6925 |-
6926 | foo
6927 |}
6928 !! html/*
6929 <table>
6930
6931
6932 <tr>
6933 <td> foo
6934 </td></tr></table>
6935
6936 !! end
6937
6938 !! test
6939 Table attributes with empty value
6940 !! options
6941 parsoid=wt2html,html2html
6942 !! wikitext
6943 {|
6944 | style=| hello
6945 |}
6946 !! html/php
6947 <table>
6948 <tr>
6949 <td style=""> hello
6950 </td></tr></table>
6951
6952 !! html/parsoid
6953 <table>
6954 <tbody><tr><td style=""> hello</td></tr>
6955 </tbody></table>
6956 !! end
6957
6958 !! test
6959 Wikitext table with a lot of comments
6960 !! wikitext
6961 {|
6962 <!-- c0 -->
6963 | foo
6964 <!-- c1 -->
6965 |-<!-- c2 -->
6966 <!-- c3 -->
6967 |<!-- c4 -->
6968 <!-- c5 -->
6969 |}
6970 !! html
6971 <table>
6972 <tr>
6973 <td> foo
6974 </td></tr>
6975 <tr>
6976 <td>
6977 </td></tr></table>
6978
6979 !! end
6980
6981 !! test
6982 Wikitext table comments represented in parsoid dom
6983 !! wikitext
6984 {|<!--c1--><!--c2-->
6985 |-<!--c3-->
6986 | x
6987 |}
6988 !! html/php+tidy
6989 <table>
6990 <tr>
6991 <td>x</td>
6992 </tr>
6993 </table>
6994 !! html/parsoid
6995 <table><!--c1--><!--c2-->
6996 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
6997 <td data-parsoid='{"autoInsertedEnd":true}'> x</td></tr>
6998 </tbody></table>
6999 !! end
7000
7001 !! test
7002 Wikitext table with double-line table cell
7003 !! wikitext
7004 {|
7005 |a
7006 b
7007 |}
7008 !! html
7009 <table>
7010 <tr>
7011 <td>a
7012 <p>b
7013 </p>
7014 </td></tr></table>
7015
7016 !! end
7017
7018 !! test
7019 Table cell with a single comment
7020 !! wikitext
7021 {|
7022 | <!-- c1 -->
7023 | a
7024 |}
7025 !! html
7026 <table>
7027 <tr>
7028 <td>
7029 </td>
7030 <td> a
7031 </td></tr></table>
7032
7033 !! end
7034
7035 !! test
7036 Table-cell after a comment-only-empty-line
7037 !! wikitext
7038 {|
7039 |a
7040 <!--c1-->
7041 <!--c2-->| b
7042 |}
7043 !! html
7044 <table>
7045 <tr>
7046 <td>a
7047 </td>
7048 <td> b
7049 </td></tr></table>
7050
7051 !! html/parsoid
7052 <table>
7053 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
7054 <!--c1-->
7055 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'> b</td></tr>
7056 </tbody></table>
7057
7058 !! end
7059
7060 !! test
7061 Build table with {{!}}
7062 !! wikitext
7063 {{{!}} class="wikitable"
7064 ! header
7065 ! second header
7066 {{!}}- style="color:red;"
7067 {{!}} data {{!}}{{!}} style="color:red;" {{!}} second data
7068 {{!}}}
7069 !! html
7070 <table class="wikitable">
7071 <tr>
7072 <th> header
7073 </th>
7074 <th> second header
7075 </th></tr>
7076 <tr style="color:red;">
7077 <td> data </td>
7078 <td style="color:red;"> second data
7079 </td></tr></table>
7080
7081 !! end
7082
7083 !! test
7084 Build table with pipe as data
7085 !! wikitext
7086 {| class="wikitable"
7087 ! header
7088 ! second header
7089 |- style="color:red;"
7090 | data || style="color:red;" | second data
7091 |-
7092 | style="color:red;" | data with | || style="color:red;" | second data with |
7093 |-
7094 || data with | ||| second data with |
7095 |}
7096 !! html
7097 <table class="wikitable">
7098 <tr>
7099 <th> header
7100 </th>
7101 <th> second header
7102 </th></tr>
7103 <tr style="color:red;">
7104 <td> data </td>
7105 <td style="color:red;"> second data
7106 </td></tr>
7107 <tr>
7108 <td style="color:red;"> data with | </td>
7109 <td style="color:red;"> second data with |
7110 </td></tr>
7111 <tr>
7112 <td> data with | </td>
7113 <td> second data with |
7114 </td></tr></table>
7115
7116 !! end
7117
7118 !! test
7119 Build table with wikilink
7120 !! wikitext
7121 {| class="wikitable"
7122 ! header || second header
7123 |- style="color:red;"
7124 | data [[Main Page|linktext]] || second data [[Main Page|linktext]]
7125 |-
7126 | data || second data [[Main Page|link|text with pipe]]
7127 |}
7128 !! html
7129 <table class="wikitable">
7130 <tr>
7131 <th> header </th>
7132 <th> second header
7133 </th></tr>
7134 <tr style="color:red;">
7135 <td> data <a href="/wiki/Main_Page" title="Main Page">linktext</a> </td>
7136 <td> second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
7137 </td></tr>
7138 <tr>
7139 <td> data </td>
7140 <td> second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
7141 </td></tr></table>
7142
7143 !! end
7144
7145 # The expected HTML structure in this test is debatable. The PHP parser does
7146 # not parse this kind of table at all. The main focus for Parsoid is on
7147 # round-tripping, so this output is ok for now. TODO: revisit!
7148 !! test
7149 Wikitext table with html-syntax row
7150 !! wikitext
7151 {|
7152 |-
7153 <td>foo</td>
7154 |}
7155 !! html/parsoid
7156 <table>
7157 <tbody>
7158 <tr>
7159 <td>foo</td></tr></tbody></table>
7160 !! end
7161
7162 !! test
7163 Implicit <td> after a |-
7164 !! options
7165 parsoid=wt2html,html2html
7166 !! wikitext
7167 {|
7168 |-
7169 a
7170 |}
7171 !! html/php
7172 <table>
7173
7174 a
7175 </table>
7176
7177 !! html/php+tidy
7178 <p>a</p>
7179 !! html/parsoid
7180 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>a</p><table>
7181 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7182
7183 </tr></tbody></table>
7184 !! end
7185
7186 !! test
7187 Lists should be recognized in an implicit <td> context
7188 !! options
7189 parsoid=wt2html,html2html
7190 !! wikitext
7191 {|
7192 |-
7193 *a
7194 |}
7195 !! html/php
7196 <table>
7197
7198 <ul><li>a</li></ul>
7199 </table>
7200
7201 !! html/php+tidy
7202 <ul>
7203 <li>a</li>
7204 </ul>
7205 !! html/parsoid
7206 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7207 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7208
7209 </tr></tbody></table>
7210 !! end
7211
7212 !! test
7213 Table cells not properly parsed in an implicit-td context
7214 !! wikitext
7215 {|
7216 |-
7217 {{table_attribs_4}} || a || b
7218 |}
7219 !! html/php+tidy
7220 <table>
7221 <tr>
7222 <td style="background-color:#DC241f;" width="10px"></td>
7223 <td>a</td>
7224 <td>b</td>
7225 </tr>
7226 </table>
7227 !! html/parsoid
7228 <table>
7229 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7230 <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>
7231 !! end
7232
7233 !! test
7234 Parsoid: Round-trip tables directly followed by content (T53219)
7235 !! options
7236 parsoid=wt2html,wt2wt
7237 !! wikitext
7238 {|
7239 |foo
7240 |} bar
7241
7242 {|
7243 |baz
7244 |}<b>quux</b>
7245 !! html+tidy
7246 <table>
7247 <tr>
7248 <td>foo</td>
7249 </tr>
7250 </table>
7251 <p>bar</p>
7252 <table>
7253 <tr>
7254 <td>baz</td>
7255 </tr>
7256 </table>
7257 <p><b>quux</b></p>
7258 !! end
7259
7260 !! test
7261 Parsoid: Default to a newline after tables in new content (T53219)
7262 !! options
7263 parsoid=html2wt
7264 !! html/parsoid
7265 <table><tbody>
7266 <tr><td>foo</td></tr></tbody></table> bar
7267 <table><tbody>
7268 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7269 !! wikitext
7270 {|
7271 |foo
7272 |}
7273 <nowiki> </nowiki>bar
7274 {|
7275 |baz
7276 |}
7277 '''quux'''
7278 !! end
7279
7280 !! test
7281 Parsoid: newline inducing block nodes don't suppress <nowiki>
7282 !! options
7283 parsoid=html2wt
7284 !! html/parsoid
7285 a<h1>foo</h1>
7286 !! wikitext
7287 <nowiki> </nowiki>a
7288
7289 = foo =
7290 !! end
7291
7292 !! test
7293 Parsoid: Row-syntax table headings followed by comment & table cells
7294 !! options
7295 parsoid=wt2html,wt2wt
7296 !! wikitext
7297 {|
7298 ! foo || bar
7299 <!-- foo --> || baz || quux
7300 |}
7301 !! html/php
7302 <table>
7303 <tr>
7304 <th> foo </th>
7305 <th> bar
7306 </th>
7307 <td> baz </td>
7308 <td> quux
7309 </td></tr></table>
7310
7311 !! html/parsoid
7312 <table>
7313 <tbody><tr><th> foo </th><th> bar
7314 <!-- foo --> </th><td> baz </td><td> quux</td></tr>
7315 </tbody></table>
7316 !! end
7317
7318 !!test
7319 Parsoid: Recover better from broken table attributes
7320 !!options
7321 parsoid=wt2html
7322 !!wikitext
7323 {| class="foo
7324 | class="bar" |
7325 foo
7326 |}
7327 !!html/php+tidy
7328 <table class="foo">
7329 <tr>
7330 <td class="bar">
7331 <p>foo</p>
7332 </td>
7333 </tr>
7334 </table>
7335 !!html/parsoid
7336 <table class="foo">
7337 <tr>
7338 <td class="bar">
7339 <p>foo</p></td></tr>
7340 </tbody></table>
7341 !!end
7342
7343 !! test
7344 Tables: Digest broken attributes on table and tr tag
7345 !! options
7346 parsoid=wt2html
7347 !! wikitext
7348 {| || |} ++
7349 |- || || ++ --
7350 |- > [
7351 |}
7352 !! html
7353 <table>
7354 <tbody>
7355 <tr class='mw-empty-elt'></tr>
7356 <tr class='mw-empty-elt'></tr>
7357 </tbody></table>
7358 !! end
7359
7360 # T137406: Whitespace in the HTML
7361 !! test
7362 1. Generate correct wikitext for tables with thead/tbody/tfoot
7363 !! options
7364 parsoid=html2wt
7365 !! html/parsoid
7366 <table>
7367 <caption>Test</caption>
7368 <thead>
7369 <tr>
7370 <th>Month</th>
7371 <th>Savings</th>
7372 </tr>
7373 </thead>
7374 <tbody>
7375 <tr>
7376 <td>January</td>
7377 <td>$100</td>
7378 </tr>
7379 <tr>
7380 <td>February</td>
7381 <td>$80</td>
7382 </tr>
7383 </tbody>
7384 <tfoot>
7385 <tr>
7386 <td>Sum</td>
7387 <td>$180</td>
7388 </tr>
7389 </tfoot>
7390 </table>
7391 !! wikitext
7392 {|
7393 |+Test
7394 !Month
7395 !Savings
7396 |-
7397 |January
7398 |$100
7399 |-
7400 |February
7401 |$80
7402 |-
7403 |Sum
7404 |$180
7405 |}
7406 !! html/php+tidy
7407 <table>
7408 <caption>Test</caption>
7409 <tr>
7410 <th>Month</th>
7411 <th>Savings</th>
7412 </tr>
7413 <tr>
7414 <td>January</td>
7415 <td>$100</td>
7416 </tr>
7417 <tr>
7418 <td>February</td>
7419 <td>$80</td>
7420 </tr>
7421 <tr>
7422 <td>Sum</td>
7423 <td>$180</td>
7424 </tr>
7425 </table>
7426 !! end
7427
7428 # T137406: No whitespace in the HTML
7429 !! test
7430 2. Generate correct wikitext for tables with thead/tbody/tfoot
7431 !! options
7432 parsoid=html2wt
7433 !! html/parsoid
7434 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7435 !! wikitext
7436 {|
7437 !heading
7438 |-
7439 |foo
7440 |}
7441 !! end
7442
7443 !! test
7444 Testing serialization after deletion in references
7445 !! options
7446 parsoid={
7447 "modes": ["wt2wt"],
7448 "changes": [
7449 ["#x", "remove"]
7450 ]
7451 }
7452 !! wikitext
7453 hi <ref><div id="x">ho</div></ref>
7454
7455 <references />
7456 !! wikitext/edited
7457 hi <ref></ref>
7458
7459 <references />
7460 !! end
7461
7462 !!test
7463 Testing serialization after deletion of table cells
7464 !!options
7465 parsoid={
7466 "modes": ["wt2wt", "selser"],
7467 "changes": [
7468 ["#x", "remove"]
7469 ]
7470 }
7471 !!wikitext
7472 {|
7473 !h1 !!h2 !!h3
7474 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
7475 |}
7476 !! wikitext/edited
7477 {|
7478 !h1 !!h2 !!h3
7479 |c2 |||c3
7480 |}
7481 !!end
7482
7483 !! test
7484 Testing selser after addition of new row before first row (T125419)
7485 !! options
7486 parsoid={
7487 "modes": ["wt2wt", "selser"],
7488 "changes": [
7489 [ "tr", "before", "<tr><td>X</td></tr>" ]
7490 ]
7491 }
7492 !! wikitext
7493 {|
7494 |a
7495 |}
7496 !! wikitext/edited
7497 {|
7498 |X
7499 |-
7500 |a
7501 |}
7502 !! end
7503
7504 !! test
7505 Serialize new table rows in a HTML table using HTML tags
7506 !! options
7507 parsoid={
7508 "modes": ["wt2wt", "selser"],
7509 "changes": [
7510 [ "tr", "before", "<tr><td>X</td></tr>" ]
7511 ]
7512 }
7513 !! wikitext
7514 <table><tr><td>a</td></tr></table>
7515 !! wikitext/edited
7516 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
7517 !! end
7518
7519 !! test
7520 Serialize new table cells in a HTML row using HTML tags
7521 !! options
7522 parsoid={
7523 "modes": ["wt2wt", "selser"],
7524 "changes": [
7525 [ "td", "before", "<td>X</td>" ]
7526 ]
7527 }
7528 !! wikitext
7529 <table><tr><td>a</td></tr></table>
7530 !! wikitext/edited
7531 <table><tr><td>X</td><td>a</td></tr></table>
7532 !! end
7533
7534 !! test
7535 Wikitext tables can be nested inside HTML tables
7536 !! options
7537 parsoid=html2wt
7538 !! html
7539 <table data-parsoid='{"stx":"html"}'>
7540 <tr><td>
7541 <table>
7542 <tr><td>foo</td></tr>
7543 </table>
7544 </td></tr>
7545 </table>
7546 !! wikitext
7547 <table>
7548 <tr><td>
7549 {|
7550 |foo
7551 |}
7552 </td></tr>
7553 </table>
7554 !! end
7555
7556 !! test
7557 Serialize wikitext list items as HTML list items when embedded in a HTML list
7558 !! options
7559 parsoid=html2wt
7560 !! html
7561 <ul data-parsoid='{"stx": "html"}'>
7562 <li data-parsoid='{}'>a</li>
7563 <li>b</li>
7564 </ul>
7565 !! wikitext
7566 <ul>
7567 <li>a</li>
7568 <li>b</li>
7569 </ul>
7570 !! end
7571
7572 # SSS FIXME: Is this actually a good thing given the
7573 # odd nested list output that is generated by MW?
7574 # <ul><li>foo<ul>..</ul></li></ul> instead of
7575 # <ul><li>foo</li><ul>..</ul></ul>
7576 !! test
7577 Wikitext lists can be nested inside HTML lists
7578 !! options
7579 parsoid=html2wt
7580 !! html
7581 <ul data-parsoid='{"stx": "html"}'>
7582 <li data-parsoid='{"stx": "html"}'>a
7583 <ul><li>b</li></ul>
7584 </li>
7585 </ul>
7586
7587 <ul data-parsoid='{"stx": "html"}'>
7588 <li>x
7589 <ul><li>y</li></ul>
7590 </li>
7591 </ul>
7592 !! wikitext
7593 <ul>
7594 <li>a
7595 * b
7596 </li>
7597 </ul>
7598
7599 <ul>
7600 <li>x
7601 * y
7602 </li>
7603 </ul>
7604 !! end
7605
7606 ###
7607 ### Internal links
7608 ###
7609 !! test
7610 Plain link, capitalized
7611 !! wikitext
7612 [[Main Page]]
7613 !! html
7614 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7615 </p>
7616 !! end
7617
7618 !! test
7619 Plain link, uncapitalized
7620 !! wikitext
7621 [[main Page]]
7622 !! html
7623 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7624 </p>
7625 !! end
7626
7627 !! test
7628 Piped link
7629 !! wikitext
7630 [[Main Page|The Main Page]]
7631 !! html
7632 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7633 </p>
7634 !! end
7635
7636 !! test
7637 Piped link with comment in link text
7638 !! wikitext
7639 [[Main Page|The Main<!--front--> Page]]
7640 !! html
7641 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7642 </p>
7643 !! end
7644
7645 !! test
7646 Piped link with multiple pipe characters in link text
7647 !! wikitext
7648 [[Main Page||The|Main|Page|]]
7649 !! html/php
7650 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7651 </p>
7652 !! html/parsoid
7653 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7654 !! end
7655
7656 !! test
7657 Piped link with no link text
7658 !! wikitext
7659 [[Thomas Bek (bishop of St David's)|]]
7660 !! html/php
7661 <p>[[Thomas Bek (bishop of St David's)|]]
7662 </p>
7663 !! html/parsoid
7664 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7665 !! end
7666
7667 !! test
7668 Piped link with empty link text
7669 !! wikitext
7670 [[Main Page|<nowiki/>]] - empty nowiki
7671 [[Main Page| ]] - empty space
7672 [[Main Page|&nbsp;]] - empty non breaking space
7673 !! html/php
7674 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7675 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7676 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7677 </p>
7678 !! html/parsoid
7679 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7680 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7681 <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>
7682 !! end
7683
7684 !! test
7685 Broken link
7686 !! wikitext
7687 [[Zigzagzogzagzig]]
7688 !! html
7689 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7690 </p>
7691 !! end
7692
7693 !! test
7694 Broken link with fragment
7695 !! wikitext
7696 [[Zigzagzogzagzig#zug]]
7697 !! html
7698 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7699 </p>
7700 !! end
7701
7702 !! test
7703 Special page link with fragment
7704 !! wikitext
7705 [[Special:Version#anchor]]
7706 !! html
7707 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7708 </p>
7709 !! end
7710
7711 !! test
7712 Nonexistent special page link with fragment
7713 !! wikitext
7714 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7715 !! html
7716 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7717 </p>
7718 !! end
7719
7720 !! test
7721 Link with prefix
7722 !! wikitext
7723 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7724 !! html
7725 <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>
7726 </p>
7727 !! end
7728
7729 !! test
7730 Link with suffix
7731 !! wikitext
7732 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7733 !! html
7734 <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>!!!
7735 </p>
7736 !! end
7737
7738 !! article
7739 prefixed article
7740 !! text
7741 Some text
7742 !! endarticle
7743
7744 !! test
7745 T45661: Piped links with identical prefixes
7746 !! wikitext
7747 [[prefixed article|prefixed articles with spaces]]
7748
7749 [[prefixed article|prefixed articlesaoeu]]
7750
7751 [[Main Page|Main Page test]]
7752 !! html
7753 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7754 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7755 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7756 </p>
7757 !! end
7758
7759
7760 !! test
7761 Link with HTML entity in suffix / tail
7762 !! wikitext
7763 [[Main Page]]&quot;, [[Main Page]]&#97;
7764 !! html/php
7765 <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;
7766 </p>
7767 !! html/parsoid
7768 <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>
7769 !! end
7770
7771 !! test
7772 Link with 3 brackets
7773 !! wikitext
7774 [[[Main Page]]]
7775 Foo [[[Main Page]]]
7776 !! html
7777 <p>[[[Main Page]]]
7778 Foo [[[Main Page]]]
7779 </p>
7780 !! end
7781
7782 !! test
7783 Link with 4 brackets
7784 !! wikitext
7785 [[[[Main Page]]]]
7786 !! html
7787 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7788 </p>
7789 !! end
7790
7791 !! test
7792 Piped link with 3 brackets
7793 !! wikitext
7794 [[[main page|the main page]]]
7795 !! html
7796 <p>[[[main page|the main page]]]
7797 </p>
7798 !! end
7799
7800 !! test
7801 Piped link with extlink-like text
7802 !! wikitext
7803 [[Main Page|[bar]]]
7804 [[Main Page|This is a [bar]]]
7805 [[Main Page|[bar]]
7806 !! html/php
7807 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7808 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7809 <a href="/wiki/Main_Page" title="Main Page">[bar</a>
7810 </p>
7811 !! html/parsoid
7812 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7813 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a>
7814 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar</a></p>
7815 !! end
7816
7817 !! test
7818 Link with multiple pipes
7819 !! wikitext
7820 [[Main Page|The|Main|Page]]
7821 !! html
7822 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7823 </p>
7824 !! end
7825
7826 !! test
7827 Anchor containing a #. (T65430)
7828 !! wikitext
7829 [[Main Page#And#Link]]
7830 !! html/php
7831 <p><a href="/wiki/Main_Page#And.23Link" title="Main Page">Main Page#And#Link</a>
7832 </p>
7833 !! html/parsoid
7834 <p><a rel="mw:WikiLink" href="./Main_Page#And.23Link" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#And.23Link"},"sa":{"href":"Main Page#And#Link"}}'>Main Page#And#Link</a></p>
7835 !! end
7836
7837 !! test
7838 Link to namespaces
7839 !! wikitext
7840 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7841 !! html
7842 <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>
7843 </p>
7844 !! end
7845
7846 !! test
7847 Link with space in namespace
7848 !! wikitext
7849 [[User talk:Foo bar]]
7850 !! html
7851 <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>
7852 </p>
7853 !! end
7854
7855 !! article
7856 MemoryAlpha:AlphaTest
7857 !! text
7858 This is an article in the MemoryAlpha namespace
7859 (which shadows the memoryalpha interwiki link).
7860 !! endarticle
7861
7862 !! test
7863 Namespace takes precedence over interwiki link (T53680)
7864 !! wikitext
7865 [[MemoryAlpha:AlphaTest]]
7866 !! html
7867 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7868 </p>
7869 !! end
7870
7871 # The previous test doesn't work correctly in html2*, due to not recognizing the
7872 # link as an internal one. This one checks for the correct behavior.
7873 !! test
7874 Link to namespace preferred over interwiki with correct rel attribute
7875 !! options
7876 parsoid=html2wt,html2html
7877 !! html/parsoid
7878 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7879 !! wikitext
7880 [[MemoryAlpha:AlphaTest]]
7881 !! end
7882
7883 !! test
7884 Piped link to namespace
7885 !! wikitext
7886 [[Meta:Disclaimers|The disclaimers]]
7887 !! html
7888 <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>
7889 </p>
7890 !! end
7891
7892 !! test
7893 Link containing }
7894 !! wikitext
7895 [[Usually caused by a typo (oops}]]
7896 !! html
7897 <p>[[Usually caused by a typo (oops}]]
7898 </p>
7899 !! end
7900
7901 !! article
7902 7% Solution
7903 !! text
7904 Just a test of an article title containing a percent.
7905 !! endarticle
7906
7907 !! test
7908 Link containing % (not as a hex sequence)
7909 !! wikitext
7910 [[7% Solution]]
7911 [[7% Solution|7%25 Solution]]
7912 !! html/php
7913 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7914 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7915 </p>
7916 !! html/parsoid
7917 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7918 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7919 !! end
7920
7921 # note that the parsoid HTML is identical to the previous test output,
7922 # so the previous test ensures that the html2wt mode will generate the
7923 # "not as a hex sequence" wikitext.
7924 !! test
7925 Link containing % as a single hex sequence interpreted to char
7926 !! options
7927 parsoid=wt2wt,wt2html,html2html
7928 !! wikitext
7929 [[7%25 Solution]]
7930 [[7%25 Solution|7%25 Solution]]
7931 !! html/php
7932 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7933 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7934 </p>
7935 !! html/parsoid
7936 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7937 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7938 !!end
7939
7940 !! test
7941 Link containing % as a double hex sequence interpreted to hex sequence
7942 !! wikitext
7943 [[7%2525 Solution]]
7944 !! html
7945 <p>[[7%2525 Solution]]
7946 </p>
7947 !!end
7948
7949 ## Example for such a section: == < ==
7950 !! test
7951 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
7952 !! wikitext
7953 [[%23%3c]][[%23%3e]]
7954 !! html/php
7955 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
7956 </p>
7957 !! html/parsoid
7958 <p><a rel="mw:WikiLink" href="./Main_Page#.3C" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#.3C"},"sa":{"href":"%23%3c"}}'>#&lt;</a><a rel="mw:WikiLink" href="./Main_Page#.3E" title="Main Page" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#.3E"},"sa":{"href":"%23%3e"}}'>#></a></p>
7959 !! end
7960
7961 !! test
7962 Link containing "<#" and ">#" as a hex sequences
7963 !! wikitext
7964 [[%3c%23]][[%3e%23]]
7965 !! html
7966 <p>[[%3c%23]][[%3e%23]]
7967 </p>
7968 !! end
7969
7970 !! test
7971 Link containing an equals sign
7972 !! wikitext
7973 [[Special:BookSources/isbn=4-00-026157-6]]
7974 !! html/php
7975 <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>
7976 </p>
7977 !! html/parsoid
7978 <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>
7979 !! end
7980
7981 !! article
7982 Foo~bar
7983 !! text
7984 Just a test of an article title containing a tilde.
7985 !! endarticle
7986
7987 # note that links containing signatures, like [[Foo~~~~]], are
7988 # massaged by the pre-save transform (PST) and so the tildes are never
7989 # seen by the parser.
7990 !! test
7991 Link containing a tilde
7992 !! wikitext
7993 [[Foo~bar]]
7994 !! html/php
7995 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
7996 </p>
7997 !! html/parsoid
7998 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
7999 !! end
8000
8001 !! test
8002 Link containing double-single-quotes '' (T6598)
8003 !! wikitext
8004 [[Lista d''e paise d''o munno]]
8005 !! html/php
8006 <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>
8007 </p>
8008 !! html/parsoid
8009 <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>
8010 !! end
8011
8012 !! test
8013 Link containing double quotes and spaces
8014 !! wikitext
8015 [[Cool "Gator"]]
8016 !! html/php
8017 <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>
8018 </p>
8019 !! html/parsoid
8020 <p><a rel="mw:WikiLink" href="./Cool_%22Gator%22" title='Cool "Gator"'>Cool "Gator"</a></p>
8021 !! end
8022
8023 !! test
8024 File containing double quotes and spaces
8025 !! wikitext
8026 [[File:Cool "Gator".png]]
8027 !! html/parsoid
8028 <p><span 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></span></p>
8029 !! end
8030
8031 !! test
8032 Redirect containing double quotes and spaces
8033 !! wikitext
8034 #REDIRECT [[Cool "Gator"]]
8035 !! html/parsoid
8036 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
8037 !! end
8038
8039 !! test
8040 Link containing double-single-quotes '' in text (T6598 sanity check)
8041 !! wikitext
8042 Some [[Link|pretty ''italics'' and stuff]]!
8043 !! html/php
8044 <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>!
8045 </p>
8046 !! html/parsoid
8047 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
8048 !! end
8049
8050 !! test
8051 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
8052 !! wikitext
8053 ''Some [[Link|pretty ''italics'' and stuff]]!''
8054 !! html
8055 <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>
8056 </p>
8057 !! end
8058
8059 !! test
8060 Link with double quotes in title part (literal) and alternate part (interpreted)
8061 !! wikitext
8062 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
8063
8064 [[''Pentecoste'']]
8065
8066 [[''Pentecoste''|Pentecoste]]
8067
8068 [[''Pentecoste''|''Pentecoste'']]
8069 !! html/php
8070 <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>
8071 </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>
8072 </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>
8073 </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>
8074 </p>
8075 !! html/parsoid
8076 <p><span 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></span></p>
8077 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
8078 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
8079 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
8080 !! end
8081
8082 !! test
8083 Broken image links with HTML captions (T41700)
8084 !! wikitext
8085 [[File:Nonexistent|<script></script>]]
8086 [[File:Nonexistent|100x100px|<script></script>]]
8087 [[File:Nonexistent|&lt;]]
8088 [[File:Nonexistent|a<i>b</i>c]]
8089 !! html/php
8090 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8091 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8092 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8093 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8094 </p>
8095 !! html/parsoid
8096 <p><span 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></span>
8097 <span 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></span>
8098 <span 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></span>
8099 <span 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></span></p>
8100 !! end
8101
8102 !! test
8103 Plain link to URL
8104 !! wikitext
8105 [[http://www.example.com]]
8106 !! html/php
8107 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8108 </p>
8109 !! html/parsoid
8110 <p>[<a rel="mw:ExtLink" href="http://www.example.com"></a>]</p>
8111 !! end
8112
8113 !! test
8114 Plain link to URL with link text
8115 !! wikitext
8116 [[http://www.example.com Link text]]
8117 !! html
8118 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8119 </p>
8120 !! end
8121
8122 !! test
8123 Plain link to protocol-relative URL
8124 !! wikitext
8125 [[//www.example.com]]
8126 !! html/php
8127 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8128 </p>
8129 !! html/parsoid
8130 <p>[<a rel="mw:ExtLink" href="//www.example.com"></a>]</p>
8131 !! end
8132
8133 !! test
8134 Plain link to protocol-relative URL with link text
8135 !! wikitext
8136 [[//www.example.com Link text]]
8137 !! html
8138 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8139 </p>
8140 !! end
8141
8142 !! test
8143 Plain link to page with question mark in title
8144 !! wikitext
8145 [[A?b]]
8146
8147 [[A?b|Baz]]
8148 !! html
8149 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8150 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8151 </p>
8152 !! end
8153
8154 # I'm fairly sure the expected result here is wrong.
8155 # We want these to be URL links, not pseudo-pages with URLs for titles....
8156 # However the current output is also pretty screwy.
8157 #
8158 # ----
8159 # I'm changing it to match the current output--it arguably makes more
8160 # sense in the light of the test above. Old expected result was:
8161 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8162 #</p>
8163 # But I think this test is bordering on "garbage in, garbage out" anyway.
8164 # -- wtm
8165 !! test
8166 Piped link to URL
8167 !! wikitext
8168 Piped link to URL: [[http://www.example.com|an example URL]]
8169 !! html/php
8170 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8171 </p>
8172 !! html/parsoid
8173 <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>
8174 !! end
8175
8176 !! test
8177 Plain link in template argument
8178 !! options
8179 parsoid=wt2html
8180 !! wikitext
8181 {{echo|[http://www.example.com |123]}}
8182
8183 {{echo|[[http://www.example.com |123]]}}
8184
8185 {{echo|[[http://www.example.com |123]}}
8186
8187 {{echo|[http://www.example.com |123]]}}
8188 !! html/php
8189 <p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8190 </p><p>[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>]
8191 </p><p>{{echo|[<a rel="nofollow" class="external text" href="http://www.example.com">|123</a>}}
8192 </p><p>[<a rel="nofollow" class="external free" href="http://www.example.com">http://www.example.com</a>
8193 </p>
8194 !! html/parsoid
8195 <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>
8196
8197 <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>
8198
8199 <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>
8200
8201 <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>
8202 !! end
8203
8204 !! test
8205 T2002: [[page|http://url/]] should link to page, not http://url/
8206 !! wikitext
8207 [[Main Page|http://url/]]
8208 !! html/php
8209 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8210 </p>
8211 !! html/parsoid
8212 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8213 !! end
8214
8215 # Parsoid does not mark self-links, by design.
8216 !! test
8217 T2337: Escaped self-links should be bold
8218 !! options
8219 title=[[Bug462]]
8220 !! wikitext
8221 [[Bu&#103;462]] [[Bug462]]
8222 !! html/php
8223 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8224 </p>
8225 !! html/php+tidy
8226 <p><a class="mw-selflink selflink">Bug462</a> <a class="mw-selflink selflink">Bug462</a></p>
8227 !! html/parsoid
8228 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8229 !! end
8230
8231 !! test
8232 Self-link to section should not be bold
8233 !! options
8234 title=[[Main Page]]
8235 !! wikitext
8236 [[Main Page#section]]
8237 !! html
8238 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8239 </p>
8240 !! end
8241
8242 !! article
8243 00
8244 !! text
8245 This is 00.
8246 !! endarticle
8247
8248 !!test
8249 Self-link to numeric title
8250 !!options
8251 title=[[0]]
8252 !! wikitext
8253 [[0]]
8254 !! html
8255 <p><a class="mw-selflink selflink">0</a>
8256 </p>
8257 !!end
8258
8259 !!test
8260 Link to numeric-equivalent title
8261 !!options
8262 title=[[0]]
8263 !! wikitext
8264 [[00]]
8265 !! html
8266 <p><a href="/wiki/00" title="00">00</a>
8267 </p>
8268 !!end
8269
8270 !! test
8271 <nowiki> inside a link
8272 !! wikitext
8273 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8274 !! html
8275 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8276 </p>
8277 !! end
8278
8279 !! test
8280 Non-breaking spaces in title
8281 !! wikitext
8282 [[&nbsp; Main &nbsp; Page &nbsp;]]
8283 !! html
8284 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8285 </p>
8286 !!end
8287
8288 # Add new article for the test below so that it doesn't red-link
8289 !! article
8290 Foo bar baz
8291 !! text
8292 boo
8293 !! endarticle
8294
8295 !! test
8296 Multiple spaces in titles should normalize to a single underscore
8297 !! options
8298 parsoid=wt2html,wt2wt
8299 !! wikitext
8300 [[Foo bar baz|x]]
8301 [[Foo bar baz|x]]
8302 [[Foo bar baz|x]]
8303 !! html/php
8304 <p><a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8305 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8306 <a href="/wiki/Foo_bar_baz" title="Foo bar baz">x</a>
8307 </p>
8308 !! html/parsoid
8309 <p><a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8310 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8311 <a rel="mw:WikiLink" href="./Foo_bar_baz" title="Foo bar baz">x</a>
8312 </p>
8313 !! end
8314
8315 !! test
8316 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8317 !! options
8318 language=ca
8319 !! wikitext
8320 '''[[Main Page]]'''
8321 !! html
8322 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8323 </p>
8324 !! end
8325
8326 !! test
8327 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8328 !! options
8329 language=ca
8330 !! wikitext
8331 ''[[Main Page]]''
8332 !! html
8333 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8334 </p>
8335 !! end
8336
8337 !! test
8338 Internal link with en linktrail: no apostrophes (T29473)
8339 !! options
8340 language=en
8341 !! wikitext
8342 [[Something]]'nice
8343 !! html
8344 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8345 </p>
8346 !! end
8347
8348 !! test
8349 Internal link with ca linktrail with apostrophes (T29473)
8350 !! options
8351 language=ca
8352 !! wikitext
8353 [[Something]]'nice
8354 !! html
8355 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8356 </p>
8357 !! end
8358
8359 !! test
8360 Internal link with kaa linktrail with apostrophes (T29473)
8361 !! options
8362 language=kaa
8363 !! wikitext
8364 [[Something]]'nice
8365 !! html
8366 <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>
8367 </p>
8368 !! end
8369
8370 !! test
8371 Link with multiple ":" in a subpage-supporting namespace (T65636)
8372 !! wikitext
8373 [[User:Foo/Test/63636:Bar|Test]]
8374 !! html/php
8375 <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>
8376 </p>
8377 !! html/parsoid
8378 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8379 !! end
8380
8381 ## Mainly a sanity check for Parsoid
8382 !! test
8383 Handle title parsing for subpages
8384 !! options
8385 title=[[/123123]]
8386 subpage
8387 !! wikitext
8388 123
8389 !! html/php
8390 <p>123
8391 </p>
8392 !! html/parsoid
8393 <p>123</p>
8394 !! end
8395
8396 !! article
8397 User:Test/123
8398 !! text
8399 test 123
8400 !! endarticle
8401
8402 !! test
8403 Link to a subpage from a namespace other than main
8404 !! options
8405 title=[[User:Test]]
8406 subpage
8407 !! wikitext
8408 [[/123]]
8409 !! html/php
8410 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8411 </p>
8412 !! html/parsoid
8413 <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>
8414 !! end
8415
8416 !! test
8417 Ensure that transclusion titles are not url-decoded
8418 !! options
8419 subpage title=[[Test]]
8420 parsoid=wt2html
8421 !! wikitext
8422 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8423 !! html/php
8424 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8425 </p>
8426 !! html/parsoid
8427 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8428 !! end
8429
8430 !! test
8431 Purely hash wikilink
8432 !! options
8433 title=[[User:Test/123]]
8434 subpage
8435 !! wikitext
8436 [[#a|b]]
8437 !! html/php
8438 <p><a href="#a">b</a>
8439 </p>
8440 !! html/parsoid
8441 <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>
8442 !! end
8443
8444 !! test
8445 Serialization of purely hash wikilink
8446 !! options
8447 title=[[User:Test/123]]
8448 subpage
8449 parsoid=html2wt
8450 !! html/parsoid
8451 <p><a href="#a">[[</a></p>
8452 !! wikitext
8453 [[#a|<nowiki>[[</nowiki>]]
8454 !! html/php
8455 <p><a href="#a">[[</a>
8456 </p>
8457 !! end
8458
8459 !! test
8460 1. Interaction of linktrail and template encapsulation
8461 !! wikitext
8462 {{echo|[[Foo]]}}l
8463 !! html/parsoid
8464 <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>
8465 !! end
8466
8467 !! test
8468 2. Interaction of linktrail and template encapsulation
8469 !! options
8470 parsoid
8471 !! wikitext
8472 {{echo|Some [[Fool]]}}s
8473 !! html
8474 <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>
8475 !! end
8476
8477 !! test
8478 3. Interaction of linktrail and template encapsulation
8479 !! options
8480 parsoid
8481 !! wikitext
8482 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8483 !! html
8484 <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>
8485 !! end
8486
8487 !! article
8488 Söfnuður
8489 !! text
8490 Test.
8491 !! endarticle
8492
8493 !! test
8494 Internal link with is link prefix
8495 !! options
8496 language=is
8497 !! wikitext
8498 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8499 !! html
8500 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8501 </p>
8502 !! end
8503
8504 !! article
8505 Mótmælendatrú
8506 !! text
8507 Test.
8508 !! endarticle
8509
8510 !! test
8511 Internal link with is link trail and link prefix
8512 !! options
8513 language=is
8514 !! wikitext
8515 [[mótmælendatrú|xxx]]ar
8516 [[mótmælendatrú]]ar
8517 mótmælenda[[söfnuður]]
8518 mótmælenda[[söfnuður|söfnuðir]]
8519 mótmælenda[[söfnuður|söfnuðir]]xxx
8520 !! html
8521 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8522 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8523 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8524 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8525 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8526 </p>
8527 !! end
8528
8529 !! test
8530 Parsoid link trail escaping
8531 !! options
8532 parsoid=html2wt,html2html
8533 !! html/parsoid
8534 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8535 !! wikitext
8536 [[apple]]<nowiki/>s
8537 !! end
8538
8539 !! test
8540 Parsoid link prefix escaping
8541 !! options
8542 language=is
8543 parsoid=html2wt,html2html
8544 !! html/parsoid
8545 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8546 !! wikitext
8547 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8548 !! end
8549
8550 !! test
8551 Parsoid link bracket escaping
8552 !! options
8553 parsoid=html2wt,html2html
8554 !! html/parsoid
8555 <p><a rel="mw:WikiLink" href="./Test" title="Test">Test</a></p>
8556 <p>[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]</p>
8557 <p>[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]</p>
8558 <p>[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]</p>
8559 <p>[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]</p>
8560 <p>[[[[[<a rel="mw:WikiLink" href="./Test" title="Test">Test</a>]]]]]</p>
8561 !! wikitext
8562 [[Test]]
8563
8564 [<nowiki/>[[Test]]]
8565
8566 [[[[Test]]]]
8567
8568 [[[<nowiki/>[[Test]]]]]
8569
8570 [[[[[[Test]]]]]]
8571
8572 [[[[[<nowiki/>[[Test]]]]]]]
8573 !! end
8574
8575 !! test
8576 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8577 !! wikitext
8578 [[Foo| bar]]
8579
8580 [[Foo| ''bar'']]
8581
8582 [http://wp.org foo]
8583
8584 [http://wp.org ''foo'']
8585 !! html
8586 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8587 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8588 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8589 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8590 </p>
8591 !! end
8592
8593 !! test
8594 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8595 !! wikitext
8596 [[Foo|{{echo|a}} b {{echo|c}}]]
8597 !! html/parsoid
8598 <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>
8599 !! end
8600
8601 !! test
8602 Link with angle bracket after anchor
8603 !! wikitext
8604 [[Foo#<bar>]]
8605 !! html/php
8606 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8607 </p>
8608 !! html/parsoid
8609 <p><a rel="mw:WikiLink" href="./Foo#.3Cbar.3E" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo#.3Cbar.3E"},"sa":{"href":"Foo#&lt;bar>"}}'>Foo#&lt;bar></a></p>
8610 !! end
8611
8612 ###
8613 ### Interwiki links (see maintenance/interwiki.sql)
8614 ###
8615
8616 !! test
8617 Inline interwiki link
8618 !! options
8619 parsoid=wt2html,wt2wt,html2html
8620 !! wikitext
8621 [[MeatBall:SoftSecurity]]
8622 !! html/php
8623 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8624 </p>
8625 !! html/parsoid
8626 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8627 !! end
8628
8629 !! test
8630 Inline interwiki link with empty title (T4372)
8631 !! options
8632 parsoid=wt2html,wt2wt,html2html
8633 !! wikitext
8634 [[MeatBall:]]
8635 !! html/php
8636 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8637 </p>
8638 !! html/parsoid
8639 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8640 !! end
8641
8642 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
8643 !! test
8644 Interwiki link encoding conversion (T3636)
8645 !! options
8646 parsoid=wt2html,wt2wt
8647 !! wikitext
8648 *[[Wikipedia:ro:Olteni&#0355;a]]
8649 *[[Wikipedia:ro:Olteni&#355;a]]
8650 !! html
8651 <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>
8652 <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>
8653
8654 !! html+tidy
8655 <ul>
8656 <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>
8657 <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>
8658 </ul>
8659 !! html/parsoid
8660 <ul>
8661 <li><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/ro:Olteniţa" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
8662 <li><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/ro:Olteniţa" title="wikipedia:ro:Olteniţa">Wikipedia:ro:Olteniţa</a></li>
8663 </ul>
8664 !! end
8665
8666 !! test
8667 Interwiki link with fragment (T4130)
8668 !! wikitext
8669 [[MeatBall:SoftSecurity#foo]]
8670 !! html
8671 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8672 </p>
8673 !! end
8674
8675 !! test
8676 Link scenarios with escaped fragments
8677 !! wikitext
8678 [[#Is this great?]]
8679 [[Foo#Is this great?]]
8680 [[meatball:Foo#Is this great?]]
8681 !! html/php
8682 <p><a href="#Is_this_great.3F">#Is this great?</a>
8683 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8684 <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>
8685 </p>
8686 !! html/parsoid
8687 <p><a rel="mw:WikiLink" href="./Main_Page#Is_this_great.3F" data-parsoid='{"stx":"simple","a":{"href":"./Main_Page#Is_this_great.3F"},"sa":{"href":"#Is this great?"}}'>#Is this great?</a>
8688 <a rel="mw:WikiLink" href="./Foo#Is_this_great.3F" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo#Is_this_great.3F"},"sa":{"href":"Foo#Is this great?"}}'>Foo#Is this great?</a>
8689 <a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?Foo#Is_this_great.3F" title="meatball:Foo" data-parsoid='{"stx":"simple","a":{"href":"http://www.usemod.com/cgi-bin/mb.pl?Foo#Is_this_great.3F"},"sa":{"href":"meatball:Foo#Is this great?"},"isIW":true}'>meatball:Foo#Is this great?</a></p>
8690 !! end
8691
8692 # Ideally the wikipedia: prefix here should be proto-relative too
8693 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8694 # define the 'en' prefix, and originally the test used 'wikipedia',
8695 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8696 # article.
8697 !! test
8698 Different interwiki prefixes mapping to the same URL
8699 !! wikitext
8700 [[:en:Foo]]
8701
8702 [[:en:Foo|Foo]]
8703
8704 [[wikipedia:Foo]]
8705
8706 [[:wikipedia:Foo|Foo]]
8707
8708 [[wikipedia:en:Foo]]
8709
8710 [[:wikipedia:en:Foo]]
8711
8712 [[ wikiPEdia :Foo]]
8713 !! html/parsoid
8714 <p><a rel="mw:ExtLink" 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>
8715
8716 <p><a rel="mw:ExtLink" 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>
8717
8718 <p><a rel="mw:ExtLink" 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>
8719
8720 <p><a rel="mw:ExtLink" 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>
8721
8722 <p><a rel="mw:ExtLink" 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>
8723
8724 <p><a rel="mw:ExtLink" 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>
8725
8726 <p><a rel="mw:ExtLink" 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>
8727 !! end
8728
8729 !! test
8730 Interwiki links that cannot be represented in wiki syntax
8731 !! wikitext
8732 [[meatball:ok]]
8733 [[meatball:ok#foo|ok with fragment]]
8734 [[meatball:ok_as_well?|ok ending with ? mark]]
8735 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8736 [http://de.wikipedia.org/wiki/#foo is just fragment]
8737
8738 !! html/php
8739 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8740 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8741 <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>
8742 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8743 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8744 </p>
8745 !! html/parsoid
8746 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8747 <a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8748 <a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?ok_as_well?" title="meatball:ok as well?">ok ending with ? mark</a>
8749 <a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8750 <a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8751 !! end
8752
8753 !! test
8754 Interwiki links: trail
8755 !! wikitext
8756 [[wikipedia:Foo|Ba]]r
8757 !! html/php
8758 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8759 </p>
8760 !! html/parsoid
8761 <p><a rel="mw:ExtLink" 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>
8762 !! end
8763
8764 !! test
8765 Local interwiki link
8766 !! options
8767 parsoid=wt2html,wt2wt,html2html
8768 !! wikitext
8769 [[local:Template:Foo]]
8770 !! html/php
8771 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8772 </p>
8773 !! html/parsoid
8774 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8775 !! end
8776
8777 # Parsoid does not mark self-links, by design.
8778 !! test
8779 Local interwiki link: self-link to current page
8780 !! options
8781 title=[[Main Page]]
8782 parsoid=wt2html,wt2wt,html2html
8783 !! wikitext
8784 [[local:Main Page]]
8785 !! html/php
8786 <p><a class="mw-selflink selflink">local:Main Page</a>
8787 </p>
8788 !! html/parsoid
8789 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8790 !! end
8791
8792 !! test
8793 Local interwiki link: prefix only (T66167)
8794 !! options
8795 parsoid=wt2html,wt2wt,html2html
8796 !! wikitext
8797 [[local:]]
8798 !! html/php
8799 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8800 </p>
8801 !! html/parsoid
8802 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8803 !! end
8804
8805 !! test
8806 Local interwiki link: with additional interwiki prefix (T63357)
8807 !! options
8808 parsoid=wt2html,wt2wt,html2html
8809 !! wikitext
8810 [[local:meatball:Hello]]
8811 !! html/php
8812 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8813 </p>
8814 !! html/parsoid
8815 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8816 !! end
8817
8818 !! test
8819 Multiple local interwiki link prefixes
8820 !! wikitext
8821 [[local:local:local:local:mi:local:Foo]]
8822 !! options
8823 parsoid=wt2html,wt2wt,html2html
8824 !! html/php
8825 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8826 </p>
8827 !! html/parsoid
8828 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8829 !! end
8830
8831 ###
8832 ### Interlanguage links
8833 ### Language links (so that searching for '### language' matches..)
8834 ###
8835
8836 !! test
8837 Interlanguage link
8838 !! wikitext
8839 Blah blah blah
8840 [[zh:Chinese]]
8841 !! html/php
8842 <p>Blah blah blah
8843 </p>
8844 !! html/parsoid
8845 <p>Blah blah blah</p>
8846 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8847 !! end
8848
8849 ## parsoid html2wt will lose the space variations
8850 !! test
8851 Interlanguage link with spacing
8852 !! options
8853 parsoid=wt2html,wt2wt,html2html
8854 !! wikitext
8855 Blah blah blah
8856 [[ zh : Chinese ]]
8857 !! html/php
8858 <p>Blah blah blah
8859 </p>
8860 !! html/parsoid
8861 <p>Blah blah blah</p>
8862 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8863 !! end
8864
8865 !! test
8866 Double interlanguage link
8867 !! wikitext
8868 Blah blah blah
8869 [[es:Spanish]]
8870 [[zh:Chinese]]
8871 !! html/php
8872 <p>Blah blah blah
8873 </p>
8874 !! html/parsoid
8875 <p>Blah blah blah</p>
8876 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8877 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8878 !! end
8879
8880 ## parsoid html2wt will lose the space variations
8881 !! test
8882 Interlanguage link variations
8883 !! options
8884 parsoid=wt2html,wt2wt,html2html
8885 !! wikitext
8886 Blah blah blah
8887 [[ es :Spanish]]
8888 [[ ZH :Chinese]]
8889 [[es:Foo_bar]]
8890 !! html/php
8891 <p>Blah blah blah
8892 </p>
8893 !! html/parsoid
8894 <p>Blah blah blah</p>
8895 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
8896 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
8897 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
8898 !! end
8899
8900 !! test
8901 Escaping of interlanguage links (T129218, T156308)
8902 !! wikitext
8903 Blah blah blah
8904 [[:es:Spanish]]
8905 [[ : zh : Chinese ]]
8906 !! html/php
8907 <p>Blah blah blah
8908 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8909 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
8910 </p>
8911 !! html/parsoid
8912 <p>Blah blah blah
8913 <a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8914 <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
8915 !! end
8916
8917 !! test
8918 Multiple colons escaping interlanguage links
8919 !! options
8920 parsoid=wt2html
8921 !! wikitext
8922 [[:es:Spanish]]
8923 [[::es:Spanish]]
8924 [[:::es:Spanish]]
8925 !! html/php
8926 <p><a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8927 [[::es:Spanish]]
8928 [[:::es:Spanish]]
8929 </p>
8930 !! html/parsoid
8931 <p><a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8932 [[::es:Spanish]]
8933 [[:::es:Spanish]]</p>
8934 !! end
8935
8936 ## parsoid html2wt will normalize the space to _
8937 !! test
8938 Space and question mark encoding in interlanguage links (T95473)
8939 !! options
8940 parsoid=wt2html,wt2wt,html2html
8941 !! wikitext
8942 Blah blah blah
8943 [[es:Foo bar?]]
8944 !! html/php
8945 <p>Blah blah blah
8946 </p>
8947 !! html/parsoid
8948 <p>Blah blah blah</p>
8949 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
8950 !! end
8951
8952 !! test
8953 Interlanguage link, with prefix links
8954 !! options
8955 language=ln
8956 !! wikitext
8957 Blah blah blah
8958 [[zh:Chinese]]
8959 !! html/php
8960 <p>Blah blah blah
8961 </p>
8962 !! html/parsoid
8963 <p>Blah blah blah</p>
8964 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8965 !! end
8966
8967 !! test
8968 Double interlanguage link, with prefix links (T10897)
8969 !! options
8970 language=ln
8971 !! wikitext
8972 Blah blah blah
8973 [[es:Spanish]]
8974 [[zh:Chinese]]
8975 !! html/php
8976 <p>Blah blah blah
8977 </p>
8978 !! html/parsoid
8979 <p>Blah blah blah</p>
8980 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8981 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8982 !! end
8983
8984 !! test
8985 "Extra" interlanguage links (T34189 / gerrit 111390)
8986 !! wikitext
8987 Blah blah blah
8988 [[mul:Article]]
8989 !! html/php
8990 <p>Blah blah blah
8991 </p>
8992 !! html/parsoid
8993 <p>Blah blah blah</p>
8994 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
8995 !! end
8996
8997 ## PHP parser tests script needs an update
8998 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8999 !! test
9000 Language links render as inline links if $wgInterwikiMagic=false
9001 !! options
9002 wgInterwikiMagic=false
9003 parsoid=wt2html,wt2wt,html2html
9004 !! wikitext
9005 Blah blah blah
9006 [[zh:Chinese]]
9007 !! html/parsoid
9008 <p>Blah blah blah <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9009 !! end
9010
9011 ## PHP parser tests script needs an update
9012 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
9013 !! test
9014 Language links render as inline links in the Talk namespace
9015 !! options
9016 title=Talk:Foo
9017 parsoid=wt2html,wt2wt,html2html
9018 !! wikitext
9019 Blah blah blah
9020 [[zh:Chinese]]
9021 !! html/parsoid
9022 <p>Blah blah blah <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
9023 !! end
9024
9025 !! test
9026 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
9027 !! options
9028 language=ln
9029 !! wikitext
9030 [[WW&nbsp;II]]
9031 !! html
9032 <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>
9033 </p>
9034 !! end
9035
9036 !! test
9037 Parsoid T55221: Wikilinks should be properly entity-escaped
9038 !! options
9039 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
9040 !! html/parsoid
9041 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9042 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
9043 !! wikitext
9044 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
9045
9046 He&amp;nbsp;llo He&amp;nbsp;llo
9047 !! html/php
9048 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
9049 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
9050 </p>
9051 !! end
9052
9053 # html2wt will fail because of title normalization without data-parsoid
9054 !! test
9055 Parsoid: handle constructor well
9056 !! options
9057 parsoid=wt2html,wt2wt
9058 !! wikitext
9059 [[constructor]]
9060
9061 [[constructor:foo]]
9062 !! html/php
9063 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
9064 </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>
9065 </p>
9066 !! html/parsoid
9067 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
9068
9069 <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>
9070 !! end
9071
9072 !! article
9073 ko:
9074 !! text
9075 Test.
9076 !! endarticle
9077
9078 # Note that `ko` isn't a known interlanguage prefix
9079 !! test
9080 Parsoid: recognize interlanguage links without a target page
9081 !! options
9082 ill
9083 !! wikitext
9084 [[es:]]
9085
9086 [[ko:]]
9087 !! html/php
9088 es:
9089 !! html/parsoid
9090 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
9091
9092 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9093 !! end
9094
9095 # Note that `ko` isn't a known interwiki prefix
9096 !! test
9097 Parsoid: recognize interwiki links without a target page
9098 !! options
9099 parsoid=wt2html,wt2wt,html2html
9100 !! wikitext
9101 [[:es:]]
9102
9103 [[:ko:]]
9104 !! html/php
9105 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
9106 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
9107 </p>
9108 !! html/parsoid
9109 <p><a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
9110 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
9111 !! end
9112
9113 !! test
9114 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
9115 !! wikitext
9116 [[mi:Foo]]
9117 !! html/php
9118 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
9119 </p>
9120 !! html/parsoid
9121 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
9122 !! end
9123
9124 !! test
9125 Interlanguage link with preceding local interwiki link (T70085)
9126 !! options
9127 parsoid=wt2html,wt2wt,html2html
9128 !! wikitext
9129 Blah blah blah
9130 [[local:es:Spanish]]
9131 !! html/php
9132 <p>Blah blah blah
9133 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
9134 </p>
9135 !! html/parsoid
9136 <p>Blah blah blah
9137 <a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
9138 !! end
9139
9140 !! test
9141 Looks like an interlanguage link, but is actually a local interwiki
9142 !! options
9143 parsoid=wt2html,wt2wt,html2html
9144 !! wikitext
9145 Blah blah blah
9146 [[mi:Template:Foo]]
9147 !! html/php
9148 <p>Blah blah blah
9149 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
9150 </p>
9151 !! html/parsoid
9152 <p>Blah blah blah
9153 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
9154 !! end
9155
9156 ###
9157 ### Redirects, Parsoid-only
9158 ###
9159
9160 !! test
9161 1. Simple redirect to page
9162 !! wikitext
9163 #REDIRECT [[Main Page]]
9164 !! html/parsoid
9165 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9166 !! end
9167
9168 !! test
9169 2. Other redirect variants
9170 !! wikitext
9171 #REDIRECT [[Main_Page]]
9172 !! html/parsoid
9173 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
9174 !! end
9175
9176 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
9177 # This tests the Parsoid bail-out code.
9178 !! test
9179 3. Other redirect variants
9180 !! wikitext
9181 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
9182 !! html/parsoid
9183 <ol><li data-parsoid>REDIRECT [[[[Bar]]]]</li></ol>
9184 !! end
9185
9186 !! test
9187 4. Redirect to a templated destination
9188 !! wikitext
9189 #REDIRECT [[{{echo|Foo}}bar]]
9190 !! html/parsoid
9191 <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"}]]}'/>
9192 !! end
9193
9194 !! test
9195 Empty redirect
9196 !! options
9197 parsoid=wt2html,wt2wt
9198 !! wikitext
9199 #REDIRECT [[]]
9200 !! html/parsoid
9201 <ol>
9202 <li>REDIRECT [[]]</li></ol>
9203 !! end
9204
9205 !! test
9206 Optional colon in #REDIRECT
9207 !! options
9208 # the colon is archaic syntax. we support it for wt2html, but we
9209 # don't care that it roundtrips back to the modern syntax.
9210 parsoid=wt2html,html2html
9211 !! wikitext
9212 #REDIRECT:[[Main Page]]
9213 !! html/parsoid
9214 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9215 !! end
9216
9217 !! test
9218 Whitespace in #REDIRECT with optional colon
9219 !! options
9220 # the colon and gratuitous whitespace is archaic syntax. we support
9221 # it for wt2html, but we don't care that it roundtrips back to the
9222 # modern syntax (without extra whitespace)
9223 parsoid=wt2html,html2html
9224 !! wikitext
9225
9226 #REDIRECT
9227 :
9228 [[Main Page]]
9229 !! html/parsoid
9230 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9231 !! end
9232
9233 !! test
9234 Piped link in #REDIRECT
9235 !! options
9236 # content after piped link is ignored. we support this syntax,
9237 # but don't care that the piped link is lost when we roundtrip this.
9238 parsoid=wt2html
9239 !! wikitext
9240 #REDIRECT [[Main Page|bar]]
9241 !! html/parsoid
9242 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9243 !! end
9244
9245 !! test
9246 Redirect to category (T104502)
9247 !! options
9248 parsoid=wt2html,wt2wt
9249 !! wikitext
9250 #REDIRECT [[Category:Foo]]
9251 !! html/parsoid
9252 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9253 !! end
9254
9255 !! test
9256 Redirect to category with URL encoding (T104502)
9257 !! options
9258 parsoid=wt2html
9259 !! wikitext
9260 #REDIRECT [[Category%3AFoo]]
9261 !! html/parsoid
9262 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9263 !! end
9264
9265 !! test
9266 Redirect to category page
9267 !! wikitext
9268 #REDIRECT [[:Category:Foo]]
9269 !! html/parsoid
9270 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9271 !! end
9272
9273 !! test
9274 Redirect to image page (1)
9275 !! wikitext
9276 #REDIRECT [[File:Wiki.png]]
9277 !! html/parsoid
9278 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9279 !! end
9280
9281 !! test
9282 Redirect to image page (2)
9283 !! wikitext
9284 #REDIRECT [[Image:Wiki.png]]
9285 !! html/parsoid
9286 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9287 !! end
9288
9289 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9290 # Next test confirms this.
9291 !! test
9292 Redirect to language (1) (T104918)
9293 !! options
9294 parsoid=wt2html,wt2wt,html2html
9295 !! wikitext
9296 #REDIRECT [[en:File:Wiki.png]]
9297 !! html/parsoid
9298 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9299 !! end
9300
9301 !! test
9302 Redirect to language (2) (T104918)
9303 !! wikitext
9304 #REDIRECT [[:en:File:Wiki.png]]
9305 !! html/parsoid
9306 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9307 !! end
9308
9309 !! test
9310 Redirect to interwiki (T104918)
9311 !! wikitext
9312 #REDIRECT [[meatball:File:Wiki.png]]
9313 !! html/parsoid
9314 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9315 !! end
9316
9317 !! test
9318 Non-English #REDIRECT
9319 !! options
9320 language=is
9321 !! wikitext
9322 #TILVÍSUN [[Main Page]]
9323 !! html/parsoid
9324 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9325 !! end
9326
9327 !! test
9328 Redirect syntax under text isn't considered a redirect
9329 !! wikitext
9330 some text
9331 #redirect [[Main Page]]
9332 !! html/parsoid
9333 <p>some text</p>
9334 <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>
9335 !! end
9336
9337 !! test
9338 New redirect
9339 !! options
9340 parsoid=html2wt
9341 !! html/parsoid
9342 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9343 !! wikitext
9344 #REDIRECT [[Foo]]
9345 Foo
9346 !! end
9347
9348 !! test
9349 Redirect followed by block on the same line
9350 !! options
9351 parsoid=wt2html
9352 !! wikitext
9353 #REDIRECT [[Main Page]]<!-- haha -->== hi ==
9354 !! html/parsoid
9355 <link rel="mw:PageProp/redirect" href="./Main_Page"/><!-- haha --><h2 id="hi"> hi </h2>
9356 !! end
9357
9358 !! test
9359 Redirect followed by a newline
9360 !! wikitext
9361 #REDIRECT [[Main Page]]
9362 A newline
9363 !! html/parsoid
9364 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9365 <p>A newline</p>
9366 !! end
9367
9368 !! test
9369 Redirect followed by multiple newlines
9370 !! wikitext
9371 #REDIRECT [[Main Page]]
9372
9373
9374 A newline
9375 !! html/parsoid
9376 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9377
9378 <p><br/>
9379 A newline</p>
9380 !! end
9381
9382 !! test
9383 Drop duplicate redirects
9384 !! options
9385 parsoid=html2wt
9386 !! html/parsoid
9387 <link rel="mw:PageProp/redirect" href="./Foo"/>
9388 <link rel="mw:PageProp/redirect" href="./Bar"/>
9389 <link rel="mw:PageProp/redirect" href="./Baz"/>
9390 !! wikitext
9391 #REDIRECT [[Foo]]
9392 !! end
9393
9394 ##
9395 ## XHTML tidiness
9396 ###
9397
9398 !! test
9399 <br> to <br />
9400 !! wikitext
9401 1<br>2<br />3
9402 !! html
9403 <p>1<br />2<br />3
9404 </p>
9405 !! end
9406
9407 !! test
9408 Broken br tag sanitization
9409 !! wikitext
9410 </br>
9411 !! html/php
9412 <p>&lt;/br&gt;
9413 </p>
9414 !! end
9415
9416 # TODO: Fix html2html mode (T53055)!
9417 !! test
9418 Parsoid: Broken br tag recognition
9419 !! options
9420 parsoid=wt2html
9421 !! wikitext
9422 </br>
9423
9424 <br/ >
9425 !! html+tidy
9426 <p><br /></p>
9427 <p><br /></p>
9428 !! end
9429
9430 !! test
9431 Incorrecly removing closing slashes from correctly formed XHTML
9432 !! wikitext
9433 <br style="clear:both;" />
9434 !! html
9435 <p><br style="clear:both;" />
9436 </p>
9437 !! end
9438
9439 !! test
9440 Failing to transform badly formed HTML into correct XHTML
9441 !! wikitext
9442 <br style="clear: left;">
9443 <br style="clear: right;">
9444 <br style="clear: both;">
9445 !! html
9446 <p><br style="clear: left;" />
9447 <br style="clear: right;" />
9448 <br style="clear: both;" />
9449 </p>
9450 !!end
9451
9452 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9453 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9454 !! test
9455 Handling html with a div self-closing tag
9456 !! wikitext
9457 <div title />
9458 <div title/>
9459 <div title/ >
9460 <div title=bar />
9461 <div title=bar/>
9462 <div title=bar/ >
9463 !! html/php
9464 <p>&lt;div title /&gt;
9465 &lt;div title/&gt;
9466 </p>
9467 <div>
9468 <p>&lt;div title=bar /&gt;
9469 &lt;div title=bar/&gt;
9470 </p>
9471 <div title="bar/"></div>
9472 </div>
9473
9474 !! html/parsoid
9475 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9476 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9477 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9478 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9479 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9480 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>
9481 !! end
9482
9483 !! test
9484 Handling html with a br self-closing tag
9485 !! wikitext
9486 <br title />
9487 <br title/>
9488 <br title/ >
9489 <br title=bar />
9490 <br title=bar/>
9491 <br title=bar/ >
9492 !! html/php
9493 <p><br title="" />
9494 <br title="" />
9495 <br />
9496 <br title="bar" />
9497 <br title="bar" />
9498 <br title="bar/" />
9499 </p>
9500 !! html/parsoid
9501 <p><br title="" />
9502 <br title="" />
9503 <br title="" />
9504 <br title="bar" />
9505 <br title="bar" />
9506 <br title="bar/" />
9507 </p>
9508 !! end
9509
9510 !! test
9511 Horizontal ruler (should it add that extra space?)
9512 !! wikitext
9513 <hr>
9514 <hr >
9515 foo <hr
9516 > bar
9517 !! html+tidy
9518 <hr />
9519 <hr />
9520 <p>foo</p>
9521 <hr />
9522 <p>bar</p>
9523 !! end
9524
9525 !! test
9526 Horizontal ruler -- 4+ dashes render hr
9527 !! wikitext
9528 ----
9529 !! html
9530 <hr />
9531
9532 !! end
9533
9534 !! test
9535 Horizontal ruler -- eats additional dashes on the same line
9536 !! wikitext
9537 ---------
9538 !! html
9539 <hr />
9540
9541 !! end
9542
9543 !! test
9544 Horizontal ruler -- does not collapse dashes on consecutive lines
9545 !! wikitext
9546 ----
9547 ----
9548 !! html
9549 <hr />
9550 <hr />
9551
9552 !! end
9553
9554 !! test
9555 Horizontal ruler -- <4 dashes render as plain text
9556 !! wikitext
9557 ---
9558 !! html
9559 <p>---
9560 </p>
9561 !! end
9562
9563 !! test
9564 Horizontal ruler -- Supports content following dashes on same line
9565 !! wikitext
9566 ---- Foo
9567 !! html
9568 <hr /> Foo
9569
9570 !! html+tidy
9571 <hr />
9572 <p>Foo</p>
9573 !! end
9574
9575 ###
9576 ### Block-level elements
9577 ###
9578 !! test
9579 Common list
9580 !! wikitext
9581 *Common list
9582 * item 2
9583 *item 3
9584 !! html
9585 <ul><li>Common list</li>
9586 <li> item 2</li>
9587 <li>item 3</li></ul>
9588
9589 !! end
9590
9591 !! test
9592 Numbered list
9593 !! wikitext
9594 #Numbered list
9595 #item 2
9596 # item 3
9597 !! html
9598 <ol><li>Numbered list</li>
9599 <li>item 2</li>
9600 <li> item 3</li></ol>
9601
9602 !! end
9603
9604 !! test
9605 Mixed list
9606 !! wikitext
9607 *Mixed list
9608 *# with numbers
9609 ** and bullets
9610 *# and numbers
9611 *bullets again
9612 **bullet level 2
9613 ***bullet level 3
9614 ***#Number on level 4
9615 **bullet level 2
9616 **#Number on level 3
9617 **#Number on level 3
9618 *#number level 2
9619 *Level 1
9620 *** Level 3
9621 #** Level 3, but ordered
9622 !! html
9623 <ul><li>Mixed list
9624 <ol><li> with numbers</li></ol>
9625 <ul><li> and bullets</li></ul>
9626 <ol><li> and numbers</li></ol></li>
9627 <li>bullets again
9628 <ul><li>bullet level 2
9629 <ul><li>bullet level 3
9630 <ol><li>Number on level 4</li></ol></li></ul></li>
9631 <li>bullet level 2
9632 <ol><li>Number on level 3</li>
9633 <li>Number on level 3</li></ol></li></ul>
9634 <ol><li>number level 2</li></ol></li>
9635 <li>Level 1
9636 <ul><li><ul><li> Level 3</li></ul></li></ul></li></ul>
9637 <ol><li><ul><li><ul><li> Level 3, but ordered</li></ul></li></ul></li></ol>
9638
9639 !! end
9640
9641 !! test
9642 1. Nested mixed wikitext and html list
9643 !! wikitext
9644 * hi
9645 * <ul><li>ho</li></ul>
9646 * hi
9647 ** ho
9648 !! html/php
9649 <ul><li> hi</li>
9650 <li> <ul><li>ho</li></ul></li>
9651 <li> hi
9652 <ul><li> ho</li></ul></li></ul>
9653
9654 !! html/parsoid
9655 <ul><li> hi</li>
9656 <li> <ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9657 <li> hi
9658 <ul><li> ho</li></ul></li></ul>
9659 !! end
9660
9661 !! test
9662 2. Nested mixed wikitext and html list (incompatible)
9663 !! wikitext
9664 ; hi
9665 : {{echo|<li>ho</li>}}
9666 !! html/php
9667 <dl><dt> hi</dt>
9668 <dd> <li>ho</li></dd></dl>
9669
9670 !! html/parsoid
9671 <dl><dt> hi</dt>
9672 <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>
9673 !! end
9674
9675 !! test
9676 Nested lists 1
9677 !! wikitext
9678 *foo
9679 **bar
9680 !! html
9681 <ul><li>foo
9682 <ul><li>bar</li></ul></li></ul>
9683
9684 !! end
9685
9686 !! test
9687 Nested lists 2
9688 !! wikitext
9689 **foo
9690 *bar
9691 !! html
9692 <ul><li><ul><li>foo</li></ul></li>
9693 <li>bar</li></ul>
9694
9695 !! end
9696
9697 !! test
9698 Nested lists 3 (first element empty)
9699 !! wikitext
9700 *
9701 **bar
9702 !! html
9703 <ul><li>
9704 <ul><li>bar</li></ul></li></ul>
9705
9706 !! end
9707
9708 !! test
9709 Nested lists 4 (first element empty)
9710 !! wikitext
9711 **
9712 *bar
9713 !! html
9714 <ul><li><ul><li></li></ul></li>
9715 <li>bar</li></ul>
9716
9717 !! end
9718
9719 !! test
9720 Nested lists 5 (both elements empty)
9721 !! wikitext
9722 **
9723 *
9724 !! html
9725 <ul><li><ul><li></li></ul></li>
9726 <li></li></ul>
9727
9728 !! end
9729
9730 !! test
9731 Nested lists 6 (both elements empty)
9732 !! wikitext
9733 *
9734 **
9735 !! html
9736 <ul><li>
9737 <ul><li></li></ul></li></ul>
9738
9739 !! end
9740
9741 !! test
9742 Nested lists 7 (skip initial nesting levels)
9743 !! wikitext
9744 *** foo
9745 !! html
9746 <ul><li><ul><li><ul><li> foo</li></ul></li></ul></li></ul>
9747
9748 !! end
9749
9750 !! test
9751 Nested lists 8 (multiple nesting transitions)
9752 !! wikitext
9753 * foo
9754 *** bar
9755 ** baz
9756 * boo
9757 !! html
9758 <ul><li> foo
9759 <ul><li><ul><li> bar</li></ul></li>
9760 <li> baz</li></ul></li>
9761 <li> boo</li></ul>
9762
9763 !! end
9764
9765 !! test
9766 Nested lists 9 (extension interaction)
9767 !! options
9768 parsoid
9769 !! wikitext
9770 *<references />
9771 !! html/parsoid
9772 <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>
9773 !! end
9774
9775 !! test
9776 1. Lists with start-of-line-transparent tokens before bullets: Comments
9777 !! wikitext
9778 *foo
9779 *<!--cmt-->bar
9780 <!--cmt-->*baz
9781 !! html
9782 <ul><li>foo</li>
9783 <li>bar</li>
9784 <li>baz</li></ul>
9785
9786 !! end
9787
9788 !! test
9789 2. Lists with start-of-line-transparent tokens before bullets: Template close
9790 !! wikitext
9791 *foo {{echo|bar
9792 }}*baz
9793 !! html
9794 <ul><li>foo bar</li>
9795 <li>baz</li></ul>
9796
9797 !! end
9798
9799 !! test
9800 List items are not parsed correctly following a <pre> block (T2785)
9801 !! wikitext
9802 * <pre>foo</pre>
9803 * <pre>bar</pre>
9804 * zar
9805 !! html/php
9806 <ul><li> <pre>foo</pre></li>
9807 <li> <pre>bar</pre></li>
9808 <li> zar</li></ul>
9809
9810 !! html/parsoid
9811 <ul><li> <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
9812 <li> <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
9813 <li> zar</li></ul>
9814 !! end
9815
9816 !! test
9817 List items from template
9818 !! wikitext
9819
9820 {{inner list}}
9821 * item 2
9822
9823 * item 0
9824 {{inner list}}
9825 * item 2
9826
9827 * item 0
9828 * notSOL{{inner list}}
9829 * item 2
9830 !! html
9831 <ul><li> item 1</li>
9832 <li> item 2</li></ul>
9833 <ul><li> item 0</li>
9834 <li> item 1</li>
9835 <li> item 2</li></ul>
9836 <ul><li> item 0</li>
9837 <li> notSOL</li>
9838 <li> item 1</li>
9839 <li> item 2</li></ul>
9840
9841 !! end
9842
9843 !! test
9844 List interrupted by empty line or heading
9845 !! wikitext
9846 * foo
9847
9848 ** bar
9849 == A heading ==
9850 * Another list item
9851 !! html
9852 <ul><li> foo</li></ul>
9853 <ul><li><ul><li> bar</li></ul></li></ul>
9854 <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>
9855 <ul><li> Another list item</li></ul>
9856
9857 !!end
9858
9859 !!test
9860 Multiple list tags generated by templates
9861 !! wikitext
9862 {{echo|<li>}}a
9863 {{echo|<li>}}b
9864 {{echo|<li>}}c
9865 !! html
9866 <li>a
9867 <li>b
9868 <li>c</li>
9869 </li>
9870 </li>
9871
9872 !! html+tidy
9873 <ul>
9874 <li>a</li>
9875 <li>b</li>
9876 <li>c</li>
9877 </ul>
9878 !!end
9879
9880 !!test
9881 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
9882 !! wikitext
9883 *a
9884 <!--This line will NOT split the list-->
9885 *b
9886 <!--This line will NOT split the list either-->
9887 *c
9888 <!--foo--> <!----> <!--This line NOT split the list either-->
9889 *d
9890 !! html
9891 <ul><li>a</li>
9892 <li>b</li>
9893 <li>c</li>
9894 <li>d</li></ul>
9895
9896 !!end
9897
9898 !!test
9899 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
9900 !! wikitext
9901 *a
9902 <!--This line will NOT split the list-->
9903 *b
9904 <!--This line will NOT split the list either-->
9905 *c
9906 <!--foo--> <!----> <!--This line NOT split the list
9907 either-->
9908 *d
9909 !! html
9910 <ul><li>a</li>
9911 <li>b</li>
9912 <li>c</li>
9913 <li>d</li></ul>
9914
9915 !!end
9916
9917 !!test
9918 Test the li-hack
9919 (The PHP parser relies on Tidy for the hack)
9920 !!options
9921 parsoid=wt2html,wt2wt
9922 !! wikitext
9923 * foo
9924 * <li>li-hack
9925 * {{echo|<li>templated li-hack}}
9926 * <!--foo--> <li> unsupported li-hack with preceding comments
9927
9928 <ul>
9929 <li><li>not a li-hack
9930 </li>
9931 </ul>
9932 !! html+tidy
9933 <ul>
9934 <li>foo</li>
9935 <li>li-hack</li>
9936 <li>templated li-hack</li>
9937 <li>unsupported li-hack with preceding comments</li>
9938 </ul>
9939 <ul>
9940 <li>not a li-hack</li>
9941 </ul>
9942 !! html/parsoid
9943 <ul><li> foo</li>
9944 <li data-parsoid='{"stx":"html","autoInsertedEnd":true,"liHackSrc":"* "}'>li-hack</li>
9945 <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>
9946 <li data-parsoid='{"autoInsertedEnd":true}'> <!--foo--> </li><li data-parsoid='{"stx":"html","autoInsertedEnd":true}'> unsupported li-hack with preceding comments</li></ul>
9947
9948 <ul data-parsoid='{"stx":"html"}'>
9949 <li class="mw-empty-elt" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></li><li data-parsoid='{"stx":"html"}'>not a li-hack
9950 </li>
9951 </ul>
9952
9953 !!end
9954
9955 !! test
9956 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
9957 !! options
9958 parsoid
9959 !! wikitext
9960 # foo
9961 ## bar
9962 * foo
9963 ** bar
9964 : foo
9965 :: bar
9966 !! html
9967 <ol>
9968 <li> foo<ol>
9969 <li> bar</li>
9970 </ol></li>
9971 </ol><ul>
9972 <li> foo<ul>
9973 <li> bar</li>
9974 </ul></li>
9975 </ul><dl>
9976 <dd> foo<dl>
9977 <dd> bar</dd>
9978 </dl></dd>
9979 </dl>
9980 !! end
9981
9982 !! test
9983 Parsoid: Test of whitespace serialization with Templated bullets
9984 !! options
9985 parsoid
9986 !! wikitext
9987 * {{bullet}}
9988 !! html/parsoid
9989 <ul>
9990 <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>
9991 </ul>
9992 !! end
9993
9994 # ------------------------------------------------------------------------
9995 # The next set of tests are about Parsoid's ability to handle badly nested
9996 # tags (parse, minimize scope of fixup, and roundtrip back)
9997 # ------------------------------------------------------------------------
9998
9999 !! test
10000 Unbalanced closing block tags break a list
10001 (php parser relies on Tidy to fix up)
10002 !! wikitext
10003 <div>
10004 *a</div><div>
10005 *b</div>
10006 !! html+tidy
10007 <div>
10008 <ul>
10009 <li>a</li>
10010 </ul>
10011 </div>
10012 <div>
10013 <ul>
10014 <li>b</li>
10015 </ul>
10016 </div>
10017 !! end
10018
10019 # Parsoid fails this test, but it might be tricky to support properly.
10020 # See T70395.
10021 !! test
10022 Unbalanced closing non-block tags don't break a list
10023 (php parser relies on Tidy to fix up)
10024 !! wikitext
10025 <span>
10026 *a</span><span>
10027 *b</span>
10028 !! html/php+tidy
10029 <ul>
10030 <li><span>a</span></li>
10031 <li><span>b</span></li>
10032 </ul>
10033 !! html/parsoid
10034 <span>
10035 <ul>
10036 <li>a<span></span>
10037 </li>
10038 <li>b
10039 </li>
10040 </ul>
10041 </span>
10042 !! end
10043
10044 !! test
10045 Unclosed formatting tags that straddle lists are closed and reopened
10046 (php parser relies on Tidy to fix up)
10047 !! options
10048 parsoid=wt2html,wt2wt,html2html
10049 !! wikitext
10050 # <s> a
10051 # b </s>
10052 !! html/php+tidy
10053 <ol>
10054 <li><s>a</s></li>
10055 <li><s>b</s></li>
10056 </ol>
10057 !! html/parsoid
10058 <ol><li> <s> a</s></li>
10059 <li><s> b </s></li></ol>
10060 !! end
10061
10062 # See T70395.
10063 !!test
10064 1. List embedded in a formatting tag
10065 !! wikitext
10066 <small>
10067 * foo
10068 </small>
10069 !! html/php+tidy
10070 <ul>
10071 <li><small>foo</small></li>
10072 </ul>
10073 !! html/parsoid
10074 <small>
10075 <ul>
10076 <li> foo</li>
10077 </ul>
10078 </small>
10079 !!end
10080
10081 ## Ugly Parsoid output here
10082 ## Not sure what the right output is.
10083 !!test
10084 2. List embedded in a formatting tag
10085 !! wikitext
10086 <small>
10087 *a
10088 *b</small>
10089 !! html/php+tidy
10090 <ul>
10091 <li><small>a</small></li>
10092 <li><small>b</small></li>
10093 </ul>
10094 !! html/parsoid
10095 <small></small>
10096 <ul><small>
10097 <li>a</li>
10098 </small>
10099 <li><small>b</small></li>
10100 </ul>
10101 !!end
10102
10103 # Ugly Parsoid and PHP parser output here
10104 # Not sure if we want to make this a test!
10105 #
10106 ## !!test
10107 ## 3. Unclosed formatting tags in list elements
10108 ## !! wikitext
10109 ## *<small>a
10110 ## *<small>b
10111 ## !! html/php+tidy
10112 ## <ul>
10113 ## <li><small>a</small></li>
10114 ## <li><small><small>b</small></small></li>
10115 ## </ul>
10116 ## !! html/parsoid
10117 ## <ul>
10118 ## <li><small>a</small></li>
10119 ## <small>
10120 ## <li><small>b</small></li>
10121 ## </small></ul>
10122 ## !!end
10123
10124 # This is a bug in the PHP parser + tidy combination.
10125 # (The </tr> tag gets parsed as text and html-escaped by PHP,
10126 # and then fostered out of the table by tidy.)
10127 # We believe the Parsoid output to be correct.
10128 !! test
10129 Table with missing opening <tr> tag
10130 !! options
10131 parsoid=wt2html,wt2wt
10132 !! wikitext
10133 <table>
10134 <td>foo</td>
10135 </tr>
10136 </table>
10137 !! html+tidy
10138 <table>
10139 <tr>
10140 <td>foo</td>
10141 </tr>
10142 </table>
10143 !! end
10144
10145 ###
10146 ### Magic Words
10147 ###
10148
10149 # Note that the current date is hard-coded as
10150 # 1970-01-01T00:02:03Z (a Thursday)
10151 # when running parser tests. The timezone is also fixed to GMT, so
10152 # local date will be identical to current date.
10153
10154 !! test
10155 Magic Word: {{CURRENTDAY}}
10156 !! wikitext
10157 {{CURRENTDAY}}
10158 !! html
10159 <p>1
10160 </p>
10161 !! end
10162
10163 !! test
10164 Magic Word: {{CURRENTDAY2}}
10165 !! wikitext
10166 {{CURRENTDAY2}}
10167 !! html
10168 <p>01
10169 </p>
10170 !! end
10171
10172 !! test
10173 Magic Word: {{CURRENTDAYNAME}}
10174 !! wikitext
10175 {{CURRENTDAYNAME}}
10176 !! html
10177 <p>Thursday
10178 </p>
10179 !! end
10180
10181 !! test
10182 Magic Word: {{CURRENTDOW}}
10183 !! wikitext
10184 {{CURRENTDOW}}
10185 !! html
10186 <p>4
10187 </p>
10188 !! end
10189
10190 !! test
10191 Magic Word: {{CURRENTMONTH}}
10192 !! wikitext
10193 {{CURRENTMONTH}}
10194 !! html
10195 <p>01
10196 </p>
10197 !! end
10198
10199 !! test
10200 Magic Word: {{CURRENTMONTH1}}
10201 !! wikitext
10202 {{CURRENTMONTH1}}
10203 !! html
10204 <p>1
10205 </p>
10206 !! end
10207
10208 !! test
10209 Magic Word: {{CURRENTMONTHABBREV}}
10210 !! wikitext
10211 {{CURRENTMONTHABBREV}}
10212 !! html
10213 <p>Jan
10214 </p>
10215 !! end
10216
10217 !! test
10218 Magic Word: {{CURRENTMONTHNAME}}
10219 !! wikitext
10220 {{CURRENTMONTHNAME}}
10221 !! html
10222 <p>January
10223 </p>
10224 !! end
10225
10226 !! test
10227 Magic Word: {{CURRENTMONTHNAMEGEN}}
10228 !! wikitext
10229 {{CURRENTMONTHNAMEGEN}}
10230 !! html
10231 <p>January
10232 </p>
10233 !! end
10234
10235 !! test
10236 Magic Word: {{CURRENTTIME}}
10237 !! wikitext
10238 {{CURRENTTIME}}
10239 !! html
10240 <p>00:02
10241 </p>
10242 !! end
10243
10244 !! test
10245 Magic Word: {{CURRENTHOUR}}
10246 !! wikitext
10247 {{CURRENTHOUR}}
10248 !! html
10249 <p>00
10250 </p>
10251 !! end
10252
10253 !! test
10254 Magic Word: {{CURRENTWEEK}} (T6594)
10255 !! wikitext
10256 {{CURRENTWEEK}}
10257 !! html
10258 <p>1
10259 </p>
10260 !! end
10261
10262 !! test
10263 Magic Word: {{CURRENTYEAR}}
10264 !! wikitext
10265 {{CURRENTYEAR}}
10266 !! html
10267 <p>1970
10268 </p>
10269 !! end
10270
10271 !! test
10272 Magic Word: {{CURRENTTIMESTAMP}}
10273 !! wikitext
10274 {{CURRENTTIMESTAMP}}
10275 !! html
10276 <p>19700101000203
10277 </p>
10278 !! end
10279
10280 !! test
10281 Magic Words LOCAL (UTC)
10282 !! wikitext
10283 * {{LOCALMONTH}}
10284 * {{LOCALMONTH1}}
10285 * {{LOCALMONTHNAME}}
10286 * {{LOCALMONTHNAMEGEN}}
10287 * {{LOCALMONTHABBREV}}
10288 * {{LOCALDAY}}
10289 * {{LOCALDAY2}}
10290 * {{LOCALDAYNAME}}
10291 * {{LOCALYEAR}}
10292 * {{LOCALTIME}}
10293 * {{LOCALHOUR}}
10294 * {{LOCALWEEK}}
10295 * {{LOCALDOW}}
10296 * {{LOCALTIMESTAMP}}
10297 !! html
10298 <ul><li> 01</li>
10299 <li> 1</li>
10300 <li> January</li>
10301 <li> January</li>
10302 <li> Jan</li>
10303 <li> 1</li>
10304 <li> 01</li>
10305 <li> Thursday</li>
10306 <li> 1970</li>
10307 <li> 00:02</li>
10308 <li> 00</li>
10309 <li> 1</li>
10310 <li> 4</li>
10311 <li> 19700101000203</li></ul>
10312
10313 !! end
10314
10315 !! test
10316 Magic Word: {{FULLPAGENAME}}
10317 !! options
10318 title=[[User:Ævar Arnfjörð Bjarmason]]
10319 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10320 !! wikitext
10321 {{FULLPAGENAME}}
10322 !! html/*
10323 <p>User:Ævar Arnfjörð Bjarmason
10324 </p>
10325 !! end
10326
10327 !! test
10328 Magic Word: {{FULLPAGENAMEE}}
10329 !! options
10330 title=[[User:Ævar Arnfjörð Bjarmason]]
10331 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10332 !! wikitext
10333 {{FULLPAGENAMEE}}
10334 !! html/*
10335 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10336 </p>
10337 !! end
10338
10339 !! test
10340 Magic Word: {{TALKSPACE}}
10341 !! options
10342 title=[[User:Ævar Arnfjörð Bjarmason]]
10343 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10344 !! wikitext
10345 {{TALKSPACE}}
10346 !! html/*
10347 <p>User talk
10348 </p>
10349 !! end
10350
10351 !! test
10352 Magic Word: {{TALKSPACE}}, same namespace
10353 !! options
10354 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10355 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10356 !! wikitext
10357 {{TALKSPACE}}
10358 !! html/*
10359 <p>User talk
10360 </p>
10361 !! end
10362
10363 !! test
10364 Magic Word: {{TALKSPACE}}, main namespace
10365 !! options
10366 title=[[Parser Test]]
10367 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10368 !! wikitext
10369 {{TALKSPACE}}
10370 !! html/*
10371 <p>Talk
10372 </p>
10373 !! end
10374
10375 !! test
10376 Magic Word: {{TALKSPACEE}}
10377 !! options
10378 title=[[User:Ævar Arnfjörð Bjarmason]]
10379 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10380 !! wikitext
10381 {{TALKSPACEE}}
10382 !! html/*
10383 <p>User_talk
10384 </p>
10385 !! end
10386
10387 !! test
10388 Magic Word: {{SUBJECTSPACE}}
10389 !! options
10390 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10391 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10392 !! wikitext
10393 {{SUBJECTSPACE}}
10394 !! html/*
10395 <p>User
10396 </p>
10397 !! end
10398
10399 !! test
10400 Magic Word: {{SUBJECTSPACE}}, same namespace
10401 !! options
10402 title=[[User:Ævar Arnfjörð Bjarmason]]
10403 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10404 !! wikitext
10405 {{SUBJECTSPACE}}
10406 !! html/*
10407 <p>User
10408 </p>
10409 !! end
10410
10411 !! test
10412 Magic Word: {{SUBJECTSPACE}}, main namespace
10413 !! options
10414 title=[[Parser Test]]
10415 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10416 !! wikitext
10417 {{SUBJECTSPACE}}
10418 !! html/*
10419
10420 !! end
10421
10422 !! test
10423 Magic Word: {{SUBJECTSPACEE}}
10424 !! options
10425 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10426 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10427 !! wikitext
10428 {{SUBJECTSPACEE}}
10429 !! html/*
10430 <p>User
10431 </p>
10432 !! end
10433
10434 !! test
10435 Magic Word: {{NAMESPACE}}
10436 !! options
10437 title=[[User:Ævar Arnfjörð Bjarmason]]
10438 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10439 !! wikitext
10440 {{NAMESPACE}}
10441 !! html/*
10442 <p>User
10443 </p>
10444 !! end
10445
10446 !! test
10447 Magic Word: {{NAMESPACEE}}
10448 !! options
10449 title=[[User:Ævar Arnfjörð Bjarmason]]
10450 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10451 !! wikitext
10452 {{NAMESPACEE}}
10453 !! html/*
10454 <p>User
10455 </p>
10456 !! end
10457
10458 !! test
10459 Magic Word: {{NAMESPACENUMBER}}
10460 !! options
10461 title=[[User:Ævar Arnfjörð Bjarmason]]
10462 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10463 !! wikitext
10464 {{NAMESPACENUMBER}}
10465 !! html/*
10466 <p>2
10467 </p>
10468 !! end
10469
10470 !! test
10471 Magic Word: {{SUBPAGENAME}}
10472 !! options
10473 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10474 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10475 !! wikitext
10476 {{SUBPAGENAME}}
10477 !! html/*
10478 <p>sub ö
10479 </p>
10480 !! end
10481
10482 !! test
10483 Magic Word: {{SUBPAGENAMEE}}
10484 !! options
10485 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10486 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10487 !! wikitext
10488 {{SUBPAGENAMEE}}
10489 !! html/*
10490 <p>sub_%C3%B6
10491 </p>
10492 !! end
10493
10494 !! test
10495 Magic Word: {{ROOTPAGENAME}}
10496 !! options
10497 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10498 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10499 !! wikitext
10500 {{ROOTPAGENAME}}
10501 !! html/*
10502 <p>Ævar Arnfjörð Bjarmason
10503 </p>
10504 !! end
10505
10506 !! test
10507 Magic Word: {{ROOTPAGENAMEE}}
10508 !! options
10509 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10510 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10511 !! wikitext
10512 {{ROOTPAGENAMEE}}
10513 !! html/*
10514 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10515 </p>
10516 !! end
10517
10518 !! test
10519 Magic Word: {{BASEPAGENAME}}
10520 !! options
10521 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10522 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10523 !! wikitext
10524 {{BASEPAGENAME}}
10525 !! html/*
10526 <p>Ævar Arnfjörð Bjarmason
10527 </p>
10528 !! end
10529
10530 !! test
10531 Magic Word: {{BASEPAGENAMEE}}
10532 !! options
10533 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10534 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10535 !! wikitext
10536 {{BASEPAGENAMEE}}
10537 !! html/*
10538 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10539 </p>
10540 !! end
10541
10542 !! test
10543 Magic Word: {{TALKPAGENAME}}
10544 !! options
10545 title=[[User:Ævar Arnfjörð Bjarmason]]
10546 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10547 !! wikitext
10548 {{TALKPAGENAME}}
10549 !! html/*
10550 <p>User talk:Ævar Arnfjörð Bjarmason
10551 </p>
10552 !! end
10553
10554 !! test
10555 Magic Word: {{TALKPAGENAMEE}}
10556 !! options
10557 title=[[User:Ævar Arnfjörð Bjarmason]]
10558 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10559 !! wikitext
10560 {{TALKPAGENAMEE}}
10561 !! html/*
10562 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10563 </p>
10564 !! end
10565
10566 !! test
10567 Magic Word: {{SUBJECTPAGENAME}}
10568 !! options
10569 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10570 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10571 !! wikitext
10572 {{SUBJECTPAGENAME}}
10573 !! html/*
10574 <p>User:Ævar Arnfjörð Bjarmason
10575 </p>
10576 !! end
10577
10578 !! test
10579 Magic Word: {{SUBJECTPAGENAMEE}}
10580 !! options
10581 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10582 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10583 !! wikitext
10584 {{SUBJECTPAGENAMEE}}
10585 !! html/*
10586 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10587 </p>
10588 !! end
10589
10590 !! test
10591 Magic Word: {{NUMBEROFFILES}}
10592 !! options
10593 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10594 !! wikitext
10595 {{NUMBEROFFILES}}
10596 !! html/*
10597 <p>7
10598 </p>
10599 !! end
10600
10601 !! test
10602 Magic Word: {{PAGENAME}}
10603 !! options
10604 title=[[User:Ævar Arnfjörð Bjarmason]]
10605 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10606 !! wikitext
10607 {{PAGENAME}}
10608 !! html/*
10609 <p>Ævar Arnfjörð Bjarmason
10610 </p>
10611 !! end
10612
10613 !! test
10614 Magic Word: {{PAGENAME}} with metacharacters
10615 !! options
10616 title=[['foo & bar = baz']]
10617 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10618 !! wikitext
10619 ''{{PAGENAME}}''
10620 !! html/php
10621 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10622 </p>
10623 !! html+tidy
10624 <p><i>'foo &amp; bar = baz'</i></p>
10625 !! end
10626
10627 !! test
10628 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10629 !! options
10630 title=[[*RFC 1234 http://example.com/]]
10631 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10632 !! wikitext
10633 {{PAGENAME}}
10634 !! html/php
10635 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10636 </p>
10637 !! html+tidy
10638 <p>*RFC 1234 http://example.com/</p>
10639 !! end
10640
10641 !! test
10642 Magic Word: {{PAGENAMEE}}
10643 !! options
10644 title=[[User:Ævar Arnfjörð Bjarmason]]
10645 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10646 !! wikitext
10647 {{PAGENAMEE}}
10648 !! html/*
10649 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10650 </p>
10651 !! end
10652
10653 !! test
10654 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10655 !! options
10656 title=[[*RFC 1234 http://example.com/]]
10657 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10658 !! wikitext
10659 {{PAGENAMEE}}
10660 !! html/php
10661 <p>&#42;RFC_1234_http&#58;//example.com/
10662 </p>
10663 !! html+tidy
10664 <p>*RFC_1234_http://example.com/</p>
10665 !! end
10666
10667 !! test
10668 Magic Word: {{REVISIONID}}
10669 !! options
10670 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10671 showflags
10672 !! wikitext
10673 {{REVISIONID}}
10674 !! html/*
10675 <p>1337
10676 </p>
10677 flags=vary-revision-id
10678 !! end
10679
10680 !! test
10681 Magic Word: {{SCRIPTPATH}}
10682 !! options
10683 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10684 !! wikitext
10685 {{SCRIPTPATH}}
10686 !! html/*
10687
10688 !! end
10689
10690 !! test
10691 Magic Word: {{STYLEPATH}}
10692 !! options
10693 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10694 !! wikitext
10695 {{STYLEPATH}}
10696 !! html/*
10697 <p>/skins
10698 </p>
10699 !! end
10700
10701 !! test
10702 Magic Word: {{SERVER}}
10703 !! options
10704 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10705 !! wikitext
10706 {{SERVER}}
10707 !! html/*
10708 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10709 </p>
10710 !! end
10711
10712 !! test
10713 Magic Word: {{SERVERNAME}}
10714 !! options
10715 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10716 !! wikitext
10717 {{SERVERNAME}}
10718 !! html/*
10719 <p>example.org
10720 </p>
10721 !! end
10722
10723 !! test
10724 Magic Word: {{SITENAME}}
10725 !! options
10726 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10727 !! wikitext
10728 {{SITENAME}}
10729 !! html/*
10730 <p>MediaWiki
10731 </p>
10732 !! end
10733
10734 !! test
10735 Magic Word: {{PAGELANGUAGE}}
10736 !! options
10737 language=fr
10738 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10739 !! wikitext
10740 {{PAGELANGUAGE}}
10741 !! html/*
10742 <p>fr
10743 </p>
10744 !! end
10745
10746 !! test
10747 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10748 !! options
10749 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10750 !! wikitext
10751 {{PAGELANGUAGE}}
10752 !! html/*
10753 <p>en
10754 </p>
10755 !! end
10756
10757 !! test
10758 Case-sensitive magic words, when cased differently, should just be template transclusions
10759 !! wikitext
10760 {{CurrentMonth}}
10761 {{currentday}}
10762 {{cURreNTweEK}}
10763 {{currentHour}}
10764 !! html
10765 <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>
10766 <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>
10767 <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>
10768 <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>
10769 </p>
10770 !! end
10771
10772 !! test
10773 Case-insensitive magic words should still work with weird casing.
10774 !! wikitext
10775 {{sErVeRNaMe}}
10776 {{LCFirst:AOEU}}
10777 {{ucFIRST:aoeu}}
10778 {{SERver}}
10779 !! html
10780 <p>example.org
10781 aOEU
10782 Aoeu
10783 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10784 </p>
10785 !! end
10786
10787 # From plwiki:PLOS_ONE
10788 !! test
10789 Parsoid: Page property magic word with magic word contents
10790 !! wikitext
10791 {{DISPLAYTITLE:''{{PAGENAME}}''}}
10792 !! html/parsoid
10793 <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>"}]]}'/>
10794 !! end
10795
10796 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
10797 # But, this is a limitation of our representation and is documented in
10798 # TemplateHandler.js in processSpecialMagicWord
10799 !! test
10800 Parsoid: Template-generated DISPLAYTITLE
10801 !! wikitext
10802 {{{{echo|DISPLAYTITLE}}:Foo}}
10803 !! options
10804 showtitle
10805 !! config
10806 wgAllowDisplayTitle=true
10807 wgRestrictDisplayTitle=false
10808 !! html/php
10809 Foo
10810
10811 !! html/parsoid
10812 <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"}]]}'/>
10813 !! end
10814
10815 !! test
10816 Namespace 1 {{ns:1}}
10817 !! wikitext
10818 {{ns:1}}
10819 !! html
10820 <p>Talk
10821 </p>
10822 !! end
10823
10824 !! test
10825 Namespace 1 {{ns:01}}
10826 !! wikitext
10827 {{ns:01}}
10828 !! html
10829 <p>Talk
10830 </p>
10831 !! end
10832
10833 !! test
10834 Namespace 0 {{ns:0}} (T6783)
10835 !! wikitext
10836 {{ns:0}}
10837 !! html
10838
10839 !! end
10840
10841 !! test
10842 Namespace 0 {{ns:00}} (T6783)
10843 !! wikitext
10844 {{ns:00}}
10845 !! html
10846
10847 !! end
10848
10849 !! test
10850 Namespace -1 {{ns:-1}}
10851 !! wikitext
10852 {{ns:-1}}
10853 !! html
10854 <p>Special
10855 </p>
10856 !! end
10857
10858 !! test
10859 Namespace User {{ns:User}}
10860 !! wikitext
10861 {{ns:User}}
10862 !! html
10863 <p>User
10864 </p>
10865 !! end
10866
10867 !! test
10868 Namespace User talk {{ns:User_talk}}
10869 !! wikitext
10870 {{ns:User_talk}}
10871 !! html
10872 <p>User talk
10873 </p>
10874 !! end
10875
10876 !! test
10877 Namespace User talk {{ns:uSeR tAlK}}
10878 !! wikitext
10879 {{ns:uSeR tAlK}}
10880 !! html
10881 <p>User talk
10882 </p>
10883 !! end
10884
10885 !! test
10886 Namespace File {{ns:File}}
10887 !! wikitext
10888 {{ns:File}}
10889 !! html
10890 <p>File
10891 </p>
10892 !! end
10893
10894 !! test
10895 Namespace File {{ns:Image}}
10896 !! wikitext
10897 {{ns:Image}}
10898 !! html
10899 <p>File
10900 </p>
10901 !! end
10902
10903 !! test
10904 Namespace (lang=de) Benutzer {{ns:User}}
10905 !! options
10906 language=de
10907 !! wikitext
10908 {{ns:User}}
10909 !! html
10910 <p>Benutzer
10911 </p>
10912 !! end
10913
10914 !! test
10915 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
10916 !! options
10917 language=de
10918 !! wikitext
10919 {{ns:3}}
10920 !! html
10921 <p>Benutzer Diskussion
10922 </p>
10923 !! end
10924
10925 !! test
10926 Urlencode
10927 !! wikitext
10928 {{urlencode:hi world?!}}
10929 {{urlencode:hi world?!|WIKI}}
10930 {{urlencode:hi world?!|PATH}}
10931 {{urlencode:hi world?!|QUERY}}
10932 !! html/php
10933 <p>hi+world%3F%21
10934 hi_world%3F!
10935 hi%20world%3F%21
10936 hi+world%3F%21
10937 </p>
10938 !! end
10939
10940 !! test
10941 Magic Word: prioritize type info over data-parsoid
10942 !! options
10943 parsoid=html2wt
10944 !! html/parsoid
10945 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
10946 !! wikitext
10947 __FORCETOC__
10948 !! end
10949
10950 !! test
10951 Magic Word: serialize on separate line (parsoid)
10952 !! options
10953 parsoid=wt2wt,html2wt
10954 !! wikitext
10955 foo
10956 __NOTOC__
10957 bar
10958 !! html/parsoid
10959 foo<meta property="mw:PageProp/notoc"/>bar
10960 !! end
10961
10962 !! test
10963 Magic Word: rt non-english wikis
10964 !! options
10965 parsoid=wt2wt
10966 language=de
10967 !! wikitext
10968 __NOEDITSECTION__
10969 !! html/parsoid
10970 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
10971 !! end
10972
10973 !!test
10974 __proto__ is treated as normal wikitext (T105997)
10975 !!wikitext
10976 __proto__
10977 !!html
10978 <p>__proto__
10979 </p>
10980 !!end
10981
10982 ###
10983 ### Magic links
10984 ###
10985 !! test
10986 Magic links: internal link to RFC (T2479)
10987 !! wikitext
10988 [[RFC 123]]
10989 !! html/php
10990 <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>
10991 </p>
10992 !! html/parsoid
10993 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
10994 !! end
10995
10996 !! test
10997 Magic links: RFC (T2479)
10998 !! wikitext
10999 RFC 822
11000 !! html/php
11001 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11002 </p>
11003 !! html/parsoid
11004 <p><a href="https://tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a></p>
11005 !! end
11006
11007 !! test
11008 Magic links: RFC (T67278)
11009 !! wikitext
11010 This is RFC 822 but thisRFC 822 is not RFC 822linked.
11011 !! html/php
11012 <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.
11013 </p>
11014 !! html/parsoid
11015 <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>
11016 !! end
11017
11018 !! test
11019 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
11020 !! wikitext
11021 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
11022 RFC
11023 822
11024 !! html/php
11025 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc822">RFC 822</a>
11026 RFC
11027 822
11028 </p>
11029 !! html/parsoid
11030 <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>
11031 RFC
11032 822</p>
11033 !! end
11034
11035 !! test
11036 Magic links: ISBN (T3937)
11037 !! wikitext
11038 ISBN 0-306-40615-2
11039 !! html/php
11040 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
11041 </p>
11042 !! html/parsoid
11043 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
11044 !! end
11045
11046 !! test
11047 Magic links: ISBN (T67278)
11048 !! wikitext
11049 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
11050 !! html/php
11051 <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.
11052 </p>
11053 !! html/parsoid
11054 <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>
11055 !! end
11056
11057 !! test
11058 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
11059 !! wikitext
11060 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
11061 ISBN
11062 9780316098113
11063 ISBN 978
11064 0316098113
11065 !! html/php
11066 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
11067 ISBN
11068 9780316098113
11069 ISBN 978
11070 0316098113
11071 </p>
11072 !! html/parsoid
11073 <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>
11074 ISBN
11075 9780316098113
11076 ISBN 978
11077 0316098113</p>
11078 !! end
11079
11080 !! test
11081 Magic links: PMID incorrectly converts space to underscore
11082 !! wikitext
11083 PMID 1234
11084 !! html/php
11085 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11086 </p>
11087 !! html/parsoid
11088 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a></p>
11089 !! end
11090
11091 !! test
11092 Magic links: PMID (T67278)
11093 !! wikitext
11094 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
11095 !! html/php
11096 <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.
11097 </p>
11098 !! html/parsoid
11099 <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>
11100 !! end
11101
11102 !! test
11103 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
11104 !! wikitext
11105 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
11106 PMID
11107 1234
11108 !! html/php
11109 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
11110 PMID
11111 1234
11112 </p>
11113 !! html/parsoid
11114 <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>
11115 PMID
11116 1234</p>
11117 !! end
11118
11119 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
11120 # since these are ExtLinkText, not MagicLinkText
11121 !! test
11122 Magic links: use appropriate serialization for "almost" magic links.
11123 !! wikitext
11124 X[[Special:BookSources/0978739256|foo]]
11125
11126 X[https://tools.ietf.org/html/rfc1234 foo]
11127 !! html/php
11128 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
11129 </p><p>X<a rel="nofollow" class="external text" href="https://tools.ietf.org/html/rfc1234">foo</a>
11130 </p>
11131 !! html/parsoid
11132 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
11133 <p>X<a rel="mw:ExtLink" href="https://tools.ietf.org/html/rfc1234">foo</a></p>
11134 !! end
11135
11136 !! test
11137 Magic links: All disabled (T47942)
11138 !! options
11139 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
11140 !! wikitext
11141 ISBN 0-306-40615-2
11142 PMID 1234
11143 RFC 4321
11144 !! html/php
11145 <p>ISBN 0-306-40615-2
11146 PMID 1234
11147 RFC 4321
11148 </p>
11149 !! end
11150
11151 ###
11152 ### Templates
11153 ####
11154
11155 !! test
11156 Nonexistent template
11157 !! wikitext
11158 {{thistemplatedoesnotexist}}
11159 !! html
11160 <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>
11161 </p>
11162 !! end
11163
11164 !! test
11165 Template with invalid target containing tags
11166 !! wikitext
11167 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11168 !! html
11169 <p>{{a<b>b</b>|foo|a=b|a = b}}
11170 </p>
11171 !! end
11172
11173 !! test
11174 Template with invalid target containing unclosed tag
11175 !! wikitext
11176 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
11177 !! html
11178 <p>{{a<b>|foo|a=b|a = b}}</b>
11179 </p>
11180 !! end
11181
11182 !! test
11183 Template with invalid target containing wikilink
11184 !! wikitext
11185 {{[[Main Page]]}}
11186 !! html/php
11187 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
11188 </p>
11189 !! html/parsoid
11190 <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>
11191 !! end
11192
11193 !! test
11194 Template with just whitespace in it, T70421
11195 !! wikitext
11196 {{echo|{{ }}}}
11197 !! html/parsoid
11198 <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>
11199 !! end
11200
11201 !! article
11202 Template:test
11203 !! text
11204 This is a test template
11205 !! endarticle
11206
11207 !! test
11208 Simple template
11209 !! wikitext
11210 {{test}}
11211 !! html
11212 <p>This is a test template
11213 </p>
11214 !! end
11215
11216 !! test
11217 Template with explicit namespace
11218 !! wikitext
11219 {{Template:test}}
11220 !! html
11221 <p>This is a test template
11222 </p>
11223 !! end
11224
11225
11226 !! article
11227 Template:paramtest
11228 !! text
11229 This is a test template with parameter {{{param}}}
11230 !! endarticle
11231
11232 !! test
11233 Template parameter
11234 !! wikitext
11235 {{paramtest|param=foo}}
11236 !! html
11237 <p>This is a test template with parameter foo
11238 </p>
11239 !! end
11240
11241 !! article
11242 Template:paramtestnum
11243 !! text
11244 [[{{{1}}}|{{{2}}}]]
11245 !! endarticle
11246
11247 !! test
11248 Template unnamed parameter
11249 !! wikitext
11250 {{paramtestnum|Main Page|the main page}}
11251 !! html
11252 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11253 </p>
11254 !! end
11255
11256 !! article
11257 Template:templatesimple
11258 !! text
11259 (test)
11260 !! endarticle
11261
11262 !! article
11263 Template:templateredirect
11264 !! text
11265 #redirect [[Template:templatesimple]]
11266 !! endarticle
11267
11268 !! article
11269 Template:templateasargtestnum
11270 !! text
11271 {{{{{1}}}}}
11272 !! endarticle
11273
11274 !! article
11275 Template:templateasargtest
11276 !! text
11277 {{template{{{templ}}}}}
11278 !! endarticle
11279
11280 !! article
11281 Template:templateasargtest2
11282 !! text
11283 {{{{{templ}}}}}
11284 !! endarticle
11285
11286 !! test
11287 Template with template name as unnamed argument
11288 !! wikitext
11289 {{templateasargtestnum|templatesimple}}
11290 !! html
11291 <p>(test)
11292 </p>
11293 !! end
11294
11295 !! test
11296 Template with template name as argument
11297 !! wikitext
11298 {{templateasargtest|templ=simple}}
11299 !! html
11300 <p>(test)
11301 </p>
11302 !! end
11303
11304 !! test
11305 Template with template name as argument (2)
11306 !! wikitext
11307 {{templateasargtest2|templ=templatesimple}}
11308 !! html
11309 <p>(test)
11310 </p>
11311 !! end
11312
11313 !! article
11314 Template:templateasargtestdefault
11315 !! text
11316 {{{{{templ|templatesimple}}}}}
11317 !! endarticle
11318
11319 !! article
11320 Template:templa
11321 !! text
11322 '''templ'''
11323 !! endarticle
11324
11325 !! test
11326 Template with default value
11327 !! wikitext
11328 {{templateasargtestdefault}}
11329 !! html
11330 <p>(test)
11331 </p>
11332 !! end
11333
11334 !! test
11335 Template with default value (value set)
11336 !! wikitext
11337 {{templateasargtestdefault|templ=templa}}
11338 !! html
11339 <p><b>templ</b>
11340 </p>
11341 !! end
11342
11343 !! test
11344 Template redirect
11345 !! wikitext
11346 {{templateredirect}}
11347 !! html/php
11348 <p>(test)
11349 </p>
11350 !! html/parsoid
11351 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11352 !! end
11353
11354 !! test
11355 Template with argument in separate line
11356 !! wikitext
11357 {{ templateasargtest |
11358 templ = simple }}
11359 !! html
11360 <p>(test)
11361 </p>
11362 !! end
11363
11364 !! test
11365 Template with complex template as argument
11366 !! wikitext
11367 {{paramtest|
11368 param ={{ templateasargtest |
11369 templ = simple }}}}
11370 !! html
11371 <p>This is a test template with parameter (test)
11372 </p>
11373 !! end
11374
11375 !! test
11376 Templates with templated name
11377 !! wikitext
11378 {{{{echo|echo}}|foo}}
11379 {{{{echo|inner list}} }}
11380 !! html
11381 <p>foo
11382 </p>
11383 <ul><li> item 1</li></ul>
11384
11385 !! html/parsoid
11386 <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>
11387 <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>
11388 !! end
11389
11390 ## Regression test; the output here isn't really that interesting.
11391 !! test
11392 Templates with templated name and top level template args
11393 !! wikitext
11394 {{1{{2{{{3}}}|4=5}}}}
11395 !! html/parsoid
11396 <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>
11397 !! end
11398
11399 # Parsoid markup is deliberate "broken". This is an edge case.
11400 # See long comment in TemplateHandler.js:convertAttribsToString.
11401 !! test
11402 Templates with invalid templated targets
11403 !! wikitext
11404 {{echo
11405 {{echo|foo}}
11406 }}
11407 !! html/php
11408 <p>{{echo
11409 foo
11410 }}
11411 </p>
11412 !! html/parsoid
11413 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11414 foo }}</p>
11415 !! end
11416
11417 !! test
11418 Template with thumb image (with link in description)
11419 !! wikitext
11420 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11421 !! html/php
11422 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>
11423
11424 !! html+tidy
11425 <p>This is a test template with parameter</p>
11426 <div class="thumb tright">
11427 <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>
11428 <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>
11429 </div>
11430 </div>
11431 !! html/parsoid
11432 <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>
11433 !! end
11434
11435 !! article
11436 Template:complextemplate
11437 !! text
11438 {{{1}}} {{paramtest|
11439 param ={{{param}}}}}
11440 !! endarticle
11441
11442 !! test
11443 Template with complex arguments
11444 !! wikitext
11445 {{complextemplate|
11446 param ={{ templateasargtest |
11447 templ = simple }}|[[Template:complextemplate|link]]}}
11448 !! html
11449 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11450 </p>
11451 !! end
11452
11453 !! test
11454 T2553: link with two variables in a piped link
11455 !! wikitext
11456 {|
11457 |[[{{{1}}}|{{{2}}}]]
11458 |}
11459 !! html/php
11460 <table>
11461 <tr>
11462 <td>[[{{{1}}}|{{{2}}}]]
11463 </td></tr></table>
11464
11465 !! html/parsoid
11466 <table>
11467 <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>
11468 </tbody></table>
11469 !! end
11470
11471 # See: T2553
11472 !! test
11473 Abort table cell attribute parsing on wikilink
11474 !! wikitext
11475 {|
11476 | testing [[one|two]] | three || four
11477 | testing one two | three || four
11478 | testing="[[one|two]]" | three || four
11479 |}
11480 !! html/php
11481 <table>
11482 <tr>
11483 <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>
11484 <td> four
11485 </td>
11486 <td> three </td>
11487 <td> four
11488 </td>
11489 <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>
11490 <td> four
11491 </td></tr></table>
11492
11493 !! html/parsoid
11494 <table>
11495 <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>
11496 <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>
11497 <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>
11498 </tbody></table>
11499 !! end
11500
11501 !! test
11502 Don't abort table cell attribute parsing if wikilink is found in template arg
11503 !! wikitext
11504 {|
11505 | Test {{#tag:ref|One two "[[three]]" four}}
11506 |}
11507 !! html/parsoid
11508 <table>
11509 <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>
11510 </tbody></table>
11511 !! end
11512
11513 !! test
11514 Magic variable as template parameter
11515 !! wikitext
11516 {{paramtest|param={{SITENAME}}}}
11517 !! html
11518 <p>This is a test template with parameter MediaWiki
11519 </p>
11520 !! end
11521
11522 !! article
11523 Template:linktest
11524 !! text
11525 [[{{{param}}}|link]]
11526 !! endarticle
11527
11528 !! test
11529 Template parameter as link source
11530 !! wikitext
11531 {{linktest|param=Main Page}}
11532 !! html
11533 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11534 </p>
11535 !! end
11536
11537 !!article
11538 Template:paramtest2
11539 !! text
11540 including another template, {{paramtest|param={{{arg}}}}}
11541 !! endarticle
11542
11543 !! test
11544 Template passing argument to another template
11545 !! wikitext
11546 {{paramtest2|arg='hmm'}}
11547 !! html
11548 <p>including another template, This is a test template with parameter 'hmm'
11549 </p>
11550 !! end
11551
11552 !! article
11553 Template:Linktest2
11554 !! text
11555 Main Page
11556 !! endarticle
11557
11558 !! test
11559 Template as link source
11560 !! wikitext
11561 [[{{linktest2}}]]
11562
11563 [[{{linktest2}}|Main Page]]
11564
11565 [[{{linktest2}}]]Page
11566 !! html
11567 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11568 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11569 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11570 </p>
11571 !! end
11572
11573
11574 !! article
11575 Template:loop1
11576 !! text
11577 {{loop2}}
11578 !! endarticle
11579
11580 !! article
11581 Template:loop2
11582 !! text
11583 {{loop1}}
11584 !! endarticle
11585
11586 !! test
11587 Template infinite loop
11588 !! wikitext
11589 {{loop1}}
11590 !! html
11591 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11592 </p>
11593 !! end
11594
11595 !! test
11596 Template from main namespace
11597 !! wikitext
11598 {{:Main Page}}
11599 !! html
11600 <p>blah blah
11601 </p>
11602 !! end
11603
11604 !! article
11605 Template:table
11606 !! text
11607 {|
11608 | 1 || 2
11609 |-
11610 | 3 || 4
11611 |}
11612 !! endarticle
11613
11614 !! test
11615 T2529: Template with table, not included at beginning of line
11616 !! wikitext
11617 foo {{table}}
11618 !! html
11619 <p>foo
11620 </p>
11621 <table>
11622 <tr>
11623 <td> 1 </td>
11624 <td> 2
11625 </td></tr>
11626 <tr>
11627 <td> 3 </td>
11628 <td> 4
11629 </td></tr></table>
11630
11631 !! end
11632
11633 !! test
11634 T2523: Template shouldn't eat newline (or add an extra one before table)
11635 !! wikitext
11636 foo
11637 {{table}}
11638 !! html
11639 <p>foo
11640 </p>
11641 <table>
11642 <tr>
11643 <td> 1 </td>
11644 <td> 2
11645 </td></tr>
11646 <tr>
11647 <td> 3 </td>
11648 <td> 4
11649 </td></tr></table>
11650
11651 !! end
11652
11653 !! test
11654 T2041: Template parameters shown as broken links
11655 !! wikitext
11656 {{{parameter}}}
11657 !! html
11658 <p>{{{parameter}}}
11659 </p>
11660 !! end
11661
11662 !! test
11663 Template with targets containing wikilinks
11664 !! options
11665 parsoid=wt2html
11666 !! wikitext
11667 {{[[foo]]}}
11668
11669 {{[[{{echo|foo}}]]}}
11670
11671 {{{{echo|[[foo}}]]}}
11672 !! html/php
11673 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11674 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11675 </p><p>{{[[foo}}]]
11676 </p>
11677 !! html/parsoid
11678 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11679 <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>
11680 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11681 !! end
11682
11683 !! article
11684 Template:''
11685 !! text
11686 bar
11687 !! endarticle
11688
11689 !! test
11690 Templates: Double quotes as template target
11691 !! wikitext
11692 foo {{''}} baz
11693 !! html/php
11694 <p>foo bar baz
11695 </p>
11696 !! html/parsoid
11697 <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
11698 </p>
11699 !! end
11700
11701 ## This test is about making sure Parsoid's data-mw is well formed in the
11702 ## face of multiple templates with intersecting and overlapping ranges. The
11703 ## wikitext itself is wretched.
11704 !! test
11705 Templates with intersecting and overlapping ranges
11706 !! wikitext
11707 {|{{echo|
11708 <p>ha</p>}}
11709 {|{{echo|
11710 <p>ho</p>}}
11711 {{echo|{{!}}hi}}
11712 |}
11713 !! html/php+tidy
11714 <p>ha</p>
11715 <p>ho</p>
11716 <table>
11717 <tr>
11718 <td></td>
11719 </tr>
11720 <tr>
11721 <td>hi</td>
11722 </tr>
11723 </table>
11724 <table>
11725 <tr>
11726 <td></td>
11727 </tr>
11728 </table>
11729 !! html/parsoid
11730 <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":""}]]}'>
11731
11732 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11733
11734 <tbody><tr><td>hi</td></tr>
11735 </tbody></table>
11736 !! end
11737
11738 !! article
11739 Template:MSGNW test
11740 !! text
11741 ''None'' of '''this''' should be
11742 * interpreted
11743 but rather passed unmodified
11744 {{test}}
11745 <gallery>
11746 File:Foobar.jpg
11747 </gallery>
11748 <!-- comment -->
11749 !! endarticle
11750
11751 # hmm, fix this or just deprecate msgnw and document its behavior?
11752 !! test
11753 msgnw keyword
11754 !! wikitext
11755 {{msgnw:MSGNW test}}
11756 !! html/php
11757 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11758 &#42; interpreted
11759 &#32;but rather passed unmodified
11760 &#123;&#123;test&#125;&#125;
11761 &#60;gallery&#62;
11762 File:Foobar.jpg
11763 &#60;/gallery&#62;
11764 &#60;!-- comment --&#62;
11765 </p>
11766 !! end
11767
11768 !! test
11769 int keyword
11770 !! wikitext
11771 {{int:youhavenewmessages|lots of money|not!}}
11772 !! html
11773 <p>You have lots of money (not!).
11774 </p>
11775 !! end
11776
11777 !! test
11778 int keyword - non-existing message
11779 !! wikitext
11780 {{int:var}}
11781 !! html
11782 <p>⧼var⧽
11783 </p>
11784 !! end
11785
11786 !! article
11787 Template:Includes
11788 !! text
11789 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11790 !! endarticle
11791
11792 !! test
11793 <includeonly> and <noinclude> being included
11794 !! wikitext
11795 {{Includes}}
11796 !! html
11797 <p>Foobar
11798 </p>
11799 !! end
11800
11801 !! article
11802 Template:Includes2
11803 !! text
11804 <onlyinclude>Foo</onlyinclude>bar
11805 !! endarticle
11806
11807 !! test
11808 <onlyinclude> being included
11809 !! wikitext
11810 {{Includes2}}
11811 !! html
11812 <p>Foo
11813 </p>
11814 !! end
11815
11816
11817 !! article
11818 Template:Includes3
11819 !! text
11820 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
11821 !! endarticle
11822
11823 !! test
11824 <onlyinclude> and <includeonly> being included
11825 !! wikitext
11826 {{Includes3}}
11827 !! html
11828 <p>Foo
11829 </p>
11830 !! end
11831
11832 !! test
11833 <includeonly> and <noinclude> on a page
11834 !! wikitext
11835 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11836 !! html
11837 <p>Foozar
11838 </p>
11839 !! end
11840
11841 !! test
11842 Un-closed <noinclude>
11843 !! wikitext
11844 <noinclude>
11845 !! html
11846 !! end
11847
11848 !! test
11849 <onlyinclude> on a page
11850 !! wikitext
11851 <onlyinclude>Foo</onlyinclude>bar
11852 !! html
11853 <p>Foobar
11854 </p>
11855 !! end
11856
11857 !! test
11858 Un-closed <onlyinclude>
11859 !! wikitext
11860 <onlyinclude>
11861 !! html
11862 !! end
11863
11864 !!test
11865 Self-closed noinclude, includeonly, onlyinclude tags
11866 !! wikitext
11867 <noinclude />
11868 <includeonly />
11869 <onlyinclude />
11870 !! html
11871 <p><br />
11872 </p>
11873 !!end
11874
11875 !!test
11876 Unbalanced includeonly and noinclude tags
11877 !! wikitext
11878 {|
11879 |a</noinclude>
11880 |b</noinclude></noinclude>
11881 |c</noinclude></includeonly>
11882 |d</includeonly></includeonly>
11883 |}
11884 !! html
11885 <table>
11886 <tr>
11887 <td>a
11888 </td>
11889 <td>b
11890 </td>
11891 <td>c&lt;/includeonly&gt;
11892 </td>
11893 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
11894 </td></tr></table>
11895
11896 !!end
11897
11898 !! article
11899 Template:Includeonly section
11900 !! text
11901 <includeonly>
11902 ==Includeonly section==
11903 </includeonly>
11904 ==Section T-1==
11905 !!endarticle
11906
11907 !! test
11908 T8563: Edit link generation for section shown by <includeonly>
11909 !! wikitext
11910 {{includeonly section}}
11911 !! html
11912 <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>
11913 <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>
11914
11915 !! end
11916
11917 # Uses same input as the contents of [[Template:Includeonly section]]
11918 !! test
11919 T8563: Section extraction for section shown by <includeonly>
11920 !! options
11921 section=T-2
11922 !! wikitext
11923 <includeonly>
11924 ==Includeonly section==
11925 </includeonly>
11926 ==Section T-2==
11927 !! html
11928 ==Section T-2==
11929 !! end
11930
11931 !! test
11932 T8563: Edit link generation for section suppressed by <includeonly>
11933 !! wikitext
11934 <includeonly>
11935 ==Includeonly section==
11936 </includeonly>
11937 ==Section 1==
11938 !! html
11939 <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>
11940
11941 !! end
11942
11943 !! test
11944 T8563: Section extraction for section suppressed by <includeonly>
11945 !! options
11946 section=1
11947 !! wikitext
11948 <includeonly>
11949 ==Includeonly section==
11950 </includeonly>
11951 ==Section 1==
11952 !! html
11953 ==Section 1==
11954 !! end
11955
11956 !! test
11957 Un-closed <includeonly>
11958 !! wikitext
11959 <includeonly>
11960 !! html/php
11961 !! html/parsoid
11962 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}'/>
11963 !! end
11964
11965 ## We used to, but no longer wt2wt this test since the default serializer
11966 ## will normalize the include directives to serialize on their own line.
11967 ## Selser will take care of preserving formatting in scenarios where they
11968 ## intermingled with other wikitext.
11969 !! test
11970 Includes and comments at SOL
11971 !! options
11972 parsoid=wt2html,html2html
11973 !! wikitext
11974 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->== hu ==
11975
11976 <noinclude>
11977 some
11978 </noinclude>* stuff
11979 * here
11980
11981 <includeonly>can have stuff</includeonly>=== here ===
11982
11983 !! html/php
11984 <h2><span class="mw-headline" id="hu">hu</span></h2>
11985 <p>some
11986 </p>
11987 <ul><li> stuff</li>
11988 <li> here</li></ul>
11989 <h3><span class="mw-headline" id="here">here</span></h3>
11990
11991 !! html/parsoid
11992 <!-- 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> hu </h2>
11993
11994 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
11995 <p>some</p>
11996 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li> stuff</li>
11997 <li> here</li></ul>
11998
11999 <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> here </h3>
12000
12001 !! end
12002
12003 # TODO: test with DOM fragment reuse!
12004 !! test
12005 Parsoid: DOM fragment reuse
12006 !! options
12007 parsoid=wt2wt,wt2html
12008 !! wikitext
12009 a{{echo|b<table></table>c}}d
12010
12011 a{{echo|b
12012 <table></table>
12013 c}}d
12014
12015 {{echo|a
12016
12017 <table></table>
12018
12019 b}}
12020 !! html
12021 <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>
12022
12023 <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">
12024 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
12025 </span><p about="#mwt2">cd</p>
12026
12027 <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">
12028
12029 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
12030
12031 </span><p about="#mwt3">b</p>
12032 !! end
12033
12034 !! test
12035 Parsoid: Merge double tds (T52603)
12036 !! options
12037 parsoid
12038 !! wikitext
12039 {|
12040 |{{echo|{{!}} foo}}
12041 |}
12042 !! html
12043 <table><tbody>
12044 <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>
12045 </tbody></table>
12046 !! end
12047
12048 !! test
12049 Parsoid: Merge double tds in nested transclusion content (T52603)
12050 !! options
12051 parsoid
12052 !! wikitext
12053 {{echo|<div>}}
12054 {|
12055 |{{echo|{{!}} foo}}
12056 |}
12057 {{echo|</div>}}
12058 !! html
12059 <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}}]}'>
12060 <table><tbody>
12061 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
12062 </tbody></table>
12063 </div>
12064 !! end
12065
12066 ###
12067 ### <includeonly> and <noinclude> in attributes
12068 ###
12069 !!test
12070 0. includeonly around the entire attribute
12071 !! wikitext
12072 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
12073 !! html
12074 <p><span id="v2">bar</span>
12075 </p>
12076 !!end
12077
12078 !!test
12079 1. includeonly in html attr key
12080 !! wikitext
12081 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
12082 !! html
12083 <p><span id="foo">bar</span>
12084 </p>
12085 !!end
12086
12087 !!test
12088 2. includeonly in html attr value
12089 !! wikitext
12090 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
12091 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
12092 !! html
12093 <p><span id="v1">bar</span>
12094 <span id="v1">bar</span>
12095 </p>
12096 !!end
12097
12098 !!test
12099 3. includeonly in part of an attr value
12100 !! wikitext
12101 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
12102 !! html
12103 <p><span style="color:red;">bar</span>
12104 </p>
12105 !!end
12106
12107 !!test
12108 4. includeonly in table attributes
12109 !! wikitext
12110 {|
12111 |- <noinclude>
12112 |-
12113 |a
12114 </noinclude>
12115 |- <includeonly>
12116 |-
12117 |b
12118 </includeonly>
12119 |}
12120 !! html
12121 <table>
12122
12123
12124 <tr>
12125 <td>a
12126 </td></tr>
12127 </table>
12128
12129 !!end
12130
12131 ###
12132 ### Preprocessor precedence tests
12133 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
12134 ###
12135 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
12136 !! test
12137 Preprocessor precedence 1: link is rightmost opening
12138 !! options
12139 parsoid=wt2html
12140 !! wikitext
12141 {{[[Foo|bar}}]]
12142
12143 But close-brace is not a valid character in a link title:
12144 {{[[Foo}}|bar]]
12145
12146 However, we can still tell this was handled as a link in the preprocessor:
12147 {{echo|[[Foo}}|bar]]|bat}}
12148 !! html/php
12149 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
12150 </p><p>But close-brace is not a valid character in a link title:
12151 {{[[Foo}}|bar]]
12152 </p><p>However, we can still tell this was handled as a link in the preprocessor:
12153 [[Foo}}|bar]]
12154 </p>
12155 !! html/parsoid
12156 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">bar}}</a></p>
12157 <p>But close-brace is not a valid character in a link title: {{[[Foo}}|bar]]</p>
12158 <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>
12159 !! end
12160
12161 !! test
12162 Preprocessor precedence 2: template is rightmost opening
12163 !! options
12164 language=zh
12165 !! wikitext
12166 -{{echo|foo}-}}-
12167 !! html/php
12168 <p>-foo}--
12169 </p>
12170 !! html/parsoid
12171 <p>-<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}-"}},"i":0}}]}'>foo}-</span>-</p>
12172 !! end
12173
12174 !! test
12175 Preprocessor precedence 3: language converter is rightmost opening
12176 !! options
12177 language=zh
12178 parsoid=wt2html
12179 !! wikitext
12180 {{echo|hi}}
12181
12182 {{-{R|echo|hi}}}-
12183
12184 [[-{R|raw]]}-
12185 !! html/php
12186 <p>hi
12187 </p><p>{{echo|hi}}
12188 </p><p>[[raw]]
12189 </p>
12190 !! html/parsoid
12191 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"hi"}},"i":0}}]}'>hi</p>
12192 <p>{{<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"echo|hi}}"}}'></span></p>
12193 <p>[[<span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw]]"}}'></span></p>
12194 !! end
12195
12196 !! test
12197 Preprocessor precedence 4: left-most angle bracket
12198 !! options
12199 language=zh
12200 !! wikitext
12201 <!--{raw}-->
12202 !! html/php
12203 !! html/parsoid
12204 <!--{raw}-->
12205 !! end
12206
12207 !! article
12208 Template:Precedence5
12209 !! text
12210 {{{{{1}}}}}
12211 !! endarticle
12212
12213 !! test
12214 Preprocessor precedence 5: tplarg takes precedence over template
12215 !! wikitext
12216 {{Precedence5|Bullet}}
12217 !! html/php
12218 <ul><li> Bar</li></ul>
12219
12220 !! html/parsoid
12221 <ul typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"Precedence5","href":"./Template:Precedence5"},"params":{"1":{"wt":"Bullet"}},"i":0}}]}'><li> Bar</li></ul>
12222 !! end
12223
12224 !! test
12225 Preprocessor precedence 6: broken link is rightmost opening
12226 !! options
12227 parsoid=wt2html
12228 !! wikitext
12229 {{echo|[[Foo}}
12230
12231 {{echo|[[Foo|bar|bat=baz}}
12232 !! html/php
12233 <p>{{echo|[[Foo}}
12234 </p><p>{{echo|[[Foo|bar|bat=baz}}
12235 </p>
12236 !! html/parsoid
12237 <p>{{echo|[[Foo}}</p>
12238 <p>{{echo|[[Foo|bar|bat=baz}}</p>
12239 !! end
12240
12241 # This next test exposes a difference between PHP and Parsoid:
12242 # Given [[Foo|{{echo|Bar]]x}}y]]z:
12243 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
12244 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
12245 # outer `[[Foo` extends until the `y]]`
12246 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
12247 # intermediate result (after template expansion), and link processing
12248 # happens on this intermediate result, which moves the wikilink
12249 # boundary leftward to `[[Foo|Bar]]`
12250 # 2b) Parsoid works in a single step, so it's going to keep the
12251 # wikilink as extending to the `y]]`
12252 # 3a) Then PHP does linktrail processing which slurps up the trailing
12253 # `xy` inside the link.
12254 # 3b) Parsoid will do linktrail processing to slurp up the trailing
12255 # `z` inside the link.
12256 # This is "correct" behavior. Parsoid's basic worldview is that the
12257 # `]]` inside the template shouldn't be allowed to leak out to affect
12258 # the surrounding wikilink. PHP may match Parsoid (in the future)
12259 # if you use {{#balance}} (T114445).
12260
12261 !! test
12262 Preprocessor precedence 7: broken template is rightmost opening
12263 !! options
12264 parsoid=wt2html
12265 !! wikitext
12266 [[Foo|{{echo|Bar]]
12267
12268 [[Foo|{{echo|Bar]]-x}}-y]]-z
12269
12270 Careful: linktrails can move the end of the wikilink:
12271 [[Foo|{{echo|y']]a}}l]]l
12272 !! html/php
12273 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
12274 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
12275 </p><p>Careful: linktrails can move the end of the wikilink:
12276 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
12277 </p>
12278 !! html/parsoid
12279 <p>[[Foo|{{echo|Bar]]</p>
12280 <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>
12281 <p>Careful: linktrails can move the end of the wikilink:
12282 <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>
12283 !! end
12284
12285 !! test
12286 Preprocessor precedence 8: broken language converter is rightmost opening
12287 !! options
12288 language=zh
12289 !! wikitext
12290 [[Foo-{R|raw]]
12291 !! html
12292 <p>[[Foo-{R|raw]]
12293 </p>
12294 !! end
12295
12296 !! article
12297 Template:Preprocessor_precedence_9
12298 !! text
12299 ;4: {{{{1}}}}
12300 ;5: {{{{{2}}}}}
12301 ;6: {{{{{{3}}}}}}
12302 ;7: {{{{{{{4}}}}}}}
12303 !! endarticle
12304
12305 !! test
12306 Preprocessor precedence 9: groups of braces
12307 !! wikitext
12308 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12309 !! html/php
12310 <dl><dt>4</dt>
12311 <dd> {Four}</dd>
12312 <dt>5</dt>
12313 <dd> </dd></dl>
12314 <ul><li> Bar</li></ul>
12315 <dl><dt>6</dt>
12316 <dd> Four</dd>
12317 <dt>7</dt>
12318 <dd> {Bullet}</dd></dl>
12319
12320 !! html/parsoid
12321 <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}}]}'>
12322 <dt>4</dt>
12323 <dd>{Four}</dd>
12324 <dt>5</dt>
12325 <dd></dd>
12326 </dl><ul about="#mwt1">
12327 <li>Bar</li>
12328 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12329 <dt>6</dt>
12330 <dd>Four</dd>
12331 <dt>7</dt>
12332 <dd>{Bullet}</dd>
12333 </dl>
12334 !! end
12335
12336 !! article
12337 Template:Preprocessor_precedence_10
12338 !! text
12339 ;1: -{R|raw}-
12340 ;2: -{{Bullet}}-
12341 ;3: -{{{1}}}-
12342 ;4: -{{{{2}}}}-
12343 ;5: -{{{{{3}}}}}-
12344 ;6: -{{{{{{4}}}}}}-
12345 ;7: -{{{{{{{5}}}}}}}-
12346 !! endarticle
12347
12348 !! test
12349 Preprocessor precedence 10: groups of braces with leading dash
12350 !! options
12351 language=zh
12352 !! wikitext
12353 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12354 !! html/php
12355 <dl><dt>1</dt>
12356 <dd> raw</dd>
12357 <dt>2</dt>
12358 <dd> -</dd></dl>
12359 <ul><li> Bar-</li></ul>
12360 <dl><dt>3</dt>
12361 <dd> -Three-</dd>
12362 <dt>4</dt>
12363 <dd> raw2</dd>
12364 <dt>5</dt>
12365 <dd> -</dd></dl>
12366 <ul><li> Bar-</li></ul>
12367 <dl><dt>6</dt>
12368 <dd> -Three-</dd>
12369 <dt>7</dt>
12370 <dd> raw2</dd></dl>
12371
12372 !! html/parsoid
12373 <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}}]}'>
12374 <dt>1</dt>
12375 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw"}}'></span></dd>
12376 <dt>2</dt>
12377 <dd>-</dd>
12378 </dl><ul about="#mwt1">
12379 <li>Bar-</li>
12380 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12381 <dt>3</dt>
12382 <dd>-Three-</dd>
12383 <dt>4</dt>
12384 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12385 <dt>5</dt>
12386 <dd>-</dd>
12387 </dl><ul about="#mwt1">
12388 <li>Bar-</li>
12389 </ul><span about="#mwt1"> </span><dl about="#mwt1">
12390 <dt>6</dt>
12391 <dd>-Three-</dd>
12392 <dt>7</dt>
12393 <dd><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"raw2"}}'></span></dd>
12394 </dl>
12395 !! end
12396
12397 !! test
12398 Preprocessor precedence 11: found during visual diff testing
12399 !! wikitext
12400 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12401
12402 {{echo|-{{echo|-{{echo|x}}}}}}
12403
12404 {{echo|-{{echo|x}}}}
12405 !! html/php
12406 <p><span>-<span>-x</span></span>
12407 </p><p>--x
12408 </p><p>-x
12409 </p>
12410 !! html/parsoid
12411 <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>
12412
12413 <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>
12414
12415 <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>
12416 !! end
12417
12418 !! test
12419 Preprocessor precedence 12: broken language converter closed by brace.
12420 !! options
12421 parsoid=wt2html
12422 !! wikitext
12423 This form breaks the template, which is unfortunate:
12424 * {{echo|foo-{bar}bat}}
12425
12426 But if the broken language converter markup is inside an extension
12427 tag, nothing bad happens:
12428 * <nowiki>foo-{bar}bat</nowiki>
12429 * {{echo|<nowiki>foo-{bar}bat</nowiki>}}
12430 * <pre>foo-{bar}bat</pre>
12431 * {{echo|<pre>foo-{bar}bat</pre>}}
12432
12433 <tag>foo-{bar}bat</tag>
12434 {{echo|<tag>foo-{bar}bat</tag>}}
12435
12436 !! html/php+tidy
12437 <p>This form breaks the template, which is unfortunate:</p>
12438 <ul>
12439 <li>{{echo|foo-{bar}bat}}</li>
12440 </ul>
12441 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12442 <ul>
12443 <li>foo-{bar}bat</li>
12444 <li>foo-{bar}bat</li>
12445 <li>
12446 <pre>
12447 foo-{bar}bat
12448 </pre></li>
12449 <li>
12450 <pre>
12451 foo-{bar}bat
12452 </pre></li>
12453 </ul>
12454 <pre>
12455 'foo-{bar}bat'
12456 array (
12457 )
12458 </pre>
12459 <pre>
12460 'foo-{bar}bat'
12461 array (
12462 )
12463 </pre>
12464 !! html/parsoid
12465 <p>This form breaks the template, which is unfortunate:</p>
12466 <ul>
12467 <li>{{echo|foo-{bar}bat}}</li>
12468 </ul>
12469 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12470 <ul>
12471 <li><span typeof="mw:Nowiki">foo-{bar}bat</span></li>
12472 <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>
12473 <li><pre typeof="mw:Extension/pre" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo-{bar}bat"}}'>foo-{bar}bat</pre></li>
12474 <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>
12475 </ul>
12476 <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>
12477 !! end
12478
12479 !! test
12480 Preprocessor precedence 13: broken language converter in external link
12481 !! options
12482 parsoid=wt2html
12483 !! wikitext
12484 * [http://example.com/-{foo Example in URL]
12485 * [http://example.com Example in -{link} description]
12486 * {{echo|[http://example.com/-{foo Breaks template, however]}}
12487 !! html/php+tidy
12488 <ul>
12489 <li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12490 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12491 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12492 </ul>
12493 !! html/parsoid
12494 <ul>
12495 <li><a rel="mw:ExtLink" href="http://example.com/-{foo">Example in URL</a></li>
12496 <li><a rel="mw:ExtLink" href="http://example.com">Example in -{link} description</a></li>
12497 <li>{{echo|<a rel="mw:ExtLink" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12498 </ul>
12499 !! end
12500
12501 !! test
12502 Preprocessor precedence 14: broken language converter in comment
12503 !! wikitext
12504 * <!--{{foo}}--> ...should be ok
12505 * <!---{{foo}}--> ...extra dashes
12506 * {{echo|foo<!-- -{bar} -->bat}} ...should be ok
12507 !! html/php+tidy
12508 <ul>
12509 <li>...should be ok</li>
12510 <li>...extra dashes</li>
12511 <li>foobat ...should be ok</li>
12512 </ul>
12513 !! html/parsoid
12514 <ul>
12515 <li><!--{{foo}}--> ...should be ok</li>
12516 <li><!--&#x2D;{{foo}}--> ...extra dashes</li>
12517 <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>
12518 </ul>
12519 !! end
12520
12521 !! test
12522 Preprocessor precedence 15: broken brace markup in headings
12523 !! options
12524 parsoid=wt2html
12525 !! wikitext
12526 __NOTOC__ __NOEDITSECTION__
12527 ===1 foo[bar 1===
12528 1
12529 ===2 foo[[bar 2===
12530 2
12531 ===3 foo{bar 3===
12532 3
12533 ===4 foo{{bar 4===
12534 4
12535 ===5 foo{{{bar 5===
12536 5
12537 ===6 foo-{bar 6===
12538 6
12539 !! html/php+tidy
12540 <h3><span class="mw-headline" id="1_foo.5Bbar_1">1 foo[bar 1</span></h3>
12541 <p>1</p>
12542 <h3><span class="mw-headline" id="2_foo.5B.5Bbar_2">2 foo[[bar 2</span></h3>
12543 <p>2</p>
12544 <h3><span class="mw-headline" id="3_foo.7Bbar_3">3 foo{bar 3</span></h3>
12545 <p>3</p>
12546 <h3><span class="mw-headline" id="4_foo.7B.7Bbar_4">4 foo{{bar 4</span></h3>
12547 <p>4</p>
12548 <h3><span class="mw-headline" id="5_foo.7B.7B.7Bbar_5">5 foo{{{bar 5</span></h3>
12549 <p>5</p>
12550 <h3><span class="mw-headline" id="6_foo-.7Bbar_6">6 foo-{bar 6</span></h3>
12551 <p>6</p>
12552 !! html/parsoid
12553 <meta property="mw:PageProp/notoc"/> <meta property="mw:PageProp/noeditsection"/
12554 >
12555 <h3>1 foo[bar 1</h3>
12556 <p>1</p>
12557 <h3>2 foo[[bar 2</h3>
12558 <p>2</p>
12559 <h3>3 foo{bar 3</h3>
12560 <p>3</p>
12561 <h3>4 foo{{bar 4</h3>
12562 <p>4</p>
12563 <h3>5 foo{{{bar 5</h3>
12564 <p>5</p>
12565 <h3>6 foo-{bar 6</h3>
12566 <p>6</p>
12567 !! end
12568
12569 !! test
12570 Preprocessor precedence 16: matching closing braces to opening braces
12571 !! options
12572 language=zh
12573 parsoid=wt2html
12574 !! wikitext
12575 -{{{echo|foo}}bar}-
12576 !! html/php
12577 <p>foobar
12578 </p>
12579 !! html/parsoid
12580 <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>
12581 !! end
12582
12583 ###
12584 ### Token Stream Patcher tests
12585 ###
12586 ### These tests won't always pass wt2wt and other modes because
12587 ### on serialization, the table will be output on a new line.
12588 ### For now, we are blacklisting them, and using this to test selser.
12589 ###
12590
12591 !!test
12592 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12593 !!options
12594 parsoid=wt2html,wt2wt
12595 !!wikitext
12596 {{echo|}}{| width = '100%'
12597 |foo
12598 |}
12599 !!html/parsoid
12600 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12601 <tbody><tr><td>foo</td></tr>
12602 </tbody></table>
12603 !!end
12604
12605 ## We used to, but no longer wt2wt this test since the default serializer
12606 ## will normalize the include directives to serialize on their own line.
12607 ## Selser will take care of preserving formatting in scenarios where they
12608 ## intermingled with other wikitext.
12609 !!test
12610 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12611 !!options
12612 parsoid=wt2html
12613 !!wikitext
12614 <includeonly>a</includeonly>{| {{{b}}}
12615 |c
12616 |}
12617 !!html/parsoid
12618 <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":""}]]}'>
12619 <tbody><tr><td>c</td></tr>
12620 </tbody></table>
12621 !!end
12622
12623 !! test
12624 Table wikitext syntax outside wiki-tables
12625 !! wikitext
12626 a
12627 |+ not a caption
12628 ! not a table heading
12629 |- not a table row
12630 | not a table cell
12631 | class="foo bar" | baz
12632 b
12633 |}
12634 |-
12635 c
12636 !! html
12637 <p>a
12638 |+ not a caption
12639 ! not a table heading
12640 |- not a table row
12641 | not a table cell
12642 | class="foo bar" | baz
12643 b
12644 |}
12645 |-
12646 c
12647 </p>
12648 !! end
12649
12650 ###
12651 ### Testing parsing of templates where a template arg
12652 ### has the same name as the template itself.
12653 ###
12654
12655 !! article
12656 Template:quote
12657 !! text
12658 {{{quote|{{{1}}}}}}
12659 !! endarticle
12660
12661 !!test
12662 Templates: Template Name/Arg clash: 1. Use of positional param
12663 !! wikitext
12664 {{quote|foo}}
12665 !! html
12666 <p>foo
12667 </p>
12668 !!end
12669
12670 !!test
12671 Templates: Template Name/Arg clash: 2. Use of named param
12672 !! wikitext
12673 {{quote|quote=foo}}
12674 !! html
12675 <p>foo
12676 </p>
12677 !!end
12678
12679 !!test
12680 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12681 !! wikitext
12682 {{quote|quote}}
12683 !! html
12684 <p>quote
12685 </p>
12686 !!end
12687
12688 ###
12689 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12690 ###
12691
12692 !!test
12693 Templates: 1. Simple use
12694 !! wikitext
12695 {{echo|Foo}}
12696 !! html
12697 <p>Foo
12698 </p>
12699 !!end
12700
12701 !!test
12702 Templates: 2. Inside a block tag
12703 !! wikitext
12704 <div>{{echo|Foo}}</div>
12705 <blockquote>{{echo|Foo}}</blockquote>
12706 !! html
12707 <div>Foo</div>
12708 <blockquote>Foo</blockquote>
12709
12710 !! html+tidy
12711 <div>Foo</div>
12712 <blockquote>
12713 <p>Foo</p>
12714 </blockquote>
12715 !!end
12716
12717 !!test
12718 Templates: P-wrapping: 1a. Templates on consecutive lines
12719 !! wikitext
12720 {{echo|Foo}}
12721 {{echo|bar}}
12722 !! html
12723 <p>Foo
12724 bar
12725 </p>
12726 !!end
12727
12728 !!test
12729 Templates: P-wrapping: 1b. Templates on consecutive lines
12730 !! wikitext
12731 Foo
12732
12733 {{echo|bar}}
12734 {{echo|baz}}
12735 !! html
12736 <p>Foo
12737 </p><p>bar
12738 baz
12739 </p>
12740 !!end
12741
12742 !!test
12743 Templates: P-wrapping: 1c. Templates on consecutive lines
12744 !! wikitext
12745 {{echo|Foo}}
12746 {{echo|bar}} <div>baz</div>
12747 !! html
12748 <p>Foo
12749 </p>
12750 bar <div>baz</div>
12751
12752 !! html+tidy
12753 <p>Foo</p>
12754 <p>bar</p>
12755 <div>baz</div>
12756 !! end
12757
12758 !!test
12759 Templates: P-wrapping: 1d. Template preceded by comment-only line
12760 !!options
12761 parsoid
12762 !! wikitext
12763 <!-- foo -->
12764 {{echo|Bar}}
12765 !! html
12766 <!-- foo -->
12767
12768 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
12769 !!end
12770
12771 !!test
12772 Templates: Inline Text: 1. Multiple template uses
12773 !! wikitext
12774 {{echo|Foo}}bar{{echo|baz}}
12775 !! html
12776 <p>Foobarbaz
12777 </p>
12778 !!end
12779
12780 !!test
12781 Templates: Inline Text: 2. Back-to-back template uses
12782 !! wikitext
12783 {{echo|Foo}}{{echo|bar}}
12784 !! html
12785 <p>Foobar
12786 </p>
12787 !!end
12788
12789 !!test
12790 Templates: Block Tags: 1. Multiple template uses
12791 !! wikitext
12792 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
12793 !! html
12794 <div>Foo</div><div>bar</div><div>baz</div>
12795
12796 !!end
12797
12798 !!test
12799 Templates: Block Tags: 2. Back-to-back template uses
12800 !! wikitext
12801 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
12802 !! html
12803 <div>Foo</div><div>bar</div>
12804
12805 !!end
12806
12807 # This is an edge case relating to paragraph wrapping.
12808 !!test
12809 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
12810 !! wikitext
12811 {{echo|a
12812 b</p>}}
12813 !! html/parsoid
12814 <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
12815 b</p>
12816 !!end
12817
12818 !!test
12819 Templates: Links: 1. Simple example
12820 !! wikitext
12821 {{echo|[[Foo|bar]]}}
12822 !! html
12823 <p><a href="/wiki/Foo" title="Foo">bar</a>
12824 </p>
12825 !!end
12826
12827 !!test
12828 Templates: Links: 2. Generation of link href
12829 !! wikitext
12830 [[{{echo|Foo}}|bar]]
12831 !! html
12832 <p><a href="/wiki/Foo" title="Foo">bar</a>
12833 </p>
12834 !!end
12835
12836 !!test
12837 Templates: Links: 3. Generation of part of a link href
12838 !! wikitext
12839 [[Fo{{echo|o}}|bar]]
12840
12841 [[Foo{{echo|bar}}]]
12842
12843 [[Foo{{echo|bar}}baz]]
12844
12845 [[Foo{{echo|bar}}|bar]]
12846
12847 [[:Foo{{echo|bar}}]]
12848
12849 [[:Foo{{echo|bar}}|bar]]
12850 !! html
12851 <p><a href="/wiki/Foo" title="Foo">bar</a>
12852 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12853 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
12854 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12855 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12856 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12857 </p>
12858 !!end
12859
12860 !!test
12861 Templates: Links: 4. Multiple templates generating link href
12862 !! wikitext
12863 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
12864 !! html
12865 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12866 </p>
12867 !!end
12868
12869 !!test
12870 Templates: Links: 5. Generation of link text
12871 !! wikitext
12872 [[Foo|{{echo|bar}}]]
12873 !! html
12874 <p><a href="/wiki/Foo" title="Foo">bar</a>
12875 </p>
12876 !!end
12877
12878 !!test
12879 Templates: Links: 5. Nested templates (only outermost template should be marked)
12880 !! wikitext
12881 {{echo|[[{{echo|Foo}}|bar]]}}
12882 !! html
12883 <p><a href="/wiki/Foo" title="Foo">bar</a>
12884 </p>
12885 !!end
12886
12887 !!test
12888 Templates: HTML Tag: 1. Generation of HTML attr. key
12889 !! wikitext
12890 <div {{echo|style}}="color:red;">foo</div>
12891 !! html
12892 <div style="color:red;">foo</div>
12893
12894 !!end
12895
12896 !!test
12897 Templates: HTML Tag: 2. Generation of HTML attr. value
12898 !! wikitext
12899 <div style={{echo|'color:red;'}}>foo</div>
12900 !! html
12901 <div style="color:red;">foo</div>
12902
12903 !!end
12904
12905 !!test
12906 Templates: HTML Tag: 3. Generation of HTML attr key and value
12907 !! wikitext
12908 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
12909 !! html
12910 <div style="color:red;">foo</div>
12911
12912 !!end
12913
12914 !!test
12915 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
12916 !! wikitext
12917 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
12918 !! html
12919 <div title="This is a long title with just one piece templated">foo</div>
12920
12921 !!end
12922
12923 !!test
12924 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
12925 !! wikitext
12926 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
12927 !! html
12928 <div title="This is a long title with just one piece templated">foo</div>
12929
12930 !!end
12931
12932 !!test
12933 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
12934 !! wikitext
12935 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
12936 !! html
12937 <div title="This is a long title with just one piece templated">foo</div>
12938
12939 !!end
12940
12941 # SSS FIXME: While it is great we added support for all this,
12942 # do we want to make this part of the spec? Maybe we want to
12943 # deprecate this kind of usage in the future?
12944 !!test
12945 Templates: HTML Tag: 7. Generation of partial attribute key string
12946 !! wikitext
12947 <div st{{echo|yle}}="color:red;">foo</div>
12948 !! html
12949 <div style="color:red;">foo</div>
12950
12951 !!end
12952
12953 !! test
12954 Templates: HTML Tag: 8. Template-generated attribute (k=v)
12955 !! wikitext
12956 <div {{echo|1=id="v1"}}>bar</div>
12957 !! html
12958 <div id="v1">bar</div>
12959
12960 !!end
12961
12962 !! test
12963 Templates: HTML Tag: 9. Multiple template-generated attributes
12964 !! wikitext
12965 <div {{echo|1=id="v1" title="foo"}}>bar</div>
12966 !! html
12967 <div id="v1" title="foo">bar</div>
12968
12969 !!end
12970
12971 !! test
12972 Templates: Support for templates generating attributes and content
12973 !! wikitext
12974 {| {{mixed_attr_content_template}}
12975 |-
12976 |bar
12977 |}
12978 !! html/php
12979 <table style="color:red;" title="T48811">
12980
12981 <tr>
12982 <td>foo
12983 </td></tr>
12984 <tr>
12985 <td>bar
12986 </td></tr></table>
12987
12988 !! html/parsoid
12989 <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|}"]}'>
12990 <tbody><tr>
12991 <td>foo</td></tr>
12992 <tr>
12993 <td>bar</td></tr>
12994 </tbody></table>
12995 !!end
12996
12997 !! test
12998 1. Entities and nowikis inside templated attributes should be handled correctly
12999 !! wikitext
13000 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
13001 !! html/php
13002 <div style="background:#f9f9f9;">foo</div>
13003
13004 !! html/parsoid
13005 <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>
13006 !! end
13007
13008 !! test
13009 2. Entities and nowikis inside templated attributes should be handled correctly
13010 !! wikitext
13011 {|
13012 |{{table_attribs_3}}
13013 |}
13014 !! html/php
13015 <table>
13016 <tr>
13017 <td style="background:#f9f9f9;">Foo
13018 </td></tr></table>
13019
13020 !! html/parsoid
13021 <table>
13022 <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>
13023 </tbody></table>
13024 !! end
13025
13026 !! test
13027 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13028 !! wikitext
13029 {{tbl-start}}
13030 |{{table_attribs_3}}
13031 {{tbl-end}}
13032 !! html/php
13033 <table>
13034 <tr>
13035 <td style="background:#f9f9f9;">Foo
13036 </td></tr></table>
13037
13038 !! html/parsoid
13039 <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}}]}'>
13040 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
13041 </tbody></table>
13042 !! end
13043
13044 # T107622
13045 !! test
13046 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
13047 !! wikitext
13048 {|
13049 | {{table_attribs_6}} hi
13050 |}
13051 !! html/php
13052 <table>
13053 <tr>
13054 <td style="background: red;"> hi
13055 </td></tr></table>
13056
13057 !! html/parsoid
13058 <table>
13059 <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>
13060 </tbody></table>
13061 !! end
13062
13063 !!test
13064 Templates: HTML Tables: 1. Generating start of a HTML table
13065 !! wikitext
13066 {{echo|<table><tr><td>foo</td>}}</tr></table>
13067 !! html
13068 <table><tr><td>foo</td></tr></table>
13069
13070 !!end
13071
13072 !!test
13073 Templates: HTML Tables: 2a. Generating middle of a HTML table
13074 !! wikitext
13075 <table><tr>{{echo|<td>foo</td>}}</tr></table>
13076 !! html
13077 <table><tr><td>foo</td></tr></table>
13078
13079 !!end
13080
13081 !!test
13082 Templates: HTML Tables: 2b. Generating middle of a HTML table
13083 !! wikitext
13084 <table>{{echo|<tr><td>foo</td></tr>}}</table>
13085 !! html
13086 <table><tr><td>foo</td></tr></table>
13087
13088 !!end
13089
13090 !!test
13091 Templates: HTML Tables: 3. Generating end of a HTML table
13092 !! wikitext
13093 <table><tr>{{echo|<td>foo</td></tr></table>}}
13094 !! html
13095 <table><tr><td>foo</td></tr></table>
13096
13097 !!end
13098
13099 !!test
13100 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
13101 !! wikitext
13102 {{echo|<table>}}<tr><td>foo</td></tr></table>
13103 !! html
13104 <table><tr><td>foo</td></tr></table>
13105
13106 !!end
13107
13108 !!test
13109 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
13110 !! wikitext
13111 <table>{{echo|<tr>}}<td>foo</td></tr></table>
13112 !! html
13113 <table><tr><td>foo</td></tr></table>
13114
13115 !!end
13116
13117 !!test
13118 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
13119 !! wikitext
13120 <table><tr>{{echo|<td>}}foo</td></tr></table>
13121 !! html
13122 <table><tr><td>foo</td></tr></table>
13123
13124 !!end
13125
13126 !!test
13127 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
13128 !! wikitext
13129 <table><tr><td>foo{{echo|</td>}}</tr></table>
13130 !! html
13131 <table><tr><td>foo</td></tr></table>
13132
13133 !!end
13134
13135 !!test
13136 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
13137 !! wikitext
13138 <table><tr><td>foo</td>{{echo|</tr>}}</table>
13139 !! html
13140 <table><tr><td>foo</td></tr></table>
13141
13142 !!end
13143
13144 !!test
13145 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
13146 !! wikitext
13147 <table><tr><td>foo</td></tr>{{echo|</table>}}
13148 !! html
13149 <table><tr><td>foo</td></tr></table>
13150
13151 !!end
13152
13153 !!test
13154 Templates: HTML Tables: 5. Proper fostering of categories from inside
13155 !!options
13156 parsoid=wt2html,wt2wt
13157 !! wikitext
13158 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
13159 <!--Two categories (T52330)-->
13160 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
13161 !! html
13162 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
13163 <!--Two categories (T52330)-->
13164 <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>
13165 !!end
13166
13167 !!test
13168 Templates: Wiki Tables: 1a. Fostering of entire template content
13169 !! wikitext
13170 {|
13171 {{echo|a}}
13172 |}
13173 !! html
13174 <table>
13175 a
13176 <tr><td></td></tr></table>
13177
13178 !! html+tidy
13179 <p>a</p>
13180 <table>
13181 <tr>
13182 <td></td>
13183 </tr>
13184 </table>
13185 !! end
13186
13187 !!test
13188 Templates: Wiki Tables: 1b. Fostering of entire template content
13189 !! wikitext
13190 {|
13191 {{echo|<div>}}
13192 foo
13193 {{echo|</div>}}
13194 |}
13195 !! html
13196 <table>
13197 <div>
13198 <p>foo
13199 </p>
13200 </div>
13201 <tr><td></td></tr></table>
13202
13203 !! html+tidy
13204 <div>
13205 <p>foo</p>
13206 </div>
13207 <table>
13208 <tr>
13209 <td></td>
13210 </tr>
13211 </table>
13212 !! end
13213
13214 !!test
13215 Templates: Wiki Tables: 2. Fostering of partial template content
13216 !! wikitext
13217 {|
13218 {{echo|a
13219 <div>b</div>}}
13220 |}
13221 !! html
13222 <table>
13223 a
13224 <div>b</div>
13225 <tr><td></td></tr></table>
13226
13227 !! html+tidy
13228 <p>a</p>
13229 <div>b</div>
13230 <table>
13231 <tr>
13232 <td></td>
13233 </tr>
13234 </table>
13235 !! end
13236
13237 !!test
13238 Templates: Wiki Tables: 3. td-content via multiple templates
13239 !! wikitext
13240 {|
13241 {{echo|{{pipe}}a}}{{echo|b}}
13242 |}
13243 !! html
13244 <table>
13245 <tr>
13246 <td>ab
13247 </td></tr></table>
13248
13249 !!end
13250
13251 !!test
13252 Templates: Wiki Tables: 4. Templated tags, no content
13253 !! wikitext
13254 {{tbl-start}}
13255 {{tbl-end}}
13256 !! html
13257 <table>
13258 <tr><td></td></tr></table>
13259
13260 !!end
13261
13262 !!test
13263 Templates: Wiki Tables: 5. Templated tags, regular td-tags
13264 !! wikitext
13265 {{tbl-start}}
13266 |foo
13267 {{tbl-end}}
13268 !! html
13269 <table>
13270 <tr>
13271 <td>foo
13272 </td></tr></table>
13273
13274 !!end
13275
13276 !!test
13277 Templates: Wiki Tables: 6. Templated tags, templated td-tags
13278 !! wikitext
13279 {{tbl-start}}
13280 {{!}}foo
13281 {{tbl-end}}
13282 !! html
13283 <table>
13284 <tr>
13285 <td>foo
13286 </td></tr></table>
13287
13288 !!end
13289
13290 ## This test case is very specific to Parsoid's internals
13291 ## and is hence only tested for Parsoid's code. Parsoid uses
13292 ## a <meta> marker tag for <ref> tags and they are expanded
13293 ## much later. We are verifying that this <meta> tag usage
13294 ## doesn't prevent foster parenting.
13295 !!test
13296 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
13297 !!wikitext
13298 {{PartialTable}}<ref>foo</ref>
13299 |}
13300
13301 <references />
13302 !!html/parsoid
13303 <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">
13304 <tbody>
13305 </tbody></table>
13306
13307 <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>
13308 !!end
13309
13310 !! test
13311 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
13312 !! wikitext
13313 {{echo|
13314 {{{!}}
13315 {{!}}-}}
13316 <onlyinclude>
13317 |foo
13318 </onlyinclude>
13319 {{!}}}
13320 !! html/parsoid
13321 <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{{!}}}"]}'>
13322 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
13323 <tbody><tr>
13324
13325 <td>foo
13326 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
13327 </tbody></table>
13328 !! end
13329
13330 !!test
13331 Templates: Lists: Multi-line list-items via templates
13332 !! wikitext
13333 *{{echo|a {{nonexistent|
13334 unused}}}}
13335 *{{echo|b {{nonexistent|
13336 unused}}}}
13337 !! html
13338 <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>
13339 <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>
13340
13341 !!end
13342
13343 !!test
13344 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
13345 !! wikitext
13346 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
13347 !! html
13348 <p><i>ab</i>c<i>d</i>e
13349 </p>
13350 !!end
13351
13352 !!test
13353 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
13354 (PHP parser generates misnested html)
13355 !! wikitext
13356 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
13357 !! html/parsoid
13358 <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>
13359 !!end
13360
13361 !!test
13362 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
13363 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
13364 !! options
13365 parsoid=wt2html,wt2wt
13366 !! wikitext
13367 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
13368 !! html
13369 <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>
13370 <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>
13371 <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>
13372 !!end
13373
13374 !!test
13375 Templates: Ugly nesting: 4. Divs opened/closed across templates
13376 !! wikitext
13377 a<div>b{{echo|c</div>d}}e
13378 !! html
13379 a<div>bc</div>de
13380
13381 !! html+tidy
13382 <p>a</p>
13383 <div>bc</div>
13384 <p>de</p>
13385 !! end
13386
13387 !!test
13388 Templates: Ugly templates: 1. Navbox template parses badly leading to table misnesting
13389 (Parsoid-centric)
13390 !! options
13391 parsoid
13392 !! wikitext
13393 {|
13394 |{{echo|foo</table>}}
13395 |bar
13396 |}
13397 !! html
13398 <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|}"]}'>
13399
13400 <tbody>
13401 <tr>
13402 <td>foo</td></tr></tbody></table><span about="#mwt1">
13403 </span><span about="#mwt1">|bar</span><span about="#mwt1">
13404 |}</span>
13405 !!end
13406
13407 !!test
13408 Templates: Ugly templates: 2. Navbox template parses badly leading to table misnesting
13409 (Parsoid-centric)
13410 !! options
13411 parsoid
13412 !! wikitext
13413 <table>
13414 <tr>
13415 <td>
13416 <table>
13417 <tr>
13418 <td>1. {{echo|foo </table>}}</td>
13419 <td> bar </td>
13420 <td>2. {{echo|baz </table>}}</td>
13421 </tr>
13422 <tr>
13423 <td>abc</td>
13424 </tr>
13425 </table>
13426 </td>
13427 </tr>
13428 <tr>
13429 <td>xyz</td>
13430 </tr>
13431 </table>
13432 !! html
13433 <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>"]}'>
13434 <tbody><tr>
13435 <td>
13436 <table>
13437 <tbody><tr>
13438 <td>1. foo </td></tr></tbody></table></td>
13439 <td> bar </td>
13440 <td>2. baz </td></tr></tbody></table><span about="#mwt2">
13441 </span><span about="#mwt2">
13442 </span><span about="#mwt2">
13443 </span><span about="#mwt2">abc</span><span about="#mwt2">
13444 </span><span about="#mwt2">
13445 </span><span about="#mwt2">
13446 </span><span about="#mwt2">
13447 </span><span about="#mwt2">
13448 </span><span about="#mwt2">
13449 </span><span about="#mwt2">xyz</span><span about="#mwt2">
13450 </span><span about="#mwt2">
13451 </span>
13452 !!end
13453
13454 !! test
13455 Templates: Ugly templates: 3. newline-only template parameter
13456 !! wikitext
13457 foo {{echo|
13458 }}
13459 !! html
13460 <p>foo
13461 </p>
13462 !! end
13463
13464 # This looks like a bug: a single newline triggers p/br for some reason.
13465 !! test
13466 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13467 !! wikitext
13468 {{echo|
13469 }}
13470 !! html
13471 <p><br />
13472 </p>
13473 !! end
13474
13475 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13476 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13477 !! test
13478 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13479 !! wikitext
13480 {{echo|<table>}}
13481 {{echo|<div>foo}}
13482 {{echo|</table>}}
13483 !! html/parsoid
13484 <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
13485 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13486 </table>
13487 !! end
13488
13489 # T66017 -- ugly wikitext with fostered content generates two template ranges
13490 # that are "identical" and generate nesting cycles in the algorithm
13491 !! test
13492 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13493 !! wikitext
13494 {{echo|<table><tr><td><table>}}
13495 {{echo|<div>}}
13496 {{echo|</div>}}
13497 !! html/parsoid
13498 <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"}'>
13499 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13500 </table></td></tr></tbody></table>
13501 !! end
13502
13503 !! test
13504 Templates: Parameters substituted at the top-level
13505 !! wikitext
13506 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13507
13508 {{{foo|bar|baz}}}
13509 !! html/php
13510 <p><i>who</i> me? <b>never!</b>
13511 </p><p>bar
13512 </p>
13513 !! html/parsoid
13514 <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>
13515
13516 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13517 !! end
13518
13519 !! test
13520 Templates: Param with empty arg in the final position
13521 !! wikitext
13522 {{{hi|}}}
13523 !! html/parsoid
13524 <span about="#mwt1" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"hi"},"params":{"1":{"wt":""}},"i":0}}]}'></span>
13525 !! end
13526
13527 !!test
13528 Parser Functions: 1. Simple example
13529 !! wikitext
13530 {{uc:foo}}
13531 !! html
13532 <p>FOO
13533 </p>
13534 !!end
13535
13536 !!test
13537 Parser Functions: 2. Nested use (only outermost should be marked up)
13538 !! wikitext
13539 {{uc:{{lc:FOO}}}}
13540 !! html
13541 <p>FOO
13542 </p>
13543 !!end
13544
13545 ###
13546 ### Pre-save transform tests
13547 ###
13548 !! test
13549 pre-save transform: subst:
13550 !! options
13551 pst
13552 !! wikitext
13553 {{subst:test}}
13554 !! html/php
13555 This is a test template
13556 !! end
13557
13558 !! test
13559 pre-save transform: normal template
13560 !! options
13561 pst
13562 !! wikitext
13563 {{test}}
13564 !! html/php
13565 {{test}}
13566 !! end
13567
13568 !! test
13569 pre-save transform: nonexistent template
13570 !! options
13571 pst
13572 !! wikitext
13573 {{thistemplatedoesnotexist}}
13574 !! html/php
13575 {{thistemplatedoesnotexist}}
13576 !! end
13577
13578 !! test
13579 pre-save transform: subst magic variables
13580 !! options
13581 pst
13582 !! wikitext
13583 {{subst:SITENAME}}
13584 !! html/php
13585 MediaWiki
13586 !! end
13587
13588 # This is T2089, which I fixed. -- wtm
13589 !! test
13590 pre-save transform: subst: templates with parameters
13591 !! options
13592 pst
13593 !! wikitext
13594 {{subst:paramtest|param="something else"}}
13595 !! html/php
13596 This is a test template with parameter "something else"
13597 !! end
13598
13599 !! article
13600 Template:nowikitest
13601 !! text
13602 <nowiki>'''not wiki'''</nowiki>
13603 !! endarticle
13604
13605 !! test
13606 pre-save transform: nowiki in subst (T3188)
13607 !! options
13608 pst
13609 !! wikitext
13610 {{subst:nowikitest}}
13611 !! html/php
13612 <nowiki>'''not wiki'''</nowiki>
13613 !! end
13614
13615 !! article
13616 Template:commenttest
13617 !! text
13618 This template has <!-- a comment --> in it.
13619 !! endarticle
13620
13621 !! test
13622 pre-save transform: comment in subst (T3936)
13623 !! options
13624 pst
13625 !! wikitext
13626 {{subst:commenttest}}
13627 !! html/php
13628 This template has <!-- a comment --> in it.
13629 !! end
13630
13631 !! test
13632 pre-save transform: unclosed tag
13633 !! options
13634 pst
13635 !! wikitext
13636 <nowiki>'''not wiki'''
13637 !! html/php
13638 <nowiki>'''not wiki'''
13639 !! end
13640
13641 !! test
13642 pre-save transform: mixed tag case
13643 !! options
13644 pst
13645 !! wikitext
13646 <NOwiki>'''not wiki'''</noWIKI>
13647 !! html/php
13648 <NOwiki>'''not wiki'''</noWIKI>
13649 !! end
13650
13651 !! test
13652 pre-save transform: unclosed comment in <nowiki>
13653 !! options
13654 pst
13655 !! wikitext
13656 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13657 !! html/php
13658 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13659 !!end
13660
13661 # Leading @ in this template definition works around a limitation
13662 # in parsoid's parserTests which otherwise strips the <span> from the
13663 # result (confusing it for a template wrapper)
13664 !! article
13665 Template:dangerous
13666 !!text
13667 @<span onmouseover="alert('crap')">Oh no</span>
13668 !!endarticle
13669
13670 !!test
13671 (confirming safety of fix for subst T3936)
13672 !! wikitext
13673 {{Template:dangerous}}
13674 !! html
13675 <p>@<span>Oh no</span>
13676 </p>
13677 !! end
13678
13679 !! test
13680 pre-save transform: comment containing gallery (T7024)
13681 !! options
13682 pst
13683 !! wikitext
13684 <!-- <gallery>data</gallery> -->
13685 !! html/php
13686 <!-- <gallery>data</gallery> -->
13687 !!end
13688
13689 !! test
13690 pre-save transform: comment containing extension
13691 !! options
13692 pst
13693 !! wikitext
13694 <!-- <tag>data</tag> -->
13695 !! html/php
13696 <!-- <tag>data</tag> -->
13697 !!end
13698
13699 !! test
13700 pre-save transform: comment containing nowiki
13701 !! options
13702 pst
13703 !! wikitext
13704 <!-- <nowiki>data</nowiki> -->
13705 !! html/php
13706 <!-- <nowiki>data</nowiki> -->
13707 !!end
13708
13709 !! test
13710 pre-save transform: <noinclude> in subst (T5298)
13711 !! options
13712 pst
13713 !! wikitext
13714 {{subst:Includes}}
13715 !! html/php
13716 Foobar
13717 !! end
13718
13719 !! test
13720 pre-save transform: <onlyinclude> in subst (T5298)
13721 !! options
13722 pst
13723 !! wikitext
13724 {{subst:Includes2}}
13725 !! html/php
13726 Foo
13727 !! end
13728
13729 !! article
13730 Template:SubstTest
13731 !!text
13732 {{<includeonly>subst:</includeonly>Includes}}
13733 !! endarticle
13734
13735 !! article
13736 Template:SafeSubstTest
13737 !! text
13738 {{<includeonly>safesubst:</includeonly>Includes}}
13739 !! endarticle
13740
13741 !! test
13742 T24297: safesubst: works during PST
13743 !! options
13744 pst
13745 !! wikitext
13746 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
13747 !! html/php
13748 FoobarFoobar
13749 !! end
13750
13751 !! test
13752 T24297: safesubst: works during normal parse
13753 !! wikitext
13754 {{SafeSubstTest}}
13755 !! html
13756 <p>Foobar
13757 </p>
13758 !! end
13759
13760 !! test
13761 subst: does not work during normal parse
13762 !! wikitext
13763 {{SubstTest}}
13764 !! html
13765 <p>{{subst:Includes}}
13766 </p>
13767 !! end
13768
13769 !! test
13770 pre-save transform: context links ("pipe trick")
13771 !! options
13772 pst
13773 !! wikitext
13774 [[Article (context)|]]
13775 [[Bar:Article|]]
13776 [[:Bar:Article|]]
13777 [[Bar:Article (context)|]]
13778 [[:Bar:Article (context)|]]
13779 [[|Article]]
13780 [[|Article (context)]]
13781 [[Bar:X (Y) Z|]]
13782 [[:Bar:X (Y) Z|]]
13783 !! html/php
13784 [[Article (context)|Article]]
13785 [[Bar:Article|Article]]
13786 [[:Bar:Article|Article]]
13787 [[Bar:Article (context)|Article]]
13788 [[:Bar:Article (context)|Article]]
13789 [[Article]]
13790 [[Article (context)]]
13791 [[Bar:X (Y) Z|X (Y) Z]]
13792 [[:Bar:X (Y) Z|X (Y) Z]]
13793 !! end
13794
13795 !! test
13796 pre-save transform: context links ("pipe trick") with interwiki prefix
13797 !! options
13798 pst
13799 !! wikitext
13800 [[interwiki:Article|]]
13801 [[:interwiki:Article|]]
13802 [[interwiki:Bar:Article|]]
13803 [[:interwiki:Bar:Article|]]
13804 !! html/php
13805 [[interwiki:Article|Article]]
13806 [[:interwiki:Article|Article]]
13807 [[interwiki:Bar:Article|Bar:Article]]
13808 [[:interwiki:Bar:Article|Bar:Article]]
13809 !! end
13810
13811 !! test
13812 pre-save transform: context links ("pipe trick") with parens in title
13813 !! options
13814 pst title=[[Somearticle (context)]]
13815 !! wikitext
13816 [[|Article]]
13817 !! html/php
13818 [[Article (context)|Article]]
13819 !! end
13820
13821 !! test
13822 pre-save transform: context links ("pipe trick") with comma in title
13823 !! options
13824 pst title=[[Someplace, Somewhere]]
13825 !! wikitext
13826 [[|Otherplace]]
13827 [[Otherplace, Elsewhere|]]
13828 [[Otherplace, Elsewhere, Anywhere|]]
13829 !! html/php
13830 [[Otherplace, Somewhere|Otherplace]]
13831 [[Otherplace, Elsewhere|Otherplace]]
13832 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
13833 !! end
13834
13835 !! test
13836 pre-save transform: context links ("pipe trick") with parens and comma
13837 !! options
13838 pst title=[[Someplace (IGNORED), Somewhere]]
13839 !! wikitext
13840 [[|Otherplace]]
13841 [[Otherplace (place), Elsewhere|]]
13842 !! html/php
13843 [[Otherplace, Somewhere|Otherplace]]
13844 [[Otherplace (place), Elsewhere|Otherplace]]
13845 !! end
13846
13847 !! test
13848 pre-save transform: context links ("pipe trick") with comma and parens
13849 !! options
13850 pst title=[[Who, me? (context)]]
13851 !! wikitext
13852 [[|Yes, you.]]
13853 [[Me, Myself, and I (1937 song)|]]
13854 !! html/php
13855 [[Yes, you. (context)|Yes, you.]]
13856 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
13857 !! end
13858
13859 !! test
13860 pre-save transform: context links ("pipe trick") with namespace
13861 !! options
13862 pst title=[[Ns:Somearticle]]
13863 !! wikitext
13864 [[|Article]]
13865 !! html/php
13866 [[Ns:Article|Article]]
13867 !! end
13868
13869 !! test
13870 pre-save transform: context links ("pipe trick") with namespace and parens
13871 !! options
13872 pst title=[[Ns:Somearticle (context)]]
13873 !! wikitext
13874 [[|Article]]
13875 !! html/php
13876 [[Ns:Article (context)|Article]]
13877 !! end
13878
13879 !! test
13880 pre-save transform: context links ("pipe trick") with namespace and comma
13881 !! options
13882 pst title=[[Ns:Somearticle, Context, Whatever]]
13883 !! wikitext
13884 [[|Article]]
13885 !! html/php
13886 [[Ns:Article, Context, Whatever|Article]]
13887 !! end
13888
13889 !! test
13890 pre-save transform: context links ("pipe trick") with namespace, comma and parens
13891 !! options
13892 pst title=[[Ns:Somearticle, Context (context)]]
13893 !! wikitext
13894 [[|Article]]
13895 !! html/php
13896 [[Ns:Article (context)|Article]]
13897 !! end
13898
13899 !! test
13900 pre-save transform: context links ("pipe trick") with namespace, parens and comma
13901 !! options
13902 pst title=[[Ns:Somearticle (IGNORED), Context]]
13903 !! wikitext
13904 [[|Article]]
13905 !! html/php
13906 [[Ns:Article, Context|Article]]
13907 !! end
13908
13909 !! test
13910 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
13911 !! options
13912 pst
13913 !! wikitext
13914 [[Article(context)|]]
13915 [[Bar:Article(context)|]]
13916 [[:Bar:Article(context)|]]
13917 [[|Article(context)]]
13918 [[Bar:X(Y)Z|]]
13919 [[:Bar:X(Y)Z|]]
13920 !! html/php
13921 [[Article(context)|Article]]
13922 [[Bar:Article(context)|Article]]
13923 [[:Bar:Article(context)|Article]]
13924 [[Article(context)]]
13925 [[Bar:X(Y)Z|X(Y)Z]]
13926 [[:Bar:X(Y)Z|X(Y)Z]]
13927 !! end
13928
13929 !! test
13930 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
13931 !! options
13932 pst
13933 !! wikitext
13934 [[Article (context)|]]
13935 [[Bar:Article (context)|]]
13936 [[:Bar:Article (context)|]]
13937 [[|Article (context)]]
13938 [[Bar:X (Y) Z|]]
13939 [[:Bar:X (Y) Z|]]
13940 !! html/php
13941 [[Article (context)|Article]]
13942 [[Bar:Article (context)|Article]]
13943 [[:Bar:Article (context)|Article]]
13944 [[Article (context)]]
13945 [[Bar:X (Y) Z|X (Y) Z]]
13946 [[:Bar:X (Y) Z|X (Y) Z]]
13947 !! end
13948
13949 !! test
13950 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
13951 !! options
13952 pst
13953 !! wikitext
13954 [[Article(context)|]]
13955 [[Bar:Article(context)|]]
13956 [[:Bar:Article(context)|]]
13957 [[|Article(context)]]
13958 [[Bar:X(Y)Z|]]
13959 [[:Bar:X(Y)Z|]]
13960 !! html/php
13961 [[Article(context)|Article]]
13962 [[Bar:Article(context)|Article]]
13963 [[:Bar:Article(context)|Article]]
13964 [[Article(context)]]
13965 [[Bar:X(Y)Z|X(Y)Z]]
13966 [[:Bar:X(Y)Z|X(Y)Z]]
13967 !! end
13968
13969 !! test
13970 pre-save transform: context links ("pipe trick") with commas (T23660)
13971 !! options
13972 pst
13973 !! wikitext
13974 [[Article (context), context|]]
13975 [[Article (context),context|]]
13976 [[Bar:Article (context), context|]]
13977 [[Bar:Article (context),context|]]
13978 [[:Bar:Article (context), context|]]
13979 [[:Bar:Article (context),context|]]
13980 !! html/php
13981 [[Article (context), context|Article]]
13982 [[Article (context),context|Article]]
13983 [[Bar:Article (context), context|Article]]
13984 [[Bar:Article (context),context|Article]]
13985 [[:Bar:Article (context), context|Article]]
13986 [[:Bar:Article (context),context|Article]]
13987 !! end
13988
13989 !! test
13990 Parsoid: backwards pipe trick
13991 !! wikitext
13992 [[|'''bar''']]
13993 !! html/php
13994 <p>[[|<b>bar</b>]]
13995 </p>
13996 !! html/parsoid
13997 <p>[[|<b>bar</b>]]</p>
13998 !! end
13999
14000 !! test
14001 pre-save transform: trim trailing empty lines
14002 !! options
14003 pst
14004 !! wikitext
14005 Empty lines are trimmed
14006
14007
14008
14009
14010 !! html/php
14011 Empty lines are trimmed
14012 !! end
14013
14014 !! test
14015 pre-save transform: Signature expansion
14016 !! options
14017 pst
14018 !! wikitext
14019 * ~~~
14020 * ~~~~
14021 * ~~~~~
14022 * <noinclude>~~~</noinclude>
14023 * <includeonly>~~~</includeonly>
14024 * <onlyinclude>~~~</onlyinclude>
14025 !! html/php
14026 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
14027 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14028 * 00:02, 1 January 1970 (UTC)
14029 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
14030 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
14031 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
14032 !! end
14033
14034
14035 !! test
14036 ParserOutput flags from signature expansion (T84843)
14037 !! options
14038 pst
14039 showflags
14040 !! wikitext
14041 ~~~~
14042 !! html/php
14043 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
14044 flags=user-signature
14045 !! end
14046
14047
14048 !! test
14049 pre-save transform: Signature expansion in nowiki tags (T2093)
14050 !! options
14051 pst disabled
14052 !! wikitext
14053 Shall not expand:
14054
14055 <nowiki>~~~~</nowiki>
14056
14057 <includeonly><nowiki>~~~~</nowiki></includeonly>
14058
14059 <noinclude><nowiki>~~~~</nowiki></noinclude>
14060
14061 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14062
14063 {{subst:Foo}} shall be converted to FOO
14064
14065 As well as inside noinclude/onlyinclude
14066 <noinclude>{{subst:Foo}}</noinclude>
14067 <onlyinclude>{{subst:Foo}}</onlyinclude>
14068
14069 But not inside includeonly
14070 <includeonly>{{subst:Foo}}</includeonly>
14071 !! html/php
14072 Shall not expand:
14073
14074 <nowiki>~~~~</nowiki>
14075
14076 <includeonly><nowiki>~~~~</nowiki></includeonly>
14077
14078 <noinclude><nowiki>~~~~</nowiki></noinclude>
14079
14080 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
14081
14082 FOO shall be converted to FOO
14083
14084 As well as inside noinclude/onlyinclude
14085 <noinclude>FOO</noinclude>
14086 <onlyinclude>FOO</onlyinclude>
14087
14088 But not inside includeonly
14089 <includeonly>{{subst:Foo}}</includeonly>
14090 !! end
14091
14092 !! test
14093 Parsoid: Recognize nowiki with trailing space in tags
14094 !! options
14095 parsoid=wt2html
14096 !! wikitext
14097 <nowiki ><div>[[foo]]</nowiki >
14098
14099 a<nowiki / >b
14100
14101 c<nowiki />d
14102
14103 e<nowiki/ >f
14104 !! html
14105 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14106 <p>ab</p>
14107 <p>cd</p>
14108 <p>ef</p>
14109 !! end
14110
14111 !! test
14112 Parsoid: Recognize nowiki with odd capitalization
14113 !! options
14114 parsoid=wt2html
14115 !! wikitext
14116 <noWikI ><div>[[foo]]</Nowiki >
14117 !! html
14118 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
14119 !! end
14120
14121
14122 !! test
14123 Parsoid: Escape nowiki with trailing space in tags
14124 !! options
14125 parsoid=html2wt
14126 !! html/parsoid
14127 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
14128 <p>a&lt;nowiki /&gt;b</p>
14129 <p>c&lt;nowiki/ &gt;d</p>
14130 !! wikitext
14131 &lt;nowiki &gt; foo &lt;/nowiki &gt;
14132
14133 a&lt;nowiki /&gt;b
14134
14135 c&lt;nowiki/ &gt;d
14136 !! end
14137
14138 !! test
14139 Parsoid: Escape weird noWikI capitalizations
14140 !! options
14141 parsoid=html2wt
14142 !! html/parsoid
14143 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
14144 !! wikitext
14145 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
14146 !! end
14147
14148 ###
14149 ### Message transform tests
14150 ###
14151 !! test
14152 message transform: magic variables
14153 !! options
14154 msg
14155 !! wikitext
14156 {{SITENAME}}
14157 !! html
14158 MediaWiki
14159 !! end
14160
14161 !! test
14162 message transform: should not transform wiki markup
14163 !! options
14164 msg
14165 !! wikitext
14166 ''test''
14167 !! html
14168 ''test''
14169 !! end
14170
14171 !! test
14172 message transform: <noinclude> in transcluded template (T6926)
14173 !! options
14174 msg
14175 !! wikitext
14176 {{Includes}}
14177 !! html
14178 Foobar
14179 !! end
14180
14181 !! test
14182 message transform: <onlyinclude> in transcluded template (T6926)
14183 !! options
14184 msg
14185 !! wikitext
14186 {{Includes2}}
14187 !! html
14188 Foo
14189 !! end
14190
14191 !! test
14192 {{#special:}} page name, known
14193 !! options
14194 msg
14195 !! wikitext
14196 {{#special:Recentchanges}}
14197 !! html
14198 Special:RecentChanges
14199 !! end
14200
14201 !! test
14202 {{#special:}} page name with subpage, known
14203 !! options
14204 msg
14205 !! wikitext
14206 {{#special:Recentchanges/param}}
14207 !! html
14208 Special:RecentChanges/param
14209 !! end
14210
14211 !! test
14212 {{#special:}} page name, unknown
14213 !! options
14214 msg
14215 !! wikitext
14216 {{#special:foobar nonexistent}}
14217 !! html
14218 Special:Foobar nonexistent
14219 !! end
14220
14221 !! test
14222 {{#speciale:}} page name, known
14223 !! options
14224 msg
14225 !! wikitext
14226 {{#speciale:Recentchanges}}
14227 !! html
14228 Special:RecentChanges
14229 !! end
14230
14231 !! test
14232 {{#speciale:}} page name with subpage, known
14233 !! options
14234 msg
14235 !! wikitext
14236 {{#speciale:Recentchanges/param}}
14237 !! html
14238 Special:RecentChanges/param
14239 !! end
14240
14241 !! test
14242 {{#speciale:}} page name, unknown
14243 !! options
14244 msg
14245 !! wikitext
14246 {{#speciale:foobar nonexistent}}
14247 !! html
14248 Special:Foobar_nonexistent
14249 !! end
14250
14251 ###
14252 ### Images
14253 ###
14254 ### For Parsoid-specific tests, see
14255 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
14256
14257 !! test
14258 Simple image
14259 !! options
14260 parsoid=wt2html,wt2wt,html2html
14261 !! wikitext
14262 [[Image:foobar.jpg]]
14263 !! html/php
14264 <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>
14265 </p>
14266 !! html/parsoid
14267 <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>
14268 !! end
14269
14270 !! test
14271 Serialize simple image with figure-inline wrapper
14272 !! options
14273 parsoid=html2wt
14274 !! html/parsoid
14275 <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>
14276 !! wikitext
14277 [[File:Foobar.jpg]]
14278 !! end
14279
14280 !! test
14281 Simple image (using File: namespace, now canonical)
14282 !! wikitext
14283 [[File:Foobar.jpg]]
14284 !! html/php
14285 <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>
14286 </p>
14287 !! html/parsoid
14288 <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>
14289 !! end
14290
14291 !! test
14292 Right-aligned image
14293 !! wikitext
14294 [[File:Foobar.jpg|right]]
14295 !! html/php
14296 <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>
14297
14298 !! html/parsoid
14299 <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>
14300 !! end
14301
14302 !! test
14303 Image with caption
14304 !! wikitext
14305 [[File:Foobar.jpg|right|Caption text]]
14306 !! html/php
14307 <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>
14308
14309 !! html/parsoid
14310 <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>
14311 !! end
14312
14313 !! test
14314 Image with caption, T55312 #1
14315 !! wikitext
14316 [[File:Foobar.jpg|right|Caption page stuff]]
14317 !! html/php
14318 <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>
14319
14320 !! html/parsoid
14321 <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>
14322 !! end
14323
14324 !! test
14325 Image with caption, T55312 #2
14326 !! wikitext
14327 [[File:Foobar.jpg|right|Caption page=]]
14328 !! html/php
14329 <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>
14330
14331 !! html/parsoid
14332 <figure class="mw-default-size mw-halign-right" typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/3/3a/Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a><figcaption>Caption page=</figcaption></figure>
14333 !! end
14334
14335 !! test
14336 Image with caption, T55312 #3
14337 !! wikitext
14338 [[File:Foobar.jpg|right|Caption page=stuff]]
14339 !! html/php
14340 <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>
14341
14342 !! html/parsoid
14343 <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>
14344 !! end
14345
14346 !! test
14347 Image caption with pipe entity
14348 !! wikitext
14349 [[File:Foobar.jpg|thumb|one &#x7C; two]]
14350 [[File:Foobar.jpg|thumb|one ''two'' &#x7C; three]]
14351 !! html/php
14352 <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>
14353 <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>
14354
14355 !! html/parsoid
14356 <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>
14357 <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>
14358 !! end
14359
14360 !! test
14361 Allow empty links in image captions (T62753)
14362 !! options
14363 thumbsize=220
14364 !! wikitext
14365 [[File:Foobar.jpg|thumb|Caption [[Link1]]
14366 [[]]
14367 [[Link2]]
14368 ]]
14369 !! html/php
14370 <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>
14371
14372 !! html/parsoid
14373 <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>
14374 [[]]
14375 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
14376 </figcaption></figure>
14377 !! end
14378
14379 !! test
14380 Titles in unlinked images (T23454)
14381 !! wikitext
14382 [[File:Foobar.jpg|link=|stuff]]
14383 !! html/php
14384 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
14385 </p>
14386 !! end
14387
14388 !! test
14389 Link with empty target
14390 !! wikitext
14391 [[]]
14392 !! html
14393 <p>[[]]
14394 </p>
14395 !! end
14396
14397 !! test
14398 Image with link trail
14399 !! wikitext
14400 Linktrails should not work for images: [[File:Foobar.jpg]]s
14401 !! html/php
14402 <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
14403 </p>
14404 !! html/parsoid
14405 <p>Linktrails should not work for images: <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>s</p>
14406 !! end
14407
14408 !! test
14409 Image with empty attribute
14410 !! options
14411 parsoid=wt2html,wt2wt,html2html
14412 !! wikitext
14413 [[File:Foobar.jpg|right||Caption text]]
14414 !! html/php
14415 <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>
14416
14417 !! html/parsoid
14418 <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>
14419 !! end
14420
14421 !! test
14422 1. Block image with individual attributes from templates
14423 !! wikitext
14424 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14425 !! html/php
14426 <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>
14427
14428 !! html/parsoid
14429 <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>
14430 !! end
14431
14432 !! test
14433 2. Block Image with individual attributes from templates
14434 !! wikitext
14435 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14436 !! html/php
14437 <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>
14438
14439 !! html/parsoid
14440 <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>
14441 !! end
14442
14443 !! test
14444 3. Inline image with individual attributes from templates
14445 !! wikitext
14446 [[File:Foobar.jpg|{{echo|50px}}]]
14447 !! html/php
14448 <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>
14449 </p>
14450 !! html/parsoid
14451 <p><span 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></span></p>
14452 !! end
14453
14454 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14455 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14456 !! test
14457 Image with multiple attributes from the same template
14458 !! wikitext
14459 [[File:Foobar.jpg|{{image_attribs}}]]
14460 !! html/php
14461 <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>
14462
14463 !! html/parsoid
14464 <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>
14465 !! end
14466
14467 !! test
14468 Image with link tails
14469 !! options
14470 thumbsize=220
14471 !! wikitext
14472 123[[File:Foobar.jpg]]456
14473 123[[File:Foobar.jpg|right]]456
14474 123[[File:Foobar.jpg|thumb]]456
14475 !! html/php
14476 <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
14477 </p>
14478 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
14479 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
14480
14481 !! html/php+tidy
14482 <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>
14483 <p>123</p>
14484 <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>
14485 <p>456 123</p>
14486 <div class="thumb tright">
14487 <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>
14488 <div class="thumbcaption">
14489 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
14490 </div>
14491 </div>
14492 </div>
14493 <p>456</p>
14494 !! html/parsoid
14495 <p>123<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>456</p>
14496 <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>
14497 <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>
14498 !! end
14499
14500 !! test
14501 Image with multiple captions -- only last one is accepted
14502 !! wikitext
14503 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14504 !! html/php
14505 <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>
14506
14507 !! html/parsoid
14508 <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>
14509 !! end
14510
14511 !! test
14512 Image with multiple widths -- use last
14513 !! wikitext
14514 [[File:Foobar.jpg|200px|300px|caption]]
14515 !! html/php
14516 <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>
14517 </p>
14518 !! html/parsoid
14519 <p><span 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></span></p>
14520 !! end
14521
14522 !! test
14523 Image with multiple alignments -- use first (T50664)
14524 !! options
14525 thumbsize=220
14526 !! wikitext
14527 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14528
14529 [[File:Foobar.jpg|middle|text-top|caption]]
14530 !! html/php
14531 <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>
14532 <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>
14533 </p>
14534 !! html/parsoid
14535 <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>
14536 <p><span 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></span></p>
14537 !! end
14538
14539 !! test
14540 Image with width attribute at different positions
14541 !! wikitext
14542 [[File:Foobar.jpg|200px|right|Caption]]
14543 [[File:Foobar.jpg|right|200px|Caption]]
14544 [[File:Foobar.jpg|right|Caption|200px]]
14545 !! html/php
14546 <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>
14547 <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>
14548 <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>
14549
14550 !! html/parsoid
14551 <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>
14552 <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>
14553 <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>
14554 !! end
14555
14556 # a sad bit of backward-compatibility
14557 !! test
14558 Image with size specified with pxpx (T15500, T53628)
14559 !! options
14560 parsoid=wt2html,wt2wt,html2html
14561 !! wikitext
14562 [[File:Foobar.jpg|20pxpx]]
14563 [[File:Foobar.jpg|200x20pxpx]]
14564 !! html/php
14565 <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>
14566 <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>
14567 </p>
14568 !! html/parsoid
14569 <p><span 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></span> <span 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></span></p>
14570 !! end
14571
14572 !! test
14573 Image with link parameter, wiki target
14574 !! wikitext
14575 [[File:Foobar.jpg|link=Main Page]]
14576 !! html/php
14577 <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>
14578 </p>
14579 !! html/parsoid
14580 <p><span 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></span></p>
14581 !! end
14582
14583 # parsoid T51293 (part 1)
14584 !! test
14585 Image with link parameter, URL target
14586 !! wikitext
14587 [[File:Foobar.jpg|link=http://example.com/]]
14588 !! html/php
14589 <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>
14590 </p>
14591 !! html/parsoid
14592 <p><span 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></span></p>
14593 !! end
14594
14595 # parsoid T51293 (part 2)
14596 !! test
14597 Image with link parameter, protocol-less URL target
14598 !! wikitext
14599 [[File:Foobar.jpg|link=//example.com/]]
14600 !! html/php
14601 <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>
14602 </p>
14603 !! html/parsoid
14604 <p><span 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></span></p>
14605 !! end
14606
14607 !! test
14608 Escaping non-block captions (T107435)
14609 !! options
14610 parsoid={
14611 "modes": ["wt2wt"],
14612 "changes": [
14613 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14614 ]
14615 }
14616 !! wikitext
14617 [[Image:Foobar.jpg|caption]]
14618 !! wikitext/edited
14619 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14620 !! end
14621
14622 # wgExternalLinkTarget not supported by Parsoid
14623 !! test
14624 Image with link parameter, wgExternalLinkTarget
14625 !! wikitext
14626 [[Image:foobar.jpg|link=http://example.com/]]
14627 !! config
14628 wgExternalLinkTarget='foobar'
14629 !! html/php
14630 <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>
14631 </p>
14632 !! end
14633
14634 !! test
14635 Image with link parameter, wgNoFollowLinks set to false
14636 !! wikitext
14637 [[Image:foobar.jpg|link=http://example.com/]]
14638 !! config
14639 wgNoFollowLinks=false
14640 !! html
14641 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14642 </p>
14643 !! end
14644
14645 !! test
14646 Image with link parameter, wgNoFollowDomainExceptions
14647 !! wikitext
14648 [[Image:foobar.jpg|link=http://example.com/]]
14649 !! config
14650 wgNoFollowDomainExceptions='example.com'
14651 !! html
14652 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14653 </p>
14654 !! end
14655
14656 # wgExternalLinkTarget not supported by Parsoid
14657 !! test
14658 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14659 !! wikitext
14660 [[Image:foobar.jpg|link=http://example.com/|Title]]
14661 !! config
14662 wgExternalLinkTarget='foobar'
14663 !! html/php
14664 <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>
14665 </p>
14666 !! end
14667
14668 !! test
14669 Image with empty link parameter
14670 !! wikitext
14671 [[File:Foobar.jpg|link=]]
14672 !! html/php
14673 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14674 </p>
14675 !! html/parsoid
14676 <p><span 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></span></p>
14677 !! end
14678
14679 !! test
14680 Image with link parameter (wiki target) and unnamed parameter
14681 !! wikitext
14682 [[File:Foobar.jpg|link=Main_Page|Title]]
14683 !! html/php
14684 <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>
14685 </p>
14686 !! html/parsoid
14687 <p><span 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></span></p>
14688 !! end
14689
14690 !! test
14691 Image with link parameter (URL target) and unnamed parameter
14692 !! wikitext
14693 [[File:Foobar.jpg|link=http://example.com/|Title]]
14694 !! html/php
14695 <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>
14696 </p>
14697 !! html/parsoid
14698 <p><span 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></span></p>
14699 !! end
14700
14701 !! test
14702 Thumbnail image with link parameter
14703 !! options
14704 thumbsize=220
14705 parsoid=wt2html,wt2wt,html2html
14706 !! wikitext
14707 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14708 !! html/php
14709 <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>
14710
14711 !! html/parsoid
14712 <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>
14713 !! end
14714
14715 !! test
14716 Manually-specified thumbnail image
14717 !! options
14718 thumbsize=220
14719 !! wikitext
14720 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14721 !! html/php
14722 <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>
14723
14724 !! html/parsoid
14725 <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>
14726 !! end
14727
14728 !! test
14729 Manually-specified thumbnail image with explicit link to wiki page
14730 !! options
14731 thumbsize=220
14732 parsoid=wt2html,wt2wt,html2html
14733 !! wikitext
14734 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14735 !! html/php
14736 <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>
14737
14738 !! html/parsoid
14739 <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>
14740 !! end
14741
14742 !! test
14743 Manually-specified thumbnail image with explicit link to url
14744 !! options
14745 thumbsize=220
14746 parsoid=wt2html,wt2wt,html2html
14747 !! wikitext
14748 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14749 !! html/php
14750 <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>
14751
14752 !! html/parsoid
14753 <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>
14754 !! end
14755
14756 !! test
14757 Manually-specified thumbnail image with explicit no link
14758 !! options
14759 thumbsize=220
14760 parsoid=wt2html,wt2wt,html2html
14761 !! wikitext
14762 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14763 !! html/php
14764 <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>
14765
14766 !! html/parsoid
14767 <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>
14768 !! end
14769
14770 !! test
14771 Manually-specified thumbnail image with explicit link and alt text
14772 !! options
14773 thumbsize=220
14774 parsoid=wt2html,wt2wt,html2html
14775 !! wikitext
14776 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14777 !! html/php
14778 <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>
14779
14780 !! html/parsoid
14781 <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>
14782 !! end
14783
14784 !! test
14785 Image with frame and link
14786 !! options
14787 parsoid=wt2html,wt2wt,html2html
14788 !! wikitext
14789 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14790 !! html/php
14791 <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>
14792
14793 !! html/parsoid
14794 <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>
14795 !! end
14796
14797 !! test
14798 Image with frame and link and explicit alt
14799 !! options
14800 parsoid=wt2html,wt2wt,html2html
14801 !! wikitext
14802 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
14803 !! html/php
14804 <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>
14805
14806 !! html/parsoid
14807 <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>
14808 !! end
14809
14810 !! test
14811 Image with wiki markup in implicit alt
14812 !! wikitext
14813 [[Image:Foobar.jpg|testing '''bold''' in alt]]
14814
14815 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
14816 !! html/php
14817 <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>
14818 </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>
14819 </p>
14820 !! html/parsoid
14821 <p><span 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></span></p>
14822
14823 <p><span 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></span></p>
14824 !! end
14825
14826 !! test
14827 Alt image option should handle most kinds of wikitext without barfing
14828 !! wikitext
14829 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
14830 !! html/php
14831 <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>
14832
14833 !! html/parsoid
14834 <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>
14835 !! end
14836
14837 !! test
14838 Image with table with attributes in caption
14839 !! options
14840 parsoid=wt2html,html2html
14841 !! wikitext
14842 [[File:Foobar.jpg|thumb|
14843 {| class="123" |
14844 |- class="456" |
14845 | ha
14846 |}
14847 ]]
14848 !! html/parsoid
14849 <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>
14850 <table class="123">
14851 <tbody><tr class="456" data-parsoid='{"startTagSrc":"|-"}'>
14852 <td> ha</td></tr>
14853 </tbody></table>
14854 </figcaption></figure>
14855 !! end
14856
14857 !! test
14858 Image with table with rows from templates in caption
14859 !! wikitext
14860 [[File:Foobar.jpg|thumb|
14861 {|
14862 {{echo|{{!}} hi}}
14863 |}
14864 ]]
14865 !! html/parsoid
14866 <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>
14867 <table>
14868 <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>
14869 </tbody></table>
14870 </figcaption></figure>
14871 !! end
14872
14873 !! test
14874 Image with nested tables in caption
14875 !! wikitext
14876 [[File:Foobar.jpg|thumb|Foo<br />
14877 {|
14878 |
14879 {|
14880 |z
14881 |}
14882 |}
14883 ]]
14884 !! html/parsoid
14885 <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}'/>
14886 <table>
14887 <tbody><tr><td>
14888 <table>
14889 <tbody><tr><td>z</td></tr>
14890 </tbody></table></td></tr>
14891 </tbody></table>
14892 </figcaption></figure>
14893 !! end
14894
14895 ###################
14896 # Conflicting image format options.
14897 # First option specified should 'win'.
14898 # All three cases in each test should be identical.
14899
14900 !! test
14901 Image with 'frameless' first.
14902 !! options
14903 parsoid=wt2html,wt2wt,html2html
14904 !! wikitext
14905 [[File:Foobar.jpg|frameless|caption]]
14906
14907 [[File:Foobar.jpg|frameless|frame|caption]]
14908
14909 [[File:Foobar.jpg|frameless|thumb|caption]]
14910 !! html/php
14911 <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>
14912 </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>
14913 </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>
14914 </p>
14915 !! html/parsoid
14916 <p><span 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></span></p>
14917 <p><span 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></span></p>
14918 <p><span 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></span></p>
14919 !! end
14920
14921 !! test
14922 Image with 'frame' first.
14923 !! options
14924 parsoid=wt2html,wt2wt,html2html
14925 !! wikitext
14926 [[File:Foobar.jpg|frame|caption]]
14927 [[File:Foobar.jpg|frame|frameless|caption]]
14928 [[File:Foobar.jpg|frame|thumb|caption]]
14929 !! html/php
14930 <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>
14931 <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>
14932 <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>
14933
14934 !! html/parsoid
14935 <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>
14936 <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>
14937 <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>
14938 !! end
14939
14940 !! test
14941 Image with 'thumb' first.
14942 !! options
14943 parsoid=wt2html,wt2wt,html2html
14944 !! wikitext
14945 [[File:Foobar.jpg|thumb|caption]]
14946 [[File:Foobar.jpg|thumb|frameless|caption]]
14947 [[File:Foobar.jpg|thumb|frame|caption]]
14948 !! html/php
14949 <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>
14950 <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>
14951 <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>
14952
14953 !! html/parsoid
14954 <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>
14955 <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>
14956 <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>
14957 !! end
14958
14959 ###################
14960 # Image sizing.
14961 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
14962 # and https://phabricator.wikimedia.org/T64258
14963 # Foobar has actual size of 1941x220
14964 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
14965 # a scalable format.
14966 # 2. Framed images always ignore size options; always render at default size.
14967 # 3. "Unspecified format" and border are the only types which can be
14968 # enlarged.
14969
14970 !! test
14971 Image: unspecified format and border enlarge
14972 !! options
14973 parsoid=wt2html,wt2wt,html2html
14974 !! wikitext
14975 [[File:Foobar.jpg|2000px]]
14976
14977 [[File:Foobar.jpg|border|2000px]]
14978 !! html/php
14979 <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>
14980 </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>
14981 </p>
14982 !! html/parsoid
14983 <p><span 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></span></p>
14984 <p><span 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></span></p>
14985 !! end
14986
14987 !! test
14988 Image: "unspecified format" and border reduce
14989 !! options
14990 parsoid=wt2html,wt2wt,html2html
14991 !! wikitext
14992 [[File:Foobar.jpg|1000px]]
14993
14994 [[File:Foobar.jpg|border|1000px]]
14995 !! html/php
14996 <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>
14997 </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>
14998 </p>
14999 !! html/parsoid
15000 <p><span 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></span></p>
15001 <p><span 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></span></p>
15002 !! end
15003
15004 !! test
15005 Image: thumbs reduce
15006 !! options
15007 parsoid=wt2html,wt2wt,html2html
15008 !! wikitext
15009 [[File:Foobar.jpg|thumb|50px]]
15010 !! html/php
15011 <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>
15012
15013 !! html/parsoid
15014 <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>
15015 !! end
15016
15017 !! test
15018 Image: bitmap thumbs can't be enlarged past original size, but vector can.
15019 !! options
15020 parsoid=wt2html,wt2wt,html2html
15021 !! wikitext
15022 [[File:Foobar.jpg|thumb|2000px]]
15023
15024 [[File:Foobar.svg|thumb|2000px]]
15025 !! html/php
15026 <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>
15027 <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>
15028
15029 !! html/parsoid
15030 <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>
15031 <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>
15032 !! end
15033
15034 !! test
15035 Image: frameless can reduce in size
15036 !! options
15037 parsoid=wt2html,wt2wt,html2html
15038 !! wikitext
15039 [[File:Foobar.jpg|frameless|50px]]
15040 !! html/php
15041 <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>
15042 </p>
15043 !! html/parsoid
15044 <p><span 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></span></p>
15045 !! end
15046
15047 !! test
15048 Image: bitmap frameless can't be enlarged past original size, but vector can
15049 !! options
15050 parsoid=wt2html,wt2wt,html2html
15051 !! wikitext
15052 [[File:Foobar.jpg|frameless|2000px]]
15053
15054 [[File:Foobar.svg|frameless|2000px]]
15055 !! html/php
15056 <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>
15057 </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>
15058 </p>
15059 !! html/parsoid
15060 <p><span 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></span></p>
15061 <p><span 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></span></p>
15062 !! end
15063
15064 !! test
15065 Image: framed images are always unscaled.
15066 !! options
15067 parsoid=wt2html,wt2wt,html2html
15068 !! wikitext
15069 [[File:Foobar.jpg|frame]]
15070
15071 [[File:Foobar.jpg|frame|50px]]
15072
15073 [[File:Foobar.jpg|frame|50x50px]]
15074
15075 [[File:Foobar.jpg|frame|2000px]]
15076 !! html/php
15077 <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>
15078 <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>
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></div></div>
15080 <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>
15081
15082 !! html/parsoid
15083 <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>
15084 <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>
15085 <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>
15086 <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>
15087 !! end
15088
15089 ###################
15090
15091 !! test
15092 Link to image page- image page normally doesn't exists, hence edit link
15093 Add test with existing image page
15094 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
15095 !! wikitext
15096 [[:Image:test]]
15097 !! html
15098 <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>
15099 </p>
15100 !! end
15101
15102 !! test
15103 T20784 Link to non-existent image page with caption should use caption as link text
15104 !! wikitext
15105 [[:Image:test|caption]]
15106 !! html
15107 <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>
15108 </p>
15109 !! end
15110
15111 !! test
15112 Frameless image caption with a free URL
15113 !! wikitext
15114 [[File:Foobar.jpg|http://example.com]]
15115 !! html/php
15116 <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>
15117 </p>
15118 !! html/parsoid
15119 <p><span 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></span></p>
15120 !! end
15121
15122 !! test
15123 Thumbnail image caption with a free URL
15124 !! options
15125 thumbsize=220
15126 !! wikitext
15127 [[File:Foobar.jpg|thumb|http://example.com]]
15128 !! html/php
15129 <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>
15130
15131 !! html/parsoid
15132 <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>
15133 !! end
15134
15135 !! test
15136 Thumbnail image caption with a free URL and explicit alt
15137 !! options
15138 thumbsize=220
15139 parsoid=wt2html,wt2wt,html2html
15140 !! wikitext
15141 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
15142 !! html/php
15143 <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>
15144
15145 !! html/parsoid
15146 <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>
15147 !! end
15148
15149 !! test
15150 SVG thumbnails with no language set
15151 !! options
15152 !! wikitext
15153 [[File:Foobar.svg|thumb|caption]]
15154 !! html/php
15155 <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>
15156
15157 !! html/parsoid
15158 <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>
15159 !! end
15160
15161 !! test
15162 SVG thumbnails with language de
15163 !! options
15164 parsoid=wt2html,wt2wt,html2html
15165 !! wikitext
15166 [[File:Foobar.svg|thumb|caption|lang=de]]
15167 !! html/php
15168 <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>
15169
15170 !! html/parsoid
15171 <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>
15172 !! end
15173
15174 !! test
15175 SVG thumbnails with invalid language code
15176 !! options
15177 parsoid=wt2html,wt2wt,html2html
15178 !! wikitext
15179 [[File:Foobar.svg|thumb|caption|lang=invalid:language:code]]
15180 !! html/php
15181 <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>
15182
15183 !! html/parsoid
15184 <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>
15185 !! end
15186
15187 !! test
15188 T3887: A ISBN with a thumbnail
15189 !! wikitext
15190 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
15191 !! html/php
15192 <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>
15193
15194 !! html/parsoid
15195 <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>
15196 !! end
15197
15198 !! test
15199 T3887: A RFC with a thumbnail
15200 !! wikitext
15201 [[File:Foobar.jpg|thumb|This is RFC 12354]]
15202 !! html/php
15203 <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>
15204
15205 !! html/parsoid
15206 <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>
15207 !! end
15208
15209 !! test
15210 T3887: A mailto link with a thumbnail
15211 !! wikitext
15212 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
15213 !! html/php
15214 <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>
15215
15216 !! html/parsoid
15217 <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>
15218 !! end
15219
15220 # Pending resolution to T2368
15221 !! test
15222 T2648: Frameless image caption with a link
15223 !! wikitext
15224 [[File:Foobar.jpg|text with a [[link]] in it]]
15225 !! html/php
15226 <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>
15227 </p>
15228 !! html/parsoid
15229 <p><span 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></span></p>
15230 !! end
15231
15232 !! test
15233 T2648: Frameless image caption with a link (suffix)
15234 !! wikitext
15235 [[File:Foobar.jpg|text with a [[link]]foo in it]]
15236 !! html/php
15237 <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>
15238 </p>
15239 !! html/parsoid
15240 <p><span 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></span></p>
15241 !! end
15242
15243 !! test
15244 T2648: Frameless image caption with an interwiki link
15245 !! wikitext
15246 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
15247 !! html/php
15248 <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>
15249 </p>
15250 !! html/parsoid
15251 <p><span 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:ExtLink\" 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></span></p>
15252 !! end
15253
15254 !! test
15255 T2648: Frameless image caption with a piped interwiki link
15256 !! wikitext
15257 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
15258 !! html/php
15259 <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>
15260 </p>
15261 !! html/parsoid
15262 <p><span 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:ExtLink\" 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></span></p>
15263 !! end
15264
15265 !! test
15266 T107474: Frameless image caption with <nowiki>
15267 !! wikitext
15268 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
15269 !! html/parsoid
15270 <p><span 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></span></p>
15271 !! end
15272
15273 !! test
15274 Escape HTML special chars in image alt text
15275 !! wikitext
15276 [[File:Foobar.jpg|& < > "]]
15277 !! html/php
15278 <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>
15279 </p>
15280 !! html/parsoid
15281 <p><span 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></span></p>
15282 !! end
15283
15284 !! test
15285 Escape HTML special chars in image alt text with LanguageConverter
15286 !! options
15287 language=zh
15288 !! wikitext
15289 [[File:Foobar.jpg|& < > "]]
15290 !! html/php
15291 <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>
15292 </p>
15293 !! html/parsoid
15294 <p><span 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></span></p>
15295 !! end
15296
15297 !! test
15298 Entities in file name and attributes
15299 !! wikitext
15300 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
15301 !! html/php
15302 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
15303 </p>
15304 !! html/parsoid
15305 <p><span 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></span></p>
15306 !! end
15307
15308 !! test
15309 T2499: Alt text should have &#1234;, not &amp;1234;
15310 !! wikitext
15311 [[File:Foobar.jpg|&#9792;]]
15312 !! html/php
15313 <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>
15314 </p>
15315 !! html/parsoid
15316 <p><span 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></span></p>
15317 !! end
15318
15319 !! test
15320 Broken image caption with link
15321 !! options
15322 parsoid=wt2html,wt2wt,html2html
15323 !! wikitext
15324 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
15325 !! html/php
15326 <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.
15327 </p>
15328 !! html/parsoid
15329 <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>
15330 !! end
15331
15332 !! test
15333 Image caption containing another image
15334 !! wikitext
15335 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
15336 !! html/php
15337 <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>
15338
15339 !! html/parsoid
15340 <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 <span 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></span> inside it!</figcaption></figure>
15341 !! end
15342
15343 !! test
15344 Image: caption containing a newline
15345 !! wikitext
15346 [[File:Foobar.jpg|This
15347 *is some text]]
15348 !! html/php
15349 <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>
15350 </p>
15351 !! html/parsoid
15352 <p><span 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></span></p>
15353 !!end
15354
15355 !!test
15356 Image: caption containing leading space
15357 (The leading space should not trigger nowiki escaping in wt2wt mode)
15358 !! wikitext
15359 [[File:Foobar.jpg|thumb| bar]]
15360 !! html/php
15361 <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>
15362
15363 !! html/parsoid
15364 <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>
15365 !!end
15366
15367 !! test
15368 Image: caption containing a table
15369 !! options
15370 parsoid=wt2html,wt2wt,html2html
15371 !! wikitext
15372 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
15373 {|
15374 ! Foo !! Bar
15375 |-
15376 | Foo1 || Bar1
15377 |}
15378 and some more text.]]
15379 !! html/php
15380 <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>
15381
15382 !! html/parsoid
15383 <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
15384 <table>
15385 <tbody>
15386 <tr><th>Foo </th><th>Bar</th></tr>
15387 <tr>
15388 <td>Foo1 </td>
15389 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
15390 !! end
15391
15392 !! test
15393 T5090: External links other than http: in image captions
15394 !! wikitext
15395 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
15396 !! html/php
15397 <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>
15398
15399 !! html/parsoid
15400 <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>
15401 !! end
15402
15403 !! test
15404 Custom class
15405 !! options
15406 parsoid=wt2html,wt2wt,html2html
15407 !! wikitext
15408 [[Image:foobar.jpg|a|class=b]]
15409 !! html/php
15410 <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>
15411 </p>
15412 !! html/parsoid
15413 <p><span 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></span></p>
15414 !! end
15415
15416 !! test
15417 Localized image handling (1).
15418 !! options
15419 parsoid=wt2html,wt2wt,html2html
15420 language=es
15421 !! wikitext
15422 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
15423 !! html/php
15424 <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>
15425
15426 !! html/parsoid
15427 <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>
15428 !! end
15429
15430 !! test
15431 Localized image handling (2).
15432 !! options
15433 thumbsize=220
15434 parsoid=wt2html,wt2wt,html2html
15435 language=es
15436 !! wikitext
15437 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
15438 !! html/php
15439 <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>
15440
15441 !! html/parsoid
15442 <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>
15443 !! end
15444
15445 !! test
15446 Localized image handling (3).
15447 !! options
15448 language=fa
15449 parsoid=html2wt
15450 !! html/parsoid
15451 <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>
15452 !! wikitext
15453 [[File:Foobar.jpg|بندانگشتی]]
15454 !! end
15455
15456 !! test
15457 "border", "frameless" and "class" attributes on an image.
15458 !! options
15459 thumbsize=220
15460 parsoid=wt2html,wt2wt,html2html
15461 !! wikitext
15462 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
15463 !! html/php
15464 <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>
15465 </p>
15466 !! html/parsoid
15467 <p><span 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></span></p>
15468 !! end
15469
15470 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
15471 !! test
15472 Invalid image attributes (T64500)
15473 !! options
15474 thumbsize=220
15475 parsoid=wt2html,wt2wt,html2html
15476 !! wikitext
15477 [[File:Foobar.jpg|thumb|float|left|caption]]
15478
15479 [[File:Foobar.jpg|thumb|righ|caption]]
15480
15481 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
15482 !! html/php
15483 <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>
15484 <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>
15485 <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>
15486
15487 !! html/parsoid
15488 <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>
15489 <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>
15490 <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>
15491 !! end
15492
15493 !! article
15494 File:Barfoo.jpg
15495 !! text
15496 #REDIRECT [[File:Barfoo.jpg]]
15497 !! endarticle
15498
15499 # FIXME: Parsoid should run this test -- but we'd need to teach the
15500 # mockAPI about the redirected Barfoo.jpg image.
15501 !! test
15502 Redirected image
15503 !! wikitext
15504 [[Image:Barfoo.jpg]]
15505 !! html/php
15506 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
15507 </p>
15508 !! end
15509
15510 !! test
15511 Missing image with uploads disabled
15512 !! options
15513 wgEnableUploads=0
15514 !! wikitext
15515 [[File:Foobaz.jpg]]
15516 !! html/php
15517 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
15518 </p>
15519 !! html/parsoid
15520 <p><span 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></span></p>
15521 !! end
15522
15523 # Parsoid-specific testing for images
15524 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
15525 # Currently imperfect due to a flaw in the Parsoid testrunner
15526 # Work in progress
15527 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
15528 # image tests.
15529
15530 !! test
15531 Parsoid-specific image handling - simple image with size and middle alignment
15532 !! wikitext
15533 [[File:Foobar.jpg|middle|50px]]
15534 !! html/parsoid
15535 <p><span 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></span></p>
15536 !! end
15537
15538 !! test
15539 Parsoid-specific image handling - simple image with size, middle alignment,
15540 non-standard namespace alias
15541 !! options
15542 parsoid=wt2wt,wt2html,html2html
15543 !! wikitext
15544 [[Image:Foobar.jpg|middle|50px]]
15545 !! html/parsoid
15546 <p><span 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></span></p>
15547 !! end
15548
15549 !! test
15550 Parsoid-specific image handling - simple image with size and middle alignment
15551 (existing content)
15552 !! wikitext
15553 [[File:Foobar.jpg|50px|middle]]
15554 !! html/parsoid
15555 <p><span 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></span></p>
15556 !! end
15557
15558 !! test
15559 Parsoid-specific image handling - simple image with size and middle alignment
15560 and non-standard namespace name
15561 !! options
15562 parsoid=wt2html,wt2wt,html2html
15563 !! wikitext
15564 [[Image:Foobar.jpg|50px|middle]]
15565 !! html/parsoid
15566 <p><span 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></span></p>
15567 !! end
15568
15569 !! test
15570 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
15571 !! wikitext
15572 [[File:Foobar.jpg|500x10px|baseline|caption]]
15573 !! html/parsoid
15574 <p><span 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></span></p>
15575 !! end
15576
15577 !! test
15578 Parsoid-specific image handling - simple image with border and size spec
15579 !! wikitext
15580 [[File:Foobar.jpg|50px|border|caption]]
15581 !! html/parsoid
15582 <p><span 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></span></p>
15583 !! end
15584
15585 !! test
15586 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15587 !! wikitext
15588 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
15589 !! html/parsoid
15590 <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>
15591 !! end
15592
15593 !! test
15594 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15595 (existing content)
15596 !! wikitext
15597 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
15598 !! html/parsoid
15599 <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>
15600 !! end
15601
15602 !! test
15603 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
15604 !! wikitext
15605 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
15606 !! html/parsoid
15607 <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>
15608 !! end
15609
15610 !! test
15611 Parsoid-specific image handling - thumbnail with specific size, halign,
15612 valign, and caption (existing content)
15613 !! wikitext
15614 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
15615 !! html/parsoid
15616 <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>
15617 !! end
15618
15619 !! test
15620 Parsoid-specific image handling - framed image with specific size and caption
15621 (size is ignored)
15622 !! options
15623 parsoid=wt2html,wt2wt,html2html
15624 !! wikitext
15625 [[File:Foobar.jpg|frame|500x50px|caption]]
15626 !! html/parsoid
15627 <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>
15628 !! end
15629
15630 !! test
15631 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption
15632 (size is ignored)
15633 !! options
15634 parsoid=wt2html,wt2wt,html2html
15635 !! wikitext
15636 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
15637 !! html/parsoid
15638 <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>
15639 !! end
15640
15641 !! test
15642 Parsoid-specific image handling - frameless image with specific size, border, and caption
15643 !! wikitext
15644 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
15645 !! html/parsoid
15646 <p><span 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></span></p>
15647 !! end
15648
15649 !! test
15650 Parsoid-specific image handling - simple image with a formatted caption
15651 !! wikitext
15652 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
15653 !! html/parsoid
15654 <p><span 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></span></p>
15655 !! end
15656
15657 !! test
15658 Parsoid-specific image handling - caption with a template in it
15659 !! wikitext
15660 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
15661 !! html/parsoid
15662 <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>
15663 !! end
15664
15665 !! test
15666 Parsoid-specific image handling - caption with unbalanced tags in it
15667 !! options
15668 parsoid=wt2html,wt2wt,html2html
15669 !! wikitext
15670 foo
15671 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
15672 bar
15673 !! html/parsoid
15674 <p>foo</p>
15675 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/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>
15676 <p>bar</p>
15677 !! end
15678
15679 !! test
15680 Parsoid-specific image handling - empty caption (1)
15681 !! options
15682 parsoid=wt2html,wt2wt
15683 !! wikitext
15684 [[File:Foobar.jpg|thumb|]]
15685 !! html/parsoid
15686 <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>
15687 !! end
15688
15689 # empty captions don't get serialized unless we're in the "round trip" case
15690 !! test
15691 Parsoid-specific image handling - empty caption (2)
15692 !! options
15693 parsoid=html2wt
15694 !! html/parsoid
15695 <figure class="mw-default-size" typeof="mw:Image/Thumb">
15696 <a href="./File:Foobar.jpg">
15697 <img resource="./File:Foobar.jpg"
15698 src="//example.com/images/3/3a/Foobar.jpg"
15699 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
15700 height="25" width="220"/>
15701 </a>
15702 <figcaption></figcaption>
15703 </figure>
15704 !! wikitext
15705 [[File:Foobar.jpg|thumb]]
15706 !! end
15707
15708 !! test
15709 Parsoid-specific image handling - whitespace caption
15710 !! wikitext
15711 [[File:Foobar.jpg|thumb| ]]
15712 !! html/parsoid
15713 <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>
15714 !! end
15715
15716 !! test
15717 Parsoid-specific image handling - lang option
15718 !! wikitext
15719 foo
15720 [[File:Foobar.svg|lang=de|caption]]
15721 bar
15722 !! html/parsoid
15723 <p>foo
15724 <span 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></span>
15725 bar</p>
15726 !! end
15727
15728 ## Edge case bugs in Parsoid from T93580
15729 !! test
15730 T93580: 1. Templated <ref> inside block images
15731 !! wikitext
15732 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
15733
15734 <references />
15735 !! html/parsoid
15736 <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>
15737
15738 <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>
15739 !! end
15740
15741 !! test
15742 T93580: 2. <ref> inside inline images
15743 !! wikitext
15744 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
15745
15746 <references />
15747 !! html/parsoid
15748 <p><span 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></span></p>
15749
15750 <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>
15751 !! end
15752
15753 !! test
15754 T93580: 3. Templated <ref> inside inline images
15755 !! wikitext
15756 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
15757
15758 <references />
15759 !! html/parsoid
15760 <p><span 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></span></p>
15761
15762 <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>
15763 !! end
15764
15765 ###
15766 ### Subpages
15767 ###
15768 !! article
15769 Subpage test/subpage
15770 !! text
15771 foo
15772 !! endarticle
15773
15774 !! test
15775 Subpage link
15776 !! options
15777 subpage title=[[Subpage test]]
15778 !! wikitext
15779 [[/subpage]]
15780 !! html
15781 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
15782 </p>
15783 !! end
15784
15785 !! test
15786 Subpage noslash link
15787 !! options
15788 subpage title=[[Subpage test]]
15789 !! wikitext
15790 [[/subpage/]]
15791 !! html
15792 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
15793 </p>
15794 !! end
15795
15796 !! article
15797 Subpage test/1/2/subpage
15798 !! text
15799 blah
15800 !! endarticle
15801
15802 !! test
15803 Relative subpage noslash link
15804 !! options
15805 parsoid=wt2wt,wt2html,html2html
15806 subpage title=[[Subpage test/1/2/3/4]]
15807 !! wikitext
15808 [[../../subpage/]]
15809
15810 [[../../subpage]]
15811 !! html/php
15812 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
15813 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
15814 </p>
15815 !! html/parsoid
15816 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
15817 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
15818 !! end
15819
15820 !! test
15821 Parsoid: dot-slash prefixed wikilinks
15822 !! wikitext
15823 [[./foo]]
15824
15825 [[././bar]]
15826
15827 [[././baz/]]
15828 !! html/php
15829 <p>[[./foo]]
15830 </p><p>[[././bar]]
15831 </p><p>[[././baz/]]
15832 </p>
15833 !! html/parsoid
15834 <p>[[./foo]]
15835 </p><p>[[././bar]]
15836 </p><p>[[././baz/]]
15837 </p>
15838 !! end
15839
15840 !! test
15841 Render invalid page names as plain text (T53090)
15842 !! wikitext
15843 [[./../foo|bar]]
15844 [[foo�|bar]]
15845 [[foo/.|bar]]
15846 [[foo/..|bar]]
15847 [[foo~~~bar]]
15848 [[foo>bar]]
15849 [[foo[bar]]
15850 [[.]]
15851 [[..]]
15852 [[foo././bar]]
15853 [[foo[http://example.com]xyz]]
15854
15855 [[{{echo|./../foo}}|bar]]
15856 [[{{echo|foo/.}}|bar]]
15857 [[{{echo|foo/..}}|bar]]
15858 [[{{echo|foo~~~~bar}}]]
15859 [[{{echo|foo>bar}}]]
15860 [[{{echo|foo././bar}}]]
15861 [[{{echo|foo{bar}}]]
15862 [[{{echo|foo}bar}}]]
15863 [[{{echo|foo[bar}}]]
15864 [[{{echo|foo]bar}}]]
15865 [[{{echo|foo<bar}}]]
15866 !!html/php
15867 <p>[[./../foo|bar]]
15868 [[foo�|bar]]
15869 [[foo/.|bar]]
15870 [[foo/..|bar]]
15871 [[foo~~~bar]]
15872 [[foo&gt;bar]]
15873 [[foo[bar]]
15874 [[.]]
15875 [[..]]
15876 [[foo././bar]]
15877 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
15878 </p><p>[[./../foo|bar]]
15879 [[foo/.|bar]]
15880 [[foo/..|bar]]
15881 [[foo~~~~bar]]
15882 [[foo&gt;bar]]
15883 [[foo././bar]]
15884 [[foo{bar]]
15885 [[foo}bar]]
15886 [[foo[bar]]
15887 [[foo]bar]]
15888 [[foo&lt;bar]]
15889 </p>
15890 !!html/parsoid
15891 <p>[[./../foo|bar]]
15892 [[foo�|bar]]
15893 [[foo/.|bar]]
15894 [[foo/..|bar]]
15895 [[foo~~~bar]]
15896 [[foo>bar]]
15897 [[foo[bar]]
15898 [[.]]
15899 [[..]]
15900 [[foo././bar]]
15901 [[foo<a rel="mw:ExtLink" href="http://example.com"></a>xyz]]</p>
15902
15903 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
15904 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
15905 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
15906 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
15907 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
15908 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
15909 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
15910 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
15911 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
15912 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
15913 [[<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>
15914 !!end
15915
15916 !! test
15917 Disabled subpages
15918 !! wikitext
15919 [[/subpage]]
15920 !! html
15921 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
15922 </p>
15923 !! end
15924
15925 !! test
15926 T2561: {{/Subpage}}
15927 !! options
15928 subpage title=[[Page]]
15929 !! wikitext
15930 {{/Subpage}}
15931 !! html
15932 <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>
15933 </p>
15934 !! end
15935
15936 ###
15937 ### Categories
15938 ###
15939 !! article
15940 Category:MediaWiki User's Guide
15941 !! text
15942 blah
15943 !! endarticle
15944
15945 !! test
15946 Link to category
15947 !! wikitext
15948 [[:Category:MediaWiki User's Guide]]
15949 !! html
15950 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User&#39;s Guide">Category:MediaWiki User's Guide</a>
15951 </p>
15952 !! end
15953
15954 !! test
15955 Simple category
15956 !! options
15957 cat
15958 !! wikitext
15959 [[Category:MediaWiki User's Guide]]
15960 !! html/php
15961 cat=MediaWiki_User's_Guide sort=
15962 !! html/parsoid
15963 <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"}}'/>
15964 !! end
15965
15966 !! test
15967 PAGESINCATEGORY invalid title fatal (r33546 fix)
15968 !! wikitext
15969 {{PAGESINCATEGORY:<bogus>}}
15970 !! html
15971 <p>0
15972 </p>
15973 !! end
15974
15975 !! test
15976 Category with different sort key
15977 !! options
15978 cat
15979 !! wikitext
15980 [[Category:MediaWiki User's Guide|Foo]]
15981 !! html/php
15982 cat=MediaWiki_User's_Guide sort=Foo
15983 !! html/parsoid
15984 <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"}}'/>
15985 !! end
15986
15987 !! test
15988 Category with identical sort key
15989 !! options
15990 cat
15991 !! wikitext
15992 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15993 !! html/php
15994 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
15995 !! html/parsoid
15996 <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"}}'/>
15997 !! end
15998
15999 !! test
16000 Category with empty sort key
16001 !! options
16002 cat
16003 pst
16004 !! wikitext
16005 [[Category:MediaWiki User's Guide|]]
16006 !! html/php
16007 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
16008 !! end
16009
16010 !! test
16011 Category with empty sort key and parentheses
16012 !! options
16013 cat
16014 pst
16015 !! wikitext
16016 [[Category:Foo (bar)|]]
16017 !! html/php
16018 [[Category:Foo (bar)|Foo]]
16019 !! end
16020
16021 !! test
16022 Category with link tail
16023 !! options
16024 cat
16025 pst
16026 !! wikitext
16027 123[[Category:Foo]]456
16028 !! html/php
16029 123[[Category:Foo]]456
16030 !! end
16031
16032 !! test
16033 Category with template
16034 !! options
16035 cat
16036 pst
16037 !! wikitext
16038 [[Category:{{echo|Foo}}]]
16039 !! html/php
16040 [[Category:{{echo|Foo}}]]
16041 !! end
16042
16043 !! test
16044 Category with template in sort key
16045 !! options
16046 cat
16047 pst
16048 !! wikitext
16049 [[Category:Foo|{{echo|Bar}}]]
16050 !! html/php
16051 [[Category:Foo|{{echo|Bar}}]]
16052 !! end
16053
16054 !! test
16055 Category with template in sort key and title
16056 !! options
16057 cat
16058 pst
16059 !! wikitext
16060 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16061 !! html/php
16062 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
16063 !! end
16064
16065 ## We used to, but no longer wt2wt this test since the default serializer
16066 ## will normalize all categories to serialize on their own line.
16067 ## This wikitext usage is going to be fairly uncommon in production and
16068 ## selser will take care of preserving formatting in those scenarios.
16069 !! test
16070 Category / paragraph interactions
16071 !! options
16072 parsoid=wt2html
16073 !! wikitext
16074 Foo [[Category:Baz]] Bar
16075
16076 Foo [[Category:Baz]]
16077 Bar
16078
16079 Foo
16080 [[Category:Baz]]
16081 Bar
16082
16083 Foo
16084 [[Category:Baz]] Bar
16085
16086 Foo
16087 [[Category:Baz]]
16088 [[Category:Baz]]
16089 [[Category:Baz]]
16090 Bar
16091
16092 [[Category:Baz]]
16093 [[Category:Baz]]
16094 [[Category:Baz]]
16095
16096 [[Category:Baz]]
16097 {{echo|[[Category:Baz]]}}
16098 [[Category:Baz]]
16099 !! html/php
16100 <p>Foo Bar
16101 </p><p>Foo
16102 Bar
16103 </p><p>Foo
16104 Bar
16105 </p><p>Foo Bar
16106 </p><p>Foo
16107 Bar
16108 </p>
16109 !! html/parsoid
16110 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16111 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16112 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16113 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
16114 <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>
16115 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
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 ##
16123 ## The whitespace on the empty line is part of the test. Please do not delete
16124 !! test
16125 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16126 !! options
16127 parsoid=wt2html
16128 !! wikitext
16129 This
16130
16131 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
16132
16133 {{echo|[[Category:Foo]] and so should this!}}
16134 !! html/php
16135 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
16136 </p>
16137 !! html/parsoid
16138 <p>This
16139
16140 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
16141
16142 <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>
16143 !! end
16144
16145 ## Parsoid will not try to wt2wt this while preserving newlines because
16146 ## it suppresses excess newlines within list items -- and we don't want to
16147 ## introduce a special case just for categories, which is, in reality somewhat
16148 ## odd behavior -- categories are unlikely to be used in list items like this
16149 ## in top-level pages and are only likely to show up in template-generated
16150 ## list items where this RT-ing is a non-issue.
16151 ##
16152 ## The whitespace on the empty line is part of the test. Please do not delete
16153 !! test
16154 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
16155 !! options
16156 parsoid=wt2html
16157 !! wikitext
16158 * This
16159
16160 [[Category:Foo]] and this should be part of the same list item
16161 * So should this
16162
16163 {{echo|[[Category:Foo]] and this should be part of the same list item}}
16164 !! html
16165 <ul><li>This and this should be part of the same list item</li>
16166 <li>So should this and this should be part of the same list item</li></ul>
16167 !! html/parsoid
16168 <ul>
16169 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
16170 <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>
16171 </ul>
16172 !! end
16173
16174 ## Newlines and categories that follow the last item of a list
16175 ## are treated differently because this (list followed by categories)
16176 ## is an extremely common pattern on wikis.
16177 !! test
16178 3. Categories and newlines: newline suppression for last list item should RT properly
16179 !! wikitext
16180 * a
16181 * b
16182
16183 [[Category:Foo]]
16184
16185 [[Category:Bar]]
16186 [[Category:Baz]]
16187 !! html/parsoid
16188 <ul><li> a</li>
16189 <li> b</li></ul>
16190
16191 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16192
16193 <link rel="mw:PageProp/Category" href="./Category:Bar" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16194 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16195 !! end
16196
16197 !! test
16198 4. Categories and newlines: newline suppression for last list item should RT properly
16199 !! wikitext
16200 * a
16201 **** b
16202
16203 [[Category:Foo]]
16204 !! html/parsoid
16205 <ul><li> a
16206 <ul><li><ul><li><ul><li> b</li></ul></li></ul></li></ul></li></ul>
16207
16208 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16209 !! end
16210
16211 ## only wt2html for this to make sure the algo only applies to the rightmost path
16212 !! test
16213 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
16214 !! options
16215 parsoid=wt2html
16216 !! wikitext
16217 * a
16218 ** b
16219 [[Category:Foo]]
16220 * c
16221 ** d
16222 [[Category:Foo]]
16223 !! html/parsoid
16224 <ul><li> a
16225 <ul><li> b
16226 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
16227 <li> c
16228 <ul><li> d</li></ul></li></ul>
16229 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
16230 !! end
16231
16232 ## We used to, but no longer wt2wt this test since the default serializer
16233 ## will normalize all categories to serialize on their own line.
16234 ## This wikitext usage is going to be fairly uncommon in production and
16235 ## selser will take care of preserving formatting in those scenarios.
16236 !! test
16237 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
16238 !! options
16239 parsoid=wt2html
16240 !! wikitext
16241 * a [[Category:Foo]]
16242 !! html/parsoid
16243 <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>
16244 !! end
16245
16246 # This test also demonstrates because of newline+category tunneling
16247 # through the list hander, template wrapping doesn't expand to the
16248 # containing list when the list item swallows the category.
16249 !! test
16250 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
16251 !! wikitext
16252 * {{echo|a
16253 [[Category:Foo]]}}
16254 !! html/parsoid
16255 <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
16256 </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>
16257 !! end
16258
16259 !! test
16260 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
16261 !! wikitext
16262 * a
16263
16264 {{echo|[[Category:Foo]]
16265 [[Category:Bar]]}}
16266 [[Category:Baz]]
16267 !! html/parsoid
16268 <ul><li> a</li></ul>
16269
16270 <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">
16271 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
16272 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
16273 !! end
16274
16275 !! test
16276 9. Categories and newlines: should behave properly with linkprefix (T87753)
16277 !! options
16278 language=ar
16279 !! wikitext
16280 foo bar
16281 foo bar
16282 [[تصنيف:Foo]]
16283 [[تصنيف:Bar]]
16284 !! html/php
16285 <p>foo bar
16286 foo bar
16287 </p>
16288 !! html/parsoid
16289 <p>foo bar
16290 foo bar</p>
16291 <link rel="mw:PageProp/Category" href="./تصنيف:Foo"/>
16292 <link rel="mw:PageProp/Category" href="./تصنيف:Bar"/>
16293 !! end
16294
16295 !! test
16296 10. No regressions on internal links following category (T174639)
16297 !! options
16298 parsoid=wt2html,html2html
16299 !! wikitext
16300 [[Category:Foo]]<div>a
16301
16302 [[Foo]]</div>
16303 !! html/php
16304 <div>a
16305 <a href="/wiki/Foo" title="Foo">Foo</a></div>
16306
16307 !! html/parsoid
16308 <link rel="mw:PageProp/Category" href="./Category:Foo"/><div>a
16309
16310 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></div>
16311 !! end
16312
16313 # Note that Parsoid differs slightly from PHP due to T175421
16314 !! test
16315 11. Special case where only newlines separate links (T175416)
16316 !! options
16317 parsoid=wt2html,html2html
16318 !! wikitext
16319 [[Category:Foo]]
16320
16321 [[Foo]][[es:Alimento]]
16322
16323 [[Foo]]
16324 !! html/php
16325 <p><br />
16326 <a href="/wiki/Foo" title="Foo">Foo</a>
16327 </p><p><a href="/wiki/Foo" title="Foo">Foo</a>
16328 </p>
16329 !! html/parsoid
16330 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
16331
16332 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p><link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16333
16334 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a></p>
16335 !! end
16336
16337 !! test
16338 Category links with multiple namespaces
16339 !! wikitext
16340 [[Category:Project:Foo]]
16341 !! html/parsoid
16342 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
16343 !! end
16344
16345 !! test
16346 Parsoid: Serialize link to category page with colon escape
16347 !! options
16348 parsoid
16349 !! wikitext
16350
16351 [[:Category:Foo]]
16352 [[:Category:Foo|Bar]]
16353 !! html
16354 <p>
16355 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
16356 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
16357 </p>
16358 !! end
16359
16360 # We used to, but no longer wt2wt this test since the default serializer
16361 # will normalize all categories to serialize on their own line.
16362 # This wikitext usage is going to be fairly uncommon in production and
16363 # selser will take care of preventing whitespace insertion if this
16364 # occurs in an article.
16365 #
16366 # html2html disabled for the same reason (whitespace insertion between
16367 # x and y).
16368 #
16369 # html2wt disabled because it localizes the "Category" namespace.
16370 !! test
16371 Link prefix/suffixes aren't applied to category links
16372 !! options
16373 parsoid=wt2html
16374 language=is
16375 !! wikitext
16376 x[[Category:Foo]]y
16377 !! html/php
16378 <p>xy
16379 </p>
16380 !! html/parsoid
16381 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
16382 !! end
16383
16384 !! test
16385 Link prefix/suffixes aren't applied to language links
16386 !! options
16387 parsoid=wt2html
16388 language=is
16389 !! wikitext
16390 x[[es:Foo]]y
16391 !! html/php
16392 <p>xy
16393 </p>
16394 !! html/parsoid
16395 <p>x<link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo" data-parsoid=""/>y</p>
16396 !! end
16397
16398 !! test
16399 Parsoid: Serialize link to file page with colon escape
16400 !! options
16401 parsoid
16402 !! wikitext
16403
16404 [[:File:Foo.png]]
16405 [[:File:Foo.png|Bar]]
16406 !! html
16407 <p>
16408 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
16409 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
16410 </p>
16411 !! end
16412
16413 !! test
16414 Parsoid: Serialize a genuine category link without colon escape
16415 !! options
16416 parsoid
16417 !! wikitext
16418 [[Category:Foo]]
16419 [[Category:Foo|Bar]]
16420 !! html
16421 <link rel="mw:PageProp/Category" href="./Category:Foo">
16422 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
16423 !! end
16424
16425 !! test
16426 Normalize hrefs properly before testing for invalid link targets (T72894)
16427 !! options
16428 parsoid=html2wt
16429 !! html/parsoid
16430 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
16431 !! wikitext
16432 [[Category:Toxine bactérienne]]
16433 !! end
16434
16435 !! test
16436 Parsoid: Defaultsort
16437 !! wikitext
16438 {{DEFAULTSORT:Foo}}
16439 !! html/parsoid
16440 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
16441 !! end
16442
16443 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
16444 # But, this is a limitation of our representation and is documented in
16445 # TemplateHandler.js in processSpecialMagicWord
16446 !! test
16447 Parsoid: Defaultsort (template-generated)
16448 !! wikitext
16449 {{{{echo|DEFAULTSORT}}:Foo}}
16450 !! html/parsoid
16451 <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"}]]}'/>
16452 !! end
16453
16454 ###
16455 ### Inter-language links
16456 ###
16457 !! test
16458 Interlanguage links
16459 !! options
16460 ill
16461 !! wikitext
16462 [[es:Alimento]]
16463 [[fr:Nourriture]]
16464 [[zh:食品]]
16465 !! html/php
16466 es:Alimento fr:Nourriture zh:食品
16467 !! html/parsoid
16468 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
16469 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
16470 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
16471 !! end
16472
16473 !! test
16474 Duplicate interlanguage links (T26502)
16475 !! options
16476 ill
16477 !! wikitext
16478 [[es:1]]
16479 [[es:2]]
16480 [[fr:1]]
16481 [[fr:2]]
16482 !! html/php
16483 es:1 fr:1
16484 !! html/parsoid
16485 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
16486 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
16487 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
16488 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
16489 !! end
16490
16491 ###
16492 ### Sections
16493 ###
16494 !! test
16495 Basic section headings
16496 !! wikitext
16497 == Headline 1 ==
16498 Some text
16499
16500 ==Headline 2==
16501 More
16502 ===Smaller headline===
16503 Blah blah
16504 !! html
16505 <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>
16506 <p>Some text
16507 </p>
16508 <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>
16509 <p>More
16510 </p>
16511 <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>
16512 <p>Blah blah
16513 </p>
16514 !! end
16515
16516 !! test
16517 Section headings with TOC
16518 !! wikitext
16519 == Headline 1 ==
16520 === Subheadline 1 ===
16521 ===== Skipping a level =====
16522 ====== Skipping a level ======
16523
16524 == Headline 2 ==
16525 Some text
16526 ===Another headline===
16527 !! html
16528 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16529 <ul>
16530 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
16531 <ul>
16532 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
16533 <ul>
16534 <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>
16535 <ul>
16536 <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>
16537 </ul>
16538 </li>
16539 </ul>
16540 </li>
16541 </ul>
16542 </li>
16543 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
16544 <ul>
16545 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
16546 </ul>
16547 </li>
16548 </ul>
16549 </div>
16550
16551 <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>
16552 <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>
16553 <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>
16554 <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>
16555 <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>
16556 <p>Some text
16557 </p>
16558 <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>
16559
16560 !! end
16561
16562 !! test
16563 TOC anchors don't collide
16564 !! wikitext
16565 __FORCETOC__
16566 == Headline 2 ==
16567 == Headline ==
16568 == Headline 2 ==
16569 == Headline ==
16570 !! html/php
16571 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16572 <ul>
16573 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
16574 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
16575 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
16576 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
16577 </ul>
16578 </div>
16579
16580 <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>
16581 <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>
16582 <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>
16583 <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>
16584
16585 !! end
16586
16587 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
16588 !! test
16589 Handling of sections up to level 6 and beyond
16590 !! wikitext
16591 = Level 1 Heading=
16592 == Level 2 Heading==
16593 === Level 3 Heading===
16594 ==== Level 4 Heading====
16595 ===== Level 5 Heading=====
16596 ====== Level 6 Heading======
16597 ======= Level 7 Heading=======
16598 ======== Level 8 Heading========
16599 ========= Level 9 Heading=========
16600 ========== Level 10 Heading==========
16601 !! html
16602 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16603 <ul>
16604 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
16605 <ul>
16606 <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>
16607 <ul>
16608 <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>
16609 <ul>
16610 <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>
16611 <ul>
16612 <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>
16613 <ul>
16614 <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>
16615 <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>
16616 <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>
16617 <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>
16618 <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>
16619 </ul>
16620 </li>
16621 </ul>
16622 </li>
16623 </ul>
16624 </li>
16625 </ul>
16626 </li>
16627 </ul>
16628 </li>
16629 </ul>
16630 </div>
16631
16632 <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>
16633 <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>
16634 <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>
16635 <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>
16636 <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>
16637 <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>
16638 <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>
16639 <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>
16640 <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>
16641 <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>
16642
16643 !! end
16644
16645 !! test
16646 TOC regression (T11764)
16647 !! wikitext
16648 == title 1 ==
16649 === title 1.1 ===
16650 ==== title 1.1.1 ====
16651 === title 1.2 ===
16652 == title 2 ==
16653 === title 2.1 ===
16654 !! html
16655 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16656 <ul>
16657 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16658 <ul>
16659 <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>
16660 <ul>
16661 <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>
16662 </ul>
16663 </li>
16664 <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>
16665 </ul>
16666 </li>
16667 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16668 <ul>
16669 <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>
16670 </ul>
16671 </li>
16672 </ul>
16673 </div>
16674
16675 <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>
16676 <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>
16677 <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>
16678 <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>
16679 <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>
16680 <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>
16681
16682 !! end
16683
16684 !! test
16685 TOC for heading containing <span id="..."></span> (T96153)
16686 !! wikitext
16687 __FORCETOC__
16688 ==<span id="old-anchor"></span>New title==
16689 !! html/php
16690 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16691 <ul>
16692 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
16693 </ul>
16694 </div>
16695
16696 <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>
16697
16698 !! end
16699
16700 !! test
16701 TOC with wgMaxTocLevel=3 (T8204)
16702 !! options
16703 wgMaxTocLevel=3
16704 !! wikitext
16705 == title 1 ==
16706 === title 1.1 ===
16707 ==== title 1.1.1 ====
16708 === title 1.2 ===
16709 == title 2 ==
16710 === title 2.1 ===
16711 !! html
16712 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16713 <ul>
16714 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16715 <ul>
16716 <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>
16717 <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>
16718 </ul>
16719 </li>
16720 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16721 <ul>
16722 <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>
16723 </ul>
16724 </li>
16725 </ul>
16726 </div>
16727
16728 <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>
16729 <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>
16730 <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>
16731 <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>
16732 <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>
16733 <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>
16734
16735 !! end
16736
16737 !! test
16738 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
16739 !! options
16740 wgMaxTocLevel=3
16741 !! wikitext
16742 ==Section 1==
16743 ===Section 1.1===
16744 ====Section 1.1.1====
16745 ====Section 1.1.1.1====
16746 ==Section 2==
16747 !! html
16748 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16749 <ul>
16750 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
16751 <ul>
16752 <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>
16753 </ul>
16754 </li>
16755 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
16756 </ul>
16757 </div>
16758
16759 <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>
16760 <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>
16761 <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>
16762 <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>
16763 <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>
16764
16765 !! end
16766
16767
16768 !! test
16769 Resolving duplicate section names
16770 !! wikitext
16771 == Foo bar ==
16772 == Foo bar ==
16773 !! html
16774 <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>
16775 <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>
16776
16777 !! end
16778
16779 !! test
16780 Resolving duplicate section names with differing case (T12721)
16781 !! wikitext
16782 == Foo bar ==
16783 == Foo Bar ==
16784 !! html
16785 <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>
16786 <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>
16787
16788 !! end
16789
16790 !! article
16791 Template:sections
16792 !! text
16793 ===Section 1===
16794 ==Section 2==
16795 !! endarticle
16796
16797 !! test
16798 Template with sections, __NOTOC__
16799 !! wikitext
16800 __NOTOC__
16801 ==Section 0==
16802 {{sections}}
16803 ==Section 4==
16804 !! html
16805 <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>
16806 <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>
16807 <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>
16808 <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>
16809
16810 !! end
16811
16812 !! test
16813 __NOEDITSECTION__ keyword
16814 !! wikitext
16815 __NOEDITSECTION__
16816 ==Section 1==
16817 ==Section 2==
16818 !! html
16819 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
16820 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
16821
16822 !! end
16823
16824 !! test
16825 Link inside a section heading
16826 !! wikitext
16827 ==Section with a [[Main Page|link]] in it==
16828 !! html
16829 <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>
16830
16831 !! end
16832
16833 !! test
16834 TOC regression (T14077)
16835 !! wikitext
16836 __TOC__
16837 == title 1 ==
16838 === title 1.1 ===
16839 == title 2 ==
16840 !! html
16841 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16842 <ul>
16843 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16844 <ul>
16845 <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>
16846 </ul>
16847 </li>
16848 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
16849 </ul>
16850 </div>
16851
16852 <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>
16853 <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>
16854 <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>
16855
16856 !! end
16857
16858 !! test
16859 T3219 URL next to image (good)
16860 !! wikitext
16861 http://example.com [[File:Foobar.jpg]]
16862 !! html/php
16863 <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>
16864 </p>
16865 !! html/parsoid
16866 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> <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>
16867 !!end
16868
16869 !! test
16870 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
16871 !! wikitext
16872 ===
16873 The line above must have a trailing space!
16874 === <!--
16875 --> <!-- -->
16876 But just in case it doesn't...
16877 !! html
16878 <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>
16879 <p>The line above must have a trailing space!
16880 </p>
16881 <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>
16882 <p>But just in case it doesn't...
16883 </p>
16884 !! end
16885
16886 !! test
16887 Header with special characters (T27462)
16888 !! wikitext
16889 The tooltips shall not show entities to the user (ie. be double escaped)
16890
16891 == text > text ==
16892 section 1
16893
16894 == text < text ==
16895 section 2
16896
16897 == text & text ==
16898 section 3
16899
16900 == text ' text ==
16901 section 4
16902
16903 == text " text ==
16904 section 5
16905 !! html
16906 <p>The tooltips shall not show entities to the user (ie. be double escaped)
16907 </p>
16908 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16909 <ul>
16910 <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>
16911 <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>
16912 <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>
16913 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
16914 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
16915 </ul>
16916 </div>
16917
16918 <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>
16919 <p>section 1
16920 </p>
16921 <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>
16922 <p>section 2
16923 </p>
16924 <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>
16925 <p>section 3
16926 </p>
16927 <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>
16928 <p>section 4
16929 </p>
16930 <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>
16931 <p>section 5
16932 </p>
16933 !! end
16934
16935 !! test
16936 Header with space, plus and underscore as entity
16937 !! wikitext
16938 Id should not contain + for spaces
16939
16940 == Space between Text ==
16941 section 1
16942
16943 == Space-Entity&#32;between&#32;Text ==
16944 section 2
16945
16946 == Plus+between+Text ==
16947 section 3
16948
16949 == Plus-Entity&#43;between&#43;Text ==
16950 section 4
16951
16952 == Underscore_between_Text ==
16953 section 5
16954
16955 == Underscore-Entity&#95;between&#95;Text ==
16956 section 6
16957
16958 [[#Space between Text]]
16959 [[#Space-Entity&#32;between&#32;Text]]
16960 [[#Plus+between+Text]]
16961 [[#Plus-Entity&#43;between&#43;Text]]
16962 [[#Underscore_between_Text]]
16963 [[#Underscore-Entity&#95;between&#95;Text]]
16964 !! html
16965 <p>Id should not contain + for spaces
16966 </p>
16967 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16968 <ul>
16969 <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>
16970 <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>
16971 <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>
16972 <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>
16973 <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>
16974 <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>
16975 </ul>
16976 </div>
16977
16978 <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>
16979 <p>section 1
16980 </p>
16981 <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>
16982 <p>section 2
16983 </p>
16984 <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>
16985 <p>section 3
16986 </p>
16987 <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>
16988 <p>section 4
16989 </p>
16990 <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>
16991 <p>section 5
16992 </p>
16993 <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>
16994 <p>section 6
16995 </p><p><a href="#Space_between_Text">#Space between Text</a>
16996 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
16997 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
16998 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
16999 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
17000 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
17001 </p>
17002 !! end
17003
17004 !! test
17005 Headers with excess '=' characters
17006 (Are similar tests necessary beyond the 1st level?)
17007 !! wikitext
17008 =foo==
17009 ==foo=
17010 =''italic'' heading==
17011 ==''italic'' heading=
17012 !! html
17013 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
17014 <ul>
17015 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
17016 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
17017 <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>
17018 <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>
17019 </ul>
17020 </div>
17021
17022 <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>
17023 <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>
17024 <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>
17025 <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>
17026
17027 !! end
17028
17029 !! test
17030 HTML headers vs TOC (T25393)
17031 (__NOEDITSECTION__ for clearer output, doesn't matter here)
17032 !! wikitext
17033 <h1>Header 1</h1>
17034 == Header 1.1 ==
17035 == Header 1.2 ==
17036
17037 <h1>Header 2
17038 </h1>
17039 == Header 2.1 ==
17040 == Header 2.2 ==
17041 __NOEDITSECTION__
17042 !! html
17043 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
17044 <ul>
17045 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
17046 <ul>
17047 <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>
17048 <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>
17049 </ul>
17050 </li>
17051 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
17052 <ul>
17053 <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>
17054 <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>
17055 </ul>
17056 </li>
17057 </ul>
17058 </div>
17059
17060 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
17061 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
17062 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
17063 <h1><span class="mw-headline" id="Header_2">Header 2</span></h1>
17064 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
17065 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
17066
17067 !! end
17068
17069 !! test
17070 Single-line or multiline-comments can follow headings
17071 !! options
17072 parsoid=wt2html,wt2wt
17073 !! wikitext
17074 ==foo==<!---->
17075 ==bar==<!--c1-->
17076 ==baz==<!--
17077 c2
17078 c3-->
17079 !! html
17080 <h2><span class="mw-headline" id="foo">foo</span></h2>
17081 <h2><span class="mw-headline" id="bar">bar</span></h2>
17082 <h2><span class="mw-headline" id="baz">baz</span></h2>
17083
17084 !! end
17085
17086 !! test
17087 T3219 URL next to image (broken)
17088 !! wikitext
17089 http://example.com[[File:Foobar.jpg]]
17090 !! html/php
17091 <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>
17092 </p>
17093 !! html/parsoid
17094 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a><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>
17095 !!end
17096
17097 !! test
17098 T3186 news: in the middle of text
17099 !! wikitext
17100 http://en.wikinews.org/wiki/Wikinews:Workplace
17101 !! html
17102 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
17103 </p>
17104 !!end
17105
17106
17107 !! test
17108 Namespaced link must have a title
17109 !! wikitext
17110 [[Project:]]
17111 !! html
17112 <p>[[Project:]]
17113 </p>
17114 !!end
17115
17116 !! test
17117 Namespaced link must have a title (bad fragment version)
17118 !! wikitext
17119 [[Project:#fragment]]
17120 !! html
17121 <p>[[Project:#fragment]]
17122 </p>
17123 !!end
17124
17125
17126 ###
17127 ### HTML tags and HTML attributes
17128 ###
17129
17130 !! test
17131 div with no attributes
17132 !! wikitext
17133 <div>HTML rocks</div>
17134 !! html
17135 <div>HTML rocks</div>
17136
17137 !! end
17138
17139 !! test
17140 div with double-quoted attribute
17141 !! wikitext
17142 <div id="rock">HTML rocks</div>
17143 !! html
17144 <div id="rock">HTML rocks</div>
17145
17146 !! end
17147
17148 !! test
17149 div with single-quoted attribute
17150 !! wikitext
17151 <div id='rock'>HTML rocks</div>
17152 !! html
17153 <div id="rock">HTML rocks</div>
17154
17155 !! end
17156
17157 !! test
17158 div with unquoted attribute
17159 !! wikitext
17160 <div id=rock>HTML rocks</div>
17161 !! html
17162 <div id="rock">HTML rocks</div>
17163
17164 !! end
17165
17166 !! test
17167 div with illegal double attributes
17168 !! wikitext
17169 <div id="a" id="b">HTML rocks</div>
17170 !! html
17171 <div id="b">HTML rocks</div>
17172
17173 !!end
17174
17175 !! test
17176 div with empty attribute value, space before equals
17177 !! options
17178 parsoid=wt2html,html2html
17179 !! wikitext
17180 <div class =>HTML rocks</div>
17181 !! html/php
17182 <div class="">HTML rocks</div>
17183
17184 !! html/parsoid
17185 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17186 !! end
17187
17188 !! test
17189 div with multiple empty attribute values
17190 !! options
17191 parsoid=wt2html,html2html
17192 !! wikitext
17193 <div id= title=>HTML rocks</div>
17194 !! html/php
17195 <div id="title.3D">HTML rocks</div>
17196
17197 !! html/parsoid
17198 <div id="title.3D" data-parsoid='{"stx":"html"}'>HTML rocks</div>
17199 !! end
17200
17201 !! test
17202 table with multiple empty attribute values
17203 !! options
17204 parsoid=wt2html,html2html
17205 !! wikitext
17206 {| title= id=
17207 | hi
17208 |}
17209 !! html/php
17210 <table title="id=">
17211 <tr>
17212 <td> hi
17213 </td></tr></table>
17214
17215 !! html/parsoid
17216 <table title="id=">
17217 <tbody><tr><td> hi</td></tr>
17218 </tbody></table>
17219 !! end
17220
17221 !! test
17222 div with braces in attribute value
17223 !! wikitext
17224 <div title="{}">Foo</div>
17225 !! html/php
17226 <div title="&#123;&#125;">Foo</div>
17227
17228 !! html/parsoid
17229 <div title="{}">Foo</div>
17230 !! end
17231
17232 !! test
17233 div with empty attribute value, no space before equals
17234 !! options
17235 parsoid=wt2html,html2html
17236 !! wikitext
17237 <div class=>HTML rocks</div>
17238 !! html/php
17239 <div class="">HTML rocks</div>
17240
17241 !! html/parsoid
17242 <div class="">HTML rocks</div>
17243 !! end
17244
17245 !! test
17246 HTML multiple attributes correction
17247 !! wikitext
17248 <p class="error" class="awesome">Awesome!</p>
17249 !! html
17250 <p class="awesome">Awesome!</p>
17251
17252 !!end
17253
17254 !! test
17255 Table multiple attributes correction
17256 !! wikitext
17257 {|
17258 !+ class="error" class="awesome"| status
17259 |}
17260 !! html
17261 <table>
17262 <tr>
17263 <th class="awesome"> status
17264 </th></tr></table>
17265
17266 !!end
17267
17268 !! test
17269 DIV IN UPPERCASE
17270 !! wikitext
17271 <DIV ID="x">HTML ROCKS</DIV>
17272 !! html
17273 <div id="x">HTML ROCKS</div>
17274
17275 !!end
17276
17277 !! test
17278 Non-ASCII pseudo-tags are rendered as text
17279 !! wikitext
17280 <khyô>
17281 !! html
17282 <p>&lt;khyô&gt;
17283 </p>
17284 !! end
17285
17286 !! test
17287 Pseudo-tag with URL 'name' renders as url link
17288 !! wikitext
17289 <http://example.com/>
17290 !! html
17291 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
17292 </p>
17293 !! end
17294
17295 !! test
17296 text with amp in the middle of nowhere
17297 !! wikitext
17298 Remember AT&T?
17299 !! html
17300 <p>Remember AT&amp;T?
17301 </p>
17302 !! end
17303
17304 !! test
17305 text with character entity: eacute
17306 !! wikitext
17307 I always thought &eacute; was a cute letter.
17308 !! html
17309 <p>I always thought &#233; was a cute letter.
17310 </p>
17311 !! html+tidy
17312 <p>I always thought é was a cute letter.</p>
17313 !! end
17314
17315 !! test
17316 text with entity-escaped character entity-like string: eacute
17317 !! wikitext
17318 I always thought &amp;eacute; was a cute letter.
17319 !! html
17320 <p>I always thought &amp;eacute; was a cute letter.
17321 </p>
17322 !! end
17323
17324 !! test
17325 text with undefined character entity: xacute
17326 !! wikitext
17327 I always thought &xacute; was a cute letter.
17328 !! html
17329 <p>I always thought &amp;xacute; was a cute letter.
17330 </p>
17331 !! end
17332
17333 !! test
17334 HTML5 tags
17335 !! wikitext
17336 <data value="5">five</data>
17337 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17338 <mark>This highlighted text</mark>
17339 !! html
17340 <p><data value="5">five</data>
17341 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
17342 <mark>This highlighted text</mark>
17343 </p>
17344 !! end
17345
17346 !! test
17347 HTML tag with leading space is parsed as text
17348 !! wikitext
17349 < div>foo< /div>
17350 !! html
17351 <p>&lt; div&gt;foo&lt; /div&gt;
17352 </p>
17353 !! end
17354
17355 ## Don't expect Parsoid and PHP to match, since PHP isn't exactly following
17356 ## the HTML5 parsing spec.
17357 !! test
17358 Element with broken attribute syntax
17359 !! options
17360 parsoid=wt2html
17361 !! wikitext
17362 <div style=" style="123">hi</div>
17363 <div =>ho</div>
17364 !! html/php
17365 <div style="123">hi</div>
17366 <div>ho</div>
17367
17368 !! html/parsoid
17369 <div style=" style=" data-parsoid='{"stx":"html","a":{"123\"":null},"sa":{"123\"":""}}'>hi</div>
17370 <div data-parsoid='{"stx":"html","a":{"=":null},"sa":{"=":""}}'>ho</div>
17371 !! end
17372
17373 ###
17374 ### Nesting tests (see T43545, T52604, T53081)
17375 ###
17376
17377 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
17378 # Note that html2wt is considerably more difficult if we use <b> in
17379 # the test case, instead of <small>
17380 !! test
17381 Ensure that HTML adoption agency algorithm is properly implemented.
17382 !! wikitext
17383 <small>X<small>Y</small>Z</small>
17384 !! html
17385 <p><small>X<small>Y</small>Z</small>
17386 </p>
17387 !! end
17388
17389 # This was T43545 in the PHP parser.
17390 # Note that tidy doesn't handle this correctly.
17391 !! test
17392 Nesting of <kbd>
17393 !! wikitext
17394 <kbd>X<kbd>Y</kbd>Z</kbd>
17395 !! html
17396 <p><kbd>X<kbd>Y</kbd>Z</kbd>
17397 </p>
17398 !! end
17399
17400 # The following cases were T53081 in the PHP parser.
17401 # Note that there are some other nestable tags (b, i, etc) which are
17402 # not covered; see T53081 for discussion.
17403
17404 # Note that tidy doesn't handle this correctly.
17405 !! test
17406 Nesting of <em>
17407 !! wikitext
17408 <em>X<em>Y</em>Z</em>
17409 !! html
17410 <p><em>X<em>Y</em>Z</em>
17411 </p>
17412 !! end
17413
17414 # Note that tidy doesn't handle this correctly.
17415 !! test
17416 Nesting of <strong>
17417 !! wikitext
17418 <strong>X<strong>Y</strong>Z</strong>
17419 !! html
17420 <p><strong>X<strong>Y</strong>Z</strong>
17421 </p>
17422 !! end
17423
17424 !! test
17425 Nesting of <q>
17426 !! wikitext
17427 <q>X<q>Y</q>Z</q>
17428 !! html+tidy
17429 <p><q>X<q>Y</q>Z</q></p>
17430 !! end
17431
17432 # Note that tidy doesn't handle this correctly.
17433 !! test
17434 Nesting of <ruby>
17435 !! wikitext
17436 <ruby>X<ruby>Y</ruby>Z</ruby>
17437 !! html
17438 <p><ruby>X<ruby>Y</ruby>Z</ruby>
17439 </p>
17440 !! end
17441
17442 # Note that tidy doesn't handle this correctly.
17443 !! test
17444 Nesting of <bdo>
17445 !! wikitext
17446 <bdo>X<bdo>Y</bdo>Z</bdo>
17447 !! html
17448 <p><bdo>X<bdo>Y</bdo>Z</bdo>
17449 </p>
17450 !! end
17451
17452
17453 ###
17454 ### Media links
17455 ###
17456
17457 !! test
17458 Media link
17459 !! wikitext
17460 [[Media:Foobar.jpg]]
17461 [[Media:Video.ogv]]
17462 [[:Media:Video.ogv]]
17463 !! html/php
17464 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
17465 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17466 <a href="http://example.com/images/0/00/Video.ogv" class="internal" title="Video.ogv">Media:Video.ogv</a>
17467 </p>
17468 !! html/parsoid
17469 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a>
17470 <a rel="mw:MediaLink" href="//example.com/images/0/00/Video.ogv" title="Video.ogv">Media:Video.ogv</a>
17471 <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>
17472 !! end
17473
17474 !! test
17475 Media link with text
17476 !! wikitext
17477 [[Media:Foobar.jpg|A neat file to look at]]
17478 !! html/php
17479 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
17480 </p>
17481 !! html/parsoid
17482 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
17483 !! end
17484
17485 # FIXME: this is still bad HTML tag nesting
17486 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
17487 !! test
17488 Media link with nasty text
17489 !! wikitext
17490 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
17491 !! html/php
17492 <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>
17493
17494 !! html+php/tidy
17495 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link</a></p>
17496 <div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div>
17497 !! html/parsoid
17498 <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>
17499
17500 !! end
17501
17502 !! test
17503 Media link to nonexistent file (T3702)
17504 !! wikitext
17505 [[Media:No such.jpg]]
17506 [[Media:No_such file.jpg]]
17507 !! html/php
17508 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
17509 <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>
17510 </p>
17511 !! html/parsoid
17512 <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>
17513 <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>
17514 !! end
17515
17516 !! test
17517 Image link to nonexistent file (T3850 - good)
17518 !! wikitext
17519 [[File:No_such.jpg]]
17520 !! html/php
17521 <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>
17522 </p>
17523 !! html/parsoid
17524 <p><span 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></span></p>
17525 !! end
17526
17527 !! test
17528 :Image link to nonexistent file (T3850 - bad)
17529 !! wikitext
17530 [[:Image:No such.jpg]]
17531 !! html/php
17532 <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>
17533 </p>
17534 !! html/parsoid
17535 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
17536 !! end
17537
17538 !! test
17539 Character reference normalization in link text (T3938)
17540 !! wikitext
17541 [[Main Page|this&that]]
17542 !! html
17543 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
17544 </p>
17545 !!end
17546
17547 !! article
17548 אַ
17549 !! text
17550 Test for unicode normalization
17551
17552 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
17553 !! endarticle
17554
17555 !! test
17556 (T21451) Links should refer to the normalized form.
17557 !! wikitext
17558 [[&#xFB2E;]]
17559 [[&#x5d0;&#x5b7;]]
17560 [[&#x5d0;ַ]]
17561 [[א&#x5b7;]]
17562 [[אַ]]
17563 !! html
17564 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
17565 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
17566 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
17567 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
17568 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
17569 </p>
17570 !! end
17571
17572 !! test
17573 Empty attribute crash test (T4067)
17574 !! wikitext
17575 <font color="">foo</font>
17576 !! html
17577 <p><font color="">foo</font>
17578 </p>
17579 !! end
17580
17581 !! test
17582 Empty attribute crash test single-quotes (T4067)
17583 !! wikitext
17584 <font color=''>foo</font>
17585 !! html
17586 <p><font color="">foo</font>
17587 </p>
17588 !! end
17589
17590 !! test
17591 Attribute test: equals, then nothing
17592 !! options
17593 parsoid=wt2html,html2html
17594 !! wikitext
17595 <font color=>foo</font>
17596 !! html/php
17597 <p><font color="">foo</font>
17598 </p>
17599 !! html/parsoid
17600 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
17601 !! end
17602
17603 !! test
17604 Attribute test: unquoted value
17605 !! options
17606 parsoid=wt2html,html2html
17607 !! wikitext
17608 <font color=x>foo</font>
17609 !! html/php
17610 <p><font color="x">foo</font>
17611 </p>
17612 !! html/parsoid
17613 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
17614 !! end
17615
17616 !! test
17617 Attribute test: unquoted but illegal value (hash)
17618 !! wikitext
17619 <font color=#x>foo</font>
17620 !! html
17621 <p><font color="#x">foo</font>
17622 </p>
17623 !! end
17624
17625 # Parsoid does not serialize to empty attribute syntax,
17626 # so wt2wt and html2wt cases are skipped
17627 !! test
17628 Attribute test: no value (T54330)
17629 !! options
17630 parsoid=wt2html,html2html
17631 !! wikitext
17632 <font color>foo</font>
17633 !! html/php
17634 <p><font color="">foo</font>
17635 </p>
17636 !! html/parsoid
17637 <p><font color="">foo</font></p>
17638 !! end
17639
17640 !! test
17641 T4095: link with three closing brackets
17642 !! wikitext
17643 [[Main Page]]]
17644 !! html/php
17645 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
17646 </p>
17647 !! html/parsoid
17648 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
17649 !! end
17650
17651 !! test
17652 T4095: link with pipe and three closing brackets
17653 !! wikitext
17654 [[Main Page|link]]]
17655 !! html/php
17656 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
17657 </p>
17658 !! html/parsoid
17659 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
17660 !! end
17661
17662 !! test
17663 T4095: link with pipe and three closing brackets, version 2
17664 !! wikitext
17665 [[Main Page|[http://example.com/]]]
17666 !! html/php
17667 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
17668 </p>
17669 !! html/parsoid
17670 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
17671 !! end
17672
17673
17674 ###
17675 ### Safety
17676 ###
17677
17678 !! article
17679 Template:Dangerous attribute
17680 !! text
17681 " onmouseover="alert(document.cookie)
17682 !! endarticle
17683
17684 !! article
17685 Template:Dangerous style attribute
17686 !! text
17687 border-size: expression(alert(document.cookie))
17688 !! endarticle
17689
17690 !! article
17691 Template:Div style
17692 !! text
17693 <div style="float: right; {{{1}}}">Magic div</div>
17694 !! endarticle
17695
17696 !! test
17697 T4304: HTML attribute safety (safe template; regression T4309)
17698 !! wikitext
17699 <div title="{{test}}"></div>
17700 !! html/php
17701 <div title="This is a test template"></div>
17702
17703 !! html/parsoid
17704 <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>
17705 !! end
17706
17707 # Parsoid has enough context to handle this case
17708 !! test
17709 T4304: HTML attribute safety (dangerous template; 2309)
17710 !! wikitext
17711 <div title="{{dangerous attribute}}"></div>
17712 !! html/php
17713 <div title=""></div>
17714
17715 !! html/parsoid
17716 <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>
17717 !! end
17718
17719 !! test
17720 T4304: HTML attribute safety (dangerous style template; 2309)
17721 !! wikitext
17722 <div style="{{dangerous style attribute}}"></div>
17723 !! html/php
17724 <div style="/* insecure input */"></div>
17725
17726 !! html/parsoid
17727 <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>
17728 !! end
17729
17730 !! test
17731 T4304: HTML attribute safety (safe parameter; 2309)
17732 !! wikitext
17733 {{div style|width: 200px}}
17734 !! html/php
17735 <div style="float: right; width: 200px">Magic div</div>
17736
17737 !! html/parsoid
17738 <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>
17739 !! end
17740
17741 !! test
17742 T4304: HTML attribute safety (unsafe parameter; 2309)
17743 !! wikitext
17744 {{div style|width: expression(alert(document.cookie))}}
17745 !! html/php
17746 <div style="/* insecure input */">Magic div</div>
17747
17748 !! html/parsoid
17749 <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>
17750 !! end
17751
17752 ## Parsoid output here differs; needs investigation.
17753 !! test
17754 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
17755 !! wikitext
17756 {{div style|"><script>alert(document.cookie)</script>}}
17757 !! html
17758 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17759
17760 !! end
17761
17762 ## Parsoid output here differs; needs investigation.
17763 !! test
17764 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
17765 !! wikitext
17766 {{div style|" ><script>alert(document.cookie)</script>}}
17767 !! html
17768 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17769
17770 !! end
17771
17772 !! test
17773 T4304: HTML attribute safety (link)
17774 !! wikitext
17775 <div title="[[Main Page]]"></div>
17776 !! html
17777 <div title="&#91;&#91;Main Page&#93;&#93;"></div>
17778
17779 !! end
17780
17781 !! test
17782 T4304: HTML attribute safety (italics)
17783 !! wikitext
17784 <div title="''foobar''"></div>
17785 !! html
17786 <div title="&#39;&#39;foobar&#39;&#39;"></div>
17787
17788 !! end
17789
17790 !! test
17791 T4304: HTML attribute safety (bold)
17792 !! wikitext
17793 <div title="'''foobar'''"></div>
17794 !! html
17795 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
17796
17797 !! end
17798
17799 !! test
17800 T4304: HTML attribute safety (ISBN)
17801 !! wikitext
17802 <div title="ISBN 1234567890"></div>
17803 !! html
17804 <div title="&#73;SBN 1234567890"></div>
17805
17806 !! end
17807
17808 !! test
17809 T4304: HTML attribute safety (RFC)
17810 !! wikitext
17811 <div title="RFC 1234"></div>
17812 !! html
17813 <div title="&#82;FC 1234"></div>
17814
17815 !! end
17816
17817 !! test
17818 T4304: HTML attribute safety (PMID)
17819 !! wikitext
17820 <div title="PMID 1234567890"></div>
17821 !! html
17822 <div title="&#80;MID 1234567890"></div>
17823
17824 !! end
17825
17826 !! test
17827 T4304: HTML attribute safety (web link)
17828 !! wikitext
17829 <div title="http://example.com/"></div>
17830 !! html
17831 <div title="http&#58;//example.com/"></div>
17832
17833 !! end
17834
17835 !! test
17836 T4304: HTML attribute safety (named web link)
17837 !! wikitext
17838 <div title="[http://example.com/ link]"></div>
17839 !! html
17840 <div title="&#91;http&#58;//example.com/ link&#93;"></div>
17841
17842 !! end
17843
17844 !! test
17845 T5244: HTML attribute safety (extension; safe)
17846 !! wikitext
17847 <div style="<nowiki>background:blue</nowiki>"></div>
17848 !! html/php
17849 <div style="background:blue"></div>
17850
17851 !! html/parsoid
17852 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
17853 !! end
17854
17855 !! test
17856 T5244: HTML attribute safety (extension; unsafe)
17857 !! wikitext
17858 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
17859 !! html/php
17860 <div style="/* insecure input */"></div>
17861
17862 !! html/parsoid
17863 <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>
17864 !! end
17865
17866 # More MSIE fun discovered by Tom Gilder
17867
17868 !! test
17869 MSIE CSS safety test: spurious slash
17870 !! wikitext
17871 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
17872 !! html/php
17873 <div style="/* insecure input */">evil</div>
17874
17875 !! html/parsoid
17876 <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>
17877 !! end
17878
17879 !! test
17880 MSIE CSS safety test: hex code
17881 !! wikitext
17882 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
17883 !! html/php
17884 <div style="/* insecure input */">evil</div>
17885
17886 !! html/parsoid
17887 <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>
17888 !! end
17889
17890 !! test
17891 MSIE CSS safety test: comment in url
17892 !! wikitext
17893 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
17894 !! html/php
17895 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
17896
17897 !! html/parsoid
17898 <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>
17899 !! end
17900
17901 !! test
17902 MSIE CSS safety test: comment in expression
17903 !! wikitext
17904 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
17905 !! html/php
17906 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
17907
17908 !! html/parsoid
17909 <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>
17910 !! end
17911
17912 !! test
17913 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
17914 !! wikitext
17915 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
17916 !! html/php
17917 <p style="/* invalid control char */">A</p>
17918
17919 !! html/parsoid
17920 <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>
17921 !! end
17922
17923 !! test
17924 MSIE 6 CSS safety test: Fullwidth (T57332)
17925 !! wikitext
17926 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
17927 <div style="top:EXPRESSION(alert())">B</div>
17928 !! html/php
17929 <p style="/* insecure input */">A</p>
17930 <div style="/* insecure input */">B</div>
17931
17932 !! html/parsoid
17933 <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>
17934 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
17935 !! end
17936
17937 !! test
17938 MSIE 6 CSS safety test: IPA extensions (T57332)
17939 !! wikitext
17940 <div style="background-image:uʀʟ(javascript:alert())">A</div>
17941 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
17942 !! html/php
17943 <div style="/* insecure input */">A</div>
17944 <p style="/* insecure input */">B</p>
17945
17946 !! html/parsoid
17947 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
17948 <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>
17949 !! end
17950
17951 !! test
17952 MSIE 6 CSS safety test: sup/sub script (T57332)
17953 !! wikitext
17954 <div style="background-image:url⁽javascript:alert())">A</div>
17955 <div style="background-image:url₍javascript:alert())">B</div>
17956 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
17957 !! html/php
17958 <div style="/* insecure input */">A</div>
17959 <div style="/* insecure input */">B</div>
17960 <p style="/* insecure input */">C</p>
17961
17962 !! html/parsoid
17963 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
17964 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
17965 <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>
17966 !! end
17967
17968 !! test
17969 Opera -o-link CSS
17970 !! options
17971 parsoid=wt2html,html2html
17972 !! wikitext
17973 <div
17974 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;"
17975 style="-o-link:attr(title);-o-link-source:current">X</div>
17976 !! html/php
17977 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
17978
17979 !! html/parsoid
17980 <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>
17981 !! end
17982
17983 !! test
17984 MSIE 6 CSS safety test: Repetition markers (T57332)
17985 !! wikitext
17986 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
17987 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
17988 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
17989 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
17990 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
17991 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
17992 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
17993 !! html/php
17994 <p style="/* insecure input */">A</p>
17995 <p style="/* insecure input */">B</p>
17996 <p style="/* insecure input */">C</p>
17997 <p style="/* insecure input */">D</p>
17998 <p style="/* insecure input */">E</p>
17999 <p style="/* insecure input */">F</p>
18000 <p style="/* insecure input */">G</p>
18001
18002 !! html/parsoid
18003 <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>
18004 <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>
18005 <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>
18006 <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>
18007 <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>
18008 <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>
18009 <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>
18010 !! end
18011
18012 !! test
18013 Table attribute legitimate extension
18014 !! wikitext
18015 {|
18016 !+ style="<nowiki>color:blue</nowiki>"| status
18017 |}
18018 !! html
18019 <table>
18020 <tr>
18021 <th style="color:blue"> status
18022 </th></tr></table>
18023
18024 !!end
18025
18026 !! test
18027 Table attribute safety
18028 !! wikitext
18029 {|
18030 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
18031 |}
18032 !! html
18033 <table>
18034 <tr>
18035 <th style="/* insecure input */"> status
18036 </th></tr></table>
18037
18038 !! end
18039
18040 !! test
18041 CSS line continuation 1
18042 !! wikitext
18043 <div style="background-image: u\&#10;rl(test.jpg);"></div>
18044 !! html
18045 <div style="/* insecure input */"></div>
18046
18047 !! end
18048
18049 !! test
18050 CSS line continuation 2
18051 !! wikitext
18052 <div style="background-image: u\&#13;rl(test.jpg); "></div>
18053 !! html
18054 <div style="/* invalid control char */"></div>
18055
18056 !! end
18057
18058 !! article
18059 Template:Identity
18060 !! text
18061 {{{1}}}
18062 !! endarticle
18063
18064 !! test
18065 Expansion of multi-line templates in attribute values (T8255)
18066 !! wikitext
18067 <div style="background: {{identity|#00FF00}}">-</div>
18068 !! html
18069 <div style="background: #00FF00">-</div>
18070
18071 !! end
18072
18073 !! test
18074 Expansion of multi-line templates in attribute values (T8255 sanity check)
18075 !! wikitext
18076 <div style="background:
18077 #00FF00">-</div>
18078 !! html/php
18079 <div style="background: #00FF00">-</div>
18080
18081 !! html/parsoid
18082 <div style="background:
18083 #00FF00">-</div>
18084 !! end
18085
18086 !! test
18087 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
18088 !! wikitext
18089 <div style="background: &#10;#00FF00">-</div>
18090 !! html
18091 <div style="background: &#10;#00FF00">-</div>
18092
18093 !! end
18094
18095 !! test
18096 Tags which are hidden from Tidy cannot pass through the Sanitizer
18097 !! wikitext
18098 <mw:toc><script>alert();</script></mw:toc>
18099 !! html+tidy
18100 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;</p>
18101 !! end
18102
18103 ###
18104 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
18105 ###
18106
18107 !! test
18108 Parser hook: empty input
18109 !! wikitext
18110 <tag></tag>
18111 !! html/php
18112 <pre>
18113 ''
18114 array (
18115 )
18116 </pre>
18117
18118 !! html/parsoid
18119 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18120 !! end
18121
18122 ## Don't expect parsoid to rt this form.
18123 !! test
18124 Parser hook: empty input using terminated empty elements
18125 !! options
18126 parsoid=wt2html,html2html
18127 !! wikitext
18128 <tag/>
18129 !! html/php
18130 <pre>
18131 NULL
18132 array (
18133 )
18134 </pre>
18135
18136 !! html/parsoid
18137 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18138 !! end
18139
18140 !! test
18141 Parser hook: empty input using terminated empty elements (space before)
18142 !! wikitext
18143 <tag />
18144 !! html/php
18145 <pre>
18146 NULL
18147 array (
18148 )
18149 </pre>
18150
18151 !! html/parsoid
18152 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
18153 !! end
18154
18155 !! test
18156 Parser hook: basic input
18157 !! wikitext
18158 <tag>input</tag>
18159 !! html/php
18160 <pre>
18161 'input'
18162 array (
18163 )
18164 </pre>
18165
18166 !! html/parsoid
18167 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18168 !! end
18169
18170 ## Don't expect parsoid to rt this form.
18171 !! test
18172 Parser hook: case insensitive
18173 !! options
18174 parsoid=wt2html,html2html
18175 !! wikitext
18176 <TAG>input</TAG>
18177 !! html/php
18178 <pre>
18179 'input'
18180 array (
18181 )
18182 </pre>
18183
18184 !! html/parsoid
18185 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18186 !! end
18187
18188 ## Don't expect parsoid to rt this form.
18189 !! test
18190 Parser hook: case insensitive, redux
18191 !! options
18192 parsoid=wt2html,html2html
18193 !! wikitext
18194 <TaG>input</TAg>
18195 !! html/php
18196 <pre>
18197 'input'
18198 array (
18199 )
18200 </pre>
18201
18202 !! html/parsoid
18203 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
18204 !! end
18205
18206 !! test
18207 Parser hook: nested tags
18208 !! wikitext
18209 <tag><tag></tag></tag>
18210 !! html/php
18211 <pre>
18212 '<tag>'
18213 array (
18214 )
18215 </pre>&lt;/tag&gt;
18216
18217 !! html/parsoid
18218 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}' data-parsoid='{}' about="#mwt2"></pre>&lt;/tag>
18219 !! end
18220
18221 !! test
18222 Parser hook: basic arguments
18223 !! wikitext
18224 <tag width="200" height="100" depth="50" square=""></tag>
18225 !! html/php
18226 <pre>
18227 ''
18228 array (
18229 'width' => '200',
18230 'height' => '100',
18231 'depth' => '50',
18232 'square' => '',
18233 )
18234 </pre>
18235
18236 !! html/parsoid
18237 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18238 !! end
18239
18240 ## Don't expect parsoid to rt this form.
18241 !! test
18242 Parser hook: basic arguments, variations
18243 !! options
18244 parsoid=wt2html,html2html
18245 !! wikitext
18246 <tag width=200 height = "100" depth = '50' square></tag>
18247 !! html/php
18248 <pre>
18249 ''
18250 array (
18251 'width' => '200',
18252 'height' => '100',
18253 'depth' => '50',
18254 'square' => '',
18255 )
18256 </pre>
18257
18258 !! html/parsoid
18259 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18260 !! end
18261
18262 !! test
18263 Parser hook: argument containing a forward slash (T7344)
18264 !! wikitext
18265 <tag filename="/tmp/bla"></tag>
18266 !! html/php
18267 <pre>
18268 ''
18269 array (
18270 'filename' => '/tmp/bla',
18271 )
18272 </pre>
18273
18274 !! html/parsoid
18275 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
18276 !! end
18277
18278 ## Don't expect parsoid to rt this form.
18279 !! test
18280 Parser hook: empty input using terminated empty elements (T4374)
18281 !! options
18282 parsoid=wt2html,html2html
18283 !! wikitext
18284 <tag foo=bar/>text
18285 !! html/php
18286 <pre>
18287 NULL
18288 array (
18289 'foo' => 'bar',
18290 )
18291 </pre>text
18292
18293 !! html/parsoid
18294 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text
18295 !! end
18296
18297 ## </tag> should be output literally since there is no matching tag that begins it
18298 ## Don't expect parsoid to rt this form.
18299 !! test
18300 Parser hook: basic arguments using terminated empty elements (T4374)
18301 !! options
18302 parsoid=wt2html
18303 !! wikitext
18304 <tag width=200 height = "100" depth = '50' square/>
18305 other stuff
18306 </tag>
18307 !! html/php
18308 <pre>
18309 NULL
18310 array (
18311 'width' => '200',
18312 'height' => '100',
18313 'depth' => '50',
18314 'square' => '',
18315 )
18316 </pre>
18317 <p>other stuff
18318 &lt;/tag&gt;
18319 </p>
18320 !! html/parsoid
18321 <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
18322 &lt;/tag></p>
18323 !! end
18324
18325 ## Don't expect parsoid to rt this form.
18326 !! test
18327 Parser hook: Don't allow unclosed extension tags
18328 !! options
18329 parsoid=wt2html
18330 !! wikitext
18331 test <tag>123
18332
18333 this is a '''test'''
18334 !! html/php
18335 <p>test &lt;tag&gt;123
18336 </p><p>this is a <b>test</b>
18337 </p>
18338 !! html/parsoid
18339 <p>test &lt;tag>123</p>
18340
18341 <p>this is a <b>test</b></p>
18342 !! end
18343
18344 ###
18345 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
18346 ###
18347
18348 !! test
18349 Parser hook: static parser hook not inside a comment
18350 !! wikitext
18351 <statictag>hello, world</statictag>
18352
18353 <statictag action="flush" />
18354 !! html/php
18355 <p><br />
18356 hello, world
18357 </p>
18358 !! html/parsoid
18359 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
18360 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p>
18361 !! end
18362
18363 !! test
18364 Parser hook: static parser hook inside a comment
18365 !! wikitext
18366 <!-- <statictag>hello, world</statictag> -->
18367 <statictag action="flush" />
18368 !! html/php
18369 <p><br />
18370 </p>
18371 !! html/parsoid
18372 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
18373 <p typeof='mw:Extension/statictag' data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about='#mwt2'></p>
18374 !! end
18375
18376 # Nested template calls; this case was broken by Parser.php rev 1.506,
18377 # since reverted.
18378
18379 !! article
18380 Template:One-parameter
18381 !! text
18382 (My parameter is: {{{1}}})
18383 !! endarticle
18384
18385 !! article
18386 Template:Map-one-parameter
18387 !! text
18388 {{{{{1}}}|{{{2}}}}}
18389 !! endarticle
18390
18391 !! test
18392 Nested template calls
18393 !! wikitext
18394 {{Map-one-parameter|One-parameter|param}}
18395 !! html
18396 <p>(My parameter is: param)
18397 </p>
18398 !! end
18399
18400
18401 ###
18402 ### Sanitizer
18403 ###
18404
18405 # HTML+Tidy strips out empty tags completely. Parsoid doesn't.
18406 # FIXME: Wikitext for this first test doesn't match its title.
18407 !! test
18408 Sanitizer: Closing of open tags
18409 !! wikitext
18410 <s></s><table></table>
18411 !! html/php+tidy
18412
18413 !! html/parsoid
18414 <s></s><table></table>
18415 !! end
18416
18417 !! test
18418 Sanitizer: Closing of open but not closed tags
18419 !! wikitext
18420 <s>foo
18421 !! html
18422 <p><s>foo</s>
18423 </p>
18424 !! end
18425
18426 !! test
18427 Sanitizer: Closing of closed but not open tags
18428 !! options
18429 parsoid=wt2html
18430 !! wikitext
18431 </s>
18432 !! html/php+tidy
18433 !! html/parsoid
18434 !! end
18435
18436 !! test
18437 Sanitizer: Closing of closed but not open table tags
18438 !! options
18439 parsoid=wt2html
18440 !! wikitext
18441 Table not started</td></tr></table>
18442 !! html/php+tidy
18443 <p>Table not started</p>
18444 !! html/parsoid
18445 <p>Table not started</p>
18446 !! end
18447
18448 !! test
18449 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
18450 !! wikitext
18451 <span id="æ: v">byte</span>[[#æ: v|backlink]]
18452 !! html/php
18453 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
18454 </p>
18455 !! html/parsoid
18456 <p><span id=".C3.A6:_v" data-parsoid='{"stx":"html","a":{"id":".C3.A6:_v"},"sa":{"id":"æ: v"}}'>byte</span><a rel="mw:WikiLink" href="./Main_Page#.C3.A6:_v" data-parsoid='{"stx":"piped","a":{"href":"./Main_Page#.C3.A6:_v"},"sa":{"href":"#æ: v"}}'>backlink</a></p>
18457 !! end
18458
18459 # In HTML5, the restrictions are that id must contain at least one character,
18460 # and must not contain any space characters.
18461 !! test
18462 Sanitizer: Validating the contents of the id attribute (T6515)
18463 !! options
18464 disabled
18465 !! wikitext
18466 <br id="" /><br id="a space" />
18467 !! html
18468 Something ...
18469 !! end
18470
18471 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
18472 !! test
18473 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
18474 !! options
18475 disabled
18476 !! wikitext
18477 <br id="foo" /><br id="foo" />
18478 !! html
18479 Something need to be done. foo-2 ?
18480 !! end
18481
18482 !! test
18483 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
18484 !! wikitext
18485 <div itemscope>
18486 <meta itemprop="hello" content="world">
18487 <meta http-equiv="refresh" content="5">
18488 <meta itemprop="hello" http-equiv="refresh" content="5">
18489 <link itemprop="hello" href="{{SERVER}}">
18490 <link rel="stylesheet" href="{{SERVER}}">
18491 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
18492 </div>
18493 !! html
18494 <div itemscope="">
18495 <p> <meta itemprop="hello" content="world" />
18496 &lt;meta http-equiv="refresh" content="5"&gt;
18497 <meta itemprop="hello" content="5" />
18498 <link itemprop="hello" href="http&#58;//example.org" />
18499 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
18500 <link itemprop="hello" href="http&#58;//example.org" />
18501 </p>
18502 </div>
18503
18504 !! end
18505
18506 !! test
18507 Sanitizer: Strip comments from CSS attributes
18508 !! options
18509 parsoid=wt2html,wt2wt
18510 !! wikitext
18511 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
18512 !! html/php
18513 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
18514 </p>
18515 !! html/parsoid
18516 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
18517 !! end
18518
18519 !! test
18520 Language converter: output gets cut off unexpectedly (T7757)
18521 !! options
18522 language=zh
18523 !! wikitext
18524 this bit is safe: }-
18525
18526 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
18527
18528 then we get cut off here: }-
18529
18530 all additional text is vanished
18531 !! html/php
18532 <p>this bit is safe: }-
18533 </p><p>but if we add a conversion instance: xxx
18534 </p><p>then we get cut off here: }-
18535 </p><p>all additional text is vanished
18536 </p>
18537 !! html/parsoid
18538 <p>this bit is safe: }-</p>
18539 <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>
18540 <p>then we get cut off here: }-</p>
18541 <p>all additional text is vanished</p>
18542 !! end
18543
18544 !! test
18545 Language converter glossary rules inside attributes (T119158)
18546 !! options
18547 language=sr variant=sr-el
18548 !! wikitext
18549 -{H|foAjrjvi=>sr-el:" onload="alert(1)" data-foo="}-
18550
18551 [[File:Foobar.jpg|alt=-{}-foAjrjvi-{}-]]
18552 !! html/php
18553 <p>
18554 </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>
18555 </p>
18556 !! html/parsoid
18557 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"foAjrjvi","l":"sr-el","t":"\" onload=\"alert(1)\" data-foo=\""}]}'/></p>
18558
18559 <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>
18560 !! end
18561
18562 !! test
18563 Self closed html pairs (T7487)
18564 !! wikitext
18565 <center><font id="bug" />Centered text</center>
18566 <div><font id="bug2" />In div text</div>
18567 !! html+tidy
18568 <center><font id="bug"></font>Centered text</center>
18569 <div><font id="bug2"></font>In div text</div>
18570 !! end
18571
18572 #
18573 #
18574 #
18575
18576 !! test
18577 Punctuation: nbsp before exclamation
18578 !! wikitext
18579 C'est grave !
18580 !! html
18581 <p>C'est grave&#160;!
18582 </p>
18583 !! end
18584
18585 !! test
18586 Punctuation: CSS !important (T13874)
18587 !! wikitext
18588 <div style="width:50% !important">important</div>
18589 !! html
18590 <div style="width:50% !important">important</div>
18591
18592 !!end
18593
18594 !! test
18595 Punctuation: CSS ! important (T13874; with space after)
18596 !! wikitext
18597 <div style="width:50% ! important">important</div>
18598 !! html
18599 <div style="width:50% ! important">important</div>
18600
18601 !!end
18602
18603 !! test
18604 HTML bullet list, closed tags (T7497)
18605 !! wikitext
18606 <ul>
18607 <li>One</li>
18608 <li>Two</li>
18609 </ul>
18610 !! html/php
18611 <ul>
18612 <li>One</li>
18613 <li>Two</li>
18614 </ul>
18615
18616 !! html/parsoid
18617 <ul data-parsoid='{"stx":"html"}'>
18618 <li data-parsoid='{"stx":"html"}'>One</li>
18619 <li data-parsoid='{"stx":"html"}'>Two</li>
18620 </ul>
18621
18622 !! end
18623
18624 !! test
18625 HTML bullet list, unclosed tags (T7497)
18626 !! wikitext
18627 <ul>
18628 <li>One
18629 <li>Two
18630 </ul>
18631 !! html/php+tidy
18632 <ul>
18633 <li>One</li>
18634 <li>Two</li>
18635 </ul>
18636 !! html/parsoid
18637 <ul data-parsoid='{"stx":"html"}'>
18638 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18639 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18640 </ul>
18641
18642 !! end
18643
18644 !! test
18645 HTML ordered list, closed tags (T7497)
18646 !! wikitext
18647 <ol>
18648 <li>One</li>
18649 <li>Two</li>
18650 </ol>
18651 !! html/php
18652 <ol>
18653 <li>One</li>
18654 <li>Two</li>
18655 </ol>
18656
18657 !! html/parsoid
18658 <ol data-parsoid='{"stx":"html"}'>
18659 <li data-parsoid='{"stx":"html"}'>One</li>
18660 <li data-parsoid='{"stx":"html"}'>Two</li>
18661 </ol>
18662
18663 !! end
18664
18665 !! test
18666 HTML ordered list, unclosed tags (T7497)
18667 !! options
18668 !! wikitext
18669 <ol>
18670 <li>One
18671 <li>Two
18672 </ol>
18673 !! html/php+tidy
18674 <ol>
18675 <li>One</li>
18676 <li>Two</li>
18677 </ol>
18678 !! html/parsoid
18679 <ol data-parsoid='{"stx":"html"}'>
18680 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18681 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18682 </ol>
18683
18684 !! end
18685
18686 !! test
18687 HTML nested bullet list, closed tags (T7497)
18688 !! wikitext
18689 <ul>
18690 <li>One</li>
18691 <li>Two:
18692 <ul>
18693 <li>Sub-one</li>
18694 <li>Sub-two</li>
18695 </ul>
18696 </li>
18697 </ul>
18698 !! html/php
18699 <ul>
18700 <li>One</li>
18701 <li>Two:
18702 <ul>
18703 <li>Sub-one</li>
18704 <li>Sub-two</li>
18705 </ul>
18706 </li>
18707 </ul>
18708
18709 !! html/parsoid
18710 <ul data-parsoid='{"stx":"html"}'>
18711 <li data-parsoid='{"stx":"html"}'>One</li>
18712 <li data-parsoid='{"stx":"html"}'>Two:
18713 <ul data-parsoid='{"stx":"html"}'>
18714 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
18715 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
18716 </ul>
18717 </li>
18718 </ul>
18719 !! end
18720
18721 !! test
18722 HTML nested bullet list, open tags (T7497)
18723 !! wikitext
18724 <ul>
18725 <li>One
18726 <li>Two:
18727 <ul>
18728 <li>Sub-one
18729 <li>Sub-two
18730 </ul>
18731 </ul>
18732 !! html/php+tidy
18733 <ul>
18734 <li>One</li>
18735 <li>Two:
18736 <ul>
18737 <li>Sub-one</li>
18738 <li>Sub-two</li>
18739 </ul>
18740 </li>
18741 </ul>
18742 !! html/parsoid
18743 <ul>
18744 <li>One
18745 </li>
18746 <li>Two:
18747 <ul>
18748 <li>Sub-one
18749 </li>
18750 <li>Sub-two
18751 </li>
18752 </ul>
18753 </li>
18754 </ul>
18755
18756 !! end
18757
18758 !! test
18759 HTML nested ordered list, closed tags (T7497)
18760 !! wikitext
18761 <ol>
18762 <li>One</li>
18763 <li>Two:
18764 <ol>
18765 <li>Sub-one</li>
18766 <li>Sub-two</li>
18767 </ol>
18768 </li>
18769 </ol>
18770 !! html
18771 <ol>
18772 <li>One</li>
18773 <li>Two:
18774 <ol>
18775 <li>Sub-one</li>
18776 <li>Sub-two</li>
18777 </ol>
18778 </li>
18779 </ol>
18780
18781 !! end
18782
18783 !! test
18784 HTML nested ordered list, open tags (T7497)
18785 !! wikitext
18786 <ol>
18787 <li>One
18788 <li>Two:
18789 <ol>
18790 <li>Sub-one
18791 <li>Sub-two
18792 </ol>
18793 </ol>
18794 !! html/php
18795 <ol>
18796 <li>One
18797 <li>Two:
18798 <ol>
18799 <li>Sub-one
18800 <li>Sub-two
18801 </ol>
18802 </ol>
18803
18804 !! html/parsoid
18805 <ol>
18806 <li>One
18807 </li>
18808 <li>Two:
18809 <ol>
18810 <li>Sub-one
18811 </li>
18812 <li>Sub-two
18813 </li>
18814 </ol>
18815 </li>
18816 </ol>
18817
18818 !! end
18819
18820 !! test
18821 HTML ordered list item with parameters oddity
18822 !! wikitext
18823 <ol><li id="fragment">One</li>
18824 </ol>
18825 !! html
18826 <ol><li id="fragment">One</li>
18827 </ol>
18828
18829 !! end
18830
18831 # parsoid doesn't explicitly mark autonumbered links, see T55505
18832 !!test
18833 T7918: autonumbering
18834 !! wikitext
18835 [http://first/] [http://second] [ftp://ftp]
18836
18837 ftp://inlineftp
18838
18839 [mailto:enclosed@mail.tld With target]
18840
18841 [mailto:enclosed@mail.tld]
18842
18843 mailto:inline@mail.tld
18844 !! html/php
18845 <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>
18846 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
18847 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
18848 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
18849 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
18850 </p>
18851 !! html/parsoid
18852 <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>
18853 <p><a rel="mw:ExtLink" href="ftp://inlineftp">ftp://inlineftp</a></p>
18854 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld">With target</a></p>
18855 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld"></a></p>
18856 <p><a rel="mw:ExtLink" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
18857 !! end
18858
18859
18860 #
18861 # Security and HTML correctness
18862 # From Nick Jenkins' fuzz testing
18863 #
18864
18865 !! test
18866 Fuzz testing: Parser13
18867 !! wikitext
18868 {|
18869 | http://a|
18870 !! html
18871 <table>
18872 <tr>
18873 <td>
18874 </td>
18875 </tr>
18876 </table>
18877
18878 !! end
18879
18880 !! test
18881 Fuzz testing: Parser14
18882 !! wikitext
18883 == onmouseover= ==
18884 http://__TOC__
18885 !! html
18886 <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>
18887 http://<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
18888 <ul>
18889 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18890 </ul>
18891 </div>
18892
18893
18894 !! html+tidy
18895 <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>
18896 <p>http://</p>
18897 <div id="toc" class="toc">
18898 <div class="toctitle">
18899 <h2>Contents</h2>
18900 </div>
18901 <ul>
18902 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18903 </ul>
18904 </div>
18905 <p></p>
18906 !! end
18907
18908 !! test
18909 Fuzz testing: Parser14-table
18910 !! options
18911 parsoid=wt2html,html2html
18912 !! wikitext
18913 ==a==
18914 {| STYLE=__TOC__
18915 !! html
18916 <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>
18917 <table style="&#95;_TOC&#95;_">
18918 <tr><td></td></tr>
18919 </table>
18920
18921 !! html+tidy
18922 <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>
18923 <table style="__TOC__">
18924 <tr>
18925 <td></td>
18926 </tr>
18927 </table>
18928 !! html/parsoid
18929 <h2>a</h2>
18930 <table style="__TOC__"></table>
18931 !! end
18932
18933 # Known to produce bogus xml (extra </td>)
18934 !! test
18935 Fuzz testing: Parser16
18936 !! wikitext
18937 {|
18938 !https://||||||
18939 !! html
18940 <table>
18941 <tr>
18942 <th>https://</th>
18943 <th></th>
18944 <th></th>
18945 <th>
18946 </td>
18947 </tr>
18948 </table>
18949
18950 !! html+tidy
18951 <table>
18952 <tr>
18953 <th>https://</th>
18954 <th></th>
18955 <th></th>
18956 <th></th>
18957 </tr>
18958 </table>
18959 !! end
18960
18961 !! test
18962 Fuzz testing: Parser21
18963 !! wikitext
18964 {|
18965 ! irc://{{ftp://a" onmouseover="alert('hello world');"
18966 |
18967 !! html
18968 <table>
18969 <tr>
18970 <th> <a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
18971 </th>
18972 <td>
18973 </td>
18974 </tr>
18975 </table>
18976
18977 !! end
18978
18979 !! test
18980 Fuzz testing: Parser22
18981 !! wikitext
18982 http://===r:::https://b
18983
18984 {|
18985 !! html
18986 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
18987 </p>
18988 <table>
18989 <tr><td></td></tr>
18990 </table>
18991
18992 !! end
18993
18994 # Known to produce bad XML for now
18995 !! test
18996 Fuzz testing: Parser24
18997 !! options
18998 parsoid=wt2html
18999 !! wikitext
19000 {|
19001 {{{|
19002 <u CLASS=
19003 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
19004 <br style="onmouseover='alert(document.cookie);' " />
19005
19006 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19007 |
19008 !! html/php
19009 <table>
19010 {{{|
19011 <u class="&#124;">}}}} &gt;
19012 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
19013
19014 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
19015 <tr>
19016 <td></u>
19017 </td>
19018 </tr>
19019 </table>
19020
19021 !! html/parsoid
19022 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
19023 <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>"}'/>}}}} >
19024 <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}'>
19025
19026
19027
19028 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table>
19029 !! end
19030
19031 # Note: the current result listed for this is not what the original one was,
19032 # but the original bug was JavaScript injection, which is fixed in any case.
19033 # It's not clear that the original result listed was any more correct than the
19034 # current one. Original result:
19035 # <p>{{{|
19036 # </p>
19037 # <li class="&#124;&#124;">
19038 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19039 !!test
19040 Fuzz testing: Parser25 (T8055)
19041 !! wikitext
19042 {{{
19043 |
19044 <LI CLASS=||
19045 >
19046 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
19047 !! html/php
19048 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
19049 </p>
19050 !! html/parsoid
19051 <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"]}'>
19052 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
19053 !! end
19054
19055 !!test
19056 Fuzz testing: URL adjacent extension (with space, clean)
19057 !! wikitext
19058 http://example.com <nowiki>junk</nowiki>
19059 !! html/php
19060 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
19061 </p>
19062 !! html/parsoid
19063 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a> <span typeof="mw:Nowiki">junk</span></p>
19064 !! end
19065
19066 !!test
19067 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
19068 !! wikitext
19069 http://example.com<nowiki>junk</nowiki>
19070 !! html/php
19071 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
19072 </p>
19073 !! html/parsoid
19074 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a><span typeof="mw:Nowiki">junk</span></p>
19075 !! end
19076
19077 !! test
19078 Fuzz testing: URL adjacent extension (no space, dirty; pre)
19079 !! wikitext
19080 http://example.com<pre>junk</pre>
19081 !! html/php
19082 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
19083
19084 !! html/php+tidy
19085 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p>
19086 <pre>
19087 junk
19088 </pre>
19089 !! html/parsoid
19090 <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>
19091 !! end
19092
19093 !! test
19094 Fuzz testing: image with bogus manual thumbnail
19095 !! wikitext
19096 [[Image:foobar.jpg|thumbnail= ]]
19097 !! html/php
19098 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
19099
19100 !! html/parsoid
19101 <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>
19102 !! end
19103
19104 !! test
19105 Fuzz testing: encoded newline in generated HTML replacements (T8577)
19106 !! wikitext
19107 <pre dir="&#10;"></pre>
19108 !! html/php
19109 <pre dir="&#10;"></pre>
19110
19111 !! html/parsoid
19112 <pre typeof="mw:Extension/pre" about="#mwt2" dir="&amp;#10;" data-mw='{"name":"pre","attrs":{"dir":"&amp;#10;"},"body":{"extsrc":""}}'></pre>
19113 !! end
19114
19115 !! test
19116 Parsing optional HTML elements (T8171)
19117 !! options
19118 !! wikitext
19119 <table>
19120 <tr>
19121 <td> Some tabular data</td>
19122 <td> More tabular data ...
19123 <td> And yet som tabular data</td>
19124 </tr>
19125 </table>
19126 !! html
19127 <table>
19128 <tr>
19129 <td> Some tabular data</td>
19130 <td> More tabular data ...
19131 </td><td> And yet som tabular data</td>
19132 </tr>
19133 </table>
19134
19135 !! end
19136
19137 !! test
19138 Correct handling of <td>, <tr> (T8171)
19139 !! options
19140 !! wikitext
19141 <table>
19142 <tr>
19143 <td> Some tabular data</td>
19144 <td> More tabular data ...</td>
19145 <td> And yet som tabular data</td>
19146 </tr>
19147 </table>
19148 !! html
19149 <table>
19150 <tr>
19151 <td> Some tabular data</td>
19152 <td> More tabular data ...</td>
19153 <td> And yet som tabular data</td>
19154 </tr>
19155 </table>
19156
19157 !! end
19158
19159
19160 !! test
19161 Parsing crashing regression (fr:JavaScript)
19162 !! wikitext
19163 </body></x>
19164 !! html
19165 <p>&lt;/body&gt;&lt;/x&gt;
19166 </p>
19167 !! end
19168
19169 !! test
19170 Inline wiki vs wiki block nesting
19171 !! wikitext
19172 '''Bold paragraph
19173
19174 New wiki paragraph
19175 !! html
19176 <p><b>Bold paragraph</b>
19177 </p><p>New wiki paragraph
19178 </p>
19179 !! end
19180
19181 # FIXME: The current php output is documented
19182 # and desired output is the parsoid target.
19183 !! test
19184 Inline HTML vs wiki block nesting
19185 !! wikitext
19186 <b>Bold paragraph
19187
19188 New wiki paragraph
19189 !! html/php
19190 <p><b>Bold paragraph
19191 </p><p>New wiki paragraph</b>
19192 </p>
19193 !! html/parsoid
19194 <p><b>Bold paragraph</b>
19195 </p><p>New wiki paragraph
19196 </p>
19197 !! end
19198
19199 # Original result was this:
19200 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
19201 # </p>
19202 # While that might be marginally more intuitive, maybe, the six-apostrophe
19203 # construct is clearly pathological and the result stated here (which is what
19204 # the parser actually does) is about as reasonable as anything.
19205 !!test
19206 Mixing markup for italics and bold
19207 !! options
19208 !! wikitext
19209 '''bold''''''bold''bolditalics'''''
19210 !! html
19211 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
19212 </p>
19213 !! end
19214
19215
19216 !! article
19217 Xyzzyx
19218 !! text
19219 Article for special page transclusion test
19220 !! endarticle
19221
19222 !! test
19223 Special page transclusion
19224 !! options
19225 !! wikitext
19226 {{Special:Prefixindex/Xyzzyx}}
19227 !! html
19228 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19229 </ul>
19230
19231 !! end
19232
19233 !! test
19234 Special page transclusion twice (T7021)
19235 !! options
19236 !! wikitext
19237 {{Special:Prefixindex/Xyzzyx}}
19238 {{Special:Prefixindex/Xyzzyx}}
19239 !! html
19240 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19241 </ul>
19242 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
19243 </ul>
19244
19245 !! end
19246
19247 !! test
19248 Transclusion of default MediaWiki message
19249 !! wikitext
19250 {{MediaWiki:Mainpage}}
19251 !! html
19252 <p>Main Page
19253 </p>
19254 !! end
19255
19256 !! test
19257 Transclusion of nonexistent MediaWiki message
19258 !! wikitext
19259 {{MediaWiki:Mainpagexxx}}
19260 !! html
19261 <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>
19262 </p>
19263 !! end
19264
19265 !! test
19266 Transclusion of MediaWiki message with underscore
19267 !! wikitext
19268 {{MediaWiki:history_short}}
19269 !! html
19270 <p>History
19271 </p>
19272 !! end
19273
19274 !! test
19275 Transclusion of MediaWiki message with space
19276 !! wikitext
19277 {{MediaWiki:history short}}
19278 !! html
19279 <p>History
19280 </p>
19281 !! end
19282
19283 !! test
19284 Invalid header with following text
19285 !! wikitext
19286 = x = y
19287 !! html
19288 <p>= x = y
19289 </p>
19290 !! end
19291
19292
19293 !! test
19294 Section extraction test (section 0)
19295 !! options
19296 section=0
19297 !! wikitext
19298 start
19299 ==a==
19300 ===aa===
19301 ====aaa====
19302 ==b==
19303 ===ba===
19304 ===bb===
19305 ====bba====
19306 ===bc===
19307 ==c==
19308 ===ca===
19309 !! html/php
19310 start
19311 !! end
19312
19313 !! test
19314 Section extraction test (section 1)
19315 !! options
19316 section=1
19317 !! wikitext
19318 start
19319 ==a==
19320 ===aa===
19321 ====aaa====
19322 ==b==
19323 ===ba===
19324 ===bb===
19325 ====bba====
19326 ===bc===
19327 ==c==
19328 ===ca===
19329 !! html/php
19330 ==a==
19331 ===aa===
19332 ====aaa====
19333 !! end
19334
19335 !! test
19336 Section extraction test (section 2)
19337 !! options
19338 section=2
19339 !! wikitext
19340 start
19341 ==a==
19342 ===aa===
19343 ====aaa====
19344 ==b==
19345 ===ba===
19346 ===bb===
19347 ====bba====
19348 ===bc===
19349 ==c==
19350 ===ca===
19351 !! html/php
19352 ===aa===
19353 ====aaa====
19354 !! end
19355
19356 !! test
19357 Section extraction test (section 3)
19358 !! options
19359 section=3
19360 !! wikitext
19361 start
19362 ==a==
19363 ===aa===
19364 ====aaa====
19365 ==b==
19366 ===ba===
19367 ===bb===
19368 ====bba====
19369 ===bc===
19370 ==c==
19371 ===ca===
19372 !! html/php
19373 ====aaa====
19374 !! end
19375
19376 !! test
19377 Section extraction test (section 4)
19378 !! options
19379 section=4
19380 !! wikitext
19381 start
19382 ==a==
19383 ===aa===
19384 ====aaa====
19385 ==b==
19386 ===ba===
19387 ===bb===
19388 ====bba====
19389 ===bc===
19390 ==c==
19391 ===ca===
19392 !! html/php
19393 ==b==
19394 ===ba===
19395 ===bb===
19396 ====bba====
19397 ===bc===
19398 !! end
19399
19400 !! test
19401 Section extraction test (section 5)
19402 !! options
19403 section=5
19404 !! wikitext
19405 start
19406 ==a==
19407 ===aa===
19408 ====aaa====
19409 ==b==
19410 ===ba===
19411 ===bb===
19412 ====bba====
19413 ===bc===
19414 ==c==
19415 ===ca===
19416 !! html/php
19417 ===ba===
19418 !! end
19419
19420 !! test
19421 Section extraction test (section 6)
19422 !! options
19423 section=6
19424 !! wikitext
19425 start
19426 ==a==
19427 ===aa===
19428 ====aaa====
19429 ==b==
19430 ===ba===
19431 ===bb===
19432 ====bba====
19433 ===bc===
19434 ==c==
19435 ===ca===
19436 !! html/php
19437 ===bb===
19438 ====bba====
19439 !! end
19440
19441 !! test
19442 Section extraction test (section 7)
19443 !! options
19444 section=7
19445 !! wikitext
19446 start
19447 ==a==
19448 ===aa===
19449 ====aaa====
19450 ==b==
19451 ===ba===
19452 ===bb===
19453 ====bba====
19454 ===bc===
19455 ==c==
19456 ===ca===
19457 !! html/php
19458 ====bba====
19459 !! end
19460
19461 !! test
19462 Section extraction test (section 8)
19463 !! options
19464 section=8
19465 !! wikitext
19466 start
19467 ==a==
19468 ===aa===
19469 ====aaa====
19470 ==b==
19471 ===ba===
19472 ===bb===
19473 ====bba====
19474 ===bc===
19475 ==c==
19476 ===ca===
19477 !! html/php
19478 ===bc===
19479 !! end
19480
19481 !! test
19482 Section extraction test (section 9)
19483 !! options
19484 section=9
19485 !! wikitext
19486 start
19487 ==a==
19488 ===aa===
19489 ====aaa====
19490 ==b==
19491 ===ba===
19492 ===bb===
19493 ====bba====
19494 ===bc===
19495 ==c==
19496 ===ca===
19497 !! html/php
19498 ==c==
19499 ===ca===
19500 !! end
19501
19502 !! test
19503 Section extraction test (section 10)
19504 !! options
19505 section=10
19506 !! wikitext
19507 start
19508 ==a==
19509 ===aa===
19510 ====aaa====
19511 ==b==
19512 ===ba===
19513 ===bb===
19514 ====bba====
19515 ===bc===
19516 ==c==
19517 ===ca===
19518 !! html/php
19519 ===ca===
19520 !! end
19521
19522 !! test
19523 Section extraction test (nonexistent section 11)
19524 !! options
19525 section=11
19526 !! wikitext
19527 start
19528 ==a==
19529 ===aa===
19530 ====aaa====
19531 ==b==
19532 ===ba===
19533 ===bb===
19534 ====bba====
19535 ===bc===
19536 ==c==
19537 ===ca===
19538 !! html/php
19539 !! end
19540
19541 !! test
19542 Section extraction test with bogus heading (section 1)
19543 !! options
19544 section=1
19545 !! wikitext
19546 ==a==
19547 ==bogus== not a legal section
19548 ==b==
19549 !! html/php
19550 ==a==
19551 ==bogus== not a legal section
19552 !! end
19553
19554 !! test
19555 Section extraction test with bogus heading (section 2)
19556 !! options
19557 section=2
19558 !! wikitext
19559 ==a==
19560 ==bogus== not a legal section
19561 ==b==
19562 !! html/php
19563 ==b==
19564 !! end
19565
19566 !! test
19567 Section extraction test with comment after heading (section 1)
19568 !! options
19569 section=1
19570 !! wikitext
19571 ==a==
19572 ==b== <!-- -->
19573 ==c==
19574 !! html/php
19575 ==a==
19576 !! end
19577
19578 !! test
19579 Section extraction test with comment after heading (section 2)
19580 !! options
19581 section=2
19582 !! wikitext
19583 ==a==
19584 ==b== <!-- -->
19585 ==c==
19586 !! html/php
19587 ==b== <!-- -->
19588 !! end
19589
19590 !! test
19591 Section extraction test with bogus <nowiki> heading (section 1)
19592 !! options
19593 section=1
19594 !! wikitext
19595 ==a==
19596 ==bogus== <nowiki>not a legal section</nowiki>
19597 ==b==
19598 !! html/php
19599 ==a==
19600 ==bogus== <nowiki>not a legal section</nowiki>
19601 !! end
19602
19603 !! test
19604 Section extraction test with bogus <nowiki> heading (section 2)
19605 !! options
19606 section=2
19607 !! wikitext
19608 ==a==
19609 ==bogus== <nowiki>not a legal section</nowiki>
19610 ==b==
19611 !! html/php
19612 ==b==
19613 !! end
19614
19615 # Formerly testing for T4587, now resolved by the use of unmarked sections
19616 # instead of respecting commented sections
19617 !! test
19618 Section extraction prefixed by comment (section 1)
19619 !! options
19620 section=1
19621 !! wikitext
19622 <!-- -->==sec1==
19623 ==sec2==
19624 !! html/php
19625 ==sec2==
19626 !!end
19627
19628 !! test
19629 Section extraction prefixed by comment (section 2)
19630 !! options
19631 section=2
19632 !! wikitext
19633 <!-- -->==sec1==
19634 ==sec2==
19635 !! html/php
19636
19637 !!end
19638
19639 # Formerly testing for T4607, now resolved by the use of unmarked sections
19640 # instead of respecting HTML-style headings
19641 !! test
19642 Section extraction, mixed wiki and html (section 1)
19643 !! options
19644 section=1
19645 !! wikitext
19646 <h2>unmarked</h2>
19647 unmarked
19648 ==1==
19649 one
19650 ==2==
19651 two
19652 !! html/php
19653 ==1==
19654 one
19655 !! end
19656
19657 !! test
19658 Section extraction, mixed wiki and html (section 2)
19659 !! options
19660 section=2
19661 !! wikitext
19662 <h2>unmarked</h2>
19663 unmarked
19664 ==1==
19665 one
19666 ==2==
19667 two
19668 !! html/php
19669 ==2==
19670 two
19671 !! end
19672
19673
19674 # Formerly testing for T5342
19675 !! test
19676 Section extraction, heading surrounded by <noinclude>
19677 !! options
19678 section=1
19679 !! wikitext
19680 <noinclude>==unmarked==</noinclude>
19681 ==marked==
19682 !! html/php
19683 ==marked==
19684 !!end
19685
19686 # Test behavior of T21910
19687 !! test
19688 Sectiion with all-equals
19689 !! options
19690 section=2
19691 !! wikitext
19692 ===
19693 The line above must have a trailing space
19694 === <!--
19695 --> <!-- -->
19696 But just in case it doesn't...
19697 !! html/php
19698 === <!--
19699 --> <!-- -->
19700 But just in case it doesn't...
19701 !! end
19702
19703 !! test
19704 Section replacement test (section 0)
19705 !! options
19706 replace=0,"xxx"
19707 !! wikitext
19708 start
19709 ==a==
19710 ===aa===
19711 ====aaa====
19712 ==b==
19713 ===ba===
19714 ===bb===
19715 ====bba====
19716 ===bc===
19717 ==c==
19718 ===ca===
19719 !! html/php
19720 xxx
19721
19722 ==a==
19723 ===aa===
19724 ====aaa====
19725 ==b==
19726 ===ba===
19727 ===bb===
19728 ====bba====
19729 ===bc===
19730 ==c==
19731 ===ca===
19732 !! end
19733
19734 !! test
19735 Section replacement test (section 1)
19736 !! options
19737 replace=1,"xxx"
19738 !! wikitext
19739 start
19740 ==a==
19741 ===aa===
19742 ====aaa====
19743 ==b==
19744 ===ba===
19745 ===bb===
19746 ====bba====
19747 ===bc===
19748 ==c==
19749 ===ca===
19750 !! html/php
19751 start
19752 xxx
19753
19754 ==b==
19755 ===ba===
19756 ===bb===
19757 ====bba====
19758 ===bc===
19759 ==c==
19760 ===ca===
19761 !! end
19762
19763 !! test
19764 Section replacement test (section 2)
19765 !! options
19766 replace=2,"xxx"
19767 !! wikitext
19768 start
19769 ==a==
19770 ===aa===
19771 ====aaa====
19772 ==b==
19773 ===ba===
19774 ===bb===
19775 ====bba====
19776 ===bc===
19777 ==c==
19778 ===ca===
19779 !! html/php
19780 start
19781 ==a==
19782 xxx
19783
19784 ==b==
19785 ===ba===
19786 ===bb===
19787 ====bba====
19788 ===bc===
19789 ==c==
19790 ===ca===
19791 !! end
19792
19793 !! test
19794 Section replacement test (section 3)
19795 !! options
19796 replace=3,"xxx"
19797 !! wikitext
19798 start
19799 ==a==
19800 ===aa===
19801 ====aaa====
19802 ==b==
19803 ===ba===
19804 ===bb===
19805 ====bba====
19806 ===bc===
19807 ==c==
19808 ===ca===
19809 !! html/php
19810 start
19811 ==a==
19812 ===aa===
19813 xxx
19814
19815 ==b==
19816 ===ba===
19817 ===bb===
19818 ====bba====
19819 ===bc===
19820 ==c==
19821 ===ca===
19822 !! end
19823
19824 !! test
19825 Section replacement test (section 4)
19826 !! options
19827 replace=4,"xxx"
19828 !! wikitext
19829 start
19830 ==a==
19831 ===aa===
19832 ====aaa====
19833 ==b==
19834 ===ba===
19835 ===bb===
19836 ====bba====
19837 ===bc===
19838 ==c==
19839 ===ca===
19840 !! html/php
19841 start
19842 ==a==
19843 ===aa===
19844 ====aaa====
19845 xxx
19846
19847 ==c==
19848 ===ca===
19849 !! end
19850
19851 !! test
19852 Section replacement test (section 5)
19853 !! options
19854 replace=5,"xxx"
19855 !! wikitext
19856 start
19857 ==a==
19858 ===aa===
19859 ====aaa====
19860 ==b==
19861 ===ba===
19862 ===bb===
19863 ====bba====
19864 ===bc===
19865 ==c==
19866 ===ca===
19867 !! html/php
19868 start
19869 ==a==
19870 ===aa===
19871 ====aaa====
19872 ==b==
19873 xxx
19874
19875 ===bb===
19876 ====bba====
19877 ===bc===
19878 ==c==
19879 ===ca===
19880 !! end
19881
19882 !! test
19883 Section replacement test (section 6)
19884 !! options
19885 replace=6,"xxx"
19886 !! wikitext
19887 start
19888 ==a==
19889 ===aa===
19890 ====aaa====
19891 ==b==
19892 ===ba===
19893 ===bb===
19894 ====bba====
19895 ===bc===
19896 ==c==
19897 ===ca===
19898 !! html/php
19899 start
19900 ==a==
19901 ===aa===
19902 ====aaa====
19903 ==b==
19904 ===ba===
19905 xxx
19906
19907 ===bc===
19908 ==c==
19909 ===ca===
19910 !! end
19911
19912 !! test
19913 Section replacement test (section 7)
19914 !! options
19915 replace=7,"xxx"
19916 !! wikitext
19917 start
19918 ==a==
19919 ===aa===
19920 ====aaa====
19921 ==b==
19922 ===ba===
19923 ===bb===
19924 ====bba====
19925 ===bc===
19926 ==c==
19927 ===ca===
19928 !! html/php
19929 start
19930 ==a==
19931 ===aa===
19932 ====aaa====
19933 ==b==
19934 ===ba===
19935 ===bb===
19936 xxx
19937
19938 ===bc===
19939 ==c==
19940 ===ca===
19941 !! end
19942
19943 !! test
19944 Section replacement test (section 8)
19945 !! options
19946 replace=8,"xxx"
19947 !! wikitext
19948 start
19949 ==a==
19950 ===aa===
19951 ====aaa====
19952 ==b==
19953 ===ba===
19954 ===bb===
19955 ====bba====
19956 ===bc===
19957 ==c==
19958 ===ca===
19959 !! html/php
19960 start
19961 ==a==
19962 ===aa===
19963 ====aaa====
19964 ==b==
19965 ===ba===
19966 ===bb===
19967 ====bba====
19968 xxx
19969
19970 ==c==
19971 ===ca===
19972 !!end
19973
19974 !! test
19975 Section replacement test (section 9)
19976 !! options
19977 replace=9,"xxx"
19978 !! wikitext
19979 start
19980 ==a==
19981 ===aa===
19982 ====aaa====
19983 ==b==
19984 ===ba===
19985 ===bb===
19986 ====bba====
19987 ===bc===
19988 ==c==
19989 ===ca===
19990 !! html/php
19991 start
19992 ==a==
19993 ===aa===
19994 ====aaa====
19995 ==b==
19996 ===ba===
19997 ===bb===
19998 ====bba====
19999 ===bc===
20000 xxx
20001 !! end
20002
20003 !! test
20004 Section replacement test (section 10)
20005 !! options
20006 replace=10,"xxx"
20007 !! wikitext
20008 start
20009 ==a==
20010 ===aa===
20011 ====aaa====
20012 ==b==
20013 ===ba===
20014 ===bb===
20015 ====bba====
20016 ===bc===
20017 ==c==
20018 ===ca===
20019 !! html/php
20020 start
20021 ==a==
20022 ===aa===
20023 ====aaa====
20024 ==b==
20025 ===ba===
20026 ===bb===
20027 ====bba====
20028 ===bc===
20029 ==c==
20030 xxx
20031 !! end
20032
20033 !! test
20034 Section replacement test with initial whitespace (T15728)
20035 !! options
20036 replace=2,"xxx"
20037 !! wikitext
20038 Preformatted initial line
20039 ==a==
20040 ===a===
20041 !! html/php
20042 Preformatted initial line
20043 ==a==
20044 xxx
20045 !! end
20046
20047
20048 !! test
20049 Section extraction, heading followed by pre with 20 spaces (T8398)
20050 !! options
20051 section=1
20052 !! wikitext
20053 ==a==
20054 a
20055 !! html/php
20056 ==a==
20057 a
20058 !! end
20059
20060 !! test
20061 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
20062 !! options
20063 section=1
20064 !! wikitext
20065 ==a==
20066 a
20067 !! html/php
20068 ==a==
20069 a
20070 !! end
20071
20072
20073 !! test
20074 Section extraction, <pre> around bogus header (T12309)
20075 !! options
20076 section=2
20077 !! wikitext
20078 == Section One ==
20079 <pre>
20080 =======
20081 </pre>
20082
20083 == Section Two ==
20084 stuff
20085 !! html/php
20086 == Section Two ==
20087 stuff
20088 !! end
20089
20090 !! test
20091 Section replacement, <pre> around bogus header (T12309)
20092 !! options
20093 replace=2,"xxx"
20094 !! wikitext
20095 == Section One ==
20096 <pre>
20097 =======
20098 </pre>
20099
20100 == Section Two ==
20101 stuff
20102 !! html/php
20103 == Section One ==
20104 <pre>
20105 =======
20106 </pre>
20107
20108 xxx
20109 !! end
20110
20111 !! test
20112 Handling of &#x0A; in URLs
20113 !! wikitext
20114 ** irc://&#x0A;a
20115 !! html/php
20116 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
20117
20118 !! html/parsoid
20119 <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>
20120 !! end
20121
20122 !! test
20123 Handling of %0A in URLs
20124 !! wikitext
20125 ** irc://%0Aa
20126 !! html/php
20127 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
20128
20129 !! html/parsoid
20130 <ul><li><ul><li> <a rel="mw:ExtLink" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
20131 !! end
20132
20133 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
20134 !! test
20135 5 quotes, code coverage +1 line
20136 !! options
20137 parsoid=wt2html
20138 !! wikitext
20139 '''''
20140 !! html/php
20141 !! html/parsoid
20142 <b><i></i></b>
20143 !! end
20144
20145 # same html as previous, but wikitext adjusted to match parsoid html2wt
20146 # note that wt2html and html2html will put the <i> before the <b>
20147 !! test
20148 5 quotes, code coverage +1 line w/ nowiki (1)
20149 !! options
20150 parsoid=wt2wt,html2wt
20151 !! wikitext
20152 '''''<nowiki/>'''''
20153 !! html/php
20154 <p><i></i>
20155 </p>
20156 !! html/parsoid
20157 <p><b><i></i></b></p>
20158 !! end
20159
20160 # same as previous, just swapping the <i> and <b>
20161 !! test
20162 5 quotes, code coverage +1 line w/ nowiki (2)
20163 !! wikitext
20164 '''''<nowiki/>'''''
20165 !! html/php
20166 <p><i></i>
20167 </p>
20168 !! html/parsoid
20169 <p><i><b></b></i></p>
20170 !! end
20171
20172 !! test
20173 Special:Search page linking.
20174 !! wikitext
20175 {{Special:search}}
20176 !! html
20177 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
20178 </p>
20179 !! end
20180
20181 !! test
20182 {{!}} is a magic word
20183 !! wikitext
20184 {{!}} is a magic word there and {{!}} is still a magic word here
20185 | is not a magic word here but {{!}} is still a magic word here
20186 !! html/php
20187 <p>| is a magic word there and | is still a magic word here
20188 | is not a magic word here but | is still a magic word here
20189 </p>
20190 !! html/parsoid
20191 <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
20192 | 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>
20193 !! end
20194
20195 !! test
20196 Say the magic word
20197 !! options
20198 title=[[Parser test]]
20199 !! wikitext
20200 * {{PAGENAME}}
20201 * {{PAGENAMEE}}
20202 * {{FULLPAGENAME}}
20203 * {{FULLPAGENAMEE}}
20204 * {{BASEPAGENAME}}
20205 * {{BASEPAGENAMEE}}
20206 * {{SUBPAGENAME}}
20207 * {{SUBPAGENAMEE}}
20208 * {{ROOTPAGENAME}}
20209 * {{ROOTPAGENAMEE}}
20210 * {{TALKPAGENAME}}
20211 * {{TALKPAGENAMEE}}
20212 * {{SUBJECTPAGENAME}}
20213 * {{SUBJECTPAGENAMEE}}
20214 * {{NAMESPACEE}}
20215 * {{NAMESPACE}}
20216 * {{NAMESPACENUMBER}}
20217 * {{TALKSPACE}}
20218 * {{TALKSPACEE}}
20219 * {{SUBJECTSPACE}}
20220 * {{SUBJECTSPACEE}}
20221 * {{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
20222 !! html
20223 <ul><li> Parser test</li>
20224 <li> Parser_test</li>
20225 <li> Parser test</li>
20226 <li> Parser_test</li>
20227 <li> Parser test</li>
20228 <li> Parser_test</li>
20229 <li> Parser test</li>
20230 <li> Parser_test</li>
20231 <li> Parser test</li>
20232 <li> Parser_test</li>
20233 <li> Talk:Parser test</li>
20234 <li> Talk:Parser_test</li>
20235 <li> Parser test</li>
20236 <li> Parser_test</li>
20237 <li> </li>
20238 <li> </li>
20239 <li> 0</li>
20240 <li> Talk</li>
20241 <li> Talk</li>
20242 <li> </li>
20243 <li> </li>
20244 <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>
20245
20246 !! end
20247 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
20248
20249 !! test
20250 Gallery with valid attributes
20251 !! wikitext
20252 <gallery type="123" summary="345">
20253 File:File:Foobar.jpg
20254 </gallery>
20255 !! html/php
20256 <ul class="gallery mw-gallery-traditional" type="123">
20257 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20258 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
20259 <div class="gallerytext">
20260 </div>
20261 </div></li>
20262 </ul>
20263
20264 !! html/parsoid
20265 <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"}}'>
20266 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"></div></li>
20267 </ul>
20268 !! end
20269
20270 ## Parsoid thinks the "centre" here is a property, not a caption.
20271 !! test
20272 Gallery
20273 !! options
20274 parsoid={
20275 "modes": ["wt2html"],
20276 "nativeGallery": true
20277 }
20278 !! wikitext
20279 <gallery>
20280 image1.png |
20281 image2.gif|||||
20282
20283 image3|
20284 image4 |300px| centre
20285 image5.svg| http://///////
20286 [[x|xx]]]]
20287 * image6
20288 </gallery>
20289 !! html/php
20290 <ul class="gallery mw-gallery-traditional">
20291 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20292 <div class="thumb" style="height: 150px;">Image1.png</div>
20293 <div class="gallerytext">
20294 </div>
20295 </div></li>
20296 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20297 <div class="thumb" style="height: 150px;">Image2.gif</div>
20298 <div class="gallerytext">
20299 </div>
20300 </div></li>
20301 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20302 <div class="thumb" style="height: 150px;">Image3</div>
20303 <div class="gallerytext">
20304 </div>
20305 </div></li>
20306 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20307 <div class="thumb" style="height: 150px;">Image4</div>
20308 <div class="gallerytext">
20309 <pre>centre
20310 </pre>
20311 </div>
20312 </div></li>
20313 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20314 <div class="thumb" style="height: 150px;">Image5.svg</div>
20315 <div class="gallerytext">
20316 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
20317 </p>
20318 </div>
20319 </div></li>
20320 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20321 <div class="thumb" style="height: 150px;">* image6</div>
20322 <div class="gallerytext">
20323 </div>
20324 </div></li>
20325 </ul>
20326
20327 !! html/parsoid
20328 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20329 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"></div></li>
20330 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"></div></li>
20331 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Image3"><img resource="./File:Image3" src="./Special:FilePath/Image3" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
20332 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:Image4"><img resource="./File:Image4" src="./Special:FilePath/Image4" height="300" width="300"/></a></span></div><div class="gallerytext"></div></li>
20333 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"> <a rel="mw:ExtLink" href="http://///////">http://///////</a></div></li>
20334 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Error mw:Image"><a href="./File:*_image6"><img resource="./File:*_image6" src="./Special:FilePath/*_image6" height="120" width="120"/></a></span></div><div class="gallerytext"></div></li>
20335 </ul>
20336 !! end
20337
20338 !! test
20339 Gallery (with options, html)
20340 !! options
20341 parsoid={
20342 "modes": ["wt2html", "html2html"],
20343 "nativeGallery": true
20344 }
20345 !! wikitext
20346 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20347 File:Nonexistent.jpg|caption
20348 File:Nonexistent.jpg
20349 image:foobar.jpg|some '''caption''' [[Main Page]]
20350 image:foobar.jpg
20351 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20352 </gallery>
20353 !! html/php
20354 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20355 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20356 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20357 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20358 <div class="gallerytext">
20359 <p>caption
20360 </p>
20361 </div>
20362 </div></li>
20363 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20364 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20365 <div class="gallerytext">
20366 </div>
20367 </div></li>
20368 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20369 <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>
20370 <div class="gallerytext">
20371 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20372 </p>
20373 </div>
20374 </div></li>
20375 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20376 <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>
20377 <div class="gallerytext">
20378 </div>
20379 </div></li>
20380 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20381 <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>
20382 <div class="gallerytext">
20383 <p>blabla.
20384 </p>
20385 </div>
20386 </div></li>
20387 </ul>
20388
20389 !! html/parsoid
20390 <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":{}}'>
20391 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20392 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span 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></span></div><div class="gallerytext">caption</div></li>
20393 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span 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></span></div><div class="gallerytext"></div></li>
20394 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span 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></span></div><div class="gallerytext">some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li>
20395 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span 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></span></div><div class="gallerytext"></div></li>
20396 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span 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></span></div><div class="gallerytext">blabla.</div></li>
20397 </ul>
20398 !! end
20399
20400 !! test
20401 Gallery (with options, extsrc)
20402 !! options
20403 parsoid={
20404 "nativeGallery": false
20405 }
20406 !! wikitext
20407 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
20408 File:Nonexistent.jpg|caption
20409 File:Nonexistent.jpg
20410 image:foobar.jpg|some '''caption''' [[Main Page]]
20411 image:foobar.jpg
20412 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
20413 </gallery>
20414 !! html/php
20415 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
20416 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
20417 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20418 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20419 <div class="gallerytext">
20420 <p>caption
20421 </p>
20422 </div>
20423 </div></li>
20424 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20425 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
20426 <div class="gallerytext">
20427 </div>
20428 </div></li>
20429 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20430 <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>
20431 <div class="gallerytext">
20432 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20433 </p>
20434 </div>
20435 </div></li>
20436 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20437 <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>
20438 <div class="gallerytext">
20439 </div>
20440 </div></li>
20441 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
20442 <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>
20443 <div class="gallerytext">
20444 <p>blabla.
20445 </p>
20446 </div>
20447 </div></li>
20448 </ul>
20449
20450 !! html/parsoid
20451 <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"}}'>
20452 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
20453 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span 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></span></div><div class="gallerytext">caption</div></li>
20454 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span 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></span></div><div class="gallerytext"></div></li>
20455 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span 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></span></div><div class="gallerytext">some <b>caption</b> <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></div></li>
20456 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span 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></span></div><div class="gallerytext"></div></li>
20457 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span 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></span></div><div class="gallerytext">blabla.</div></li>
20458 </ul>
20459 !! end
20460
20461 !! test
20462 Gallery with link that has fragment
20463 !! options
20464 parsoid={
20465 "modes": ["wt2html", "html2html"],
20466 "nativeGallery": true
20467 }
20468 !! wikitext
20469 <gallery>
20470 image:foobar.jpg|link=Main_Page
20471 image:foobar.jpg|link=Main_Page#section
20472 image:foobar.jpg|link=Main Page#section|caption
20473 </gallery>
20474 !! html/php
20475 <ul class="gallery mw-gallery-traditional">
20476 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20477 <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>
20478 <div class="gallerytext">
20479 </div>
20480 </div></li>
20481 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20482 <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>
20483 <div class="gallerytext">
20484 </div>
20485 </div></li>
20486 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20487 <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>
20488 <div class="gallerytext">
20489 <p>caption
20490 </p>
20491 </div>
20492 </div></li>
20493 </ul>
20494
20495 !! html/parsoid
20496 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20497 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"></div></li>
20498 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"></div></li>
20499 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext">caption</div></li>
20500 </ul>
20501 !! end
20502
20503 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
20504 !! test
20505 Gallery with template inside caption
20506 !! options
20507 parsoid={
20508 "nativeGallery": true
20509 }
20510 !! wikitext
20511 <gallery caption="{{echo|hi}}">
20512 File:Foobar.jpg|{{echo|ho}}
20513 </gallery>
20514 !! html/php
20515 <ul class="gallery mw-gallery-traditional">
20516 <li class='gallerycaption'>{{echo|hi}}</li>
20517 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20518 <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>
20519 <div class="gallerytext">
20520 <p>ho
20521 </p>
20522 </div>
20523 </div></li>
20524 </ul>
20525
20526 !! html/parsoid
20527 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20528 <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>
20529 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></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>
20530 </ul>
20531 !! end
20532
20533 !! test
20534 Gallery with wikitext inside caption
20535 !! options
20536 parsoid={
20537 "nativeGallery": true
20538 }
20539 !! wikitext
20540 <gallery>
20541 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
20542 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
20543 </gallery>
20544 !! html/php
20545 <ul class="gallery mw-gallery-traditional">
20546 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20547 <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>
20548 <div class="gallerytext">
20549 <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>
20550 </p>
20551 </div>
20552 </div></li>
20553 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20554 <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>
20555 <div class="gallerytext">
20556 <p>This is a test template
20557 </p>
20558 </div>
20559 </div></li>
20560 </ul>
20561
20562 !! html/parsoid
20563 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20564 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"><span 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></span></div></li>
20565 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></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>
20566 </ul>
20567 !! end
20568
20569 !! test
20570 Gallery (with showfilename option)
20571 !! options
20572 parsoid={
20573 "nativeGallery": true
20574 }
20575 !! wikitext
20576 <gallery showfilename="">
20577 File:Nonexistent.jpg|caption
20578 File:Nonexistent.jpg
20579 File:Foobar.jpg|some '''caption''' [[Main Page]]
20580 File:Foobar.jpg
20581 </gallery>
20582 !! html/php
20583 <ul class="gallery mw-gallery-traditional">
20584 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20585 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20586 <div class="gallerytext">
20587 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20588 caption
20589 </p>
20590 </div>
20591 </div></li>
20592 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20593 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20594 <div class="gallerytext">
20595 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
20596 </p>
20597 </div>
20598 </div></li>
20599 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20600 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20601 <div class="gallerytext">
20602 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20603 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20604 </p>
20605 </div>
20606 </div></li>
20607 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20608 <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>
20609 <div class="gallerytext">
20610 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20611 </p>
20612 </div>
20613 </div></li>
20614 </ul>
20615
20616 !! html/parsoid
20617 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
20618 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"><a href="./File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">File:Nonexistent.jpg</a>caption</div></li>
20619 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"><a href="./File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">File:Nonexistent.jpg</a></div></li>
20620 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></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>
20621 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"><a href="./File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">File:Foobar.jpg</a></div></li>
20622 </ul>
20623 !! end
20624
20625 ## Should Parsoid be preserving these variations? See T151367
20626 !! test
20627 Gallery (with namespace-less filenames)
20628 !! options
20629 parsoid={
20630 "modes": ["wt2html", "html2html"],
20631 "nativeGallery": true
20632 }
20633 !! wikitext
20634 <gallery>
20635 File:Nonexistent.jpg
20636 Nonexistent.jpg
20637 image:foobar.jpg
20638 foobar.jpg
20639 </gallery>
20640 !! html/php
20641 <ul class="gallery mw-gallery-traditional">
20642 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20643 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20644 <div class="gallerytext">
20645 </div>
20646 </div></li>
20647 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20648 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20649 <div class="gallerytext">
20650 </div>
20651 </div></li>
20652 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20653 <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>
20654 <div class="gallerytext">
20655 </div>
20656 </div></li>
20657 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20658 <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>
20659 <div class="gallerytext">
20660 </div>
20661 </div></li>
20662 </ul>
20663
20664 !! html/parsoid
20665 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20666 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"></div></li>
20667 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"></div></li>
20668 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"></div></li>
20669 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"></div></li>
20670 </ul>
20671 !! end
20672
20673 !! test
20674 Gallery override link with WikiLink (T36852)
20675 !! options
20676 parsoid={
20677 "nativeGallery": true
20678 }
20679 !! wikitext
20680 <gallery>
20681 File:Foobar.jpg|alt=galleryalt|link=InterWikiLink
20682 </gallery>
20683 !! html/php
20684 <ul class="gallery mw-gallery-traditional">
20685 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20686 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/InterWikiLink"><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>
20687 <div class="gallerytext">
20688 </div>
20689 </div></li>
20690 </ul>
20691
20692 !! html/parsoid
20693 <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":{}}'>
20694 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:Image"><a href="./InterWikiLink"><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></span></div><div class="gallerytext"></div></li>
20695 </ul>
20696 !! end
20697
20698 !! test
20699 Gallery override link with absolute external link (T36852)
20700 !! options
20701 parsoid={
20702 "nativeGallery": true
20703 }
20704 !! wikitext
20705 <gallery>
20706 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
20707 </gallery>
20708 !! html/php
20709 <ul class="gallery mw-gallery-traditional">
20710 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20711 <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>
20712 <div class="gallerytext">
20713 </div>
20714 </div></li>
20715 </ul>
20716
20717 !! html/parsoid
20718 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20719 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"></div></li>
20720 </ul>
20721 !! end
20722
20723 !! test
20724 Gallery override link with absolute external link with LanguageConverter
20725 !! options
20726 language=zh
20727 !! input
20728 <gallery>
20729 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
20730 </gallery>
20731 !! result
20732 <ul class="gallery mw-gallery-traditional">
20733 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20734 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="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>
20735 <div class="gallerytext">
20736 <p>caption
20737 </p>
20738 </div>
20739 </div></li>
20740 </ul>
20741
20742 !! end
20743
20744 !! test
20745 Gallery override link with malicious javascript (T36852)
20746 !! options
20747 parsoid={
20748 "modes": ["wt2html", "html2html"],
20749 "nativeGallery": true
20750 }
20751 !! wikitext
20752 <gallery>
20753 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
20754 </gallery>
20755 !! html/php
20756 <ul class="gallery mw-gallery-traditional">
20757 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20758 <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>
20759 <div class="gallerytext">
20760 </div>
20761 </div></li>
20762 </ul>
20763
20764 !! html/parsoid
20765 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20766 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"></div></li>
20767 </ul>
20768 !! end
20769
20770 # Note that parsoid uses the invalid link as a caption, PHP does not.
20771 !! test
20772 Gallery with invalid title as link (T45964)
20773 !! options
20774 parsoid={
20775 "modes": ["wt2html", "html2html"],
20776 "nativeGallery": true
20777 }
20778 !! wikitext
20779 <gallery>
20780 File:Foobar.jpg|link=<
20781 </gallery>
20782 !! html/php
20783 <ul class="gallery mw-gallery-traditional">
20784 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20785 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/120px-Foobar.jpg" width="120" height="14" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/240px-Foobar.jpg 2x" /></a></div></div>
20786 <div class="gallerytext">
20787 </div>
20788 </div></li>
20789 </ul>
20790
20791 !! html/parsoid
20792 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20793 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext">link=&lt;</div></li>
20794 </ul>
20795 !! end
20796
20797 !! test
20798 Serialize gallery without attrs in data-mw
20799 !! options
20800 parsoid={
20801 "modes": ["html2wt"],
20802 "nativeGallery": true
20803 }
20804 !! html/parsoid
20805 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
20806 <li class="gallerycaption">123</li>
20807 <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>
20808 </ul>
20809 !! wikitext
20810 <gallery caption="123">
20811 File:Test.png
20812 </gallery>
20813 !! end
20814
20815 !! test
20816 Gallery with class and style attributes
20817 !! options
20818 parsoid={
20819 "nativeGallery": true
20820 }
20821 !! wikitext
20822 <gallery class="center" style="text-align: center;">
20823 File:Foobar.jpg
20824 </gallery>
20825 !! html/php
20826 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
20827 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20828 <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>
20829 <div class="gallerytext">
20830 </div>
20831 </div></li>
20832 </ul>
20833
20834 !! html/parsoid
20835 <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":{}}'>
20836 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span 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></span></div><div class="gallerytext"></div></li>
20837 </ul>
20838 !! end
20839
20840 !! test
20841 Gallery in slideshow mode
20842 !! options
20843 parsoid={
20844 "nativeGallery": true
20845 }
20846 !! wikitext
20847 <gallery mode="slideshow" showthumbnails="">
20848 File:Foobar.jpg
20849 </gallery>
20850 !! html/php
20851 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
20852 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20853 <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>
20854 <div class="gallerytext">
20855 </div>
20856 </div></li>
20857 </ul>
20858
20859 !! html/parsoid
20860 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
20861 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px;"><span 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></span></div><div class="gallerytext"></div></li>
20862 </ul>
20863 !! end
20864
20865 !! test
20866 HTML Hex character encoding (spells the word "JavaScript")
20867 !! options
20868 parsoid=wt2html,wt2wt,html2html
20869 !! wikitext
20870 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
20871 !! html/php
20872 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
20873 </p>
20874 !! html/php+tidy
20875 <p>JavaScript</p>
20876 !! html/parsoid
20877 <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>
20878 !! end
20879
20880 !! test
20881 HTML Hex character encoding bogus encoding (T28437 regression check)
20882 !! wikitext
20883 &#xsee;&#XSEE;
20884 !! html/php
20885 <p>&amp;#xsee;&amp;#XSEE;
20886 </p>
20887 !! html/parsoid
20888 <p>&amp;#xsee;&amp;#XSEE;</p>
20889 !! end
20890
20891 !! test
20892 HTML Hex character encoding mixed case
20893 !! options
20894 parsoid=wt2html,wt2wt,html2html
20895 !! wikitext
20896 &#xEE;&#Xee;
20897 !! html/php
20898 <p>&#xee;&#xee;
20899 </p>
20900 !! html/php+tidy
20901 <p>îî</p>
20902 !! html/parsoid
20903 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
20904 !! end
20905
20906 # See: https://www.w3.org/TR/html5/syntax.html#character-references
20907 # Note that U+000C (form feed) is not a valid XML character, so
20908 # it is banned even though allowed in HTML5.
20909 !! test
20910 Illegal character references (T106578)
20911 !! wikitext
20912 ; Null: &#00;
20913 ; FF: &#xC;
20914 ; CR: &#xD;
20915 ; Control (low): &#8;
20916 ; Control (high): &#x7F; &#x9F;
20917 ; Surrogate: &#xD83D;&#xDCA9;
20918 ; This is an okay astral character: &#x1F4A9;
20919 !! html+tidy
20920 <dl>
20921 <dt>Null</dt>
20922 <dd>&amp;#00;</dd>
20923 <dt>FF</dt>
20924 <dd>&amp;#xC;</dd>
20925 <dt>CR</dt>
20926 <dd>&amp;#xD;</dd>
20927 <dt>Control (low)</dt>
20928 <dd>&amp;#8;</dd>
20929 <dt>Control (high)</dt>
20930 <dd>&amp;#x7F; &amp;#x9F;</dd>
20931 <dt>Surrogate</dt>
20932 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
20933 <dt>This is an okay astral character</dt>
20934 <dd>💩</dd>
20935 </dl>
20936 !! end
20937
20938 !! test
20939 __FORCETOC__ override
20940 !! wikitext
20941 __NEWSECTIONLINK__
20942 __FORCETOC__
20943 !! html/php
20944 <p><br />
20945 </p>
20946 !! end
20947
20948 !! test
20949 ISBN code coverage
20950 !! wikitext
20951 ISBN 978-0-1234-56&#x20;789
20952 !! html
20953 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
20954 </p>
20955 !! html+tidy
20956 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a> 789</p>
20957 !! html/parsoid
20958 <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>
20959 !! end
20960
20961 !! test
20962 ISBN followed by 5 spaces
20963 !! wikitext
20964 ISBN
20965 !! html
20966 <p>ISBN
20967 </p>
20968 !! end
20969
20970 !! test
20971 Double ISBN
20972 !! wikitext
20973 ISBN ISBN 1234567890
20974 !! html/php
20975 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20976 </p>
20977 !! html/parsoid
20978 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
20979 !! end
20980
20981 # Uppercase X and lowercase x as well
20982 !! test
20983 ISBN with an X
20984 !! wikitext
20985 ISBN 3-462-04561-X
20986 ISBN 3-462-04561-x
20987 ISBN 080442957X
20988 ISBN 080442957x
20989 ISBN 978080442957X
20990 ISBN 978080442957x
20991 !! html/php
20992 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
20993 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
20994 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
20995 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
20996 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
20997 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
20998 </p>
20999 !! html/parsoid
21000 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
21001 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
21002 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
21003 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
21004 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
21005 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
21006 !! end
21007
21008 !! test
21009 ISBN with empty prefix (parsoid test)
21010 !! wikitext
21011 ISBN 1234567890
21012 !! html/php
21013 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21014 </p>
21015 !! html/parsoid
21016 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
21017 !! end
21018
21019 !! test
21020 T24905: <abbr> followed by ISBN followed by </a>
21021 !! wikitext
21022 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
21023 !! html/php
21024 <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>
21025 </p>
21026 !! html/parsoid
21027 <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>
21028 !! end
21029
21030 !! test
21031 Double RFC
21032 !! wikitext
21033 RFC RFC 1234
21034 !! html
21035 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a>
21036 </p>
21037 !! end
21038
21039 !! test
21040 Double RFC with a wiki link
21041 !! wikitext
21042 RFC [[RFC 1234]]
21043 !! html
21044 <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>
21045 </p>
21046 !! end
21047
21048 !! test
21049 RFC code coverage
21050 !! wikitext
21051 RFC 983&#x20;987
21052 !! html
21053 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
21054 </p>
21055 !! html+tidy
21056 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc983">RFC 983</a> 987</p>
21057 !! end
21058
21059 !! test
21060 Centre-aligned image
21061 !! wikitext
21062 [[Image:foobar.jpg|centre]]
21063 !! html
21064 <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>
21065
21066 !!end
21067
21068 !! test
21069 None-aligned image
21070 !! wikitext
21071 [[Image:foobar.jpg|none]]
21072 !! html
21073 <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>
21074
21075 !!end
21076
21077 !! test
21078 Width + Height sized image (using px) (height is ignored)
21079 !! wikitext
21080 [[Image:foobar.jpg|640x480px]]
21081 !! html
21082 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
21083 </p>
21084 !!end
21085
21086 !! test
21087 Width-sized image (using px, no following whitespace)
21088 !! wikitext
21089 [[Image:foobar.jpg|640px]]
21090 !! html
21091 <p><a href="/wiki/File:Foobar.jpg" class="image"><img alt="Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/640px-Foobar.jpg" width="640" height="73" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/960px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/1280px-Foobar.jpg 2x" /></a>
21092 </p>
21093 !!end
21094
21095 !! test
21096 Width-sized image (using px, with following whitespace - test regression from r39467)
21097 !! wikitext
21098 [[Image:foobar.jpg|640px ]]
21099 !! html
21100 <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>
21101 </p>
21102 !!end
21103
21104 !! test
21105 Width-sized image (using px, with preceding whitespace - test regression from r39467)
21106 !! wikitext
21107 [[Image:foobar.jpg| 640px]]
21108 !! html
21109 <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>
21110 </p>
21111 !!end
21112
21113 !! test
21114 Image with page parameter
21115 !! options
21116 djvu
21117 !! wikitext
21118 [[File:LoremIpsum.djvu|page=2]]
21119 !! html/php
21120 <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>
21121 </p>
21122 !! html/parsoid
21123 <p><span 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></span></p>
21124 !! end
21125
21126 !! test
21127 Another italics / bold test
21128 !! wikitext
21129 ''' ''x'
21130 !! html
21131 <pre>'<i> </i>x'
21132 </pre>
21133 !!end
21134
21135 # FIXME: The php output seems broken. It's interleaving some open/close tags.
21136 !! test
21137 dt/dd/dl test
21138 !! wikitext
21139 :;;;::
21140 !! html/php
21141 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
21142
21143 !! html/parsoid
21144 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
21145
21146 !!end
21147
21148 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
21149 !! test
21150 Images with the "|" character in the comment
21151 !! wikitext
21152 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
21153 !! html/php
21154 <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>
21155
21156 !! html/parsoid
21157 <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>
21158 !! end
21159
21160 !! test
21161 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
21162 !! wikitext
21163 <html><script>alert(1);</script></html>
21164 !! html
21165 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
21166 </p>
21167 !! end
21168
21169 !! test
21170 HTML with raw HTML ($wgRawHtml==true)
21171 !! options
21172 wgRawHtml=1
21173 !! wikitext
21174 <html><script>alert(1);</script></html>
21175 !! html/php
21176 <p><script>alert(1);</script>
21177 </p>
21178 !! end
21179
21180 !! test
21181 Parents of subpages, one level up
21182 !! options
21183 subpage title=[[Subpage test/L1/L2/L3]]
21184 !! wikitext
21185 [[../|L2]]
21186 !! html
21187 <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>
21188 </p>
21189 !! end
21190
21191
21192 !! test
21193 Parents of subpages, one level up, not named
21194 !! options
21195 subpage title=[[Subpage test/L1/L2/L3]]
21196 !! wikitext
21197 [[../]]
21198 !! html
21199 <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>
21200 </p>
21201 !! end
21202
21203
21204
21205 !! test
21206 Parents of subpages, two levels up
21207 !! options
21208 subpage title=[[Subpage test/L1/L2/L3]]
21209 !! wikitext
21210 [[../../|L1]]2
21211
21212 [[../../|L1]]l
21213 !! html
21214 <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
21215 </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>
21216 </p>
21217 !! end
21218
21219 !! test
21220 Parents of subpages, two levels up, without trailing slash or name.
21221 !! options
21222 subpage title=[[Subpage test/L1/L2/L3]]
21223 !! wikitext
21224 [[../..]]
21225 !! html
21226 <p>[[../..]]
21227 </p>
21228 !! end
21229
21230 !! test
21231 Parents of subpages, two levels up, with lots of extra trailing slashes.
21232 !! options
21233 subpage title=[[Subpage test/L1/L2/L3]]
21234 !! wikitext
21235 [[../../////]]
21236 !! html
21237 <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>
21238 </p>
21239 !! end
21240
21241 !! article
21242 Subpage test/L1/L2/L3Sibling
21243 !! text
21244 Sibling article
21245 !! endarticle
21246
21247 !! test
21248 Transclusion of a sibling page (one level up)
21249 !! options
21250 subpage title=[[Subpage test/L1/L2/L3]]
21251 !! wikitext
21252 {{../L3Sibling}}
21253 !! html
21254 <p>Sibling article
21255 </p>
21256 !! end
21257
21258 !! test
21259 Transclusion of a child page
21260 !! options
21261 subpage title=[[Subpage test/L1/L2]]
21262 !! wikitext
21263 {{/L3Sibling}}
21264 !! html
21265 <p>Sibling article
21266 </p>
21267 !! end
21268
21269 # This is wt2html only in Parsoid because we add <nowiki>
21270 # because of {{..}} and we don't expect to fix that to
21271 # eliminate the nowikis selective for {{..}} markup.
21272 !! test
21273 Non-transclusion because of too many up levels
21274 !! options
21275 subpage title=[[Subpage test/L1/L2/L3]]
21276 parsoid=wt2html
21277 !! wikitext
21278 {{../../../../More than parent}}
21279 !! html/php
21280 <p>{{../../../../More than parent}}
21281 </p>
21282 !! html/parsoid
21283 <p>{{../../../../More than parent}}</p>
21284 !! end
21285
21286 !! test
21287 Definition list code coverage
21288 !! wikitext
21289 ; title : def
21290 ; title : def
21291 ;title: def
21292 !! html/php
21293 <dl><dt> title &#160;</dt>
21294 <dd> def</dd>
21295 <dt> title&#160;</dt>
21296 <dd> def</dd>
21297 <dt>title</dt>
21298 <dd> def</dd></dl>
21299
21300 !! html/parsoid
21301 <dl><dt> title <span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21302 <dt> title<span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
21303 <dt>title</dt><dd> def</dd></dl>
21304 !! end
21305
21306 !! test
21307 Don't fall for the self-closing div
21308 !! wikitext
21309 <div>hello world</div/>
21310 !! html
21311 <div>hello world</div>
21312
21313 !! end
21314
21315 !! test
21316 MSGNW magic word
21317 !! wikitext
21318 {{MSGNW:msg}}
21319 !! html/php
21320 <p>&#91;&#91;:Template:Msg&#93;&#93;
21321 </p>
21322 !! end
21323
21324 !! test
21325 RAW magic word
21326 !! wikitext
21327 {{RAW:QUERTY}}
21328 !! html
21329 <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>
21330 </p>
21331 !! end
21332
21333 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
21334 !! test
21335 Always escape literal '>' in output, not just after '<'
21336 !! wikitext
21337 ><>
21338 !! html
21339 <p>&gt;&lt;&gt;
21340 </p>
21341 !! end
21342
21343 !! test
21344 Template caching
21345 !! wikitext
21346 {{Test}}
21347 {{Test}}
21348 !! html
21349 <p>This is a test template
21350 This is a test template
21351 </p>
21352 !! end
21353
21354
21355 !! article
21356 MediaWiki:Fake
21357 !! text
21358 ==header==
21359 !! endarticle
21360
21361 !! test
21362 Inclusion of !userCanEdit() content
21363 !! wikitext
21364 {{MediaWiki:Fake}}
21365 !! html
21366 <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>
21367
21368 !! end
21369
21370
21371 !! test
21372 Out-of-order TOC heading levels
21373 !! wikitext
21374 ==2==
21375 ======6======
21376 ===3===
21377 =1=
21378 =====5=====
21379 ==2==
21380 !! html
21381 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
21382 <ul>
21383 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
21384 <ul>
21385 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
21386 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
21387 </ul>
21388 </li>
21389 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
21390 <ul>
21391 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
21392 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
21393 </ul>
21394 </li>
21395 </ul>
21396 </div>
21397
21398 <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>
21399 <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>
21400 <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>
21401 <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>
21402 <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>
21403 <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>
21404
21405 !! end
21406
21407
21408 !! test
21409 ISBN with a dummy number
21410 !! wikitext
21411 ISBN ---
21412 !! html
21413 <p>ISBN ---
21414 </p>
21415 !! end
21416
21417
21418 !! test
21419 ISBN with space-delimited number
21420 !! wikitext
21421 ISBN 92 9017 032 8
21422 !! html/php
21423 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
21424 </p>
21425 !! html/parsoid
21426 <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>
21427 !! end
21428
21429
21430 !! test
21431 ISBN with multiple spaces, no number
21432 !! wikitext
21433 ISBN foo
21434 !! html
21435 <p>ISBN foo
21436 </p>
21437 !! end
21438
21439
21440 !! test
21441 ISBN length
21442 !! wikitext
21443 ISBN 123456789
21444
21445 ISBN 1234567890
21446
21447 ISBN 12345678901
21448 !! html/php
21449 <p>ISBN 123456789
21450 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
21451 </p><p>ISBN 12345678901
21452 </p>
21453 !! html/parsoid
21454 <p>ISBN 123456789</p>
21455
21456 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
21457
21458 <p>ISBN 12345678901</p>
21459 !! end
21460
21461
21462 !! test
21463 ISBN with trailing year (T9110)
21464 !! wikitext
21465 ISBN 1-234-56789-0 - 2006
21466
21467 ISBN 1 234 56789 0 - 2006
21468 !! html/php
21469 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
21470 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
21471 </p>
21472 !! html/parsoid
21473 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
21474
21475 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
21476 !! end
21477
21478
21479 !! test
21480 anchorencode
21481 !! wikitext
21482 {{anchorencode:foo bar©#%n}}
21483 !! html
21484 <p>foo_bar.C2.A9.23.25n
21485 </p>
21486 !! end
21487
21488 !! test
21489 anchorencode trims spaces
21490 !! wikitext
21491 {{anchorencode: __pretty__please__}}
21492 !! html
21493 <p>pretty_please
21494 </p>
21495 !! end
21496
21497 !! test
21498 anchorencode deals with links
21499 !! wikitext
21500 {{anchorencode: [[hello|world]] [[hi]]}}
21501 !! html
21502 <p>world_hi
21503 </p>
21504 !! end
21505
21506 !! test
21507 anchorencode deals with templates
21508 !! wikitext
21509 {{anchorencode: {{Foo}} }}
21510 !! html
21511 <p>FOO
21512 </p>
21513 !! end
21514
21515 !! test
21516 anchorencode encodes like the TOC generator: (T20431)
21517 !! wikitext
21518 === _ +:.3A%3A&&amp;]] ===
21519 {{anchorencode: _ +:.3A%3A&&amp;]] }}
21520 __NOEDITSECTION__
21521 !! html
21522 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
21523 <p>.2B:.3A.253A.26.26.5D.5D
21524 </p>
21525 !! end
21526
21527 !! test
21528 T8200: blockquotes and paragraph formatting
21529 !! wikitext
21530 <blockquote>
21531 foo
21532 </blockquote>
21533
21534 bar
21535
21536 baz
21537 !! html
21538 <blockquote>
21539 <p>foo
21540 </p>
21541 </blockquote>
21542 <p>bar
21543 </p>
21544 <pre>baz
21545 </pre>
21546 !! end
21547
21548 !! test
21549 T10293: Use of center tag ruins paragraph formatting
21550 !! wikitext
21551 <center>
21552 foo
21553 </center>
21554
21555 bar
21556
21557 baz
21558 !! html
21559 <center>
21560 <p>foo
21561 </p>
21562 </center>
21563 <p>bar
21564 </p>
21565 <pre>baz
21566 </pre>
21567 !! end
21568
21569 !!test
21570 Parsing of overlapping (improperly nested) inline html tags
21571 !! wikitext
21572 <span><s>x</span></s>
21573 !! html/php
21574 <p><span><s>x&lt;/span&gt;</s></span>
21575 </p>
21576 !! html/parsoid
21577 <p><span><s>x</s></span>
21578 </p>
21579 !!end
21580
21581 ###
21582 ### Language variants related tests
21583 ###
21584
21585 # Parsoid does not mark self-links.
21586 # Parsoid does not convert links; PHP will do any necessary redirects.
21587
21588 !! test
21589 Self-link in language variants
21590 !! options
21591 title=[[Dunav]] language=sr
21592 !! wikitext
21593 Both [[Dunav]] and [[Дунав]] are names for this river.
21594 !! html/php
21595 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
21596 </p>
21597 !! html/parsoid
21598 <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>
21599 !! end
21600
21601 !! article
21602 Дуна
21603 !! text
21604 content
21605 !! endarticle
21606
21607 !! test
21608 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
21609 !! options
21610 title=[[Duna]] language=sr
21611 !! wikitext
21612 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
21613 !! html/php
21614 <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.
21615 </p>
21616 !! html/parsoid
21617 <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>
21618 !! end
21619
21620 !! test
21621 Link to a section of a variant of this title shouldn't be parsed as self-link
21622 !! options
21623 title=[[Duna]] language=sr
21624 !! wikitext
21625 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
21626 !! html/php
21627 <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.
21628 </p>
21629 !! html/parsoid
21630 <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>
21631 !! end
21632
21633 !! test
21634 Link to pages in language variants
21635 !! options
21636 language=sr
21637 !! wikitext
21638 Main Page can be written as [[Маин Паге]]
21639 !! html/php
21640 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
21641 </p>
21642 !! html/parsoid
21643 <p>Main Page can be written as <a rel="mw:WikiLink" href="./Маин_Паге" title="Маин Паге">Маин Паге</a></p>
21644 !! end
21645
21646
21647 !! test
21648 Multiple links to pages in language variants
21649 !! options
21650 language=sr
21651 !! wikitext
21652 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
21653 !! html/php
21654 <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>.
21655 </p>
21656 !! html/parsoid
21657 <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>
21658 !! end
21659
21660
21661 !! test
21662 Simple template in language variants
21663 !! options
21664 language=sr
21665 !! wikitext
21666 {{тест}}
21667 !! html/php
21668 <p>This is a test template
21669 </p>
21670 !! end
21671
21672
21673 !! test
21674 Template with explicit namespace in language variants
21675 !! options
21676 language=sr
21677 !! wikitext
21678 {{Template:тест}}
21679 !! html/php
21680 <p>This is a test template
21681 </p>
21682 !! end
21683
21684
21685 !! test
21686 Basic test for template parameter in language variants
21687 !! options
21688 language=sr
21689 !! wikitext
21690 {{парамтест|param=foo}}
21691 !! html/php
21692 <p>This is a test template with parameter foo
21693 </p>
21694 !! end
21695
21696 !! test
21697 Simple category in language variants
21698 !! options
21699 language=sr cat
21700 !! wikitext
21701 [[Category:МедиаWики Усер'с Гуиде]]
21702 !! html/php
21703 cat=МедиаWики_Усер'с_Гуиде sort=
21704 !! html/parsoid
21705 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
21706 !! end
21707
21708 !! article
21709 Category:分类
21710 !! text
21711 blah
21712 !! endarticle
21713
21714 !! article
21715 Category:分類
21716 !! text
21717 blah
21718 !! endarticle
21719
21720 ## We used to, but no longer wt2wt this test since the default serializer
21721 ## will normalize all categories to serialize on their own line.
21722 ## This wikitext usage is going to be fairly uncommon in production and
21723 ## selser will take care of preserving formatting in those scenarios.
21724 !! test
21725 Don't convert blue categorylinks to another variant (T35210)
21726 !! options
21727 cat
21728 language=zh
21729 parsoid=wt2html
21730 !! wikitext
21731 [[A]][[Category:分类]]
21732 !! html/php
21733 cat=分类 sort=
21734 !! html/parsoid
21735 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
21736 <link rel="mw:PageProp/Category" href="./Category:分类"/>
21737 !! end
21738
21739 !! test
21740 Stripping -{}- tags (language variants)
21741 !! options
21742 language=sr
21743 !! wikitext
21744 Latin proverb: -{Ne nuntium necare}-
21745 !! html/php
21746 <p>Latin proverb: Ne nuntium necare
21747 </p>
21748 !! html/parsoid
21749 <p>Latin proverb: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21750 !! end
21751
21752
21753 !! test
21754 Prevent conversion with -{}- tags (language variants)
21755 !! options
21756 language=sr variant=sr-ec
21757 !! wikitext
21758 Latinski: -{Ne nuntium necare}-
21759 !! html/php
21760 <p>Латински: Ne nuntium necare
21761 </p>
21762 !! html/parsoid
21763 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21764 !! end
21765
21766
21767 !! test
21768 Prevent conversion of text with -{}- tags (language variants)
21769 !! options
21770 language=sr variant=sr-ec
21771 !! wikitext
21772 Latinski: -{Ne nuntium necare}-
21773 !! html/php
21774 <p>Латински: Ne nuntium necare
21775 </p>
21776 !! html/parsoid
21777 <p>Latinski: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Ne nuntium necare"}}'></span></p>
21778 !! end
21779
21780
21781 !! test
21782 Prevent conversion of links with -{}- tags (language variants)
21783 !! options
21784 language=sr variant=sr-ec
21785 !! wikitext
21786 -{[[Main Page]]}-
21787 !! html/php
21788 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21789 </p>
21790 !! html/parsoid
21791 <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>
21792 !! end
21793
21794
21795 !! test
21796 -{}- tags within headlines (within html for parserConvert())
21797 !! options
21798 language=sr variant=sr-ec
21799 !! wikitext
21800 == -{Naslov}- ==
21801
21802 Note that even an unprotected headline ID is not affected by language
21803 conversion:
21804
21805 == Latinski ==
21806 !! html/php
21807 <h2><span class="mw-headline" id="-.7BNaslov.7D-">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>
21808 <p>Ноте тхат евен ан унпротецтед хеадлине ИД ис нот аффецтед бy лангуаге
21809 цонверсион:
21810 </p>
21811 <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>
21812
21813 !! html/parsoid
21814 <h2 id="-.7BNaslov.7D-"><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Naslov"}}'></span></h2>
21815
21816 <p>Note that even an unprotected headline ID is not affected by language
21817 conversion:</p>
21818
21819 <h2 id="Latinski">Latinski</h2>
21820 !! end
21821
21822 !! test
21823 Explicit definition of language variant alternatives
21824 !! options
21825 language=zh variant=zh-tw
21826 !! wikitext
21827 -{zh:China;zh-tw:Taiwan}-, not China
21828 !! html/php
21829 <p>Taiwan, not China
21830 </p>
21831 !! html/parsoid
21832 <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>
21833 !! end
21834
21835 !! test
21836 Filter syntax for language variants
21837 !! options
21838 language=zh variant=zh-tw
21839 !! wikitext
21840 foo-{zh;zh-hans;zh-hant|blog, WEBJOURNAL, WEBLOG}-quux
21841 !! html/php
21842 <p>fooblog, WEBJOURNAL, WEBLOGquux
21843 </p>
21844 !! html/parsoid
21845 <p>foo<span typeof="mw:LanguageVariant" data-mw-variant='{"filter":{"l":["zh","zh-hans","zh-hant"],"t":"blog, WEBJOURNAL, WEBLOG"}}'></span>quux</p>
21846 !! end
21847
21848 # Note that Parsoid post-processing for language variants needs to
21849 # update the `title` attribute here, based on the mw:ExpandedAttrs property
21850 !! test
21851 Conversion around HTML tags
21852 !! options
21853 language=sr variant=sr-ec
21854 !! wikitext
21855 -{H|span=>sr-ec:script;title=>sr-ec:src}-
21856 <span title="La-{sr-el:L;sr-ec:C}-tin">ski</span>
21857 !! html/php
21858 <p>
21859 <span title="ЛаCтин">ски</span>
21860 </p>
21861 !! html/parsoid
21862 <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"}]}'/>
21863 <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>
21864 !! end
21865
21866 !! test
21867 Explicit session-wise two-way language variant mapping (A flag and - flag)
21868 !! options
21869 language=zh variant=zh-tw
21870 !! wikitext
21871 This is -{zh:China; zh-tw:Taiwan}-, but we'll forget that now.
21872
21873 Taiwan is not China.
21874
21875 But -{A|zh:China; zh-tw:Taiwan}- is China,
21876
21877 (This-{-|zh:China; zh-tw:Taiwan}- should be stripped!)
21878
21879 and -{China}- is China.
21880 !! html/php
21881 <p>This is Taiwan, but we'll forget that now.
21882 </p><p>Taiwan is not China.
21883 </p><p>But Taiwan is Taiwan,
21884 </p><p>(This should be stripped!)
21885 </p><p>and China is China.
21886 </p>
21887 !! html/parsoid
21888 <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>
21889 <p>Taiwan is not China.</p>
21890 <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>
21891 <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>
21892 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"China"}}'></span> is China.</p>
21893 !! end
21894
21895 !! test
21896 Explicit session-wise one-way language variant mapping (A flag and - flag)
21897 !! options
21898 language=zh variant=zh-tw
21899 !! wikitext
21900 This is -{COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}-, but we'll forget that now.
21901
21902 COUNTRY is China or Taiwan.
21903
21904 But -{A|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- is COUNTRY,
21905
21906 (This-{-|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
21907
21908 and -{COUNTRY}- is COUNTRY.
21909 !! html/php
21910 <p>This is Taiwan, but we'll forget that now.
21911 </p><p>COUNTRY is China or Taiwan.
21912 </p><p>But Taiwan is Taiwan,
21913 </p><p>(This should be stripped!)
21914 </p><p>and COUNTRY is COUNTRY.
21915 </p>
21916 !! html/parsoid
21917 <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>
21918 <p>COUNTRY is China or Taiwan.</p>
21919 <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>
21920 <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>
21921 <p>and <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"COUNTRY"}}'></span> is COUNTRY.</p>
21922 !! end
21923
21924 !! test
21925 Explicit session-wise two-way language variant mapping (H flag for hide)
21926 !! options
21927 language=zh variant=zh-tw
21928 !! wikitext
21929 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
21930
21931 Taiwan is China.
21932 !! html/php
21933 <p>(This should be stripped!)
21934 </p><p>Taiwan is Taiwan.
21935 </p>
21936 !! html/parsoid
21937 <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>
21938 <p>Taiwan is China.</p>
21939 !! end
21940
21941 !! test
21942 Explicit session-wise one-way language variant mapping (H flag for hide)
21943 !! options
21944 language=zh variant=zh-tw
21945 !! wikitext
21946 (This-{H|COUNTRY=>zh:China;COUNTRY=>zh-tw:Taiwan}- should be stripped!)
21947
21948 COUNTRY is Taiwan or China.
21949 !! html/php
21950 <p>(This should be stripped!)
21951 </p><p>Taiwan is Taiwan or China.
21952 </p>
21953 !! html/parsoid
21954 <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>
21955 <p>COUNTRY is Taiwan or China.</p>
21956 !! end
21957
21958 ## Note that parsoid test runner does not support 'showtitle' option.
21959 !! test
21960 Adding explicit conversion rule for title (T flag)
21961 !! options
21962 language=zh variant=zh-tw showtitle
21963 !! wikitext
21964 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
21965
21966 Taiwan is China.
21967 !! html/php
21968 Taiwan
21969 <p>Should be stripped!
21970 </p><p>Taiwan is China.
21971 </p>
21972 !! html/parsoid
21973 <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>
21974 <p>Taiwan is China.</p>
21975 !! end
21976
21977 !! test
21978 Code coverage: T combined with H flag
21979 !! options
21980 language=zh variant=zh-tw showtitle
21981 !! wikitext
21982 Should be stripped-{T;H|zh:China; zh-tw:Taiwan}-!
21983
21984 Taiwan is China.
21985 !! html/php
21986 Taiwan
21987 <p>Should be stripped!
21988 </p><p>Taiwan is Taiwan.
21989 </p>
21990 !! html/parsoid
21991 <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>
21992 <p>Taiwan is China.</p>
21993 !! end
21994
21995 !! test
21996 Code coverage: T with no variants
21997 !! options
21998 language=zh variant=zh-tw showtitle
21999 !! wikitext
22000 -{H|zh:China; zh-tw:Taiwan}-
22001 Taiwan is China.-{T|Taiwan is China}-
22002 !! html/php
22003 Taiwan is China
22004 <p>
22005 Taiwan is Taiwan.
22006 </p>
22007 !! html/parsoid
22008 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22009 Taiwan is China.<meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Taiwan is China"},"title":true}'/></p>
22010 !! end
22011
22012 !! test
22013 Code coverage: rules with no variants
22014 !! options
22015 language=zh variant=zh-tw
22016 !! wikitext
22017 -{H|zh:China; zh-tw:Taiwan}-
22018 Taiwan is China.
22019 -{H|China}-
22020 Taiwan is China.
22021 !! html/php
22022 <p>
22023 Taiwan is Taiwan.
22024
22025 Taiwan is China.
22026 </p>
22027 !! html/parsoid
22028 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>
22029 Taiwan is China.
22030 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":"China"}]}'/>
22031 Taiwan is China.</p>
22032 !! end
22033
22034
22035 !! test
22036 Code coverage: D flag for conversion rule
22037 !! options
22038 language=zh variant=zh-tw
22039 !! wikitext
22040 -{D|zh-cn:XA; zh-tw:YA}-
22041 -{A;D|zh-cn:XB; zh-tw:YB}-
22042 -{D;H|zh-cn:XC; zh-tw:YC}-
22043
22044 -{D;H|FOO=>zh-tw:BAR;FOO=>zh-cn:BAT}-
22045
22046 -{D|0=>zh-tw:1}-
22047 -{A;D|2=>zh-tw:3}-
22048 -{D;H|4=>zh-tw:5}-
22049
22050 XA XB XC YA YB YC FOO BAR BAT 012345
22051 !! html/php
22052 <p>大陆:XA;台灣:YA;
22053
22054 大陆:XC;台灣:YC;
22055 </p><p>FOO⇒台灣:BAR;FOO⇒大陆:BAT;
22056 </p><p>0⇒台灣:1;
22057
22058 4⇒台灣:5;
22059 </p><p>XA YB YC YA YB YC BAR BAR BAT 013355
22060 </p>
22061 !! html/parsoid
22062 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"twoway":[{"l":"zh-cn","t":"XA"},{"l":"zh-tw","t":"YA"}]}'></span>
22063 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XB"},{"l":"zh-tw","t":"YB"}]}'/>
22064 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"twoway":[{"l":"zh-cn","t":"XC"},{"l":"zh-tw","t":"YC"}]}'></span></p>
22065 <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>
22066 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"describe":true,"oneway":[{"f":"0","l":"zh-tw","t":"1"}]}'></span>
22067 <meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"2","l":"zh-tw","t":"3"}]}'/>
22068 <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"describe":true,"oneway":[{"f":"4","l":"zh-tw","t":"5"}]}'></span></p>
22069 <p>XA XB XC YA YB YC FOO BAR BAT 012345</p>
22070 !! end
22071
22072 !! test
22073 Code coverage: N flag for conversion rule
22074 !! options
22075 language=zh variant=zh-cn
22076 !! wikitext
22077 -{N|zh-cn}-
22078
22079 -{N|zh-tw}-
22080
22081 -{N|sr-ec}-
22082 !! html/php
22083 <p>大陆
22084 </p><p>台灣
22085 </p><p>српски (ћирилица)‎
22086 </p>
22087 !! html/parsoid
22088 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-cn"}}'></span></p>
22089 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"zh-tw"}}'></span></p>
22090 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"sr-ec"}}'></span></p>
22091 !! end
22092
22093 # html2wt suppresses the bogus 'D' flag, so this is wt2html only
22094 !! test
22095 Code coverage: N flag for conversion rule (wt2html only)
22096 !! options
22097 language=zh variant=zh-cn
22098 parsoid=wt2html,html2html
22099 !! wikitext
22100 -{D;N|en}-
22101 !! html/php
22102 <p>English
22103 </p>
22104 !! html/parsoid
22105 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"name":{"t":"en"}}' data-parsoid='{"fl":["D","N"]}'></span></p>
22106 !! end
22107
22108 !! test
22109 Testing that changing the language variant here in the tests actually works
22110 !! options
22111 language=zh variant=zh showtitle
22112 !! wikitext
22113 Should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22114 !! html/php
22115 China
22116 <p>Should be stripped!
22117 </p>
22118 !! html/parsoid
22119 <p>Should be stripped<meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"zh","t":"China"},{"l":"zh-tw","t":"Taiwan"}]}'/>!</p>
22120 !! end
22121
22122 !! test
22123 Recursive conversion of alt and title attrs shouldn't clear converter state
22124 !! options
22125 language=zh variant=zh-cn
22126 showtitle
22127 !! wikitext
22128 -{H|zh-cn:Exclamation; zh-tw:exclamation}-
22129 Should be stripped-{T|zh-cn:China; zh-tw:Taiwan}-<span title="exclamation">!</span>
22130 !! html/php
22131 China
22132 <p>
22133 Should be stripped<span title="Exclamation">!</span>
22134 </p>
22135 !! html/parsoid
22136 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"zh-cn","t":"Exclamation"},{"l":"zh-tw","t":"exclamation"}]}'/>
22137 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>
22138 !! end
22139
22140 !! test
22141 T26072: more test on conversion rule for title
22142 !! options
22143 language=zh variant=zh-tw showtitle
22144 !! wikitext
22145 This should be stripped-{T|zh:China; zh-tw:Taiwan}-!
22146
22147 This won't take interferes with the title rule-{H|zh:Beijing; zh-tw:Taipei}-.
22148 !! html/php
22149 Taiwan
22150 <p>This should be stripped!
22151 </p><p>This won't take interferes with the title rule.
22152 </p>
22153 !! html/parsoid
22154 <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>
22155 <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>
22156 !! end
22157
22158 !! test
22159 Partly disable title conversion if variant == main language code
22160 !! options
22161 language=zh variant=zh title=[[ZH]] showtitle
22162 !! wikitext
22163 -{T|zh-cn:CN;zh-tw:TW}-
22164 !! html/php
22165 ZH
22166 <p>
22167 </p>
22168 !! html/parsoid
22169 <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>
22170 !! end
22171
22172 !! test
22173 Partly disable title conversion if variant == main language code, more
22174 !! options
22175 language=zh variant=zh title=[[ZH]] showtitle
22176 !! wikitext
22177 -{T|TW}-
22178 !! html/php
22179 ZH
22180 <p>
22181 </p>
22182 !! html/parsoid
22183 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"TW"},"title":true}'/></p>
22184 !! end
22185
22186 !! test
22187 Raw output of variant escape tags (R flag)
22188 !! options
22189 language=zh variant=zh-tw
22190 !! wikitext
22191 Raw: -{R|zh:China;zh-tw:Taiwan}-
22192 !! html/php
22193 <p>Raw: zh:China;zh-tw:Taiwan
22194 </p>
22195 !! html/parsoid
22196 <p>Raw: <span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"zh:China;zh-tw:Taiwan"}}'></span></p>
22197 !! end
22198
22199 # html2wt suppresses the bogus 'D' flags, so this is wt2html only
22200 !! test
22201 Raw output of variant escape tags (R flag) (wt2html only)
22202 !! options
22203 language=zh variant=zh-tw
22204 parsoid=wt2html,html2html
22205 !! wikitext
22206 -{Variant}- -{D|syntax}- -{D;R|options}-
22207 !! html/php
22208 <p>Variant syntax options
22209 </p>
22210 !! html/parsoid
22211 <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>
22212 !! end
22213
22214 !! test
22215 Nested markup inside raw output of variant escape tags (R flag)
22216 !! options
22217 language=zh variant=zh-tw
22218 !! wikitext
22219 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
22220 !! html/php
22221 <p>Nested raw: nested Taiwan nested
22222 </p>
22223 !! html/parsoid
22224 <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>
22225 !! end
22226
22227 !! test
22228 Nested markup and spaces inside raw output of variant escape tags (R flag)
22229 !! options
22230 language=zh variant=zh-tw
22231 !! wikitext
22232 X-{ outer -{ inner }- outer }-X
22233 !! html/php
22234 <p>X outer inner outer X
22235 </p>
22236 !! html/parsoid
22237 <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>
22238 !! end
22239
22240 !! test
22241 Templates inside raw output of variant escape tags (R flag)
22242 !! options
22243 language=zh variant=zh-tw
22244 !! wikitext
22245 Nested raw: -{R|nested {{echo|hi}} templates}-
22246 !! html/php
22247 <p>Nested raw: nested hi templates
22248 </p>
22249 !! html/parsoid
22250 <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>
22251 !! end
22252
22253 !! test
22254 Strings evaluating false shouldn't be ignored by Language converter (T51072)
22255 !! options
22256 language=zh variant=zh-cn
22257 !! input
22258 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
22259 !! html/php
22260 <p>0
22261 </p>
22262 !! html/parsoid
22263 <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>
22264 !! end
22265
22266 !! test
22267 Conversion rules from [numeric-only string] to [something else] (T48634)
22268 !! options
22269 language=zh variant=zh-cn
22270 !! input
22271 -{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
22272 !! html/php
22273 <p>D12345EE12345
22274 </p>
22275 !! html/parsoid
22276 <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>
22277 !! end
22278
22279 !! test
22280 Two-way converter rule entries with an empty value should be ignored (T53551)
22281 !! options
22282 language=zh variant=zh-cn
22283 !! input
22284 -{H|zh-cn:foo;zh-tw:;}-foobar
22285 !! html/php
22286 <p>foobar
22287 </p>
22288 !! html/parsoid
22289 <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>
22290 !! end
22291
22292 !! test
22293 One-way converter rule entries with an empty "from" string should be ignored (T53551)
22294 !! options
22295 language=zh variant=zh-cn
22296 !! input
22297 -{H|=>zh-cn:foo;}-foobar
22298 !! html/php
22299 <p>foobar
22300 </p>
22301 !! html/parsoid
22302 <p><meta typeof="mw:LanguageVariant" data-parsoid='{"tSp":[5]}' data-mw-variant='{"add":true,"oneway":[{"f":"","l":"zh-cn","t":"foo"}]}'/>foobar</p>
22303 !! end
22304
22305 !! test
22306 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
22307 !! options
22308 language=zh variant=zh-cn
22309 !! input
22310 -{H|}-foobar
22311 !! html/php
22312 <p>foobar
22313 </p>
22314 !! html/parsoid
22315 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"*","t":""}]}'/>foobar</p>
22316 !! end
22317
22318 !! test
22319 Nested using of manual convert syntax
22320 !! options
22321 language=zh variant=zh-hk
22322 !! wikitext
22323 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
22324 !! html/php
22325 <p>Nested: Hello Hong Kong!
22326 </p>
22327 !! html/parsoid
22328 <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>
22329 !! end
22330
22331 !! test
22332 HTML markups with conversion syntax in attribs, nested in other conversion blocks
22333 !! options
22334 language=zh variant=zh-cn
22335 !! wikitext
22336 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
22337 !! html/php
22338 <p><span title="X">A</span>
22339 </p>
22340 !! html/parsoid
22341 <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>
22342 !! end
22343
22344 !! test
22345 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet in PHP parser)
22346 !! options
22347 language=zh variant=zh-cn
22348 !! wikitext
22349 -{<span title="-{X}-">A</span>}-
22350 !! html/php+disabled
22351 <p><span title="X">A</span>
22352 </p>
22353 !! html/parsoid
22354 <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>
22355 !! end
22356
22357 # Parsoid and PHP disagree on how to parse this example: Parsoid
22358 # insists that the content of a language converter element be a valid
22359 # DOM fragment or attribute string
22360 !! test
22361 Language converter markup with block content
22362 !! options
22363 language=zh variant=zh-cn
22364 !! wikitext
22365 <span>a-{b<div>c}-d
22366
22367 <span>a-{zh;zh-hans;zh-hant|b<div>c}-d
22368
22369 <span>a-{H|0=>zh-cn:x<span>y;0=>zh-tw:b<div>c}-d
22370 !! html/php+tidy
22371 <p><span>ab</span></p>
22372 <div><span>cd <span>ab</span></span>
22373 <div><span>cd <span>ad</span></span></div>
22374 </div>
22375 !! html/parsoid
22376 <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>
22377
22378 <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>
22379
22380 <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>
22381 !! end
22382
22383 !! test
22384 LanguageConverter selser (1)
22385 !! options
22386 language=zh variant=zh-cn
22387 parsoid={
22388 "modes": ["wt2wt", "selser"],
22389 "changes": [
22390 ["span[typeof]", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22391 ]
22392 }
22393 !! wikitext
22394 -{raw}-
22395 !! wikitext/edited
22396 -{edited}-
22397 !! end
22398
22399 !! test
22400 LanguageConverter selser (2)
22401 !! options
22402 language=zh variant=zh-cn
22403 parsoid={
22404 "modes": ["wt2wt", "selser"],
22405 "changes": [
22406 ["span[class='x']", "contents", "text", "-{foo}-"],
22407 ["a", "contents", "text", "-{"],
22408 ["span[typeof]", "attr", "data-mw", "{\"parts\":[{\"template\":{\"target\":{\"wt\":\"1x\",\"href\":\"./Template:1x\"},\"params\":{\"1\":{\"wt\":\"-{\"}},\"i\":0}}]}"]
22409 ]
22410 }
22411 !! wikitext
22412 <span class="x">TEXT1</span>
22413 [http://example.com TEXT2]
22414 [[Foo|TEXT3]]
22415 {{echo|TEXT4}}
22416 !! wikitext/edited
22417 <span class="x"><nowiki>-{foo}-</nowiki></span>
22418 [http://example.com -{]
22419 [[Foo|<nowiki>-{</nowiki>]]
22420 {{1x|<nowiki>-{</nowiki>}}
22421 !! end
22422
22423 # Tests LanguageVariantText in ConstrainedText
22424 !! test
22425 LanguageConverter selser (3)
22426 !! options
22427 language=zh variant=zh-cn
22428 parsoid={
22429 "modes": ["wt2wt", "selser"],
22430 "changes": [
22431 ["td > span", "attr", "typeof", "mw:LanguageVariant"],
22432 ["td > span", "attr", "data-mw-variant", "{\"disabled\":{\"t\":\"edited\"}}"]
22433 ]
22434 }
22435 !! wikitext
22436 {|
22437 |-
22438 |<span>Foo</span>
22439 |}
22440 !! wikitext/edited
22441 {|
22442 |-
22443 |<nowiki/>-{edited}-
22444 |}
22445 !! end
22446
22447 # Tests LanguageVariantText._fromSelSer
22448 !! test
22449 LanguageConverter selser (4)
22450 !! options
22451 language=zh variant=zh-cn
22452 parsoid={
22453 "modes": ["wt2wt", "selser"],
22454 "changes": [
22455 ["td > span.x", "remove"]
22456 ]
22457 }
22458 !! wikitext
22459 {|
22460 |-
22461 |<span class="x">Foo</span>-{Bar}-
22462 ||<span class="x">Foo</span>-{Bar}-
22463 |}
22464 !! wikitext/edited
22465 {|
22466 |-
22467 |<nowiki/>-{Bar}-
22468 ||-{Bar}-
22469 |}
22470 !! end
22471
22472 # Since Parsoid is starting to emit canonical wikitext for links,
22473 # [http://example.com http://example.com] will not RT back to that
22474 # form anymore.
22475 # Parsoid does not language-convert links (it is done in a
22476 # post-processing step)
22477 !! test
22478 Proper conversion of text in external links
22479 !! options
22480 language=sr variant=sr-ec
22481 parsoid=wt2html
22482 !! wikitext
22483 http://www.google.com
22484 gopher://www.google.com
22485 [http://www.google.com http://www.google.com]
22486 [gopher://www.google.com gopher://www.google.com]
22487 [https://www.google.com irc://www.google.com]
22488 [ftp://www.google.com www.google.com/ftp://dir]
22489 [//www.google.com www.google.com]
22490 !! html/php
22491 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22492 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22493 <a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
22494 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
22495 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
22496 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
22497 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
22498 </p>
22499 !! html/parsoid
22500 <p><a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
22501 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
22502 <a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
22503 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
22504 <a rel="mw:ExtLink" href="https://www.google.com">irc://www.google.com</a>
22505 <a rel="mw:ExtLink" href="ftp://www.google.com">www.google.com/ftp://dir</a>
22506 <a rel="mw:ExtLink" href="//www.google.com">www.google.com</a></p>
22507 !! end
22508
22509 !! test
22510 Do not convert roman numbers to language variants
22511 !! options
22512 language=sr variant=sr-ec
22513 !! wikitext
22514 Fridrih IV je car.
22515 !! html/php
22516 <p>Фридрих IV је цар.
22517 </p>
22518 !! html/parsoid
22519 <p>Fridrih IV je car.</p>
22520 !! end
22521
22522 !! test
22523 Unclosed language converter markup "-{"
22524 !! options
22525 language=sr
22526 !! wikitext
22527 -{T|hello
22528 !! html
22529 <p>-{T|hello
22530 </p>
22531 !! end
22532
22533 !! test
22534 Don't convert raw rule "-{R|=&gt;}-" to "=>"
22535 !! options
22536 language=sr
22537 !! wikitext
22538 -{R|=&gt;}-
22539 !! html/php
22540 <p>=&gt;
22541 </p>
22542 !! html/parsoid
22543 <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>
22544 !!end
22545
22546 !! test
22547 Don't break link parsing if language converter markup is in the caption.
22548 !! options
22549 language=sr variant=sr-ec
22550 !! wikitext
22551 [[Main Page|-{R|main page}-]]
22552 !! html/php
22553 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
22554 </p>
22555 !! html/parsoid
22556 <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>
22557 !! end
22558
22559 !! test
22560 T146304: Don't break template parsing if language converter markup is in the parameter.
22561 !! options
22562 language=sr variant=sr-ec
22563 !! wikitext
22564 {{echo|-{R|foo}-}}
22565 !! html/php
22566 <p>foo
22567 </p>
22568 !! html/parsoid
22569 <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>
22570 !! end
22571
22572 !! test
22573 T146305: Don't break image parsing if language converter markup is in the caption.
22574 !! options
22575 language=sr
22576 !! wikitext
22577 [[Датотека:Foobar.jpg|thumb|-{R|caption:}-]]
22578 !! html/php
22579 <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>
22580
22581 !! html/parsoid
22582 <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>
22583 !! end
22584
22585 !! test
22586 T146305: Don't break image parsing if nested language converter markup is in the caption.
22587 !! options
22588 language=zh variant=zh-cn
22589 !! wikitext
22590 [[File:Foobar.jpg|thumb|-{|zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
22591 !! html/php
22592 <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>
22593
22594 !! html/parsoid
22595 <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>
22596 !! end
22597
22598 # XXX html2wt disabled because rich markup in alt is not preserved.
22599 !! test
22600 Don't break gallery if language converter markup is inside.
22601 !! options
22602 language=zh
22603 !! wikitext
22604 <gallery>
22605 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
22606 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
22607 </gallery>
22608 !! html/php
22609 <ul class="gallery mw-gallery-traditional">
22610 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22611 <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>
22612 <div class="gallerytext">
22613 <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>
22614 </p>
22615 </div>
22616 </div></li>
22617 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
22618 <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>
22619 <div class="gallerytext">
22620 <p>This is a test template
22621 </p>
22622 </div>
22623 </div></li>
22624 </ul>
22625
22626 !! html/parsoid
22627 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" 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"}}'>
22628 <li class="gallerybox">
22629 <div class="thumb"><span 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></span></div>
22630 <div class="gallerytext"><span 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></span></div>
22631 </li>
22632 <li class="gallerybox">
22633 <div class="thumb"><span 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></span></div>
22634 <div class="gallerytext"><span 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>
22635 </li>
22636 </ul>
22637 !! end
22638
22639 !! test
22640 T153135: Don't break list handling if language converter markup is in the item.
22641 !! options
22642 language=zh variant=zh-cn
22643 !! wikitext
22644 ;-{zh-cn:AAA;zh-tw:BBB}-
22645 ;-{R|foo:bar}-
22646 !! html/php
22647 <dl><dt>AAA</dt>
22648 <dt>foo:bar</dt></dl>
22649
22650 !! html/parsoid
22651 <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>
22652 <dt data-parsoid='{"dsr":[25,39,1,0]}'><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"foo:bar"}}'></span></dt>
22653 </dl>
22654 !! end
22655
22656 // Note that parsoid does not protect colons unless language converter
22657 // markup is properly nested, because it is a backtracking parser.
22658 !! test
22659 T153135: Unclosed markup in definition list (code coverage)
22660 !! options
22661 language=zh variant=zh-cn
22662 !! wikitext
22663 ;<b>foo:bar
22664 ;-{zh-cn:AAA
22665 !! html/php+tidy
22666 <dl>
22667 <dt><b>foo:bar</b></dt>
22668 <dt><b>-{zh-cn:AAA</b></dt>
22669 </dl>
22670 !! html/parsoid
22671 <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}'>
22672 <dt data-parsoid='{"dsr":[12,20,1,0]}'>-{zh-cn</dt>
22673 <dd data-parsoid='{"stx":"row","dsr":[20,24,1,0]}'>AAA</dd>
22674 </b></dl>
22675 !! end
22676
22677 !! test
22678 T153135: Nested language converter markup in definition list (code coverage)
22679 !! options
22680 language=zh variant=zh-cn
22681 !! wikitext
22682 ;-{|zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
22683 !! html/php
22684 <dl><dt>AAA foo:bar bat:baz</dt>
22685 <dd>def</dd></dl>
22686
22687 !! html/parsoid
22688 <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>
22689 <dd data-parsoid='{"stx":"row","dsr":[49,53,1,0]}'>def</dd>
22690 </dl>
22691 !! end
22692
22693 # html2wt mode disabled due to <nowiki> insertion.
22694 !! test
22695 T153140: Don't break table handling if language converter markup is in the cell.
22696 !! options
22697 language=sr variant=sr-ec
22698 parsoid=wt2html,wt2wt,html2html
22699 !! wikitext
22700 {|
22701 |-
22702 | -{R|B}-
22703 |}
22704 !! html/php
22705 <table>
22706
22707 <tr>
22708 <td> B
22709 </td></tr></table>
22710
22711 !! html/parsoid
22712 <table>
22713 <tbody>
22714 <tr>
22715 <td><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"B"}}'></span></td>
22716 </tr>
22717 </tbody>
22718 </table>
22719 !! end
22720
22721 !! test
22722 Language converter tricky html2wt cases (1)
22723 !! options
22724 language=sr
22725 parsoid=html2wt,wt2wt
22726 !! html/parsoid
22727 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"}-"}}'></span></p>
22728 !! wikitext
22729 -{<nowiki>}-</nowiki>}-
22730 !! html/php
22731 <p>&#125;-
22732 </p>
22733 !! end
22734
22735 !! test
22736 Language converter tricky html2wt cases (2)
22737 !! options
22738 language=sr
22739 parsoid=html2wt,wt2wt
22740 !! html/parsoid
22741 <p>-{foo}-</p>
22742 !! wikitext
22743 <nowiki>-{foo}-</nowiki>
22744 !! html/php
22745 <p>-&#123;foo&#125;-
22746 </p>
22747 !! end
22748
22749 !! test
22750 Language converter tricky html2wt cases (3)
22751 !! options
22752 language=sr
22753 parsoid=html2wt,wt2wt
22754 !! html/parsoid
22755 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"|"}}'></span></p>
22756 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"R|raw"}}'></span></p>
22757 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"-{foo}-"}}'></span></p>
22758 !! wikitext
22759 -{R||}-
22760
22761 -{R|R|raw}-
22762
22763 -{<nowiki>-{foo}-</nowiki>}-
22764 !! html/php
22765 <p>|
22766 </p><p>R|raw
22767 </p><p>-&#123;foo&#125;-
22768 </p>
22769 !! end
22770
22771 !! test
22772 Language converter tricky html2wt cases (4)
22773 !! options
22774 language=sr
22775 parsoid=html2wt,wt2wt
22776 !! html/parsoid
22777 <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>
22778 !! wikitext
22779 -{R|{{echo|hey}}}-
22780 !! html/php
22781 <p>hey
22782 </p>
22783 !! end
22784
22785 # Note that the <nowiki> escaping added by parsoid for source text,
22786 # destination text, and language names only works on the PHP side
22787 # for *destination text*. (HTML entity escaping wouldn't work
22788 # any better.) This is probably a bug, at least for source texts.
22789 # (For language names PHP uses a precise regexp based on the languages
22790 # it currently knows have variants, which is fragile since this set
22791 # can grow/shrink over time.)
22792 !! test
22793 Language converter tricky html2wt cases (5)
22794 !! options
22795 language=zh variant=zh-cn
22796 !! html/parsoid
22797 <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>
22798 <p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"A","l":"bo:g;us","t":"B"}]}'/></p>
22799 <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>
22800 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"twoway":[{"l":"bo:g;us","t":"xyz"},{"l":"zh-cn","t":"abc"}]}'></span></p>
22801 <p>a:b=>c xyz</p>
22802 !! wikitext
22803 -{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
22804
22805 -{H|A=><nowiki>bo:g;us</nowiki>:B}-
22806
22807 -{A|zh-tw:xyz; zh-cn:<nowiki>0;zh-tw:bar</nowiki>}-
22808
22809 -{<nowiki>bo:g;us</nowiki>:xyz; zh-cn:abc}-
22810
22811 a:b=>c xyz
22812 !! html/php+disabled
22813 <p>foobat;xyz=&gt;zh-cn:abc
22814 </p><p>A
22815 </p><p>0;zh-tw:bar
22816 </p><p>abc
22817 </p><p>a:b=&gt;c 0;zh-tw:bar
22818 </p>
22819 !! end
22820
22821 !! test
22822 T179579: Nowiki and lc interaction
22823 !! options
22824 parsoid=wt2html
22825 language=sr
22826 !! wikitext
22827 -{</nowiki>123}-
22828
22829 -{123<nowiki>|</nowiki>456}-
22830 !! html/parsoid
22831 <p><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"&amp;lt;/nowiki>123"}}' data-parsoid='{"fl":[],"src":"-{&lt;/nowiki>123}-"}'></span></p>
22832
22833 <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>
22834 !! end
22835
22836 !! test
22837 T2529: Uncovered bullet
22838 !! wikitext
22839 * Foo {{bullet}}
22840 !! html
22841 <ul><li> Foo </li>
22842 <li> Bar</li></ul>
22843
22844 !! end
22845
22846 # Plain MediaWiki does not remove empty lists, but tidy actually does.
22847 # Templates in Wikipedia rely on this behavior, as tidy has always been
22848 # enabled there. These tests are normally run *without* tidy, so specify the
22849 # full output here.
22850 # To test realistic parsing behavior, apply a tidy-like transformation to both
22851 # the expected output and your parser's output.
22852 !! test
22853 T2529: Uncovered bullet leaving empty list, normally removed by tidy
22854 !! wikitext
22855 ******* Foo {{bullet}}
22856 !! html
22857 <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>
22858 <li> Bar</li></ul>
22859
22860 !! end
22861
22862 !! test
22863 T2529: Uncovered table already at line-start
22864 !! wikitext
22865 x
22866
22867 {{table}}
22868 y
22869 !! html
22870 <p>x
22871 </p>
22872 <table>
22873 <tr>
22874 <td> 1 </td>
22875 <td> 2
22876 </td></tr>
22877 <tr>
22878 <td> 3 </td>
22879 <td> 4
22880 </td></tr></table>
22881 <p>y
22882 </p>
22883 !! end
22884
22885 !! test
22886 T2529: Uncovered bullet in parser function result
22887 !! wikitext
22888 * Foo {{lc:{{bullet}} }}
22889 !! html
22890 <ul><li> Foo </li>
22891 <li> bar</li></ul>
22892
22893 !! end
22894
22895 !! test
22896 T7678: Double-parsed template argument
22897 !! wikitext
22898 {{lc:{{{1}}}|hello}}
22899 !! html
22900 <p>{{{1}}}
22901 </p>
22902 !! end
22903
22904 !! test
22905 T7678: Double-parsed template invocation
22906 !! wikitext
22907 {{lc:{{paramtest {{!}} param = hello }} }}
22908 !! html
22909 <p>{{paramtest | param = hello }}
22910 </p>
22911 !! end
22912
22913 !! test
22914 Case insensitivity of parser functions for non-ASCII characters (T10143)
22915 !! options
22916 language=cs
22917 title=[[Main Page]]
22918 !! wikitext
22919 {{PRVNÍVELKÉ:ěščř}}
22920 {{prvnívelké:ěščř}}
22921 {{PRVNÍMALÉ:ěščř}}
22922 {{prvnímalé:ěščř}}
22923 {{MALÁ:ěščř}}
22924 {{malá:ěščř}}
22925 {{VELKÁ:ěščř}}
22926 {{velká:ěščř}}
22927 !! html
22928 <p>Ěščř
22929 Ěščř
22930 ěščř
22931 ěščř
22932 ěščř
22933 ěščř
22934 ĚŠČŘ
22935 ĚŠČŘ
22936 </p>
22937 !! end
22938
22939 !! test
22940 Morwen/13: Unclosed link followed by heading
22941 !! wikitext
22942 [[link
22943 ==heading==
22944 !! html
22945 <p>[[link
22946 </p>
22947 <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>
22948
22949 !! end
22950
22951 !! test
22952 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
22953 !! wikitext
22954 {{foo|
22955 =heading=
22956 !! html
22957 <p>{{foo|
22958 </p>
22959 <h1><span class="mw-headline" id="heading">heading</span></h1>
22960
22961 !! end
22962
22963 !! test
22964 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
22965 !! wikitext
22966 {{foo|
22967 ==heading==
22968 !! html
22969 <p>{{foo|
22970 </p>
22971 <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>
22972
22973 !! end
22974
22975 !! test
22976 Tildes in comments
22977 !! options
22978 pst
22979 !! wikitext
22980 <!-- ~~~~ -->
22981 !! html/php
22982 <!-- ~~~~ -->
22983 !! end
22984
22985 !! test
22986 Paragraphs inside divs (no extra line breaks)
22987 !! wikitext
22988 <div>Line one
22989
22990 Line two</div>
22991 !! html
22992 <div>Line one
22993 Line two</div>
22994
22995 !! end
22996
22997 !! test
22998 Paragraphs inside divs (extra line break on open)
22999 !! wikitext
23000 <div>
23001 Line one
23002
23003 Line two</div>
23004 !! html
23005 <div>
23006 <p>Line one
23007 </p>
23008 Line two</div>
23009
23010 !! end
23011
23012 !! test
23013 Paragraphs inside divs (extra line break on close)
23014 !! wikitext
23015 <div>Line one
23016
23017 Line two
23018 </div>
23019 !! html
23020 <div>Line one
23021 <p>Line two
23022 </p>
23023 </div>
23024
23025 !! end
23026
23027 !! test
23028 Paragraphs inside divs (extra line break on open and close)
23029 !! wikitext
23030 <div>
23031 Line one
23032
23033 Line two
23034 </div>
23035 !! html
23036 <div>
23037 <p>Line one
23038 </p><p>Line two
23039 </p>
23040 </div>
23041
23042 !! end
23043
23044 !! test
23045 Nesting tags, paragraphs on lines which begin with <div>
23046 !! wikitext
23047 <div></div><strong>A
23048 B</strong>
23049 !! html/php+tidy
23050 <p><strong>A</strong></p>
23051 <p><strong>B</strong></p>
23052 !! html/parsoid
23053 <div></div>
23054 <p><strong>A
23055 B</strong>
23056 </p>
23057 !! end
23058
23059 # T8200: <blockquote> should behave like <div> with respect to line breaks
23060 !! test
23061 T8200: paragraphs inside blockquotes (no extra line breaks)
23062 !! wikitext
23063 <blockquote>Line one
23064
23065 Line two</blockquote>
23066 !! html
23067 <blockquote>Line one
23068 Line two</blockquote>
23069
23070 !! html+tidy
23071 <blockquote>
23072 <p>Line one Line two</p>
23073 </blockquote>
23074 !! end
23075
23076 !! test
23077 T8200: paragraphs inside blockquotes (extra line break on open)
23078 !! wikitext
23079 <blockquote>
23080 Line one
23081
23082 Line two</blockquote>
23083 !! html
23084 <blockquote>
23085 <p>Line one
23086 </p>
23087 Line two</blockquote>
23088
23089 !! html+tidy
23090 <blockquote>
23091 <p>Line one</p>
23092 Line two</blockquote>
23093 !! end
23094
23095 !! test
23096 T8200: paragraphs inside blockquotes (extra line break on close)
23097 !! wikitext
23098 <blockquote>Line one
23099
23100 Line two
23101 </blockquote>
23102 !! html
23103 <blockquote>Line one
23104 <p>Line two
23105 </p>
23106 </blockquote>
23107
23108 !! html+tidy
23109 <blockquote>
23110 <p>Line one</p>
23111 <p>Line two</p>
23112 </blockquote>
23113 !! end
23114
23115 !! test
23116 T8200: paragraphs inside blockquotes (extra line break on open and close)
23117 !! wikitext
23118 <blockquote>
23119 Line one
23120
23121 Line two
23122 </blockquote>
23123 !! html
23124 <blockquote>
23125 <p>Line one
23126 </p><p>Line two
23127 </p>
23128 </blockquote>
23129
23130 !! html+tidy
23131 <blockquote>
23132 <p>Line one</p>
23133 <p>Line two</p>
23134 </blockquote>
23135 !! end
23136
23137 !! test
23138 Paragraphs inside blockquotes/divs (no extra line breaks)
23139 !! wikitext
23140 <blockquote><div>Line one
23141
23142 Line two</div></blockquote>
23143 !! html
23144 <blockquote><div>Line one
23145 Line two</div></blockquote>
23146
23147 !! end
23148
23149 !! test
23150 Paragraphs inside blockquotes/divs (extra line break on open)
23151 !! wikitext
23152 <blockquote><div>
23153 Line one
23154
23155 Line two</div></blockquote>
23156 !! html
23157 <blockquote><div>
23158 <p>Line one
23159 </p>
23160 Line two</div></blockquote>
23161
23162 !! end
23163
23164 !! test
23165 Paragraphs inside blockquotes/divs (extra line break on close)
23166 !! wikitext
23167 <blockquote><div>Line one
23168
23169 Line two
23170 </div></blockquote>
23171 !! html
23172 <blockquote><div>Line one
23173 <p>Line two
23174 </p>
23175 </div></blockquote>
23176
23177 !! end
23178
23179 !! test
23180 Paragraphs inside blockquotes/divs (extra line break on open and close)
23181 !! wikitext
23182 <blockquote><div>
23183 Line one
23184
23185 Line two
23186 </div></blockquote>
23187 !! html
23188 <blockquote><div>
23189 <p>Line one
23190 </p><p>Line two
23191 </p>
23192 </div></blockquote>
23193
23194 !! end
23195
23196 !! test
23197 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
23198 !! options
23199 wgLinkHolderBatchSize=0
23200 !! wikitext
23201 [[meatball:1]]
23202 [[meatball:2]]
23203 [[meatball:3]]
23204 !! html
23205 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
23206 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
23207 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
23208 </p>
23209 !! end
23210
23211 !! test
23212 Free external link invading image caption
23213 !! wikitext
23214 [[Image:Foobar.jpg|thumb|http://x|hello]]
23215 !! html
23216 <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>
23217
23218 !! end
23219
23220 !! test
23221 T17196: localised external link numbers
23222 !! options
23223 language=fa
23224 !! wikitext
23225 [http://en.wikipedia.org/]
23226 !! html/php
23227 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
23228 </p>
23229 !! html/parsoid
23230 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/"></a></p>
23231 !! end
23232
23233 !! test
23234 Multibyte character in padleft
23235 !! wikitext
23236 {{padleft:-Hello|7|Æ}}
23237 !! html
23238 <p>Æ-Hello
23239 </p>
23240 !! end
23241
23242 !! test
23243 Multibyte character in padright
23244 !! wikitext
23245 {{padright:Hello-|7|Æ}}
23246 !! html
23247 <p>Hello-Æ
23248 </p>
23249 !! end
23250
23251 !!test
23252 formatdate parser function
23253 !! wikitext
23254 {{#formatdate:2009-03-24}}
23255 !! html
23256 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
23257 </p>
23258 !! end
23259
23260 !!test
23261 formatdate parser function, with default format
23262 !! wikitext
23263 {{#formatdate:2009-03-24|mdy}}
23264 !! html
23265 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
23266 </p>
23267 !! end
23268
23269 !! test
23270 Spacing of numbers in formatted dates
23271 !! wikitext
23272 {{#formatdate:January 15}}
23273 !! html
23274 <p><span class="mw-formatted-date" title="01-15">January 15</span>
23275 </p>
23276 !! end
23277
23278 !! test
23279 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
23280 !! options
23281 language=nl title=[[MediaWiki:Common.css]]
23282 !! wikitext
23283 {{#formatdate:2009-03-24|dmy}}
23284 !! html
23285 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
23286 </p>
23287 !! end
23288
23289 #
23290 #
23291 #
23292
23293 #
23294 # Edit comments
23295 #
23296
23297 !! test
23298 Edit comment with link
23299 !! options
23300 comment
23301 !! wikitext
23302 I like the [[Main Page]] a lot
23303 !! html/php
23304 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
23305 !!end
23306
23307 !! test
23308 Edit comment with link and link text
23309 !! options
23310 comment
23311 !! wikitext
23312 I like the [[Main Page|best pages]] a lot
23313 !! html/php
23314 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23315 !!end
23316
23317 !! test
23318 Edit comment with link and link text with suffix
23319 !! options
23320 comment
23321 !! wikitext
23322 I like the [[Main Page|best page]]s a lot
23323 !! html/php
23324 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
23325 !!end
23326
23327 !! test
23328 Edit comment with section link (non-local, eg in history list)
23329 !! options
23330 comment title=[[Main Page]]
23331 !! wikitext
23332 /* External links */ removed bogus entries
23333 !! html/php
23334 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23335 !!end
23336
23337 !! test
23338 Edit comment with section link and text before it (non-local, eg in history list)
23339 !! options
23340 comment title=[[Main Page]]
23341 !! wikitext
23342 pre-comment text /* External links */ removed bogus entries
23343 !! html/php
23344 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>
23345 !!end
23346
23347 !! test
23348 Edit comment with section link (local, eg in diff view)
23349 !! options
23350 comment local title=[[Main Page]]
23351 !! wikitext
23352 /* External links */ removed bogus entries
23353 !! html/php
23354 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
23355 !!end
23356
23357 !! test
23358 Edit comment with subpage link (T16080)
23359 !! options
23360 comment
23361 subpage
23362 title=[[Subpage test]]
23363 !! wikitext
23364 Poked at a [[/subpage]] here...
23365 !! html/php
23366 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
23367 !!end
23368
23369 !! test
23370 Edit comment with subpage link and link text (T16080)
23371 !! options
23372 comment
23373 subpage
23374 title=[[Subpage test]]
23375 !! wikitext
23376 Poked at a [[/subpage|neat little page]] here...
23377 !! html/php
23378 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
23379 !!end
23380
23381 !! test
23382 Edit comment with bogus subpage link in non-subpage NS (T16080)
23383 !! options
23384 comment
23385 title=[[Subpage test]]
23386 !! wikitext
23387 Poked at a [[/subpage]] here...
23388 !! html/php
23389 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...
23390 !!end
23391
23392 !! test
23393 Edit comment with bare anchor link (local, as on diff)
23394 !! options
23395 comment
23396 local
23397 title=[[Main Page]]
23398 !! wikitext
23399 [[#section]]
23400 !! html/php
23401 <a href="#section">#section</a>
23402 !! end
23403
23404 !! test
23405 Edit comment with bare anchor link (non-local, as on history)
23406 !! options
23407 comment
23408 title=[[Main Page]]
23409 !! wikitext
23410 [[#section]]
23411 !! html/php
23412 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
23413 !! end
23414
23415 !! test
23416 Anchor starting with underscore
23417 !! options
23418 title=[[Foo]]
23419 !! wikitext
23420 [[#_ref|One]]
23421 !! html/php
23422 <p><a href="#_ref">One</a>
23423 </p>
23424 !! html/parsoid
23425 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
23426 !! end
23427
23428 !! test
23429 Id starting with underscore
23430 !! wikitext
23431 <div id="_ref"></div>
23432 !! html/*
23433 <div id="_ref"></div>
23434
23435 !! end
23436
23437 !! test
23438 Edit comment with link with more than one pipe (T99346)
23439 !! options
23440 comment
23441 !! wikitext
23442 [[Main Page|Many|pipes]]
23443 !! html/php
23444 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
23445 !! end
23446
23447 !! test
23448 Complex edit comment with link with more than one pipe (T99346)
23449 !! options
23450 comment
23451 !! wikitext
23452 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
23453 !! html/php
23454 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;
23455 !! end
23456
23457 !! test
23458 Space normalisation on autocomment (T24784)
23459 !! options
23460 comment
23461 title=[[Main Page]]
23462 !! wikitext
23463 /* __hello__world__ */
23464 !! html/php
23465 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
23466 !! end
23467
23468 !! test
23469 percent-encoding and + signs in comments (T28410)
23470 !! options
23471 comment
23472 !! wikitext
23473 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
23474 !! html/php
23475 <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>
23476 !! end
23477
23478 # Parsoid doesn't support this yet: see T75581
23479 # but it *should* omit the 'src' attribute if the image is bad.
23480 # PHP side of tests was disabled in
23481 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
23482 # because of issues in the PHP parserTests infrastructure
23483 # (but the output below is indeed what the PHP side emits)
23484 !! test
23485 Bad images - basic functionality
23486 !! wikitext
23487 [[File:Bad.jpg]]
23488 !! DISABLED/html/php
23489 !! html/parsoid
23490 <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>
23491 !! end
23492
23493 !! test
23494 Bad images - T18039: text after bad image disappears
23495 !! wikitext
23496 Foo bar
23497 [[File:Bad.jpg]]
23498 Bar foo
23499 !! DISABLED/html/php
23500 <p>Foo bar
23501 </p><p>Bar foo
23502 </p>
23503 !! html/parsoid
23504 <p>Foo bar
23505 <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>
23506 Bar foo</p>
23507 !! end
23508
23509 !! test
23510 Verify that displaytitle works (T24501) no displaytitle
23511 !! options
23512 showtitle
23513 !! config
23514 wgAllowDisplayTitle=true
23515 wgRestrictDisplayTitle=false
23516 !! wikitext
23517 this is not the the title
23518 !! html/php
23519 Parser test
23520 <p>this is not the the title
23521 </p>
23522 !! end
23523
23524 !! test
23525 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
23526 !! options
23527 showtitle
23528 title=[[Screen]]
23529 !! config
23530 wgAllowDisplayTitle=true
23531 wgRestrictDisplayTitle=false
23532 !! wikitext
23533 this is not the the title
23534 {{DISPLAYTITLE:whatever}}
23535 !! html/php
23536 whatever
23537 <p>this is not the the title
23538 </p>
23539 !! end
23540
23541 !! test
23542 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
23543 !! options
23544 showtitle
23545 title=[[Screen]]
23546 !! config
23547 wgAllowDisplayTitle=true
23548 wgRestrictDisplayTitle=true
23549 !! wikitext
23550 this is not the the title
23551 {{DISPLAYTITLE:whatever}}
23552 !! html/php
23553 Screen
23554 <p>this is not the the title
23555 </p>
23556 !! end
23557
23558 !! test
23559 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
23560 !! options
23561 showtitle
23562 title=[[Screen]]
23563 !! config
23564 wgAllowDisplayTitle=true
23565 wgRestrictDisplayTitle=true
23566 !! wikitext
23567 this is not the the title
23568 {{DISPLAYTITLE:screen}}
23569 !! html/php
23570 screen
23571 <p>this is not the the title
23572 </p>
23573 !! end
23574
23575 !! test
23576 Verify that displaytitle works (T24501) AllowDisplayTitle=false
23577 !! options
23578 showtitle
23579 title=[[Screen]]
23580 !! config
23581 wgAllowDisplayTitle=false
23582 !! wikitext
23583 this is not the the title
23584 {{DISPLAYTITLE:screen}}
23585 !! html/php
23586 Screen
23587 <p>this is not the the title
23588 <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>
23589 </p>
23590 !! end
23591
23592 !! test
23593 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
23594 !! options
23595 showtitle
23596 title=[[Screen]]
23597 !! config
23598 wgAllowDisplayTitle=false
23599 !! wikitext
23600 this is not the the title
23601 !! html/php
23602 Screen
23603 <p>this is not the the title
23604 </p>
23605 !! end
23606
23607 !! test
23608 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
23609 !! options
23610 showtitle
23611 title=[[Screen]]
23612 !! config
23613 wgAllowDisplayTitle=true
23614 wgRestrictDisplayTitle=true
23615 !! wikitext
23616 this is not the the title
23617 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
23618 !! html/php
23619 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
23620 <p>this is not the the title
23621 </p>
23622 !! end
23623
23624 !! test
23625 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
23626 !! options
23627 showtitle
23628 title=[[Screen]]
23629 !! config
23630 wgAllowDisplayTitle=true
23631 wgRestrictDisplayTitle=true
23632 !! wikitext
23633 this is not the the title
23634 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
23635 !! html/php
23636 <span style="color: red;">s</span>creen
23637 <p>this is not the the title
23638 </p>
23639 !! end
23640
23641 !! test
23642 Page status indicators: Empty name is invalid
23643 !! options
23644 showindicators
23645 !! wikitext
23646 <indicator name=" "></indicator>
23647 <indicator></indicator>
23648 !! html/php
23649 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23650 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
23651 </p>
23652 !! end
23653
23654 !! test
23655 Page status indicators: Weird syntaxes that are okay
23656 !! options
23657 showindicators
23658 !! wikitext
23659 <indicator name="empty" />
23660 <indicator name="name"></indicator>
23661 !! html/php
23662 empty=
23663 name=
23664 <p><br />
23665 </p>
23666 !! end
23667
23668 !! test
23669 Page status indicators: Torture test
23670 !! options
23671 showindicators
23672 !! wikitext
23673 <indicator name="01">hello world</indicator>
23674 <indicator name="02">[[Main Page]]</indicator>
23675 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
23676 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
23677 <indicator name="05">* foo
23678 * bar</indicator>
23679 <indicator name="06"><nowiki>foo</nowiki></indicator>
23680 <indicator name="07"> Preformatted</indicator>
23681 <indicator name="08"><div>Broken tag</indicator>
23682 <indicator name="09">{| class=wikitable
23683 | cell
23684 |}</indicator>
23685 <indicator name="10">Two
23686
23687 paragraphs</indicator>
23688 !! html/php
23689 01=hello world
23690 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
23691 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" />
23692 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>
23693 05=<ul><li> foo</li>
23694 <li> bar</li></ul>
23695
23696 06=foo
23697 07=<pre>Preformatted
23698 </pre>
23699 08=<div>Broken tag</div>
23700
23701 09=<table class="wikitable">
23702 <tr>
23703 <td> cell
23704 </td></tr></table>
23705
23706 10=<p>Two
23707 </p><p>paragraphs
23708 </p>
23709 <p><br />
23710 </p><p><br />
23711 </p><p><br />
23712 </p><p><br />
23713 </p><p><br />
23714 </p>
23715 !! end
23716
23717 !! test
23718 preload: check <noinclude> and <includeonly>
23719 !! options
23720 preload
23721 !! wikitext
23722 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
23723 !! html/php
23724 Hello kind world.
23725 !! end
23726
23727 !! test
23728 preload: check <onlyinclude>
23729 !! options
23730 preload
23731 !! wikitext
23732 Goodbye <onlyinclude>Hello world</onlyinclude>
23733 !! html/php
23734 Hello world
23735 !! end
23736
23737 !! test
23738 preload: can pass tags through if we want to
23739 !! options
23740 preload
23741 !! wikitext
23742 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
23743 !! html/php
23744 <includeonly>Hello world</includeonly>
23745 !! end
23746
23747 !! test
23748 preload: check that it doesn't try to do tricks
23749 !! options
23750 preload
23751 !! wikitext
23752 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
23753 !! html/php
23754 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
23755 !! end
23756
23757 !! test
23758 Play a bit with r67090 and T5158
23759 !! wikitext
23760 <div style="width:50% !important">&nbsp;</div>
23761 <div style="width:50%&nbsp;!important">&nbsp;</div>
23762 <div style="width:50%&#160;!important">&nbsp;</div>
23763 <div style="border : solid;">&nbsp;</div>
23764 !! html/php
23765 <div style="width:50% !important">&#160;</div>
23766 <div style="width:50% !important">&#160;</div>
23767 <div style="width:50% !important">&#160;</div>
23768 <div style="border&#160;: solid;">&#160;</div>
23769
23770 !! html/parsoid
23771 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
23772 <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>
23773 <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>
23774 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
23775
23776 !! end
23777
23778 !! test
23779 HTML5 data attributes
23780 !! wikitext
23781 <span data-foo="bar">Baz</span>
23782 <p data-abc-def_hij="">Quuz</p>
23783 !! html/php
23784 <p><span data-foo="bar">Baz</span>
23785 </p>
23786 <p data-abc-def_hij="">Quuz</p>
23787
23788 !! html/parsoid
23789 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
23790 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
23791 !! end
23792
23793 !! test
23794 Strip reserved data attributes
23795 !! wikitext
23796 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
23797 !! html/php
23798 <div data-ok="fred">d</div>
23799
23800 !! html/parsoid
23801 <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>
23802 !! end
23803
23804 !! test
23805 percent-encoding and + signs in internal links (T28410)
23806 !! wikitext
23807 [[User:+%]] [[Page+title%]]
23808 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
23809 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
23810 [[%33%45]] [[%33%45+]]
23811 !! html/php
23812 <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>
23813 <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>
23814 <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>
23815 <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>
23816 </p>
23817 !! html/parsoid
23818 <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>
23819 <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>
23820 <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> <span 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></span>
23821 <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>
23822 !! end
23823
23824 !! test
23825 Special characters in embedded file links (T29679)
23826 !! wikitext
23827 [[File:Contains & ampersand.jpg]]
23828 [[File:Does not exist.jpg|Title with & ampersand]]
23829 !! html/php
23830 <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>
23831 <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>
23832 </p>
23833 !! html/parsoid
23834 <p><span 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></span>
23835 <span 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></span></p>
23836 !! end
23837
23838 !! test
23839 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
23840 !! wikitext
23841 Text&apos;s been normalized?
23842 !! html
23843 <p>Text&#39;s been normalized?
23844 </p>
23845 !! end
23846
23847 !! test
23848 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
23849 !! wikitext
23850 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
23851 !! html
23852 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
23853 </p>
23854 !! end
23855
23856 !! test
23857 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
23858 !! wikitext
23859 [http://www.example.org/ ideograms]
23860 !! html
23861 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
23862 </p>
23863 !! end
23864
23865 !! test
23866 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
23867 !! wikitext
23868 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
23869 !! html
23870 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
23871 </p>
23872 !! end
23873
23874 !! article
23875 Mediawiki:loop1
23876 !! text
23877 {{Identical|A}}
23878 !! endarticle
23879
23880 !! article
23881 Mediawiki:loop2
23882 !! text
23883 {{Identical|B}}
23884 !! endarticle
23885
23886 !! article
23887 Template:Identical
23888 !! text
23889 {{int:loop1}}
23890 {{int:loop2}}
23891 !! endarticle
23892
23893 !! test
23894 T33098 Template which includes system messages which includes the template
23895 !! wikitext
23896 {{Identical}}
23897 !! html
23898 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
23899 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
23900 </p>
23901 !! end
23902
23903 !! test
23904 T33490 Turkish: ucfirst 'blah'
23905 !! options
23906 language=tr
23907 !! wikitext
23908 {{ucfirst:blah}}
23909 !! html
23910 <p>Blah
23911 </p>
23912 !! end
23913
23914 !! test
23915 T33490 Turkish: ucfirst 'ix'
23916 !! options
23917 language=tr
23918 !! wikitext
23919 {{ucfirst:ix}}
23920 !! html
23921 <p>İx
23922 </p>
23923 !! end
23924
23925 !! test
23926 T33490 Turkish: lcfirst 'BLAH'
23927 !! options
23928 language=tr
23929 !! wikitext
23930 {{lcfirst:BLAH}}
23931 !! html
23932 <p>bLAH
23933 </p>
23934 !! end
23935
23936 !! test
23937 T33490 Turkish: ucfırst (with a dotless i)
23938 !! options
23939 language=tr
23940 !! wikitext
23941 {{ucfırst:blah}}
23942 !! html
23943 <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>
23944 </p>
23945 !! end
23946
23947 !! test
23948 T33490 ucfırst (with a dotless i) with English language
23949 !! options
23950 language=en
23951 !! wikitext
23952 {{ucfırst:blah}}
23953 !! html
23954 <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>
23955 </p>
23956 !! end
23957
23958 # Note that Parsoid doesn't emit an explicit TOC.
23959 # Note also that the html2wt direction tends to emit an extra newline
23960 # between the __TOC__ magicword and the first heading unless *both*
23961 # the <meta> and the <h2> have a data-parsoid attribute set (even if
23962 # it's "{}").
23963
23964 !! test
23965 T28375: TOC with italics
23966 !! options
23967 title=[[Main Page]]
23968 !! wikitext
23969 __TOC__
23970 == ''Lost'' episodes ==
23971 !! html/php
23972 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23973 <ul>
23974 <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>
23975 </ul>
23976 </div>
23977
23978 <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>
23979
23980 !! html/parsoid
23981 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23982 <h2 data-parsoid='{}'> <i>Lost</i> episodes </h2>
23983 !! end
23984
23985 !! test
23986 T28375: TOC with bold
23987 !! options
23988 title=[[Main Page]]
23989 !! wikitext
23990 __TOC__
23991 == '''should be bold''' then normal text ==
23992 !! html/php
23993 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23994 <ul>
23995 <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>
23996 </ul>
23997 </div>
23998
23999 <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>
24000
24001 !! html/parsoid
24002 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24003 <h2 data-parsoid='{}'> <b>should be bold</b> then normal text </h2>
24004 !! end
24005
24006 !! test
24007 T35845: Headings become cursive in TOC when they contain an image
24008 !! options
24009 title=[[Main Page]]
24010 !! wikitext
24011 __TOC__
24012 == Image [[Image:foobar.jpg]] ==
24013 !! html/php
24014 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
24015 <ul>
24016 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
24017 </ul>
24018 </div>
24019
24020 <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>
24021
24022 !! html/parsoid
24023 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24024 <h2 data-parsoid='{}'> Image <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" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"Image:foobar.jpg"}}'/></a></span> </h2>
24025 !! end
24026
24027 !! test
24028 T35845 (2): Headings become bold in TOC when they contain a blockquote
24029 !! options
24030 title=[[Main Page]]
24031 !! wikitext
24032 __TOC__
24033 == <blockquote>Quote</blockquote> ==
24034 !! html/php
24035 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
24036 <ul>
24037 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24038 </ul>
24039 </div>
24040
24041 <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>
24042
24043 !! html/php+tidy
24044 <p></p>
24045 <div id="toc" class="toc">
24046 <div class="toctitle">
24047 <h2>Contents</h2>
24048 </div>
24049 <ul>
24050 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
24051 </ul>
24052 </div>
24053 <p></p>
24054 <h2><span class="mw-headline" id="Quote"></span></h2>
24055 <blockquote>
24056 <p><span class="mw-headline" id="Quote">Quote</span></p>
24057 </blockquote>
24058 <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>
24059 !! html/parsoid
24060 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24061 <h2 data-parsoid='{}'> <blockquote>Quote</blockquote> </h2>
24062 !! end
24063
24064 !! test
24065 Unclosed tags in TOC
24066 !! options
24067 title=[[Main Page]]
24068 !! wikitext
24069 __TOC__
24070 == Proof: 2 < 3 ==
24071 <small>Hanc marginis exiguitas non caperet.</small>
24072 QED
24073 !! html/php
24074 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
24075 <ul>
24076 <li class="toclevel-1 tocsection-1"><a href="#Proof:_2_.3C_3"><span class="tocnumber">1</span> <span class="toctext">Proof: 2 &lt; 3</span></a></li>
24077 </ul>
24078 </div>
24079
24080 <h2><span class="mw-headline" id="Proof:_2_.3C_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>
24081 <p><small>Hanc marginis exiguitas non caperet.</small>
24082 QED
24083 </p>
24084 !! html/parsoid
24085 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24086 <h2 data-parsoid='{}'> Proof: 2 &lt; 3 </h2>
24087 <p><small>Hanc marginis exiguitas non caperet.</small>
24088 QED</p>
24089 !! end
24090
24091 !! test
24092 Multiple tags in TOC
24093 !! wikitext
24094 __TOC__
24095 == <i>Foo</i> <b>Bar</b> ==
24096
24097 == <i>Foo</i> <blockquote>Bar</blockquote> ==
24098 !! html/php
24099 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
24100 <ul>
24101 <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>
24102 <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>
24103 </ul>
24104 </div>
24105
24106 <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>
24107 <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>
24108
24109 !! html/php+tidy
24110 <p></p>
24111 <div id="toc" class="toc">
24112 <div class="toctitle">
24113 <h2>Contents</h2>
24114 </div>
24115 <ul>
24116 <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>
24117 <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>
24118 </ul>
24119 </div>
24120 <p></p>
24121 <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>
24122 <h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i></span></h2>
24123 <blockquote>
24124 <p><span class="mw-headline" id="Foo_Bar_2">Bar</span></p>
24125 </blockquote>
24126 <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>
24127 !! html/parsoid
24128 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24129 <h2 data-parsoid='{}'> <i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b> </h2>
24130 <h2> <i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote> </h2>
24131 !! end
24132
24133 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
24134 # html5 tag parsing.
24135 !! test
24136 Tags with parameters in TOC
24137 !! options
24138 parsoid=wt2html
24139 !! wikitext
24140 __TOC__
24141 == <sup class="in-h2">Hello</sup> ==
24142
24143 == <sup class="a > b">Evilbye</sup> ==
24144 !! html/php
24145 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
24146 <ul>
24147 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
24148 <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>
24149 </ul>
24150 </div>
24151
24152 <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>
24153 <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>
24154
24155 !! html/parsoid
24156 <meta property="mw:PageProp/toc" />
24157 <h2> <sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup> </h2>
24158
24159 <h2> <sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup> </h2>
24160 !! end
24161
24162 !! test
24163 span tags with directionality in TOC
24164 !! wikitext
24165 __TOC__
24166 == <span dir="ltr">C++</span> ==
24167
24168 == <span dir="rtl">זבנג!</span> ==
24169
24170 == <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> ==
24171
24172 == <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> ==
24173
24174 == <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> ==
24175 !! html/php
24176 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
24177 <ul>
24178 <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>
24179 <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>
24180 <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>
24181 <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>
24182 <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>
24183 </ul>
24184 </div>
24185
24186 <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>
24187 <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>
24188 <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>
24189 <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>
24190 <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>
24191
24192 !! html/parsoid
24193 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24194 <h2 data-parsoid='{}'> <span dir="ltr">C++</span> </h2>
24195 <h2> <span dir="rtl">זבנג!</span> </h2>
24196 <h2> <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> </h2>
24197 <h2> <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> </h2>
24198 <h2> <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> </h2>
24199 !! end
24200
24201 !! test
24202 T74884: bdi element in ToC
24203 !! wikitext
24204 __TOC__
24205 == <bdi>test</bdi> ==
24206 !! html/php
24207 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
24208 <ul>
24209 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
24210 </ul>
24211 </div>
24212
24213 <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>
24214
24215 !! html/parsoid
24216 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24217 <h2 data-parsoid='{}'> <bdi>test</bdi> </h2>
24218 !! end
24219
24220 !! test
24221 T35715: s/strike element in ToC
24222 !! wikitext
24223 __TOC__
24224 == <s>test</s> test <strike>test</strike> ==
24225 !! html/php
24226 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
24227 <ul>
24228 <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>
24229 </ul>
24230 </div>
24231
24232 <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>
24233
24234 !! html/parsoid
24235 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24236 <h2 data-parsoid='{}'> <s>test</s> test <strike>test</strike> </h2>
24237 !! end
24238
24239 # Note that the html output does not have the <p></p>, but the
24240 # html+tidy output *does*. This is because the empty <p></p> is
24241 # removed by the sanitizer, but only when tidy is *not* enabled (!).
24242 !! test
24243 Empty <p> tag in TOC, removed by Sanitizer (T92892)
24244 !! wikitext
24245 __TOC__
24246 == x ==
24247 !! html/php
24248 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
24249 <ul>
24250 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
24251 </ul>
24252 </div>
24253
24254 <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>
24255
24256 !! html/php+tidy
24257 <p></p>
24258 <div id="toc" class="toc">
24259 <div class="toctitle">
24260 <h2>Contents</h2>
24261 </div>
24262 <ul>
24263 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
24264 </ul>
24265 </div>
24266 <p></p>
24267 <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>
24268 !! html/parsoid
24269 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
24270 <h2 data-parsoid='{}'> x </h2>
24271 !! end
24272
24273 !! article
24274 MediaWiki:T34057
24275 !! text
24276 == {{int:headline_sample}} ==
24277 !! endarticle
24278
24279 !! test
24280 T34057: Title needed when expanding <h> nodes.
24281 !! options
24282 title=[[Main Page]]
24283 !! wikitext
24284 {{int:T34057}}
24285 !! html
24286 <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>
24287
24288 !! end
24289
24290 !! test
24291 Strip marker in urlencode
24292 !! wikitext
24293 {{urlencode:x<nowiki/>y}}
24294 {{urlencode:x<nowiki/>y|wiki}}
24295 {{urlencode:x<nowiki/>y|path}}
24296 {{urlencode:x<pre id="one">two</pre>y}}
24297 !! html/php
24298 <p>xy
24299 xy
24300 xy
24301 xy
24302 </p>
24303 !! end
24304
24305 !! test
24306 Strip marker in lc
24307 !! wikitext
24308 {{lc:x<nowiki/>y}}
24309 !! html
24310 <p>xy
24311 </p>
24312 !! end
24313
24314 !! test
24315 Strip marker in uc
24316 !! wikitext
24317 {{uc:x<nowiki/>y}}
24318 !! html
24319 <p>XY
24320 </p>
24321 !! end
24322
24323 !! test
24324 Strip marker in formatNum
24325 !! wikitext
24326 {{formatnum:1<nowiki/>2}}
24327 {{formatnum:1<nowiki/>2|R}}
24328 !! html
24329 <p>12
24330 12
24331 </p>
24332 !! end
24333
24334 !! test
24335 Check noCommafy in formatNum
24336 !! options
24337 language=be-tarask
24338 !! wikitext
24339 {{formatnum:123456.78}}
24340 {{formatnum:123456.78|NOSEP}}
24341 !! html
24342 <p>123 456,78
24343 123456.78
24344 </p>
24345 !! end
24346
24347 !! test
24348 Wrong option for formatNum (T58199)
24349 !! wikitext
24350 {{formatnum:1,234.56|Random}}
24351 {{formatnum:1,234.56|EVERYTHING}}
24352 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
24353 !! html
24354 <p>1,234.56
24355 1,234.56
24356 1,234.56
24357 </p>
24358 !! end
24359
24360 !! test
24361 Strip marker in grammar
24362 !! options
24363 language=fi
24364 !! wikitext
24365 {{grammar:elative|foo<nowiki/>bar}}
24366 !! html
24367 <p>foobarista
24368 </p>
24369 !! end
24370
24371 !! test
24372 Strip marker in padleft
24373 !! wikitext
24374 {{padleft:|2|x<nowiki/>y}}
24375 !! html
24376 <p>xy
24377 </p>
24378 !! end
24379
24380 !! test
24381 Strip marker in padright
24382 !! wikitext
24383 {{padright:|2|x<nowiki/>y}}
24384 !! html
24385 <p>xy
24386 </p>
24387 !! end
24388
24389 !! test
24390 Strip marker in anchorencode
24391 !! wikitext
24392 {{anchorencode:x<nowiki/>y}}
24393 !! html
24394 <p>xy
24395 </p>
24396 !! end
24397
24398 !! test
24399 nowiki inside link inside heading (T20295)
24400 !! wikitext
24401 ==[[foo|x<nowiki>y</nowiki>z]]==
24402 !! html
24403 <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>
24404
24405 !! end
24406
24407 !! test
24408 new support for bdi element (T33817)
24409 !! wikitext
24410 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24411 !! html
24412 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
24413
24414 !!end
24415
24416 !! test
24417 Ignore pipe between table row attributes
24418 !! wikitext
24419 {|
24420 | quux
24421 |- id=foo | style='color: red'
24422 | bar
24423 |}
24424 !! html
24425 <table>
24426 <tr>
24427 <td> quux
24428 </td></tr>
24429 <tr id="foo" style="color: red">
24430 <td> bar
24431 </td></tr></table>
24432
24433 !! end
24434
24435 !!test
24436 Language parser function
24437 !! wikitext
24438 {{#language:ar}}
24439 !! html
24440 <p>العربية
24441 </p>
24442 !! end
24443
24444 !!test
24445 Padleft and padright as substr
24446 !! wikitext
24447 {{padleft:|3|abcde}}
24448 {{padright:|3|abcde}}
24449 !! html
24450 <p>abc
24451 abc
24452 </p>
24453 !! end
24454
24455 !!test
24456 Special parser function
24457 !! wikitext
24458 {{#special:RandomPage}}
24459 {{#special:BaDtItLe}}
24460 {{#special:Foobar}}
24461 !! html
24462 <p>Special:Random
24463 Special:Badtitle
24464 Special:Foobar
24465 </p>
24466 !! end
24467
24468 !!test
24469 T36939 - Case insensitive link parsing ([HttP://])
24470 !! wikitext
24471 [HttP://MediaWiki.Org/]
24472 !! html/php
24473 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
24474 </p>
24475 !! html/parsoid
24476 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/"></a></p>
24477 !! end
24478
24479 !!test
24480 T36939 - Case insensitive link parsing ([HttP:// title])
24481 !! wikitext
24482 [HttP://MediaWiki.Org/ MediaWiki]
24483 !! html
24484 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
24485 </p>
24486 !! end
24487
24488 !!test
24489 T36939 - Case insensitive link parsing (HttP://)
24490 !! wikitext
24491 HttP://MediaWiki.Org/
24492 !! html/php
24493 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
24494 </p>
24495 !! html/parsoid
24496 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
24497 !! end
24498
24499 !!test
24500 Disable TOC
24501 !! options
24502 notoc
24503 !! wikitext
24504 Lead
24505 == Section 1 ==
24506 == Section 2 ==
24507 == Section 3 ==
24508 == Section 4 ==
24509 == Section 5 ==
24510 !! html
24511 <p>Lead
24512 </p>
24513
24514 <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>
24515 <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>
24516 <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>
24517 <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>
24518 <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>
24519
24520 !! end
24521
24522
24523 ###
24524 ### Parsoid-specific tests
24525 ### Parsoid-PHP parser incompatibilities
24526 ###
24527 !!test
24528 1. SOL-sensitive wikitext tokens as template-args
24529 !!options
24530 parsoid=wt2html,wt2wt
24531 !! wikitext
24532 {{echo|*a}}
24533 {{echo|#a}}
24534 {{echo|:a}}
24535 !! html
24536 <span about="#mwt1" typeof="mw:Transclusion">
24537 </span><ul about="#mwt1"><li>a</li>
24538 </ul>
24539 <span about="#mwt2" typeof="mw:Transclusion">
24540 </span><ol about="#mwt2"><li>a</li>
24541 </ol>
24542 <span about="#mwt3" typeof="mw:Transclusion">
24543 </span><dl about="#mwt3"><dd>a</dd>
24544 </dl>
24545 !!end
24546
24547 #### -----------------------------------------------------------------
24548 #### Parsoid-specific functionality tests
24549 #### -----------------------------------------------------------------
24550
24551 # T65642/T68749: Formatting elt fixup around images is cleaned up.
24552 # We know wt2wt will fail, but we expect selser to pass.
24553 # Due to the nature of our testing, wt2wt and selser tests will enter the
24554 # blacklist and we'll catch selser regressions based on changes to the
24555 # blacklist entries for selser tests.
24556 !! test
24557 1. Bad treebuilder fixup of formatting elt is cleaned up
24558 !! options
24559 parsoid=wt2html,wt2wt
24560 !! wikitext
24561 {|
24562 |
24563 <small>
24564 [[Image:Foobar.jpg|right|Test]]
24565 </small>
24566 |}
24567 !! html/parsoid
24568 <table>
24569 <tbody><tr><td>
24570 <small>
24571 <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>
24572 </small>
24573 </td></tr>
24574 </tbody></table>
24575 !! end
24576
24577 !! test
24578 2. Bad treebuilder fixup of formatting elt is cleaned up
24579 !! options
24580 parsoid=wt2html,wt2wt
24581 !! wikitext
24582 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
24583
24584 <small>[[Image:Foobar.jpg|right|300px]]</small>
24585 !! html/parsoid
24586
24587 <p><b>foo</b></p>
24588 <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>
24589 <p><b>bar</b></p>
24590 <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>
24591 !! end
24592
24593 !! test
24594 3. Bad treebuilder fixup of formatting elt is cleaned up
24595 !! options
24596 parsoid=wt2html,wt2wt
24597 !! wikitext
24598 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
24599 !! html/parsoid
24600 <p><small><b>foo</b></small></p>
24601 <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>
24602 <p><small><b>bar</b></small></p>
24603 !! end
24604
24605 !! test
24606 4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
24607 !! options
24608 parsoid=wt2html,wt2wt
24609 !! wikitext
24610 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
24611 !! html/parsoid
24612 <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>
24613 !! end
24614
24615 #### ----------------------------------------------------------------
24616 #### Parsoid-only testing of Parsoid's impl of LST
24617 #### Not implemented yet, see
24618 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
24619 #### ----------------------------------------------------------------
24620
24621 ## We still need to support serializing the older format while content is stored.
24622 !! test
24623 LST Sections: Backwards compatibility
24624 !! options
24625 parsoid={
24626 "suppressErrors": true,
24627 "modes": ["html2wt"]
24628 }
24629 !! wikitext
24630 <section begin="2011-05-16" />
24631 <section end="2014-04-10 (MW 1.23wmf22)" />
24632 !! html/parsoid
24633 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
24634 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
24635 !! end
24636
24637 !! test
24638 LST Sections: Newfangled approach
24639 !! wikitext
24640 <section begin="2011-05-16" />
24641 <section end="2014-04-10 (MW 1.23wmf22)" />
24642 !! html/parsoid
24643 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'>
24644 </span>
24645 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null}'>
24646 </span></p>
24647 !! end
24648
24649 #--------- Test stripping of empty nodes in template content ----------
24650
24651 !! test
24652 Empty LI and TR nodes should be stripped from template content
24653 !! wikitext
24654 {{EmptyLITest}}
24655 {{EmptyTRTest}}
24656 !! html/parsoid
24657 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
24658 <li>a</li>
24659 <li>b</li>
24660 </ul>
24661 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
24662 <tbody>
24663 <tr>
24664 <td>foo</td>
24665 </tr>
24666 <tr>
24667 <td>bar</td>
24668 </tr>
24669 </tbody>
24670 </table>
24671 !! end
24672
24673 !! test
24674 Empty LI and TR nodes should not be stripped from top-level content
24675 !! wikitext
24676 * a
24677 *
24678 * b
24679 {|
24680 |-
24681 |-
24682 |foo
24683 |}
24684 !! html/parsoid
24685 <ul>
24686 <li> a</li>
24687 <li class='mw-empty-elt'></li>
24688 <li> b</li>
24689 </ul>
24690 <table>
24691 <tbody>
24692 <tr class='mw-empty-elt'></tr>
24693 <tr>
24694 <td>foo</td>
24695 </tr>
24696 </tbody>
24697 </table>
24698 !! end
24699
24700 !! test
24701 Empty TR nodes should not be stripped if they have any attributes set
24702 !! wikitext
24703 {{EmptyTRWithHTMLAttrTest}}
24704 !! html/parsoid
24705 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
24706 <tr align='center'></tr>
24707 <tr><td>foo</td></tr>
24708 <tr align='center'></tr>
24709 <tr><td>bar</td></tr>
24710 </table>
24711 !! end
24712
24713 #### ----------------------------------------------------------------
24714 #### The following section of tests are primarily to test
24715 #### wikitext escaping capabilities of Parsoid. Given that
24716 #### escaping can be done any number of ways, the wikitext (input)
24717 #### is always adjusted to reflect how Parsoid adds nowiki
24718 #### escape tags.
24719 ####
24720 #### We are marking several tests as parsoid-only since the
24721 #### HTML in the result section is different from what the
24722 #### PHP parser generates for it.
24723 #### ----------------------------------------------------------------
24724
24725
24726 #### --------------- Headings ---------------
24727 #### 0. Unnested
24728 #### 1. Nested inside html <h1>=foo=</h1>
24729 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
24730 #### 3. Nested inside html with wikitext split by html tags
24731 #### 4. No escape needed
24732 #### 5. Empty headings <h1></h1>
24733 #### 6. Heading chars in SOL context
24734 #### ----------------------------------------
24735 !! test
24736 Headings: 0. Unnested
24737 !! options
24738 parsoid=html2wt
24739 !! html/parsoid
24740 <p>=foo=</p>
24741
24742 <p> =foo=
24743 <!--cmt-->
24744 =foo=</p>
24745
24746 <p>=foo<i>a</i>=</p>
24747 !! wikitext
24748 <nowiki>=foo=</nowiki>
24749
24750 <nowiki> </nowiki>=foo=
24751 <!--cmt-->
24752 <nowiki>=foo=</nowiki>
24753
24754 =foo''a''<nowiki>=</nowiki>
24755 !!end
24756
24757 # New headings and existing headings are handled differently
24758 !! test
24759 Headings: 1. Nested inside html
24760 !! options
24761 parsoid=html2wt
24762 !! html/parsoid
24763 <h1>=foo=</h1>
24764 <h2>=foo=</h2>
24765 <h3>=foo=</h3>
24766
24767 <h1 data-parsoid=''>=foo=</h1>
24768 <h2 data-parsoid=''>=foo=</h2>
24769 <h3 data-parsoid=''>=foo=</h3>
24770 <h4 data-parsoid=''>=foo=</h4>
24771 <h5 data-parsoid=''>=foo=</h5>
24772 <h6 data-parsoid=''>=foo=</h6>
24773 !! wikitext
24774 = =foo= =
24775
24776 == =foo= ==
24777
24778 === =foo= ===
24779
24780 =<nowiki>=foo=</nowiki>=
24781 ==<nowiki>=foo=</nowiki>==
24782 ===<nowiki>=foo=</nowiki>===
24783 ====<nowiki>=foo=</nowiki>====
24784 =====<nowiki>=foo=</nowiki>=====
24785 ======<nowiki>=foo=</nowiki>======
24786
24787 !!end
24788
24789 !! test
24790 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
24791 !! options
24792 parsoid=html2wt
24793 !! html/parsoid
24794 <h1>foo</h1>*bar
24795 <h1>foo</h1>=bar
24796 <h1>foo</h1>=bar=
24797 !! wikitext
24798 = foo =
24799 <nowiki>*</nowiki>bar
24800
24801 = foo =
24802 =bar
24803
24804 = foo =
24805 <nowiki>=bar=</nowiki>
24806 !!end
24807
24808 !! test
24809 Headings: 3. Nested inside html with wikitext split by html tags
24810 !! options
24811 parsoid=html2wt
24812 !! html/parsoid
24813 <h1>=<b>bold</b>foo=</h1>
24814 !! wikitext
24815 = ='''bold'''foo= =
24816 !!end
24817
24818 !! test
24819 Headings: 4a. No escaping needed (testing just h1 and h2)
24820 !! options
24821 parsoid=html2wt
24822 !! html/parsoid
24823 <h1>=foo</h1>
24824 <h1>foo=</h1>
24825 <h1> =foo= </h1>
24826 <h1>=foo= bar</h1>
24827 <h2>=foo</h2>
24828 <h2>foo=</h2>
24829 <h1>=</h1>
24830 <h1><i>=</i>foo=</h1>
24831 !! wikitext
24832 = =foo =
24833
24834 = foo= =
24835
24836 = =foo= =
24837
24838 = =foo= bar =
24839
24840 == =foo ==
24841
24842 == foo= ==
24843
24844 = = =
24845
24846 = ''=''foo= =
24847 !!end
24848
24849 !! test
24850 Headings: 4b. No escaping needed (inside p-tags)
24851 !! options
24852 parsoid=html2wt
24853 !! html/parsoid
24854 <p>===
24855 =foo= x
24856 =foo= <s></s>
24857 </p>
24858 !! wikitext
24859 ===
24860 =foo= x
24861 =foo= <s></s>
24862 !!end
24863
24864 !! test
24865 Headings: 5. Empty headings
24866 !! options
24867 parsoid=html2wt
24868 !! html/parsoid
24869 <h1 data-parsoid='{}'></h1>
24870
24871 <h2 data-parsoid='{}'></h2>
24872
24873 <h3 data-parsoid='{}'></h3>
24874
24875 <h4 data-parsoid='{}'></h4>
24876
24877 <h5 data-parsoid='{}'></h5>
24878
24879 <h6 data-parsoid='{}'></h6>
24880 !! wikitext
24881 =<nowiki/>=
24882
24883 ==<nowiki/>==
24884
24885 ===<nowiki/>===
24886
24887 ====<nowiki/>====
24888
24889 =====<nowiki/>=====
24890
24891 ======<nowiki/>======
24892 !!end
24893
24894 !! test
24895 Headings: 6a. Heading chars in SOL context (with trailing spaces)
24896 !! options
24897 parsoid=html2wt
24898 !! html/parsoid
24899 <p>=a=</p>
24900
24901 <p>=a=</p>
24902
24903 <p>=a=</p>
24904 !! wikitext
24905 <nowiki>=a=</nowiki>
24906
24907 <nowiki>=a=</nowiki>
24908
24909 <nowiki>=a=</nowiki>
24910 !!end
24911
24912 !! test
24913 Headings: 6b. Heading chars in SOL context (with trailing newlines)
24914 !! options
24915 parsoid=html2wt
24916 !! html/parsoid
24917 <p>=a=
24918 b</p>
24919
24920 <p>=a=
24921 b</p>
24922
24923 <p>=a=
24924 b</p>
24925 !! wikitext
24926 <nowiki>=a=</nowiki>
24927 b
24928
24929 <nowiki>=a=</nowiki>
24930 b
24931
24932 <nowiki>=a=</nowiki>
24933 b
24934 !!end
24935
24936 !! test
24937 Headings: 6c. Heading chars in SOL context (leading newline break)
24938 !! options
24939 parsoid=html2wt
24940 !! html/parsoid
24941 <p>a
24942 =b=</p>
24943 !! wikitext
24944 a
24945 <nowiki>=b=</nowiki>
24946 !!end
24947
24948 !! test
24949 Headings: 6d. Heading chars in SOL context (with interspersed comments)
24950 !! options
24951 parsoid=html2wt
24952 !! html/parsoid
24953 <!--c0--><p>=a=</p>
24954
24955 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
24956 !! wikitext
24957 <!--c0--><nowiki>=a=</nowiki>
24958
24959 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
24960 !!end
24961
24962 !! test
24963 Headings: 6d. Heading chars in SOL context (No escaping needed)
24964 !! options
24965 parsoid=html2wt
24966 !! html/parsoid
24967 =a=<div>b</div>
24968 !! wikitext
24969 =a=<div>b</div>
24970 !!end
24971
24972 !! test
24973 Headings: 7. Insert a newline between new content and headings
24974 !! options
24975 parsoid=html2wt
24976 !! html/parsoid
24977 <h2>NEW</h2>
24978 <p>new</p>
24979 <h2 data-parsoid='{}'>A</h2>
24980 <p data-parsoid='{}'>a</p>
24981 !! wikitext
24982 == NEW ==
24983 new
24984
24985 ==A==
24986 a
24987
24988 !! end
24989
24990 #### --------------- Lists ---------------
24991 #### 0. Outside nests (*foo, etc.)
24992 #### 1. Nested inside html <ul><li>*foo</li></ul>
24993 #### 2. Inside definition lists
24994 #### 3. Only bullets at start should be escaped
24995 #### 4. No escapes needed
24996 #### 5. No unnecessary escapes
24997 #### 6. Escape bullets in SOL position
24998 #### 7. Escape bullets in a multi-line context
24999 #### ----------------------------------------
25000
25001 !! test
25002 Lists: 0. Outside nests
25003 !! options
25004 parsoid=html2wt
25005 !! html/parsoid
25006 <p>*foo</p>
25007
25008 <p>#foo</p>
25009
25010 <p>;Foo:bar</p>
25011 !! wikitext
25012 <nowiki>*</nowiki>foo
25013
25014 <nowiki>#</nowiki>foo
25015
25016 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
25017 !!end
25018
25019 ## Making these next 3 tests Parsoid-only since they are html2wt tests
25020 ## to test wikitext escaping, and insignificant whitespace diffs
25021 ## cause PHP parser tests to barf
25022 !! test
25023 Lists: 1. Nested inside html (No unnecessary escapes)
25024 !! options
25025 parsoid=html2wt
25026 !! html/parsoid
25027 <ul>
25028 <li>*foo</li>
25029 <li>#foo</li>
25030 <li>:foo</li>
25031 <li>;foo</li>
25032 <li data-parsoid='{}'>*foo</li>
25033 <li data-parsoid='{}'>#foo</li>
25034 <li data-parsoid='{}'>:foo</li>
25035 <li data-parsoid='{}'>;foo</li>
25036 </ul>
25037
25038 <ol>
25039 <li>*foo</li>
25040 <li>#foo</li>
25041 <li>:foo</li>
25042 <li>;foo</li>
25043 <li data-parsoid='{}'>*foo</li>
25044 <li data-parsoid='{}'>#foo</li>
25045 <li data-parsoid='{}'>:foo</li>
25046 <li data-parsoid='{}'>;foo</li>
25047 </ol>
25048 !! wikitext
25049 * *foo
25050 * #foo
25051 * :foo
25052 * ;foo
25053 *<nowiki>*foo</nowiki>
25054 *<nowiki>#foo</nowiki>
25055 *<nowiki>:foo</nowiki>
25056 *<nowiki>;foo</nowiki>
25057
25058 # *foo
25059 # #foo
25060 # :foo
25061 # ;foo
25062 #<nowiki>*foo</nowiki>
25063 #<nowiki>#foo</nowiki>
25064 #<nowiki>:foo</nowiki>
25065 #<nowiki>;foo</nowiki>
25066 !!end
25067
25068 !! test
25069 Lists: 2. Inside definition lists
25070 !! options
25071 parsoid=html2wt
25072 !! html/parsoid
25073 <dl><dt>;foo</dt></dl>
25074 <dl><dt>:foo</dt></dl>
25075 <dl><dt>:foo</dt>
25076 <dd>bar</dd></dl>
25077 <dl><dd>:foo</dd></dl>
25078 !! wikitext
25079 ; ;foo
25080
25081 ; <nowiki>:foo</nowiki>
25082
25083 ; <nowiki>:foo</nowiki>
25084 : bar
25085
25086 : :foo
25087 !!end
25088
25089 !! test
25090 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
25091 !! options
25092 parsoid=html2wt
25093 !! html/parsoid
25094 <ul>
25095 <li>*foo*bar</li>
25096 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
25097 </ul>
25098 !! wikitext
25099 * *foo*bar
25100 *<nowiki>*foo</nowiki>''it''*bar
25101 !!end
25102
25103 !! test
25104 Lists: 4. No escapes needed
25105 !! options
25106 parsoid=html2wt
25107 !! html/parsoid
25108 <ul>
25109 <li>foo*bar
25110 </li>
25111 </ul>
25112 <ul>
25113 <li><i>foo</i>*bar
25114 </li>
25115 </ul>
25116 <ul>
25117 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
25118 </li>
25119 </ul>
25120 <ul>
25121 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
25122 </li>
25123 </ul>
25124 !! wikitext
25125 *foo*bar
25126
25127 *''foo''*bar
25128
25129 *[[Foo]]: bar
25130
25131 *[[Foo]]*bar
25132 !!end
25133
25134 !! test
25135 Lists: 5. No unnecessary escapes
25136 !! options
25137 parsoid=html2wt
25138 !! html/parsoid
25139 <ul><li> bar <span>[[foo]]</span></li></ul>
25140 <ul><li> =bar <span>[[foo]]</span></li></ul>
25141 <ul><li> [[bar <span>[[foo]]</span></li></ul>
25142 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
25143 <ul><li> =bar <span>foo]]</span>=</li></ul>
25144 <ul><li> <s></s>: a</li></ul>
25145 <ul><li> <i>* foo</i></li></ul>
25146
25147 !! wikitext
25148 * bar <span><nowiki>[[foo]]</nowiki></span>
25149
25150 * =bar <span><nowiki>[[foo]]</nowiki></span>
25151
25152 * [[bar <span><nowiki>[[foo]]</nowiki></span>
25153
25154 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
25155
25156 * =bar <span>foo]]</span>=
25157
25158 * <s></s>: a
25159
25160 * ''* foo''
25161 !!end
25162
25163 !! test
25164 Lists: 6. Escape bullets in SOL position
25165 !! options
25166 parsoid=html2wt
25167 !! html/parsoid
25168 <p><!--cmt-->*foo</p>
25169 !! wikitext
25170 <!--cmt--><nowiki>*</nowiki>foo
25171 !!end
25172
25173 !! test
25174 Lists: 7. Escape bullets in a multi-line context
25175 !! options
25176 parsoid=html2wt
25177 !! html/parsoid
25178 <p>a
25179 *b
25180 </p>
25181 !! wikitext
25182 a
25183 <nowiki>*</nowiki>b
25184 !!end
25185
25186 !! test
25187 Lists: 8. Escape colons only if not present in tags
25188 !! options
25189 parsoid=html2wt
25190 !! html/parsoid
25191 <dl><dt>a:b<i>c:d</i></dt></dl>
25192 !! wikitext
25193 ; <nowiki>a:b</nowiki>''c:d''
25194 !! end
25195
25196 #### --------------- HRs ---------------
25197 #### 1. Single line
25198 #### -----------------------------------
25199
25200 !! test
25201 HRs: 1. Single line
25202 !! options
25203 parsoid=html2wt
25204 !! html/parsoid
25205 <hr />----
25206 <hr />=foo=
25207 <hr />*foo
25208 !! wikitext
25209 ----<nowiki>----</nowiki>
25210 ----=foo=
25211 ----*foo
25212 !! end
25213
25214 #### --------------- Tables ---------------
25215 #### 1a. Simple example
25216 #### 1b. No escaping needed (!foo)
25217 #### 1c. No escaping needed (|foo)
25218 #### 1d. No escaping needed (|}foo)
25219 ####
25220 #### 2a. Nested in td (<td>foo|bar</td>)
25221 #### 2b. Nested in td (<td>foo||bar</td>)
25222 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
25223 ####
25224 #### 3a. Nested in th (<th>foo!bar</th>)
25225 #### 3b. Nested in th (<th>foo!!bar</th>)
25226 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
25227 ####
25228 #### 4a. Escape -
25229 #### 4b. Escape +
25230 #### 4c. No escaping needed
25231 #### --------------------------------------
25232
25233 !! test
25234 Tables: 1a. Simple example
25235 !! options
25236 parsoid=html2wt
25237 !! html/parsoid
25238 <p>{|
25239 |}
25240 </p>
25241 !! wikitext
25242 <nowiki>{|</nowiki>
25243 |}
25244 !! end
25245
25246 !! test
25247 Tables: 1b. No escaping needed
25248 !! options
25249 parsoid=html2wt
25250 !! html/parsoid
25251 <p>!foo
25252 </p>
25253 !! wikitext
25254 !foo
25255 !! end
25256
25257 !! test
25258 Tables: 1c. No escaping needed
25259 !! options
25260 parsoid=html2wt
25261 !! html/parsoid
25262 <p>|foo
25263 </p>
25264 !! wikitext
25265 |foo
25266 !! end
25267
25268 !! test
25269 Tables: 1d. No escaping needed
25270 !! options
25271 parsoid=html2wt
25272 !! html/parsoid
25273 <p>|}foo
25274 </p>
25275 !! wikitext
25276 |}foo
25277 !! end
25278
25279 !! test
25280 Tables: 2a. Nested in td
25281 !! options
25282 parsoid=html2wt
25283 !! html/parsoid
25284 <table><tbody><tr>
25285 <td>foo|bar</td></tr>
25286 <tr><td>x<div>a|b</div></td>
25287 </tbody></table>
25288 !! wikitext
25289 {|
25290 |<nowiki>foo|bar</nowiki>
25291 |-
25292 |x<div><nowiki>a|b</nowiki></div>
25293 |}
25294 !! html/php+tidy
25295 <table>
25296 <tr>
25297 <td>foo|bar</td>
25298 </tr>
25299 <tr>
25300 <td>x
25301 <div>a|b</div>
25302 </td>
25303 </tr>
25304 </table>
25305 !! end
25306
25307 !! test
25308 Tables: 2b. Nested in td
25309 !! options
25310 parsoid=html2wt
25311 !! html/parsoid
25312 <table><tbody><tr>
25313 <td>foo||bar</td>
25314 <td>a<i>b||c</i></td>
25315 <td>a<i><div>b||c</div></i></td>
25316 </tr></tbody></table>
25317 !! wikitext
25318 {|
25319 |<nowiki>foo||bar</nowiki>
25320 |a''<nowiki>b||c</nowiki>''
25321 |a''<div><nowiki>b||c</nowiki></div>''
25322 |}
25323 !! html/php
25324 <table>
25325 <tr>
25326 <td>foo||bar
25327 </td>
25328 <td>a<i>b||c</i>
25329 </td>
25330 <td>a<i><div>b||c</div></i>
25331 </td></tr></table>
25332
25333 !! end
25334
25335 !! test
25336 Tables: 2c. Nested in td -- no escaping needed
25337 !! options
25338 parsoid=html2wt
25339 !! html/*
25340 <table>
25341 <tr>
25342 <td>foo!!bar
25343 </td></tr></table>
25344
25345 !! wikitext
25346 {|
25347 |foo!!bar
25348 |}
25349 !! end
25350
25351 !! test
25352 Tables: 3a. Nested in th
25353 !! options
25354 parsoid=html2wt
25355 !! html/*
25356 <table>
25357 <tr>
25358 <th>foo!bar
25359 </th></tr></table>
25360
25361 !! wikitext
25362 {|
25363 !foo!bar
25364 |}
25365 !! end
25366
25367 !! test
25368 Tables: 3b. Nested in th
25369 !! options
25370 parsoid=html2wt
25371 !! html/parsoid
25372 <table><tbody>
25373 <tr><th>foo!!bar</th>
25374 <th><i>foo|bar</i></th>
25375 <th><i>foo!!bar</i></th>
25376 <th><i><span>foo!!bar</span></i></th>
25377 </tr></tbody></table>
25378 !! wikitext
25379 {|
25380 !<nowiki>foo!!bar</nowiki>
25381 !''<nowiki>foo|bar</nowiki>''
25382 !''<nowiki>foo!!bar</nowiki>''
25383 !''<span><nowiki>foo!!bar</nowiki></span>''
25384 |}
25385 !! html/php
25386 <table>
25387 <tr>
25388 <th>foo!!bar
25389 </th>
25390 <th><i>foo|bar</i>
25391 </th>
25392 <th><i>foo!!bar</i>
25393 </th>
25394 <th><i><span>foo!!bar</span></i>
25395 </th></tr></table>
25396
25397 !! end
25398
25399 !! test
25400 Tables: 3c. Nested in th
25401 !! options
25402 parsoid=html2wt
25403 !! html/parsoid
25404 <table><tbody>
25405 <tr><th>foo||bar</th>
25406 <th><span typeof="mw:Nowiki">foo||bar</span></th>
25407 </tr></tbody></table>
25408 !! wikitext
25409 {|
25410 !<nowiki>foo||bar</nowiki>
25411 !<nowiki>foo||bar</nowiki>
25412 |}
25413 !! html/php
25414 <table>
25415 <tr>
25416 <th>foo||bar
25417 </th>
25418 <th>foo||bar
25419 </th></tr></table>
25420
25421 !! end
25422
25423 !! test
25424 Tables: 4a. Escape -
25425 !! options
25426 parsoid=html2wt
25427 !! html/*
25428 <table>
25429 <tr>
25430 <th>-bar
25431 </th></tr>
25432 <tr>
25433 <td>-bar
25434 </td></tr></table>
25435
25436 !! wikitext
25437 {|
25438 !-bar
25439 |-
25440 |<nowiki>-bar</nowiki>
25441 |}
25442 !! end
25443
25444 !! test
25445 Tables: 4b. Escape +
25446 !! options
25447 parsoid=html2wt
25448 !! html/*
25449 <table>
25450 <tr>
25451 <th>+bar
25452 </th></tr>
25453 <tr>
25454 <td>+bar
25455 </td></tr></table>
25456
25457 !! wikitext
25458 {|
25459 !+bar
25460 |-
25461 |<nowiki>+bar</nowiki>
25462 |}
25463 !! end
25464
25465 !! test
25466 Tables: 4c. No escaping needed
25467 !! options
25468 parsoid=html2wt
25469 !! html/parsoid
25470 <table><tbody>
25471 <tr><td>foo-bar</td><td>foo+bar</td></tr>
25472 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
25473 <tr><td>foo
25474 <p>bar|baz
25475 +bar
25476 -bar</p></td></tr>
25477 <tr><td>x
25478 <div>a|b</div></td>
25479 </tbody></table>
25480 !! wikitext
25481 {|
25482 |foo-bar
25483 |foo+bar
25484 |-
25485 |''foo''-bar
25486 |''foo''+bar
25487 |-
25488 |foo
25489 bar|baz
25490 +bar
25491 -bar
25492 |-
25493 |x
25494 <div>a|b</div>
25495 |}
25496 !! html/php
25497 <table>
25498 <tr>
25499 <td>foo-bar
25500 </td>
25501 <td>foo+bar
25502 </td></tr>
25503 <tr>
25504 <td><i>foo</i>-bar
25505 </td>
25506 <td><i>foo</i>+bar
25507 </td></tr>
25508 <tr>
25509 <td>foo
25510 <p>bar|baz
25511 +bar
25512 -bar
25513 </p>
25514 </td></tr>
25515 <tr>
25516 <td>x
25517 <div>a|b</div>
25518 </td></tr></table>
25519
25520 !! end
25521
25522 !! test
25523 Tables: 4d. No escaping needed
25524 !! options
25525 parsoid=html2wt
25526 !! html/parsoid
25527 <table>
25528 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
25529 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
25530 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
25531 </tbody></table>
25532 !! wikitext
25533 {|
25534 |[[Foo]]-bar
25535 ||+1
25536 ||-2
25537 |}
25538 !! html/php
25539 <table>
25540 <tr>
25541 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
25542 </td>
25543 <td>+1
25544 </td>
25545 <td>-2
25546 </td></tr></table>
25547
25548 !! end
25549
25550 !! test
25551 T97430: Don't emit empty nowiki pairs around marker meta tags
25552 !! options
25553 parsoid=html2wt
25554 !! html/parsoid
25555 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25556 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
25557 !! wikitext
25558 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
25559 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
25560 !! end
25561
25562 !! test
25563 Unclosed xmlish element in table line shouldn't eat end delimiters
25564 !! options
25565 parsoid=html2wt
25566 !! html/parsoid
25567 <table>
25568 <tbody><tr><td> &lt;foo</td>
25569 <td> bar></td></tr>
25570 </tbody></table>
25571 !! wikitext
25572 {|
25573 | <foo
25574 | bar>
25575 |}
25576 !! html/php
25577 <table>
25578 <tr>
25579 <td> &lt;foo
25580 </td>
25581 <td> bar&gt;
25582 </td></tr></table>
25583
25584 !! end
25585
25586 #### --------------- Links ----------------
25587 #### 1. Quote marks in link text
25588 #### 2. Wikilinks: Escapes needed
25589 #### 3. Wikilinks: No escapes needed
25590 #### 4. Extlinks: Escapes needed
25591 #### 5. Extlinks: No escapes needed
25592 #### --------------------------------------
25593 !! test
25594 Links 1. WikiLinks: No escapes needed
25595 !! options
25596 parsoid=html2wt
25597 !! html/parsoid
25598 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
25599 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
25600 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
25601 !! wikitext
25602 [[Foo|Foo''boo'']]
25603 [[Foo|[Foobar]]]
25604 [[Foo|x [Foobar] x]]
25605 !! html/php
25606 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
25607 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
25608 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
25609 </p>
25610 !! end
25611
25612 !! test
25613 Links 2. WikiLinks: Escapes needed
25614 !! options
25615 parsoid=html2wt
25616 !! html/parsoid
25617 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
25618 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
25619 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
25620 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
25621 <a href="Foo" rel="mw:WikiLink">|Bar</a>
25622 <a href="Foo" rel="mw:WikiLink">]]bar</a>
25623 <a href="Foo" rel="mw:WikiLink">[[bar</a>
25624 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
25625 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
25626 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
25627 !! wikitext
25628 [[Foo|<nowiki>Foobar]</nowiki>]]
25629 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
25630 [[Foo|<nowiki>[[Bar]]</nowiki>]]
25631 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
25632 [[Foo|<nowiki>|Bar</nowiki>]]
25633 [[Foo|<nowiki>]]bar</nowiki>]]
25634 [[Foo|<nowiki>[[bar</nowiki>]]
25635 [[Foo|<nowiki>x [[ y</nowiki>]]
25636 [[Foo|<nowiki>x ]] y</nowiki>]]
25637 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
25638 !! html/php
25639 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
25640 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
25641 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
25642 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
25643 <a href="/wiki/Foo" title="Foo">|Bar</a>
25644 <a href="/wiki/Foo" title="Foo">]]bar</a>
25645 <a href="/wiki/Foo" title="Foo">[[bar</a>
25646 <a href="/wiki/Foo" title="Foo">x [[ y</a>
25647 <a href="/wiki/Foo" title="Foo">x ]] y</a>
25648 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
25649 </p>
25650 !! end
25651
25652 !! test
25653 Links 3. WikiLinks: No escapes needed
25654 !! options
25655 parsoid=html2wt
25656 !! html/parsoid
25657 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
25658 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
25659 !! wikitext
25660 [[Foo|[Foobar]]
25661 [[Foo|foo|bar]]
25662 !! html/php
25663 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
25664 <a href="/wiki/Foo" title="Foo">foo|bar</a>
25665 </p>
25666 !! end
25667
25668 !! test
25669 Links 4. ExtLinks: Escapes needed
25670 !! options
25671 parsoid=html2wt
25672 !! html/parsoid
25673 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
25674 <a rel="mw:ExtLink" href="http://google.com">google]</a>
25675 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
25676 <p>[http://google.com]</p>
25677 <p>[http://google.com google]</p>
25678 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
25679 <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>
25680 !! wikitext
25681 [http://google.com <nowiki>[google]</nowiki>]
25682 [http://google.com <nowiki>google]</nowiki>]
25683 [http://google.com <nowiki>goog] le</nowiki>]
25684
25685 <nowiki>[http://google.com]</nowiki>
25686
25687 <nowiki>[http://google.com google]</nowiki>
25688
25689 [http://google.com<nowiki>]</nowiki>
25690
25691 [{{echo|http://google.com}}<nowiki>]</nowiki>
25692 !! html/php
25693 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
25694 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
25695 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
25696 </p><p>[http://google.com]
25697 </p><p>[http://google.com google]
25698 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
25699 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
25700 </p>
25701 !! end
25702
25703 !! test
25704 Links 5. ExtLinks: No escapes needed
25705 !! options
25706 parsoid=html2wt
25707 !! html/parsoid
25708 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
25709 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
25710 !! wikitext
25711 [http://google.com [google]
25712
25713 [[http://google.com]]
25714 !! html/php
25715 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
25716 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
25717 </p>
25718 !! end
25719
25720 !! test
25721 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
25722 !! options
25723 parsoid=html2wt
25724 !! html/parsoid
25725 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
25726 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
25727 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
25728 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
25729 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
25730 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
25731 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
25732 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
25733 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
25734 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
25735 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
25736 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
25737 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
25738 </p>
25739 !! wikitext
25740 x<nowiki/>http://example.com<nowiki/>y
25741 http://example.com<nowiki/>?x
25742 http://example.com<nowiki/>&x
25743 http://example.com<nowiki/>'x
25744 http://example.com<nowiki/>,x
25745 http://example.com<nowiki/>.x
25746 http://example.com<nowiki/>;x
25747 http://example.com<nowiki/>:x
25748 http://example.com<nowiki/>;x
25749 http://example.com<nowiki/>!x
25750 http://example.com<nowiki/>=x
25751 http://example.com<nowiki/>(x)
25752 http://example.com(x<nowiki/>)
25753 !! end
25754
25755 !! test
25756 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
25757 !! options
25758 parsoid=html2wt
25759 !! html/parsoid
25760 <p>x
25761 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
25762 y
25763 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
25764 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
25765 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
25766 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
25767 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
25768 </p>
25769 !! wikitext
25770 x
25771 http://example.com
25772 y
25773 "http://example.com"
25774 (http://example.com)
25775 (http://example.com) foo
25776 http://example.com,
25777 http://example.com, foo
25778 !! html/php
25779 <p>x
25780 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
25781 y
25782 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
25783 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
25784 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
25785 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
25786 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
25787 </p>
25788 !! end
25789
25790 !! test
25791 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
25792 !! options
25793 parsoid=html2wt
25794 !! html/parsoid
25795 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
25796 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
25797 !! wikitext
25798 http://example.com.,;:!?\
25799 -http://example.com:
25800 !! html/php
25801 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
25802 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
25803 </p>
25804 !! end
25805
25806 !! test
25807 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
25808 !! options
25809 parsoid=html2wt
25810 !! html/parsoid
25811 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
25812 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
25813 X<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
25814 !! wikitext
25815 RFC 123<nowiki/>4
25816 RFC 123<nowiki/>y
25817 X<nowiki/>RFC 123<nowiki/>y
25818 !! end
25819
25820 !! test
25821 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
25822 !! options
25823 parsoid=html2wt
25824 !! html/parsoid
25825 <p><a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
25826 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
25827 -<a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
25828 </p>
25829 !! wikitext
25830 RFC 123?foo
25831 RFC 123&foo
25832 -RFC 123-
25833 !! html/php
25834 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>?foo
25835 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
25836 -<a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc123">RFC 123</a>-
25837 </p>
25838 !! end
25839
25840 !! test
25841 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
25842 !! options
25843 parsoid=html2wt
25844 !! html/parsoid
25845 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
25846 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
25847 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
25848 !! wikitext
25849 PMID 123<nowiki/>4
25850 PMID 123<nowiki/>y
25851 X<nowiki/>PMID 123<nowiki/>y
25852 !! end
25853
25854 !! test
25855 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
25856 !! options
25857 parsoid=html2wt
25858 !! html/parsoid
25859 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
25860 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
25861 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
25862 </p>
25863 !! wikitext
25864 PMID 123?foo
25865 PMID 123&foo
25866 -PMID 123-
25867 !! html/php
25868 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
25869 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
25870 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
25871 </p>
25872 !! end
25873
25874 !! test
25875 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
25876 !! options
25877 parsoid=html2wt
25878 !! html/parsoid
25879 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
25880 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
25881 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
25882 </p>
25883 !! wikitext
25884 ISBN 1234567890<nowiki/>1
25885 ISBN 1234567890<nowiki/>x
25886 a<nowiki/>ISBN 1234567890<nowiki/>b
25887 !! end
25888
25889 !! test
25890 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
25891 !! options
25892 parsoid=html2wt
25893 !! html/parsoid
25894 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
25895 !! wikitext
25896 -ISBN 1234567890's
25897 !! html/php
25898 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
25899 </p>
25900 !! end
25901
25902 !! test
25903 Links 14. Protect link-like plain text. (Parsoid bug T78425)
25904 !! options
25905 parsoid=html2wt
25906 !! html/*
25907 <p>this is not a link: http://example.com
25908 </p>
25909 !! wikitext
25910 this is not a link: <nowiki>http://example.com</nowiki>
25911 !! end
25912
25913 !! test
25914 Links 15. Link trails can't become link prefixes.
25915 !! options
25916 language=is
25917 parsoid=html2wt
25918 !! html/parsoid
25919 <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>
25920 !! wikitext
25921 [[Söfnuður]]-[[00]]
25922 !! html/php
25923 <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>
25924 </p>
25925 !! end
25926
25927 #### --------------- Quotes ---------------
25928 #### 1. Quotes inside <b> and <i>
25929 #### 2. Link fragments separated by <i> and <b> tags
25930 #### 3. Link fragments inside <i> and <b>
25931 #### 4. No escaping needed
25932 #### --------------------------------------
25933 !! test
25934 1a. Quotes inside <b> and <i>
25935 !! options
25936 parsoid=html2wt
25937 !! html/*
25938 <p><i>'foo'</i>
25939 <i>''foo''</i>
25940 <i>'''foo'''</i>
25941 <i>foo</i>'s
25942 <b>'foo'</b>
25943 <b>''foo''</b>
25944 <b>'''foo'''</b>
25945 <b>foo'<i>bar'</i>baz</b>
25946 <b>foo</b>'s
25947 '<i>foo</i>
25948 <i>foo</i>'
25949 <i>foo'</i>'
25950 '<i>foo</i>'
25951 '<b>foo</b>
25952 <b>foo</b>'
25953 '<b>foo</b>'
25954 <i>fools'<span> errand</span></i>
25955 <i><span>fool</span>'s errand</i>
25956 '<i>foo</i> bar '<i>baz</i>
25957 a|!*#-:;+-~[]{}b'<i>x</i>
25958 </p>
25959 !! wikitext
25960 ''<nowiki/>'foo'''
25961 ''<nowiki>''foo''</nowiki>''
25962 ''<nowiki>'''foo'''</nowiki>''
25963 ''foo''<nowiki/>'s
25964 '''<nowiki/>'foo''''
25965 '''<nowiki>''foo''</nowiki>'''
25966 '''<nowiki>'''foo'''</nowiki>'''
25967 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
25968 '''foo'''<nowiki/>'s
25969 '''foo''
25970 ''foo''<nowiki/>'
25971 ''foo'''<nowiki/>'
25972 '''foo''<nowiki/>'
25973 ''''foo'''
25974 '''foo'''<nowiki/>'
25975 ''''foo'''<nowiki/>'
25976 ''fools'<span> errand</span>''
25977 ''<span>fool</span>'s errand''
25978 '<nowiki/>''foo'' bar '''baz''
25979 a|!*#-:;+-~[]{}b'''x''
25980 !! end
25981
25982 !! test
25983 1b. Quotes inside <b> and <i> with other tags on same line
25984 !! options
25985 parsoid=html2wt
25986 !! html/parsoid
25987 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
25988 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
25989 <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>
25990 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
25991 '<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>
25992 '<i>foo</i> <div title="name">test</div>
25993 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
25994 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
25995 <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>
25996 </ol>
25997 !! wikitext
25998 '''a'' foo ''[[bar]]''
25999 ''a''' foo ''[[bar]]''
26000 ''a''' foo '''{{echo|[[bar]]}}'''
26001 [[foo]] x'''[[bar]]''
26002 '''foo'' <ref>test</ref>
26003 '''foo'' <div title="name">test</div>
26004 '''foo'' and <br> bar
26005 <references />
26006 !! end
26007
26008 !! test
26009 2. Link fragments separated by <i> and <b> tags
26010 !! options
26011 parsoid=html2wt
26012 !! html/parsoid
26013 <p>[[<i>foo</i>hello]]</p>
26014 <p>[[<b>foo</b>hello]]</p>
26015 !! wikitext
26016 [[''foo''<nowiki>hello]]</nowiki>
26017
26018 [['''foo'''<nowiki>hello]]</nowiki>
26019 !! end
26020
26021 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
26022 # this is one of the shortcomings of this format
26023 !! test
26024 3. Link fragments inside <i> and <b>
26025 !! options
26026 parsoid=html2wt
26027 !! html/parsoid
26028 <p><i>[[foo</i>]]</p>
26029 <p><b>[[foo</b>]]</p>
26030 !! wikitext
26031 ''[[foo''<nowiki>]]</nowiki>
26032
26033 '''[[foo'''<nowiki>]]</nowiki>
26034 !! end
26035
26036 !! test
26037 4. No escaping needed
26038 !! options
26039 parsoid=html2wt
26040 !! html/parsoid
26041 <p>'<span><i>bar</i></span>'
26042 '<span><b>bar</b></span>'
26043 'a:b'foo
26044 </p>
26045 !! wikitext
26046 '<span>''bar''</span>'
26047 '<span>'''bar'''</span>'
26048 'a:b'foo
26049 !! end
26050
26051 #### ----------- Paragraphs ---------------
26052 #### 1. No unnecessary escapes
26053 #### --------------------------------------
26054
26055 !! test
26056 1. No unnecessary escapes
26057 !! options
26058 parsoid=html2wt
26059 !! html/parsoid
26060 <p>bar <span>[[foo]]</span>
26061 </p><p>=bar <span>[[foo]]</span>
26062 </p><p>[[bar <span>[[foo]]</span>
26063 </p><p>]]bar <span>[[foo]]</span>
26064 </p><p>=bar <span>foo]]</span>=
26065 </p>
26066 !! wikitext
26067 bar <span><nowiki>[[foo]]</nowiki></span>
26068
26069 =bar <span><nowiki>[[foo]]</nowiki></span>
26070
26071 [[bar <span><nowiki>[[foo]]</nowiki></span>
26072
26073 ]]bar <span><nowiki>[[foo]]</nowiki></span>
26074
26075 =bar <span>foo]]</span><nowiki>=</nowiki>
26076 !!end
26077
26078 #### ----------------------- PRE --------------------------
26079 #### 1. Leading whitespace in SOL context should be escaped
26080 #### ------------------------------------------------------
26081 !! test
26082 1. Leading whitespace in SOL context should be escaped
26083 !! options
26084 parsoid=html2wt
26085 !! html/parsoid
26086 <p> a</p>
26087
26088 <p> a</p>
26089
26090 <p> a(tab)</p>
26091
26092 <p> a
26093 <!--cmt-->
26094 a</p>
26095
26096 <p>a
26097 b</p>
26098
26099 <p>a
26100 b</p>
26101
26102 <p>a
26103 b</p>
26104 !! wikitext
26105 <nowiki> </nowiki>a
26106
26107 <nowiki> </nowiki> a
26108
26109 a(tab)
26110
26111 <nowiki> </nowiki> a
26112 <!--cmt-->
26113 <nowiki> </nowiki>a
26114
26115 a
26116 <nowiki> </nowiki>b
26117
26118 a
26119 b
26120
26121 a
26122 b
26123 !! html/php
26124 <p> a
26125 </p><p> a
26126 </p><p> a(tab)
26127 </p><p> a
26128 a
26129 </p><p>a
26130 b
26131 </p><p>a
26132 b
26133 </p><p>a
26134 b
26135 </p>
26136 !! end
26137
26138 !! test
26139 2. Leading whitespace in non-indent-pre contexts should not be escaped
26140 !! options
26141 parsoid=html2wt
26142 !! html/parsoid
26143 <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>
26144 <ol class="mw-references references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
26145 <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>
26146 b</span></li>
26147 </ol>
26148 !! wikitext
26149 foo <ref>''a''
26150 b</ref>
26151 <references />
26152 !! end
26153
26154 !! test
26155 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
26156 !! options
26157 parsoid=html2wt
26158 !! html/parsoid
26159 <blockquote>
26160 <p>
26161 a
26162 <span>b</span>
26163 c</p>
26164 </blockquote>
26165 !! wikitext
26166 <blockquote>
26167 a
26168 <span>b</span>
26169 c
26170 </blockquote>
26171 !! end
26172
26173 !! test
26174 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
26175 !! options
26176 parsoid=html2wt
26177 !! html/parsoid
26178 <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>
26179 !! wikitext
26180 [[File:Foobar.jpg|thumb|caption]]
26181 !! end
26182
26183 !! test
26184 5. Nowiki escaping should account for indent-pres
26185 !! options
26186 parsoid=html2wt
26187 !! html/parsoid
26188 <pre>==foo==</pre>
26189 !! wikitext
26190 ==foo==
26191 !! end
26192
26193 !!test
26194 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
26195 !! options
26196 parsoid=html2wt
26197 !! html/parsoid
26198 <pre>
26199 * foo
26200 * bar
26201 </pre>
26202 !! wikitext
26203 * foo
26204 * bar
26205 !! end
26206
26207 #### --------------- Behavior Switches --------------------
26208
26209 !! test
26210 1. Valid behavior switches should be escaped
26211 !! options
26212 parsoid=html2wt
26213 !! html/parsoid
26214 __TOC__
26215 <i>__TOC__</i>
26216 !! wikitext
26217 <nowiki>__TOC__</nowiki>
26218 ''<nowiki>__TOC__</nowiki>''
26219 !! end
26220
26221 !! test
26222 2. Invalid behavior switches should not be escaped
26223 !! options
26224 parsoid=html2wt
26225 !! html/parsoid
26226 __TOO__
26227 __|__
26228 !! wikitext
26229 __TOO__
26230 __|__
26231 !! end
26232
26233 # We use indent-pre as an indirect way to test for sol-transparent behavior.
26234 !! test
26235 Behavior switches should be SOL-transparent
26236 !! options
26237 parsoid=html2wt
26238 !! html/parsoid
26239 <meta property="mw:PageProp/toc" />
26240
26241 <!-- this one's bogus -->
26242 <pre>__TOO__</pre>
26243
26244 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
26245
26246 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
26247 !! wikitext
26248 __TOC__
26249
26250 <!-- this one's bogus -->
26251 __TOO__
26252
26253 __TOC__ foo
26254
26255 __TOC__
26256 bar
26257 !! end
26258
26259 #### --------------- HTML tags ---------------
26260 #### 1. a tags
26261 #### 2. other tags
26262 #### 3. multi-line html tag
26263 #### 4. extension tags
26264 #### -----------------------------------------
26265 !! test
26266 1. a tags
26267 !! options
26268 parsoid=html2wt
26269 !! html/parsoid
26270 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
26271 !! wikitext
26272 <a href="http://google.com">google</a>
26273 !! end
26274
26275 !! test
26276 2. other tags
26277 !! options
26278 parsoid=html2wt
26279 !! html/parsoid
26280 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
26281 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
26282 <li> &lt;td&gt;</li></ul>
26283
26284 !! wikitext
26285 * <nowiki><div>foo</div></nowiki>
26286 * <nowiki><div style="color:red">foo</div></nowiki>
26287 * <nowiki><td></nowiki>
26288 !! end
26289
26290 !! test
26291 3. multi-line html tag
26292 !! options
26293 parsoid=html2wt
26294 !! html/parsoid
26295 <p>&lt;div
26296 &gt;foo&lt;/div
26297 &gt;
26298 </p>
26299 !! wikitext
26300 <nowiki><div
26301 >foo</div
26302 ></nowiki>
26303 !! end
26304
26305 !! test
26306 4. extension tags
26307 !! options
26308 parsoid=html2wt
26309 !! html/parsoid
26310 <p>&lt;ref&gt;foo&lt;/ref&gt;
26311 </p><p>&lt;ref&gt;bar
26312 </p><p>baz&lt;/ref&gt;
26313 </p>
26314 !! wikitext
26315 <nowiki><ref>foo</ref></nowiki>
26316
26317 <nowiki><ref>bar</nowiki>
26318
26319 baz<nowiki></ref></nowiki>
26320 !! end
26321
26322 #### --------------- Others ---------------
26323 !! test
26324 Escaping nowikis
26325 !! options
26326 parsoid=html2wt
26327 !! html/parsoid
26328 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
26329 </p>
26330 !! wikitext
26331 &lt;nowiki&gt;foo&lt;/nowiki&gt;
26332 !! end
26333
26334 ## The quote-char in the input is necessary for triggering the bug
26335 !! test
26336 (T54035) Nowiki-escaping should not get tripped by " :" in text
26337 !! options
26338 parsoid=html2wt
26339 !! html/parsoid
26340 <p>foo's bar :</p>
26341 !! wikitext
26342 foo's bar :
26343 !! end
26344
26345 #----------- End of wikitext escaping tests --------------
26346
26347 !! test
26348
26349 Tag-like HTML structures are passed through as text
26350 !! wikitext
26351 <x y>
26352
26353 <x.y>
26354
26355 <x-y>
26356
26357 1>2
26358
26359 x<y
26360
26361 a>b
26362
26363 1<d e>f
26364 !! html
26365 <p>&lt;x y&gt;
26366 </p><p>&lt;x.y&gt;
26367 </p><p>&lt;x-y&gt;
26368 </p><p>1&gt;2
26369 </p><p>x&lt;y
26370 </p><p>a&gt;b
26371 </p><p>1&lt;d e&gt;f
26372 </p>
26373 !! end
26374
26375 !! test
26376 HTML tag with necessary entities in attributes
26377 !! wikitext
26378 <span title="&amp;amp;">foo</span>
26379 !! html
26380 <p><span title="&amp;amp;">foo</span>
26381 </p>
26382 !! end
26383
26384 !! test
26385 HTML tag with 'unnecessary' entity encoding in attributes
26386 !! wikitext
26387 <span title="&amp;">foo</span>
26388 !! html
26389 <p><span title="&amp;">foo</span>
26390 </p>
26391 !! end
26392
26393 !! test
26394 HTML tag with broken attribute value quoting
26395 !! options
26396 parsoid=wt2html,html2html
26397 !! wikitext
26398 <span title="Hello world>Foo</span>
26399 !! html/php
26400 <p><span title="Hello world">Foo</span>
26401 </p>
26402 !! html/parsoid
26403 <p><span title="Hello world">Foo</span></p>
26404 !! end
26405
26406 !! test
26407 Self-closed tag with broken attribute value quoting
26408 !! options
26409 parsoid=wt2html,html2html
26410 !! wikitext
26411 <div title="Hello world />Foo
26412 !! html/php+tidy
26413 <div title="Hello world"></div>
26414 <p>Foo</p>
26415 !! html/parsoid
26416 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
26417 !! end
26418
26419 !! test
26420 Table with broken attribute value quoting
26421 !! options
26422 parsoid=wt2html,html2html
26423 !! wikitext
26424 {|
26425 | title="Hello world|Foo
26426 |}
26427 !! html/php
26428 <table>
26429 <tr>
26430 <td title="Hello world">Foo
26431 </td></tr></table>
26432
26433 !! html/parsoid
26434 <table>
26435 <tr>
26436 <td title="Hello world">Foo
26437 </td></tr></table>
26438
26439 !! end
26440
26441 !! test
26442 Table with broken attribute value quoting on consecutive lines
26443 !! options
26444 parsoid=wt2html,html2html
26445 !! wikitext
26446 {|
26447 | title="Hello world|Foo
26448 | style="color:red|Bar
26449 |}
26450 !! html/php
26451 <table>
26452 <tr>
26453 <td title="Hello world">Foo
26454 </td>
26455 <td style="color:red">Bar
26456 </td></tr></table>
26457
26458 !! html/parsoid
26459 <table><tbody>
26460 <tr>
26461 <td title="Hello world">Foo
26462 </td><td style="color: red">Bar
26463 </td></tr></tbody></table>
26464
26465 !! end
26466
26467 !!test
26468 Accept empty td cell attribute
26469 !! wikitext
26470 {|
26471 | align="center" | foo || |
26472 |}
26473 !! html
26474 <table>
26475 <tr>
26476 <td align="center"> foo </td>
26477 <td>
26478 </td></tr></table>
26479
26480 !!end
26481
26482 !!test
26483 Non-empty attributes in th-cells
26484 !! wikitext
26485 {|
26486 ! Foo !! style="color: red" | Bar
26487 |}
26488 !! html
26489 <table>
26490 <tr>
26491 <th> Foo </th>
26492 <th style="color: red"> Bar
26493 </th></tr></table>
26494
26495 !!end
26496
26497 !!test
26498 Accept empty attributes in th-cells
26499 !! wikitext
26500 {|
26501 !| foo !!| bar
26502 |}
26503 !! html
26504 <table>
26505 <tr>
26506 <th> foo </th>
26507 <th> bar
26508 </th></tr></table>
26509
26510 !!end
26511
26512 !!test
26513 Empty table rows go away
26514 !! wikitext
26515 {|
26516 | Hello
26517 | there
26518 |- class="foo"
26519 |-
26520 |}
26521 !! html
26522 <table>
26523 <tr>
26524 <td> Hello
26525 </td>
26526 <td> there
26527 </td></tr>
26528
26529 </table>
26530
26531 !! end
26532
26533 ###
26534 ### Parsoid-centric tests for testing RTing of inter-element separators
26535 ### Edge cases not tested by existing parser tests and specific to
26536 ### Parsoid-specific serialization strategies.
26537 ###
26538
26539 !!test
26540 RT-ed inter-element separators should be valid separators
26541 !! wikitext
26542 {|
26543 |- [[foo]]
26544 |}
26545 !! html/php
26546 <table>
26547
26548 </table>
26549
26550 !! html/parsoid
26551 <table>
26552 <tbody><tr class='mw-empty-elt' data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
26553 </tbody></table>
26554 !!end
26555
26556 # Parsoid-only since PHP parser relies on Tidy for correct output
26557 !!test
26558 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
26559 !!options
26560 parsoid
26561 !! wikitext
26562 {|
26563 |<small>foo
26564 bar
26565 |}
26566
26567 {|
26568 |<small>foo<small>
26569 |}
26570 !! html
26571 <table>
26572 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
26573 <p>bar</p></small></td></tr>
26574 </tbody></table>
26575
26576 <table>
26577 <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>
26578 </tbody></table>
26579 !!end
26580
26581 # Note that the "style" attribute is really a template parameter here.
26582 # The = would have to be {{=}} if you wanted the literal.
26583 !!test
26584 Empty TD followed by TD with tpl-generated attribute
26585 !! wikitext
26586 {|
26587 |-
26588 |
26589 |{{echo|style='color:red'}}|foo
26590 |}
26591 !! html
26592 <table>
26593
26594 <tr>
26595 <td>
26596 </td>
26597 <td>foo
26598 </td></tr></table>
26599
26600 !!end
26601
26602 !!test
26603 Indented table with an empty td
26604 !! wikitext
26605 {|
26606 |-
26607 |
26608 |foo
26609 |}
26610 !! html
26611 <table>
26612
26613 <tr>
26614 <td>
26615 </td>
26616 <td>foo
26617 </td></tr></table>
26618
26619 !!end
26620
26621 ## We have some newline diffs RT-ing this edge case
26622 ## and it is not important enough -- we seem to be emitting
26623 ## at most 2 newlines after a </tr> and this is unrelated to
26624 ## the issue from T85627 that this is testing.
26625 !!test
26626 Indented table with blank lines in between (T85627)
26627 !! options
26628 parsoid=wt2html
26629 !! wikitext
26630 {|
26631 |foo
26632
26633
26634 |}
26635 !! html
26636 <table>
26637
26638 <tr>
26639 <td>foo
26640 </td></tr></table>
26641
26642 !!end
26643
26644 !!test
26645 Indented block & table
26646 !! wikitext
26647 <div>foo</div>
26648 {|
26649 |foo
26650 |}
26651 !! html/php
26652 <div>foo</div>
26653 <table>
26654 <tr>
26655 <td>foo
26656 </td></tr></table>
26657
26658 !! html/parsoid
26659 <div data-parsoid='{"stx":"html"}'>foo</div>
26660 <table><tbody>
26661 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
26662 </tbody></table>
26663 !!end
26664
26665 !! test
26666 Indent and comment before table row
26667 !! wikitext
26668 {|
26669 <!--hi-->|-
26670 | there
26671 |}
26672 !! html/php
26673 <table>
26674
26675 <tr>
26676 <td> there
26677 </td></tr></table>
26678
26679 !! html/parsoid
26680 <table>
26681 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
26682 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
26683 </tbody></table>
26684 !! end
26685
26686 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
26687 !!test
26688 Empty TR followed by a template-generated TR
26689 !!options
26690 parsoid
26691 !! wikitext
26692 {|
26693 |-
26694 {{echo|<tr><td>foo</td></tr>}}
26695 |}
26696 !! html
26697 <table>
26698 <tbody>
26699 <tr class='mw-empty-elt'></tr>
26700 <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}}]}'>
26701 <td>foo</td></tr>
26702 </tbody></table>
26703 !!end
26704
26705 ## PHP and parsoid output differ for this, and since this is primarily
26706 ## for testing Parsoid's serializer, marking this Parsoid only
26707 !!test
26708 Empty TR followed by mixed-ws-comment line should RT correctly
26709 !!options
26710 parsoid
26711 !! wikitext
26712 {|
26713 |-
26714 <!--c-->
26715 |-
26716 <!--c--> <!--d-->
26717 |}
26718 !! html
26719 <table>
26720 <tbody>
26721 <tr class='mw-empty-elt'></tr>
26722 <!--c-->
26723 <tr>
26724 <!--c--> </tr><!--d-->
26725 </tbody></table>
26726
26727 !!end
26728
26729 !!test
26730 Multi-line image caption generated by templates with/without trailing newlines
26731 !! wikitext
26732 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
26733 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
26734 !! html/parsoid
26735 <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>
26736 <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>
26737 !!end
26738
26739 !! test
26740 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
26741 !! options
26742 parsoid=html2wt
26743 !! html/parsoid
26744 <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>
26745
26746 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
26747 !! wikitext
26748 <includeonly>foo</includeonly>
26749 new para
26750
26751 [[Category:Foo]]
26752
26753 = new heading =
26754 !! end
26755
26756 ## PHP emits broken html for this, and since this is primarily
26757 ## a Parsoid serializer test, marking this Parsoid only
26758 !!test
26759 Improperly nested inline or quotes tags with whitespace in between
26760 !! wikitext
26761 <span> <s>x</span> </s>
26762 ''' ''x''' ''
26763 !! html/parsoid
26764 <p><span> <s>x</s></span><s> </s>
26765 <b> <i>x</i></b><i> </i>
26766 </p>
26767 !!end
26768
26769 !!test
26770 Encapsulate protected attributes from wt
26771 !! wikitext
26772 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
26773
26774 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
26775 | ok
26776 |}
26777 !! html/parsoid
26778 <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>
26779
26780 <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">
26781 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'> ok</td></tr>
26782 </tbody></table>
26783 !!end
26784
26785 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
26786 ## Having nested or stray pre tags results in the attempt to add duplicates,
26787 ## causing an assertion fail. This test tries to prevent that situation.
26788 !!test
26789 Ensure ParagraphWrapper can deal with stray closing pre tags
26790 !!options
26791 parsoid=wt2html
26792 !! wikitext
26793 plain text</pre>
26794 !! html/parsoid
26795 plain text
26796 !!end
26797
26798 !!test
26799 1. Ensure fostered text content is wrapped in element nodes
26800 !!options
26801 parsoid=wt2html
26802 !! wikitext
26803 <table>hi</table><table>ho</table>
26804 !! html/parsoid
26805 <p>hi</p>
26806 <table></table>
26807 <p>ho</p>
26808 <table></table>
26809 !!end
26810
26811 !!test
26812 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
26813 !!options
26814 parsoid=wt2html,wt2wt
26815 !! wikitext
26816 <table>
26817 <tr> || ||
26818 <td> a
26819 </table>
26820 !! html/parsoid
26821 <p> || ||
26822 </p><table>
26823 <tbody><tr><td> a</td></tr>
26824 </tbody></table>
26825 !!end
26826
26827 !!test
26828 Encapsulation properly handles null DSR information from foster box
26829 !!options
26830 parsoid=wt2html,wt2wt
26831 !! wikitext
26832 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
26833 !! html/parsoid
26834 <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>
26835 !!end
26836
26837 !!test
26838 1. Encapsulate foster-parented transclusion content
26839 !!options
26840 parsoid=wt2wt,wt2html
26841 !! wikitext
26842 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
26843 !! html/parsoid
26844 <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>
26845 <tbody>
26846 <tr>
26847 <td>bar</td>
26848 </tr>
26849 </tbody>
26850 </table>
26851 !!end
26852
26853 !!test
26854 2. Encapsulate foster-parented transclusion content
26855 !!options
26856 parsoid=wt2wt,wt2html
26857 !! wikitext
26858 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
26859 !! html/parsoid
26860 <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>
26861 <table>
26862 <tbody>
26863 <tr>
26864 <td>bar</td>
26865 </tr>
26866 </tbody>
26867 </table>
26868 !!end
26869
26870 !!test
26871 3. Encapsulate foster-parented transclusion content
26872 !!options
26873 parsoid=wt2wt,wt2html
26874 !! wikitext
26875 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
26876 !! html/parsoid
26877 <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;]}">
26878 <p>foo</p>
26879 </div>
26880 <table>
26881 <tbody>
26882 <tr>
26883 <td>bar</td>
26884 </tr>
26885 </tbody>
26886 </table>
26887 !!end
26888
26889 !!test
26890 4. Encapsulate foster-parented transclusion content
26891 !!options
26892 parsoid=wt2wt,wt2html
26893 !! wikitext
26894 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
26895 !! html/parsoid
26896 <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;]}">
26897 <p>foo</p>
26898 </div>
26899 <table>
26900 <tbody>
26901 <tr>
26902 <td>bar</td>
26903 </tr>
26904 </tbody>
26905 </table>
26906 !!end
26907
26908 !!test
26909 5. Encapsulate foster-parented transclusion content
26910 !!options
26911 parsoid=wt2wt,wt2html
26912 !! wikitext
26913 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
26914 !! html/parsoid
26915 <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>
26916 <table>
26917 <tbody>
26918 <tr>
26919 <td>
26920 <div>
26921 <p>foo</p>
26922 </div>
26923 </td>
26924 </tr>
26925 </tbody>
26926 </table>
26927 !!end
26928
26929 !!test
26930 6. Encapsulate foster-parented transclusion content
26931 !!options
26932 parsoid=wt2wt,wt2html
26933 !! wikitext
26934 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
26935 !! html/parsoid
26936 <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>
26937 <table>
26938 <tbody>
26939 <tr>
26940 <td>
26941 <div>
26942 <p>foo</p>
26943 </div>
26944 </td>
26945 </tr>
26946 </tbody>
26947 </table>
26948 <p>ok</p>
26949 !!end
26950
26951 !!test
26952 7. Encapsulate foster-parented transclusion content
26953 !!options
26954 parsoid=wt2wt,wt2html
26955 !! wikitext
26956 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
26957 !! html/parsoid
26958 <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>
26959 <table>
26960 <tbody>
26961 <tr>
26962 <td>bar</td>
26963 </tr>
26964 </tbody>
26965 </table>
26966 !!end
26967
26968 # Note that the wt is broken on purpose: the = should be {{=}} if you
26969 # don't want it to be a template parameter key.
26970 !!test
26971 8. Encapsulate foster-parented transclusion content
26972 !!options
26973 parsoid=wt2wt,wt2html
26974 !! wikitext
26975 {{echo|a
26976 }}{|{{echo|style='color:red'}}
26977 |-
26978 |b
26979 |}
26980 !! html/parsoid
26981 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}'>a</p>
26982 <span> </span>
26983 <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>
26984 <table>
26985 <tbody>
26986 <tr>
26987 <td>b</td>
26988 </tr>
26989 </tbody>
26990 </table>
26991 !!end
26992
26993 !!test
26994 9. Encapsulate foster-parented transclusion content
26995 !!options
26996 parsoid=wt2wt,wt2html
26997 !! wikitext
26998 <table>{{echo|hi</table>hello}}
26999 !! html/parsoid
27000 <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>
27001 !!end
27002
27003 !!test
27004 Table in fosterable position
27005 !!options
27006 parsoid=wt2html
27007 !! wikitext
27008 {{OpenTable}}
27009 <div>
27010 {|
27011 |}
27012 </div>
27013 |}
27014 !! html/parsoid
27015 <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">
27016 </span>
27017 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
27018
27019 <table>
27020 </table>
27021 !!end
27022
27023 # Parsoid only for T66747
27024 !! test
27025 Properly encapsulate empty-content transclusions in fosterable positions
27026 !! wikitext
27027 <table>
27028 {{#if:|
27029 <td>foo</td>
27030 }}
27031 </table>
27032 !! html/parsoid
27033 <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"}]]}'>
27034
27035 </table>
27036 !! end
27037
27038 !! test
27039 Always encapsulate foster box when template range is expanded to table
27040 !! options
27041 parsoid=wt2wt
27042 !! wikitext
27043 {|
27044 hello
27045 {{OpenTable}}
27046 |}
27047 !! html/parsoid
27048
27049 !! end
27050
27051 !! test
27052 T115289: Unclosed table
27053 !! wikitext
27054 {{echo|<table>}}<!--c-->[[Category:Two]]
27055 !! html/parsoid
27056 <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>
27057 !! end
27058
27059 !! test
27060 T115289: Don't migrate newlines out of tables with fostered content
27061 !! wikitext
27062 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
27063 !! html/parsoid
27064 <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>
27065 !! end
27066
27067 !! test
27068 T73074: More fostering fun
27069 !! wikitext
27070 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
27071 !! html/parsoid
27072 <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>
27073 !! end
27074
27075 !!test
27076 Support <object> element with .data attribute
27077 !!options
27078 parsoid=html2wt
27079 !! html/parsoid
27080 <object data="test.swf"></object>
27081 !! wikitext
27082 <object data="test.swf"></object>
27083 !!end
27084
27085 !! test
27086 Don't block XML namespace declaration
27087 !! wikitext
27088 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27089 !! html/php
27090 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
27091 </p>
27092 !! html/parsoid
27093 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
27094 !! end
27095
27096 # -----------------------------------------------------------------
27097 # The following section of tests are primarily to spec requirements
27098 # around Parsoid's serialization (old, new, edited content)
27099 #
27100 # All these tests are marked Parsoid html2wt and html2html only
27101 # ----------------------------------------------------------------
27102
27103 !! test
27104 Ignore rel attribute in a-tags during serialization to url-links
27105 !! options
27106 parsoid=html2wt
27107 !! html/parsoid
27108 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
27109 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
27110 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
27111 !! wikitext
27112 http://en.wikipedia.org/wiki/Foobar
27113 http://en.wikipedia.org/wiki/Foobar
27114 http://en.wikipedia.org/wiki/Foobar
27115 !! end
27116
27117 # 'mi' is a localinterwiki prefix as well as a language
27118 !! test
27119 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
27120 !! options
27121 parsoid=html2wt
27122 !! html/parsoid
27123 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
27124 !! wikitext
27125 [[Foo]]
27126 !! end
27127
27128 !! test
27129 Parsoid should accept interwiki shortcuts
27130 !! options
27131 parsoid=html2wt
27132 !! html/parsoid
27133 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
27134 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
27135 <a href='./fr:Foo'>Foo</a></p>
27136 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
27137 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
27138 <a href='fr%3AFoo'>Foo</a></p>
27139 <p><a href='FR%3AFoo'>Foo</a>
27140 <a href='./FR:Foo'>Foo</a></p>
27141 !! wikitext
27142 [[:fr:Foo|Foo]]
27143 [[:fr:Foo|Foo]]
27144 [[:fr:Foo|Foo]]
27145
27146 [[:fr:Foo|Foo]]
27147 [[:fr:Foo|Foo]]
27148 [[:fr:Foo|Foo]]
27149
27150 [[:fr:Foo|Foo]]
27151 [[:fr:Foo|Foo]]
27152 !! end
27153
27154 !! test
27155 Parsoid should not accept invalid interwiki shortcuts
27156 !! options
27157 parsoid=html2wt
27158 !! html/parsoid
27159 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
27160 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
27161 <a href='news:Foo'>Foo</a></p>
27162 !! wikitext
27163 [news:Foo Foo]
27164 [news:Foo Foo]
27165 [news:Foo Foo]
27166 !! end
27167
27168 # See T93839
27169 !! test
27170 New wikilinks should be serialized properly
27171 !! options
27172 parsoid=html2wt
27173 !! html/parsoid
27174 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
27175 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
27176 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
27177 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
27178 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
27179 !! wikitext
27180 [[Foo]]
27181 [[Foo]]
27182 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
27183 http://en.wikipedia.org/wiki/Foo
27184 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
27185 !! end
27186
27187 !! test
27188 New wiki links (href variations)
27189 !! options
27190 parsoid=html2wt
27191 !! html/parsoid
27192 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27193 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
27194 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
27195 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
27196 !! wikitext
27197 [[Foo_bar]]
27198 [[Foo_bar]]
27199 [[Foo_bar]]
27200 [[Toxine bactérienne]]
27201 !! end
27202
27203 !! test
27204 New wiki links (content string variations)
27205 !! options
27206 parsoid=html2wt
27207 !! html/parsoid
27208 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
27209 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
27210 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
27211 !! wikitext
27212 [[Foo_bar]]
27213 [[Foo bar]]
27214 [[Foo_bar|./Foo_bar]]
27215 !! end
27216
27217 !! test
27218 New category links (href variations)
27219 !! options
27220 parsoid=html2wt
27221 !! html/parsoid
27222 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
27223 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
27224 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
27225 !! wikitext
27226 [[Category:Toxine bactérienne]]
27227 [[Category:Toxine bactérienne]]
27228 [[Category:Toxine bactérienne]]
27229 !! end
27230
27231 !! test
27232 New sol transparent links don't need indent-pre nowiki protection
27233 !! options
27234 parsoid=html2wt
27235 language=de
27236 !! html/parsoid
27237 <link rel="mw:PageProp/redirect" href="./Main_Page">
27238 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
27239 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
27240 !! wikitext
27241 #WEITERLEITUNG [[Main Page]]
27242 <!-- this is good --> [[Category:Good]]
27243 <!-- this is great --> [[Kategorie:Great]]
27244 !! end
27245
27246 !! test
27247 New interlanguage links (href variations)
27248 !! options
27249 parsoid=html2wt
27250 !! html/parsoid
27251 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
27252 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
27253 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
27254 !! wikitext
27255 [[es:Toxine bactérienne]]
27256 [[es:Toxine_bactérienne]]
27257 [[es:Toxine_bactérienne]]
27258 !! end
27259
27260 !! test
27261 Image: Modifying size of an image (1)
27262 !! options
27263 parsoid={
27264 "modes": ["wt2wt"],
27265 "changes": [
27266 ["img[height]", "attr", "height", "22"],
27267 ["img[width]", "attr", "width", "200"]
27268 ]
27269 }
27270 !! wikitext
27271 [[Image:Foobar.jpg|230x230px]]
27272 !! wikitext/edited
27273 [[Image:Foobar.jpg|200x200px]]
27274 !!end
27275
27276 !! test
27277 Image: Modifying size of an image (2)
27278 !! options
27279 parsoid={
27280 "modes": ["wt2wt"],
27281 "changes": [
27282 ["img[height]", "attr", "height", "100"],
27283 ["img[width]", "attr", "width", "500"]
27284 ]
27285 }
27286 !! wikitext
27287 [[Image:Foobar.jpg|230x230px]]
27288 !! wikitext/edited
27289 [[Image:Foobar.jpg|500x500px]]
27290 !!end
27291
27292 # Change in size is ignored so long as class='mw-default-size'
27293 !! test
27294 Image: Modifying size of an image (3)
27295 !! options
27296 parsoid={
27297 "modes": ["wt2wt"],
27298 "changes": [
27299 ["figure[class]", "removeClass", "mw-default-size"],
27300 ["figure img", "attr", "height", "19"],
27301 ["figure img", "attr", "width", "170"]
27302 ]
27303 }
27304 !! wikitext
27305 [[Image:Foobar.jpg|thumb]]
27306 !! wikitext/edited
27307 [[Image:Foobar.jpg|thumb|170x170px]]
27308 !!end
27309
27310 !! test
27311 Image: Modifying alignment of an image (T50665)
27312 !! options
27313 parsoid={
27314 "modes": ["wt2wt"],
27315 "changes": [
27316 ["figure[class]", "removeClass", "mw-halign-right"],
27317 ["figure[class]", "addClass", "mw-halign-left"]
27318 ]
27319 }
27320 !! wikitext
27321 [[Image:Foobar.jpg|thumb|caption|right]]
27322 !! wikitext/edited
27323 [[Image:Foobar.jpg|thumb|caption|left]]
27324 !! end
27325
27326 !! test
27327 Image: Modifying mw-default-size of an frameless image (T64805)
27328 !! options
27329 parsoid={
27330 "modes": ["wt2wt"],
27331 "changes": [
27332 ["figure.mw-default-size", "removeClass", "mw-default-size"]
27333 ]
27334 }
27335 !! wikitext
27336 [[Image:Foobar.jpg|frameless|right]]
27337 !! wikitext/edited
27338 [[Image:Foobar.jpg|frameless|right|220x220px]]
27339 !! end
27340
27341 !! test
27342 Image: Modifying valign of an image (T51221)
27343 !! options
27344 parsoid={
27345 "modes": ["wt2wt"],
27346 "changes": [
27347 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
27348 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
27349 ]
27350 }
27351 !! wikitext
27352 [[File:Foobar.jpg|20px|middle]]
27353 !! wikitext/edited
27354 [[File:Foobar.jpg|20px|text-top]]
27355 !! end
27356
27357 !! test
27358 Image: Modifying alt attribute of an image (T58400)
27359 !! options
27360 parsoid={
27361 "modes": ["wt2wt"],
27362 "changes": [
27363 ["img[alt]", "attr", "alt", "some alternate edited text"]
27364 ]
27365 }
27366 !! wikitext
27367 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
27368 !! wikitext/edited
27369 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
27370 !!end
27371
27372 !! test
27373 Image: Modifying caption of an image
27374 !! options
27375 parsoid={
27376 "modes": ["wt2wt"],
27377 "changes": [
27378 ["figcaption", "text", "new caption"]
27379 ]
27380 }
27381 !! wikitext
27382 [[Image:Foobar.jpg|thumb|original caption]]
27383 !! wikitext/edited
27384 [[Image:Foobar.jpg|thumb|new caption]]
27385 !!end
27386
27387 !! test
27388 Image: empty alt attribute (T50924)
27389 !! options
27390 parsoid
27391 !! wikitext
27392 [[File:Foobar.jpg|thumb|alt=|bar]]
27393 !! html
27394 <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>
27395 !! end
27396
27397 !! test
27398 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
27399 !! options
27400 parsoid=html2wt
27401 language=ar
27402 disabled
27403 !! html/parsoid
27404 <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>
27405 !! wikitext
27406 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
27407 !! end
27408
27409 !! test
27410 Image: Block level image should have \n before and after
27411 !! wikitext
27412 123
27413 [[File:Foobar.jpg|right|thumb|150x150px]]
27414 456
27415 !! html/parsoid
27416 <p>123</p>
27417 <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>
27418 <p>456</p>
27419 !! end
27420
27421 !! test
27422 Image: New block level image should have \n before and after (existing content)
27423 !! wikitext
27424 123
27425 [[File:Foobar.jpg|right|thumb|150x150px]]
27426 456
27427 !! html/parsoid
27428 <p>123</p>
27429 <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>
27430 <p>456</p>
27431 !! end
27432
27433 !! test
27434 Image: upright option (parsoid)
27435 !! wikitext
27436 [[File:Foobar.jpg|thumb|upright|caption]]
27437 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
27438 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
27439 !! html/parsoid
27440 <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>
27441 <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>
27442 <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>
27443 !! end
27444
27445 !! test
27446 Image: upright option is ignored on inline and frame images (parsoid)
27447 !! wikitext
27448 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
27449 !! html/parsoid
27450 <p><span 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></span></p>
27451 !! end
27452
27453 !! test
27454 Image: in template parameter with empty parameter
27455 !! wikitext
27456 {{echo|[[File:Foobar.jpg|link=]]}}
27457 !! html/parsoid
27458 <p><span 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></span></p>
27459 !! end
27460
27461 !! test
27462 Image: from basic HTML (1)
27463 !! options
27464 parsoid=html2wt
27465 !! html/parsoid
27466 <span typeof="mw:Image">
27467 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27468 </span>
27469 !! wikitext
27470 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27471 !! end
27472
27473 !! test
27474 Image: from basic HTML (2)
27475 !! options
27476 parsoid=html2wt
27477 !! html/parsoid
27478 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
27479 !! wikitext
27480 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
27481 !! end
27482
27483 !! test
27484 Image: from basic HTML (3)
27485 !! options
27486 parsoid=html2wt
27487 !! html/parsoid
27488 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
27489 !! wikitext
27490 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
27491 !! end
27492
27493 !! test
27494 Image: from basic HTML (4)
27495 !! options
27496 parsoid=html2wt
27497 !! html/parsoid
27498 <img src="./File:Foobar.jpg">
27499 !! wikitext
27500 [[File:Foobar.jpg|link=]]
27501 !! end
27502
27503 !! test
27504 Image: Invalid title as link
27505 !! wikitext
27506 [[File:Foobar.jpg|link=<]]
27507 !! html/php
27508 <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>
27509 </p>
27510 !! html/parsoid
27511 <p><span 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></span></p>
27512 !! end
27513
27514 !! test
27515 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
27516 !! options
27517 parsoid=html2wt
27518 !! html/parsoid
27519 <ul>
27520 <li><p>foo</p></li>
27521 </ul>
27522 !! wikitext
27523 * foo
27524 !! end
27525
27526 !! test
27527 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
27528 !! options
27529 parsoid=html2wt
27530 !! html/parsoid
27531 <ul> <li>foo</li></ul>
27532 !! wikitext
27533 * foo
27534 !! end
27535
27536 !! test
27537 Don't strip leading whitespace when handling indent-pre suppressing tags
27538 !! options
27539 parsoid=html2wt
27540 !! html/parsoid
27541 <table>
27542 <tr><td> indented row</td></tr>
27543 </table>
27544 <blockquote><p>
27545 <b>This is very bold of you!</b>
27546 </p>
27547 <table><tr><td>
27548 indented cell (no pre-wrapping!)
27549 </td></tr></table>
27550 </blockquote>
27551 <p>foo</p>
27552 <div>bar</div>
27553 !! wikitext
27554 {|
27555 | indented row
27556 |}
27557 <blockquote>
27558 '''This is very bold of you!'''
27559
27560 {|
27561 |
27562 indented cell (no pre-wrapping!)
27563 |}
27564 </blockquote>
27565 foo
27566 <div>bar</div>
27567 !! end
27568
27569 !! test
27570 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
27571 !! options
27572 parsoid=html2wt
27573 !! html/parsoid
27574 <p>foo</p>
27575 <span>bar</span>
27576
27577 <span>foo2
27578 </span>bar2
27579
27580 <div>foo</div>
27581 <span>bar</span>
27582
27583 <div>
27584 <span>foo</span>
27585 </div>
27586 !! wikitext
27587 foo
27588
27589 <span>bar</span>
27590
27591 <span>foo2
27592 <nowiki> </nowiki></span>bar2
27593
27594 <div>foo</div>
27595 <nowiki> </nowiki><span>bar</span>
27596
27597 <div>
27598 <nowiki> </nowiki><span>foo</span>
27599 </div>
27600 !! end
27601
27602 !! test
27603 Lists: Dont insert newlines in a serialized list item.
27604 !! options
27605 parsoid=html2wt
27606 !! html/parsoid
27607 <ul><li>a<br>b</li><li>c</li></ul>
27608 !! wikitext
27609 * a<br>b
27610 * c
27611 !! end
27612
27613 !! test
27614 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
27615 !! options
27616 parsoid={
27617 "modes": ["html2wt"],
27618 "scrubWikitext": false
27619 }
27620 !! html/parsoid
27621 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
27622 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
27623
27624 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
27625 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
27626
27627 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
27628
27629 <h2><meta property="mw:PageProp/toc" /> ok</h2>
27630 !! wikitext
27631 == hello there [[Category:A1]] ==
27632
27633 == [[Category:A2]] hi pal ==
27634
27635 == <!--foo--> [[Category:A3]] how goes it ==
27636
27637 == it goes well [[Category:A4]] <!--bar--> ==
27638
27639 ==howdy [[Category:A5]]==
27640
27641 == __TOC__ ok ==
27642 !! end
27643
27644 !! test
27645 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
27646 !! options
27647 parsoid={
27648 "modes": ["html2wt"],
27649 "scrubWikitext": true
27650 }
27651 !! html/parsoid
27652 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
27653 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
27654
27655 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
27656 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
27657
27658 <h2><meta property="mw:PageProp/toc" /> ok</h2>
27659 !! wikitext
27660 == hello there ==
27661 [[Category:A1]]
27662 [[Category:A2]]
27663
27664 == hi pal ==
27665
27666 <!--foo--> [[Category:A3]]
27667
27668 == how goes it ==
27669
27670 == it goes well ==
27671 [[Category:A4]] <!--bar-->
27672
27673 __TOC__
27674
27675 == ok ==
27676 !! end
27677
27678 !! test
27679 Headings: Don't hoist metas that come from templates
27680 !! options
27681 parsoid={
27682 "modes": ["html2wt"],
27683 "scrubWikitext": true
27684 }
27685 !! html/parsoid
27686 <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>
27687 !! wikitext
27688 == {{echo|foo [[Category:Foo]]}} ==
27689 !! end
27690
27691 !! test
27692 Headings: Category in ref isn't hoisted
27693 !! options
27694 parsoid={
27695 "modes": ["html2wt"],
27696 "scrubWikitext": true
27697 }
27698 !! html/parsoid
27699 <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>
27700
27701 <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>
27702 !! wikitext
27703 == foo <ref>bar
27704 [[Category:Baz]] </ref> ==
27705
27706 <references />
27707 !! end
27708
27709 !! test
27710 Parsoid: Serialize positional parameters with = in them as named parameter
27711 !! options
27712 parsoid=html2wt
27713 !! html/parsoid
27714 <p about="#mwt1" typeof="mw:Transclusion"
27715 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
27716
27717 <p about="#mwt1" typeof="mw:Transclusion"
27718 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
27719
27720 <!--Orig params with data-parsoid has heuristics for handling = chars-->
27721 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
27722 <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>
27723 !! wikitext
27724 {{echo|1=f=oo}}
27725
27726 {{echo|1=f=oo|2=bar}}
27727
27728 <!--Orig params with data-parsoid has heuristics for handling = chars-->
27729 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
27730 {{echo|<nowiki>f=oo</nowiki>|bar}}
27731 !! end
27732
27733 !! test
27734 Parsoid: Serialize positional parameters with = in extlink as named parameter
27735 !! options
27736 parsoid=html2wt
27737 !! html/parsoid
27738 <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>
27739 !! wikitext
27740 {{echo|1=http://stuff?is=ok}}
27741 !! end
27742
27743 !! test
27744 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
27745 !! options
27746 parsoid=html2wt
27747 !! html/parsoid
27748 <div>a<p>b</p></div>
27749 <div>a
27750 <p>b</p></div>
27751 <div>
27752 a
27753 <p>b</p></div>
27754 !! wikitext
27755 <div>a
27756 b
27757 </div>
27758 <div>a
27759 b
27760 </div>
27761 <div>
27762 a
27763
27764 b
27765 </div>
27766 !! end
27767
27768 !! test
27769 Substrings resembling wikitext in hrefs should not get nowiki escapes
27770 !! options
27771 parsoid=html2wt
27772 !! html/parsoid
27773 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
27774 !! wikitext
27775 [[Foo''bar''baz]]
27776 !! end
27777
27778 !! test
27779 Enforce single-line context in the serializer
27780 !! options
27781 parsoid=html2wt
27782 !! html/parsoid
27783 <h2>testing
27784 123</h2>
27785
27786 <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">
27787 </span><span about="#mwt1">you</span> </h2>
27788
27789 <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>
27790
27791 <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
27792 there</span></li></ol>
27793
27794 <ul><li>asd
27795 sdf</li></ul>
27796
27797 <ul><li>foo
27798 bar
27799 baz</li>
27800 <li>foo <b>bar</b>
27801 baz</li></ul>
27802
27803 <dl><dt>hi
27804 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
27805 ho</dd></dl>
27806
27807 <dl><dd> <table>
27808 <tbody><tr><td> ha
27809 ha
27810 ha</td></tr>
27811 </tbody></table></dd></dl>
27812 !! wikitext
27813 == testing 123 ==
27814
27815 == hi {{bogus|there
27816 you}} ==
27817
27818 == foo <ref>hello
27819 there</ref> ==
27820
27821 <references />
27822
27823 * asd sdf
27824
27825 * foo bar baz
27826 * foo '''bar''' baz
27827
27828 ; hi ho : hi ho
27829
27830 : {|
27831 | ha
27832 ha
27833 ha
27834 |}
27835 !! end
27836
27837 !! test
27838 Serialize new placeholder space without spans
27839 !! options
27840 parsoid=html2wt
27841 !! html/parsoid
27842 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
27843
27844 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
27845
27846 <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>
27847 !! wikitext
27848 foo : bar
27849
27850 foo : bar
27851
27852 <ref>foo : bar</ref>ok
27853 !! end
27854
27855
27856 #-----------------------
27857 # Tag minimization tests
27858 #-----------------------
27859
27860 !! test
27861 1. I/B quote minimization: wikitext-only tags should be combined
27862 !! options
27863 parsoid=html2wt
27864 !! html/parsoid
27865 <p><i>A</i><i>B</i></p>
27866 <p><b>A</b><b>B</b></p>
27867 <p><i>A</i><b><i>B</i></b></p>
27868 <p><b>A</b><i><b>B</b></i></p>
27869 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
27870 <p><i><b>A</b></i><i><b>B</b></i></p>
27871 <p><i><b>A</b></i><b><i>B</i></b></p>
27872 <p><b><i>A</i></b><i><b>B</b></i></p>
27873 !! wikitext
27874 ''AB''
27875
27876 '''AB'''
27877
27878 ''A'''B'''''
27879
27880 '''A''B'''''
27881
27882 '''A''BC''D'''
27883
27884 '''''AB'''''
27885
27886 '''''AB'''''
27887
27888 '''''AB'''''
27889 !! end
27890
27891 !! test
27892 2. I/B quote minimization: wikitext and html tags should not be combined
27893 !! options
27894 parsoid=html2wt
27895 !! html/parsoid
27896 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
27897 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
27898 !! wikitext
27899 ''A''<i>B</i>
27900
27901 ''A''<nowiki/>'''<i>B</i>'''
27902 !! end
27903
27904 !! test
27905 3. I/B quote minimization: templated content stops minimization
27906 !! options
27907 parsoid=html2wt
27908 !! html/parsoid
27909 <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>
27910 <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>
27911 !! wikitext
27912 ''A''{{echo|''B''}}
27913
27914 ''A''{{echo|'''''B'''''}}
27915 !! end
27916
27917 !! test
27918 4. I/B quote minimization: new content should be mimimized with adjacent old content
27919 !! options
27920 parsoid=html2wt
27921 !! html/parsoid
27922 <p><i>A</i><i>B</i></p>
27923 <p><b>A</b><b>B</b></p>
27924 <p><i>A</i><b><i>B</i></b></p>
27925 !! wikitext
27926 ''AB''
27927
27928 '''AB'''
27929
27930 ''A'''B'''''
27931 !! end
27932
27933 !! test
27934 5a. Merge adjacent quote nodes if they've been edited
27935 !! options
27936 parsoid={
27937 "modes": ["wt2wt", "selser"],
27938 "changes": [
27939 ["p", "contents", "remove", ":contains('b')"]
27940 ]
27941 }
27942 !! wikitext
27943 ''a''b''c''
27944 !! wikitext/edited
27945 ''ac''
27946 !! end
27947
27948 !! test
27949 5b. Merge adjacent quote nodes if they've been edited
27950 !! options
27951 parsoid={
27952 "modes": ["wt2wt", "selser"],
27953 "changes": [
27954 ["#x", "remove"]
27955 ]
27956 }
27957 !! wikitext
27958 ''a''<span id="x">b</span>''c''
27959 !! wikitext/edited
27960 ''ac''
27961 !! end
27962
27963 !! test
27964 1. Merge adjacent link nodes as long as at least one element is new
27965 !! options
27966 parsoid={
27967 "modes": ["html2wt"],
27968 "scrubWikitext": true
27969 }
27970 !! html/parsoid
27971 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
27972 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
27973 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
27974 !! wikitext
27975 [[Football]]
27976 [[Football]]
27977 [[Football|Foot]][[Football|ball]]
27978 !! end
27979
27980 !! test
27981 2. Merge adjacent link nodes and enable additional normalizations
27982 !! options
27983 parsoid={
27984 "modes": ["html2wt"],
27985 "scrubWikitext": true
27986 }
27987 !! html/parsoid
27988 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
27989 !! wikitext
27990 [[Football|''Football'']]
27991 !! end
27992
27993 !! test
27994 3. Don't merge adjacent link nodes if scrubWikitext is false
27995 !! options
27996 parsoid={
27997 "modes": ["html2wt"],
27998 "scrubWikitext": false
27999 }
28000 !! html/parsoid
28001 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
28002 !! wikitext
28003 [[Football|Foot]][[Football|ball]]
28004 !! end
28005
28006 #------------------------------
28007 # End of tag minimization tests
28008 #------------------------------
28009
28010 !!test
28011 T56262: New entities
28012 !! options
28013 parsoid=html2wt
28014 !! html/parsoid
28015 <span typeof="mw:Entity">&nbsp;</span>
28016 !! wikitext
28017 &nbsp;
28018 !! end
28019
28020 ## Note that there is no wikitext output for 'unknownproperty' ##
28021 ## Unknown magic words are silently dropped ##
28022
28023 !! test
28024 Magic words
28025 !! options
28026 parsoid=html2wt
28027 !! html/parsoid
28028 <meta property='mw:PageProp/toc' />
28029 <meta property='mw:PageProp/notoc' />
28030 <meta property='mw:PageProp/forcetoc' />
28031 <meta property='mw:PageProp/index' />
28032 <meta property='mw:PageProp/noindex' />
28033 <meta property='mw:PageProp/nogallery' />
28034 <meta property='mw:PageProp/noeditsection' />
28035 <meta property='mw:PageProp/notitleconvert' />
28036 <meta property='mw:PageProp/nocontentconvert' />
28037 <meta property='mw:PageProp/unknownproperty' />
28038 !! wikitext
28039 __TOC__
28040 __NOTOC__
28041 __FORCETOC__
28042 __INDEX__
28043 __NOINDEX__
28044 __NOGALLERY__
28045 __NOEDITSECTION__
28046 __NOTITLECONVERT__
28047 __NOCONTENTCONVERT__
28048 !! end
28049
28050 !! test
28051 Consecutive <pre>s should not get merged
28052 !! options
28053 parsoid=html2wt,html2html
28054 !! html/parsoid
28055 <pre>a</pre><pre>b</pre>
28056
28057 <pre>c
28058 </pre><pre>
28059 d</pre>
28060
28061 <pre>e
28062
28063 </pre><pre>
28064
28065 f</pre>
28066 !! wikitext
28067 a
28068
28069 b
28070
28071 c
28072
28073 d
28074
28075 e
28076
28077
28078
28079 f
28080 !! end
28081
28082 !! test
28083 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
28084 !! options
28085 parsoid=html2wt
28086 !! html/parsoid
28087 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
28088 !! wikitext
28089 [[Special:BookSources/1234567890|ISBN 1234567895]]
28090 !! end
28091
28092 !! test
28093 Edited RFC links not serializable as RFC links should serialize as extlinks
28094 !! options
28095 parsoid=html2wt
28096 !! html/parsoid
28097 <a href="https://tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
28098 !! wikitext
28099 [https://tools.ietf.org/html/rfc123 New RFC]
28100 !! end
28101
28102 !! test
28103 Edited PMID links not serializable as PMID links should serialize as extlinks
28104 !! options
28105 parsoid=html2wt
28106 !! html/parsoid
28107 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
28108 !! wikitext
28109 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
28110 !! end
28111
28112 !! test
28113 WTS of autolinks with trailing/surrounding context
28114 !! options
28115 parsoid=html2wt
28116 !! html/parsoid
28117 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
28118 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
28119 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
28120 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
28121 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
28122 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
28123 !! wikitext
28124 http://cscott.net'''foo'''
28125
28126 http://cscott.net<b>foo</b>
28127
28128 '''http://cscott.net'''
28129
28130 '''http://cscott.net '''
28131
28132 '''http://cscott.net<nowiki/>x'''
28133
28134 http://cscott.net<nowiki/>x
28135 !! end
28136
28137 !! test
28138 WTS of autolinks with nowikis (round-trip)
28139 !! wikitext
28140 x<nowiki/>http://cscott.net<nowiki/>x
28141 !! html/parsoid
28142 <p>x<a rel="mw:ExtLink" href="http://cscott.net">http://cscott.net</a>x</p>
28143 !! end
28144
28145 # this is the "easy" test because it leaves in place all the
28146 # data-parsoid information indicating this is an autolink
28147 !! test
28148 WTS of autolinks with escapes (editing)
28149 !! options
28150 parsoid={
28151 "modes": ["wt2wt"],
28152 "changes": [
28153 [ "span", "remove" ]
28154 ]
28155 }
28156 !! wikitext
28157 x<nowiki/>http://cscott.net<nowiki/>x
28158 !! wikitext/edited
28159 x<nowiki/>http://cscott.net<nowiki/>x
28160 !! end
28161
28162 !! test
28163 WTS of edited autolink-like text (T103364)
28164 !! options
28165 parsoid={
28166 "modes": ["wt2wt"],
28167 "changes": [
28168 [ "span[typeof]", "removeAttr", "typeof" ]
28169 ]
28170 }
28171 !! wikitext
28172 Not a link: <nowiki>http://example.com</nowiki>.
28173 !! wikitext/edited
28174 Not a link: <span><nowiki>http://example.com</nowiki></span>.
28175 !! end
28176
28177 !! test
28178 WTS of newly-authored autolink-like text (T103364)
28179 !! options
28180 parsoid=html2wt
28181 !! html/parsoid
28182 <p>http://example.com is not a link.</p>
28183 !! wikitext
28184 <nowiki>http://example.com</nowiki> is not a link.
28185 !! end
28186
28187 !! test
28188 WTS of autolink-like text after an autolink (T108563)
28189 !! options
28190 parsoid=html2wt
28191 !! html/parsoid
28192 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
28193 !! wikitext
28194 http://example.com <nowiki>http://example.com</nowiki> is not a link.
28195 !! end
28196
28197 !! test
28198 Magic links inside links (not autolinked)
28199 !! wikitext
28200 [[Foo|http://example.com]]
28201 [[Foo|RFC 1234]]
28202 [[Foo|PMID 1234]]
28203 [[Foo|ISBN 123456789x]]
28204
28205 [http://foo.com http://example.com]
28206 [http://foo.com RFC 1234]
28207 [http://foo.com PMID 1234]
28208 [http://foo.com ISBN 123456789x]
28209 !! html+tidy
28210 <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>
28211 <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>
28212 !! html/parsoid
28213 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
28214 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
28215 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
28216 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
28217
28218 <p><a rel="mw:ExtLink" href="http://foo.com">http://example.com</a>
28219 <a rel="mw:ExtLink" href="http://foo.com">RFC 1234</a>
28220 <a rel="mw:ExtLink" href="http://foo.com">PMID 1234</a>
28221 <a rel="mw:ExtLink" href="http://foo.com">ISBN 123456789x</a></p>
28222 !! end
28223
28224 !! test
28225 Magic links inside image captions (autolinked)
28226 !! wikitext
28227 [[File:Foobar.jpg|thumb|http://example.com]]
28228 [[File:Foobar.jpg|thumb|RFC 1234]]
28229 [[File:Foobar.jpg|thumb|PMID 1234]]
28230 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
28231 !! html+tidy
28232 <div class="thumb tright">
28233 <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>
28234 <div class="thumbcaption">
28235 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28236 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div>
28237 </div>
28238 </div>
28239 <div class="thumb tright">
28240 <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>
28241 <div class="thumbcaption">
28242 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28243 <a class="external mw-magiclink-rfc" rel="nofollow" href="https://tools.ietf.org/html/rfc1234">RFC 1234</a></div>
28244 </div>
28245 </div>
28246 <div class="thumb tright">
28247 <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>
28248 <div class="thumbcaption">
28249 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28250 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a></div>
28251 </div>
28252 </div>
28253 <div class="thumb tright">
28254 <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>
28255 <div class="thumbcaption">
28256 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
28257 <a href="/wiki/Special:BookSources/123456789X" class="internal mw-magiclink-isbn">ISBN 123456789x</a></div>
28258 </div>
28259 </div>
28260 !! html/parsoid
28261 <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>
28262 <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>
28263 <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>
28264 <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>
28265 !! end
28266
28267 !! test
28268 WTS of magic word text (T109371)
28269 !! options
28270 parsoid=html2wt
28271 !! html/parsoid
28272 <p>RFC 1234</p>
28273 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
28274 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
28275 !! wikitext
28276 <nowiki>RFC 1234</nowiki>
28277
28278 [http://foo.com RFC 1234]
28279
28280 [[Foo|RFC 1234]]
28281 !! end
28282
28283 !! test
28284 Edited Redirect link should emit a non-piped wikitext link
28285 !! options
28286 parsoid=html2wt
28287 !! html/parsoid
28288 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
28289 !! wikitext
28290 #REDIRECT [[Bar]]
28291 !! end
28292
28293 !! test
28294 T75121: Infer extension name from typeOf if data-mw is not present
28295 !! options
28296 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28297 !! html/parsoid
28298 <div typeOf="mw:Extension/foo"></div>
28299 !! wikitext
28300 <foo />
28301 !! end
28302
28303 # Note that the <p> wrapping isn't present in PHP parser output
28304 # The important thing for this test is that P-wrapping doesn't
28305 # interfere with the <nowiki> protection for leading - in <td>
28306 # (which isn't necessary for <th>).
28307 !! test
28308 T88318: p-wrapped dash in table.
28309 !! options
28310 parsoid=html2wt,wt2wt
28311 !! html/parsoid
28312 <table><tbody>
28313 <tr><th><p>-</p></th><th><p>- </p></th></tr>
28314 <tr><td><p>-</p></td><td><p>- </p></td></tr>
28315 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
28316 </tbody></table>
28317 !! wikitext
28318 {|
28319 !-
28320 !-
28321 |-
28322 |<nowiki>-</nowiki>
28323 |<nowiki>- </nowiki>
28324 |-
28325 |<small>-</small>
28326 |<br>
28327 -
28328 |<br>
28329 -
28330 |}
28331 !! html/php+tidy
28332 <table>
28333 <tr>
28334 <th>-</th>
28335 <th>-</th>
28336 </tr>
28337 <tr>
28338 <td>-</td>
28339 <td>-</td>
28340 </tr>
28341 <tr>
28342 <td><small>-</small></td>
28343 <td><br />
28344 <p>-</p>
28345 </td>
28346 <td><br />
28347 <p>-</p>
28348 </td>
28349 </tr>
28350 </table>
28351 !! end
28352
28353 !! test
28354 T149209: WTS: Handle newlines in table cells properly
28355 !! options
28356 parsoid=html2wt
28357 !! html/parsoid
28358 <table>
28359 <tbody>
28360 <tr><td>a
28361 b
28362 </td><td data-parsoid='{"stx":"row"}'>c</td></tr>
28363 <tr><td><p>x</p>
28364 </td><td data-parsoid='{"stx":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
28365 </tbody></table>
28366 <table>
28367 <tbody>
28368 <tr><th>a
28369 b
28370 </th><th data-parsoid='{"stx":"row"}'>c</th></tr>
28371 <tr><th><p>x</h>
28372 </th><th data-parsoid='{"stx":"row"}'>y</th></tr>
28373 </tbody></table>
28374 !! wikitext
28375 {|
28376 |a
28377 b
28378 |c
28379 |-
28380 |x
28381 {{!}}y
28382 |}
28383 {|
28384 !a
28385 b
28386 !c
28387 |-
28388 !x
28389 !y
28390 |}
28391 !! end
28392
28393 !! test
28394 T149209: Selser: Handle newlines in table cells properly
28395 !! options
28396 parsoid={
28397 "modes": ["selser"],
28398 "changes": [
28399 [ "#h1", "html", "a\nb\n" ],
28400 [ "#h2", "html", "a\nb\n" ],
28401 [ "#c1", "html", "a\nb\n" ],
28402 [ "#c2", "html", "<p>a</p>" ],
28403 [ "#c3", "html", "<p>a</p>" ],
28404 [ "#c4", "html", "edit-me<p>a</p>" ]
28405 ]
28406 }
28407 !! wikitext
28408 {|
28409 ! id="h1" |edit-me!!1
28410 |-
28411 ! id="h2" |edit-me||2
28412 |-
28413 | id="c1" |edit-me||3
28414 |-
28415 | id="c2" |edit-me||4
28416 |-
28417 | id="c3" |edit-me||p||q||r
28418 |-
28419 | id="c4" |edit-me||p||q||r
28420 |}
28421 !! wikitext/edited
28422 {|
28423 ! id="h1" |a
28424 b
28425 !1
28426 |-
28427 ! id="h2" |a
28428 b
28429 !2
28430 |-
28431 | id="c1" |a
28432 b
28433 |3
28434 |-
28435 | id="c2" |a
28436 |4
28437 |-
28438 | id="c3" |a
28439 |p||q||r
28440 |-
28441 | id="c4" |edit-me
28442 a
28443 |p||q||r
28444 |}
28445 !! end
28446
28447 !! test
28448 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
28449 !! options
28450 parsoid=html2wt
28451 !! html/parsoid
28452 <table id='mwAb'>
28453 <td id='mwAc'>foo</td>
28454 <td id='serialize-this'>bar</td>
28455 </table>
28456 !! wikitext
28457 {|
28458 |foo
28459 | id="serialize-this" |bar
28460 |}
28461 !! end
28462
28463 !! test
28464 Parsoid-like element ids should not be serialized to wikitext unless shadowed
28465 !! options
28466 parsoid=html2wt
28467 !! html/parsoid
28468 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
28469 !! wikitext
28470 <div id="hello">ok</div>
28471 !! end
28472
28473 !! test
28474 WTS change modes
28475 !! options
28476 parsoid={
28477 "modes": ["wt2wt"],
28478 "changes": [
28479 [ "#xyz", "before", "<b>before</b> stuff " ],
28480 [ "#xyz", "after", " stuff <i>after</i>" ],
28481 [ "#xyz", "html", "x <b>y</b> z" ]
28482 ]
28483 }
28484 !! wikitext
28485 <span id="xyz">hello</span>
28486 !! wikitext/edited
28487 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
28488 !! end
28489
28490 !! test
28491 Never serialize a-tag as html, regardless of what data-parsoid has to say
28492 !! options
28493 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28494 !! html/parsoid
28495 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
28496 !! wikitext
28497 [[Foo]]
28498 !! end
28499
28500 ## SSS FIXME: This is broken output nevertheless.
28501 ## What might be a reasonable non-broken output for this?
28502 ## This is an edge case unlikely to be seen in production
28503 ## that I am not wasting more time on this right now.
28504 !! test
28505 Never serialize a-tag as html, no matter what attributes it has
28506 !! options
28507 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28508 !! html/parsoid
28509 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
28510 !! wikitext
28511 [http://boo.org http://boohoo.org]
28512 !! end
28513
28514 # Misnested is an indication that selser can reuse the source but these have
28515 # shown to sneak through on occasion. See T101768.
28516 # The original wikitext here is: [http://test.com [[one]] two three]
28517 !! test
28518 Strip span tags added to mark misnested links
28519 !! options
28520 parsoid=html2wt
28521 !! html/parsoid
28522 <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>
28523 !! wikitext
28524 [http://test.com][[one]] two three
28525 !! end
28526
28527 !! test
28528 Catch regression when unpacking misnested links
28529 !! options
28530 parsoid=wt2html
28531 !! wikitext
28532 {{echo|hi}}[http://example.com [[ho]]]
28533 !! html/parsoid
28534 <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>
28535 !! end
28536
28537 !! test
28538 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
28539 !! options
28540 parsoid=html2wt
28541 !! html/parsoid
28542 <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|}"]}'>
28543 <tbody><tr><td>d
28544 </td></tr>
28545 </tbody></table>
28546 !! wikitext
28547 {{echo|a}}
28548 {|{{echo|c
28549 {{!}}d
28550 }}
28551 |}
28552 !! end
28553
28554 ## This test verifies the presence and computation of this attribute indirectly
28555 ## by making an edit and ensuring that the serialization is correct (which it would be
28556 ## only if firstWikitextNode is properly set).
28557 !! test
28558 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
28559 !! options
28560 parsoid= {
28561 "modes": ["wt2wt"],
28562 "changes": [
28563 [ "div#x", "remove" ],
28564 [ "div", "before", "<div>new</div>" ]
28565 ]
28566 }
28567 !! wikitext
28568 <div id="x">foo</div>
28569 {|
28570 {{echo|<div>boo</div>
28571 {{!}}b}}
28572 |c
28573 |}
28574 !! wikitext/edited
28575
28576 <div>new</div>
28577 {|
28578 {{echo|<div>boo</div>
28579 {{!}}b}}
28580 |c
28581 |}
28582 !! end
28583
28584 # --------------------------------------------
28585 # Tests spec'ing wikitext serialization norms |
28586 # --------------------------------------------
28587
28588 !! test
28589 Serialize multi-line indent-pre starting with wikitext syntax
28590 !! options
28591 parsoid=html2wt
28592 !! html/parsoid
28593 <pre>* 1
28594 ** 2
28595 * 3</pre>
28596 !! wikitext
28597 * 1
28598 ** 2
28599 * 3
28600 !! end
28601
28602 !! test
28603 1. Categories should always be serialized on their own line
28604 !! options
28605 parsoid=html2wt
28606 !! html/parsoid
28607 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
28608 !! wikitext
28609 foo
28610 [[Category:Foo]]
28611 bar
28612 !! end
28613
28614 !! test
28615 2. Categories that are part of templates should not introduce a line break
28616 !! wikitext
28617 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
28618 !! html/parsoid
28619 <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>
28620 !! end
28621
28622 # Careful while editing these next 2 tests. There are \u200f characters
28623 # before and after the <link> tags in the HTML and following some
28624 # of the categories in wikitext
28625 # Do not remove these characters in edits.
28626 #
28627 # As part of the serialization, these bidi characters will get stripped.
28628 !! test
28629 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
28630 !! options
28631 parsoid={
28632 "modes": ["html2wt"],
28633 "scrubWikitext": true
28634 }
28635 !! html/parsoid
28636 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
28637 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
28638 !! wikitext
28639 [[קטגוריה:טקסים]]
28640 [[קטגוריה: שיטות משפט]]
28641 !! end
28642
28643 !! test
28644 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
28645 !! options
28646 parsoid={
28647 "modes": ["html2wt"],
28648 "scrubWikitext": true
28649 }
28650 !! html/parsoid
28651 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
28652 !! wikitext
28653 [[קטגוריה:טקסים]]
28654 ‏y
28655 !! end
28656
28657 !! test
28658 Lists: Add space after bullets
28659 !! options
28660 parsoid=html2wt
28661 !! html/parsoid
28662 <ul>
28663 <li>foo</li>
28664 <li> bar</li>
28665 <li><span> baz</span></li>
28666 </ul>
28667 !! wikitext
28668 * foo
28669 * bar
28670 * <span> baz</span>
28671 !! end
28672
28673 !! test
28674 1. Headings: Add space before/after == (T53744)
28675 !! options
28676 parsoid=html2wt
28677 !! html/parsoid
28678 <h2>foo</h2>
28679 <h2> bar</h2>
28680 <h2>baz </h2>
28681 <h2><span> baz</span></h2>
28682 !! wikitext
28683 == foo ==
28684
28685 == bar ==
28686
28687 == baz ==
28688
28689 == <span> baz</span> ==
28690 !! end
28691
28692 !! test
28693 2. Headings: Add space before/after == even after hoisted content
28694 !! options
28695 parsoid={
28696 "modes": ["html2wt"],
28697 "scrubWikitext": true
28698 }
28699 !! html/parsoid
28700 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
28701 !! wikitext
28702 [[Category:A2]]
28703
28704 == ok ==
28705 !! end
28706
28707 !! test
28708 1. Headings: suppress newly created empty headings
28709 !! options
28710 parsoid={
28711 "modes": ["html2wt"],
28712 "scrubWikitext": true
28713 }
28714 !! html/parsoid
28715 <h2></h2>
28716 !! wikitext
28717 !! end
28718
28719 !! test
28720 2. Headings: don't suppress empty headings if scrubWikitext is false
28721 !! options
28722 parsoid=html2wt
28723 !! html/parsoid
28724 <h2></h2>
28725 !! wikitext
28726 ==<nowiki/>==
28727 !! end
28728
28729 !! test
28730 3. Headings: suppress empty headings on edits
28731 !! options
28732 parsoid={
28733 "modes": ["selser"],
28734 "scrubWikitext": true,
28735 "changes": [
28736 [ "#x", "remove"]
28737 ]
28738 }
28739 !! wikitext
28740 ==<span id="x">foo</span>==
28741 !! wikitext/edited
28742 !! end
28743
28744 !! test
28745 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
28746 !! options
28747 parsoid={
28748 "modes": ["html2wt"],
28749 "scrubWikitext": true
28750 }
28751 !! html/parsoid
28752 <h2>foo<br/>bar</h2>
28753 <h2>foo <span><br/>bar</span> baz</h2>
28754 !! wikitext
28755 == foo bar ==
28756
28757 == foo <span> bar</span> baz ==
28758 !! end
28759
28760 !! test
28761 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
28762 !! options
28763 parsoid={
28764 "modes": ["html2wt"],
28765 "scrubWikitext": false
28766 }
28767 !! html/parsoid
28768 <h2>foo<br/>bar</h2>
28769 !! wikitext
28770 == foo<br> bar ==
28771 !! end
28772
28773 !! test
28774 1. WT Quote Tags: suppress newly created empty style tags
28775 !! options
28776 parsoid={
28777 "modes": ["html2wt"],
28778 "scrubWikitext": true
28779 }
28780 !! html/parsoid
28781 <i></i><b></b>
28782 !! wikitext
28783 !! end
28784
28785 !! test
28786 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
28787 !! options
28788 parsoid=html2wt
28789 !! html/parsoid
28790 <i></i><b></b>
28791 !! wikitext
28792 ''<nowiki/>'''''<nowiki/>'''
28793 !! end
28794
28795 !! test
28796 3. WT Quote Tags: suppress empty style tags on edits
28797 !! options
28798 parsoid={
28799 "modes": ["selser"],
28800 "scrubWikitext": true,
28801 "changes": [
28802 [ "#x", "remove"]
28803 ]
28804 }
28805 !! wikitext
28806 '''<span id="x">foo</span>'''
28807 !! wikitext/edited
28808 !! end
28809
28810 !! test
28811 1. Anchors: suppress newly created empty anchors
28812 !! options
28813 parsoid={
28814 "modes": ["html2wt"],
28815 "scrubWikitext": true
28816 }
28817 !! html/parsoid
28818 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
28819 !! wikitext
28820 !! end
28821
28822 !! test
28823 2. Anchors: don't suppress empty anchors if scrubWikitext is false
28824 !! options
28825 parsoid={
28826 "modes": ["html2wt"],
28827 "scrubWikitext": false
28828 }
28829 !! html/parsoid
28830 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
28831 !! wikitext
28832 [[Test|<nowiki/>]]
28833 !! end
28834
28835 !! test
28836 3. Anchors: suppress empty anchors on edits
28837 !! options
28838 parsoid={
28839 "modes": ["selser"],
28840 "scrubWikitext": true,
28841 "changes": [
28842 [ "#x", "remove"]
28843 ]
28844 }
28845 !! wikitext
28846 [[Test|<span id="x">foo</span>]]
28847 !! wikitext/edited
28848 !! end
28849
28850 !! test
28851 3a. Anchors: do not suppress numbered extlinks
28852 !! options
28853 parsoid={
28854 "modes": ["wt2wt"],
28855 "scrubWikitext": true
28856 }
28857 !! wikitext
28858 [http://foo.com]
28859 !! html/parsoid
28860 <a rel="mw:ExtLink" href="http://foo.com"></a>
28861 !! end
28862
28863 !! test
28864 3b. Anchors: do not suppress numbered extlinks
28865 !! options
28866 parsoid={
28867 "modes": ["wt2wt"],
28868 "scrubWikitext": true,
28869 "changes": [
28870 [ "#x", "remove"]
28871 ]
28872 }
28873 !! wikitext
28874 [http://foo.com <span id="x">foo</span>]
28875 !! wikitext/edited
28876 [http://foo.com]
28877 !! end
28878
28879 !!test
28880 Normalizations should be restricted to edited content
28881 !!options
28882 parsoid={
28883 "modes": ["selser"],
28884 "scrubWikitext": true,
28885 "changes": [
28886 [ "h1", "before", "<i></i>"]
28887 ]
28888 }
28889 !!wikitext
28890 a
28891 = =
28892 b
28893 !!wikitext/edited
28894 a
28895 = =
28896 b
28897 !!end
28898
28899 !! test
28900 1. Multiple normalizations (html2wt)
28901 !! options
28902 parsoid={
28903 "modes": ["html2wt"],
28904 "scrubWikitext": true
28905 }
28906 !! html
28907 <h2><i></i></h2>
28908 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
28909 </a><b><i></i></b>x</p>
28910 !! wikitext
28911
28912 [[foo]]
28913 x
28914
28915 !! end
28916
28917 !! test
28918 2. Multiple normalizations (selser)
28919 !! options
28920 parsoid={
28921 "modes": ["selser"],
28922 "scrubWikitext": true,
28923 "changes": [
28924 [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
28925 ]
28926 }
28927 !! wikitext
28928 <span id="x">foo</span>
28929 !! wikitext/edited
28930 <span id="x">foo</span>
28931
28932 x
28933 !! end
28934
28935 !! test
28936 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
28937 !! options
28938 parsoid={
28939 "modes": ["html2wt"],
28940 "scrubWikitext": true
28941 }
28942 !! html/parsoid
28943 <p> hi</p>
28944 <p> hello</p>
28945 !! wikitext
28946 hi
28947
28948 hello
28949 !! end
28950
28951 !! test
28952 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
28953 !! options
28954 parsoid=html2wt
28955 !! html/parsoid
28956 <p> hi</p>
28957 <p> hello</p>
28958 !! wikitext
28959 <nowiki> </nowiki>hi
28960
28961 <nowiki> </nowiki> hello
28962 !! end
28963
28964 !! test
28965 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
28966 !! options
28967 parsoid={
28968 "modes": ["html2wt"],
28969 "scrubWikitext": true
28970 }
28971 !! html/parsoid
28972 <p>Foo
28973 bar
28974 baz</p>
28975
28976 <table><tr><td>Foo
28977 bar
28978 baz bang</td></tr></table>
28979
28980 <p><!--boo--> foo
28981 bar</p>
28982
28983 <p> foo
28984 bar<span>boo</span></p>
28985 !! wikitext
28986 Foo
28987 bar
28988 baz
28989
28990 {|
28991 |Foo
28992 bar
28993 baz bang
28994 |}
28995
28996 <!--boo-->foo
28997 bar
28998
28999 foo
29000 bar<span>boo</span>
29001 !! end
29002
29003 !! test
29004 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
29005 !! options
29006 parsoid={
29007 "modes": ["selser"],
29008 "scrubWikitext": true,
29009 "changes": [
29010 [ "p", "html", " a\n b" ]
29011 ]
29012 }
29013 !! wikitext
29014 xyz
29015 !! wikitext/edited
29016 a
29017 b
29018 !! end
29019
29020 !! test
29021 1. New links that end in spaces
29022 !! options
29023 parsoid={
29024 "modes": ["html2wt"],
29025 "scrubWikitext": false
29026 }
29027 !! html/parsoid
29028 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29029 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29030 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29031 !! wikitext
29032 [[Berlin ]]<nowiki/>is the capital of Germany.
29033
29034 [[Foo ]]'''bar'''
29035
29036 [[Boston ]] is a city.
29037 !! end
29038
29039 !! test
29040 2. New links that end in spaces
29041 !! options
29042 parsoid={
29043 "modes": ["html2wt"],
29044 "scrubWikitext": true
29045 }
29046 !! html/parsoid
29047 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
29048 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
29049 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
29050 !! wikitext
29051 [[Berlin]] is the capital of Germany.
29052
29053 [[Foo]] '''bar'''
29054
29055 [[Boston]] is a city.
29056 !! end
29057
29058 !! test
29059 1. Table cells with escapable prefixes
29060 !! options
29061 parsoid={
29062 "modes": ["html2wt"],
29063 "scrubWikitext": false
29064 }
29065 !! html
29066 <table>
29067 <tr><td>a</td></tr>
29068 <tr><td>-</td></tr>
29069 <tr><td>+</td></tr>
29070 </table>
29071 !! wikitext
29072 {|
29073 |a
29074 |-
29075 |<nowiki>-</nowiki>
29076 |-
29077 |<nowiki>+</nowiki>
29078 |}
29079 !! end
29080
29081 !! test
29082 2. Table cells with escapable prefixes
29083 !! options
29084 parsoid={
29085 "modes": ["html2wt"],
29086 "scrubWikitext": true
29087 }
29088 !! html
29089 <table>
29090 <tr><td>a</td></tr>
29091 <tr><td>-</td></tr>
29092 <tr><td>+</td></tr>
29093 </table>
29094 !! wikitext
29095 {|
29096 |a
29097 |-
29098 | -
29099 |-
29100 | +
29101 |}
29102 !! end
29103
29104 !! test
29105 3a. Table cells with escapable prefixes after edits
29106 !! options
29107 parsoid={
29108 "modes": ["selser"],
29109 "scrubWikitext": true,
29110 "changes": [
29111 [ "table tbody tr:first-child td:first-child", "remove"]
29112 ]
29113 }
29114 !! wikitext
29115 {|
29116 |a||-
29117 |}
29118 !! wikitext/edited
29119 {|
29120 | -
29121 |}
29122 !! end
29123
29124 !! test
29125 3b. Table cells with escapable prefixes after edits
29126 !! options
29127 parsoid={
29128 "modes": ["selser"],
29129 "scrubWikitext": true,
29130 "changes": [
29131 [ "table tbody tr:first-child td:first-child", "html", "-" ],
29132 [ "#x", "remove" ]
29133 ]
29134 }
29135 !! wikitext
29136 {|
29137 |pqr
29138 |<span id="x">foo</span>+
29139 |}
29140 !! wikitext/edited
29141 {|
29142 | -
29143 | +
29144 |}
29145 !! end
29146
29147 # FIXME: This test will fail because
29148 # normalization doesn't realize that the id attribute
29149 # will eliminate the escapable scenario
29150 !! test
29151 4a. Table cells without escapable prefixes after edits
29152 !! options
29153 parsoid={
29154 "modes": ["selser"],
29155 "scrubWikitext": true,
29156 "changes": [
29157 [ "#x", "html", "-" ]
29158 ]
29159 }
29160 !! wikitext
29161 {|
29162 | id="x" |abcd
29163 |}
29164 !! wikitext/edited
29165 {|
29166 | id="x" |-
29167 |}
29168 !! end
29169
29170 ## This tests normalizer's ability to discriminate between
29171 ## cells having identical content.
29172 !! test
29173 4b. Table cells without escapable prefixes after edits
29174 !! options
29175 parsoid={
29176 "modes": ["selser"],
29177 "scrubWikitext": true,
29178 "changes": [
29179 [ "td", "html", "-" ]
29180 ]
29181 }
29182 !! wikitext
29183 {|
29184 |a||b
29185 |}
29186 !! wikitext/edited
29187 {|
29188 | -||-
29189 |}
29190 !! end
29191
29192 ## This tests normalizer's ability to not be tripped by
29193 ## comments (and whitespace)
29194 !! test
29195 4c. Table cells without escapable prefixes after edits
29196 !! options
29197 parsoid={
29198 "modes": ["selser"],
29199 "scrubWikitext": true,
29200 "changes": [
29201 [ "table tbody tr td:first-child", "remove" ]
29202 ]
29203 }
29204 !! wikitext
29205 {|
29206 |-
29207 <!--foo--> |a||-
29208 |}
29209 !! wikitext/edited
29210 {|
29211 |-
29212 <!--foo--> | -
29213 |}
29214 !! end
29215
29216 ## This tests normalizer's ability to handle HTML cells
29217 !! test
29218 4d. Table cells without escapable prefixes after edits
29219 !! options
29220 parsoid={
29221 "modes": ["selser"],
29222 "scrubWikitext": true,
29223 "changes": [
29224 [ "td", "html", "-" ]
29225 ]
29226 }
29227 !! wikitext
29228 <table>
29229 <tr><td>a</td></tr>
29230 </table>
29231 !! wikitext/edited
29232 <table>
29233 <tr><td>-</td></tr>
29234 </table>
29235 !! end
29236
29237 ## T111151 Remove font elements without attributes
29238 !! test
29239 5a. font tags without attributes should be dropped in scrubWikitext mode
29240 !! options
29241 parsoid={
29242 "modes": ["html2wt"],
29243 "scrubWikitext": true
29244 }
29245 !! html
29246 <font>foo</font>
29247 <font><font>bar</font></font>
29248 <font class="x">boo</font>
29249 !! wikitext
29250 foo
29251 bar
29252 <font class="x">boo</font>
29253 !! end
29254
29255 !! test
29256 5b. font tags should not be dropped without scrubWikitext being enabled
29257 !! options
29258 parsoid={
29259 "modes": ["html2wt"],
29260 "scrubWikitext": false
29261 }
29262 !! html
29263 <font>foo</font>
29264 !! wikitext
29265 <font>foo</font>
29266 !! end
29267
29268 !! test
29269 Escape nowiki DOM elements
29270 !! options
29271 parsoid=html2wt
29272 !! html/parsoid
29273 <nowiki><i>foo</i></nowiki>
29274 !! wikitext
29275 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
29276 !! end
29277
29278 # This is meant to be an interim fix while we go about figuring out
29279 # how to not introduce these trailing <nowiki/>s in the first place.
29280 !! test
29281 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
29282 !! options
29283 parsoid=html2wt
29284 !! html/parsoid
29285 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
29286 y</p>
29287 <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>
29288 <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>
29289 !! wikitext
29290 x
29291 y
29292
29293 {{echo|
29294 1 = <nowiki/>}}
29295
29296 {{echo|
29297 1 = <nowiki/>
29298 }}
29299 !! end
29300
29301 # ---------------------------------------------------
29302 # End of tests spec'ing wikitext serialization norms |
29303 # ---------------------------------------------------
29304
29305 # T104032
29306 !! test
29307 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
29308 !! options
29309 parsoid=html2wt
29310 !! html/parsoid
29311 a<p>b</p>
29312 <b>c</b><p>d</p>
29313 <table><tr>
29314 <td>a<p>b</p></td>
29315 <td><b>c</b><p>d</p></td>
29316 </tr></table>
29317 !! wikitext
29318 a
29319
29320 b
29321
29322 '''c'''
29323
29324 d
29325 {|
29326 |a
29327 b
29328 |'''c'''
29329 d
29330 |}
29331 !! end
29332
29333 !! test
29334 Anchor without href scenarios
29335 !! options
29336 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
29337 !! html/parsoid
29338 <a class="bc"></a>
29339 <a class="no">dice</a>
29340 <a name="foo"></a>
29341 !! wikitext
29342
29343 dice
29344 <span name="foo"></span>
29345 !! end
29346
29347 !! test
29348 New transclusion added after a list should be serialized after the list
29349 !! options
29350 parsoid=html2wt
29351 !! html/parsoid
29352 <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>
29353 !! wikitext
29354 * a
29355 {{echo|foo}}
29356 !! end
29357
29358 # -----------------------------------------------------------------
29359 # End of section for Parsoid-only html2wt tests for serialization
29360 # of new content
29361 # -----------------------------------------------------------------
29362
29363 # -----------------------------------------------------------------
29364 # The following section of tests are primarily to spec behavior of
29365 # the selective serializer. All these tests have manual selser
29366 # changes. The automated selser changes for all tests handle the
29367 # wide variation of changes, but these tests here capture specs
29368 # deterministically.
29369 # ----------------------------------------------------------------
29370
29371 ## T90517
29372 !! test
29373 Selser: New comments should not be lost
29374 !! options
29375 parsoid={
29376 "modes": ["selser"],
29377 "changes": [
29378 [ "#a", "after", "<!--c1-->" ],
29379 [ "#b", "before", "<!--c2-->" ]
29380 ]
29381 }
29382 !! wikitext
29383 <span id="a">a</span>
29384
29385 <span id="b">b</span>
29386 !! wikitext/edited
29387 <span id="a">a</span><!--c1-->
29388
29389 <!--c2--><span id="b">b</span>
29390 !! end
29391
29392 ## T89383
29393 !! test
29394 Selser: Check for validity of DSR before using it
29395 !! options
29396 parsoid={
29397 "modes": ["selser"],
29398 "changes": [
29399 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
29400 ]
29401 }
29402 !! wikitext
29403 <span id="a">a</span>
29404 !! wikitext/edited
29405 {{DISPLAYTITLE:foo}}
29406 <span id="a">a</span>
29407 !! end
29408
29409 !! test
29410 1. DOMDiff: Changes to <ref> content should be looked up using id
29411 !! options
29412 parsoid={
29413 "modes": ["selser"],
29414 "changes": [
29415 ["#X", "after", "bar"],
29416 ["#Y", "after", "baz"]
29417 ]
29418 }
29419 !! wikitext
29420 X <ref><span id="X">foo</span></ref>
29421 Y <ref name="a" />
29422 <references>
29423 <ref name="a"><span id="Y">foo</span></ref>
29424 </references>
29425 !! wikitext/edited
29426 X <ref><span id="X">foo</span>bar</ref>
29427 Y <ref name="a" />
29428 <references>
29429 <ref name="a"><span id="Y">foo</span>baz</ref>
29430 </references>
29431 !! end
29432
29433 !! test
29434 2. DOMDiff: Changes to <ref> content should be looked up using id
29435 !! options
29436 parsoid={
29437 "modes": ["selser"],
29438 "changes": [
29439 ["#Z", "after", "bar"]
29440 ]
29441 }
29442 !! wikitext
29443 A <ref>foo bar for a</ref>
29444 B <ref group="X" name="b" />
29445
29446 <references />
29447
29448 <references group="X">
29449 <ref name="b"><span id="Z">foo</span></ref>
29450 </references>
29451 !! wikitext/edited
29452 A <ref>foo bar for a</ref>
29453 B <ref group="X" name="b" />
29454
29455 <references />
29456
29457 <references group="X">
29458 <ref name="b"><span id="Z">foo</span>bar</ref>
29459 </references>
29460 !! end
29461
29462 !! test
29463 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
29464 !! options
29465 parsoid={
29466 "modes": ["selser"],
29467 "changes": [
29468 [ "div:first-child", "text", "bar" ]
29469 ]
29470 }
29471 !! wikitext
29472 <div style="{{1x|color:red;}}%">foo</div>
29473 !! wikitext/edited
29474 <div style="{{1x|color:red;}}%">bar</div>
29475 !! end
29476
29477 !! test
29478 Empty LI (T49673)
29479 !! wikitext
29480 * a
29481 *
29482 *
29483 * b
29484 !! html/php+tidy
29485 <ul>
29486 <li>a</li>
29487 <li class="mw-empty-elt"></li>
29488 <li class="mw-empty-elt"></li>
29489 <li>b</li>
29490 </ul>
29491 !! end
29492
29493 !! test
29494 Thumbnail output
29495 !! wikitext
29496 [[File:Thumb.png|thumb]]
29497 !! html/php+tidy
29498 <div class="thumb tright">
29499 <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>
29500 <div class="thumbcaption">
29501 <div class="magnify"><a href="/wiki/File:Thumb.png" class="internal" title="Enlarge"></a></div>
29502 </div>
29503 </div>
29504 </div>
29505 !! end
29506
29507 !! test
29508 unclosed internal link XSS (T137264)
29509 !! wikitext
29510 [[#%3Cscript%3Ealert(1)%3C/script%3E|
29511 !! html/php
29512 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
29513 </p>
29514 !! html/parsoid
29515 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
29516 !! end
29517
29518 # Use $wgRawHtml to inject a <style> tag, since you normally can't in wikitext
29519 # (Parsoid doesn't support $wgRawHtml==true)
29520 !! test
29521 Validating that <style> isn't eaten by tidy (T167349)
29522 !! options
29523 wgRawHtml=1
29524 !! wikitext
29525 <div class="foo">
29526 <html><style>.foo::before { content: "<foo>"; }</style></html>
29527 <html><style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style></html>
29528 </div>
29529 !! html/php+tidy
29530 <div class="foo">
29531 <style>.foo::before { content: "<foo>"; }</style>
29532 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
29533 </div>
29534 !! end
29535
29536 !! test
29537 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
29538 !! wikitext
29539 == A&B&amp;C&amp;amp;D&amp;amp;amp;E ==
29540 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
29541 !! html/php
29542 <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>
29543 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
29544 </p>
29545 !! end
29546
29547 !! test
29548 Decoding of HTML entities in indicator names for IDs (T104196)
29549 !! options
29550 showindicators
29551 !! wikitext
29552 <indicator name="1&2&amp;3&amp;amp;4&amp;amp;amp;5">Indicator</indicator>
29553 !! html/php
29554 1&2&3&amp;4&amp;amp;5=Indicator
29555
29556 !! end
29557
29558 !! test
29559 HTML5 ids: fallback to legacy
29560 !! config
29561 wgFragmentMode=[ 'html5', 'legacy' ]
29562 !! wikitext
29563 == Foo bar ==
29564
29565 == foo Bar ==
29566
29567 == Тест ==
29568
29569 == Тест ==
29570
29571 == тест ==
29572
29573 == Hey < # " > % : ' ==
29574 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
29575
29576 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
29577
29578 <!-- These two links should produce identical HTML -->
29579 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
29580
29581 !! html/php
29582 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
29583 <ul>
29584 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
29585 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
29586 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
29587 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
29588 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
29589 <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>
29590 </ul>
29591 </div>
29592
29593 <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>
29594 <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>
29595 <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>
29596 <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>
29597 <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>
29598 <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>
29599 <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>
29600 </p><p>💩 <span id="💩"></span>
29601 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
29602 </p>
29603 !! end
29604
29605 !! test
29606 HTML5 ids: legacy with a fallback to modern
29607 !! config
29608 wgFragmentMode=[ 'legacy', 'html5' ]
29609 !! wikitext
29610 == Foo bar ==
29611
29612 == foo Bar ==
29613
29614 == Тест ==
29615
29616 == Тест ==
29617
29618 == тест ==
29619
29620 == Hey < # " > % : ' ==
29621 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
29622
29623 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
29624
29625 <!-- These two links should produce identical HTML -->
29626 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
29627
29628 !! html/php
29629 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
29630 <ul>
29631 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
29632 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
29633 <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>
29634 <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>
29635 <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>
29636 <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>
29637 </ul>
29638 </div>
29639
29640 <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>
29641 <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>
29642 <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>
29643 <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>
29644 <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>
29645 <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>
29646 <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>
29647 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
29648 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
29649 </p>
29650 !! end
29651
29652 !! test
29653 HTML5 ids: no legacy
29654 !! config
29655 wgFragmentMode=[ 'html5' ]
29656 !! wikitext
29657 == Foo bar ==
29658
29659 == foo Bar ==
29660
29661 == Тест ==
29662
29663 == Тест ==
29664
29665 == тест ==
29666
29667 == Hey < # " > % : ' ==
29668 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
29669
29670 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
29671
29672 <!-- These two links should produce identical HTML -->
29673 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
29674
29675 !! html/php
29676 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
29677 <ul>
29678 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
29679 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
29680 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
29681 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
29682 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
29683 <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>
29684 </ul>
29685 </div>
29686
29687 <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>
29688 <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>
29689 <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>
29690 <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>
29691 <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>
29692 <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>
29693 <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>
29694 </p><p>💩 <span id="💩"></span>
29695 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
29696 </p>
29697 !! end
29698
29699 !! test
29700 T90902: Normalize weird characters in section IDs
29701 !! config
29702 wgFragmentMode=[ 'html5', 'legacy' ]
29703 !! wikitext
29704 == Foo&nbsp;bar ==
29705 [[#Foo&nbsp;bar]]
29706
29707 !! html/php
29708 <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>
29709 <p><a href="#Foo_bar">#Foo&#160;bar</a>
29710 </p>
29711 !! end
29712
29713 !! test
29714 T51672: Test for brackets in attributes of elements in external link texts
29715 !! wikitext
29716 [http://example.com/ link <span title="title with [brackets]">span</span>]
29717 [http://example.com/ link <span title="title with &#91;brackets&#93;">span</span>]
29718
29719 !! html/php
29720 <p><a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
29721 <a rel="nofollow" class="external text" href="http://example.com/">link <span title="title with &#91;brackets&#93;">span</span></a>
29722 </p>
29723 !! end
29724
29725 !! test
29726 T72875: Test for brackets in attributes of elements in internal link texts
29727 !! wikitext
29728 [[Foo|link <span title="title with [[double brackets]]">span</span>]]
29729 [[Foo|link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span>]]
29730
29731 !! html/php
29732 <p><a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
29733 <a href="/wiki/Foo" title="Foo">link <span title="title with &#91;&#91;double brackets&#93;&#93;">span</span></a>
29734 </p>
29735 !! end
29736
29737 !! test
29738 T179544: {{anchorencode:}} output should be always usable in links
29739 !! config
29740 wgFragmentMode=[ 'html5' ]
29741 !! wikitext
29742 <span id="{{anchorencode:[foo]}}"></span>[[#{{anchorencode:[foo]}}]]
29743 !! html/php
29744 <p><span id="&#91;foo&#93;"></span><a href="#[foo]">#&#91;foo&#93;</a>
29745 </p>
29746 !! end
29747
29748 ## ------------------------------
29749 ## Parsoid section-wrapping tests
29750 ## ------------------------------
29751 !! test
29752 Section wrapping for well-nested sections (no leading content)
29753 !! options
29754 parsoid={
29755 "wrapSections": true
29756 }
29757 !! wikitext
29758 = 1 =
29759 a
29760
29761 = 2 =
29762 b
29763
29764 == 2.1 ==
29765 c
29766
29767 == 2.2 ==
29768 d
29769
29770 === 2.2.1 ===
29771 e
29772
29773 = 3 =
29774 f
29775 !! html/parsoid
29776 <section data-mw-section-id="1"><h1 id="1"> 1 </h1>
29777 <p>a</p>
29778
29779 </section><section data-mw-section-id="2"><h1 id="2"> 2 </h1>
29780 <p>b</p>
29781
29782 <section data-mw-section-id="3"><h2 id="2.1"> 2.1 </h2>
29783 <p>c</p>
29784
29785 </section><section data-mw-section-id="4"><h2 id="2.2"> 2.2 </h2>
29786 <p>d</p>
29787
29788 <section data-mw-section-id="5"><h3 id="2.2.1"> 2.2.1 </h3>
29789 <p>e</p>
29790
29791 </section></section></section><section data-mw-section-id="6"><h1 id="3"> 3 </h1>
29792 <p>f</p>
29793
29794 </section>
29795 !! end
29796
29797 !! test
29798 Section wrapping for well-nested sections (with leading content)
29799 !! options
29800 parsoid={
29801 "wrapSections": true
29802 }
29803 !! wikitext
29804 Para 1.
29805
29806 Para 2 with a <div>nested in it</div>
29807
29808 Para 3.
29809
29810 = 1 =
29811 a
29812
29813 = 2 =
29814 b
29815
29816 == 2.1 ==
29817 c
29818 !! html/parsoid
29819 <section data-mw-section-id="0"><p>Para 1.</p>
29820
29821 <p>Para 2 with a </p><div>nested in it</div>
29822
29823 <p>Para 3.</p>
29824
29825 </section><section data-mw-section-id="1"><h1 id="1"> 1 </h1>
29826 <p>a</p>
29827
29828 </section><section data-mw-section-id="2"><h1 id="2"> 2 </h1>
29829 <p>b</p>
29830
29831 <section data-mw-section-id="3"><h2 id="2.1"> 2.1 </h2>
29832 <p>c</p>
29833
29834 </section></section>
29835 !! end
29836
29837 !! test
29838 Section wrapping with template-generated sections (good nesting 1)
29839 !! options
29840 parsoid={
29841 "wrapSections": true
29842 }
29843 !! wikitext
29844 = 1 =
29845 a
29846
29847 {{echo|1=
29848 == 1.1 ==
29849 b
29850 }}
29851
29852 == 1.2 ==
29853 c
29854
29855 = 2 =
29856 d
29857 !! html/parsoid
29858 <section data-mw-section-id="1"><h1 id="1"> 1 </h1>
29859 <p>a</p>
29860
29861 <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">
29862 </span><p about="#mwt1">b</p>
29863 </section><section data-mw-section-id="3"><h2 id="1.2"> 1.2 </h2>
29864 <p>c</p>
29865
29866 </section></section><section data-mw-section-id="4"><h1 id="2"> 2 </h1>
29867 <p>d</p></section>
29868 !! end
29869
29870 # In this example, the template scope is mildly expanded to incorporate the
29871 # trailing newline after the transclusion since that is part of section 1.1.1
29872 !! test
29873 Section wrapping with template-generated sections (good nesting 2)
29874 !! options
29875 parsoid={
29876 "wrapSections": true,
29877 "modes": ["wt2html", "wt2wt"]
29878 }
29879 !! wikitext
29880 = 1 =
29881 a
29882
29883 {{echo|1=
29884 == 1.1 ==
29885 b
29886 === 1.1.1 ===
29887 d
29888 }}
29889 = 2 =
29890 e
29891 !! html/parsoid
29892 <section data-mw-section-id="1"><h1 id="1"> 1 </h1>
29893 <p>a</p>
29894
29895 <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">
29896 </span><p about="#mwt1">b</p><span about="#mwt1">
29897 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1"> 1.1.1 </h3><span about="#mwt1">
29898 </span><p about="#mwt1">d</p><span about="#mwt1">
29899 </span></section></section></section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="2"> 2 </h1>
29900 <p>e</p></section>
29901 !! end
29902
29903 # In this example, the template scope is mildly expanded to incorporate the
29904 # trailing newline after the transclusion since that is part of section 1.2.1
29905 !! test
29906 Section wrapping with template-generated sections (good nesting 3)
29907 !! options
29908 parsoid={
29909 "wrapSections": true,
29910 "modes": ["wt2html", "wt2wt"]
29911 }
29912 !! wikitext
29913 = 1 =
29914 a
29915
29916 {{echo|1=
29917 x
29918 == 1.1 ==
29919 b
29920 ==1.2==
29921 c
29922 ===1.2.1===
29923 d
29924 }}
29925 = 2 =
29926 e
29927 !! html/parsoid
29928 <section data-mw-section-id="1" data-parsoid="{}"><h1 id="1"> 1 </h1>
29929 <p>a</p>
29930
29931 <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">
29932 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1"> 1.1 </h2><span about="#mwt1">
29933 </span><p about="#mwt1">b</p><span about="#mwt1">
29934 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
29935 </span><p about="#mwt1">c</p><span about="#mwt1">
29936 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
29937 </span><p about="#mwt1">d</p><span about="#mwt1">
29938 </span></section></section></section><section data-mw-section-id="5"><h1 id="2"> 2 </h1>
29939 <p>e</p></section>
29940 !! end
29941
29942 # Because of section-wrapping and template-wrapping interactions,
29943 # the scope of the template is expanded so that the template markup
29944 # is valid in the presence of <section> tags.
29945 !! test
29946 Section wrapping with template-generated sections (bad nesting 1)
29947 !! options
29948 parsoid={
29949 "wrapSections": true
29950 }
29951 !! wikitext
29952 = 1 =
29953 a
29954
29955 {{echo|1=
29956 = 2 =
29957 b
29958 == 2.1 ==
29959 c
29960 }}
29961
29962 d
29963
29964 = 3 =
29965 e
29966 !! html/parsoid
29967 <section data-mw-section-id="1"><h1 id="1"> 1 </h1>
29968 <p>a</p>
29969
29970 </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">
29971 </span><p about="#mwt1">b</p><span about="#mwt1">
29972 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1"> 2.1 </h2><span about="#mwt1">
29973 </span><p about="#mwt1">c</p><span about="#mwt1">
29974
29975 </span><p about="#mwt1">d</p><span about="#mwt1">
29976
29977 </span></section></section><section data-mw-section-id="4"><h1 id="3"> 3 </h1>
29978 <p>e</p></section>
29979 !! end
29980
29981 # Because of section-wrapping and template-wrapping interactions,
29982 # additional template wrappers are added to <section> tags
29983 # so that template wrapping semantics are valid whether section
29984 # tags are retained or stripped. But, the template scope can expand
29985 # greatly when accounting for section tags.
29986 !! test
29987 Section wrapping with template-generated sections (bad nesting 2)
29988 !! options
29989 parsoid={
29990 "wrapSections": true,
29991 "modes": ["wt2html", "wt2wt"]
29992 }
29993 !! wikitext
29994 = 1 =
29995 a
29996
29997 {{echo|1=
29998 == 1.2 ==
29999 b
30000 = 2 =
30001 c
30002 }}
30003
30004 d
30005
30006 = 3 =
30007 e
30008 !! html/parsoid
30009 <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>
30010 <p>a</p>
30011
30012 <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">
30013 </span><p about="#mwt1">b</p><span about="#mwt1">
30014 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2"> 2 </h1><span about="#mwt1">
30015 </span><p about="#mwt1">c</p>
30016
30017 <p>d</p>
30018 </section><section data-mw-section-id="4" data-parsoid="{}"><h1 id="3"> 3 </h1>
30019 <p>e</p></section>
30020 !! end
30021
30022 !! test
30023 Section wrapping with uneditable lead section + div wrapping multiple sections
30024 !! options
30025 parsoid={
30026 "wrapSections": true
30027 }
30028 !! wikitext
30029 foo
30030
30031 <div style="border:1px solid red;">
30032 = 1 =
30033 a
30034
30035 == 1.1 ==
30036 b
30037
30038 = 2 =
30039 c
30040 </div>
30041
30042 = 3 =
30043 d
30044
30045 == 3.1 ==
30046 e
30047 !! html/parsoid
30048 <section data-mw-section-id="-1"><p>foo</p>
30049
30050 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
30051 <section data-mw-section-id="1"><h1 id="1"> 1 </h1>
30052 <p>a</p>
30053
30054 <section data-mw-section-id="2"><h2 id="1.1"> 1.1 </h2>
30055 <p>b</p>
30056
30057 </section></section><section data-mw-section-id="-1"><h1 id="2"> 2 </h1>
30058 <p>c</p>
30059 </section></div>
30060
30061 </section><section data-mw-section-id="4"><h1 id="3"> 3 </h1>
30062 <p>d</p>
30063
30064 <section data-mw-section-id="5"><h2 id="3.1"> 3.1 </h2>
30065 <p>e</p>
30066 </section></section>
30067 !! end
30068
30069 !! test
30070 Section wrapping with editable lead section + div overlapping multiple sections
30071 !! options
30072 parsoid={
30073 "wrapSections": true
30074 }
30075 !! wikitext
30076 foo
30077
30078 = 1 =
30079 a
30080 <div style="border:1px solid red;">
30081 b
30082
30083 == 1.1 ==
30084 c
30085
30086 = 2 =
30087 d
30088 </div>
30089 e
30090
30091 = 3 =
30092 f
30093
30094 == 3.1 ==
30095 g
30096 !! html/parsoid
30097 <section data-mw-section-id="0"><p>foo</p>
30098
30099 </section><section data-mw-section-id="-1"><h1 id="1"> 1 </h1>
30100 <p>a</p>
30101 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
30102 <p>b</p>
30103
30104 <section data-mw-section-id="2"><h2 id="1.1"> 1.1 </h2>
30105 <p>c</p>
30106
30107 </section><section data-mw-section-id="-1"><h1 id="2"> 2 </h1>
30108 <p>d</p>
30109 </section></div>
30110 <p>e</p>
30111
30112 </section><section data-mw-section-id="4"><h1 id="3"> 3 </h1>
30113 <p>f</p>
30114
30115 <section data-mw-section-id="5"><h2 id="3.1"> 3.1 </h2>
30116 <p>g</p>
30117 </section></section>
30118 !! end
30119
30120 !! test
30121 HTML header tags should not be wrapped in section tags
30122 !! options
30123 parsoid={
30124 "wrapSections": true
30125 }
30126 !! wikitext
30127 foo
30128
30129 <h1>a</h1>
30130
30131 = b =
30132
30133 <h1>c</h1>
30134
30135 = d =
30136 !! html/parsoid
30137 <section data-mw-section-id="0"><p>foo</p>
30138
30139 <h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
30140
30141 </section><section data-mw-section-id="1"><h1 id="b"> b </h1>
30142
30143 <h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
30144
30145 </section><section data-mw-section-id="2"><h1 id="d"> d </h1></section>
30146 !! end