Merge "Move some more classes to comply with class per file"
[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 !! article
113 Template:echo_with_span
114 !! text
115 <span>{{{1}}}</span>
116 !! endarticle
117
118 !! article
119 Template:echo_with_div
120 !! text
121 <div>{{{1}}}</div>
122 !! endarticle
123
124 !! article
125 Template:blank_param
126 !! text
127 {{{1}}}
128 {{{}}}
129 !! endarticle
130
131 !! article
132 Template:table_attribs
133 !! text
134 <noinclude>
135 |</noinclude>style="color:red;"|Foo
136 !! endarticle
137
138 !! article
139 Template:table_attribs_2
140 !! text
141 <noinclude>
142 |</noinclude>style="color:red;"|Foo
143 |Bar||Baz
144 !! endarticle
145
146 !! article
147 Template:table_attribs_3
148 !! text
149 <noinclude>
150 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo
151 !! endarticle
152
153 !! article
154 Template:table_attribs_4
155 !! text
156 | style="background-color:#DC241f;" width="10px" |
157 !! endarticle
158
159 !! article
160 Template:table_attribs_5
161 !! text
162 <noinclude>
163 |</noinclude>style="color:red;"||Bar
164 !! endarticle
165
166 !! article
167 Template:table_attribs_6
168 !! text
169 style="background: <nowiki>
170
171
172 red;</nowiki>" |
173 !! endarticle
174
175 !! article
176 Template:table_attribs_7
177 !! text
178 <noinclude>
179 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
180 !! endarticle
181
182 !! article
183 Template:table_header_cells
184 !! text
185 {{table_attribs}}!!style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
186 !! endarticle
187
188 !! article
189 Template:table_cells
190 !! text
191 {{table_attribs}}||style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
192 !! endarticle
193
194 !! article
195 Template:PartialTable
196 !! text
197 {|
198 |-
199 !! endarticle
200
201 !! article
202 Template:image_attribs
203 !! text
204 <noinclude>
205 [[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
206 !! endarticle
207
208 ## See T48811 for details
209 !! article
210 Template:mixed_attr_content_template
211 !! text
212 style="color:red;" title="T48811"
213 |-
214 |foo
215 !! endarticle
216
217 !! article
218 Template:definition_list
219 !! text
220 one
221 ::two
222 !! endarticle
223
224 !! article
225 A?b
226 !! text
227 Weirdo titles!
228 !! endarticle
229
230 !!article
231 Template:Bullet
232 !!text
233 * Bar
234 !!endarticle
235
236 !!article
237 Template:OpenTable
238 !!text
239 {|
240 !!endarticle
241
242 !!article
243 Template:EmptyLITest
244 !!text
245 *a
246 *
247 *
248 *b
249 !!endarticle
250
251 !!article
252 Template:EmptyTRTest
253 !!text
254 {|
255 |-
256 |-
257 |foo
258 |-
259 |-
260 |bar
261 |}
262 !!endarticle
263
264 !!article
265 Template:EmptyTRWithHTMLAttrTest
266 !!text
267 <table>
268 <tr align="center"></tr>
269 <tr><td>foo</td></tr>
270 <tr align="center"></tr>
271 <tr><td>bar</td></tr>
272 </table>
273 !!endarticle
274
275 !! article
276 Template:CircularRef
277 !! text
278 <ref>{{CircularRef}}</ref>
279 !! endarticle
280
281 ###
282 ### Basic tests
283 ###
284 !! test
285 Blank input
286 !! wikitext
287 !! html
288 !! end
289
290 !! test
291 CircularRef
292 !! wikitext
293 {{CircularRef}}
294 <references />
295 !! html/parsoid
296 <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>
297 <ol class="mw-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>
298 !! end
299
300 !! test
301 Simple paragraph
302 !! wikitext
303 This is a simple paragraph.
304 !! html
305 <p>This is a simple paragraph.
306 </p>
307 !! end
308
309 !! test
310 Paragraphs with extra newline spacing
311 !! wikitext
312 foo
313
314 bar
315
316
317 baz
318
319
320
321 booz
322 !! html
323 <p>foo
324 </p><p>bar
325 </p><p><br />
326 baz
327 </p><p><br />
328 </p><p>booz
329 </p>
330 !! end
331
332 !! test
333 Paragraphs with newline spacing with comment lines in between
334 !! wikitext
335 ----
336 a
337 <!--foo-->
338 b
339 ----
340 a
341 <!--foo--><!--More than 1 comment, still stripped-->
342 b
343 ----
344 a
345 <!--foo--> <!----> <!-- bar -->
346 b
347 ----
348 a
349 <!--foo-->
350
351 b
352 ----
353 a
354
355 <!--foo-->
356 b
357 ----
358 a
359 <!--foo-->
360
361
362 b
363 ----
364 a
365
366
367 <!--foo-->
368 b
369 ----
370 !! html
371 <hr />
372 <p>a
373 b
374 </p>
375 <hr />
376 <p>a
377 b
378 </p>
379 <hr />
380 <p>a
381 b
382 </p>
383 <hr />
384 <p>a
385 </p><p>b
386 </p>
387 <hr />
388 <p>a
389 </p><p>b
390 </p>
391 <hr />
392 <p>a
393 </p><p><br />
394 b
395 </p>
396 <hr />
397 <p>a
398 </p><p><br />
399 b
400 </p>
401 <hr />
402
403 !! end
404
405 !! test
406 Paragraphs with newline spacing with non-empty white-space lines in between
407 !! wikitext
408 ----
409 a
410
411 b
412 ----
413 a
414
415
416 b
417 ----
418 !! html
419 <hr />
420 <p>a
421 </p><p>b
422 </p>
423 <hr />
424 <p>a
425 </p><p><br />
426 b
427 </p>
428 <hr />
429
430 !! end
431
432 !! test
433 Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
434 !! wikitext
435 ----
436 a
437 <!--foo-->
438 b
439 ----
440 a
441 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
442 b
443 ----
444 a
445
446 <!--foo-->
447 <!--bar-->
448 b
449 ----
450 a
451
452 <!--foo-->
453 <!--bar-->
454
455 b
456 ----
457 !! html
458 <hr />
459 <p>a
460 b
461 </p>
462 <hr />
463 <p>a
464 b
465 </p>
466 <hr />
467 <p>a
468 </p><p>b
469 </p>
470 <hr />
471 <p>a
472 </p><p><br />
473 b
474 </p>
475 <hr />
476
477 !! end
478
479 !! test
480 Extra newlines: More paragraphs with indented comment
481 !! wikitext
482 a
483
484 <!--boo-->
485
486 b
487 !! html
488 <p>a
489 </p><p><br />
490 b
491 </p>
492 !!end
493
494 !! test
495 Extra newlines followed by heading
496 !! wikitext
497 a
498
499
500
501 =b=
502 [[a]]
503
504
505 =b=
506 !! html
507 <p>a
508 </p><p><br />
509 </p>
510 <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>
511 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
512 </p><p><br />
513 </p>
514 <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>
515
516 !! end
517
518 !! test
519 Extra newlines between heading and content are swallowed
520 !! wikitext
521 =b=
522
523
524
525 [[a]]
526 !! html
527 <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>
528 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
529 </p>
530 !! end
531
532 !! test
533 Heading with line break in nowiki
534 !! options
535 parsoid=wt2html
536 !! wikitext
537 == A <nowiki>B
538 C</nowiki> ==
539 !! html
540 <h2><span class="mw-headline" id="A_B.0AC">A B
541 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>
542
543 !! html/parsoid
544 <h2 id="A_B.0AC">A <span typeof="mw:Nowiki">B
545 C</span> </h2>
546 !! end
547
548 !! test
549 Parsing an URL
550 !! wikitext
551 http://fr.wikipedia.org/wiki/🍺
552 <!-- EasterEgg we love beer, better be able be able to link to it -->
553 !! html
554 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
555 </p>
556 !! end
557
558 # Note that the html+tidy output removes the spaces after the <li>,
559 # which is a bug (https://sourceforge.net/p/tidy/bugs/945/, etc).
560 # This is an issue for all tests with lists. We intentionally do
561 # *not* add html+tidy clauses for these, as we don't want to
562 # document/test the broken behavior. (Parsoid matches the non-tidy
563 # output in these cases.)
564
565 !! test
566 Simple list
567 !! wikitext
568 * Item 1
569 * Item 2
570 !! html
571 <ul><li> Item 1</li>
572 <li> Item 2</li></ul>
573
574 !! end
575
576 !! test
577 Italics and bold
578 !! wikitext
579 * plain
580 * plain''italic''plain
581 * plain''italic''plain''italic''plain
582 * plain'''bold'''plain
583 * plain'''bold'''plain'''bold'''plain
584 * plain''italic''plain'''bold'''plain
585 * plain'''bold'''plain''italic''plain
586 * plain''italic'''bold-italic'''italic''plain
587 * plain'''bold''bold-italic''bold'''plain
588 * plain'''''bold-italic'''italic''plain
589 * plain'''''bold-italic''bold'''plain
590 * plain''italic'''bold-italic'''''plain
591 * plain'''bold''bold-italic'''''plain
592 * plain l'''italic''plain
593 * plain l''''bold''' plain
594 !! html
595 <ul><li> plain</li>
596 <li> plain<i>italic</i>plain</li>
597 <li> plain<i>italic</i>plain<i>italic</i>plain</li>
598 <li> plain<b>bold</b>plain</li>
599 <li> plain<b>bold</b>plain<b>bold</b>plain</li>
600 <li> plain<i>italic</i>plain<b>bold</b>plain</li>
601 <li> plain<b>bold</b>plain<i>italic</i>plain</li>
602 <li> plain<i>italic<b>bold-italic</b>italic</i>plain</li>
603 <li> plain<b>bold<i>bold-italic</i>bold</b>plain</li>
604 <li> plain<i><b>bold-italic</b>italic</i>plain</li>
605 <li> plain<b><i>bold-italic</i>bold</b>plain</li>
606 <li> plain<i>italic<b>bold-italic</b></i>plain</li>
607 <li> plain<b>bold<i>bold-italic</i></b>plain</li>
608 <li> plain l'<i>italic</i>plain</li>
609 <li> plain l'<b>bold</b> plain</li></ul>
610
611 !! end
612
613 # this example taken from the [[simple:Moon]] article (T49326)
614 !! test
615 Italics and possessives (1)
616 !! wikitext
617 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
618 !! html
619 <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
620 </p>
621 !! end
622
623 # this example taken from [[en:Flaming Pie]] (T51926)
624 !! test
625 Italics and possessives (2)
626 !! wikitext
627 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
628 !! html
629 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
630 </p>
631 !! end
632
633 # this example taken from [[en:Dictionary]] (T51926)
634 !! test
635 Italics and possessives (3)
636 !! wikitext
637 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''.
638 !! html
639 <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>.
640 </p>
641 !! end
642
643
644 ###
645 ### 2-quote opening sequence tests
646 ###
647 !! test
648 Italics and bold: 2-quote opening sequence: (2,2)
649 !! wikitext
650 ''foo''
651 !! html
652 <p><i>foo</i>
653 </p>
654 !!end
655
656 !! test
657 Italics and bold: 2-quote opening sequence: (2,3)
658 !! wikitext
659 ''foo'''
660 !! html/*
661 <p><i>foo'</i>
662 </p>
663 !!end
664
665 !! test
666 Italics and bold: 2-quote opening sequence: (2,4)
667 !! options
668 parsoid=wt2html
669 !! wikitext
670 ''foo''''
671 !! html/*
672 <p><i>foo''</i>
673 </p>
674 !!end
675
676 # same html as previous, but wikitext adjusted to match parsoid html2wt
677 !! test
678 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
679 !! wikitext
680 ''foo<nowiki>''</nowiki>''
681 !! html
682 <p><i>foo''</i>
683 </p>
684 !! end
685
686 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
687 !! test
688 Italics and bold: 2-quote opening sequence: (2,5)
689 !! options
690 parsoid=wt2html
691 !! wikitext
692 ''foo'''''
693 !! html/php
694 <p><i>foo</i>
695 </p>
696 !! html/parsoid
697 <p><i>foo</i><b></b>
698 </p>
699 !!end
700
701 # same html as previous, but wikitext adjusted to match parsoid html2wt
702 !! test
703 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
704 !! wikitext
705 ''foo'''''<nowiki/>'''
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
715 ###
716 ### 3-quote opening sequence tests
717 ###
718
719 !! test
720 Italics and bold: 3-quote opening sequence: (3,2)
721 !! wikitext
722 '''foo''
723 !! html/*
724 <p>'<i>foo</i>
725 </p>
726 !!end
727
728 !! test
729 Italics and bold: 3-quote opening sequence: (3,3)
730 !! wikitext
731 '''foo'''
732 !! html
733 <p><b>foo</b>
734 </p>
735 !!end
736
737 !! test
738 Italics and bold: 3-quote opening sequence: (3,4)
739 !! wikitext
740 '''foo''''
741 !! html/*
742 <p><b>foo'</b>
743 </p>
744 !!end
745
746 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
747 !! test
748 Italics and bold: 3-quote opening sequence: (3,5)
749 !! options
750 parsoid=wt2html
751 !! wikitext
752 '''foo'''''
753 !! html/php
754 <p><b>foo</b>
755 </p>
756 !! html/parsoid
757 <p><b>foo</b><i></i>
758 </p>
759 !!end
760
761 # same html as previous, but wikitext adjusted to match parsoid html2wt
762 !! test
763 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
764 !! wikitext
765 '''foo'''''<nowiki/>''
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
775 ###
776 ### 4-quote opening sequence tests
777 ###
778
779 !! test
780 Italics and bold: 4-quote opening sequence: (4,2)
781 !! options
782 parsoid=wt2html
783 !! wikitext
784 ''''foo''
785 !! html/*
786 <p>''<i>foo</i>
787 </p>
788 !!end
789
790 # same html as previous, but wikitext adjusted to match parsoid html2wt
791 !! test
792 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
793 !! wikitext
794 <nowiki>''</nowiki>''foo''
795 !! html
796 <p>''<i>foo</i>
797 </p>
798 !! end
799
800 !! test
801 Italics and bold: 4-quote opening sequence: (4,3)
802 !! wikitext
803 ''''foo'''
804 !! html/*
805 <p>'<b>foo</b>
806 </p>
807 !!end
808
809 !! test
810 Italics and bold: 4-quote opening sequence: (4,4)
811 !! options
812 parsoid=wt2html
813 !! wikitext
814 ''''foo''''
815 !! html/*
816 <p>'<b>foo'</b>
817 </p>
818 !!end
819
820 # same html as previous, but wikitext adjusted to match parsoid html2wt
821 !! test
822 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
823 !! wikitext
824 '<nowiki/>'''foo''''
825 !! html
826 <p>'<b>foo'</b>
827 </p>
828 !! end
829
830 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
831 !! test
832 Italics and bold: 4-quote opening sequence: (4,5)
833 !! options
834 parsoid=wt2html
835 !! wikitext
836 ''''foo'''''
837 !! html/php
838 <p>'<b>foo</b>
839 </p>
840 !! html/parsoid
841 <p>'<b>foo</b><i></i>
842 </p>
843 !!end
844
845 # same html as previous, but wikitext adjusted to match parsoid html2wt
846 !! test
847 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
848 !! wikitext
849 '<nowiki/>'''foo'''''<nowiki/>''
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
859 ###
860 ### 5-quote opening sequence tests
861 ###
862
863 !! test
864 Italics and bold: 5-quote opening sequence: (5,2)
865 !! options
866 parsoid=wt2html
867 !! wikitext
868 '''''foo''
869 !! html/*
870 <p><b><i>foo</i></b>
871 </p>
872 !!end
873
874 # same html as previous, but wikitext adjusted to match parsoid html2wt
875 !! test
876 Italics and bold: 5-quote opening sequence: (5,2+3)
877 !! wikitext
878 '''''foo'''''
879 !! html/*
880 <p><i><b>foo</b></i>
881 </p>
882 !! end
883
884 !! test
885 Italics and bold: 5-quote opening sequence: (5,3)
886 !! options
887 parsoid=wt2html
888 !! wikitext
889 '''''foo'''
890 !! html/*
891 <p><i><b>foo</b></i>
892 </p>
893 !!end
894
895 # same html as previous, but wikitext adjusted to match parsoid html2wt
896 !! test
897 Italics and bold: 5-quote opening sequence: (5,3+2)
898 !! wikitext
899 '''''foo'''''
900 !! html
901 <p><i><b>foo</b></i>
902 </p>
903 !! end
904
905 !! test
906 Italics and bold: 5-quote opening sequence: (5,4)
907 !! options
908 parsoid=wt2html
909 !! wikitext
910 '''''foo''''
911 !! html/*
912 <p><i><b>foo'</b></i>
913 </p>
914 !!end
915
916 !! test
917 Italics and bold: 5-quote opening sequence: (5,5)
918 !! wikitext
919 '''''foo'''''
920 !! html
921 <p><i><b>foo</b></i>
922 </p>
923 !!end
924
925 !! test
926 Italics and bold: 5-quote opening sequence: (5,6)
927 !! wikitext
928 '''''foo''''''
929 !! html/*
930 <p><i><b>foo'</b></i>
931 </p>
932 !! end
933
934 ###
935 ### multiple quote sequences in a line
936 ###
937
938 !! test
939 Italics and bold: multiple quote sequences: (2,4,2)
940 !! options
941 parsoid=wt2html
942 !! wikitext
943 ''foo''''bar''
944 !! html/*
945 <p><i>foo'<b>bar</b></i>
946 </p>
947 !! end
948
949 # same html as previous, but wikitext adjusted to match parsoid html2wt
950 !! test
951 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
952 !! wikitext
953 ''foo'<nowiki/>'''bar'''''
954 !! html
955 <p><i>foo'<b>bar</b></i>
956 </p>
957 !! end
958
959 !! test
960 Italics and bold: multiple quote sequences: (2,4,3)
961 !! options
962 parsoid=wt2html
963 !! wikitext
964 ''foo''''bar'''
965 !! html/*
966 <p><i>foo'<b>bar</b></i>
967 </p>
968 !! end
969
970 # same html as previous, but wikitext adjusted to match parsoid html2wt
971 !! test
972 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
973 !! wikitext
974 ''foo'<nowiki/>'''bar'''''
975 !! html
976 <p><i>foo'<b>bar</b></i>
977 </p>
978 !! end
979
980 !! test
981 Italics and bold: multiple quote sequences: (2,4,4)
982 !! options
983 parsoid=wt2html
984 !! wikitext
985 ''foo''''bar''''
986 !! html/*
987 <p><i>foo'<b>bar'</b></i>
988 </p>
989 !! end
990
991 # same html as previous, but wikitext adjusted to match parsoid html2wt
992 !! test
993 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
994 !! wikitext
995 ''foo'<nowiki/>'''bar'<nowiki/>'''''
996 !! html
997 <p><i>foo'<b>bar'</b></i>
998 </p>
999 !! end
1000
1001 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1002 !! test
1003 Italics and bold: multiple quote sequences: (3,4,2)
1004 !! options
1005 parsoid=wt2html
1006 !! wikitext
1007 '''foo''''bar''
1008 !! html/php
1009 <p><b>foo'</b>bar
1010 </p>
1011 !! html/parsoid
1012 <p><b>foo'</b>bar<i></i>
1013 </p>
1014 !! end
1015
1016 # same html as previous, but wikitext adjusted to match parsoid html2wt
1017 !! test
1018 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1019 !! wikitext
1020 '''foo''''bar''<nowiki/>''
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 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1030 !! test
1031 Italics and bold: multiple quote sequences: (3,4,3)
1032 !! options
1033 parsoid=wt2html
1034 !! wikitext
1035 '''foo''''bar'''
1036 !! html/php
1037 <p><b>foo'</b>bar
1038 </p>
1039 !! html/parsoid
1040 <p><b>foo'</b>bar<b></b>
1041 </p>
1042 !! end
1043
1044 # same html as previous, but wikitext adjusted to match parsoid html2wt
1045 !! test
1046 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1047 !! wikitext
1048 '''foo''''bar'''<nowiki/>'''
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 ###
1058 ### other quote tests
1059 ###
1060 !! test
1061 Italics and bold: other quote tests: (2,3,5)
1062 !! wikitext
1063 ''this is about '''foo's family'''''
1064 !! html
1065 <p><i>this is about <b>foo's family</b></i>
1066 </p>
1067 !!end
1068
1069
1070 !! test
1071 Italics and bold: other quote tests: (2,(3,3),2)
1072 !! wikitext
1073 ''this is about '''foo's''' family''
1074 !! html
1075 <p><i>this is about <b>foo's</b> family</i>
1076 </p>
1077 !!end
1078
1079
1080 !! test
1081 Italics and bold: other quote tests: (3,2,3,2)
1082 !! options
1083 parsoid=wt2html
1084 !! wikitext
1085 '''this is about ''foo'''s family''
1086 !! html/*
1087 <p><b>this is about <i>foo</i></b><i>s family</i>
1088 </p>
1089 !!end
1090
1091
1092 # same html as previous, but wikitext adjusted to match parsoid html2wt
1093 !! test
1094 Italics and bold: other quote tests: (3,2,3+2+2,2)
1095 !! wikitext
1096 '''this is about ''foo'''''<nowiki/>''s family''
1097 !! html
1098 <p><b>this is about <i>foo</i></b><i>s family</i>
1099 </p>
1100 !! end
1101
1102
1103 !! test
1104 Italics and bold: other quote tests: (3,2,3,3)
1105 !! wikitext
1106 '''this is about ''foo'''s family'''
1107 !! html/*
1108 <p>'<i>this is about </i>foo<b>s family</b>
1109 </p>
1110 !!end
1111
1112
1113 !! test
1114 Italics and bold: other quote tests: (3,(2,2),3)
1115 !! wikitext
1116 '''this is about ''foo's'' family'''
1117 !! html
1118 <p><b>this is about <i>foo's</i> family</b>
1119 </p>
1120 !!end
1121
1122
1123 !! test
1124 Italicized possessive
1125 !! wikitext
1126 The ''[[Main Page]]'''s talk page.
1127 !! html/php
1128 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1129 </p>
1130 !! html/parsoid
1131 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1132 !! end
1133
1134 !! test
1135 Parsoid only: Quote balancing context should be restricted to td/th cells on the same wikitext line
1136 (Requires tidy for PHP parser output to be fixed up)
1137 !! options
1138 parsoid=wt2html,wt2wt
1139 !! wikitext
1140 {|
1141 !''a!!''b
1142 |''a||''b
1143 |}
1144 !! html/php+tidy
1145 <table>
1146 <tr>
1147 <th><i>a</i></th>
1148 <th><i>b</i></th>
1149 <td><i>a</i></td>
1150 <td><i>b</i></td>
1151 </tr>
1152 </table>
1153 !! html/parsoid
1154 <table>
1155 <tbody><tr><th><i>a</i></th><th><i>b</i></th>
1156 <td><i>a</i></td><td><i>b</i></td></tr>
1157 </tbody></table>
1158 !! end
1159
1160 ###
1161 ### Non-html5 tags
1162 ###
1163
1164 !! test
1165 Non-html5 tags should be accepted
1166 !! wikitext
1167 <center>''foo''</center>
1168 <big>''foo''</big>
1169 <font>''foo''</font>
1170 <strike>''foo''</strike>
1171 <tt>''foo''</tt>
1172 !! html
1173 <center><i>foo</i></center>
1174 <p><big><i>foo</i></big>
1175 <font><i>foo</i></font>
1176 <strike><i>foo</i></strike>
1177 <tt><i>foo</i></tt>
1178 </p>
1179 !! end
1180
1181 !! test
1182 <wbr> is valid wikitext (T54468)
1183 !! wikitext
1184 <wbr>
1185 !! html
1186 <p><wbr />
1187 </p>
1188 !! end
1189
1190 # <strike> is HTML4, <s> is HTML4/5.
1191 !! test
1192 <s> or <strike> for strikethrough
1193 !! wikitext
1194 <strike>strike</strike>
1195
1196 <s>s</s>
1197 !! html
1198 <p><strike>strike</strike>
1199 </p><p><s>s</s>
1200 </p>
1201 !! end
1202
1203 ## a not permitted
1204 ## i,b,br omitted
1205 !! test
1206 Text-level semantic html elements in wikitext
1207 !! wikitext
1208 <em>text</em>
1209 <strong>text</strong>
1210 <small>text</small>
1211 <s>text</s>
1212 <cite>text</cite>
1213 <q>text</q>
1214 <dfn>text</dfn>
1215 <abbr>text</abbr>
1216 <data>text</data>
1217 <time>text</time>
1218 <code>text</code>
1219 <var>text</var>
1220 <samp>text</samp>
1221 <kbd>text</kbd>
1222 <sub>text</sub>
1223 <u>text</u>
1224 <mark>text</mark>
1225 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1226 <bdi>text</bdi>
1227 <bdo>text</bdo>
1228 <span>text</span>
1229 <wbr />
1230 !! html
1231 <p><em>text</em>
1232 <strong>text</strong>
1233 <small>text</small>
1234 <s>text</s>
1235 <cite>text</cite>
1236 <q>text</q>
1237 <dfn>text</dfn>
1238 <abbr>text</abbr>
1239 <data>text</data>
1240 <time>text</time>
1241 <code>text</code>
1242 <var>text</var>
1243 <samp>text</samp>
1244 <kbd>text</kbd>
1245 <sub>text</sub>
1246 <u>text</u>
1247 <mark>text</mark>
1248 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1249 <bdi>text</bdi>
1250 <bdo>text</bdo>
1251 <span>text</span>
1252 <wbr />
1253 </p>
1254 !! end
1255
1256 # test cases taken from
1257 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1258 !! test
1259 Ruby markup (W3C-style)
1260 !! wikitext
1261 ; Mono-ruby for individual base characters
1262 : <ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1263 ; Group ruby
1264 : <ruby>今日<rt>きょう</rt></ruby>
1265 ; Jukugo ruby
1266 : <ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1267 ; Inline ruby
1268 : <ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1269 ; Double-sided ruby
1270 : <ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1271 <ruby>
1272 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1273 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1274 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1275 </ruby>
1276 !! html
1277 <dl><dt> Mono-ruby for individual base characters</dt>
1278 <dd> <ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1279 <dt> Group ruby</dt>
1280 <dd> <ruby>今日<rt>きょう</rt></ruby></dd>
1281 <dt> Jukugo ruby</dt>
1282 <dd> <ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1283 <dt> Inline ruby</dt>
1284 <dd> <ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1285 <dt> Double-sided ruby</dt>
1286 <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>
1287 <p><ruby>
1288 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1289 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1290 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1291 </ruby>
1292 </p>
1293 !! end
1294
1295 # The next two test different paths in the sanitizer.
1296 !! test
1297 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1298 !! wikitext
1299 <blockquote|>a</blockquote>
1300
1301 <b→> doesn't terminate </b→>
1302
1303 <bä> doesn't terminate </bä>
1304
1305 <boo> doesn't terminate </boo>
1306
1307 <s.foo> doesn't terminate </s.foo>
1308
1309 <sub-ID#1>
1310 !! html
1311 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1312 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1313 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1314 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1315 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1316 </p><p>&lt;sub-ID#1&gt;
1317 </p>
1318 !! end
1319
1320 # There is a tidy bug here: https://sourceforge.net/p/tidy/bugs/946/
1321 # If the non-word-character tag made it through the sanitizer, tidy
1322 # would munge it up.
1323 !! test
1324 Non-word characters don't terminate tag names + tidy
1325 !! wikitext
1326 <blockquote|>a</blockquote>
1327
1328 <b→> doesn't terminate </b→>
1329
1330 <bä> doesn't terminate </bä>
1331
1332 <boo> doesn't terminate </boo>
1333
1334 <s.foo> doesn't terminate </s.foo>
1335
1336 <sub-ID#1>
1337 !! html+tidy
1338 <p>&lt;blockquote|&gt;a</p>
1339 <p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;</p>
1340 <p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;</p>
1341 <p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;</p>
1342 <p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;</p>
1343 <p>&lt;sub-ID#1&gt;</p>
1344 !! end
1345
1346 ###
1347 ### See tests/parser/parserTestsParserHook.php for the <tåg> extension)
1348 ### This checks that HTML5 tags (with non-word characters in the tag
1349 ### name) make it safely through the parser -- the Sanitizer will
1350 ### munge them later, as it should.
1351 ###
1352 !! test
1353 Non-word characters are valid in extension tags (T19663)
1354 !! wikitext
1355 <tåg>tåg</tåg>
1356 !! html/php
1357 <pre>
1358 'tåg'
1359 array (
1360 )
1361 </pre>
1362
1363 !! html/parsoid
1364 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1365 !! end
1366
1367 !! test
1368 Isolated close tags should be treated as literal text (T54760)
1369 !! options
1370 parsoid=wt2html
1371 !! wikitext
1372 </b>
1373
1374 <s.foo>s</s>
1375 !! html/php+tidy
1376 <p>&lt;s.foo&gt;s</p>
1377 !! html/parsoid
1378 <p>&lt;s.foo&gt;s</p>
1379 !! end
1380
1381 ###
1382 ### Special characters
1383 ###
1384
1385 !! test
1386 Bare pipe character (T54363)
1387 !! wikitext
1388 |
1389 !! html
1390 <p>|
1391 </p>
1392 !! end
1393
1394 !! test
1395 Bare pipe character from a template (T54363)
1396 !! wikitext
1397 {{pipe}}
1398 !! html
1399 <p>|
1400 </p>
1401 !! end
1402
1403 ###
1404 ### <nowiki> test cases
1405 ###
1406
1407 !! test
1408 <nowiki> unordered list
1409 !! wikitext
1410 <nowiki>* This is not an unordered list item.</nowiki>
1411 !! html/php
1412 <p>* This is not an unordered list item.
1413 </p>
1414 !! html/parsoid
1415 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1416 !! end
1417
1418 !! test
1419 <nowiki> spacing
1420 !! wikitext
1421 <nowiki>Lorem ipsum dolor
1422
1423 sed abit.
1424 sed nullum.
1425
1426 :and a colon
1427 </nowiki>
1428 !! html/php
1429 <p>Lorem ipsum dolor
1430
1431 sed abit.
1432 sed nullum.
1433
1434 :and a colon
1435
1436 </p>
1437 !! html/parsoid
1438 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1439
1440 sed abit.
1441 sed nullum.
1442
1443 :and a colon
1444 </span></p>
1445 !! end
1446
1447 !! test
1448 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1449 !! wikitext
1450 <nowiki><span class="error"></nowiki>
1451 !! html/php
1452 <p>&lt;span class="error"&gt;
1453 </p>
1454 !! html/parsoid
1455 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1456 !! end
1457
1458 !! test
1459 nowiki 3
1460 !! wikitext
1461 :There is not nowiki.
1462 :There is <nowiki>nowiki</nowiki>.
1463
1464 #There is not nowiki.
1465 #There is <nowiki>nowiki</nowiki>.
1466
1467 *There is not nowiki.
1468 *There is <nowiki>nowiki</nowiki>.
1469 !! html/php
1470 <dl><dd>There is not nowiki.</dd>
1471 <dd>There is nowiki.</dd></dl>
1472 <ol><li>There is not nowiki.</li>
1473 <li>There is nowiki.</li></ol>
1474 <ul><li>There is not nowiki.</li>
1475 <li>There is nowiki.</li></ul>
1476
1477 !! html/parsoid
1478 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1479 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1480
1481 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1482 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1483
1484 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1485 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1486 !! end
1487
1488 !! test
1489 Entities inside <nowiki>
1490 !! wikitext
1491 <nowiki>&lt;</nowiki>
1492 !! html/php
1493 <p>&lt;
1494 </p>
1495 !! html/parsoid
1496 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1497 !! end
1498
1499 !! test
1500 Entities inside template parameters
1501 !! wikitext
1502 {{echo|&ndash;}}
1503 !! html/php+tidy
1504 <p>–</p>
1505 !! html/parsoid
1506 <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>
1507 !! end
1508
1509 !! test
1510 Properly escape nowiki when combined with other wiki markup
1511 !! options
1512 parsoid=html2wt
1513 !! html/parsoid
1514 <p>* &lt;/nowiki&gt; tag</p>
1515 !! wikitext
1516 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1517 !! end
1518
1519 !! test
1520 T93824: Put escaped HTML tags inside nowiki
1521 !! options
1522 parsoid=html2wt
1523 !! html/parsoid
1524 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1525 !! wikitext
1526 <nowiki><h2>foo</h2></nowiki>
1527 !! end
1528
1529 !! test
1530 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1531 !! options
1532 parsoid=html2wt
1533 !! html/parsoid
1534 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1535 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1536 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1537 !! wikitext
1538 This text: L'[[Foo]]
1539 This text: L<nowiki>''</nowiki>[[Foo]]
1540 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1541 !! end
1542
1543 # This test fails because wikitext whitespace is not normalized before comparing.
1544 !! test
1545 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1546 !! options
1547 parsoid=html2wt
1548 !! html/parsoid
1549 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1550 </p>
1551 !! wikitext
1552 This text : L<nowiki>''</nowiki>[[Foo]]
1553 !! end
1554
1555 # This test and the next one are html2wt only as they test that incorrect wikitext
1556 # passed in template arguments gets escaped or wrapped in nowikis where required.
1557 !! test
1558 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1559 !! options
1560 parsoid=html2wt
1561 !! html/parsoid
1562 <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>
1563 <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>
1564 !! wikitext
1565 {{echo|foo{{!}}bar}}
1566 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1567 !! end
1568
1569 !! test
1570 T53961: Output correct nowikis in template arguments
1571 !! options
1572 parsoid=html2wt
1573 !! html/parsoid
1574 <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>
1575 <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>
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;a [[ b&quot;}},&quot;i&quot;:0}}]}" about="#mwt3"></span>
1577 <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>
1578 <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>
1579 !! wikitext
1580 {{echo|a [ b}}
1581 {{echo|<nowiki>a }} b</nowiki>}}
1582 {{echo|<nowiki>a [[ b</nowiki>}}
1583 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1584 {{echo|a <nowiki>}</nowiki>}}
1585 !! end
1586
1587 !! test
1588 Cases where "!!" needs nowiki protection
1589 !! options
1590 parsoid=html2wt
1591 !! html/parsoid
1592 <table>
1593 <tr><th>this needs protection !! here</th></tr>
1594 </table>
1595
1596 <table>
1597 <tr><th>this does not need
1598 protection !! here</th></tr>
1599 </table>
1600 !! wikitext
1601 {|
1602 !<nowiki>this needs protection !! here</nowiki>
1603 |}
1604
1605 {|
1606 !this does not need
1607 protection !! here
1608 |}
1609 !! end
1610
1611 ###
1612 ### Comments
1613 ###
1614 !! test
1615 Comments and Indent-Pre
1616 !! wikitext
1617 <!-- comment 1 --> asdf
1618
1619 <!-- comment 1 --> asdf
1620 <!-- comment 2 -->
1621
1622 <!-- comment 1 --> asdf
1623 <!-- comment 2 -->xyz
1624
1625 <!-- comment 1 --> asdf
1626 <!-- comment 2 --> xyz
1627 !! html
1628 <pre>asdf
1629 </pre>
1630 <pre>asdf
1631 </pre>
1632 <pre>asdf
1633 </pre>
1634 <p>xyz
1635 </p>
1636 <pre>asdf
1637 xyz
1638 </pre>
1639 !! end
1640
1641 !! test
1642 Comment test 2a
1643 !! wikitext
1644 asdf
1645 <!-- comment 1 -->
1646 jkl
1647 !! html
1648 <p>asdf
1649 jkl
1650 </p>
1651 !! end
1652
1653 !! test
1654 Comment test 2b
1655 !! wikitext
1656 asdf
1657 <!-- comment 1 -->
1658
1659 jkl
1660 !! html
1661 <p>asdf
1662 </p><p>jkl
1663 </p>
1664 !! end
1665
1666 !! test
1667 Comment test 3
1668 !! wikitext
1669 asdf
1670 <!-- comment 1 -->
1671 <!-- comment 2 -->
1672 jkl
1673 !! html
1674 <p>asdf
1675 jkl
1676 </p>
1677 !! end
1678
1679 !! test
1680 Comment test 4
1681 !! wikitext
1682 asdf<!-- comment 1 -->jkl
1683 !! html
1684 <p>asdfjkl
1685 </p>
1686 !! end
1687
1688 !! test
1689 Comment spacing
1690 !! wikitext
1691 a
1692 <!-- foo --> b <!-- bar -->
1693 c
1694 !! html
1695 <p>a
1696 </p>
1697 <pre> b
1698 </pre>
1699 <p>c
1700 </p>
1701 !! end
1702
1703 !! test
1704 Comment whitespace
1705 !! wikitext
1706 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1707 !! html
1708
1709 !! end
1710
1711 !! test
1712 Comment semantics and delimiters
1713 !! wikitext
1714 <!-- --><!----><!-----><!------>
1715 !! html/php
1716
1717 !! html/parsoid
1718 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1719 !! end
1720
1721 !! test
1722 Comment semantics and delimiters, redux
1723 !! wikitext
1724 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1725 -- foo -- funky huh? ... -->
1726 !! html/php
1727
1728 !! html/parsoid
1729 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1730 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1731 !! end
1732
1733 !! test
1734 Comment semantics and delimiters: directors cut
1735 !! wikitext
1736 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1737 everything starting with < followed by !-- until the first -- and > we see,
1738 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1739 -->-->
1740 !! html/php
1741 <p>--&gt;
1742 </p>
1743 !! html/parsoid
1744 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1745 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1746 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1747 --><p>--></p>
1748 !! end
1749
1750 !! test
1751 Comment semantics: nesting
1752 !! wikitext
1753 <!--<!-- no, we're not going to do anything fancy here -->-->
1754 !! html/php
1755 <p>--&gt;
1756 </p>
1757 !! html/parsoid
1758 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1759 !! end
1760
1761 # Parsoid closes the unclosed comment, even if it means a slight
1762 # round-trip diff.
1763 !! test
1764 Comment semantics: unclosed comment at end
1765 !! options
1766 parsoid=wt2html,html2html
1767 !! wikitext
1768 <!--This comment will run out to the end of the document
1769 !! html/php
1770
1771 !! html/parsoid
1772 <!--This comment will run out to the end of the document-->
1773 !! end
1774
1775 !! test
1776 Comment semantics: normalize comments to play nice with XML and browsers
1777 !! wikitext
1778 <!-- Browsers --!> think this is closed -->
1779 <!--> This would normally be text -->
1780 <!---> As would this -->
1781 <!-- XML doesn't like trailing dashes -------->
1782 <!-- Nor doubled hyphens -- anywhere in the data -->
1783 But this is not a comment.
1784 !! html/php
1785 <p>But this is not a comment.
1786 </p>
1787 !! html/parsoid
1788 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1789 <!--&#x3E; This would normally be text -->
1790 <!--&#x2D;&#x3E; As would this -->
1791 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1792 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1793 <p>But this is not a comment.</p>
1794 !! end
1795
1796 !! test
1797 Comment semantics: round-trip even text which contains encoded -->
1798 !! wikitext
1799 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1800 !! html/parsoid
1801 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1802 !! end
1803
1804 !! test
1805 Comment in template title
1806 !! wikitext
1807 {{f<!---->oo}}
1808 !! html
1809 <p>FOO
1810 </p>
1811 !! end
1812
1813 !! test
1814 Comment on its own line post-expand
1815 !! wikitext
1816 a
1817 {{blank}}<!---->
1818 b
1819 !! html
1820 <p>a
1821 </p><p>b
1822 </p>
1823 !! end
1824
1825 !! test
1826 Comment on its own line post-expand with non-significant whitespace
1827 !! wikitext
1828 a
1829 {{blank}} <!---->
1830 b
1831 !! html
1832 <p>a
1833 </p><p>b
1834 </p>
1835 !! end
1836
1837 !! test
1838 Multiple comments should still parse as SOL-transparent
1839 !! options
1840 parsoid=wt2html,wt2wt
1841 !! wikitext
1842 <!--c1-->*a
1843 <!--c2--><!--c3--><!--c4-->*b
1844 !! html/php
1845 <ul><li>a</li>
1846 <li>b</li></ul>
1847
1848 !! html/parsoid
1849 <!--c1--><ul>
1850 <li>a
1851 </li>
1852 <!--c2--><!--c3--><!--c4-->
1853 <li>b
1854 </li>
1855 </ul>
1856 !! end
1857
1858 ###
1859 ### paragraph wrapping tests
1860 ###
1861 !! test
1862 No block tags
1863 !! wikitext
1864 a
1865
1866 b
1867 !! html
1868 <p>a
1869 </p><p>b
1870 </p>
1871 !! end
1872
1873 !! test
1874 Block tag on one line (<div>)
1875 !! wikitext
1876 a <div>foo</div>
1877
1878 b
1879 !! html
1880 a <div>foo</div>
1881 <p>b
1882 </p>
1883 !! html+tidy
1884 <p>a</p>
1885 <div>foo</div>
1886 <p>b</p>
1887 !! end
1888
1889 !! test
1890 Block tag on one line (<blockquote>)
1891 !! wikitext
1892 a <blockquote>foo</blockquote>
1893
1894 b
1895 !! html
1896 a <blockquote>foo</blockquote>
1897 <p>b
1898 </p>
1899 !! html+tidy
1900 <p>a</p>
1901 <blockquote>
1902 <p>foo</p>
1903 </blockquote>
1904 <p>b</p>
1905 !! end
1906
1907 !! test
1908 Block tag on both lines (<div>)
1909 !! wikitext
1910 a <div>foo</div>
1911
1912 b <div>foo</div>
1913 !! html
1914 a <div>foo</div>
1915 b <div>foo</div>
1916
1917 !! html+tidy
1918 <p>a</p>
1919 <div>foo</div>
1920 <p>b</p>
1921 <div>foo</div>
1922 !! end
1923
1924 !! test
1925 Block tag on both lines (<blockquote>)
1926 !! wikitext
1927 a <blockquote>foo</blockquote>
1928
1929 b <blockquote>foo</blockquote>
1930 !! html
1931 a <blockquote>foo</blockquote>
1932 b <blockquote>foo</blockquote>
1933
1934 !! html+tidy
1935 <p>a</p>
1936 <blockquote>
1937 <p>foo</p>
1938 </blockquote>
1939 <p>b</p>
1940 <blockquote>
1941 <p>foo</p>
1942 </blockquote>
1943 !! end
1944
1945 !! test
1946 Multiple lines without block tags
1947 !! wikitext
1948 <div>foo</div> a
1949 b
1950 c
1951 d<!--foo--> e
1952 x <div>foo</div> z
1953 !! html
1954 <div>foo</div> a
1955 <p>b
1956 c
1957 d e
1958 </p>
1959 x <div>foo</div> z
1960
1961 !! html+tidy
1962 <div>foo</div>
1963 <p>a</p>
1964 <p>b c d e</p>
1965 <p>x</p>
1966 <div>foo</div>
1967 <p>z</p>
1968 !! end
1969
1970 # Tidy strips out the empty <div> tags. Parsoid doesn't.
1971 # So, we have a separate section for Parsoid. We don't want
1972 # to mimic this stripping behavior in Parsoid. It affects
1973 # editing experience and also requires us to maintain additional
1974 # info for RT-ing.
1975 !! test
1976 Empty lines between lines with block tags
1977 !! wikitext
1978 <div></div>
1979
1980
1981 <div></div>a
1982
1983 b
1984 <div>a</div>b
1985
1986 <div>b</div>d
1987
1988
1989 <div>e</div>
1990 !! html
1991 <div></div>
1992 <p><br />
1993 </p>
1994 <div></div>a
1995 <p>b
1996 </p>
1997 <div>a</div>b
1998 <div>b</div>d
1999 <p><br />
2000 </p>
2001 <div>e</div>
2002
2003 !! html+tidy
2004 <p><br /></p>
2005 <p>a</p>
2006 <p>b</p>
2007 <div>a</div>
2008 <p>b</p>
2009 <div>b</div>
2010 <p>d</p>
2011 <p><br /></p>
2012 <div>e</div>
2013 !! html/parsoid
2014 <div data-parsoid='{"stx":"html"}'></div>
2015
2016 <p><br /></p>
2017 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2018
2019 <p>b</p>
2020 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2021
2022 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2023
2024 <p><br /></p>
2025 <div data-parsoid='{"stx":"html"}'>e</div>
2026 !! end
2027
2028 ## PHP parser emits output which is broken
2029 !! test
2030 Unclosed HTML p-tags should be handled properly
2031 !! wikitext
2032 <div><p>foo</div>
2033 a
2034
2035 b
2036 !! html/php+tidy
2037 <div>
2038 <p>foo</p>
2039 </div>
2040 <p>a</p>
2041 <p>b</p>
2042 !! html/parsoid
2043 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2044 <p>a</p>
2045 <p>b</p>
2046 !! end
2047
2048 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2049 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2050 ## them for now.
2051 !! test
2052 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2053 !! options
2054 parsoid=wt2html
2055 !! wikitext
2056 a [[Category:A1]] [[Category:A2]]
2057 [[Category:A3]]
2058 [[Category:A4]]
2059 !! html/parsoid
2060 <p>a</p>
2061 <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"/>
2062 !! end
2063
2064 !! test
2065 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2066 !! options
2067 parsoid=wt2html
2068 !! wikitext
2069 [[Category:A1]]a
2070 !! html/parsoid
2071 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2072 !! end
2073
2074 ###
2075 ### Preformatted text
2076 ###
2077 !! test
2078 Preformatted text
2079 !! wikitext
2080 This is some
2081 Preformatted text
2082 With ''italic''
2083 And '''bold'''
2084 And a [[Main Page|link]]
2085 !! html
2086 <pre>This is some
2087 Preformatted text
2088 With <i>italic</i>
2089 And <b>bold</b>
2090 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2091 </pre>
2092 !! end
2093
2094 !! test
2095 Tabs don't trigger preformatted text
2096 !! wikitext
2097 This is not
2098 preformatted text.
2099 This is preformatted text.
2100 So is this.
2101 !! html/php
2102 <p> This is not
2103 preformatted text.
2104 </p>
2105 <pre>This is preformatted text.
2106 So is this.
2107 </pre>
2108 !! html/parsoid
2109 <p> This is not
2110 preformatted text.</p>
2111 <pre>This is preformatted text.
2112 So is this.</pre>
2113 !! end
2114
2115 !! test
2116 Space before tab needs nowiki pre protection
2117 !! options
2118 parsoid=html2wt
2119 !! html/parsoid
2120 <p> a</p>
2121 !! wikitext
2122 <nowiki> </nowiki> a
2123 !! end
2124
2125 !! test
2126 Ident preformatting with inline content
2127 !! wikitext
2128 a
2129 ''b''
2130 !! html
2131 <pre>a
2132 <i>b</i>
2133 </pre>
2134 !! end
2135
2136 !! test
2137 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2138 !! wikitext
2139 <pre><nowiki>
2140 <b>
2141 <cite>
2142 <em>
2143 </nowiki></pre>
2144 !! html
2145 <pre>
2146 &lt;b&gt;
2147 &lt;cite&gt;
2148 &lt;em&gt;
2149 </pre>
2150
2151 !! end
2152
2153 !! test
2154 Regression with preformatted in <center>
2155 !! wikitext
2156 <center>
2157 Blah
2158 </center>
2159 !! html
2160 <center>
2161 <pre>Blah
2162 </pre>
2163 </center>
2164
2165 !! end
2166
2167 !! test
2168 T54763: Preformatted in <blockquote>
2169 !! wikitext
2170 <blockquote>
2171 Blah
2172 {|
2173 |
2174 indented cell (no pre-wrapping!)
2175 |}
2176 </blockquote>
2177 !! html
2178 <blockquote>
2179 <p> Blah
2180 </p>
2181 <table>
2182 <tr>
2183 <td>
2184 <p> indented cell (no pre-wrapping!)
2185 </p>
2186 </td></tr></table>
2187 </blockquote>
2188
2189 !! end
2190
2191 !! test
2192 T53086: Double newlines in blockquotes should be turned into paragraphs
2193 !! wikitext
2194 <blockquote>
2195 Foo
2196
2197 Bar
2198 </blockquote>
2199 !! html
2200 <blockquote>
2201 <p>Foo
2202 </p><p>Bar
2203 </p>
2204 </blockquote>
2205
2206 !! end
2207
2208 !! test
2209 T17491: <ins>/<del> in blockquote
2210 !! wikitext
2211 <blockquote>
2212 Foo <del>bar</del> <ins>baz</ins> quux
2213 </blockquote>
2214 !! html
2215 <blockquote>
2216 <p>Foo <del>bar</del> <ins>baz</ins> quux
2217 </p>
2218 </blockquote>
2219
2220 !! end
2221
2222 # Note that the p-wrapping is newline sensitive, which could be
2223 # considered a bug: tidy will wrap only the 'Foo' in the example
2224 # below in a <p> tag. (see comment 23-25 of T8200)
2225 !! test
2226 T17491: <ins>/<del> in blockquote (2)
2227 !! wikitext
2228 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2229 </blockquote>
2230 !! html
2231 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2232 </blockquote>
2233
2234 !! html+tidy
2235 <blockquote>
2236 <p>Foo</p>
2237 <del>bar</del> <ins>baz</ins> quux</blockquote>
2238 !! end
2239
2240 !! test
2241 <pre> with attributes (T5202)
2242 !! wikitext
2243 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2244 !! html
2245 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2246
2247 !! end
2248
2249 !! test
2250 <pre> with width attribute (T5202)
2251 !! wikitext
2252 <pre width="8">Narrow screen goodies</pre>
2253 !! html
2254 <pre width="8">Narrow screen goodies</pre>
2255
2256 !! end
2257
2258 !! test
2259 <pre> with forbidden attribute (T5202)
2260 !! wikitext
2261 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2262 !! html
2263 <pre width="8">Narrow screen goodies</pre>
2264
2265 !! end
2266
2267 !! test
2268 Entities inside <pre>
2269 !! wikitext
2270 <pre>&lt;</pre>
2271 !! html
2272 <pre>&lt;</pre>
2273
2274 !! end
2275
2276 !! test
2277 <pre> with forbidden attribute values (T5202)
2278 !! wikitext
2279 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2280 !! html
2281 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2282
2283 !! end
2284
2285 !! test
2286 <nowiki> inside <pre> (T15238)
2287 !! wikitext
2288 <pre>
2289 <nowiki>
2290 </pre>
2291 <pre>
2292 <nowiki></nowiki>
2293 </pre>
2294 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2295 !! html
2296 <pre>
2297 &lt;nowiki&gt;
2298 </pre>
2299 <pre>
2300
2301 </pre>
2302 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2303
2304 !! end
2305
2306 !! test
2307 <nowiki> inside of #tag:pre
2308 !! wikitext
2309 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2310 !! html/php
2311 <pre>Foo &#8594;bar</pre>
2312
2313 !! html/parsoid
2314 <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>
2315 !! end
2316
2317 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2318 ## aren't enclosed in nowikis.
2319 !! test
2320 <nowiki> and <pre> preference (first one wins)
2321 !! options
2322 parsoid=wt2html
2323 !! wikitext
2324 <pre>
2325 <nowiki>
2326 </pre>
2327 </nowiki>
2328 </pre>
2329
2330 <nowiki>
2331 <pre>
2332 <nowiki>
2333 </pre>
2334 </nowiki>
2335 </pre>
2336
2337 !! html/php
2338 <pre>
2339 &lt;nowiki&gt;
2340 </pre>
2341 <p>&lt;/nowiki&gt;
2342 &lt;/pre&gt;
2343 </p><p>
2344 &lt;pre&gt;
2345 &lt;nowiki&gt;
2346 &lt;/pre&gt;
2347
2348 &lt;/pre&gt;
2349 </p>
2350 !! html/parsoid
2351 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2352 </pre>
2353 <p>&lt;/nowiki></p>
2354
2355
2356 <p><span typeof="mw:Nowiki">
2357 &lt;pre>
2358 &lt;nowiki>
2359 &lt;/pre>
2360 </span></p>
2361 !! end
2362
2363 !! test
2364 </pre> inside nowiki
2365 !! wikitext
2366 <nowiki></pre></nowiki>
2367 !! html
2368 <p>&lt;/pre&gt;
2369 </p>
2370 !! end
2371
2372 # Parsoid doesn't strip empty tags, like Tidy does.
2373 !! test
2374 Empty pre; pre inside other HTML tags (T56946)
2375 !! wikitext
2376 a
2377
2378 <div><pre>
2379 foo
2380 </pre></div>
2381 <pre></pre>
2382 !! html/php
2383 <p>a
2384 </p>
2385 <div><pre>
2386 foo
2387 </pre></div>
2388 <pre></pre>
2389
2390 !! html/php+tidy
2391 <p>a</p>
2392 <div>
2393 <pre>
2394 foo
2395 </pre></div>
2396 !! html/parsoid
2397 <p>a</p>
2398
2399 <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
2400 </pre></div>
2401 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2402 !! end
2403
2404 !! test
2405 HTML pre followed by indent-pre
2406 !! wikitext
2407 <pre>foo</pre>
2408 bar
2409 !! html
2410 <pre>foo</pre>
2411 <pre>bar
2412 </pre>
2413 !! end
2414
2415 # Note that tidy removes the empty <p> tags from the start and end.
2416 # Parsoid does not, by design.
2417 !! test
2418 Block tag pre
2419 !! wikitext
2420 <p><pre>foo</pre></p>
2421 !! html/php+tidy
2422 <pre>
2423 foo
2424 </pre>
2425 !! html/parsoid
2426 <p 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 data-parsoid='{"autoInsertedStart":true,"stx":"html"}'></p>
2427 !! end
2428
2429 !!test
2430 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2431 !! wikitext
2432 {{echo|}}
2433 !! html
2434
2435 !!end
2436
2437 !!test
2438 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2439 !! wikitext
2440 {{echo|
2441 foo}}
2442 !! html
2443 <p>foo
2444 </p>
2445 !!end
2446
2447 !! test
2448 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2449 !! wikitext
2450 {{echo|a
2451 b}}
2452 !! html
2453 <pre>a
2454 </pre>
2455 <p>b
2456 </p>
2457 !!end
2458
2459 !! test
2460 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2461 !! wikitext
2462 {{echo|a
2463 b
2464 c
2465 d
2466 e
2467 }}
2468 !! html
2469 <pre>a
2470 </pre>
2471 <p>b
2472 c
2473 </p>
2474 <pre>d
2475 </pre>
2476 <p>e
2477 </p>
2478 !!end
2479
2480 !!test
2481 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2482 !! wikitext
2483 {{echo| foo}}
2484
2485 {{echo| foo}}{{echo| bar}}
2486
2487 {{echo| foo}}
2488 {{echo| bar}}
2489
2490 {{echo|<!--cmt--> foo}}
2491
2492 <!--cmt-->{{echo| foo}}
2493
2494 {{echo|{{echo| }}bar}}
2495 !! html
2496 <pre>foo
2497 </pre>
2498 <pre>foo bar
2499 </pre>
2500 <pre>foo
2501 bar
2502 </pre>
2503 <pre>foo
2504 </pre>
2505 <pre>foo
2506 </pre>
2507 <pre>bar
2508 </pre>
2509 !!end
2510
2511 !! test
2512 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2513 !! wikitext
2514 {{echo| }}a
2515
2516 {{echo|
2517 }}a
2518
2519 {{echo|
2520 b}}
2521
2522 {{echo|a
2523 }}b
2524
2525 {{echo|a
2526 }} b
2527 !! html
2528 <pre>a
2529 </pre>
2530 <p><br />
2531 </p>
2532 <pre>a
2533 </pre>
2534 <p><br />
2535 </p>
2536 <pre>b
2537 </pre>
2538 <p>a
2539 </p>
2540 <pre>b
2541 </pre>
2542 <p>a
2543 </p>
2544 <pre>b
2545 </pre>
2546 !!end
2547
2548 ## Hmm, should Parsoid rt this?
2549 !! test
2550 Pres with newline attributes
2551 !! options
2552 parsoid=wt2html,html2html
2553 !! wikitext
2554 <pre class="one
2555 two">hi</pre>
2556 !! html/php
2557 <pre class="one two">hi</pre>
2558
2559 !! html/parsoid
2560 <pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2561 !! end
2562
2563 !! test
2564 Things that look like <pre> tags aren't treated as such
2565 !! wikitext
2566 Barack Obama <President> of the United States
2567 <President></President>
2568 !! html
2569 <p>Barack Obama &lt;President&gt; of the United States
2570 &lt;President&gt;&lt;/President&gt;
2571 </p>
2572 !! end
2573
2574 !! test
2575 Handle broken pre-like tags (T66025)
2576 !! options
2577 parsoid=wt2html
2578 !! wikitext
2579 {{echo|<pre <pre>x</pre>}}
2580
2581 <table><pre </table>
2582 !! html/php
2583 <pre>x</pre>
2584 <table>&lt;pre </table>
2585
2586 !! html/php+tidy
2587 <pre>
2588 x
2589 </pre>
2590 <p>&lt;pre</p>
2591 !! html/parsoid
2592 <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>
2593
2594
2595 <p>&lt;pre </p>
2596
2597 <table></table>
2598 !! end
2599
2600 !! test
2601 Parsoid: handle pre with space after attribute
2602 !! options
2603 parsoid=wt2html
2604 !! wikitext
2605 <pre style="width:50%;" >{{echo|foo}}</pre>
2606 !! html/php
2607 <pre style="width:50%;">{{echo|foo}}</pre>
2608
2609 !! html/parsoid
2610 <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>
2611 !! end
2612
2613 # TODO / maybe: fix wt2wt for this
2614 !! test
2615 Parsoid: Don't paragraph-wrap fosterable content
2616 !! options
2617 parsoid=wt2html
2618 !! wikitext
2619 {|
2620 <td></td>
2621 <td></td>
2622
2623
2624
2625 |}
2626 !! html
2627 <table>
2628
2629 <tbody>
2630 <tr>
2631 <td></td>
2632
2633 <td></td></tr>
2634
2635
2636
2637 </tbody></table>
2638 !! end
2639
2640 !! test
2641 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2642 !! options
2643 parsoid=wt2html
2644 !! wikitext
2645 {|
2646 <td>
2647 <td>
2648 </td>
2649
2650
2651
2652 |}
2653 !! html
2654 <table>
2655
2656 <tbody>
2657 <tr>
2658 <td></td>
2659
2660 <td>
2661 </td></tr>
2662
2663
2664
2665 </tbody></table>
2666 !! end
2667
2668
2669 #--------------------------------------------------------------------
2670 # Transclusion parameter whitespace stripping tests
2671 # Behavior is different for positional and named parameters
2672 #--------------------------------------------------------------------
2673 !! test
2674 Templates: Strip leading and trailing whitespace from named-param values
2675 !! wikitext
2676 {{echo|1= a }}
2677
2678 {{echo|1= {{echo|b}} }}
2679
2680 {{echo| 1 =
2681 c }}
2682
2683 {{echo| 1 =
2684 * d
2685 }}
2686 !! html
2687 <p>a
2688 </p><p>b
2689 </p><p>c
2690 </p>
2691 <ul><li> d</li></ul>
2692
2693 !! end
2694
2695 !! test
2696 Templates: Don't strip whitespace from positional-param values
2697 !! wikitext
2698 {{echo|a }}
2699
2700 {{echo|{{echo|b}} }}
2701
2702 {{echo| c
2703 }}
2704
2705 {{echo| {{echo|d}}
2706 }}
2707
2708 {{echo|
2709 e}}
2710
2711 {{echo|
2712 * f}}
2713
2714 {{echo|
2715 }}g
2716 !! html
2717 <p>a
2718 </p><p>b
2719 </p>
2720 <pre>c
2721 </pre>
2722 <p><br />
2723 </p>
2724 <pre>d
2725 </pre>
2726 <p><br />
2727 </p>
2728 <pre>e
2729 </pre>
2730 <p><br />
2731 </p>
2732 <ul><li> f</li></ul>
2733 <p><br />
2734 </p>
2735 <pre>g
2736 </pre>
2737 !! end
2738
2739 !! test
2740 Templates: Don't recognize targets split by newlines
2741 !! options
2742 parsoid=wt2html
2743 !! wikitext
2744 {{ech
2745 o|foo}}
2746 !! html/php
2747 <p>{{ech
2748 o|foo}}
2749 </p>
2750 !! html/parsoid
2751 <p>{{ech
2752 o|foo}}</p>
2753 !! end
2754
2755 !! test
2756 Templates: Recognize targets when newlines and comments don't split the target
2757 !! options
2758 parsoid=wt2html
2759 !! wikitext
2760 {{
2761 <!--X--> ech<!--X-->o<!--X-->
2762 <!--X--> <!--X-->
2763
2764 |foo}}
2765 !! html/php
2766 <p>foo
2767 </p>
2768 !! html/parsoid
2769 <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>
2770 !! end
2771
2772 !! test
2773 Templates: Handle empty comment-and-ws-only lines correctly
2774 !! wikitext
2775 {{echo|foo
2776 <!--should be ignored-->
2777 <!--should be ignored as well-->
2778 bar}}
2779 !! html/php
2780 <p>foo
2781 bar
2782 </p>
2783 !! html/parsoid
2784 <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>
2785 !! end
2786
2787 !! test
2788 Templates: Handle comments in the target
2789 !! wikitext
2790 {{echo
2791 <!-- should be ignored -->
2792 |foo}}
2793
2794 {{echo
2795 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
2796 |foo}}
2797
2798 {{echo<!-- should be ignored -->
2799 |foo}}
2800
2801 {{echo<!-- should be ignored -->|foo}}
2802
2803 {{<!-- should be ignored -->echo|foo}}
2804 !! html/php
2805 <p>foo
2806 </p><p>foo
2807 </p><p>foo
2808 </p><p>foo
2809 </p><p>foo
2810 </p>
2811 !! html/parsoid
2812 <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>
2813
2814 <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>
2815
2816 <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>
2817
2818 <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>
2819
2820 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
2821 !!end
2822
2823 !! test
2824 Templates: Handle comments in parameter names (T69657)
2825 !! wikitext
2826 {{echo|1
2827 <!-- should be ignored -->
2828 =foo}}
2829
2830 {{echo|
2831 <!-- should be ignored -->
2832 1 = foo}}
2833
2834 {{echo|1<!-- should be ignored -->=foo}}
2835
2836 {{echo|<!-- should be ignored -->1=foo}}
2837 !! html/php
2838 <p>foo
2839 </p><p>foo
2840 </p><p>foo
2841 </p><p>foo
2842 </p>
2843 !! html/parsoid
2844 <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>
2845
2846 <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>
2847
2848 <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>
2849
2850 <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>
2851 !!end
2852
2853 !! test
2854 Templates: Other wikitext in parameter names (T69657)
2855 !! wikitext
2856 {{echo|''1''=foo}}
2857 !! html/php
2858 <p>{{{1}}}
2859 </p>
2860 !! html/parsoid
2861 <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>
2862 !!end
2863
2864 #--------------------------------------------------------------------
2865 # Transclusion parameter escaping tests
2866 #--------------------------------------------------------------------
2867 !! test
2868 Templates: Parsoid parameter escaping test 1
2869 !! wikitext
2870 {{echo|[foo]|{{echo|[bar]}}}}
2871 !! html/php+tidy
2872 <p>[foo]</p>
2873 !! html/parsoid
2874 <p about="#mwt1" typeof="mw:Transclusion"
2875 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
2876 !! end
2877
2878 !! test
2879 Parsoid: Pipes in external links in template parameter
2880 !! wikitext
2881 {{echo|[{{echo|http://example.com}} link]}}
2882 !! html/php+tidy
2883 <p><a rel="nofollow" class="external text" href="http://example.com">link</a></p>
2884 !! html/parsoid
2885 <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>
2886 !! end
2887
2888 !! test
2889 Parsoid: pipe in transclusion parameter
2890 !! wikitext
2891 {{echo|http://foo.com/a&#124;b}}
2892 !! html/php+tidy
2893 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a></p>
2894 !! html/parsoid
2895 <p><a rel="mw:ExtLink" href="http://foo.com/a%7Cb" about="#mwt1"
2896 typeof="mw:Transclusion"
2897 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>
2898 !! end
2899
2900 !! test
2901 Parsoid: Pipe in external link target and content in template parameter
2902 !! options
2903 parsoid=html2wt,wt2wt
2904 !! wikitext
2905 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
2906 !! html/php+tidy
2907 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a|b</a></p>
2908 !! html/parsoid
2909 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
2910 typeof="mw:Transclusion"
2911 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
2912 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
2913 !! end
2914
2915 !! test
2916 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
2917 !! options
2918 parsoid
2919 !! wikitext
2920 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
2921 !! html
2922 <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>
2923 !! end
2924
2925 !! test
2926 Templates: Don't escape already nowiki-escaped text in template parameters
2927 !! options
2928 parsoid=html2wt,wt2wt
2929 !! wikitext
2930 {{echo|foo<nowiki>|</nowiki>bar}}
2931 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
2932 {{echo|<nowiki></nowiki>}}
2933 !! html/php+tidy
2934 <p>foo|bar &lt;div&gt;</p>
2935 !! html/parsoid
2936 <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>
2937 <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>
2938 <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>
2939 </p>
2940 !! end
2941
2942 ## T54824
2943 !! test
2944 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
2945 !! options
2946 parsoid=html2wt,wt2wt
2947 !! wikitext
2948 {{echo|{{echo|1=bar}}}}
2949 !! html/php+tidy
2950 <p>bar</p>
2951 !! html/parsoid
2952 <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>
2953 !! end
2954
2955 ## T58733
2956 !! test
2957 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
2958 !! wikitext
2959 {{echo|a : b}}
2960 !! html/php+tidy
2961 <p>a&#160;: b</p>
2962 !! html/parsoid
2963 <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>
2964 !! end
2965
2966 ## T73412
2967 !! test
2968 Templates: Preserve blank parameter names
2969 !! wikitext
2970 {{echo|=foo}}
2971 !! html/php+tidy
2972 <p>{{{1}}}</p>
2973 !! html/parsoid
2974 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
2975 !! end
2976
2977 !! test
2978 Templates: Preserve blank parameter names in other positions
2979 !! wikitext
2980 {{blank_param|bar|=foo}}
2981 !! html/php+tidy
2982 <p>bar foo</p>
2983 !! html/parsoid
2984 <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
2985 foo</p>
2986 !! end
2987
2988 ###
2989 ### Parsoid-centric tests for testing RT edge cases for pre
2990 ###
2991
2992 !!test
2993 1a. Indent-Pre and Comments
2994 !! wikitext
2995 a
2996 <!--a-->
2997 c
2998 !! html
2999 <pre>a
3000 </pre>
3001 <p>c
3002 </p>
3003 !!end
3004
3005 !!test
3006 1b. Indent-Pre and Comments
3007 !! wikitext
3008 a
3009 <!--a-->
3010 c
3011 !! html
3012 <pre>a
3013 </pre>
3014 <p>c
3015 </p>
3016 !!end
3017
3018 !!test
3019 1c. Indent-Pre and Comments
3020 !! wikitext
3021 <!--a--> a
3022
3023 <!--a--> a
3024 !! html
3025 <pre> a
3026 </pre>
3027 <pre> a
3028 </pre>
3029 !!end
3030
3031 !!test
3032 1d. Indent-Pre and Comments
3033 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3034 !! wikitext
3035 <!--a--> a
3036
3037 <!--b-->b
3038 !! html
3039 <pre>a
3040 </pre>
3041 <pre>b
3042 </pre>
3043 !!end
3044
3045 !!test
3046 2a. Indent-Pre and tables
3047 !! wikitext
3048 {|
3049 |-
3050 !h1!!h2
3051 |foo||bar
3052 |}
3053 !! html
3054 <table>
3055
3056 <tr>
3057 <th>h1</th>
3058 <th>h2
3059 </th>
3060 <td>foo</td>
3061 <td>bar
3062 </td></tr></table>
3063
3064 !!end
3065
3066 !!test
3067 2b. Indent-Pre and tables
3068 !! wikitext
3069 {|
3070 |-
3071 |foo
3072 |}
3073 !! html
3074 <table>
3075
3076 <tr>
3077 <td>foo
3078 </td></tr></table>
3079
3080 !!end
3081
3082 !!test
3083 2c. Indent-Pre and tables (T44252)
3084 !! wikitext
3085 {|
3086 |+ foo
3087 ! | bar
3088 |}
3089 !! html
3090 <table>
3091 <caption> foo
3092 </caption>
3093 <tr>
3094 <th> bar
3095 </th></tr></table>
3096
3097 !!end
3098
3099 !!test
3100 2d. Indent-Pre and tables
3101 !! wikitext
3102 a
3103 {|
3104 | b
3105 |}
3106 !! html/php
3107 <pre>a
3108 </pre>
3109 <table>
3110 <tr>
3111 <td> b
3112 </td></tr></table>
3113
3114 !! html/parsoid
3115 <pre>a</pre>
3116 <table>
3117 <tbody><tr><td> b</td></tr>
3118 </tbody></table>
3119 !!end
3120
3121 !!test
3122 2e. Indent-Pre and table-line syntax
3123 !! wikitext
3124 a
3125 | b
3126 | c
3127 !! html/php
3128 <pre>a
3129 | b
3130 | c
3131 </pre>
3132 !!end
3133
3134 !!test
3135 2f. Indent-pre started by table-line syntax
3136 !! wikitext
3137 a
3138 | b
3139 | c
3140 !! html/php
3141 <p>a
3142 </p>
3143 <pre>| b
3144 | c
3145 </pre>
3146 !! html/parsoid
3147 <p>a</p>
3148 <pre>
3149 | b
3150 | c</pre>
3151 !!end
3152
3153 !! test
3154 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3155 !! wikitext
3156 <table>
3157 <tr>
3158 <td>
3159 Text that should be rendered preformatted
3160 </td>
3161 </tr>
3162 </table>
3163 !! html
3164 <table>
3165 <tr>
3166 <td>
3167 <pre>Text that should be rendered preformatted
3168 </pre>
3169 </td>
3170 </tr>
3171 </table>
3172
3173 !! end
3174
3175 !!test
3176 3a. Indent-Pre and block tags (single-line html)
3177 !! wikitext
3178 a <p> foo </p>
3179 b <div> foo </div>
3180 c <blockquote> foo </blockquote>
3181 <span> foo </span>
3182 !! html
3183 a <p> foo </p>
3184 b <div> foo </div>
3185 c <blockquote> foo </blockquote>
3186 <pre><span> foo </span>
3187 </pre>
3188 !! html/parsoid
3189 <p>a </p><p data-parsoid='{"stx":"html"}'> foo </p>
3190 <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3191 <p>c </p><blockquote data-parsoid='{"stx":"html"}'> foo </blockquote>
3192 <pre><span> foo </span>
3193 </pre>
3194 !! html+tidy
3195 <p>a</p>
3196 <p>foo</p>
3197 <p>b</p>
3198 <div>foo</div>
3199 <p>c</p>
3200 <blockquote>
3201 <p>foo</p>
3202 </blockquote>
3203 <pre>
3204 <span> foo </span>
3205 </pre>
3206 !! end
3207
3208 !!test
3209 3b. Indent-Pre and block tags (multi-line html)
3210 !! wikitext
3211 a <span>foo</span>
3212 b <div> foo </div>
3213 !! html
3214 <pre>a <span>foo</span>
3215 </pre>
3216 b <div> foo </div>
3217
3218 !! html/parsoid
3219 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3220 b <div data-parsoid='{"stx":"html"}'> foo </div>
3221 !! html+tidy
3222 <pre>
3223 a <span>foo</span>
3224 </pre>
3225 <p>b</p>
3226 <div>foo</div>
3227 !!end
3228
3229 !!test
3230 3c. Indent-Pre and block tags (pre-content on separate line)
3231 !! wikitext
3232 <p>
3233 foo
3234 </p>
3235
3236 <div>
3237 foo
3238 </div>
3239
3240 <center>
3241 foo
3242 </center>
3243
3244 <blockquote>
3245 foo
3246 </blockquote>
3247
3248 <blockquote>
3249 <pre>
3250 foo
3251 </pre>
3252 </blockquote>
3253
3254 <table><tr><td>
3255 foo
3256 </td></tr></table>
3257
3258 <ul><li>
3259 foo
3260 </li></ul>
3261
3262 !! html
3263 <p>
3264 foo
3265 </p>
3266 <div>
3267 <pre>foo
3268 </pre>
3269 </div>
3270 <center>
3271 <pre>foo
3272 </pre>
3273 </center>
3274 <blockquote>
3275 <p> foo
3276 </p>
3277 </blockquote>
3278 <blockquote>
3279 <pre>
3280 foo
3281 </pre>
3282 </blockquote>
3283 <table><tr><td>
3284 <pre>foo
3285 </pre>
3286 </td></tr></table>
3287 <ul><li>
3288 foo
3289 </li></ul>
3290
3291 !!end
3292
3293 !! test
3294 4. Indent-Pre and extension tags
3295 !! wikitext
3296 a <tag />
3297 !! html/php
3298 a <pre>
3299 NULL
3300 array (
3301 )
3302 </pre>
3303
3304 !! html/parsoid
3305 a <pre typeof="mw:Extension/tag" about="#mwt2" data-parsoid='{}' data-mw='{"name":"tag","attrs":{},"body":null}'></pre>
3306 !! end
3307
3308 !! test
3309 5. Indent-Pre and html pre
3310 !! wikitext
3311 <pre class="123">hi</pre>
3312 !! html/php
3313 <pre class="123">hi</pre>
3314
3315 !! html/parsoid
3316 <pre typeof="mw:Extension/pre" about="#mwt2" class="123" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3317 !! end
3318
3319 !!test
3320 Render paragraphs when indent-pre is suppressed in blocklevels
3321 !! wikitext
3322 <blockquote>
3323 foo
3324
3325 bar
3326 </blockquote>
3327 !! html
3328 <blockquote>
3329 <p> foo
3330 </p><p> bar
3331 </p>
3332 </blockquote>
3333
3334 !!end
3335
3336 !!test
3337 4. Multiple spaces at start-of-line
3338 !! wikitext
3339 <p> foo </p>
3340 foo
3341 {|
3342 |foo
3343 |}
3344 !! html
3345 <p> foo </p>
3346 <pre> foo
3347 </pre>
3348 <table>
3349 <tr>
3350 <td>foo
3351 </td></tr></table>
3352
3353 !!end
3354
3355 ## NOTE: the leading white-space chars on empty line are significant
3356 !! test
3357 5a. White-space in indent-pre
3358 !! wikitext
3359 a<br />
3360
3361 b
3362 !! html
3363 <pre>a<br />
3364
3365 b
3366 </pre>
3367 !! end
3368
3369 ## NOTE: the leading white-space chars on empty line are significant
3370 !! test
3371 5b. White-space in indent-pre
3372 !! wikitext
3373 a
3374
3375 b
3376
3377
3378 c
3379 !! html
3380 <pre>a
3381
3382 b
3383
3384
3385 c
3386 </pre>
3387 !! end
3388
3389 !! test
3390 5c. White-space in indent-pre
3391 !! wikitext
3392 ''a''
3393 ''b''
3394 ''c''
3395 !! html
3396 <pre><i>a</i>
3397 <i>b</i>
3398 <i>c</i>
3399 </pre>
3400 !! end
3401
3402 !! test
3403 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3404 !! wikitext
3405 a
3406
3407 <!-- continue -->
3408 b
3409
3410 c
3411
3412 d
3413 !! html
3414 <pre>a
3415
3416 b
3417 </pre>
3418 <pre>c
3419
3420 </pre>
3421 <p>d
3422 </p>
3423 !! end
3424
3425 !! test
3426 7a. Indent-pre and category links
3427 !! options
3428 parsoid=wt2html,wt2wt
3429 !! wikitext
3430 [[Category:foo]] <!-- No pre-wrapping -->
3431 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3432 !! html/php+tidy
3433 !! html/parsoid
3434 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3435 <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 -->
3436 !! end
3437
3438 ## We used to, but no longer wt2wt this test since the default serializer
3439 ## will normalize all categories to serialize on their own line.
3440 ## This wikitext usage is going to be fairly uncommon in production and
3441 ## selser will take care of preserving formatting in those scenarios.
3442 !! test
3443 7b. Indent-pre and category links
3444 !! options
3445 parsoid=wt2html
3446 !! wikitext
3447 [[Category:foo]] a
3448 [[Category:foo]] {{echo|b}}
3449 !! html/parsoid
3450 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3451 <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>
3452 !! end
3453
3454 !! test
3455 Indent-Pre: Newlines in comments shouldn't affect sol state
3456 !! wikitext
3457 a <!--
3458 foo
3459 --> b
3460 !! html/php+tidy
3461 <p>a b</p>
3462 !! html/parsoid
3463 <p>a <!--
3464 foo
3465 --> b</p>
3466 !! end
3467
3468 ###
3469 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3470 ###
3471
3472 !!test
3473 HTML-pre: 1. embedded newlines
3474 !! wikitext
3475 <pre>foo</pre>
3476
3477 <pre>
3478 foo
3479 </pre>
3480
3481 <pre>
3482
3483 foo
3484 </pre>
3485
3486 <pre>
3487
3488
3489 foo
3490 </pre>
3491 !! html/php+tidy
3492 <pre>
3493 foo
3494 </pre>
3495 <pre>
3496 foo
3497 </pre>
3498 <pre>
3499
3500 foo
3501 </pre>
3502 <pre>
3503
3504
3505 foo
3506 </pre>
3507 !! html/parsoid
3508 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3509
3510 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3511 </pre>
3512
3513 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3514
3515 foo
3516 </pre>
3517
3518 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3519
3520
3521 foo
3522 </pre>
3523 !!end
3524
3525 !! test
3526 HTML-pre: big spaces
3527 !! wikitext
3528 <pre>
3529
3530
3531
3532
3533 haha
3534
3535
3536
3537
3538 haha
3539
3540
3541
3542
3543 </pre>
3544 !! html/php+tidy
3545 <pre>
3546
3547
3548
3549
3550 haha
3551
3552
3553
3554
3555 haha
3556
3557
3558
3559
3560 </pre>
3561 !! html/parsoid
3562 <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"}}'>
3563
3564
3565
3566
3567 haha
3568
3569
3570
3571
3572 haha
3573
3574
3575
3576
3577 </pre>
3578 !! end
3579
3580 !!test
3581 HTML-pre: 2: indented text
3582 !! wikitext
3583 <pre>
3584 foo
3585 </pre>
3586 !! html
3587 <pre>
3588 foo
3589 </pre>
3590
3591 !!end
3592
3593 !!test
3594 HTML-pre: 3: other wikitext
3595 !! wikitext
3596 <pre>
3597 * foo
3598 # bar
3599 = no-h =
3600 '' no-italic ''
3601 [[ NoLink ]]
3602 </pre>
3603 !! html/php
3604 <pre>
3605 * foo
3606 # bar
3607 = no-h =
3608 '' no-italic ''
3609 [[ NoLink ]]
3610 </pre>
3611
3612 !! html/parsoid
3613 <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
3614 # bar
3615 = no-h =
3616 '' no-italic ''
3617 [[ NoLink ]]
3618 </pre>
3619 !!end
3620
3621 ###
3622 ### Definition lists
3623 ###
3624 !! test
3625 Simple definition
3626 !! wikitext
3627 ; name : Definition
3628 !! html
3629 <dl><dt> name&#160;</dt>
3630 <dd> Definition</dd></dl>
3631
3632 !! end
3633
3634 !! test
3635 Definition list for indentation only
3636 !! wikitext
3637 : Indented text
3638 !! html
3639 <dl><dd> Indented text</dd></dl>
3640
3641 !! end
3642
3643 !! test
3644 Definition list with no space
3645 !! wikitext
3646 ;name:Definition
3647 !! html
3648 <dl><dt>name</dt>
3649 <dd>Definition</dd></dl>
3650
3651 !!end
3652
3653 !! test
3654 Definition list with URL link
3655 !! wikitext
3656 ; http://example.com/ : definition
3657 !! html
3658 <dl><dt> <a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&#160;</dt>
3659 <dd> definition</dd></dl>
3660
3661 !! end
3662
3663 !! test
3664 Definition list with bracketed URL link
3665 !! wikitext
3666 ;[http://www.example.com/ Example]:Something about it
3667 !! html
3668 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
3669 <dd>Something about it</dd></dl>
3670
3671 !! end
3672
3673 !! test
3674 Definition list with wikilink containing colon
3675 !! wikitext
3676 ; [[Help:FAQ]]: The least-read page on Wikipedia
3677 !! html
3678 <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>
3679 <dd> The least-read page on Wikipedia</dd></dl>
3680
3681 !! end
3682
3683 # At Brion's and JeLuF's insistence... :)
3684 !! test
3685 Definition list with news link containing colon
3686 !! wikitext
3687 ; news:alt.wikipedia.rox: This isn't even a real newsgroup!
3688 !! html/php
3689 <dl><dt> <a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
3690 <dd> This isn't even a real newsgroup!</dd></dl>
3691
3692 !! html/parsoid
3693 <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>
3694 !! end
3695
3696 !! test
3697 Malformed definition list with colon
3698 !! wikitext
3699 ; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
3700 !! html
3701 <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>
3702
3703 !! end
3704
3705 !! test
3706 Definition lists: colon in external link text
3707 !! wikitext
3708 ; [http://www.wikipedia2.org/ Wikipedia : The Next Generation]: OK, I made that up
3709 !! html
3710 <dl><dt> <a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia&#160;: The Next Generation</a></dt>
3711 <dd> OK, I made that up</dd></dl>
3712
3713 !! end
3714
3715 !! test
3716 Definition lists: colon in HTML attribute
3717 !! wikitext
3718 ;<b style="display: inline">bold</b>
3719 !! html
3720 <dl><dt><b style="display: inline">bold</b></dt></dl>
3721
3722 !! end
3723
3724 !! test
3725 Definition lists: self-closed tag
3726 !! wikitext
3727 ;one<br/>two : two-line fun
3728 !! html
3729 <dl><dt>one<br />two&#160;</dt>
3730 <dd> two-line fun</dd></dl>
3731
3732 !! end
3733
3734 !! test
3735 Definition lists: ignore colons inside tags
3736 !! wikitext
3737 ;one <b>two : tag <i>fun:</i>:</b>: def
3738 !! html
3739 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
3740 <dd> def</dd></dl>
3741
3742 !! end
3743
3744 !! test
3745 Definition lists: excess closed tags
3746 !! wikitext
3747 ;one</b>two : bad tag fun
3748 !! html/php+tidy
3749 <dl>
3750 <dt>onetwo&#160;</dt>
3751 <dd>bad tag fun</dd>
3752 </dl>
3753 !! html/parsoid
3754 <dl>
3755 <dt>onetwo</dt>
3756 <dd>bad tag fun</dd>
3757 </dl>
3758 !! end
3759
3760 !! test
3761 T13748: Literal closing tags
3762 !! wikitext
3763 <dl>
3764 <dt>test 1</dt>
3765 <dd>test test test test test</dd>
3766 <dt>test 2</dt>
3767 <dd>test test test test test</dd>
3768 </dl>
3769 !! html
3770 <dl>
3771 <dt>test 1</dt>
3772 <dd>test test test test test</dd>
3773 <dt>test 2</dt>
3774 <dd>test test test test test</dd>
3775 </dl>
3776
3777 !! end
3778
3779 !! test
3780 Definition and unordered list using wiki syntax nested in unordered list using html tags.
3781 !! wikitext
3782 <ul><li>
3783 ; term : description
3784 * unordered
3785 </li></ul>
3786 !! html
3787 <ul><li>
3788 <dl><dt> term&#160;</dt>
3789 <dd> description</dd></dl>
3790 <ul><li> unordered</li></ul>
3791 </li></ul>
3792
3793 !! end
3794
3795 !! test
3796 Definition list with empty definition and following paragraph
3797 !! wikitext
3798 ; term:
3799 Paragraph text
3800 !! html
3801 <dl><dt> term</dt>
3802 <dd></dd></dl>
3803 <p>Paragraph text
3804 </p>
3805 !! end
3806
3807 !! test
3808 Nested definition lists using html syntax
3809 !! wikitext
3810 <dl><dt>x</dt>
3811 <dd>a</dd>
3812 <dd>b</dd></dl>
3813 !! html
3814 <dl><dt>x</dt>
3815 <dd>a</dd>
3816 <dd>b</dd></dl>
3817
3818 !! end
3819
3820 !! test
3821 Definition Lists: No nesting: Multiple dd's
3822 !! wikitext
3823 ;x
3824 :a
3825 :b
3826 !! html
3827 <dl><dt>x</dt>
3828 <dd>a</dd>
3829 <dd>b</dd></dl>
3830
3831 !! end
3832
3833 !! test
3834 Definition Lists: Indentation: Regular
3835 !! wikitext
3836 :i1
3837 ::i2
3838 :::i3
3839 !! html
3840 <dl><dd>i1
3841 <dl><dd>i2
3842 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3843
3844 !! end
3845
3846 !! test
3847 Definition Lists: Indentation: Missing 1st level
3848 !! wikitext
3849 ::i2
3850 :::i3
3851 !! html
3852 <dl><dd><dl><dd>i2
3853 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3854
3855 !! end
3856
3857 !! test
3858 Definition Lists: Indentation: Multi-level indent
3859 !! wikitext
3860 :::i3
3861 !! html
3862 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
3863
3864 !! end
3865
3866 !! test
3867 Definition Lists: Hacky use to indent tables
3868 !! wikitext
3869 ::{|
3870 |foo
3871 |bar
3872 |}
3873 this text
3874 should be left alone
3875 !! html
3876 <dl><dd><dl><dd><table>
3877 <tr>
3878 <td>foo
3879 </td>
3880 <td>bar
3881 </td></tr></table></dd></dl></dd></dl>
3882 <p>this text
3883 should be left alone
3884 </p>
3885 !! end
3886
3887 !! test
3888 Definition Lists: Hacky use to indent tables, with comments (T65979)
3889 !! wikitext
3890 <!-- foo -->
3891 ::{|
3892 |foo
3893 |bar
3894 |}<!-- bar -->
3895 this text
3896 should be left alone
3897 !! html/parsoid
3898 <!-- foo -->
3899 <dl><dd><dl><dd><table><tr>
3900 <td>foo</td>
3901 <td>bar</td>
3902 </tr></table><!-- bar --></dd></dl></dd></dl>
3903 <p>this text
3904 should be left alone</p>
3905 !! end
3906
3907 !! test
3908 Definition Lists: Hacky use to indent tables, with comment before table
3909 !! wikitext
3910 ::<!-- foo -->{|
3911 |foo
3912 |}
3913 !! html/parsoid
3914 <dl><dd><dl><dd><!-- foo --><table><tr>
3915 <td>foo</td>
3916 </tr></table></dd></dl></dd></dl>
3917 !! end
3918
3919 # The trailing whitespace in this test is to catch a regression in
3920 # Parsoid after T54473.
3921 !! test
3922 Definition Lists: Hacky use to indent tables (WS-insensitive)
3923 !! wikitext
3924 : {|
3925 |a
3926 |}
3927 !! html/php
3928 <dl><dd><table>
3929 <tr>
3930 <td>a
3931 </td></tr></table></dd></dl>
3932
3933 !! html/parsoid
3934 <dl><dd> <table>
3935 <tbody><tr><td>a</td></tr>
3936 </tbody></table> </dd></dl>
3937 !! end
3938
3939 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
3940 ## as an empty dt item. It also ignores all but the last ";" when followed
3941 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
3942 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
3943 ## ";"s.
3944 ##
3945 ## Ex: ";;t2 ::d2" is transformed into:
3946 ##
3947 ## <dl>
3948 ## <dt>t2 </dt>
3949 ## <dd>
3950 ## <dl>
3951 ## <dt></dt>
3952 ## <dd>d2</dd>
3953 ## </dl>
3954 ## </dd>
3955 ## </dl>
3956 ##
3957 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
3958 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
3959 ##
3960 ## <dl>
3961 ## <dt>
3962 ## <dl>
3963 ## <dt>t2 </dt>
3964 ## <dd>:d2</dd>
3965 ## </dl>
3966 ## </dt>
3967 ## </dl>
3968 ##
3969 ## All Parsoid only definition list tests have this difference.
3970 ##
3971 ## See also: https://phabricator.wikimedia.org/T8569
3972 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
3973
3974 !! test
3975 Table / list interaction: indented table with lists in table contents
3976 !! wikitext
3977 :{|
3978 |-
3979 | a
3980 * b
3981 |-
3982 | c
3983 * d
3984 |}
3985 !! html
3986 <dl><dd><table>
3987
3988 <tr>
3989 <td> a
3990 <ul><li> b</li></ul>
3991 </td></tr>
3992 <tr>
3993 <td> c
3994 <ul><li> d</li></ul>
3995 </td></tr></table></dd></dl>
3996
3997 !! end
3998
3999 !!test
4000 Table / list interaction: lists nested in tables nested in indented lists
4001 !! wikitext
4002 :{|
4003 |
4004 :a
4005 :b
4006 |
4007 *c
4008 *d
4009 |}
4010
4011 *e
4012 *f
4013 !! html
4014 <dl><dd><table>
4015 <tr>
4016 <td>
4017 <dl><dd>a</dd>
4018 <dd>b</dd></dl>
4019 </td>
4020 <td>
4021 <ul><li>c</li>
4022 <li>d</li></ul>
4023 </td></tr></table></dd></dl>
4024 <ul><li>e</li>
4025 <li>f</li></ul>
4026
4027 !!end
4028
4029 !! test
4030 Definition Lists: Nesting: Multi-level (Parsoid only)
4031 !! options
4032 parsoid
4033 !! wikitext
4034 ;t1 :d1
4035 ;;t2 ::d2
4036 ;;;t3 :::d3
4037 !! html
4038 <dl>
4039 <dt>t1 </dt>
4040 <dd>d1</dd>
4041 <dt>
4042 <dl>
4043 <dt>t2 </dt>
4044 <dd>:d2</dd>
4045 <dt>
4046 <dl>
4047 <dt>t3 </dt>
4048 <dd>::d3</dd>
4049 </dl>
4050 </dt>
4051 </dl>
4052 </dt>
4053 </dl>
4054
4055
4056 !! end
4057
4058
4059 !! test
4060 Definition Lists: Nesting: Test 2 (Parsoid only)
4061 !! wikitext
4062 ;t1
4063 ::d2
4064 !! html/php+tidy
4065 <dl>
4066 <dt>t1</dt>
4067 <dd>
4068 <dl>
4069 <dd>d2</dd>
4070 </dl>
4071 </dd>
4072 </dl>
4073 !! html/parsoid
4074 <dl>
4075 <dt>t1</dt>
4076 <dd>
4077 <dl>
4078 <dd>d2</dd>
4079 </dl>
4080 </dd>
4081 </dl>
4082
4083 !! end
4084
4085
4086 !! test
4087 Definition Lists: Nesting: Test 3 (Parsoid only)
4088 !! wikitext
4089 :;t1
4090 ::::d2
4091 !! html/php+tidy
4092 <dl>
4093 <dd>
4094 <dl>
4095 <dt>t1</dt>
4096 <dd>
4097 <dl>
4098 <dd>
4099 <dl>
4100 <dd>d2</dd>
4101 </dl>
4102 </dd>
4103 </dl>
4104 </dd>
4105 </dl>
4106 </dd>
4107 </dl>
4108 !! html/parsoid
4109 <dl>
4110 <dd>
4111 <dl>
4112 <dt>t1</dt>
4113 <dd>
4114 <dl>
4115 <dd>
4116 <dl>
4117 <dd>d2</dd>
4118 </dl>
4119 </dd>
4120 </dl>
4121 </dd>
4122 </dl>
4123 </dd>
4124 </dl>
4125
4126 !! end
4127
4128
4129 !! test
4130 Definition Lists: Nesting: Test 4
4131 !! wikitext
4132 ::;t3
4133 :::d3
4134 !! html
4135 <dl><dd><dl><dd><dl><dt>t3</dt>
4136 <dd>d3</dd></dl></dd></dl></dd></dl>
4137
4138 !! end
4139
4140
4141 ## The Parsoid team believes the following three test exposes a
4142 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4143 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4144 ## It also exposes a "misfeature" in tidy, which doesn't like
4145 ## <dl> tags with a single <dt> child; it converts the <dt> into
4146 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4147 !! test
4148 Definition Lists: Mixed Lists: Test 1
4149 !! wikitext
4150 :;* foo
4151 ::* bar
4152 :; baz
4153 !! html/php
4154 <dl><dd><dl><dt><ul><li> foo</li>
4155 <li> bar</li></ul></dt></dl>
4156 <dl><dt> baz</dt></dl></dd></dl>
4157
4158 !! html/php+tidy
4159 <dl>
4160 <dd>
4161 <dl>
4162 <dd>
4163 <ul>
4164 <li>foo</li>
4165 <li>bar</li>
4166 </ul>
4167 </dd>
4168 </dl>
4169 <dl>
4170 <dt>baz</dt>
4171 </dl>
4172 </dd>
4173 </dl>
4174 !! html/parsoid
4175 <dl>
4176 <dd><dl>
4177 <dt><ul>
4178 <li> foo
4179 </li>
4180 </ul></dt>
4181 <dd><ul>
4182 <li> bar
4183 </li>
4184 </ul></dd>
4185 <dt> baz</dt>
4186 </dl></dd>
4187 </dl>
4188 !! end
4189
4190 !! test
4191 Definition Lists: Mixed Lists: Test 2
4192 !! wikitext
4193 *: d1
4194 *: d2
4195 !! html
4196 <ul><li><dl><dd> d1</dd>
4197 <dd> d2</dd></dl></li></ul>
4198
4199 !! end
4200
4201
4202 !! test
4203 Definition Lists: Mixed Lists: Test 3
4204 !! wikitext
4205 *::: d1
4206 *::: d2
4207 !! html
4208 <ul><li><dl><dd><dl><dd><dl><dd> d1</dd>
4209 <dd> d2</dd></dl></dd></dl></dd></dl></li></ul>
4210
4211 !! end
4212
4213
4214 !! test
4215 Definition Lists: Mixed Lists: Test 4
4216 !! wikitext
4217 *;d1 :d2
4218 *;d3 :d4
4219 !! html
4220 <ul><li><dl><dt>d1&#160;</dt>
4221 <dd>d2</dd>
4222 <dt>d3&#160;</dt>
4223 <dd>d4</dd></dl></li></ul>
4224
4225 !! end
4226
4227
4228 !! test
4229 Definition Lists: Mixed Lists: Test 5
4230 !! wikitext
4231 *:d1
4232 *:: d2
4233 !! html
4234 <ul><li><dl><dd>d1
4235 <dl><dd> d2</dd></dl></dd></dl></li></ul>
4236
4237 !! end
4238
4239
4240 !! test
4241 Definition Lists: Mixed Lists: Test 6
4242 !! wikitext
4243 #*:d1
4244 #*::: d3
4245 !! html
4246 <ol><li><ul><li><dl><dd>d1
4247 <dl><dd><dl><dd> d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4248
4249 !! end
4250
4251
4252 !! test
4253 Definition Lists: Mixed Lists: Test 7
4254 !! wikitext
4255 :* d1
4256 :* d2
4257 !! html
4258 <dl><dd><ul><li> d1</li>
4259 <li> d2</li></ul></dd></dl>
4260
4261 !! end
4262
4263
4264 !! test
4265 Definition Lists: Mixed Lists: Test 8
4266 !! wikitext
4267 :* d1
4268 ::* d2
4269 !! html
4270 <dl><dd><ul><li> d1</li></ul>
4271 <dl><dd><ul><li> d2</li></ul></dd></dl></dd></dl>
4272
4273 !! end
4274
4275
4276 !! test
4277 Definition Lists: Mixed Lists: Test 9
4278 !! wikitext
4279 *;foo :bar
4280 !! html
4281 <ul><li><dl><dt>foo&#160;</dt>
4282 <dd>bar</dd></dl></li></ul>
4283
4284 !! end
4285
4286
4287 !! test
4288 Definition Lists: Mixed Lists: Test 10
4289 !! wikitext
4290 *#;foo :bar
4291 !! html
4292 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4293 <dd>bar</dd></dl></li></ol></li></ul>
4294
4295 !! end
4296
4297 # The Parsoid team disagrees with the PHP parser's seemingly-random
4298 # rules regarding dd/dt on the next two tests. Parsoid is more
4299 # consistent, and recognizes the shared nesting and keeps the
4300 # still-open tags around until the nesting is complete.
4301 # (And tidy again converts <dt> to <dd> before 'bar'.)
4302
4303 !! test
4304 Definition Lists: Mixed Lists: Test 11
4305 !! wikitext
4306 *#*#;*;;foo :bar
4307 *#*#;boo :baz
4308 !! html/php
4309 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4310 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4311 <dl><dt>boo&#160;</dt>
4312 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4313
4314 !! html/php+tidy
4315 <ul>
4316 <li>
4317 <ol>
4318 <li>
4319 <ul>
4320 <li>
4321 <ol>
4322 <li>
4323 <dl>
4324 <dt>foo&#160;</dt>
4325 <dd>
4326 <ul>
4327 <li>
4328 <dl>
4329 <dd>
4330 <dl>
4331 <dt>bar</dt>
4332 </dl>
4333 </dd>
4334 </dl>
4335 </li>
4336 </ul>
4337 </dd>
4338 </dl>
4339 <dl>
4340 <dt>boo&#160;</dt>
4341 <dd>baz</dd>
4342 </dl>
4343 </li>
4344 </ol>
4345 </li>
4346 </ul>
4347 </li>
4348 </ol>
4349 </li>
4350 </ul>
4351 !! html/parsoid
4352 <ul>
4353 <li>
4354 <ol>
4355 <li>
4356 <ul>
4357 <li>
4358 <ol>
4359 <li>
4360 <dl>
4361 <dt>
4362 <ul>
4363 <li>
4364 <dl>
4365 <dt>
4366 <dl>
4367 <dt>foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4368 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4369 </dl></dt>
4370 </dl></li>
4371 </ul></dt>
4372 <dt>boo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4373 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4374 </dl></li>
4375 </ol></li>
4376 </ul></li>
4377 </ol></li>
4378 </ul>
4379 !! end
4380
4381
4382 # Another case where tidy converts a <dt> to a <dd> (but Parsoid doesn't).
4383 # From whitelist:
4384 # * The test is wrong, there are two colons where there should be :;
4385 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4386 !! test
4387 Definition Lists: Weird Ones: Test 1
4388 !! wikitext
4389 *#;*::;; foo : bar (who uses this?)
4390 !! html/php
4391 <ul><li><ol><li><dl><dt> foo&#160;</dt>
4392 <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>
4393
4394 !! html/php+tidy
4395 <ul>
4396 <li>
4397 <ol>
4398 <li>
4399 <dl>
4400 <dt>foo&#160;</dt>
4401 <dd>
4402 <ul>
4403 <li>
4404 <dl>
4405 <dd>
4406 <dl>
4407 <dd>
4408 <dl>
4409 <dd>
4410 <dl>
4411 <dt>bar (who uses this?)</dt>
4412 </dl>
4413 </dd>
4414 </dl>
4415 </dd>
4416 </dl>
4417 </dd>
4418 </dl>
4419 </li>
4420 </ul>
4421 </dd>
4422 </dl>
4423 </li>
4424 </ol>
4425 </li>
4426 </ul>
4427 !! html/parsoid
4428 <ul>
4429 <li>
4430 <ol>
4431 <li>
4432 <dl>
4433 <dt>
4434 <ul>
4435 <li>
4436 <dl>
4437 <dd>
4438 <dl>
4439 <dd>
4440 <dl>
4441 <dt>
4442 <dl>
4443 <dt> foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span></dt>
4444 <dd data-parsoid='{"stx":"row"}'> bar (who uses this?)</dd>
4445 </dl></dt>
4446 </dl></dd>
4447 </dl></dd>
4448 </dl></li>
4449 </ul></dt>
4450 </dl></li>
4451 </ol></li>
4452 </ul>
4453 !! end
4454
4455 !! test
4456 Definition Lists: colons occurring in tags
4457 !! wikitext
4458 ;a:b
4459 ;'''a:b'''
4460 ;<i>a:b</i>
4461 ;<span>a:b</span>
4462 ;<div>a:b</div>
4463 ;<div>a
4464 :b</div>
4465 ;{{echo|a:b}}
4466 ;{{echo|''a:b''}}
4467 ;;;''a:b''
4468 !! html+tidy
4469 <dl>
4470 <dt>a</dt>
4471 <dd>b</dd>
4472 <dt><b>a:b</b></dt>
4473 <dt><i>a:b</i></dt>
4474 <dt><span>a:b</span></dt>
4475 <dd>
4476 <div>a:b</div>
4477 </dd>
4478 <dd>
4479 <div>a
4480 <dl>
4481 <dd>b</dd>
4482 </dl>
4483 </div>
4484 </dd>
4485 <dt>a</dt>
4486 <dd>b</dd>
4487 <dt><i>a:b</i></dt>
4488 </dl>
4489 <dl>
4490 <dd>
4491 <dl>
4492 <dd>
4493 <dl>
4494 <dt><i>a:b</i></dt>
4495 </dl>
4496 </dd>
4497 </dl>
4498 </dd>
4499 </dl>
4500 !! html/parsoid
4501 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4502 <dt><b>a:b</b></dt>
4503 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4504 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4505 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4506 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4507 <dd>b</dd>
4508 <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>
4509 <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>
4510 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4511 !! end
4512
4513 !! test
4514 Definition Lists: colons and tables 1
4515 !! wikitext
4516 :{|
4517 | x
4518 |}
4519 :{|
4520 | y
4521 |}
4522 !! html
4523 <dl><dd><table>
4524 <tr>
4525 <td> x
4526 </td></tr></table></dd></dl>
4527 <dl><dd><table>
4528 <tr>
4529 <td> y
4530 </td></tr></table></dd></dl>
4531
4532 !! end
4533
4534 # Parsoid's output (as documented below) differs from php's in this case.
4535 # This is probably a bug. If we fixup parsoid to match php's output, the
4536 # above test should pass and the below test case can be removed. It is
4537 # unclear which output is more desirable.
4538
4539 !! test
4540 Definition Lists: colons and tables 2
4541 !! wikitext
4542 :{|
4543 | x
4544 |}
4545 :{|
4546 | y
4547 |}
4548 !! html/parsoid
4549 <dl><dd><table>
4550 <tr>
4551 <td> x
4552 </td></tr></table></dd>
4553 <dd><table>
4554 <tr>
4555 <td> y
4556 </td></tr></table></dd></dl>
4557 !! end
4558
4559 !! test
4560 Definition Lists: template interaction
4561 !! wikitext
4562 ::{{definition_list}}
4563
4564 :one
4565 ::{{definition_list}}
4566 :::two
4567 :::three
4568 ::four
4569 !! html/parsoid
4570 <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">
4571 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4572
4573 <dl><dd data-parsoid='{}'>one
4574 <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">
4575 </span><dd about="#mwt2">two
4576 <dl><dd>two</dd>
4577 <dd>three</dd></dl></dd>
4578 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4579 !! end
4580
4581
4582 ###
4583 ### External links
4584 ###
4585 !! test
4586 External links: non-bracketed
4587 !! wikitext
4588 Non-bracketed: http://example.com
4589 !! html
4590 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4591 </p>
4592 !! end
4593
4594 # parsoid doesn't explicitly mark autonumbered links, see T55505
4595 !! test
4596 External links: numbered
4597 !! wikitext
4598 Numbered: [http://example.com]
4599 Numbered: [http://example.net]
4600 Numbered: [http://example.com]
4601 !! html/php
4602 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4603 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4604 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4605 </p>
4606 !! html/parsoid
4607 <p>Numbered: <a rel="mw:ExtLink" href="http://example.com"></a>
4608 Numbered: <a rel="mw:ExtLink" href="http://example.net"></a>
4609 Numbered: <a rel="mw:ExtLink" href="http://example.com"></a></p>
4610 !!end
4611
4612 !! test
4613 External links: specified text
4614 !! wikitext
4615 Specified text: [http://example.com link]
4616 !! html
4617 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4618 </p>
4619 !!end
4620
4621 !! test
4622 External links: trail
4623 !! wikitext
4624 Linktrails should not work for external links: [http://example.com link]s
4625 !! html
4626 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4627 </p>
4628 !! end
4629
4630 !! test
4631 External links: dollar sign in URL
4632 !! wikitext
4633 http://example.com/1$2345
4634 !! html
4635 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4636 </p>
4637 !! end
4638
4639 # parsoid doesn't explicitly mark autonumbered links, see T55505
4640 !! test
4641 External links: dollar sign in URL (autonumber)
4642 !! wikitext
4643 [http://example.com/1$2345]
4644 !! html/php
4645 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4646 </p>
4647 !! html/parsoid
4648 <p><a rel="mw:ExtLink" href="http://example.com/1$2345"></a></p>
4649 !!end
4650
4651 !! test
4652 External links: open square bracket forbidden in URL (T6377)
4653 !! options
4654 parsoid=wt2html,wt2wt,html2html
4655 !! wikitext
4656 http://example.com/1[2345
4657 !! html/php
4658 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4659 </p>
4660 !! html/parsoid
4661 <p><a rel="mw:ExtLink" href="http://example.com/1">http://example.com/1</a>[2345</p>
4662 !! end
4663
4664 !! test
4665 External links: open square bracket forbidden in URL (named) (T6377)
4666 !! options
4667 parsoid=wt2html,html2html
4668 !! wikitext
4669 [http://example.com/1[2345]
4670 !! html/php
4671 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4672 </p>
4673 !! html/parsoid
4674 <p><a rel="mw:ExtLink" href="http://example.com/1">[2345</a></p>
4675 !!end
4676
4677 # parsoid adds a space before the link name
4678 !! test
4679 External links: open square bracket forbidden in URL (named) (T6377)
4680 Parsoid variant.
4681 !! wikitext
4682 [http://example.com/1 [2345]
4683 !! html
4684 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4685 </p>
4686 !!end
4687
4688 !! test
4689 External links: nowiki in URL link text (T8230)
4690 !! wikitext
4691 [http://example.com/ <nowiki>''example site''</nowiki>]
4692 !! html
4693 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4694 </p>
4695 !! end
4696
4697 !! test
4698 External links: newline forbidden in text (T8230 regression check)
4699 !! wikitext
4700 [http://example.com/ first
4701 second]
4702 !! html
4703 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4704 second]
4705 </p>
4706 !!end
4707
4708 !! test
4709 External links: Pipe char between url and text
4710 !! wikitext
4711 [http://example.com | link]
4712 !! html
4713 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4714 </p>
4715 !!end
4716
4717 !! test
4718 External links: protocol-relative URL in brackets
4719 !! wikitext
4720 [//example.com/ Test]
4721 !! html
4722 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4723 </p>
4724 !! end
4725
4726 # parsoid doesn't explicitly mark autonumbered links, see T55505
4727 !! test
4728 External links: protocol-relative URL in brackets without text
4729 !! wikitext
4730 [//example.com]
4731 !! html/php
4732 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
4733 </p>
4734 !! html/parsoid
4735 <p><a rel="mw:ExtLink" href="//example.com"></a></p>
4736 !! end
4737
4738 !! test
4739 External links: protocol-relative URL in free text is left alone
4740 !! wikitext
4741 //example.com/Foo
4742 !! html
4743 <p>//example.com/Foo
4744 </p>
4745 !!end
4746
4747 !! test
4748 External links: protocol-relative URL in the middle of a word is left alone (T32269)
4749 !! wikitext
4750 foo//example.com/Foo
4751 !! html
4752 <p>foo//example.com/Foo
4753 </p>
4754 !! end
4755
4756 !! test
4757 External links: with no contents
4758 !! wikitext
4759 [http://en.wikipedia.org/wiki/Foo]
4760
4761 [[wikipedia:Foo|Bar]]
4762
4763 [[wikipedia:Foo|<span>Bar</span>]]
4764 !! html/php
4765 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
4766 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
4767 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
4768 </p>
4769 !! html/parsoid
4770 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo"></a></p>
4771 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
4772 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
4773 !! end
4774
4775 !! test
4776 External links: Free with trailing punctuation
4777 !! wikitext
4778 http://example.com,
4779 http://example.com;
4780 http://example.com\
4781 http://example.com.
4782 http://example.com:
4783 http://example.com!
4784 http://example.com?
4785 http://example.com)
4786 http://example.com/url_with_(brackets)
4787 (http://example.com/url_without_brackets)
4788 http://example.com/url_with_entity&amp;
4789 http://example.com/url_with_entity&#x26;
4790 http://example.com/url_with_entity&#038;
4791 http://example.com/url_with_entity&nbsp;
4792 http://example.com/url_with_entity&#xA0;
4793 http://example.com/url_with_entity&#160;
4794 http://example.com/url_with_entity&lt;
4795 http://example.com/url_with_entity&#x3C;
4796 http://example.com/url_with_entity&#60;
4797 !! html/php
4798 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
4799 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
4800 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
4801 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.
4802 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
4803 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>!
4804 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>?
4805 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
4806 <a rel="nofollow" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4807 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4808 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4809 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4810 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4811 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4812 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
4813 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4814 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
4815 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
4816 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
4817 </p>
4818 !! html/parsoid
4819 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a>,
4820 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>;
4821 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>\
4822 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>.
4823 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:
4824 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>!
4825 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>?
4826 <a rel="mw:ExtLink" href="http://example.com">http://example.com</a>)
4827 <a rel="mw:ExtLink" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4828 (<a rel="mw:ExtLink" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4829 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4830 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4831 <a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4832 <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>
4833 <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>
4834 <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>
4835 <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>
4836 <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>
4837 <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>
4838 !! end
4839
4840 !! test
4841 External links: tricky Parsoid html2html case
4842 !! options
4843 parsoid=wt2html,wt2wt,html2html
4844 !! wikitext
4845 http://example.com/url_with_entity&amp;amp;
4846 !! html/php
4847 <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>;
4848 </p>
4849 !! html/parsoid
4850 <p><a rel="mw:ExtLink" href="http://example.com/url_with_entity&amp;amp">http://example.com/url_with_entity&amp;amp</a>;</p>
4851 !! end
4852
4853 !! test
4854 External links: Free with trailing quotes (T113666)
4855 !! wikitext
4856 '''News:''' Stuff here
4857
4858 news:'a'b''c''d e
4859 !! html/php
4860 <p><b>News:</b> Stuff here
4861 </p><p><a rel="nofollow" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e
4862 </p>
4863 !! html/parsoid
4864 <p><b>News:</b> Stuff here</p>
4865 <p><a rel="mw:ExtLink" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
4866 !! end
4867
4868 !! test
4869 External links: with entity
4870 !! wikitext
4871 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
4872 !! html/php
4873 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
4874 </p>
4875 !! html/parsoid
4876 <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>
4877 !! end
4878
4879 !! test
4880 External links: Lone protocols are never linked (T105697)
4881 !! wikitext
4882 http://
4883 http://;
4884 (http://)
4885 bitcoin:
4886 bitcoin:;
4887 (bitcoin:)
4888 !! html
4889 <p>http://
4890 http://;
4891 (http://)
4892 bitcoin:
4893 bitcoin:;
4894 (bitcoin:)
4895 </p>
4896 !! end
4897
4898 !! test
4899 External links: No preceding word characters allowed (T67278)
4900 !! wikitext
4901 NOPEhttp://example.com
4902 N0http://example.com
4903 ok:http://example.com
4904 ok-http://example.com
4905 !! html
4906 <p>NOPEhttp://example.com
4907 N0http://example.com
4908 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4909 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4910 </p>
4911 !! end
4912
4913 !! test
4914 External links: nofollow domain exception
4915 !! wikitext
4916 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
4917 !! html
4918 <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>.
4919 </p>
4920 !!end
4921
4922 !! test
4923 External image
4924 !! wikitext
4925 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4926 !! html
4927 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
4928 </p>
4929 !! end
4930
4931 !! test
4932 External image from https
4933 !! wikitext
4934 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4935 !! html
4936 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
4937 </p>
4938 !! end
4939
4940 !! test
4941 External image (when not allowed)
4942 !! options
4943 wgAllowExternalImages=0
4944 !! wikitext
4945 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4946 !! html
4947 <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>
4948 </p>
4949 !! end
4950
4951 !! test
4952 Link to non-http image, no img tag
4953 !! wikitext
4954 Link to non-http image, no img tag: ftp://example.com/test.jpg
4955 !! html
4956 <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>
4957 </p>
4958 !! end
4959
4960 !! test
4961 External links: terminating separator
4962 !! wikitext
4963 Terminating separator: http://example.com/thing,
4964 !! html
4965 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
4966 </p>
4967 !! end
4968
4969 !! test
4970 External links: intervening separator
4971 !! wikitext
4972 Intervening separator: http://example.com/1,2,3
4973 !! html
4974 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
4975 </p>
4976 !! end
4977
4978 !! test
4979 External links: old bug with URL in query
4980 !! wikitext
4981 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
4982 !! html
4983 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
4984 </p>
4985 !! end
4986
4987 !! test
4988 External links: old URL-in-URL bug, mixed protocols
4989 !! wikitext
4990 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
4991 !! html
4992 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
4993 </p>
4994 !!end
4995
4996 # Since Parsoid is starting to emit canonical wikitext for links,
4997 # [http://example.com http://example.com] will not RT back to that
4998 # form anymore.
4999 !! test
5000 External links: URL in text
5001 !! options
5002 parsoid=wt2html
5003 !! wikitext
5004 URL in text: [http://example.com http://example.com]
5005 !! html/php
5006 <p>URL in text: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5007 </p>
5008 !! html/parsoid
5009 <p>URL in text: <a rel="mw:ExtLink" href="http://example.com">http://example.com</a></p>
5010 !! end
5011
5012 !! test
5013 External links: Clickable images
5014 !! wikitext
5015 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5016 !! html/php
5017 <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>
5018 </p>
5019 !! html/parsoid
5020 <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>
5021 !! end
5022
5023 !! test
5024 External links: raw ampersand
5025 !! wikitext
5026 Old &amp; use: http://x&y
5027 !! html
5028 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5029 </p>
5030 !! end
5031
5032 !! test
5033 External links: encoded ampersand
5034 !! wikitext
5035 Old &amp; use: http://x&amp;y
5036 !! html/php
5037 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5038 </p>
5039 !! html/parsoid
5040 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y">http://x&amp;y</a></p>
5041 !! end
5042
5043 !! test
5044 External links: encoded equals (T8102)
5045 !! wikitext
5046 http://example.com/?foo&#61;bar
5047 !! html/php
5048 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5049 </p>
5050 !! html/parsoid
5051 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5052 !! end
5053
5054 ##
5055 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5056 ## does it number them. As discussed in T55505, we can identify
5057 ## autonumbered links via CSS.
5058 ##
5059
5060 !! test
5061 External links: [raw ampersand]
5062 !! wikitext
5063 Old &amp; use: [http://x&y]
5064 !! html/php
5065 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5066 </p>
5067 !! html/parsoid
5068 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y"></a></p>
5069 !! end
5070
5071 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5072 # mode will return the [raw ampersand] wikitext
5073 !! test
5074 External links: [encoded ampersand]
5075 !! options
5076 parsoid=wt2html,wt2wt,html2html
5077 !! wikitext
5078 Old &amp; use: [http://x&amp;y]
5079 !! html/php
5080 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5081 </p>
5082 !! html/parsoid
5083 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" href="http://x&amp;y"></a></p>
5084 !! end
5085
5086 !! test
5087 External links: [raw equals]
5088 !! wikitext
5089 [http://example.com/?foo=bar]
5090 !! html/php
5091 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5092 </p>
5093 !! html/parsoid
5094 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar"></a></p>
5095 !! end
5096
5097 # note that parsoid html is identical to [raw equals] case; so html2wt
5098 # mode will return the [raw equals] wikitext
5099 !! test
5100 External links: [encoded equals] (T8102)
5101 !! options
5102 parsoid=wt2html,wt2wt,html2html
5103 !! wikitext
5104 [http://example.com/?foo&#61;bar]
5105 !! html/php
5106 <p><a rel="nofollow" class="external autonumber" href="http://example.com/?foo=bar">[1]</a>
5107 </p>
5108 !! html/parsoid
5109 <p><a rel="mw:ExtLink" href="http://example.com/?foo=bar"></a></p>
5110 !! end
5111
5112 # xxx parsoid strips the IDN character, so the round-trip tests will
5113 # obviously fail and are disabled. --cscott
5114 !! test
5115 External links: [IDN ignored character reference in hostname; strip it right off]
5116 !! options
5117 parsoid=wt2html,wt2wt,html2html
5118 !! wikitext
5119 [http://e&zwnj;xample.com/]
5120 !! html/php
5121 <p><a rel="nofollow" class="external autonumber" href="http://example.com/">[1]</a>
5122 </p>
5123 !! html/parsoid
5124 <p><a rel="mw:ExtLink" href="http://example.com/"></a></p>
5125 !! end
5126
5127 # FIXME: This test (the IDN characters in the text of a link) is an inconsistency.
5128 # Where an external link could easily circumvent the sanitization of the text of
5129 # a link like this (where an IDN-ignore character is in the URL somewhere), this
5130 # test demands a higher standard. That's a bit strange.
5131 #
5132 # Example:
5133 #
5134 # http://e‌xample.com -> [http://example.com|http://example.com]
5135 # [http://example.com|http://e‌xample.com] -> [http://example.com|http://e‌xample.com]
5136 #
5137 # The first example is sanitized, but the second is not. Any security benefits
5138 # from this production are trivial to circumvent. Either remove this test and
5139 # let the parser(s) do their thing unaccosted, or fix the inconsistency and change
5140 # the test accordingly.
5141 #
5142 # All our love,
5143 # The Parsoid team.
5144 # xxx parsoid strips the IDN character, so the round-trip tests will
5145 # obviously fail and are disabled. --cscott
5146 !! test
5147 External links: IDN ignored character reference in hostname; strip it right off
5148 !! options
5149 parsoid=wt2html,html2html
5150 !! wikitext
5151 http://e&zwnj;xample.com/
5152 !! html/php
5153 <p><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>
5154 </p>
5155 !! html/parsoid
5156 <p><a rel="mw:ExtLink" href="http://example.com/">http://example.com/</a></p>
5157 !! end
5158
5159 !! test
5160 External links: www.jpeg.org (T2554)
5161 !! wikitext
5162 http://www.jpeg.org
5163 !! html
5164 <p><a rel="nofollow" class="external free" href="http://www.jpeg.org">http://www.jpeg.org</a>
5165 </p>
5166 !! end
5167
5168 # parsoid doesn't explicitly mark autonumbered links, see T55505
5169 !! test
5170 External links: URL within URL (T2002)
5171 !! wikitext
5172 [http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp]
5173 !! html/php
5174 <p><a rel="nofollow" class="external autonumber" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp">[1]</a>
5175 </p>
5176 !! html/parsoid
5177 <p><a rel="mw:ExtLink" href="http://www.unausa.org/newindex.asp?place=http://www.unausa.org/programs/mun.asp"></a></p>
5178 !! end
5179
5180 !! test
5181 T2361: URL inside bracketed URL
5182 !! wikitext
5183 [http://www.example.com/foo http://www.example.com/bar]
5184 !! html
5185 <p><a rel="nofollow" class="external text" href="http://www.example.com/foo">http://www.example.com/bar</a>
5186 </p>
5187 !! end
5188
5189 !! test
5190 T2361: URL within URL, not bracketed
5191 !! wikitext
5192 http://www.example.com/foo?=http://www.example.com/bar
5193 !! html
5194 <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>
5195 </p>
5196 !! end
5197
5198 !! test
5199 T2289: ">"-token in URL-tail
5200 !! wikitext
5201 http://www.example.com/<hello>
5202 !! html
5203 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>&lt;hello&gt;
5204 </p>
5205 !!end
5206
5207 !! test
5208 T2289: literal ">"-token in URL-tail
5209 !! wikitext
5210 http://www.example.com/<b>html</b>
5211 !! html/php
5212 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a><b>html</b>
5213 </p>
5214 !! html/parsoid
5215 <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>
5216 !! end
5217
5218 !! test
5219 T2289: ">"-token in bracketed URL
5220 !! wikitext
5221 [http://www.example.com/<hello> stuff]
5222 !! html
5223 <p><a rel="nofollow" class="external text" href="http://www.example.com/">&lt;hello&gt; stuff</a>
5224 </p>
5225 !!end
5226
5227 !! test
5228 T2289: literal ">"-token in bracketed URL
5229 !! wikitext
5230 [http://www.example.com/<b>html</b> stuff]
5231 !! html
5232 <p><a rel="nofollow" class="external text" href="http://www.example.com/"><b>html</b> stuff</a>
5233 </p>
5234 !!end
5235
5236 !! test
5237 T2289: literal double quote at end of URL
5238 !! wikitext
5239 http://www.example.com/"hello"
5240 !! html
5241 <p><a rel="nofollow" class="external free" href="http://www.example.com/">http://www.example.com/</a>"hello"
5242 </p>
5243 !!end
5244
5245 !! test
5246 T2289: literal double quote in bracketed URL
5247 !! wikitext
5248 [http://www.example.com/"hello" stuff]
5249 !! html
5250 <p><a rel="nofollow" class="external text" href="http://www.example.com/">"hello" stuff</a>
5251 </p>
5252 !!end
5253
5254 !! test
5255 External links: multiple legal whitespace is fine, Magnus. Don't break it please. (T7081)
5256 !! wikitext
5257 [http://www.example.com test]
5258 !! html
5259 <p><a rel="nofollow" class="external text" href="http://www.example.com">test</a>
5260 </p>
5261 !! end
5262
5263 !! test
5264 External links: link text with spaces
5265 !! wikitext
5266 [http://www.example.com a b c]
5267 [http://www.example.com ''a'' ''b'']
5268 !! html
5269 <p><a rel="nofollow" class="external text" href="http://www.example.com">a b c</a>
5270 <a rel="nofollow" class="external text" href="http://www.example.com"><i>a</i> <i>b</i></a>
5271 </p>
5272 !! end
5273
5274 !! test
5275 External links: wiki links within external link (T5695)
5276 !! options
5277 parsoid=wt2html,html2html
5278 !! wikitext
5279 [http://example.com [[wikilink]] embedded in ext link]
5280 !! html/php
5281 <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>
5282 </p>
5283 !! html/parsoid
5284 <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>
5285 !! end
5286
5287 !! test
5288 T2787: Links with one slash after the url protocol are invalid
5289 !! wikitext
5290 http:/example.com
5291
5292 [http:/example.com title]
5293 !! html
5294 <p>http:/example.com
5295 </p><p>[http:/example.com title]
5296 </p>
5297 !! end
5298
5299 !! test
5300 Bracketed external links with template-generated invalid target
5301 !! wikitext
5302 [{{echo|http:/example.com}} title]
5303 !! html
5304 <p>[http:/example.com title]
5305 </p>
5306 !! end
5307
5308 # wt2html only because Parsoid would want to add <nowiki>s coming from html
5309 !! test
5310 Broken wikilinks (but not external links) prevent templates from closing
5311 !! options
5312 parsoid=wt2html
5313 !! wikitext
5314 [http://example.com x
5315
5316 {{echo|[http://example.com x}}
5317
5318 [[Foo
5319
5320 {{echo|[[Foo}}
5321 !! html/php
5322 <p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5323 </p><p>[<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> x
5324 </p><p>[[Foo
5325 </p><p>{{echo|[[Foo}}
5326 </p>
5327 !! html/parsoid
5328 <p>[<a rel="mw:ExtLink" href="http://example.com">http://example.com</a> x</p>
5329 <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>
5330 <p>[[Foo</p>
5331 <p>{{echo|[[Foo}}</p>
5332 !! end
5333
5334 !! test
5335 Wikilinks with embedded newlines are not broken
5336 !! wikitext
5337 {{echo|[[ Foo
5338 B
5339 C]]}}
5340 !! html/php
5341 <p>[[ Foo
5342 B
5343 C]]
5344 </p>
5345 !! html/parsoid
5346 <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>
5347 !! end
5348
5349 !! test
5350 Broken templates
5351 !! options
5352 parsoid=wt2html
5353 !! wikitext
5354 {{echo|[[Foo|}}]]
5355
5356 [[Foo|{{echo|]]}}
5357 !! html/php
5358 <p>{{echo|<a href="/wiki/Foo" title="Foo">}}</a>
5359 </p><p>[[Foo|]]
5360 </p>
5361 !! html/parsoid
5362 <p>{{echo|<a rel="mw:WikiLink" href="./Foo" title="Foo">}}</a></p>
5363 <p>[[Foo|<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"]]"}},"i":0}}]}'>]]</span></p>
5364 !! end
5365
5366 !! test
5367 T4702: Mismatched <i>, <b> and <a> tags are invalid
5368 !! wikitext
5369 ''[http://example.com text'']
5370 [http://example.com '''text]'''
5371 ''Something [http://example.com in italic'']
5372 ''Something [http://example.com mixed''''', even bold]'''
5373 '''''Now [http://example.com both''''']
5374 !! html
5375 <p><a rel="nofollow" class="external text" href="http://example.com"><i>text</i></a>
5376 <a rel="nofollow" class="external text" href="http://example.com"><b>text</b></a>
5377 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>in italic</i></a>
5378 <i>Something </i><a rel="nofollow" class="external text" href="http://example.com"><i>mixed</i><b>, even bold</b></a>
5379 <i><b>Now </b></i><a rel="nofollow" class="external text" href="http://example.com"><i><b>both</b></i></a>
5380 </p>
5381 !! end
5382
5383
5384 !! test
5385 T6781: %26 in URL
5386 !! wikitext
5387 http://www.example.com/?title=AT%26T
5388 !! html/php
5389 <p><a rel="nofollow" class="external free" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a>
5390 </p>
5391 !! html/parsoid
5392 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T">http://www.example.com/?title=AT%26T</a></p>
5393 !! end
5394
5395 # According to https://www.w3.org/TR/2011/WD-html5-20110525/Overview.html#parsing-urls a plain
5396 # % is actually legal in HTML5. Any change in output would need testing though.
5397 !! test
5398 T6781, T7267: %25 in URL
5399 !! wikitext
5400 http://www.example.com/?title=100%25_Bran
5401 !! html/php
5402 <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>
5403 </p>
5404 !! html/parsoid
5405 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=100%25_Bran">http://www.example.com/?title=100%25_Bran</a></p>
5406 !! end
5407
5408 !! test
5409 T6781, T7267: %28, %29 in URL
5410 !! wikitext
5411 http://www.example.com/?title=Ben-Hur_%281959_film%29
5412 !! html/php
5413 <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>
5414 </p>
5415 !! html/parsoid
5416 <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>
5417 !! end
5418
5419
5420 !! test
5421 T6781: %26 in autonumber URL
5422 !! wikitext
5423 [http://www.example.com/?title=AT%26T]
5424 !! html/php
5425 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=AT%26T">[1]</a>
5426 </p>
5427 !! html/parsoid
5428 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T"></a></p>
5429 !! end
5430
5431 !! test
5432 T6781, T7267: %26 in autonumber URL
5433 !! wikitext
5434 [http://www.example.com/?title=100%25_Bran]
5435 !! html/php
5436 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=100%25_Bran">[1]</a>
5437 </p>
5438 !! html/parsoid
5439 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=100%25_Bran"></a></p>
5440 !! end
5441
5442 !! test
5443 T6781, T7267: %28, %29 in autonumber URL
5444 !! wikitext
5445 [http://www.example.com/?title=Ben-Hur_%281959_film%29]
5446 !! html/php
5447 <p><a rel="nofollow" class="external autonumber" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">[1]</a>
5448 </p>
5449 !! html/parsoid
5450 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29"></a></p>
5451 !! end
5452
5453
5454 !! test
5455 T6781: %26 in bracketed URL
5456 !! wikitext
5457 [http://www.example.com/?title=AT%26T link]
5458 !! html/php
5459 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=AT%26T">link</a>
5460 </p>
5461 !! html/parsoid
5462 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=AT%26T">link</a></p>
5463 !! end
5464
5465 !! test
5466 T6781, T7267: %25 in bracketed URL
5467 !! wikitext
5468 [http://www.example.com/?title=100%25_Bran link]
5469 !! html
5470 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=100%25_Bran">link</a>
5471 </p>
5472 !! end
5473
5474 !! test
5475 T6781, T7267: %28, %29 in bracketed URL
5476 !! wikitext
5477 [http://www.example.com/?title=Ben-Hur_%281959_film%29 link]
5478 !! html/php
5479 <p><a rel="nofollow" class="external text" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a>
5480 </p>
5481 !! html/parsoid
5482 <p><a rel="mw:ExtLink" href="http://www.example.com/?title=Ben-Hur_%281959_film%29">link</a></p>
5483 !! end
5484
5485 !! test
5486 External link containing a period in the anchor. (T65947)
5487 !! wikitext
5488 [//foo.org/bar#baz. bang]
5489
5490 [//foo.org/bar. bang]
5491 !! html/php
5492 <p><a rel="nofollow" class="external text" href="//foo.org/bar#baz.">bang</a>
5493 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar.">bang</a>
5494 </p>
5495 !! html/parsoid
5496 <p><a rel="mw:ExtLink" href="//foo.org/bar#baz.">bang</a></p>
5497 <p><a rel="mw:ExtLink" href="//foo.org/bar.">bang</a></p>
5498 !! end
5499
5500 !! test
5501 External link containing a single quote. (T65947)
5502 !! wikitext
5503 [//foo.org/bar'baz]
5504
5505 [//foo.org/bar'baz bang]
5506 !! html/php
5507 <p><a rel="nofollow" class="external autonumber" href="//foo.org/bar'baz">[1]</a>
5508 </p><p><a rel="nofollow" class="external text" href="//foo.org/bar'baz">bang</a>
5509 </p>
5510 !! html/parsoid
5511 <p><a rel="mw:ExtLink" href="//foo.org/bar'baz"></a></p>
5512 <p><a rel="mw:ExtLink" href="//foo.org/bar'baz">bang</a></p>
5513 !! end
5514
5515 !! test
5516 External link containing double-single-quotes in text '' (T6598 sanity check)
5517 !! wikitext
5518 Some [http://example.com/ pretty ''italics'' and stuff]!
5519 !! html
5520 <p>Some <a rel="nofollow" class="external text" href="http://example.com/">pretty <i>italics</i> and stuff</a>!
5521 </p>
5522 !! end
5523
5524 !! test
5525 External link containing double-single-quotes in text embedded in italics (T6598 sanity check)
5526 !! wikitext
5527 ''Some [http://example.com/ pretty ''italics'' and stuff]!''
5528 !! html
5529 <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>
5530 </p>
5531 !! end
5532
5533 !! test
5534 External link containing double-single-quotes with no space separating the url from text in italics
5535 !! wikitext
5536 [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]].]
5537 !! html/php
5538 <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>
5539 </p>
5540 !! html/php+tidy
5541 <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>
5542 !! html/parsoid
5543 <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>
5544 !! end
5545
5546 !! test
5547 External link with comments in link text
5548 !! wikitext
5549 [http://www.google.com Google <!-- comment -->]
5550 !! html/php
5551 <p><a rel="nofollow" class="external text" href="http://www.google.com">Google </a>
5552 </p>
5553 !! html/parsoid
5554 <p><a rel="mw:ExtLink" href="http://www.google.com">Google <!-- comment --></a></p>
5555 !! end
5556
5557 !! test
5558 External link to bare IPv4 address
5559 !! wikitext
5560 [http://192.168.0.1 Link]
5561 !! html/php
5562 <p><a rel="nofollow" class="external text" href="http://192.168.0.1">Link</a>
5563 </p>
5564 !! html/parsoid
5565 <p><a rel="mw:ExtLink" href="http://192.168.0.1">Link</a></p>
5566 !! end
5567
5568 !! test
5569 URL-encoding in URL functions (single parameter)
5570 !! wikitext
5571 {{localurl:Some page|amp=&}}
5572 !! html
5573 <p>/index.php?title=Some_page&amp;amp=&amp;
5574 </p>
5575 !! end
5576
5577 !! test
5578 URL-encoding in URL functions (multiple parameters)
5579 !! wikitext
5580 {{localurl:Some page|q=?&amp=&}}
5581 !! html
5582 <p>/index.php?title=Some_page&amp;q=?&amp;amp=&amp;
5583 </p>
5584 !! end
5585
5586 !! test
5587 Brackets in urls
5588 !! wikitext
5589 http://example.com/index.php?foozoid%5B%5D=bar
5590
5591 http://example.com/index.php?foozoid&#x5B;&#x5D;=bar
5592 !! html/php
5593 <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>
5594 </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>
5595 </p>
5596 !! html/parsoid
5597 <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>
5598
5599 <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>
5600 !! end
5601
5602 !! test
5603 IPv6 urls, autolink format (T23261)
5604 !! wikitext
5605 http://[2404:130:0:1000::187:2]/index.php
5606
5607 Examples from RFC 2373, section 2.2:
5608 * http://[1080::8:800:200C:417A]/unicast
5609 * http://[FF01::101]/multicast
5610 * http://[::1]/loopback
5611 * http://[::]/unspecified
5612 * http://[::13.1.68.3]/ipv4compat
5613 * http://[::FFFF:129.144.52.38]/ipv4compat
5614
5615 Examples from RFC 2732, section 2:
5616 * http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html
5617 * http://[1080:0:0:0:8:800:200C:417A]/index.html
5618 * http://[3ffe:2a00:100:7031::1]
5619 * http://[1080::8:800:200C:417A]/foo
5620 * http://[::192.9.5.5]/ipng
5621 * http://[::FFFF:129.144.52.38]:80/index.html
5622 * http://[2010:836B:4179::836B:4179]
5623
5624 !! html/php
5625 <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>
5626 </p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
5627 </p>
5628 <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>
5629 <li> <a rel="nofollow" class="external free" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5630 <li> <a rel="nofollow" class="external free" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5631 <li> <a rel="nofollow" class="external free" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5632 <li> <a rel="nofollow" class="external free" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5633 <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>
5634 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5635 </p>
5636 <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>
5637 <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>
5638 <li> <a rel="nofollow" class="external free" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5639 <li> <a rel="nofollow" class="external free" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5640 <li> <a rel="nofollow" class="external free" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5641 <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>
5642 <li> <a rel="nofollow" class="external free" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5643
5644 !! html/parsoid
5645 <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>
5646
5647 <p>Examples from <a href="//tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
5648 <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/unicast">http://[1080::8:800:200C:417A]/unicast</a></li>
5649 <li> <a rel="mw:ExtLink" href="http://[FF01::101]/multicast">http://[FF01::101]/multicast</a></li>
5650 <li> <a rel="mw:ExtLink" href="http://[::1]/loopback">http://[::1]/loopback</a></li>
5651 <li> <a rel="mw:ExtLink" href="http://[::]/unspecified">http://[::]/unspecified</a></li>
5652 <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]/ipv4compat">http://[::13.1.68.3]/ipv4compat</a></li>
5653 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]/ipv4compat">http://[::FFFF:129.144.52.38]/ipv4compat</a></li></ul>
5654
5655 <p>Examples from <a href="//tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
5656 <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>
5657 <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>
5658 <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">http://[3ffe:2a00:100:7031::1]</a></li>
5659 <li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/foo">http://[1080::8:800:200C:417A]/foo</a></li>
5660 <li> <a rel="mw:ExtLink" href="http://[::192.9.5.5]/ipng">http://[::192.9.5.5]/ipng</a></li>
5661 <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>
5662 <li> <a rel="mw:ExtLink" href="http://[2010:836B:4179::836B:4179]">http://[2010:836B:4179::836B:4179]</a></li></ul>
5663 !! end
5664
5665 !! test
5666 IPv6 urls, bracketed format (T23261)
5667 !! wikitext
5668 [http://[2404:130:0:1000::187:2]/index.php test]
5669
5670 Examples from RFC 2373, section 2.2:
5671 * [http://[1080::8:800:200C:417A] unicast]
5672 * [http://[FF01::101] multicast]
5673 * [http://[::1]/ loopback]
5674 * [http://[::] unspecified]
5675 * [http://[::13.1.68.3] ipv4compat]
5676 * [http://[::FFFF:129.144.52.38] ipv4compat]
5677
5678 Examples from RFC 2732, section 2:
5679 * [http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html 1]
5680 * [http://[1080:0:0:0:8:800:200C:417A]/index.html 2]
5681 * [http://[3ffe:2a00:100:7031::1] 3]
5682 * [http://[1080::8:800:200C:417A]/foo 4]
5683 * [http://[::192.9.5.5]/ipng 5]
5684 * [http://[::FFFF:129.144.52.38]:80/index.html 6]
5685 * [http://[2010:836B:4179::836B:4179] 7]
5686
5687 !! html/php
5688 <p><a rel="nofollow" class="external text" href="http://[2404:130:0:1000::187:2]/index.php">test</a>
5689 </p><p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2373">RFC 2373</a>, section 2.2:
5690 </p>
5691 <ul><li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5692 <li> <a rel="nofollow" class="external text" href="http://[FF01::101]">multicast</a></li>
5693 <li> <a rel="nofollow" class="external text" href="http://[::1]/">loopback</a></li>
5694 <li> <a rel="nofollow" class="external text" href="http://[::]">unspecified</a></li>
5695 <li> <a rel="nofollow" class="external text" href="http://[::13.1.68.3]">ipv4compat</a></li>
5696 <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5697 <p>Examples from <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc2732">RFC 2732</a>, section 2:
5698 </p>
5699 <ul><li> <a rel="nofollow" class="external text" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5700 <li> <a rel="nofollow" class="external text" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5701 <li> <a rel="nofollow" class="external text" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5702 <li> <a rel="nofollow" class="external text" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5703 <li> <a rel="nofollow" class="external text" href="http://[::192.9.5.5]/ipng">5</a></li>
5704 <li> <a rel="nofollow" class="external text" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5705 <li> <a rel="nofollow" class="external text" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5706
5707 !! html/parsoid
5708 <p><a rel="mw:ExtLink" href="http://[2404:130:0:1000::187:2]/index.php">test</a></p>
5709
5710 <p>Examples from <a href="//tools.ietf.org/html/rfc2373" rel="mw:ExtLink">RFC 2373</a>, section 2.2:</p>
5711 <ul><li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]">unicast</a></li>
5712 <li> <a rel="mw:ExtLink" href="http://[FF01::101]">multicast</a></li>
5713 <li> <a rel="mw:ExtLink" href="http://[::1]/">loopback</a></li>
5714 <li> <a rel="mw:ExtLink" href="http://[::]">unspecified</a></li>
5715 <li> <a rel="mw:ExtLink" href="http://[::13.1.68.3]">ipv4compat</a></li>
5716 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]">ipv4compat</a></li></ul>
5717
5718 <p>Examples from <a href="//tools.ietf.org/html/rfc2732" rel="mw:ExtLink">RFC 2732</a>, section 2:</p>
5719 <ul><li> <a rel="mw:ExtLink" href="http://[FEDC:BA98:7654:3210:FEDC:BA98:7654:3210]:80/index.html">1</a></li>
5720 <li> <a rel="mw:ExtLink" href="http://[1080:0:0:0:8:800:200C:417A]/index.html">2</a></li>
5721 <li> <a rel="mw:ExtLink" href="http://[3ffe:2a00:100:7031::1]">3</a></li>
5722 <li> <a rel="mw:ExtLink" href="http://[1080::8:800:200C:417A]/foo">4</a></li>
5723 <li> <a rel="mw:ExtLink" href="http://[::192.9.5.5]/ipng">5</a></li>
5724 <li> <a rel="mw:ExtLink" href="http://[::FFFF:129.144.52.38]:80/index.html">6</a></li>
5725 <li> <a rel="mw:ExtLink" href="http://[2010:836B:4179::836B:4179]">7</a></li></ul>
5726 !! end
5727
5728 !! test
5729 Non-extlinks in brackets
5730 !! wikitext
5731 [foo]
5732 [foo bar]
5733 [foo ''bar'']
5734 [fool's] errand
5735 [fool's errand]
5736 [{{echo|foo}}]
5737 [{{echo|foo}} bar]
5738 [{{echo|foo}} ''bar'']
5739 [{{echo|foo}}l's] errand
5740 [{{echo|foo}}l's errand]
5741 [url={{echo|foo}}]
5742 [url=http://example.com]
5743 [http:// bare protocols don't count]
5744 !! html/php
5745 <p>[foo]
5746 [foo bar]
5747 [foo <i>bar</i>]
5748 [fool's] errand
5749 [fool's errand]
5750 [foo]
5751 [foo bar]
5752 [foo <i>bar</i>]
5753 [fool's] errand
5754 [fool's errand]
5755 [url=foo]
5756 [url=<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>]
5757 [http:// bare protocols don't count]
5758 </p>
5759 !! html/parsoid
5760 <p>[foo]
5761 [foo bar]
5762 [foo <i>bar</i>]
5763 [fool's] errand
5764 [fool's errand]
5765 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span>]
5766 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span> bar]
5767 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}"}'>foo</span> <i>bar</i>]
5768 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}l&#39;s"}'>fool's</span>] errand
5769 [<span typeof="mw:Placeholder" data-parsoid='{"src":"{{echo|foo}}l&#39;s"}'>fool's</span> errand]
5770 [<span typeof="mw:Placeholder" data-parsoid='{"src":"url={{echo|foo}}"}'>url=foo</span>]
5771 [url=<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>]
5772 [http:// bare protocols don't count]</p>
5773 !! end
5774
5775 !! test
5776 Percent encoding in external links
5777 !! wikitext
5778 [https://github.com/search?l=&q=ResourceLoader+%40wikimedia Search]
5779 !! html/php
5780 <p><a rel="nofollow" class="external text" href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a>
5781 </p>
5782 !! html/parsoid
5783 <p><a rel="mw:ExtLink"
5784 href="https://github.com/search?l=&amp;q=ResourceLoader+%40wikimedia">Search</a></p>
5785 !! end
5786
5787 !! test
5788 Use url link syntax for links where the content is equal the link target
5789 !! wikitext
5790 http://example.com
5791 !! html/php
5792 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
5793 </p>
5794 !! html/parsoid
5795 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a></p>
5796 !! end
5797
5798 !! test
5799 Parenthesis in external links, especially URL links
5800 !! wikitext
5801 http://example.com)
5802
5803 http://example.com/test)
5804
5805 http://example.com/(test)
5806
5807 http://example.com/((test)
5808
5809 (http://example.com/(test))
5810
5811 (http://example.com/(test)))))
5812
5813 http://example.com/a)b
5814
5815 [http://example.com) foo]
5816 !! html/php
5817 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5818 </p><p><a rel="nofollow" class="external free" href="http://example.com/test">http://example.com/test</a>)
5819 </p><p><a rel="nofollow" class="external free" href="http://example.com/(test)">http://example.com/(test)</a>
5820 </p><p><a rel="nofollow" class="external free" href="http://example.com/((test)">http://example.com/((test)</a>
5821 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test))">http://example.com/(test))</a>
5822 </p><p>(<a rel="nofollow" class="external free" href="http://example.com/(test)))))">http://example.com/(test)))))</a>
5823 </p><p><a rel="nofollow" class="external free" href="http://example.com/a)b">http://example.com/a)b</a>
5824 </p><p><a rel="nofollow" class="external text" href="http://example.com)">foo</a>
5825 </p>
5826 !! html/parsoid
5827 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a>)</p>
5828 <p><a rel="mw:ExtLink" href="http://example.com/test">http://example.com/test</a>)</p>
5829 <p><a rel="mw:ExtLink" href="http://example.com/(test)">http://example.com/(test)</a></p>
5830 <p><a rel="mw:ExtLink" href="http://example.com/((test)">http://example.com/((test)</a></p>
5831 <p>(<a rel="mw:ExtLink" href="http://example.com/(test))">http://example.com/(test))</a></p>
5832 <p>(<a rel="mw:ExtLink" href="http://example.com/(test)))))">http://example.com/(test)))))</a></p>
5833 <p><a rel="mw:ExtLink" href="http://example.com/a)b">http://example.com/a)b</a></p>
5834 <p><a rel="mw:ExtLink" href="http://example.com)">foo</a></p>
5835 !! end
5836
5837 !! test
5838 Parenthesis in external links, w/ transclusion or comment
5839 !! wikitext
5840 (http://example.com/{{echo|hi}})
5841
5842 (http://example.com<!-- hi -->)
5843 !! html/php
5844 <p>(<a rel="nofollow" class="external free" href="http://example.com/hi">http://example.com/hi</a>)
5845 </p><p>(<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
5846 </p>
5847 !! html/parsoid
5848 <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>
5849
5850 <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>
5851 !! end
5852
5853 !! test
5854 Serialize <a> tags with invalid link targets as plain text
5855 !! options
5856 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
5857 !! html/parsoid
5858 <a rel="mw:WikiLink" href="[[foo]]">text</a>
5859 <a rel="mw:WikiLink" href="[[foo]]">*text</a>
5860 <a rel="mw:WikiLink" href="[[foo]]">[[foo]]</a>
5861 <a rel="mw:WikiLink" href="[[foo]]">*a [[foo]]</a>
5862 !! wikitext
5863 text
5864 <nowiki>*</nowiki>text
5865 <nowiki>[[foo]]</nowiki>
5866 <nowiki>*</nowiki>a <nowiki>[[foo]]</nowiki>
5867 !! end
5868
5869 !! test
5870 mw:ExtLink -vs- mw:WikiLink (T94723)
5871 !! options
5872 parsoid=html2wt
5873 !! html/parsoid
5874 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"piped","a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>Bar</a>
5875 <a rel="mw:WikiLink" href="./Foo" title="Foo">Bar</a>
5876 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5877 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/Foo" title="Foo">Bar</a>
5878 <p>
5879 <a rel="mw:ExtLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5880 <a rel="mw:WikiLink" href="http://en.wikipedia.org/wiki/European_Robin">European Robin</a>
5881 </p>
5882 !! wikitext
5883 [[Foo|Bar]]
5884 [[Foo|Bar]]
5885 [[wikipedia:Foo|Bar]]
5886 [[wikipedia:Foo|Bar]]
5887
5888 [[wikipedia:European_Robin|European Robin]]
5889 [[wikipedia:European_Robin|European Robin]]
5890 !! end
5891
5892 !! test
5893 mw:ExtLink linking to a interwiki URL can be round-tripped losslessly (T94723)
5894 !! options
5895 parsoid=wt2wt
5896 !! wikitext
5897 [http://en.wikipedia.org/wiki/European_Robin European Robin]
5898 !! html/parsoid
5899 THIS SECTION IS NOT USED (but Parsoid won't run the test without it)
5900 !! end
5901
5902
5903 ###
5904 ### Quotes
5905 ###
5906
5907 !! test
5908 Quotes
5909 !! wikitext
5910 Normal text. '''Bold text.''' Normal text. ''Italic text.''
5911
5912 Normal text. '''''Bold italic text.''''' Normal text.
5913 !! html
5914 <p>Normal text. <b>Bold text.</b> Normal text. <i>Italic text.</i>
5915 </p><p>Normal text. <i><b>Bold italic text.</b></i> Normal text.
5916 </p>
5917 !! end
5918
5919
5920 # Parsoid inserts an empty bold tag pair at the end of the line, that the PHP
5921 # parser strips. The wikitext contains just the first half of the bold
5922 # quote pair.
5923 !! test
5924 Unclosed and unmatched quotes
5925 !! wikitext
5926 '''''Bold italic text '''with bold deactivated''' in between.'''''
5927
5928 '''''Bold italic text ''with italic deactivated'' in between.'''''
5929
5930 '''Bold text..
5931
5932 ..spanning two paragraphs (should not work).'''
5933
5934 '''Bold tag left open
5935
5936 ''Italic tag left open
5937
5938 Normal text.
5939
5940 <!-- Unmatching number of opening, closing tags: -->
5941 '''This year''''s election ''should'' beat '''last year''''s.
5942
5943 ''Tom'''s car is bigger than ''Susan'''s.
5944
5945 Plain ''italic'''s plain
5946 !! html/php
5947 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
5948 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
5949 </p><p><b>Bold text..</b>
5950 </p><p>..spanning two paragraphs (should not work).
5951 </p><p><b>Bold tag left open</b>
5952 </p><p><i>Italic tag left open</i>
5953 </p><p>Normal text.
5954 </p><p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
5955 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
5956 </p><p>Plain <i>italic'</i>s plain
5957 </p>
5958 !! html/parsoid
5959 <p><i><b>Bold italic text </b>with bold deactivated<b> in between.</b></i>
5960 </p><p><b><i>Bold italic text </i>with italic deactivated<i> in between.</i></b>
5961 </p><p><b>Bold text..</b>
5962 </p><p>..spanning two paragraphs (should not work).<b></b>
5963 </p><p><b>Bold tag left open</b>
5964 </p><p><i>Italic tag left open</i>
5965 </p><p>Normal text.
5966 </p>
5967 <!-- Unmatching number of opening, closing tags: -->
5968 <p><b>This year'</b>s election <i>should</i> beat <b>last year'</b>s.
5969 </p><p><i>Tom<b>s car is bigger than </b></i><b>Susan</b>s.
5970 </p><p>Plain <i>italic'</i>s plain
5971 </p>
5972 !! end
5973
5974 ###
5975 ### Tables
5976 ###
5977 ### some content taken from http://meta.wikimedia.org/wiki/MediaWiki_User%27s_Guide:_Using_tables
5978 ###
5979
5980 # This should not produce <table></table> as <table><tr><td></td></tr></table>
5981 # is the bare minimum required by the spec, see:
5982 # https://www.w3.org/TR/xhtml-modularization/dtd_module_defs.html#a_module_Basic_Tables
5983 # Parsoid team replies: empty table tags are legal in HTML5
5984 !! test
5985 A table with no data.
5986 !! options
5987 parsoid=wt2html
5988 !! wikitext
5989 {||}
5990 !! html/php
5991
5992 !! html/parsoid
5993 <table></table>
5994
5995 !! end
5996
5997 !! test
5998 A table with stray table end tags on start tag line (wt2html)
5999 !! options
6000 parsoid=wt2html
6001 !! wikitext
6002 {|style="color: red;"|}
6003
6004 {|style="color: red;" |}
6005 |foo
6006 |}
6007
6008 {|style="color: red;"|} id="foo"
6009 |foo
6010 |}
6011
6012 {|style="color: red;" |} id="foo"
6013 |foo
6014 |}
6015 !! html
6016 <table style="color: red;"></table>
6017
6018 <table style="color: red;">
6019 <tbody><tr>
6020 <td>foo</td>
6021 </tr></tbody>
6022 </table>
6023
6024 <table style="color: red;" id="foo">
6025 <tbody><tr>
6026 <td>foo</td>
6027 </tr></tbody>
6028 </table>
6029
6030 <table style="color: red;" id="foo">
6031 <tbody><tr>
6032 <td>foo</td>
6033 </tr></tbody>
6034 </table>
6035
6036 !! end
6037
6038 !! test
6039 A table with no data (take 2)
6040 !! wikitext
6041 {|
6042 |}
6043 !! html/parsoid
6044 <table></table>
6045 !! end
6046
6047 # A table with nothing but a caption is invalid XHTML, we might want to render
6048 # this as <p>caption</p>
6049 # Parsoid team replies: table with only a caption is legal in HTML5
6050 !! test
6051 A table with nothing but a caption
6052 !! wikitext
6053 {|
6054 |+ caption
6055 |}
6056 !! html/php
6057 <table>
6058 <caption> caption
6059 </caption><tr><td></td></tr></table>
6060
6061 !! html/parsoid
6062 <table><caption> caption</caption></table>
6063 !! end
6064
6065 !! test
6066 A table with caption with default-spaced attributes and a table row
6067 !! wikitext
6068 {|
6069 |+ style="color: red;" | caption1
6070 |-
6071 | foo
6072 |}
6073 !! html
6074 <table>
6075 <caption style="color: red;"> caption1
6076 </caption>
6077 <tr>
6078 <td> foo
6079 </td></tr></table>
6080
6081 !! end
6082
6083 !! test
6084 A table with captions with non-default spaced attributes and a table row
6085 !! wikitext
6086 {|
6087 |+style="color: red;"|caption2
6088 |+ style="color: red;"| caption3
6089 |-
6090 | foo
6091 |}
6092 !! html
6093 <table>
6094 <caption style="color: red;">caption2
6095 </caption>
6096 <caption style="color: red;"> caption3
6097 </caption>
6098 <tr>
6099 <td> foo
6100 </td></tr></table>
6101
6102 !! end
6103
6104 !! test
6105 Table td-cell syntax variations
6106 !! wikitext
6107 {|
6108 | foo bar foo | baz
6109 | foo bar foo || baz
6110 | style='color:red;' | baz
6111 | style='color:red;' || baz
6112 |}
6113 !! html
6114 <table>
6115 <tr>
6116 <td> baz
6117 </td>
6118 <td> foo bar foo </td>
6119 <td> baz
6120 </td>
6121 <td style="color:red;"> baz
6122 </td>
6123 <td> style='color:red;' </td>
6124 <td> baz
6125 </td></tr></table>
6126
6127 !! end
6128
6129 !! test
6130 Simple table
6131 !! wikitext
6132 {|
6133 | 1 || 2
6134 |-
6135 | 3 || 4
6136 |}
6137 !! html
6138 <table>
6139 <tr>
6140 <td> 1 </td>
6141 <td> 2
6142 </td></tr>
6143 <tr>
6144 <td> 3 </td>
6145 <td> 4
6146 </td></tr></table>
6147
6148 !! end
6149
6150 !! test
6151 Simple table but with multiple dashes for row wikitext
6152 !! wikitext
6153 {|
6154 | foo
6155 |-----
6156 | bar
6157 |}
6158 !! html
6159 <table>
6160 <tr>
6161 <td> foo
6162 </td></tr>
6163 <tr>
6164 <td> bar
6165 </td></tr></table>
6166
6167 !! end
6168
6169 !! test
6170 Multiplication table
6171 !! wikitext
6172 {| border="1" cellpadding="2"
6173 |+Multiplication table
6174 |-
6175 ! &times; !! 1 !! 2 !! 3
6176 |-
6177 ! 1
6178 | 1 || 2 || 3
6179 |-
6180 ! 2
6181 | 2 || 4 || 6
6182 |-
6183 ! 3
6184 | 3 || 6 || 9
6185 |-
6186 ! 4
6187 | 4 || 8 || 12
6188 |-
6189 ! 5
6190 | 5 || 10 || 15
6191 |}
6192 !! html
6193 <table border="1" cellpadding="2">
6194 <caption>Multiplication table
6195 </caption>
6196 <tr>
6197 <th> &#215; </th>
6198 <th> 1 </th>
6199 <th> 2 </th>
6200 <th> 3
6201 </th></tr>
6202 <tr>
6203 <th> 1
6204 </th>
6205 <td> 1 </td>
6206 <td> 2 </td>
6207 <td> 3
6208 </td></tr>
6209 <tr>
6210 <th> 2
6211 </th>
6212 <td> 2 </td>
6213 <td> 4 </td>
6214 <td> 6
6215 </td></tr>
6216 <tr>
6217 <th> 3
6218 </th>
6219 <td> 3 </td>
6220 <td> 6 </td>
6221 <td> 9
6222 </td></tr>
6223 <tr>
6224 <th> 4
6225 </th>
6226 <td> 4 </td>
6227 <td> 8 </td>
6228 <td> 12
6229 </td></tr>
6230 <tr>
6231 <th> 5
6232 </th>
6233 <td> 5 </td>
6234 <td> 10 </td>
6235 <td> 15
6236 </td></tr></table>
6237
6238 !! end
6239
6240 !! test
6241 Accept "||" in table headings
6242 !! wikitext
6243 {|
6244 !h1 || h2
6245 |}
6246 !! html
6247 <table>
6248 <tr>
6249 <th>h1 </th>
6250 <th> h2
6251 </th></tr></table>
6252
6253 !! end
6254
6255 !! test
6256 Accept "!!" in table data
6257 !! wikitext
6258 {|
6259 | Foo!! ||
6260 |}
6261 !! html
6262 <table>
6263 <tr>
6264 <td> Foo!! </td>
6265 <td>
6266 </td></tr></table>
6267
6268 !! html/parsoid
6269 <table>
6270 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'> Foo!! </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'></td></tr>
6271 </tbody></table>
6272 !! end
6273
6274 !! test
6275 Accept "||" in indented table headings
6276 !! wikitext
6277 :{|
6278 !h1 || h2
6279 |}
6280 !! html
6281 <dl><dd><table>
6282 <tr>
6283 <th>h1 </th>
6284 <th> h2
6285 </th></tr></table></dd></dl>
6286
6287 !! end
6288
6289 !! test
6290 Accept "!!" in templates
6291 !! wikitext
6292 {|
6293 !a {{echo|b!!c}}
6294 |}
6295 !! html/php
6296 <table>
6297 <tr>
6298 <th>a b</th>
6299 <th>c
6300 </th></tr></table>
6301
6302 !! html/parsoid
6303 <table>
6304 <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>
6305 !! end
6306
6307 !! test
6308 Accept "!!" in table headings after newline
6309 !! wikitext
6310 {|
6311 !a
6312 b!!c
6313 |}
6314 !! html/php
6315 <table>
6316 <tr>
6317 <th>a
6318 <p>b!!c
6319 </p>
6320 </th></tr></table>
6321
6322 !! html/parsoid
6323 <table>
6324 <tbody><tr><th>a
6325 <p>b!!c</p></th></tr>
6326 </tbody></table>
6327 !! end
6328
6329 !! test
6330 Accept "!!" in table data of mixed wikitext / html syntax
6331 !! wikitext
6332 {|
6333 !a
6334 <tr><td>b!!c</td></tr>
6335 |}
6336 !! html+tidy
6337 <table>
6338 <tr>
6339 <th>a</th>
6340 </tr>
6341 <tr>
6342 <td>b!!c</td>
6343 </tr>
6344 </table>
6345 !! html/parsoid
6346 <table>
6347 <tbody><tr><th>a</th></tr>
6348 <tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>b!!c</td></tr>
6349 </tbody></table>
6350 !! end
6351
6352 !! test
6353 Accept empty attributes in td/th cells (td/th cells starting with leading ||)
6354 !! wikitext
6355 {|
6356 !| h1
6357 || a
6358 |}
6359 !! html
6360 <table>
6361 <tr>
6362 <th> h1
6363 </th>
6364 <td> a
6365 </td></tr></table>
6366
6367 !! end
6368
6369 !!test
6370 Accept "| !" at start of line in tables (ignore !-attribute)
6371 !! wikitext
6372 {|
6373 |-
6374 | !style="color:red" | bar
6375 |}
6376 !! html
6377 <table>
6378
6379 <tr>
6380 <td> bar
6381 </td></tr></table>
6382
6383 !!end
6384
6385 !!test
6386 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 +/-
6387 !! wikitext
6388 {|
6389 |-
6390 |style='color:red;'|+1
6391 |style='color:blue;'|-1
6392 |-
6393 | 1 || 2 || 3
6394 | 1 ||+2 ||-3
6395 |-
6396 | +1
6397 | -1
6398 |}
6399 !! html
6400 <table>
6401
6402 <tr>
6403 <td style="color:red;">+1
6404 </td>
6405 <td style="color:blue;">-1
6406 </td></tr>
6407 <tr>
6408 <td> 1 </td>
6409 <td> 2 </td>
6410 <td> 3
6411 </td>
6412 <td> 1 </td>
6413 <td>+2 </td>
6414 <td>-3
6415 </td></tr>
6416 <tr>
6417 <td> +1
6418 </td>
6419 <td> -1
6420 </td></tr></table>
6421
6422 !!end
6423
6424 !! test
6425 Table rowspan
6426 !! wikitext
6427 {| border=1
6428 | Cell 1, row 1
6429 |rowspan=2| Cell 2, row 1 (and 2)
6430 | Cell 3, row 1
6431 |-
6432 | Cell 1, row 2
6433 | Cell 3, row 2
6434 |}
6435 !! html
6436 <table border="1">
6437 <tr>
6438 <td> Cell 1, row 1
6439 </td>
6440 <td rowspan="2"> Cell 2, row 1 (and 2)
6441 </td>
6442 <td> Cell 3, row 1
6443 </td></tr>
6444 <tr>
6445 <td> Cell 1, row 2
6446 </td>
6447 <td> Cell 3, row 2
6448 </td></tr></table>
6449
6450 !! end
6451
6452 !! test
6453 Nested table
6454 !! wikitext
6455 {| border=1
6456 | &alpha;
6457 |
6458 {| bgcolor=#ABCDEF border=2
6459 |nested
6460 |-
6461 |table
6462 |}
6463 |the original table again
6464 |}
6465 !! html
6466 <table border="1">
6467 <tr>
6468 <td> &#945;
6469 </td>
6470 <td>
6471 <table bgcolor="#ABCDEF" border="2">
6472 <tr>
6473 <td>nested
6474 </td></tr>
6475 <tr>
6476 <td>table
6477 </td></tr></table>
6478 </td>
6479 <td>the original table again
6480 </td></tr></table>
6481
6482 !! end
6483
6484 !! test
6485 Invalid attributes in table cell (T3830)
6486 !! wikitext
6487 {|
6488 |Cell:|broken
6489 |}
6490 !! html
6491 <table>
6492 <tr>
6493 <td>broken
6494 </td></tr></table>
6495
6496 !! end
6497
6498 !! test
6499 Table cell attributes: Pipes protected by nowikis should be treated as a plain character
6500 !! wikitext
6501 {|
6502 | title="foo" |bar
6503 | title="foo<nowiki>|</nowiki>" |bar
6504 | title="foo<nowiki>|</nowiki>" bar
6505 |}
6506 !! html/php
6507 <table>
6508 <tr>
6509 <td title="foo">bar
6510 </td>
6511 <td title="foo&#124;">bar
6512 </td>
6513 <td> title="foo|" bar
6514 </td></tr></table>
6515
6516 !! html/parsoid
6517 <table>
6518 <tbody><tr><td title="foo">bar</td>
6519 <td title="foo|" data-parsoid='{"a":{"title":"foo|"},"sa":{"title":"foo&lt;nowiki>|&lt;/nowiki>"},"autoInsertedEnd":true}'>bar</td>
6520 <td> title="foo<span typeof="mw:Nowiki">|</span>" bar</td></tr>
6521 </tbody></table>
6522 !! end
6523
6524 # See: http://lists.wikimedia.org/mailman/htdig/wikitech-l/2006-April/022293.html
6525 # N.B. The "|}" to close the table is missing from the input, so parsoid's
6526 # *2wt modes will fail.
6527 !! test
6528 Table security: embedded pipes
6529 !! options
6530 parsoid=wt2html,html2html
6531 !! wikitext
6532 {|
6533 | |[ftp://|x||]" onmouseover="alert(document.cookie)">test
6534 !! html/php
6535 <table>
6536 <tr>
6537 <td>[<a rel="nofollow" class="external free" href="ftp://%7Cx">ftp://%7Cx</a></td>
6538 <td>]" onmouseover="alert(document.cookie)"&gt;test
6539 </td>
6540 </tr>
6541 </table>
6542
6543 !! html/parsoid
6544 <table><tbody>
6545 <tr>
6546 <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_v":"row","autoInsertedEnd":true}'>]" onmouseover="alert(document.cookie)">test</td></tr></tbody></table>
6547 !! end
6548
6549 !! test
6550 Element attributes with double ! should not be broken up by <th>
6551 !! wikitext
6552 {|
6553 ! hi <div class="!!">ha</div> ho
6554 |}
6555 !! html/php
6556 <table>
6557 <tr>
6558 <th> hi <div class="!!">ha</div> ho
6559 </th></tr></table>
6560
6561 !! html/parsoid
6562 <table>
6563 <tbody><tr><th> hi <div class="!!" data-parsoid='{"stx":"html"}'>ha</div> ho</th></tr>
6564 </tbody></table>
6565 !! end
6566
6567 !! test
6568 ! and || in element attributes should not be parsed as <th>/<td>
6569 !! wikitext
6570 {|
6571 | <div style="color: red !important;" data-contrived="put this here ||">hi</div>
6572 |}
6573 !! html/php
6574 <table>
6575 <tr>
6576 <td> <div style="color: red !important;" data-contrived="put this here &#124;&#124;">hi</div>
6577 </td></tr></table>
6578
6579 !! html/parsoid
6580 <table>
6581 <tbody><tr><td> <div style="color: red !important;" data-contrived="put this here ||" data-parsoid='{"stx":"html"}'>hi</div></td></tr>
6582 </tbody></table>
6583 !! end
6584
6585 # FIXME: The output seems broken. Filed as T110268.
6586 !! test
6587 ! and || in td attributes should not be parsed as <th>/<td>
6588 !! options
6589 parsoid=wt2html
6590 !! wikitext
6591 {|
6592 | style="color: red !important;" data-contrived="put this here ||" | foo
6593 |}
6594 !! html/php
6595 <table>
6596 <tr>
6597 <td> style="color: red !important;" data-contrived="put this here </td>
6598 <td> foo
6599 </td></tr></table>
6600
6601 !! html/parsoid
6602 <table>
6603 <tbody><tr><td> style="color: red !important;" data-contrived="put this here </td><td data-parsoid='{"stx_v":"row","a":{"\"":null},"sa":{"\"":""},"autoInsertedEnd":true}'> foo</td></tr>
6604 </tbody></table>
6605 !! end
6606
6607 !! test
6608 Break on | in element attribute in template
6609 !! options
6610 parsoid=wt2html,html2html
6611 !! wikitext
6612 {{echo|1=<div class="hi|ho">ha</div>}}
6613 !! html/php
6614 <p>ho"&gt;ha&lt;/div&gt;
6615 </p>
6616 !! html/parsoid
6617 <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>
6618 !! end
6619
6620 !! test
6621 Break on | in element attribute name in template
6622 !! wikitext
6623 {{echo|<div cla|ss="hiho">ha</div>}}
6624 !! html/parsoid
6625 <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>
6626 !! end
6627
6628 !! test
6629 Don't break on | in extension attribute in template
6630 !! wikitext
6631 {{echo|<ref name="hi|ho">ha</ref>}}
6632
6633 <references />
6634 !! html/parsoid
6635 <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>
6636
6637 <ol class="mw-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>
6638 !! end
6639
6640 ## We don't support roundtripping of these attributes in Parsoid.
6641 ## Selective serialization takes care of preventing dirty diffs.
6642 ## But, on edits, we dirty-diff the invalid attribute text.
6643 !! test
6644 Invalid text in table attributes should be discarded
6645 !! options
6646 parsoid=wt2html
6647 !! wikitext
6648 {| <span>boo</span> style='border:1px solid black'
6649 | <span>boo</span> style='color:blue' | 1
6650 |<span>boo</span> style='color:blue'| 2
6651 |}
6652 !! html/php
6653 <table style="border:1px solid black">
6654 <tr>
6655 <td style="color:blue"> 1
6656 </td>
6657 <td style="color:blue"> 2
6658 </td></tr></table>
6659
6660 !! html/parsoid
6661 <table style="border:1px solid black">
6662 <tr>
6663 <td style="color:blue"> 1</td>
6664 <td style="color:blue"> 2</td>
6665 </tr>
6666 </table>
6667 !! end
6668
6669 !! test
6670 Invalid text in table attributes should be preserved by selective serializer
6671 !! options
6672 parsoid={
6673 "modes": ["selser"],
6674 "changes": [
6675 ["td:first-child", "text", "abc"],
6676 ["td + td", "text", "xyz"]
6677 ]
6678 }
6679 !! wikitext
6680 {| <span>boo</span> style='border:1px solid black'
6681 | <span>boo</span> style='color:blue' | 1
6682 |<span>boo</span> style='color:blue'| 2
6683 |}
6684 !! wikitext/edited
6685 {| <span>boo</span> style='border:1px solid black'
6686 | <span>boo</span> style='color:blue' |abc
6687 |<span>boo</span> style='color:blue'|xyz
6688 |}
6689 !! end
6690
6691 !! test
6692 1. Template-generated table cell attributes and cell content
6693 !! wikitext
6694 {|
6695 |{{table_attribs}}
6696 | {{table_attribs}}
6697 || {{table_attribs_5}}
6698 | <!--foo--> <!--bar--> <!--baz--> {{table_attribs}}
6699 |align=center {{table_attribs}}
6700 | <!--foo--> align=center <!--bar--> {{table_attribs}}
6701 |}
6702 !! html
6703 <table>
6704 <tr>
6705 <td style="color:red;">Foo
6706 </td>
6707 <td style="color:red;">Foo
6708 </td>
6709 <td> style="color:red;"</td>
6710 <td>Bar
6711 </td>
6712 <td style="color:red;">Foo
6713 </td>
6714 <td align="center" style="color:red;">Foo
6715 </td>
6716 <td align="center" style="color:red;">Foo
6717 </td></tr></table>
6718
6719 !! end
6720
6721 !! test
6722 2. Template-generated table cell attributes and cell content
6723 !! wikitext
6724 {|
6725 |{{table_attribs_2}}
6726 |}
6727 !! html/php
6728 <table>
6729 <tr>
6730 <td style="color:red;">Foo
6731 </td>
6732 <td>Bar</td>
6733 <td>Baz
6734 </td></tr></table>
6735
6736 !! html/parsoid
6737 <table>
6738 <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>
6739 <td about="#mwt1">Bar</td><td about="#mwt1">Baz</td></tr>
6740 </tbody></table>
6741 !! end
6742
6743 !! test
6744 3. Template-generated table cell attributes and cell content
6745 !! wikitext
6746 {|
6747 !align=center {{table_header_cells}}
6748 |-
6749 |align=center {{table_cells}}
6750 |}
6751 !! html/php
6752 <table>
6753 <tr>
6754 <th align="center" style="color:red;">Foo</th>
6755 <th style="color:red;"><i>Bar</i></th>
6756 <th style="color:brown;"><i>Foo</i> and Baz
6757 </th></tr>
6758 <tr>
6759 <td align="center" style="color:red;">Foo</td>
6760 <td style="color:red;"><i>Bar</i></td>
6761 <td style="color:brown;"><i>Foo</i> and Baz
6762 </td></tr></table>
6763
6764 !! html/parsoid
6765 <table>
6766 <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>
6767 <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>
6768 </tbody></table>
6769 !! end
6770
6771 !! test
6772 4. Template-generated table cell attributes and cell content inside a templated table
6773 !! wikitext
6774 {{tbl-start}}
6775 !align=center {{table_header_cells}}
6776 |-
6777 |align=center {{table_cells}}
6778 {{tbl-end}}
6779 !! html/php
6780 <table>
6781 <tr>
6782 <th align="center" style="color:red;">Foo</th>
6783 <th style="color:red;"><i>Bar</i></th>
6784 <th style="color:brown;"><i>Foo</i> and Baz
6785 </th></tr>
6786 <tr>
6787 <td align="center" style="color:red;">Foo</td>
6788 <td style="color:red;"><i>Bar</i></td>
6789 <td style="color:brown;"><i>Foo</i> and Baz
6790 </td></tr></table>
6791
6792 !! html/parsoid
6793 <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}}]}'>
6794 <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>
6795 <tr>
6796 <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>
6797 </tbody></table>
6798 !! end
6799
6800 ## Edge case fix to prevent future regressions
6801 !! test
6802 T107652: <ref>s in templates that also generate table cell attributes should be rendered properly
6803 !! wikitext
6804 {|
6805 |{{table_attribs_7}}
6806 |}
6807 <references />
6808 !! html/parsoid
6809 <table>
6810 <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>
6811 </tbody></table>
6812 <ol class="mw-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>
6813 !! end
6814
6815 !! test
6816 Table with row followed by newlines and table heading
6817 !! options
6818 parsoid=wt2html,html2html
6819 !! wikitext
6820 {|
6821 |-
6822
6823 ! foo
6824 |}
6825 !! html/*
6826 <table>
6827
6828
6829 <tr>
6830 <th> foo
6831 </th></tr></table>
6832
6833 !! end
6834
6835 !! test
6836 Table with empty line following the start tag
6837 !! options
6838 parsoid=wt2html,html2html
6839 !! wikitext
6840 {|
6841
6842 |-
6843 | foo
6844 |}
6845 !! html/*
6846 <table>
6847
6848
6849 <tr>
6850 <td> foo
6851 </td></tr></table>
6852
6853 !! end
6854
6855 !! test
6856 Table attributes with empty value
6857 !! options
6858 parsoid=wt2html,html2html
6859 !! wikitext
6860 {|
6861 | style=| hello
6862 |}
6863 !! html/php
6864 <table>
6865 <tr>
6866 <td style=""> hello
6867 </td></tr></table>
6868
6869 !! html/parsoid
6870 <table>
6871 <tbody><tr><td style=""> hello</td></tr>
6872 </tbody></table>
6873 !! end
6874
6875 !! test
6876 Wikitext table with a lot of comments
6877 !! wikitext
6878 {|
6879 <!-- c0 -->
6880 | foo
6881 <!-- c1 -->
6882 |-<!-- c2 -->
6883 <!-- c3 -->
6884 |<!-- c4 -->
6885 <!-- c5 -->
6886 |}
6887 !! html
6888 <table>
6889 <tr>
6890 <td> foo
6891 </td></tr>
6892 <tr>
6893 <td>
6894 </td></tr></table>
6895
6896 !! end
6897
6898 !! test
6899 Wikitext table comments represented in parsoid dom
6900 !! wikitext
6901 {|<!--c1--><!--c2-->
6902 |-<!--c3-->
6903 | x
6904 |}
6905 !! html/php+tidy
6906 <table>
6907 <tr>
6908 <td>x</td>
6909 </tr>
6910 </table>
6911 !! html/parsoid
6912 <table><!--c1--><!--c2-->
6913 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'><!--c3-->
6914 <td data-parsoid='{"autoInsertedEnd":true}'> x</td></tr>
6915 </tbody></table>
6916 !! end
6917
6918 !! test
6919 Wikitext table with double-line table cell
6920 !! wikitext
6921 {|
6922 |a
6923 b
6924 |}
6925 !! html
6926 <table>
6927 <tr>
6928 <td>a
6929 <p>b
6930 </p>
6931 </td></tr></table>
6932
6933 !! end
6934
6935 !! test
6936 Table cell with a single comment
6937 !! wikitext
6938 {|
6939 | <!-- c1 -->
6940 | a
6941 |}
6942 !! html
6943 <table>
6944 <tr>
6945 <td>
6946 </td>
6947 <td> a
6948 </td></tr></table>
6949
6950 !! end
6951
6952 !! test
6953 Table-cell after a comment-only-empty-line
6954 !! wikitext
6955 {|
6956 |a
6957 <!--c1-->
6958 <!--c2-->| b
6959 |}
6960 !! html
6961 <table>
6962 <tr>
6963 <td>a
6964 </td>
6965 <td> b
6966 </td></tr></table>
6967
6968 !! html/parsoid
6969 <table>
6970 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>a</td>
6971 <!--c1-->
6972 <!--c2--><td data-parsoid='{"autoInsertedEnd":true}'> b</td></tr>
6973 </tbody></table>
6974
6975 !! end
6976
6977 !! test
6978 Build table with {{!}}
6979 !! wikitext
6980 {{{!}} class="wikitable"
6981 ! header
6982 ! second header
6983 {{!}}- style="color:red;"
6984 {{!}} data {{!}}{{!}} style="color:red;" {{!}} second data
6985 {{!}}}
6986 !! html
6987 <table class="wikitable">
6988 <tr>
6989 <th> header
6990 </th>
6991 <th> second header
6992 </th></tr>
6993 <tr style="color:red;">
6994 <td> data </td>
6995 <td style="color:red;"> second data
6996 </td></tr></table>
6997
6998 !! end
6999
7000 !! test
7001 Build table with pipe as data
7002 !! wikitext
7003 {| class="wikitable"
7004 ! header
7005 ! second header
7006 |- style="color:red;"
7007 | data || style="color:red;" | second data
7008 |-
7009 | style="color:red;" | data with | || style="color:red;" | second data with |
7010 |-
7011 || data with | ||| second data with |
7012 |}
7013 !! html
7014 <table class="wikitable">
7015 <tr>
7016 <th> header
7017 </th>
7018 <th> second header
7019 </th></tr>
7020 <tr style="color:red;">
7021 <td> data </td>
7022 <td style="color:red;"> second data
7023 </td></tr>
7024 <tr>
7025 <td style="color:red;"> data with | </td>
7026 <td style="color:red;"> second data with |
7027 </td></tr>
7028 <tr>
7029 <td> data with | </td>
7030 <td> second data with |
7031 </td></tr></table>
7032
7033 !! end
7034
7035 !! test
7036 Build table with wikilink
7037 !! wikitext
7038 {| class="wikitable"
7039 ! header || second header
7040 |- style="color:red;"
7041 | data [[Main Page|linktext]] || second data [[Main Page|linktext]]
7042 |-
7043 | data || second data [[Main Page|link|text with pipe]]
7044 |}
7045 !! html
7046 <table class="wikitable">
7047 <tr>
7048 <th> header </th>
7049 <th> second header
7050 </th></tr>
7051 <tr style="color:red;">
7052 <td> data <a href="/wiki/Main_Page" title="Main Page">linktext</a> </td>
7053 <td> second data <a href="/wiki/Main_Page" title="Main Page">linktext</a>
7054 </td></tr>
7055 <tr>
7056 <td> data </td>
7057 <td> second data <a href="/wiki/Main_Page" title="Main Page">link|text with pipe</a>
7058 </td></tr></table>
7059
7060 !! end
7061
7062 # The expected HTML structure in this test is debatable. The PHP parser does
7063 # not parse this kind of table at all. The main focus for Parsoid is on
7064 # round-tripping, so this output is ok for now. TODO: revisit!
7065 !! test
7066 Wikitext table with html-syntax row
7067 !! wikitext
7068 {|
7069 |-
7070 <td>foo</td>
7071 |}
7072 !! html/parsoid
7073 <table>
7074 <tbody>
7075 <tr>
7076 <td>foo</td></tr></tbody></table>
7077 !! end
7078
7079 !! test
7080 Implicit <td> after a |-
7081 !! options
7082 parsoid=wt2html,html2html
7083 !! wikitext
7084 {|
7085 |-
7086 a
7087 |}
7088 !! html/php
7089 <table>
7090
7091 a
7092 </table>
7093
7094 !! html/php+tidy
7095 <p>a</p>
7096 !! html/parsoid
7097 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>a</p><table>
7098 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7099
7100 </tr></tbody></table>
7101 !! end
7102
7103 !! test
7104 Lists should be recognized in an implicit <td> context
7105 !! options
7106 parsoid=wt2html,html2html
7107 !! wikitext
7108 {|
7109 |-
7110 *a
7111 |}
7112 !! html/php
7113 <table>
7114
7115 <ul><li>a</li></ul>
7116 </table>
7117
7118 !! html/php+tidy
7119 <ul>
7120 <li>a</li>
7121 </ul>
7122 !! html/parsoid
7123 <ul data-parsoid='{"fostered":true,"autoInsertedEnd":true}'><li>a</li></ul><table>
7124 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7125
7126 </tr></tbody></table>
7127 !! end
7128
7129 !! test
7130 Table cells not properly parsed in an implicit-td context
7131 !! wikitext
7132 {|
7133 |-
7134 {{table_attribs_4}} || a || b
7135 |}
7136 !! html/php+tidy
7137 <table>
7138 <tr>
7139 <td style="background-color:#DC241f;" width="10px"></td>
7140 <td>a</td>
7141 <td>b</td>
7142 </tr>
7143 </table>
7144 !! html/parsoid
7145 <table>
7146 <tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
7147 <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>
7148 !! end
7149
7150 !! test
7151 Parsoid: Round-trip tables directly followed by content (T53219)
7152 !! options
7153 parsoid=wt2html,wt2wt
7154 !! wikitext
7155 {|
7156 |foo
7157 |} bar
7158
7159 {|
7160 |baz
7161 |}<b>quux</b>
7162 !! html+tidy
7163 <table>
7164 <tr>
7165 <td>foo</td>
7166 </tr>
7167 </table>
7168 <p>bar</p>
7169 <table>
7170 <tr>
7171 <td>baz</td>
7172 </tr>
7173 </table>
7174 <p><b>quux</b></p>
7175 !! end
7176
7177 !! test
7178 Parsoid: Default to a newline after tables in new content (T53219)
7179 !! options
7180 parsoid=html2wt
7181 !! html/parsoid
7182 <table><tbody>
7183 <tr><td>foo</td></tr></tbody></table> bar
7184 <table><tbody>
7185 <tr><td>baz</td></tr></tbody></table><b>quux</b>
7186 !! wikitext
7187 {|
7188 |foo
7189 |}
7190 <nowiki> </nowiki>bar
7191 {|
7192 |baz
7193 |}
7194 '''quux'''
7195 !! end
7196
7197 !! test
7198 Parsoid: newline inducing block nodes don't suppress <nowiki>
7199 !! options
7200 parsoid=html2wt
7201 !! html/parsoid
7202 a<h1>foo</h1>
7203 !! wikitext
7204 <nowiki> </nowiki>a
7205
7206 = foo =
7207 !! end
7208
7209 !! test
7210 Parsoid: Row-syntax table headings followed by comment & table cells
7211 !! options
7212 parsoid=wt2html,wt2wt
7213 !! wikitext
7214 {|
7215 ! foo || bar
7216 <!-- foo --> || baz || quux
7217 |}
7218 !! html/php
7219 <table>
7220 <tr>
7221 <th> foo </th>
7222 <th> bar
7223 </th>
7224 <td> baz </td>
7225 <td> quux
7226 </td></tr></table>
7227
7228 !! html/parsoid
7229 <table>
7230 <tbody><tr><th> foo </th><th> bar
7231 <!-- foo --> </th><td> baz </td><td> quux</td></tr>
7232 </tbody></table>
7233 !! end
7234
7235 !!test
7236 Parsoid: Recover better from broken table attributes
7237 !!options
7238 parsoid=wt2html
7239 !!wikitext
7240 {| class="foo
7241 | class="bar" |
7242 foo
7243 |}
7244 !!html/php+tidy
7245 <table class="foo">
7246 <tr>
7247 <td class="bar">
7248 <p>foo</p>
7249 </td>
7250 </tr>
7251 </table>
7252 !!html/parsoid
7253 <table class="foo">
7254 <tr>
7255 <td class="bar">
7256 <p>foo</p></td></tr>
7257 </tbody></table>
7258 !!end
7259
7260 !! test
7261 Tables: Digest broken attributes on table and tr tag
7262 !! options
7263 parsoid=wt2html
7264 !! wikitext
7265 {| || |} ++
7266 |- || || ++ --
7267 |- > [
7268 |}
7269 !! html
7270 <table>
7271 <tbody>
7272 <tr></tr>
7273 <tr></tr>
7274 </tbody></table>
7275 !! end
7276
7277 # T137406: Whitespace in the HTML
7278 !! test
7279 1. Generate correct wikitext for tables with thead/tbody/tfoot
7280 !! options
7281 parsoid=html2wt
7282 !! html/parsoid
7283 <table>
7284 <caption>Test</caption>
7285 <thead>
7286 <tr>
7287 <th>Month</th>
7288 <th>Savings</th>
7289 </tr>
7290 </thead>
7291 <tbody>
7292 <tr>
7293 <td>January</td>
7294 <td>$100</td>
7295 </tr>
7296 <tr>
7297 <td>February</td>
7298 <td>$80</td>
7299 </tr>
7300 </tbody>
7301 <tfoot>
7302 <tr>
7303 <td>Sum</td>
7304 <td>$180</td>
7305 </tr>
7306 </tfoot>
7307 </table>
7308 !! wikitext
7309 {|
7310 |+Test
7311 !Month
7312 !Savings
7313 |-
7314 |January
7315 |$100
7316 |-
7317 |February
7318 |$80
7319 |-
7320 |Sum
7321 |$180
7322 |}
7323 !! html/php+tidy
7324 <table>
7325 <caption>Test</caption>
7326 <tr>
7327 <th>Month</th>
7328 <th>Savings</th>
7329 </tr>
7330 <tr>
7331 <td>January</td>
7332 <td>$100</td>
7333 </tr>
7334 <tr>
7335 <td>February</td>
7336 <td>$80</td>
7337 </tr>
7338 <tr>
7339 <td>Sum</td>
7340 <td>$180</td>
7341 </tr>
7342 </table>
7343 !! end
7344
7345 # T137406: No whitespace in the HTML
7346 !! test
7347 2. Generate correct wikitext for tables with thead/tbody/tfoot
7348 !! options
7349 parsoid=html2wt
7350 !! html/parsoid
7351 <table><thead><tr><th>heading</th></tr></thead><tbody><tr><td>foo</td></tr></tbody></table>
7352 !! wikitext
7353 {|
7354 !heading
7355 |-
7356 |foo
7357 |}
7358 !! end
7359
7360 !! test
7361 Testing serialization after deletion in references
7362 !! options
7363 parsoid={
7364 "modes": ["wt2wt"],
7365 "changes": [
7366 ["#x", "remove"]
7367 ]
7368 }
7369 !! wikitext
7370 hi <ref><div id="x">ho</div></ref>
7371
7372 <references />
7373 !! wikitext/edited
7374 hi <ref></ref>
7375
7376 <references />
7377 !! end
7378
7379 !!test
7380 Testing serialization after deletion of table cells
7381 !!options
7382 parsoid={
7383 "modes": ["wt2wt", "selser"],
7384 "changes": [
7385 ["#x", "remove"]
7386 ]
7387 }
7388 !!wikitext
7389 {|
7390 !h1 !!h2 !!h3
7391 | id="x" |c1 {{!}}{{!}}{{!}}c2 |||c3
7392 |}
7393 !! wikitext/edited
7394 {|
7395 !h1 !!h2 !!h3
7396 |c2 |||c3
7397 |}
7398 !!end
7399
7400 !! test
7401 Testing selser after addition of new row before first row (T125419)
7402 !! options
7403 parsoid={
7404 "modes": ["wt2wt", "selser"],
7405 "changes": [
7406 [ "tr", "before", "<tr><td>X</td></tr>" ]
7407 ]
7408 }
7409 !! wikitext
7410 {|
7411 |a
7412 |}
7413 !! wikitext/edited
7414 {|
7415 |X
7416 |-
7417 |a
7418 |}
7419 !! end
7420
7421 !! test
7422 Serialize new table rows in a HTML table using HTML tags
7423 !! options
7424 parsoid={
7425 "modes": ["wt2wt", "selser"],
7426 "changes": [
7427 [ "tr", "before", "<tr><td>X</td></tr>" ]
7428 ]
7429 }
7430 !! wikitext
7431 <table><tr><td>a</td></tr></table>
7432 !! wikitext/edited
7433 <table><tr><td>X</td></tr><tr><td>a</td></tr></table>
7434 !! end
7435
7436 !! test
7437 Serialize new table cells in a HTML row using HTML tags
7438 !! options
7439 parsoid={
7440 "modes": ["wt2wt", "selser"],
7441 "changes": [
7442 [ "td", "before", "<td>X</td>" ]
7443 ]
7444 }
7445 !! wikitext
7446 <table><tr><td>a</td></tr></table>
7447 !! wikitext/edited
7448 <table><tr><td>X</td><td>a</td></tr></table>
7449 !! end
7450
7451 !! test
7452 Wikitext tables can be nested inside HTML tables
7453 !! options
7454 parsoid=html2wt
7455 !! html
7456 <table data-parsoid='{"stx":"html"}'>
7457 <tr><td>
7458 <table>
7459 <tr><td>foo</td></tr>
7460 </table>
7461 </td></tr>
7462 </table>
7463 !! wikitext
7464 <table>
7465 <tr><td>
7466 {|
7467 |foo
7468 |}
7469 </td></tr>
7470 </table>
7471 !! end
7472
7473 !! test
7474 Serialize wikitext list items as HTML list items when embedded in a HTML list
7475 !! options
7476 parsoid=html2wt
7477 !! html
7478 <ul data-parsoid='{"stx": "html"}'>
7479 <li data-parsoid='{}'>a</li>
7480 <li>b</li>
7481 </ul>
7482 !! wikitext
7483 <ul>
7484 <li>a</li>
7485 <li>b</li>
7486 </ul>
7487 !! end
7488
7489 # SSS FIXME: Is this actually a good thing given the
7490 # odd nested list output that is generated by MW?
7491 # <ul><li>foo<ul>..</ul></li></ul> instead of
7492 # <ul><li>foo</li><ul>..</ul></ul>
7493 !! test
7494 Wikitext lists can be nested inside HTML lists
7495 !! options
7496 parsoid=html2wt
7497 !! html
7498 <ul data-parsoid='{"stx": "html"}'>
7499 <li data-parsoid='{"stx": "html"}'>a
7500 <ul><li>b</li></ul>
7501 </li>
7502 </ul>
7503
7504 <ul data-parsoid='{"stx": "html"}'>
7505 <li>x
7506 <ul><li>y</li></ul>
7507 </li>
7508 </ul>
7509 !! wikitext
7510 <ul>
7511 <li>a
7512 * b
7513 </li>
7514 </ul>
7515
7516 <ul>
7517 <li>x
7518 * y
7519 </li>
7520 </ul>
7521 !! end
7522
7523 ###
7524 ### Internal links
7525 ###
7526 !! test
7527 Plain link, capitalized
7528 !! wikitext
7529 [[Main Page]]
7530 !! html
7531 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
7532 </p>
7533 !! end
7534
7535 !! test
7536 Plain link, uncapitalized
7537 !! wikitext
7538 [[main Page]]
7539 !! html
7540 <p><a href="/wiki/Main_Page" title="Main Page">main Page</a>
7541 </p>
7542 !! end
7543
7544 !! test
7545 Piped link
7546 !! wikitext
7547 [[Main Page|The Main Page]]
7548 !! html
7549 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7550 </p>
7551 !! end
7552
7553 !! test
7554 Piped link with comment in link text
7555 !! wikitext
7556 [[Main Page|The Main<!--front--> Page]]
7557 !! html
7558 <p><a href="/wiki/Main_Page" title="Main Page">The Main Page</a>
7559 </p>
7560 !! end
7561
7562 !! test
7563 Piped link with multiple pipe characters in link text
7564 !! wikitext
7565 [[Main Page||The|Main|Page|]]
7566 !! html/php
7567 <p><a href="/wiki/Main_Page" title="Main Page">|The|Main|Page|</a>
7568 </p>
7569 !! html/parsoid
7570 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">|The|Main|Page|</a></p>
7571 !! end
7572
7573 !! test
7574 Piped link with no link text
7575 !! wikitext
7576 [[Thomas Bek (bishop of St David's)|]]
7577 !! html/php
7578 <p>[[Thomas Bek (bishop of St David's)|]]
7579 </p>
7580 !! html/parsoid
7581 <p>[[Thomas Bek (bishop of St David's)|]]</p>
7582 !! end
7583
7584 !! test
7585 Piped link with empty link text
7586 !! wikitext
7587 [[Main Page|<nowiki/>]] - empty nowiki
7588 [[Main Page| ]] - empty space
7589 [[Main Page|&nbsp;]] - empty non breaking space
7590 !! html/php
7591 <p><a href="/wiki/Main_Page" title="Main Page"></a> - empty nowiki
7592 <a href="/wiki/Main_Page" title="Main Page"> </a> - empty space
7593 <a href="/wiki/Main_Page" title="Main Page">&#160;</a> - empty non breaking space
7594 </p>
7595 !! html/parsoid
7596 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page"><span typeof="mw:Nowiki"></span></a> - empty nowiki
7597 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page"> </a> - empty space
7598 <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>
7599 !! end
7600
7601 !! test
7602 Broken link
7603 !! wikitext
7604 [[Zigzagzogzagzig]]
7605 !! html
7606 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig</a>
7607 </p>
7608 !! end
7609
7610 !! test
7611 Broken link with fragment
7612 !! wikitext
7613 [[Zigzagzogzagzig#zug]]
7614 !! html
7615 <p><a href="/index.php?title=Zigzagzogzagzig&amp;action=edit&amp;redlink=1" class="new" title="Zigzagzogzagzig (page does not exist)">Zigzagzogzagzig#zug</a>
7616 </p>
7617 !! end
7618
7619 !! test
7620 Special page link with fragment
7621 !! wikitext
7622 [[Special:Version#anchor]]
7623 !! html
7624 <p><a href="/wiki/Special:Version#anchor" title="Special:Version">Special:Version#anchor</a>
7625 </p>
7626 !! end
7627
7628 !! test
7629 Nonexistent special page link with fragment
7630 !! wikitext
7631 [[Special:ThisNameWillHopefullyNeverBeUsed#anchor]]
7632 !! html
7633 <p><a href="/wiki/Special:ThisNameWillHopefullyNeverBeUsed" class="new" title="Special:ThisNameWillHopefullyNeverBeUsed (page does not exist)">Special:ThisNameWillHopefullyNeverBeUsed#anchor</a>
7634 </p>
7635 !! end
7636
7637 !! test
7638 Link with prefix
7639 !! wikitext
7640 xxx[[main Page]], xxx[[Main Page]], Xxx[[main Page]] XXX[[main Page]], XXX[[Main Page]]
7641 !! html
7642 <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>
7643 </p>
7644 !! end
7645
7646 !! test
7647 Link with suffix
7648 !! wikitext
7649 [[Main Page]]xxx, [[Main Page]]XXX, [[Main Page]]!!!
7650 !! html
7651 <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>!!!
7652 </p>
7653 !! end
7654
7655 !! article
7656 prefixed article
7657 !! text
7658 Some text
7659 !! endarticle
7660
7661 !! test
7662 T45661: Piped links with identical prefixes
7663 !! wikitext
7664 [[prefixed article|prefixed articles with spaces]]
7665
7666 [[prefixed article|prefixed articlesaoeu]]
7667
7668 [[Main Page|Main Page test]]
7669 !! html
7670 <p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articles with spaces</a>
7671 </p><p><a href="/wiki/Prefixed_article" title="Prefixed article">prefixed articlesaoeu</a>
7672 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page test</a>
7673 </p>
7674 !! end
7675
7676
7677 !! test
7678 Link with HTML entity in suffix / tail
7679 !! wikitext
7680 [[Main Page]]&quot;, [[Main Page]]&#97;
7681 !! html/php
7682 <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;
7683 </p>
7684 !! html/parsoid
7685 <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>
7686 !! end
7687
7688 !! test
7689 Link with 3 brackets
7690 !! wikitext
7691 [[[Main Page]]]
7692 Foo [[[Main Page]]]
7693 !! html
7694 <p>[[[Main Page]]]
7695 Foo [[[Main Page]]]
7696 </p>
7697 !! end
7698
7699 !! test
7700 Link with 4 brackets
7701 !! wikitext
7702 [[[[Main Page]]]]
7703 !! html
7704 <p>[[<a href="/wiki/Main_Page" title="Main Page">Main Page</a>]]
7705 </p>
7706 !! end
7707
7708 !! test
7709 Piped link with 3 brackets
7710 !! wikitext
7711 [[[main page|the main page]]]
7712 !! html
7713 <p>[[[main page|the main page]]]
7714 </p>
7715 !! end
7716
7717 !! test
7718 Piped link with extlink-like text
7719 !! wikitext
7720 [[Main Page|[bar]]]
7721 [[Main Page|This is a [bar]]]
7722 !! html/php
7723 <p><a href="/wiki/Main_Page" title="Main Page">[bar]</a>
7724 <a href="/wiki/Main_Page" title="Main Page">This is a [bar]</a>
7725 </p>
7726 !! html/parsoid
7727 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>[bar]</a>
7728 <a rel="mw:WikiLink" href="./Main_Page" title="Main Page" data-parsoid='{"stx":"piped"}'>This is a [bar]</a></p>
7729 !! end
7730
7731 !! test
7732 Link with multiple pipes
7733 !! wikitext
7734 [[Main Page|The|Main|Page]]
7735 !! html
7736 <p><a href="/wiki/Main_Page" title="Main Page">The|Main|Page</a>
7737 </p>
7738 !! end
7739
7740 !! test
7741 Anchor containing a #. (T65430)
7742 !! wikitext
7743 [[Main Page#And#Link]]
7744 !! html/php
7745 <p><a href="/wiki/Main_Page#And.23Link" title="Main Page">Main Page#And#Link</a>
7746 </p>
7747 !! html/parsoid
7748 <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>
7749 !! end
7750
7751 !! test
7752 Link to namespaces
7753 !! wikitext
7754 [[Talk:Parser testing]], [[Meta:Disclaimers]]
7755 !! html
7756 <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>
7757 </p>
7758 !! end
7759
7760 !! test
7761 Link with space in namespace
7762 !! wikitext
7763 [[User talk:Foo bar]]
7764 !! html
7765 <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>
7766 </p>
7767 !! end
7768
7769 !! article
7770 MemoryAlpha:AlphaTest
7771 !! text
7772 This is an article in the MemoryAlpha namespace
7773 (which shadows the memoryalpha interwiki link).
7774 !! endarticle
7775
7776 !! test
7777 Namespace takes precedence over interwiki link (T53680)
7778 !! wikitext
7779 [[MemoryAlpha:AlphaTest]]
7780 !! html
7781 <p><a href="/wiki/MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a>
7782 </p>
7783 !! end
7784
7785 # The previous test doesn't work correctly in html2*, due to not recognizing the
7786 # link as an internal one. This one checks for the correct behavior.
7787 !! test
7788 Link to namespace preferred over interwiki with correct rel attribute
7789 !! options
7790 parsoid=html2wt,html2html
7791 !! html/parsoid
7792 <p><a rel="mw:WikiLink" href="./MemoryAlpha:AlphaTest" title="MemoryAlpha:AlphaTest">MemoryAlpha:AlphaTest</a></p>
7793 !! wikitext
7794 [[MemoryAlpha:AlphaTest]]
7795 !! end
7796
7797 !! test
7798 Piped link to namespace
7799 !! wikitext
7800 [[Meta:Disclaimers|The disclaimers]]
7801 !! html
7802 <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>
7803 </p>
7804 !! end
7805
7806 !! test
7807 Link containing }
7808 !! wikitext
7809 [[Usually caused by a typo (oops}]]
7810 !! html
7811 <p>[[Usually caused by a typo (oops}]]
7812 </p>
7813 !! end
7814
7815 !! article
7816 7% Solution
7817 !! text
7818 Just a test of an article title containing a percent.
7819 !! endarticle
7820
7821 !! test
7822 Link containing % (not as a hex sequence)
7823 !! wikitext
7824 [[7% Solution]]
7825 [[7% Solution|7%25 Solution]]
7826 !! html/php
7827 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7828 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7829 </p>
7830 !! html/parsoid
7831 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7832 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7833 !! end
7834
7835 # note that the parsoid HTML is identical to the previous test output,
7836 # so the previous test ensures that the html2wt mode will generate the
7837 # "not as a hex sequence" wikitext.
7838 !! test
7839 Link containing % as a single hex sequence interpreted to char
7840 !! options
7841 parsoid=wt2wt,wt2html,html2html
7842 !! wikitext
7843 [[7%25 Solution]]
7844 [[7%25 Solution|7%25 Solution]]
7845 !! html/php
7846 <p><a href="/wiki/7%25_Solution" title="7% Solution">7% Solution</a>
7847 <a href="/wiki/7%25_Solution" title="7% Solution">7%25 Solution</a>
7848 </p>
7849 !! html/parsoid
7850 <p><a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7% Solution</a>
7851 <a rel="mw:WikiLink" href="./7%25_Solution" title="7% Solution">7%25 Solution</a></p>
7852 !!end
7853
7854 !! test
7855 Link containing % as a double hex sequence interpreted to hex sequence
7856 !! wikitext
7857 [[7%2525 Solution]]
7858 !! html
7859 <p>[[7%2525 Solution]]
7860 </p>
7861 !!end
7862
7863 ## Example for such a section: == < ==
7864 !! test
7865 Link containing "#<" and "#>" % as a hex sequences- these are valid section anchors
7866 !! wikitext
7867 [[%23%3c]][[%23%3e]]
7868 !! html/php
7869 <p><a href="#.3C">#&lt;</a><a href="#.3E">#&gt;</a>
7870 </p>
7871 !! html/parsoid
7872 <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>
7873 !! end
7874
7875 !! test
7876 Link containing "<#" and ">#" as a hex sequences
7877 !! wikitext
7878 [[%3c%23]][[%3e%23]]
7879 !! html
7880 <p>[[%3c%23]][[%3e%23]]
7881 </p>
7882 !! end
7883
7884 !! test
7885 Link containing an equals sign
7886 !! wikitext
7887 [[Special:BookSources/isbn=4-00-026157-6]]
7888 !! html/php
7889 <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>
7890 </p>
7891 !! html/parsoid
7892 <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>
7893 !! end
7894
7895 !! article
7896 Foo~bar
7897 !! text
7898 Just a test of an article title containing a tilde.
7899 !! endarticle
7900
7901 # note that links containing signatures, like [[Foo~~~~]], are
7902 # massaged by the pre-save transform (PST) and so the tildes are never
7903 # seen by the parser.
7904 !! test
7905 Link containing a tilde
7906 !! wikitext
7907 [[Foo~bar]]
7908 !! html/php
7909 <p><a href="/wiki/Foo~bar" title="Foo~bar">Foo~bar</a>
7910 </p>
7911 !! html/parsoid
7912 <p><a rel="mw:WikiLink" href="./Foo~bar" title="Foo~bar">Foo~bar</a></p>
7913 !! end
7914
7915 !! test
7916 Link containing double-single-quotes '' (T6598)
7917 !! wikitext
7918 [[Lista d''e paise d''o munno]]
7919 !! html/php
7920 <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''e paise d''o munno (page does not exist)">Lista d''e paise d''o munno</a>
7921 </p>
7922 !! html/parsoid
7923 <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>
7924 !! end
7925
7926 !! test
7927 Link containing double quotes and spaces
7928 !! wikitext
7929 [[Cool "Gator"]]
7930 !! html/php
7931 <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>
7932 </p>
7933 !! html/parsoid
7934 <p><a rel="mw:WikiLink" href="./Cool_%22Gator%22" title='Cool "Gator"'>Cool "Gator"</a></p>
7935 !! end
7936
7937 !! test
7938 File containing double quotes and spaces
7939 !! wikitext
7940 [[File:Cool "Gator".png]]
7941 !! html/parsoid
7942 <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>
7943 !! end
7944
7945 !! test
7946 Redirect containing double quotes and spaces
7947 !! wikitext
7948 #REDIRECT [[Cool "Gator"]]
7949 !! html/parsoid
7950 <link rel="mw:PageProp/redirect" href="./Cool_%22Gator%22" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Cool_%22Gator%22"},"sa":{"href":"Cool \"Gator\""}}'/>
7951 !! end
7952
7953 !! test
7954 Link containing double-single-quotes '' in text (T6598 sanity check)
7955 !! wikitext
7956 Some [[Link|pretty ''italics'' and stuff]]!
7957 !! html/php
7958 <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>!
7959 </p>
7960 !! html/parsoid
7961 <p>Some <a rel="mw:WikiLink" href="./Link" title="Link">pretty <i>italics</i> and stuff</a>!</p>
7962 !! end
7963
7964 !! test
7965 Link containing double-single-quotes '' in text embedded in italics (T6598 sanity check)
7966 !! wikitext
7967 ''Some [[Link|pretty ''italics'' and stuff]]!''
7968 !! html
7969 <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>
7970 </p>
7971 !! end
7972
7973 !! test
7974 Link with double quotes in title part (literal) and alternate part (interpreted)
7975 !! wikitext
7976 [[File:Denys_Savchenko_''Pentecoste''.jpg]]
7977
7978 [[''Pentecoste'']]
7979
7980 [[''Pentecoste''|Pentecoste]]
7981
7982 [[''Pentecoste''|''Pentecoste'']]
7983 !! html/php
7984 <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>
7985 </p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)">''Pentecoste''</a>
7986 </p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)">Pentecoste</a>
7987 </p><p><a href="/index.php?title=%27%27Pentecoste%27%27&amp;action=edit&amp;redlink=1" class="new" title="''Pentecoste'' (page does not exist)"><i>Pentecoste</i></a>
7988 </p>
7989 !! html/parsoid
7990 <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>
7991 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">''Pentecoste''</a></p>
7992 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''">Pentecoste</a></p>
7993 <p><a rel="mw:WikiLink" href="./''Pentecoste''" title="''Pentecoste''"><i>Pentecoste</i></a></p>
7994 !! end
7995
7996 !! test
7997 Broken image links with HTML captions (T41700)
7998 !! wikitext
7999 [[File:Nonexistent|<script></script>]]
8000 [[File:Nonexistent|100x100px|<script></script>]]
8001 [[File:Nonexistent|&lt;]]
8002 [[File:Nonexistent|a<i>b</i>c]]
8003 !! html/php
8004 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8005 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;script&gt;&lt;/script&gt;</a>
8006 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">&lt;</a>
8007 <a href="/index.php?title=Special:Upload&amp;wpDestFile=Nonexistent" class="new" title="File:Nonexistent">abc</a>
8008 </p>
8009 !! html/parsoid
8010 <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>
8011 <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>
8012 <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>
8013 <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>
8014 !! end
8015
8016 !! test
8017 Plain link to URL
8018 !! wikitext
8019 [[http://www.example.com]]
8020 !! html/php
8021 <p>[<a rel="nofollow" class="external autonumber" href="http://www.example.com">[1]</a>]
8022 </p>
8023 !! html/parsoid
8024 <p>[<a rel="mw:ExtLink" href="http://www.example.com"></a>]</p>
8025 !! end
8026
8027 !! test
8028 Plain link to URL with link text
8029 !! wikitext
8030 [[http://www.example.com Link text]]
8031 !! html
8032 <p>[<a rel="nofollow" class="external text" href="http://www.example.com">Link text</a>]
8033 </p>
8034 !! end
8035
8036 !! test
8037 Plain link to protocol-relative URL
8038 !! wikitext
8039 [[//www.example.com]]
8040 !! html/php
8041 <p>[<a rel="nofollow" class="external autonumber" href="//www.example.com">[1]</a>]
8042 </p>
8043 !! html/parsoid
8044 <p>[<a rel="mw:ExtLink" href="//www.example.com"></a>]</p>
8045 !! end
8046
8047 !! test
8048 Plain link to protocol-relative URL with link text
8049 !! wikitext
8050 [[//www.example.com Link text]]
8051 !! html
8052 <p>[<a rel="nofollow" class="external text" href="//www.example.com">Link text</a>]
8053 </p>
8054 !! end
8055
8056 !! test
8057 Plain link to page with question mark in title
8058 !! wikitext
8059 [[A?b]]
8060
8061 [[A?b|Baz]]
8062 !! html
8063 <p><a href="/wiki/A%3Fb" title="A?b">A?b</a>
8064 </p><p><a href="/wiki/A%3Fb" title="A?b">Baz</a>
8065 </p>
8066 !! end
8067
8068
8069 # I'm fairly sure the expected result here is wrong.
8070 # We want these to be URL links, not pseudo-pages with URLs for titles....
8071 # However the current output is also pretty screwy.
8072 #
8073 # ----
8074 # I'm changing it to match the current output--it arguably makes more
8075 # sense in the light of the test above. Old expected result was:
8076 #<p>Piped link to URL: <a href="/index.php?title=Http://www.example.com&amp;action=edit" class="new">an example URL</a>
8077 #</p>
8078 # But I think this test is bordering on "garbage in, garbage out" anyway.
8079 # -- wtm
8080 !! test
8081 Piped link to URL
8082 !! wikitext
8083 Piped link to URL: [[http://www.example.com|an example URL]]
8084 !! html/php
8085 <p>Piped link to URL: [<a rel="nofollow" class="external text" href="http://www.example.com%7Can">example URL</a>]
8086 </p>
8087 !! html/parsoid
8088 <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>
8089 !! end
8090
8091 !! test
8092 T2002: [[page|http://url/]] should link to page, not http://url/
8093 !! wikitext
8094 [[Main Page|http://url/]]
8095 !! html/php
8096 <p><a href="/wiki/Main_Page" title="Main Page">http://url/</a>
8097 </p>
8098 !! html/parsoid
8099 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">http://url/</a></p>
8100 !! end
8101
8102 # Parsoid does not mark self-links, by design.
8103 !! test
8104 T2337: Escaped self-links should be bold
8105 !! options
8106 title=[[Bug462]]
8107 !! wikitext
8108 [[Bu&#103;462]] [[Bug462]]
8109 !! html/php
8110 <p><a class="mw-selflink selflink">Bu&#103;462</a> <a class="mw-selflink selflink">Bug462</a>
8111 </p>
8112 !! html/php+tidy
8113 <p><a class="mw-selflink selflink">Bug462</a> <a class="mw-selflink selflink">Bug462</a></p>
8114 !! html/parsoid
8115 <p><a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a> <a rel="mw:WikiLink" href="./Bug462" title="Bug462">Bug462</a></p>
8116 !! end
8117
8118 !! test
8119 Self-link to section should not be bold
8120 !! options
8121 title=[[Main Page]]
8122 !! wikitext
8123 [[Main Page#section]]
8124 !! html
8125 <p><a href="/wiki/Main_Page#section" title="Main Page">Main Page#section</a>
8126 </p>
8127 !! end
8128
8129 !! article
8130 00
8131 !! text
8132 This is 00.
8133 !! endarticle
8134
8135 !!test
8136 Self-link to numeric title
8137 !!options
8138 title=[[0]]
8139 !! wikitext
8140 [[0]]
8141 !! html
8142 <p><a class="mw-selflink selflink">0</a>
8143 </p>
8144 !!end
8145
8146 !!test
8147 Link to numeric-equivalent title
8148 !!options
8149 title=[[0]]
8150 !! wikitext
8151 [[00]]
8152 !! html
8153 <p><a href="/wiki/00" title="00">00</a>
8154 </p>
8155 !!end
8156
8157 !! test
8158 <nowiki> inside a link
8159 !! wikitext
8160 [[Main<nowiki> Page</nowiki>]] [[Main Page|the main page <nowiki>[it's not very good]</nowiki>]]
8161 !! html
8162 <p>[[Main Page]] <a href="/wiki/Main_Page" title="Main Page">the main page [it's not very good]</a>
8163 </p>
8164 !! end
8165
8166 !! test
8167 Non-breaking spaces in title
8168 !! wikitext
8169 [[&nbsp; Main &nbsp; Page &nbsp;]]
8170 !! html
8171 <p><a href="/wiki/Main_Page" title="Main Page">&#160; Main &#160; Page &#160;</a>
8172 </p>
8173 !!end
8174
8175 !! test
8176 Internal link with ca linktrail, surrounded by bold apostrophes (T29473 primary issue)
8177 !! options
8178 language=ca
8179 !! wikitext
8180 '''[[Main Page]]'''
8181 !! html
8182 <p><b><a href="/wiki/Main_Page" title="Main Page">Main Page</a></b>
8183 </p>
8184 !! end
8185
8186 !! test
8187 Internal link with ca linktrail, surrounded by italic apostrophes (T29473 primary issue)
8188 !! options
8189 language=ca
8190 !! wikitext
8191 ''[[Main Page]]''
8192 !! html
8193 <p><i><a href="/wiki/Main_Page" title="Main Page">Main Page</a></i>
8194 </p>
8195 !! end
8196
8197 !! test
8198 Internal link with en linktrail: no apostrophes (T29473)
8199 !! options
8200 language=en
8201 !! wikitext
8202 [[Something]]'nice
8203 !! html
8204 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (page does not exist)">Something</a>'nice
8205 </p>
8206 !! end
8207
8208 !! test
8209 Internal link with ca linktrail with apostrophes (T29473)
8210 !! options
8211 language=ca
8212 !! wikitext
8213 [[Something]]'nice
8214 !! html
8215 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (encara no existeix)">Something'nice</a>
8216 </p>
8217 !! end
8218
8219 !! test
8220 Internal link with kaa linktrail with apostrophes (T29473)
8221 !! options
8222 language=kaa
8223 !! wikitext
8224 [[Something]]'nice
8225 !! html
8226 <p><a href="/index.php?title=Something&amp;action=edit&amp;redlink=1" class="new" title="Something (bet ele jaratılmag'an)">Something'nice</a>
8227 </p>
8228 !! end
8229
8230 !! test
8231 Link with multiple ":" in a subpage-supporting namespace (T65636)
8232 !! wikitext
8233 [[User:Foo/Test/63636:Bar|Test]]
8234 !! html/php
8235 <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>
8236 </p>
8237 !! html/parsoid
8238 <p><a rel="mw:WikiLink" href="./User:Foo/Test/63636:Bar" title="User:Foo/Test/63636:Bar">Test</a></p>
8239 !! end
8240
8241 ## Mainly a sanity check for Parsoid
8242 !! test
8243 Handle title parsing for subpages
8244 !! options
8245 title=[[/123123]]
8246 subpage
8247 !! wikitext
8248 123
8249 !! html/php
8250 <p>123
8251 </p>
8252 !! html/parsoid
8253 <p>123</p>
8254 !! end
8255
8256 !! article
8257 User:Test/123
8258 !! text
8259 test 123
8260 !! endarticle
8261
8262 !! test
8263 Link to a subpage from a namespace other than main
8264 !! options
8265 title=[[User:Test]]
8266 subpage
8267 !! wikitext
8268 [[/123]]
8269 !! html/php
8270 <p><a href="/wiki/User:Test/123" title="User:Test/123">/123</a>
8271 </p>
8272 !! html/parsoid
8273 <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>
8274 !! end
8275
8276 !! test
8277 Ensure that transclusion titles are not url-decoded
8278 !! options
8279 subpage title=[[Test]]
8280 parsoid=wt2html
8281 !! wikitext
8282 {{Bar%C3%A9}} {{/Bar%C3%A9}}
8283 !! html/php
8284 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}
8285 </p>
8286 !! html/parsoid
8287 <p>{{Bar%C3%A9}} {{/Bar%C3%A9}}</p>
8288 !! end
8289
8290 !! test
8291 Purely hash wikilink
8292 !! options
8293 title=[[User:Test/123]]
8294 subpage
8295 !! wikitext
8296 [[#a|b]]
8297 !! html/php
8298 <p><a href="#a">b</a>
8299 </p>
8300 !! html/parsoid
8301 <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>
8302 !! end
8303
8304 !! test
8305 1. Interaction of linktrail and template encapsulation
8306 !! wikitext
8307 {{echo|[[Foo]]}}l
8308 !! html/parsoid
8309 <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>
8310 !! end
8311
8312 !! test
8313 2. Interaction of linktrail and template encapsulation
8314 !! options
8315 parsoid
8316 !! wikitext
8317 {{echo|Some [[Fool]]}}s
8318 !! html
8319 <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>
8320 !! end
8321
8322 !! test
8323 3. Interaction of linktrail and template encapsulation
8324 !! options
8325 parsoid
8326 !! wikitext
8327 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8328 !! html
8329 <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>
8330 !! end
8331
8332 !! article
8333 Söfnuður
8334 !! text
8335 Test.
8336 !! endarticle
8337
8338 !! test
8339 Internal link with is link prefix
8340 !! options
8341 language=is
8342 !! wikitext
8343 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8344 !! html
8345 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8346 </p>
8347 !! end
8348
8349 !! article
8350 Mótmælendatrú
8351 !! text
8352 Test.
8353 !! endarticle
8354
8355 !! test
8356 Internal link with is link trail and link prefix
8357 !! options
8358 language=is
8359 !! wikitext
8360 [[mótmælendatrú|xxx]]ar
8361 [[mótmælendatrú]]ar
8362 mótmælenda[[söfnuður]]
8363 mótmælenda[[söfnuður|söfnuðir]]
8364 mótmælenda[[söfnuður|söfnuðir]]xxx
8365 !! html
8366 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8367 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8368 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8369 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8370 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8371 </p>
8372 !! end
8373
8374 !! test
8375 Parsoid link trail escaping
8376 !! options
8377 parsoid=html2wt,html2html
8378 !! html/parsoid
8379 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8380 !! wikitext
8381 [[apple]]<nowiki/>s
8382 !! end
8383
8384 !! test
8385 Parsoid link prefix escaping
8386 !! options
8387 language=is
8388 parsoid=html2wt,html2html
8389 !! html/parsoid
8390 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8391 !! wikitext
8392 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8393 !! end
8394
8395 !! test
8396 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8397 !! wikitext
8398 [[Foo| bar]]
8399
8400 [[Foo| ''bar'']]
8401
8402 [http://wp.org foo]
8403
8404 [http://wp.org ''foo'']
8405 !! html
8406 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8407 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8408 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8409 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8410 </p>
8411 !! end
8412
8413 !! test
8414 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8415 !! wikitext
8416 [[Foo|{{echo|a}} b {{echo|c}}]]
8417 !! html/parsoid
8418 <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>
8419 !! end
8420
8421 !! test
8422 Link with angle bracket after anchor
8423 !! wikitext
8424 [[Foo#<bar>]]
8425 !! html/php
8426 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8427 </p>
8428 !! html/parsoid
8429 <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>
8430 !! end
8431
8432 ###
8433 ### Interwiki links (see maintenance/interwiki.sql)
8434 ###
8435
8436 !! test
8437 Inline interwiki link
8438 !! options
8439 parsoid=wt2html,wt2wt,html2html
8440 !! wikitext
8441 [[MeatBall:SoftSecurity]]
8442 !! html/php
8443 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8444 </p>
8445 !! html/parsoid
8446 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8447 !! end
8448
8449 !! test
8450 Inline interwiki link with empty title (T4372)
8451 !! options
8452 parsoid=wt2html,wt2wt,html2html
8453 !! wikitext
8454 [[MeatBall:]]
8455 !! html/php
8456 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8457 </p>
8458 !! html/parsoid
8459 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8460 !! end
8461
8462 !! test
8463 Interwiki link encoding conversion (T3636)
8464 !! wikitext
8465 *[[Wikipedia:ro:Olteni&#0355;a]]
8466 *[[Wikipedia:ro:Olteni&#355;a]]
8467 !! html
8468 <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>
8469 <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>
8470
8471 !! html+tidy
8472 <ul>
8473 <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>
8474 <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>
8475 </ul>
8476 !! end
8477
8478 !! test
8479 Interwiki link with fragment (T4130)
8480 !! wikitext
8481 [[MeatBall:SoftSecurity#foo]]
8482 !! html
8483 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8484 </p>
8485 !! end
8486
8487 !! test
8488 Link scenarios with escaped fragments
8489 !! wikitext
8490 [[#Is this great?]]
8491 [[Foo#Is this great?]]
8492 [[meatball:Foo#Is this great?]]
8493 !! html/php
8494 <p><a href="#Is_this_great.3F">#Is this great?</a>
8495 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8496 <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>
8497 </p>
8498 !! html/parsoid
8499 <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>
8500 <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>
8501 <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>
8502 !! end
8503
8504 # Ideally the wikipedia: prefix here should be proto-relative too
8505 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8506 # define the 'en' prefix, and originally the test used 'wikipedia',
8507 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8508 # article.
8509 !! test
8510 Different interwiki prefixes mapping to the same URL
8511 !! wikitext
8512 [[:en:Foo]]
8513
8514 [[:en:Foo|Foo]]
8515
8516 [[wikipedia:Foo]]
8517
8518 [[:wikipedia:Foo|Foo]]
8519
8520 [[wikipedia:en:Foo]]
8521
8522 [[:wikipedia:en:Foo]]
8523
8524 [[ wikiPEdia :Foo]]
8525 !! html/parsoid
8526 <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>
8527
8528 <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>
8529
8530 <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>
8531
8532 <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>
8533
8534 <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>
8535
8536 <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>
8537
8538 <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>
8539 !! end
8540
8541 !! test
8542 Interwiki links that cannot be represented in wiki syntax
8543 !! wikitext
8544 [[meatball:ok]]
8545 [[meatball:ok#foo|ok with fragment]]
8546 [[meatball:ok_as_well?|ok ending with ? mark]]
8547 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8548 [http://de.wikipedia.org/wiki/#foo is just fragment]
8549
8550 !! html/php
8551 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8552 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8553 <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>
8554 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8555 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8556 </p>
8557 !! html/parsoid
8558 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8559 <a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8560 <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>
8561 <a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8562 <a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8563 !! end
8564
8565 !! test
8566 Interwiki links: trail
8567 !! wikitext
8568 [[wikipedia:Foo|Ba]]r
8569 !! html/php
8570 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8571 </p>
8572 !! html/parsoid
8573 <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>
8574 !! end
8575
8576 !! test
8577 Local interwiki link
8578 !! options
8579 parsoid=wt2html,wt2wt,html2html
8580 !! wikitext
8581 [[local:Template:Foo]]
8582 !! html/php
8583 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8584 </p>
8585 !! html/parsoid
8586 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8587 !! end
8588
8589 # Parsoid does not mark self-links, by design.
8590 !! test
8591 Local interwiki link: self-link to current page
8592 !! options
8593 title=[[Main Page]]
8594 parsoid=wt2html,wt2wt,html2html
8595 !! wikitext
8596 [[local:Main Page]]
8597 !! html/php
8598 <p><a class="mw-selflink selflink">local:Main Page</a>
8599 </p>
8600 !! html/parsoid
8601 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8602 !! end
8603
8604 !! test
8605 Local interwiki link: prefix only (T66167)
8606 !! options
8607 parsoid=wt2html,wt2wt,html2html
8608 !! wikitext
8609 [[local:]]
8610 !! html/php
8611 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8612 </p>
8613 !! html/parsoid
8614 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8615 !! end
8616
8617 !! test
8618 Local interwiki link: with additional interwiki prefix (T63357)
8619 !! options
8620 parsoid=wt2html,wt2wt,html2html
8621 !! wikitext
8622 [[local:meatball:Hello]]
8623 !! html/php
8624 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8625 </p>
8626 !! html/parsoid
8627 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8628 !! end
8629
8630 !! test
8631 Multiple local interwiki link prefixes
8632 !! wikitext
8633 [[local:local:local:local:mi:local:Foo]]
8634 !! options
8635 parsoid=wt2html,wt2wt,html2html
8636 !! html/php
8637 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8638 </p>
8639 !! html/parsoid
8640 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8641 !! end
8642
8643 ###
8644 ### Interlanguage links
8645 ### Language links (so that searching for '### language' matches..)
8646 ###
8647
8648 !! test
8649 Interlanguage link
8650 !! wikitext
8651 Blah blah blah
8652 [[zh:Chinese]]
8653 !! html/php
8654 <p>Blah blah blah
8655 </p>
8656 !! html/parsoid
8657 <p>Blah blah blah</p>
8658 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8659 !! end
8660
8661 ## parsoid html2wt will lose the space variations
8662 !! test
8663 Interlanguage link with spacing
8664 !! options
8665 parsoid=wt2html,wt2wt,html2html
8666 !! wikitext
8667 Blah blah blah
8668 [[ zh : Chinese ]]
8669 !! html/php
8670 <p>Blah blah blah
8671 </p>
8672 !! html/parsoid
8673 <p>Blah blah blah</p>
8674 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8675 !! end
8676
8677 !! test
8678 Double interlanguage link
8679 !! wikitext
8680 Blah blah blah
8681 [[es:Spanish]]
8682 [[zh:Chinese]]
8683 !! html/php
8684 <p>Blah blah blah
8685 </p>
8686 !! html/parsoid
8687 <p>Blah blah blah</p>
8688 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8689 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8690 !! end
8691
8692 ## parsoid html2wt will lose the space variations
8693 !! test
8694 Interlanguage link variations
8695 !! options
8696 parsoid=wt2html,wt2wt,html2html
8697 !! wikitext
8698 Blah blah blah
8699 [[ es :Spanish]]
8700 [[ ZH :Chinese]]
8701 [[es:Foo_bar]]
8702 !! html/php
8703 <p>Blah blah blah
8704 </p>
8705 !! html/parsoid
8706 <p>Blah blah blah</p>
8707 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
8708 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
8709 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
8710 !! end
8711
8712 !! test
8713 Escaping of interlanguage links (T129218, T156308)
8714 !! wikitext
8715 Blah blah blah
8716 [[:es:Spanish]]
8717 [[ : zh : Chinese ]]
8718 !! html/php
8719 <p>Blah blah blah
8720 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8721 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
8722 </p>
8723 !! html/parsoid
8724 <p>Blah blah blah
8725 <a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8726 <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
8727 !! end
8728
8729 ## parsoid html2wt will normalize the space to _
8730 !! test
8731 Space and question mark encoding in interlanguage links (T95473)
8732 !! options
8733 parsoid=wt2html,wt2wt,html2html
8734 !! wikitext
8735 Blah blah blah
8736 [[es:Foo bar?]]
8737 !! html/php
8738 <p>Blah blah blah
8739 </p>
8740 !! html/parsoid
8741 <p>Blah blah blah</p>
8742 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar%3F" />
8743 !! end
8744
8745 !! test
8746 Interlanguage link, with prefix links
8747 !! options
8748 language=ln
8749 !! wikitext
8750 Blah blah blah
8751 [[zh:Chinese]]
8752 !! html/php
8753 <p>Blah blah blah
8754 </p>
8755 !! html/parsoid
8756 <p>Blah blah blah</p>
8757 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8758 !! end
8759
8760 !! test
8761 Double interlanguage link, with prefix links (T10897)
8762 !! options
8763 language=ln
8764 !! wikitext
8765 Blah blah blah
8766 [[es:Spanish]]
8767 [[zh:Chinese]]
8768 !! html/php
8769 <p>Blah blah blah
8770 </p>
8771 !! html/parsoid
8772 <p>Blah blah blah</p>
8773 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8774 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8775 !! end
8776
8777 !! test
8778 "Extra" interlanguage links (T34189 / gerrit 111390)
8779 !! wikitext
8780 Blah blah blah
8781 [[mul:Article]]
8782 !! html/php
8783 <p>Blah blah blah
8784 </p>
8785 !! html/parsoid
8786 <p>Blah blah blah</p>
8787 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
8788 !! end
8789
8790 ## PHP parser tests script needs an update
8791 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8792 !! test
8793 Language links render as inline links if $wgInterwikiMagic=false
8794 !! options
8795 wgInterwikiMagic=false
8796 parsoid=wt2html,wt2wt,html2html
8797 !! wikitext
8798 Blah blah blah
8799 [[zh:Chinese]]
8800 !! html/parsoid
8801 <p>Blah blah blah <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
8802 !! end
8803
8804 ## PHP parser tests script needs an update
8805 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8806 !! test
8807 Language links render as inline links in the Talk namespace
8808 !! options
8809 title=Talk:Foo
8810 parsoid=wt2html,wt2wt,html2html
8811 !! wikitext
8812 Blah blah blah
8813 [[zh:Chinese]]
8814 !! html/parsoid
8815 <p>Blah blah blah <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
8816 !! end
8817
8818 !! test
8819 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
8820 !! options
8821 language=ln
8822 !! wikitext
8823 [[WW&nbsp;II]]
8824 !! html
8825 <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>
8826 </p>
8827 !! end
8828
8829 !! test
8830 Parsoid T55221: Wikilinks should be properly entity-escaped
8831 !! options
8832 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
8833 !! html/parsoid
8834 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
8835 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
8836 !! wikitext
8837 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
8838
8839 He&amp;nbsp;llo He&amp;nbsp;llo
8840 !! html/php
8841 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
8842 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
8843 </p>
8844 !! end
8845
8846 # html2wt will fail because of title normalization without data-parsoid
8847 !! test
8848 Parsoid: handle constructor well
8849 !! options
8850 parsoid=wt2html,wt2wt
8851 !! wikitext
8852 [[constructor]]
8853
8854 [[constructor:foo]]
8855 !! html/php
8856 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
8857 </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>
8858 </p>
8859 !! html/parsoid
8860 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
8861
8862 <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>
8863 !! end
8864
8865 !! article
8866 ko:
8867 !! text
8868 Test.
8869 !! endarticle
8870
8871 # Note that `ko` isn't a known interlanguage prefix
8872 !! test
8873 Parsoid: recognize interlanguage links without a target page
8874 !! options
8875 ill
8876 !! wikitext
8877 [[es:]]
8878
8879 [[ko:]]
8880 !! html/php
8881 es:
8882 !! html/parsoid
8883 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
8884
8885 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
8886 !! end
8887
8888 # Note that `ko` isn't a known interwiki prefix
8889 !! test
8890 Parsoid: recognize interwiki links without a target page
8891 !! options
8892 parsoid=wt2html,wt2wt,html2html
8893 !! wikitext
8894 [[:es:]]
8895
8896 [[:ko:]]
8897 !! html/php
8898 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
8899 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
8900 </p>
8901 !! html/parsoid
8902 <p><a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
8903 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
8904 !! end
8905
8906 !! test
8907 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
8908 !! wikitext
8909 [[mi:Foo]]
8910 !! html/php
8911 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
8912 </p>
8913 !! html/parsoid
8914 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
8915 !! end
8916
8917 !! test
8918 Interlanguage link with preceding local interwiki link (T70085)
8919 !! options
8920 parsoid=wt2html,wt2wt,html2html
8921 !! wikitext
8922 Blah blah blah
8923 [[local:es:Spanish]]
8924 !! html/php
8925 <p>Blah blah blah
8926 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
8927 </p>
8928 !! html/parsoid
8929 <p>Blah blah blah
8930 <a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
8931 !! end
8932
8933 !! test
8934 Looks like an interlanguage link, but is actually a local interwiki
8935 !! options
8936 parsoid=wt2html,wt2wt,html2html
8937 !! wikitext
8938 Blah blah blah
8939 [[mi:Template:Foo]]
8940 !! html/php
8941 <p>Blah blah blah
8942 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
8943 </p>
8944 !! html/parsoid
8945 <p>Blah blah blah
8946 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
8947 !! end
8948
8949 ###
8950 ### Redirects, Parsoid-only
8951 ###
8952
8953 !! test
8954 1. Simple redirect to page
8955 !! wikitext
8956 #REDIRECT [[Main Page]]
8957 !! html/parsoid
8958 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
8959 !! end
8960
8961 !! test
8962 2. Other redirect variants
8963 !! wikitext
8964 #REDIRECT [[Main_Page]]
8965 !! html/parsoid
8966 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
8967 !! end
8968
8969 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
8970 # This tests the Parsoid bail-out code.
8971 !! test
8972 3. Other redirect variants
8973 !! wikitext
8974 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
8975 !! html/parsoid
8976 <ol><li data-parsoid>REDIRECT [[[[Bar]]]]</li></ol>
8977 !! end
8978
8979 !! test
8980 4. Redirect to a templated destination
8981 !! wikitext
8982 #REDIRECT [[{{echo|Foo}}bar]]
8983 !! html/parsoid
8984 <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"}]]}'/>
8985 !! end
8986
8987 !! test
8988 Empty redirect
8989 !! options
8990 parsoid=wt2html,wt2wt
8991 !! wikitext
8992 #REDIRECT [[]]
8993 !! html/parsoid
8994 <ol>
8995 <li>REDIRECT [[]]</li></ol>
8996 !! end
8997
8998 !! test
8999 Optional colon in #REDIRECT
9000 !! options
9001 # the colon is archaic syntax. we support it for wt2html, but we
9002 # don't care that it roundtrips back to the modern syntax.
9003 parsoid=wt2html,html2html
9004 !! wikitext
9005 #REDIRECT:[[Main Page]]
9006 !! html/parsoid
9007 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9008 !! end
9009
9010 !! test
9011 Whitespace in #REDIRECT with optional colon
9012 !! options
9013 # the colon and gratuitous whitespace is archaic syntax. we support
9014 # it for wt2html, but we don't care that it roundtrips back to the
9015 # modern syntax (without extra whitespace)
9016 parsoid=wt2html,html2html
9017 !! wikitext
9018
9019 #REDIRECT
9020 :
9021 [[Main Page]]
9022 !! html/parsoid
9023 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9024 !! end
9025
9026 !! test
9027 Piped link in #REDIRECT
9028 !! options
9029 # content after piped link is ignored. we support this syntax,
9030 # but don't care that the piped link is lost when we roundtrip this.
9031 parsoid=wt2html
9032 !! wikitext
9033 #REDIRECT [[Main Page|bar]]
9034 !! html/parsoid
9035 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9036 !! end
9037
9038 !! test
9039 Redirect to category (T104502)
9040 !! options
9041 parsoid=wt2html,wt2wt
9042 !! wikitext
9043 #REDIRECT [[Category:Foo]]
9044 !! html/parsoid
9045 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9046 !! end
9047
9048 !! test
9049 Redirect to category with URL encoding (T104502)
9050 !! options
9051 parsoid=wt2html
9052 !! wikitext
9053 #REDIRECT [[Category%3AFoo]]
9054 !! html/parsoid
9055 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9056 !! end
9057
9058 !! test
9059 Redirect to category page
9060 !! wikitext
9061 #REDIRECT [[:Category:Foo]]
9062 !! html/parsoid
9063 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9064 !! end
9065
9066 !! test
9067 Redirect to image page (1)
9068 !! wikitext
9069 #REDIRECT [[File:Wiki.png]]
9070 !! html/parsoid
9071 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9072 !! end
9073
9074 !! test
9075 Redirect to image page (2)
9076 !! wikitext
9077 #REDIRECT [[Image:Wiki.png]]
9078 !! html/parsoid
9079 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9080 !! end
9081
9082 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9083 # Next test confirms this.
9084 !! test
9085 Redirect to language (1) (T104918)
9086 !! options
9087 parsoid=wt2html,wt2wt,html2html
9088 !! wikitext
9089 #REDIRECT [[en:File:Wiki.png]]
9090 !! html/parsoid
9091 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9092 !! end
9093
9094 !! test
9095 Redirect to language (2) (T104918)
9096 !! wikitext
9097 #REDIRECT [[:en:File:Wiki.png]]
9098 !! html/parsoid
9099 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9100 !! end
9101
9102 !! test
9103 Redirect to interwiki (T104918)
9104 !! wikitext
9105 #REDIRECT [[meatball:File:Wiki.png]]
9106 !! html/parsoid
9107 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9108 !! end
9109
9110 !! test
9111 Non-English #REDIRECT
9112 !! options
9113 language=is
9114 !! wikitext
9115 #TILVÍSUN [[Main Page]]
9116 !! html/parsoid
9117 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9118 !! end
9119
9120 !! test
9121 Redirect syntax under text isn't considered a redirect
9122 !! wikitext
9123 some text
9124 #redirect [[Main Page]]
9125 !! html/parsoid
9126 <p>some text</p>
9127 <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>
9128 !! end
9129
9130 # FIXME: Should hoist the redirect to the top of the page and ensure there
9131 # is only one.
9132 !! test
9133 New redirect
9134 !! options
9135 parsoid=html2wt
9136 !! html/parsoid
9137 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9138 !! wikitext
9139 Foo
9140 #REDIRECT [[Foo]]
9141 !! end
9142
9143 ##
9144 ## XHTML tidiness
9145 ###
9146
9147 !! test
9148 <br> to <br />
9149 !! wikitext
9150 1<br>2<br />3
9151 !! html
9152 <p>1<br />2<br />3
9153 </p>
9154 !! end
9155
9156 !! test
9157 Broken br tag sanitization
9158 !! wikitext
9159 </br>
9160 !! html/php
9161 <p>&lt;/br&gt;
9162 </p>
9163 !! end
9164
9165 # TODO: Fix html2html mode (T53055)!
9166 !! test
9167 Parsoid: Broken br tag recognition
9168 !! options
9169 parsoid=wt2html
9170 !! wikitext
9171 </br>
9172
9173 <br/ >
9174 !! html+tidy
9175 <p><br /></p>
9176 <p><br /></p>
9177 !! end
9178
9179 !! test
9180 Incorrecly removing closing slashes from correctly formed XHTML
9181 !! wikitext
9182 <br style="clear:both;" />
9183 !! html
9184 <p><br style="clear:both;" />
9185 </p>
9186 !! end
9187
9188 !! test
9189 Failing to transform badly formed HTML into correct XHTML
9190 !! wikitext
9191 <br style="clear: left;">
9192 <br style="clear: right;">
9193 <br style="clear: both;">
9194 !! html
9195 <p><br style="clear: left;" />
9196 <br style="clear: right;" />
9197 <br style="clear: both;" />
9198 </p>
9199 !!end
9200
9201 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9202 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9203 !! test
9204 Handling html with a div self-closing tag
9205 !! wikitext
9206 <div title />
9207 <div title/>
9208 <div title/ >
9209 <div title=bar />
9210 <div title=bar/>
9211 <div title=bar/ >
9212 !! html/php
9213 <p>&lt;div title /&gt;
9214 &lt;div title/&gt;
9215 </p>
9216 <div>
9217 <p>&lt;div title=bar /&gt;
9218 &lt;div title=bar/&gt;
9219 </p>
9220 <div title="bar/"></div>
9221 </div>
9222
9223 !! html/parsoid
9224 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9225 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9226 <div title="" data-parsoid='{"stx":"html","selfClose":true,"brokenHTMLTag":true}'></div>
9227 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9228 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9229 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>
9230 !! end
9231
9232 !! test
9233 Handling html with a br self-closing tag
9234 !! wikitext
9235 <br title />
9236 <br title/>
9237 <br title/ >
9238 <br title=bar />
9239 <br title=bar/>
9240 <br title=bar/ >
9241 !! html/php
9242 <p><br title="" />
9243 <br title="" />
9244 <br />
9245 <br title="bar" />
9246 <br title="bar" />
9247 <br title="bar/" />
9248 </p>
9249 !! html/parsoid
9250 <p><br title="" />
9251 <br title="" />
9252 <br title="" />
9253 <br title="bar" />
9254 <br title="bar" />
9255 <br title="bar/" />
9256 </p>
9257 !! end
9258
9259 !! test
9260 Horizontal ruler (should it add that extra space?)
9261 !! wikitext
9262 <hr>
9263 <hr >
9264 foo <hr
9265 > bar
9266 !! html+tidy
9267 <hr />
9268 <hr />
9269 <p>foo</p>
9270 <hr />
9271 <p>bar</p>
9272 !! end
9273
9274 !! test
9275 Horizontal ruler -- 4+ dashes render hr
9276 !! wikitext
9277 ----
9278 !! html
9279 <hr />
9280
9281 !! end
9282
9283 !! test
9284 Horizontal ruler -- eats additional dashes on the same line
9285 !! wikitext
9286 ---------
9287 !! html
9288 <hr />
9289
9290 !! end
9291
9292 !! test
9293 Horizontal ruler -- does not collapse dashes on consecutive lines
9294 !! wikitext
9295 ----
9296 ----
9297 !! html
9298 <hr />
9299 <hr />
9300
9301 !! end
9302
9303 !! test
9304 Horizontal ruler -- <4 dashes render as plain text
9305 !! wikitext
9306 ---
9307 !! html
9308 <p>---
9309 </p>
9310 !! end
9311
9312 !! test
9313 Horizontal ruler -- Supports content following dashes on same line
9314 !! wikitext
9315 ---- Foo
9316 !! html
9317 <hr /> Foo
9318
9319 !! html+tidy
9320 <hr />
9321 <p>Foo</p>
9322 !! end
9323
9324 ###
9325 ### Block-level elements
9326 ###
9327 !! test
9328 Common list
9329 !! wikitext
9330 *Common list
9331 * item 2
9332 *item 3
9333 !! html
9334 <ul><li>Common list</li>
9335 <li> item 2</li>
9336 <li>item 3</li></ul>
9337
9338 !! end
9339
9340 !! test
9341 Numbered list
9342 !! wikitext
9343 #Numbered list
9344 #item 2
9345 # item 3
9346 !! html
9347 <ol><li>Numbered list</li>
9348 <li>item 2</li>
9349 <li> item 3</li></ol>
9350
9351 !! end
9352
9353 !! test
9354 Mixed list
9355 !! wikitext
9356 *Mixed list
9357 *# with numbers
9358 ** and bullets
9359 *# and numbers
9360 *bullets again
9361 **bullet level 2
9362 ***bullet level 3
9363 ***#Number on level 4
9364 **bullet level 2
9365 **#Number on level 3
9366 **#Number on level 3
9367 *#number level 2
9368 *Level 1
9369 *** Level 3
9370 #** Level 3, but ordered
9371 !! html
9372 <ul><li>Mixed list
9373 <ol><li> with numbers</li></ol>
9374 <ul><li> and bullets</li></ul>
9375 <ol><li> and numbers</li></ol></li>
9376 <li>bullets again
9377 <ul><li>bullet level 2
9378 <ul><li>bullet level 3
9379 <ol><li>Number on level 4</li></ol></li></ul></li>
9380 <li>bullet level 2
9381 <ol><li>Number on level 3</li>
9382 <li>Number on level 3</li></ol></li></ul>
9383 <ol><li>number level 2</li></ol></li>
9384 <li>Level 1
9385 <ul><li><ul><li> Level 3</li></ul></li></ul></li></ul>
9386 <ol><li><ul><li><ul><li> Level 3, but ordered</li></ul></li></ul></li></ol>
9387
9388 !! end
9389
9390 !! test
9391 1. Nested mixed wikitext and html list
9392 !! wikitext
9393 * hi
9394 * <ul><li>ho</li></ul>
9395 * hi
9396 ** ho
9397 !! html/php
9398 <ul><li> hi</li>
9399 <li> <ul><li>ho</li></ul></li>
9400 <li> hi
9401 <ul><li> ho</li></ul></li></ul>
9402
9403 !! html/parsoid
9404 <ul><li> hi</li>
9405 <li> <ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9406 <li> hi
9407 <ul><li> ho</li></ul></li></ul>
9408 !! end
9409
9410 !! test
9411 2. Nested mixed wikitext and html list (incompatible)
9412 !! wikitext
9413 ; hi
9414 : {{echo|<li>ho</li>}}
9415 !! html/php
9416 <dl><dt> hi</dt>
9417 <dd> <li>ho</li></dd></dl>
9418
9419 !! html/parsoid
9420 <dl><dt> hi</dt>
9421 <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>
9422 !! end
9423
9424 !! test
9425 Nested lists 1
9426 !! wikitext
9427 *foo
9428 **bar
9429 !! html
9430 <ul><li>foo
9431 <ul><li>bar</li></ul></li></ul>
9432
9433 !! end
9434
9435 !! test
9436 Nested lists 2
9437 !! wikitext
9438 **foo
9439 *bar
9440 !! html
9441 <ul><li><ul><li>foo</li></ul></li>
9442 <li>bar</li></ul>
9443
9444 !! end
9445
9446 !! test
9447 Nested lists 3 (first element empty)
9448 !! wikitext
9449 *
9450 **bar
9451 !! html
9452 <ul><li>
9453 <ul><li>bar</li></ul></li></ul>
9454
9455 !! end
9456
9457 !! test
9458 Nested lists 4 (first element empty)
9459 !! wikitext
9460 **
9461 *bar
9462 !! html
9463 <ul><li><ul><li></li></ul></li>
9464 <li>bar</li></ul>
9465
9466 !! end
9467
9468 !! test
9469 Nested lists 5 (both elements empty)
9470 !! wikitext
9471 **
9472 *
9473 !! html
9474 <ul><li><ul><li></li></ul></li>
9475 <li></li></ul>
9476
9477 !! end
9478
9479 !! test
9480 Nested lists 6 (both elements empty)
9481 !! wikitext
9482 *
9483 **
9484 !! html
9485 <ul><li>
9486 <ul><li></li></ul></li></ul>
9487
9488 !! end
9489
9490 !! test
9491 Nested lists 7 (skip initial nesting levels)
9492 !! wikitext
9493 *** foo
9494 !! html
9495 <ul><li><ul><li><ul><li> foo</li></ul></li></ul></li></ul>
9496
9497 !! end
9498
9499 !! test
9500 Nested lists 8 (multiple nesting transitions)
9501 !! wikitext
9502 * foo
9503 *** bar
9504 ** baz
9505 * boo
9506 !! html
9507 <ul><li> foo
9508 <ul><li><ul><li> bar</li></ul></li>
9509 <li> baz</li></ul></li>
9510 <li> boo</li></ul>
9511
9512 !! end
9513
9514 !! test
9515 Nested lists 9 (extension interaction)
9516 !! options
9517 parsoid
9518 !! wikitext
9519 *<references />
9520 !! html/parsoid
9521 <ul><li data-parsoid='{}'><ol class="mw-references" typeof="mw:Extension/references" about="#mwt2" data-parsoid='{}' data-mw='{"name":"references","attrs":{}}'></ol></li></ul>
9522 !! end
9523
9524 !! test
9525 1. Lists with start-of-line-transparent tokens before bullets: Comments
9526 !! wikitext
9527 *foo
9528 *<!--cmt-->bar
9529 <!--cmt-->*baz
9530 !! html
9531 <ul><li>foo</li>
9532 <li>bar</li>
9533 <li>baz</li></ul>
9534
9535 !! end
9536
9537 !! test
9538 2. Lists with start-of-line-transparent tokens before bullets: Template close
9539 !! wikitext
9540 *foo {{echo|bar
9541 }}*baz
9542 !! html
9543 <ul><li>foo bar</li>
9544 <li>baz</li></ul>
9545
9546 !! end
9547
9548 !! test
9549 List items are not parsed correctly following a <pre> block (T2785)
9550 !! wikitext
9551 * <pre>foo</pre>
9552 * <pre>bar</pre>
9553 * zar
9554 !! html/php
9555 <ul><li> <pre>foo</pre></li>
9556 <li> <pre>bar</pre></li>
9557 <li> zar</li></ul>
9558
9559 !! html/parsoid
9560 <ul><li> <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
9561 <li> <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
9562 <li> zar</li></ul>
9563 !! end
9564
9565 !! test
9566 List items from template
9567 !! wikitext
9568
9569 {{inner list}}
9570 * item 2
9571
9572 * item 0
9573 {{inner list}}
9574 * item 2
9575
9576 * item 0
9577 * notSOL{{inner list}}
9578 * item 2
9579 !! html
9580 <ul><li> item 1</li>
9581 <li> item 2</li></ul>
9582 <ul><li> item 0</li>
9583 <li> item 1</li>
9584 <li> item 2</li></ul>
9585 <ul><li> item 0</li>
9586 <li> notSOL</li>
9587 <li> item 1</li>
9588 <li> item 2</li></ul>
9589
9590 !! end
9591
9592 !! test
9593 List interrupted by empty line or heading
9594 !! wikitext
9595 * foo
9596
9597 ** bar
9598 == A heading ==
9599 * Another list item
9600 !! html
9601 <ul><li> foo</li></ul>
9602 <ul><li><ul><li> bar</li></ul></li></ul>
9603 <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>
9604 <ul><li> Another list item</li></ul>
9605
9606 !!end
9607
9608 !!test
9609 Multiple list tags generated by templates
9610 !! wikitext
9611 {{echo|<li>}}a
9612 {{echo|<li>}}b
9613 {{echo|<li>}}c
9614 !! html
9615 <li>a
9616 <li>b
9617 <li>c</li>
9618 </li>
9619 </li>
9620
9621 !! html+tidy
9622 <ul>
9623 <li>a</li>
9624 <li>b</li>
9625 <li>c</li>
9626 </ul>
9627 !!end
9628
9629 !!test
9630 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
9631 !! wikitext
9632 *a
9633 <!--This line will NOT split the list-->
9634 *b
9635 <!--This line will NOT split the list either-->
9636 *c
9637 <!--foo--> <!----> <!--This line NOT split the list either-->
9638 *d
9639 !! html
9640 <ul><li>a</li>
9641 <li>b</li>
9642 <li>c</li>
9643 <li>d</li></ul>
9644
9645 !!end
9646
9647 !!test
9648 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
9649 !! wikitext
9650 *a
9651 <!--This line will NOT split the list-->
9652 *b
9653 <!--This line will NOT split the list either-->
9654 *c
9655 <!--foo--> <!----> <!--This line NOT split the list
9656 either-->
9657 *d
9658 !! html
9659 <ul><li>a</li>
9660 <li>b</li>
9661 <li>c</li>
9662 <li>d</li></ul>
9663
9664 !!end
9665
9666 !!test
9667 Test the li-hack
9668 (The PHP parser relies on Tidy for the hack)
9669 !!options
9670 parsoid=wt2html,wt2wt
9671 !! wikitext
9672 * foo
9673 * <li>li-hack
9674 * {{echo|<li>templated li-hack}}
9675 * <!--foo--> <li> unsupported li-hack with preceding comments
9676
9677 <ul>
9678 <li><li>not a li-hack
9679 </li>
9680 </ul>
9681 !! html+tidy
9682 <ul>
9683 <li>foo</li>
9684 <li>li-hack</li>
9685 <li>templated li-hack</li>
9686 <li>unsupported li-hack with preceding comments</li>
9687 </ul>
9688 <ul>
9689 <li>not a li-hack</li>
9690 </ul>
9691 !!end
9692
9693 !! test
9694 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
9695 !! options
9696 parsoid
9697 !! wikitext
9698 # foo
9699 ## bar
9700 * foo
9701 ** bar
9702 : foo
9703 :: bar
9704 !! html
9705 <ol>
9706 <li> foo<ol>
9707 <li> bar</li>
9708 </ol></li>
9709 </ol><ul>
9710 <li> foo<ul>
9711 <li> bar</li>
9712 </ul></li>
9713 </ul><dl>
9714 <dd> foo<dl>
9715 <dd> bar</dd>
9716 </dl></dd>
9717 </dl>
9718 !! end
9719
9720 !! test
9721 Parsoid: Test of whitespace serialization with Templated bullets
9722 !! options
9723 parsoid
9724 !! wikitext
9725 * {{bullet}}
9726 !! html
9727 <ul>
9728 <li> </li><li about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"bullet","href":"./Template:Bullet"},"params":{},"i":0}}]}'> Bar</li>
9729 </ul>
9730 !! end
9731
9732 # ------------------------------------------------------------------------
9733 # The next set of tests are about Parsoid's ability to handle badly nested
9734 # tags (parse, minimize scope of fixup, and roundtrip back)
9735 # ------------------------------------------------------------------------
9736
9737 !! test
9738 Unbalanced closing block tags break a list
9739 (php parser relies on Tidy to fix up)
9740 !! wikitext
9741 <div>
9742 *a</div><div>
9743 *b</div>
9744 !! html+tidy
9745 <div>
9746 <ul>
9747 <li>a</li>
9748 </ul>
9749 </div>
9750 <div>
9751 <ul>
9752 <li>b</li>
9753 </ul>
9754 </div>
9755 !! end
9756
9757 # Parsoid fails this test, but it might be tricky to support properly.
9758 # See T70395.
9759 !! test
9760 Unbalanced closing non-block tags don't break a list
9761 (php parser relies on Tidy to fix up)
9762 !! wikitext
9763 <span>
9764 *a</span><span>
9765 *b</span>
9766 !! html/php+tidy
9767 <ul>
9768 <li><span>a</span></li>
9769 <li><span>b</span></li>
9770 </ul>
9771 !! html/parsoid
9772 <span>
9773 <ul>
9774 <li>a<span></span>
9775 </li>
9776 <li>b
9777 </li>
9778 </ul>
9779 </span>
9780 !! end
9781
9782 !! test
9783 Unclosed formatting tags that straddle lists are closed and reopened
9784 (php parser relies on Tidy to fix up)
9785 !! options
9786 parsoid=wt2html,wt2wt,html2html
9787 !! wikitext
9788 # <s> a
9789 # b </s>
9790 !! html/php+tidy
9791 <ol>
9792 <li><s>a</s></li>
9793 <li><s>b</s></li>
9794 </ol>
9795 !! html/parsoid
9796 <ol><li> <s> a</s></li>
9797 <li><s> b </s></li></ol>
9798 !! end
9799
9800 # See T70395.
9801 !!test
9802 1. List embedded in a formatting tag
9803 !! wikitext
9804 <small>
9805 * foo
9806 </small>
9807 !! html/php+tidy
9808 <ul>
9809 <li><small>foo</small></li>
9810 </ul>
9811 !! html/parsoid
9812 <small>
9813 <ul>
9814 <li> foo</li>
9815 </ul>
9816 </small>
9817 !!end
9818
9819 ## Ugly Parsoid output here
9820 ## Not sure what the right output is.
9821 !!test
9822 2. List embedded in a formatting tag
9823 !! wikitext
9824 <small>
9825 *a
9826 *b</small>
9827 !! html/php+tidy
9828 <ul>
9829 <li><small>a</small></li>
9830 <li><small>b</small></li>
9831 </ul>
9832 !! html/parsoid
9833 <small></small>
9834 <ul><small>
9835 <li>a</li>
9836 </small>
9837 <li><small>b</small></li>
9838 </ul>
9839 !!end
9840
9841 # Ugly Parsoid and PHP parser output here
9842 # Not sure if we want to make this a test!
9843 #
9844 ## !!test
9845 ## 3. Unclosed formatting tags in list elements
9846 ## !! wikitext
9847 ## *<small>a
9848 ## *<small>b
9849 ## !! html/php+tidy
9850 ## <ul>
9851 ## <li><small>a</small></li>
9852 ## <li><small><small>b</small></small></li>
9853 ## </ul>
9854 ## !! html/parsoid
9855 ## <ul>
9856 ## <li><small>a</small></li>
9857 ## <small>
9858 ## <li><small>b</small></li>
9859 ## </small></ul>
9860 ## !!end
9861
9862 # This is a bug in the PHP parser + tidy combination.
9863 # (The </tr> tag gets parsed as text and html-escaped by PHP,
9864 # and then fostered out of the table by tidy.)
9865 # We believe the Parsoid output to be correct.
9866 !! test
9867 Table with missing opening <tr> tag
9868 !! options
9869 parsoid=wt2html,wt2wt
9870 !! wikitext
9871 <table>
9872 <td>foo</td>
9873 </tr>
9874 </table>
9875 !! html+tidy
9876 <table>
9877 <tr>
9878 <td>foo</td>
9879 </tr>
9880 </table>
9881 !! end
9882
9883 ###
9884 ### Magic Words
9885 ###
9886
9887 # Note that the current date is hard-coded as
9888 # 1970-01-01T00:02:03Z (a Thursday)
9889 # when running parser tests. The timezone is also fixed to GMT, so
9890 # local date will be identical to current date.
9891
9892 !! test
9893 Magic Word: {{CURRENTDAY}}
9894 !! wikitext
9895 {{CURRENTDAY}}
9896 !! html
9897 <p>1
9898 </p>
9899 !! end
9900
9901 !! test
9902 Magic Word: {{CURRENTDAY2}}
9903 !! wikitext
9904 {{CURRENTDAY2}}
9905 !! html
9906 <p>01
9907 </p>
9908 !! end
9909
9910 !! test
9911 Magic Word: {{CURRENTDAYNAME}}
9912 !! wikitext
9913 {{CURRENTDAYNAME}}
9914 !! html
9915 <p>Thursday
9916 </p>
9917 !! end
9918
9919 !! test
9920 Magic Word: {{CURRENTDOW}}
9921 !! wikitext
9922 {{CURRENTDOW}}
9923 !! html
9924 <p>4
9925 </p>
9926 !! end
9927
9928 !! test
9929 Magic Word: {{CURRENTMONTH}}
9930 !! wikitext
9931 {{CURRENTMONTH}}
9932 !! html
9933 <p>01
9934 </p>
9935 !! end
9936
9937 !! test
9938 Magic Word: {{CURRENTMONTH1}}
9939 !! wikitext
9940 {{CURRENTMONTH1}}
9941 !! html
9942 <p>1
9943 </p>
9944 !! end
9945
9946 !! test
9947 Magic Word: {{CURRENTMONTHABBREV}}
9948 !! wikitext
9949 {{CURRENTMONTHABBREV}}
9950 !! html
9951 <p>Jan
9952 </p>
9953 !! end
9954
9955 !! test
9956 Magic Word: {{CURRENTMONTHNAME}}
9957 !! wikitext
9958 {{CURRENTMONTHNAME}}
9959 !! html
9960 <p>January
9961 </p>
9962 !! end
9963
9964 !! test
9965 Magic Word: {{CURRENTMONTHNAMEGEN}}
9966 !! wikitext
9967 {{CURRENTMONTHNAMEGEN}}
9968 !! html
9969 <p>January
9970 </p>
9971 !! end
9972
9973 !! test
9974 Magic Word: {{CURRENTTIME}}
9975 !! wikitext
9976 {{CURRENTTIME}}
9977 !! html
9978 <p>00:02
9979 </p>
9980 !! end
9981
9982 !! test
9983 Magic Word: {{CURRENTHOUR}}
9984 !! wikitext
9985 {{CURRENTHOUR}}
9986 !! html
9987 <p>00
9988 </p>
9989 !! end
9990
9991 !! test
9992 Magic Word: {{CURRENTWEEK}} (T6594)
9993 !! wikitext
9994 {{CURRENTWEEK}}
9995 !! html
9996 <p>1
9997 </p>
9998 !! end
9999
10000 !! test
10001 Magic Word: {{CURRENTYEAR}}
10002 !! wikitext
10003 {{CURRENTYEAR}}
10004 !! html
10005 <p>1970
10006 </p>
10007 !! end
10008
10009 !! test
10010 Magic Word: {{CURRENTTIMESTAMP}}
10011 !! wikitext
10012 {{CURRENTTIMESTAMP}}
10013 !! html
10014 <p>19700101000203
10015 </p>
10016 !! end
10017
10018 !! test
10019 Magic Words LOCAL (UTC)
10020 !! wikitext
10021 * {{LOCALMONTH}}
10022 * {{LOCALMONTH1}}
10023 * {{LOCALMONTHNAME}}
10024 * {{LOCALMONTHNAMEGEN}}
10025 * {{LOCALMONTHABBREV}}
10026 * {{LOCALDAY}}
10027 * {{LOCALDAY2}}
10028 * {{LOCALDAYNAME}}
10029 * {{LOCALYEAR}}
10030 * {{LOCALTIME}}
10031 * {{LOCALHOUR}}
10032 * {{LOCALWEEK}}
10033 * {{LOCALDOW}}
10034 * {{LOCALTIMESTAMP}}
10035 !! html
10036 <ul><li> 01</li>
10037 <li> 1</li>
10038 <li> January</li>
10039 <li> January</li>
10040 <li> Jan</li>
10041 <li> 1</li>
10042 <li> 01</li>
10043 <li> Thursday</li>
10044 <li> 1970</li>
10045 <li> 00:02</li>
10046 <li> 00</li>
10047 <li> 1</li>
10048 <li> 4</li>
10049 <li> 19700101000203</li></ul>
10050
10051 !! end
10052
10053 !! test
10054 Magic Word: {{FULLPAGENAME}}
10055 !! options
10056 title=[[User:Ævar Arnfjörð Bjarmason]]
10057 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10058 !! wikitext
10059 {{FULLPAGENAME}}
10060 !! html/*
10061 <p>User:Ævar Arnfjörð Bjarmason
10062 </p>
10063 !! end
10064
10065 !! test
10066 Magic Word: {{FULLPAGENAMEE}}
10067 !! options
10068 title=[[User:Ævar Arnfjörð Bjarmason]]
10069 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10070 !! wikitext
10071 {{FULLPAGENAMEE}}
10072 !! html/*
10073 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10074 </p>
10075 !! end
10076
10077 !! test
10078 Magic Word: {{TALKSPACE}}
10079 !! options
10080 title=[[User:Ævar Arnfjörð Bjarmason]]
10081 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10082 !! wikitext
10083 {{TALKSPACE}}
10084 !! html/*
10085 <p>User talk
10086 </p>
10087 !! end
10088
10089 !! test
10090 Magic Word: {{TALKSPACE}}, same namespace
10091 !! options
10092 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10093 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10094 !! wikitext
10095 {{TALKSPACE}}
10096 !! html/*
10097 <p>User talk
10098 </p>
10099 !! end
10100
10101 !! test
10102 Magic Word: {{TALKSPACE}}, main namespace
10103 !! options
10104 title=[[Parser Test]]
10105 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10106 !! wikitext
10107 {{TALKSPACE}}
10108 !! html/*
10109 <p>Talk
10110 </p>
10111 !! end
10112
10113 !! test
10114 Magic Word: {{TALKSPACEE}}
10115 !! options
10116 title=[[User:Ævar Arnfjörð Bjarmason]]
10117 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10118 !! wikitext
10119 {{TALKSPACEE}}
10120 !! html/*
10121 <p>User_talk
10122 </p>
10123 !! end
10124
10125 !! test
10126 Magic Word: {{SUBJECTSPACE}}
10127 !! options
10128 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10129 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10130 !! wikitext
10131 {{SUBJECTSPACE}}
10132 !! html/*
10133 <p>User
10134 </p>
10135 !! end
10136
10137 !! test
10138 Magic Word: {{SUBJECTSPACE}}, same namespace
10139 !! options
10140 title=[[User:Ævar Arnfjörð Bjarmason]]
10141 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10142 !! wikitext
10143 {{SUBJECTSPACE}}
10144 !! html/*
10145 <p>User
10146 </p>
10147 !! end
10148
10149 !! test
10150 Magic Word: {{SUBJECTSPACE}}, main namespace
10151 !! options
10152 title=[[Parser Test]]
10153 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10154 !! wikitext
10155 {{SUBJECTSPACE}}
10156 !! html/*
10157
10158 !! end
10159
10160 !! test
10161 Magic Word: {{SUBJECTSPACEE}}
10162 !! options
10163 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10164 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10165 !! wikitext
10166 {{SUBJECTSPACEE}}
10167 !! html/*
10168 <p>User
10169 </p>
10170 !! end
10171
10172 !! test
10173 Magic Word: {{NAMESPACE}}
10174 !! options
10175 title=[[User:Ævar Arnfjörð Bjarmason]]
10176 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10177 !! wikitext
10178 {{NAMESPACE}}
10179 !! html/*
10180 <p>User
10181 </p>
10182 !! end
10183
10184 !! test
10185 Magic Word: {{NAMESPACEE}}
10186 !! options
10187 title=[[User:Ævar Arnfjörð Bjarmason]]
10188 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10189 !! wikitext
10190 {{NAMESPACEE}}
10191 !! html/*
10192 <p>User
10193 </p>
10194 !! end
10195
10196 !! test
10197 Magic Word: {{NAMESPACENUMBER}}
10198 !! options
10199 title=[[User:Ævar Arnfjörð Bjarmason]]
10200 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10201 !! wikitext
10202 {{NAMESPACENUMBER}}
10203 !! html/*
10204 <p>2
10205 </p>
10206 !! end
10207
10208 !! test
10209 Magic Word: {{SUBPAGENAME}}
10210 !! options
10211 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10212 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10213 !! wikitext
10214 {{SUBPAGENAME}}
10215 !! html/*
10216 <p>sub ö
10217 </p>
10218 !! end
10219
10220 !! test
10221 Magic Word: {{SUBPAGENAMEE}}
10222 !! options
10223 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10224 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10225 !! wikitext
10226 {{SUBPAGENAMEE}}
10227 !! html/*
10228 <p>sub_%C3%B6
10229 </p>
10230 !! end
10231
10232 !! test
10233 Magic Word: {{ROOTPAGENAME}}
10234 !! options
10235 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10236 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10237 !! wikitext
10238 {{ROOTPAGENAME}}
10239 !! html/*
10240 <p>Ævar Arnfjörð Bjarmason
10241 </p>
10242 !! end
10243
10244 !! test
10245 Magic Word: {{ROOTPAGENAMEE}}
10246 !! options
10247 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10248 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10249 !! wikitext
10250 {{ROOTPAGENAMEE}}
10251 !! html/*
10252 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10253 </p>
10254 !! end
10255
10256 !! test
10257 Magic Word: {{BASEPAGENAME}}
10258 !! options
10259 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10260 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10261 !! wikitext
10262 {{BASEPAGENAME}}
10263 !! html/*
10264 <p>Ævar Arnfjörð Bjarmason
10265 </p>
10266 !! end
10267
10268 !! test
10269 Magic Word: {{BASEPAGENAMEE}}
10270 !! options
10271 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10272 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10273 !! wikitext
10274 {{BASEPAGENAMEE}}
10275 !! html/*
10276 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10277 </p>
10278 !! end
10279
10280 !! test
10281 Magic Word: {{TALKPAGENAME}}
10282 !! options
10283 title=[[User:Ævar Arnfjörð Bjarmason]]
10284 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10285 !! wikitext
10286 {{TALKPAGENAME}}
10287 !! html/*
10288 <p>User talk:Ævar Arnfjörð Bjarmason
10289 </p>
10290 !! end
10291
10292 !! test
10293 Magic Word: {{TALKPAGENAMEE}}
10294 !! options
10295 title=[[User:Ævar Arnfjörð Bjarmason]]
10296 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10297 !! wikitext
10298 {{TALKPAGENAMEE}}
10299 !! html/*
10300 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10301 </p>
10302 !! end
10303
10304 !! test
10305 Magic Word: {{SUBJECTPAGENAME}}
10306 !! options
10307 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10308 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10309 !! wikitext
10310 {{SUBJECTPAGENAME}}
10311 !! html/*
10312 <p>User:Ævar Arnfjörð Bjarmason
10313 </p>
10314 !! end
10315
10316 !! test
10317 Magic Word: {{SUBJECTPAGENAMEE}}
10318 !! options
10319 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10320 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10321 !! wikitext
10322 {{SUBJECTPAGENAMEE}}
10323 !! html/*
10324 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10325 </p>
10326 !! end
10327
10328 !! test
10329 Magic Word: {{NUMBEROFFILES}}
10330 !! options
10331 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10332 !! wikitext
10333 {{NUMBEROFFILES}}
10334 !! html/*
10335 <p>7
10336 </p>
10337 !! end
10338
10339 !! test
10340 Magic Word: {{PAGENAME}}
10341 !! options
10342 title=[[User:Ævar Arnfjörð Bjarmason]]
10343 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10344 !! wikitext
10345 {{PAGENAME}}
10346 !! html/*
10347 <p>Ævar Arnfjörð Bjarmason
10348 </p>
10349 !! end
10350
10351 !! test
10352 Magic Word: {{PAGENAME}} with metacharacters
10353 !! options
10354 title=[['foo & bar = baz']]
10355 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10356 !! wikitext
10357 ''{{PAGENAME}}''
10358 !! html/php
10359 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10360 </p>
10361 !! html+tidy
10362 <p><i>'foo &amp; bar = baz'</i></p>
10363 !! end
10364
10365 !! test
10366 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10367 !! options
10368 title=[[*RFC 1234 http://example.com/]]
10369 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10370 !! wikitext
10371 {{PAGENAME}}
10372 !! html/php
10373 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10374 </p>
10375 !! html+tidy
10376 <p>*RFC 1234 http://example.com/</p>
10377 !! end
10378
10379 !! test
10380 Magic Word: {{PAGENAMEE}}
10381 !! options
10382 title=[[User:Ævar Arnfjörð Bjarmason]]
10383 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10384 !! wikitext
10385 {{PAGENAMEE}}
10386 !! html/*
10387 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10388 </p>
10389 !! end
10390
10391 !! test
10392 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10393 !! options
10394 title=[[*RFC 1234 http://example.com/]]
10395 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10396 !! wikitext
10397 {{PAGENAMEE}}
10398 !! html/php
10399 <p>&#42;RFC_1234_http&#58;//example.com/
10400 </p>
10401 !! html+tidy
10402 <p>*RFC_1234_http://example.com/</p>
10403 !! end
10404
10405 !! test
10406 Magic Word: {{REVISIONID}}
10407 !! options
10408 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10409 !! wikitext
10410 {{REVISIONID}}
10411 !! html/*
10412 <p>1337
10413 </p>
10414 !! end
10415
10416 !! test
10417 Magic Word: {{SCRIPTPATH}}
10418 !! options
10419 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10420 !! wikitext
10421 {{SCRIPTPATH}}
10422 !! html/*
10423
10424 !! end
10425
10426 !! test
10427 Magic Word: {{STYLEPATH}}
10428 !! options
10429 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10430 !! wikitext
10431 {{STYLEPATH}}
10432 !! html/*
10433 <p>/skins
10434 </p>
10435 !! end
10436
10437 !! test
10438 Magic Word: {{SERVER}}
10439 !! options
10440 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10441 !! wikitext
10442 {{SERVER}}
10443 !! html/*
10444 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10445 </p>
10446 !! end
10447
10448 !! test
10449 Magic Word: {{SERVERNAME}}
10450 !! options
10451 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10452 !! wikitext
10453 {{SERVERNAME}}
10454 !! html/*
10455 <p>example.org
10456 </p>
10457 !! end
10458
10459 !! test
10460 Magic Word: {{SITENAME}}
10461 !! options
10462 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10463 !! wikitext
10464 {{SITENAME}}
10465 !! html/*
10466 <p>MediaWiki
10467 </p>
10468 !! end
10469
10470 !! test
10471 Magic Word: {{PAGELANGUAGE}}
10472 !! options
10473 language=fr
10474 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10475 !! wikitext
10476 {{PAGELANGUAGE}}
10477 !! html/*
10478 <p>fr
10479 </p>
10480 !! end
10481
10482 !! test
10483 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10484 !! options
10485 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10486 !! wikitext
10487 {{PAGELANGUAGE}}
10488 !! html/*
10489 <p>en
10490 </p>
10491 !! end
10492
10493 !! test
10494 Case-sensitive magic words, when cased differently, should just be template transclusions
10495 !! wikitext
10496 {{CurrentMonth}}
10497 {{currentday}}
10498 {{cURreNTweEK}}
10499 {{currentHour}}
10500 !! html
10501 <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>
10502 <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>
10503 <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>
10504 <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>
10505 </p>
10506 !! end
10507
10508 !! test
10509 Case-insensitive magic words should still work with weird casing.
10510 !! wikitext
10511 {{sErVeRNaMe}}
10512 {{LCFirst:AOEU}}
10513 {{ucFIRST:aoeu}}
10514 {{SERver}}
10515 !! html
10516 <p>example.org
10517 aOEU
10518 Aoeu
10519 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10520 </p>
10521 !! end
10522
10523 # From plwiki:PLOS_ONE
10524 !! test
10525 Parsoid: Page property magic word with magic word contents
10526 !! wikitext
10527 {{DISPLAYTITLE:''{{PAGENAME}}''}}
10528 !! html/parsoid
10529 <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>"}]]}'/>
10530 !! end
10531
10532 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
10533 # But, this is a limitation of our representation and is documented in
10534 # TemplateHandler.js in processSpecialMagicWord
10535 !! test
10536 Parsoid: Template-generated DISPLAYTITLE
10537 !! wikitext
10538 {{{{echo|DISPLAYTITLE}}:Foo}}
10539 !! options
10540 showtitle
10541 !! config
10542 wgAllowDisplayTitle=true
10543 wgRestrictDisplayTitle=false
10544 !! html/php
10545 Foo
10546
10547 !! html/parsoid
10548 <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"}]]}'/>
10549 !! end
10550
10551 !! test
10552 Namespace 1 {{ns:1}}
10553 !! wikitext
10554 {{ns:1}}
10555 !! html
10556 <p>Talk
10557 </p>
10558 !! end
10559
10560 !! test
10561 Namespace 1 {{ns:01}}
10562 !! wikitext
10563 {{ns:01}}
10564 !! html
10565 <p>Talk
10566 </p>
10567 !! end
10568
10569 !! test
10570 Namespace 0 {{ns:0}} (T6783)
10571 !! wikitext
10572 {{ns:0}}
10573 !! html
10574
10575 !! end
10576
10577 !! test
10578 Namespace 0 {{ns:00}} (T6783)
10579 !! wikitext
10580 {{ns:00}}
10581 !! html
10582
10583 !! end
10584
10585 !! test
10586 Namespace -1 {{ns:-1}}
10587 !! wikitext
10588 {{ns:-1}}
10589 !! html
10590 <p>Special
10591 </p>
10592 !! end
10593
10594 !! test
10595 Namespace User {{ns:User}}
10596 !! wikitext
10597 {{ns:User}}
10598 !! html
10599 <p>User
10600 </p>
10601 !! end
10602
10603 !! test
10604 Namespace User talk {{ns:User_talk}}
10605 !! wikitext
10606 {{ns:User_talk}}
10607 !! html
10608 <p>User talk
10609 </p>
10610 !! end
10611
10612 !! test
10613 Namespace User talk {{ns:uSeR tAlK}}
10614 !! wikitext
10615 {{ns:uSeR tAlK}}
10616 !! html
10617 <p>User talk
10618 </p>
10619 !! end
10620
10621 !! test
10622 Namespace File {{ns:File}}
10623 !! wikitext
10624 {{ns:File}}
10625 !! html
10626 <p>File
10627 </p>
10628 !! end
10629
10630 !! test
10631 Namespace File {{ns:Image}}
10632 !! wikitext
10633 {{ns:Image}}
10634 !! html
10635 <p>File
10636 </p>
10637 !! end
10638
10639 !! test
10640 Namespace (lang=de) Benutzer {{ns:User}}
10641 !! options
10642 language=de
10643 !! wikitext
10644 {{ns:User}}
10645 !! html
10646 <p>Benutzer
10647 </p>
10648 !! end
10649
10650 !! test
10651 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
10652 !! options
10653 language=de
10654 !! wikitext
10655 {{ns:3}}
10656 !! html
10657 <p>Benutzer Diskussion
10658 </p>
10659 !! end
10660
10661 !! test
10662 Urlencode
10663 !! wikitext
10664 {{urlencode:hi world?!}}
10665 {{urlencode:hi world?!|WIKI}}
10666 {{urlencode:hi world?!|PATH}}
10667 {{urlencode:hi world?!|QUERY}}
10668 !! html/php
10669 <p>hi+world%3F%21
10670 hi_world%3F!
10671 hi%20world%3F%21
10672 hi+world%3F%21
10673 </p>
10674 !! end
10675
10676 !! test
10677 Magic Word: prioritize type info over data-parsoid
10678 !! options
10679 parsoid=html2wt
10680 !! html/parsoid
10681 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
10682 !! wikitext
10683 __FORCETOC__
10684 !! end
10685
10686 !! test
10687 Magic Word: serialize on separate line (parsoid)
10688 !! options
10689 parsoid=wt2wt,html2wt
10690 !! wikitext
10691 foo
10692 __NOTOC__
10693 bar
10694 !! html/parsoid
10695 foo<meta property="mw:PageProp/notoc"/>bar
10696 !! end
10697
10698 !! test
10699 Magic Word: rt non-english wikis
10700 !! options
10701 parsoid=wt2wt
10702 language=de
10703 !! wikitext
10704 __NOEDITSECTION__
10705 !! html/parsoid
10706 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
10707 !! end
10708
10709 !!test
10710 __proto__ is treated as normal wikitext (T105997)
10711 !!wikitext
10712 __proto__
10713 !!html
10714 <p>__proto__
10715 </p>
10716 !!end
10717
10718 ###
10719 ### Magic links
10720 ###
10721 !! test
10722 Magic links: internal link to RFC (T2479)
10723 !! wikitext
10724 [[RFC 123]]
10725 !! html/php
10726 <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>
10727 </p>
10728 !! html/parsoid
10729 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
10730 !! end
10731
10732 !! test
10733 Magic links: RFC (T2479)
10734 !! wikitext
10735 RFC 822
10736 !! html/php
10737 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
10738 </p>
10739 !! html/parsoid
10740 <p><a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a></p>
10741 !! end
10742
10743 !! test
10744 Magic links: RFC (T67278)
10745 !! wikitext
10746 This is RFC 822 but thisRFC 822 is not RFC 822linked.
10747 !! html/php
10748 <p>This is <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a> but thisRFC 822 is not RFC 822linked.
10749 </p>
10750 !! html/parsoid
10751 <p>This is <a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
10752 !! end
10753
10754 !! test
10755 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
10756 !! wikitext
10757 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
10758 RFC
10759 822
10760 !! html/php
10761 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
10762 RFC
10763 822
10764 </p>
10765 !! html/parsoid
10766 <p><a href="//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>
10767 RFC
10768 822</p>
10769 !! end
10770
10771 !! test
10772 Magic links: ISBN (T3937)
10773 !! wikitext
10774 ISBN 0-306-40615-2
10775 !! html/php
10776 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
10777 </p>
10778 !! html/parsoid
10779 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
10780 !! end
10781
10782 !! test
10783 Magic links: ISBN (T67278)
10784 !! wikitext
10785 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
10786 !! html/php
10787 <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.
10788 </p>
10789 !! html/parsoid
10790 <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>
10791 !! end
10792
10793 !! test
10794 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
10795 !! wikitext
10796 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
10797 ISBN
10798 9780316098113
10799 ISBN 978
10800 0316098113
10801 !! html/php
10802 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
10803 ISBN
10804 9780316098113
10805 ISBN 978
10806 0316098113
10807 </p>
10808 !! html/parsoid
10809 <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>
10810 ISBN
10811 9780316098113
10812 ISBN 978
10813 0316098113</p>
10814 !! end
10815
10816 !! test
10817 Magic links: PMID incorrectly converts space to underscore
10818 !! wikitext
10819 PMID 1234
10820 !! html/php
10821 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
10822 </p>
10823 !! html/parsoid
10824 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a></p>
10825 !! end
10826
10827 !! test
10828 Magic links: PMID (T67278)
10829 !! wikitext
10830 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
10831 !! html/php
10832 <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.
10833 </p>
10834 !! html/parsoid
10835 <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>
10836 !! end
10837
10838 !! test
10839 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
10840 !! wikitext
10841 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
10842 PMID
10843 1234
10844 !! html/php
10845 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
10846 PMID
10847 1234
10848 </p>
10849 !! html/parsoid
10850 <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>
10851 PMID
10852 1234</p>
10853 !! end
10854
10855 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
10856 # since these are ExtLinkText, not MagicLinkText
10857 !! test
10858 Magic links: use appropriate serialization for "almost" magic links.
10859 !! wikitext
10860 X[[Special:BookSources/0978739256|foo]]
10861
10862 X[//tools.ietf.org/html/rfc1234 foo]
10863 !! html/php
10864 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
10865 </p><p>X<a rel="nofollow" class="external text" href="//tools.ietf.org/html/rfc1234">foo</a>
10866 </p>
10867 !! html/parsoid
10868 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
10869 <p>X<a rel="mw:ExtLink" href="//tools.ietf.org/html/rfc1234">foo</a></p>
10870 !! end
10871
10872 !! test
10873 Magic links: All disabled (T47942)
10874 !! options
10875 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
10876 !! wikitext
10877 ISBN 0-306-40615-2
10878 PMID 1234
10879 RFC 4321
10880 !! html/php
10881 <p>ISBN 0-306-40615-2
10882 PMID 1234
10883 RFC 4321
10884 </p>
10885 !! end
10886
10887 ###
10888 ### Templates
10889 ####
10890
10891 !! test
10892 Nonexistent template
10893 !! wikitext
10894 {{thistemplatedoesnotexist}}
10895 !! html
10896 <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>
10897 </p>
10898 !! end
10899
10900 !! test
10901 Template with invalid target containing tags
10902 !! wikitext
10903 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
10904 !! html
10905 <p>{{a<b>b</b>|foo|a=b|a = b}}
10906 </p>
10907 !! end
10908
10909 !! test
10910 Template with invalid target containing unclosed tag
10911 !! wikitext
10912 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
10913 !! html
10914 <p>{{a<b>|foo|a=b|a = b}}</b>
10915 </p>
10916 !! end
10917
10918 !! test
10919 Template with invalid target containing wikilink
10920 !! wikitext
10921 {{[[Main Page]]}}
10922 !! html/php
10923 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
10924 </p>
10925 !! html/parsoid
10926 <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>
10927 !! end
10928
10929 !! test
10930 Template with just whitespace in it, T70421
10931 !! wikitext
10932 {{echo|{{ }}}}
10933 !! html/parsoid
10934 <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>
10935 !! end
10936
10937 !! article
10938 Template:test
10939 !! text
10940 This is a test template
10941 !! endarticle
10942
10943 !! test
10944 Simple template
10945 !! wikitext
10946 {{test}}
10947 !! html
10948 <p>This is a test template
10949 </p>
10950 !! end
10951
10952 !! test
10953 Template with explicit namespace
10954 !! wikitext
10955 {{Template:test}}
10956 !! html
10957 <p>This is a test template
10958 </p>
10959 !! end
10960
10961
10962 !! article
10963 Template:paramtest
10964 !! text
10965 This is a test template with parameter {{{param}}}
10966 !! endarticle
10967
10968 !! test
10969 Template parameter
10970 !! wikitext
10971 {{paramtest|param=foo}}
10972 !! html
10973 <p>This is a test template with parameter foo
10974 </p>
10975 !! end
10976
10977 !! article
10978 Template:paramtestnum
10979 !! text
10980 [[{{{1}}}|{{{2}}}]]
10981 !! endarticle
10982
10983 !! test
10984 Template unnamed parameter
10985 !! wikitext
10986 {{paramtestnum|Main Page|the main page}}
10987 !! html
10988 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
10989 </p>
10990 !! end
10991
10992 !! article
10993 Template:templatesimple
10994 !! text
10995 (test)
10996 !! endarticle
10997
10998 !! article
10999 Template:templateredirect
11000 !! text
11001 #redirect [[Template:templatesimple]]
11002 !! endarticle
11003
11004 !! article
11005 Template:templateasargtestnum
11006 !! text
11007 {{{{{1}}}}}
11008 !! endarticle
11009
11010 !! article
11011 Template:templateasargtest
11012 !! text
11013 {{template{{{templ}}}}}
11014 !! endarticle
11015
11016 !! article
11017 Template:templateasargtest2
11018 !! text
11019 {{{{{templ}}}}}
11020 !! endarticle
11021
11022 !! test
11023 Template with template name as unnamed argument
11024 !! wikitext
11025 {{templateasargtestnum|templatesimple}}
11026 !! html
11027 <p>(test)
11028 </p>
11029 !! end
11030
11031 !! test
11032 Template with template name as argument
11033 !! wikitext
11034 {{templateasargtest|templ=simple}}
11035 !! html
11036 <p>(test)
11037 </p>
11038 !! end
11039
11040 !! test
11041 Template with template name as argument (2)
11042 !! wikitext
11043 {{templateasargtest2|templ=templatesimple}}
11044 !! html
11045 <p>(test)
11046 </p>
11047 !! end
11048
11049 !! article
11050 Template:templateasargtestdefault
11051 !! text
11052 {{{{{templ|templatesimple}}}}}
11053 !! endarticle
11054
11055 !! article
11056 Template:templa
11057 !! text
11058 '''templ'''
11059 !! endarticle
11060
11061 !! test
11062 Template with default value
11063 !! wikitext
11064 {{templateasargtestdefault}}
11065 !! html
11066 <p>(test)
11067 </p>
11068 !! end
11069
11070 !! test
11071 Template with default value (value set)
11072 !! wikitext
11073 {{templateasargtestdefault|templ=templa}}
11074 !! html
11075 <p><b>templ</b>
11076 </p>
11077 !! end
11078
11079 !! test
11080 Template redirect
11081 !! wikitext
11082 {{templateredirect}}
11083 !! html/php
11084 <p>(test)
11085 </p>
11086 !! html/parsoid
11087 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11088 !! end
11089
11090 !! test
11091 Template with argument in separate line
11092 !! wikitext
11093 {{ templateasargtest |
11094 templ = simple }}
11095 !! html
11096 <p>(test)
11097 </p>
11098 !! end
11099
11100 !! test
11101 Template with complex template as argument
11102 !! wikitext
11103 {{paramtest|
11104 param ={{ templateasargtest |
11105 templ = simple }}}}
11106 !! html
11107 <p>This is a test template with parameter (test)
11108 </p>
11109 !! end
11110
11111 !! test
11112 Templates with templated name
11113 !! wikitext
11114 {{{{echo|echo}}|foo}}
11115 {{{{echo|inner list}} }}
11116 !! html
11117 <p>foo
11118 </p>
11119 <ul><li> item 1</li></ul>
11120
11121 !! html/parsoid
11122 <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>
11123 <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>
11124 !! end
11125
11126 # Parsoid markup is deliberate "broken". This is an edge case.
11127 # See long comment in TemplateHandler.js:convertAttribsToString.
11128 !! test
11129 Templates with invalid templated targets
11130 !! wikitext
11131 {{echo
11132 {{echo|foo}}
11133 }}
11134 !! html/php
11135 <p>{{echo
11136 foo
11137 }}
11138 </p>
11139 !! html/parsoid
11140 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11141 foo }}</p>
11142 !! end
11143
11144 !! test
11145 Template with thumb image (with link in description)
11146 !! wikitext
11147 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11148 !! html/php
11149 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>
11150
11151 !! html+tidy
11152 <p>This is a test template with parameter</p>
11153 <div class="thumb tright">
11154 <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>
11155 <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>
11156 </div>
11157 </div>
11158 !! html/parsoid
11159 <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>
11160 !! end
11161
11162 !! article
11163 Template:complextemplate
11164 !! text
11165 {{{1}}} {{paramtest|
11166 param ={{{param}}}}}
11167 !! endarticle
11168
11169 !! test
11170 Template with complex arguments
11171 !! wikitext
11172 {{complextemplate|
11173 param ={{ templateasargtest |
11174 templ = simple }}|[[Template:complextemplate|link]]}}
11175 !! html
11176 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11177 </p>
11178 !! end
11179
11180 !! test
11181 T2553: link with two variables in a piped link
11182 !! wikitext
11183 {|
11184 |[[{{{1}}}|{{{2}}}]]
11185 |}
11186 !! html/php
11187 <table>
11188 <tr>
11189 <td>[[{{{1}}}|{{{2}}}]]
11190 </td></tr></table>
11191
11192 !! html/parsoid
11193 <table>
11194 <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>
11195 </tbody></table>
11196 !! end
11197
11198 # See: T2553
11199 !! test
11200 Abort table cell attribute parsing on wikilink
11201 !! wikitext
11202 {|
11203 | testing [[one|two]] | three || four
11204 | testing one two | three || four
11205 | testing="[[one|two]]" | three || four
11206 |}
11207 !! html/php
11208 <table>
11209 <tr>
11210 <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>
11211 <td> four
11212 </td>
11213 <td> three </td>
11214 <td> four
11215 </td>
11216 <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>
11217 <td> four
11218 </td></tr></table>
11219
11220 !! html/parsoid
11221 <table>
11222 <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_v":"row","autoInsertedEnd":true}'> four</td>
11223 <td data-parsoid='{"a":{"testing":null,"one":null,"two":null},"sa":{"testing":"","one":"","two":""},"autoInsertedEnd":true}'> three </td><td data-parsoid='{"stx_v":"row","autoInsertedEnd":true}'> four</td>
11224 <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_v":"row","autoInsertedEnd":true}'> four</td></tr>
11225 </tbody></table>
11226 !! end
11227
11228 !! test
11229 Don't abort table cell attribute parsing if wikilink is found in template arg
11230 !! wikitext
11231 {|
11232 | Test {{#tag:ref|One two "[[three]]" four}}
11233 |}
11234 !! html/parsoid
11235 <table>
11236 <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>
11237 </tbody></table>
11238 !! end
11239
11240 !! test
11241 Magic variable as template parameter
11242 !! wikitext
11243 {{paramtest|param={{SITENAME}}}}
11244 !! html
11245 <p>This is a test template with parameter MediaWiki
11246 </p>
11247 !! end
11248
11249 !! article
11250 Template:linktest
11251 !! text
11252 [[{{{param}}}|link]]
11253 !! endarticle
11254
11255 !! test
11256 Template parameter as link source
11257 !! wikitext
11258 {{linktest|param=Main Page}}
11259 !! html
11260 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11261 </p>
11262 !! end
11263
11264 !!article
11265 Template:paramtest2
11266 !! text
11267 including another template, {{paramtest|param={{{arg}}}}}
11268 !! endarticle
11269
11270 !! test
11271 Template passing argument to another template
11272 !! wikitext
11273 {{paramtest2|arg='hmm'}}
11274 !! html
11275 <p>including another template, This is a test template with parameter 'hmm'
11276 </p>
11277 !! end
11278
11279 !! article
11280 Template:Linktest2
11281 !! text
11282 Main Page
11283 !! endarticle
11284
11285 !! test
11286 Template as link source
11287 !! wikitext
11288 [[{{linktest2}}]]
11289
11290 [[{{linktest2}}|Main Page]]
11291
11292 [[{{linktest2}}]]Page
11293 !! html
11294 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11295 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11296 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11297 </p>
11298 !! end
11299
11300
11301 !! article
11302 Template:loop1
11303 !! text
11304 {{loop2}}
11305 !! endarticle
11306
11307 !! article
11308 Template:loop2
11309 !! text
11310 {{loop1}}
11311 !! endarticle
11312
11313 !! test
11314 Template infinite loop
11315 !! wikitext
11316 {{loop1}}
11317 !! html
11318 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11319 </p>
11320 !! end
11321
11322 !! test
11323 Template from main namespace
11324 !! wikitext
11325 {{:Main Page}}
11326 !! html
11327 <p>blah blah
11328 </p>
11329 !! end
11330
11331 !! article
11332 Template:table
11333 !! text
11334 {|
11335 | 1 || 2
11336 |-
11337 | 3 || 4
11338 |}
11339 !! endarticle
11340
11341 !! test
11342 T2529: Template with table, not included at beginning of line
11343 !! wikitext
11344 foo {{table}}
11345 !! html
11346 <p>foo
11347 </p>
11348 <table>
11349 <tr>
11350 <td> 1 </td>
11351 <td> 2
11352 </td></tr>
11353 <tr>
11354 <td> 3 </td>
11355 <td> 4
11356 </td></tr></table>
11357
11358 !! end
11359
11360 !! test
11361 T2523: Template shouldn't eat newline (or add an extra one before table)
11362 !! wikitext
11363 foo
11364 {{table}}
11365 !! html
11366 <p>foo
11367 </p>
11368 <table>
11369 <tr>
11370 <td> 1 </td>
11371 <td> 2
11372 </td></tr>
11373 <tr>
11374 <td> 3 </td>
11375 <td> 4
11376 </td></tr></table>
11377
11378 !! end
11379
11380 !! test
11381 T2041: Template parameters shown as broken links
11382 !! wikitext
11383 {{{parameter}}}
11384 !! html
11385 <p>{{{parameter}}}
11386 </p>
11387 !! end
11388
11389 !! test
11390 Template with targets containing wikilinks
11391 !! options
11392 parsoid=wt2html
11393 !! wikitext
11394 {{[[foo]]}}
11395
11396 {{[[{{echo|foo}}]]}}
11397
11398 {{{{echo|[[foo}}]]}}
11399 !! html/php
11400 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11401 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11402 </p><p>{{[[foo}}]]
11403 </p>
11404 !! html/parsoid
11405 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11406 <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>
11407 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11408 !! end
11409
11410 !! article
11411 Template:''
11412 !! text
11413 bar
11414 !! endarticle
11415
11416 !! test
11417 Templates: Double quotes as template target
11418 !! wikitext
11419 foo {{''}} baz
11420 !! html/php
11421 <p>foo bar baz
11422 </p>
11423 !! html/parsoid
11424 <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
11425 </p>
11426 !! end
11427
11428 ## This test is about making sure Parsoid's data-mw is well formed in the
11429 ## face of multiple templates with intersecting and overlapping ranges. The
11430 ## wikitext itself is wretched.
11431 !! test
11432 Templates with intersecting and overlapping ranges
11433 !! wikitext
11434 {|{{echo|
11435 <p>ha</p>}}
11436 {|{{echo|
11437 <p>ho</p>}}
11438 {{echo|{{!}}hi}}
11439 |}
11440 !! html/php+tidy
11441 <p>ha</p>
11442 <p>ho</p>
11443 <table>
11444 <tr>
11445 <td></td>
11446 </tr>
11447 <tr>
11448 <td>hi</td>
11449 </tr>
11450 </table>
11451 <table>
11452 <tr>
11453 <td></td>
11454 </tr>
11455 </table>
11456 !! html/parsoid
11457 <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":""}]]}'>
11458
11459 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11460
11461 <tbody><tr><td>hi</td></tr>
11462 </tbody></table>
11463 !! end
11464
11465 !! article
11466 Template:MSGNW test
11467 !! text
11468 ''None'' of '''this''' should be
11469 * interpreted
11470 but rather passed unmodified
11471 {{test}}
11472 <gallery>
11473 File:Foobar.jpg
11474 </gallery>
11475 <!-- comment -->
11476 !! endarticle
11477
11478 # hmm, fix this or just deprecate msgnw and document its behavior?
11479 !! test
11480 msgnw keyword
11481 !! wikitext
11482 {{msgnw:MSGNW test}}
11483 !! html/php
11484 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11485 &#42; interpreted
11486 &#32;but rather passed unmodified
11487 &#123;&#123;test&#125;&#125;
11488 &#60;gallery&#62;
11489 File:Foobar.jpg
11490 &#60;/gallery&#62;
11491 &#60;!-- comment --&#62;
11492 </p>
11493 !! end
11494
11495 !! test
11496 int keyword
11497 !! wikitext
11498 {{int:youhavenewmessages|lots of money|not!}}
11499 !! html
11500 <p>You have lots of money (not!).
11501 </p>
11502 !! end
11503
11504 !! test
11505 int keyword - non-existing message
11506 !! wikitext
11507 {{int:var}}
11508 !! html
11509 <p>⧼var⧽
11510 </p>
11511 !! end
11512
11513 !! article
11514 Template:Includes
11515 !! text
11516 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11517 !! endarticle
11518
11519 !! test
11520 <includeonly> and <noinclude> being included
11521 !! wikitext
11522 {{Includes}}
11523 !! html
11524 <p>Foobar
11525 </p>
11526 !! end
11527
11528 !! article
11529 Template:Includes2
11530 !! text
11531 <onlyinclude>Foo</onlyinclude>bar
11532 !! endarticle
11533
11534 !! test
11535 <onlyinclude> being included
11536 !! wikitext
11537 {{Includes2}}
11538 !! html
11539 <p>Foo
11540 </p>
11541 !! end
11542
11543
11544 !! article
11545 Template:Includes3
11546 !! text
11547 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
11548 !! endarticle
11549
11550 !! test
11551 <onlyinclude> and <includeonly> being included
11552 !! wikitext
11553 {{Includes3}}
11554 !! html
11555 <p>Foo
11556 </p>
11557 !! end
11558
11559 !! test
11560 <includeonly> and <noinclude> on a page
11561 !! wikitext
11562 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11563 !! html
11564 <p>Foozar
11565 </p>
11566 !! end
11567
11568 !! test
11569 Un-closed <noinclude>
11570 !! wikitext
11571 <noinclude>
11572 !! html
11573 !! end
11574
11575 !! test
11576 <onlyinclude> on a page
11577 !! wikitext
11578 <onlyinclude>Foo</onlyinclude>bar
11579 !! html
11580 <p>Foobar
11581 </p>
11582 !! end
11583
11584 !! test
11585 Un-closed <onlyinclude>
11586 !! wikitext
11587 <onlyinclude>
11588 !! html
11589 !! end
11590
11591 !!test
11592 Self-closed noinclude, includeonly, onlyinclude tags
11593 !! wikitext
11594 <noinclude />
11595 <includeonly />
11596 <onlyinclude />
11597 !! html
11598 <p><br />
11599 </p>
11600 !!end
11601
11602 !!test
11603 Unbalanced includeonly and noinclude tags
11604 !! wikitext
11605 {|
11606 |a</noinclude>
11607 |b</noinclude></noinclude>
11608 |c</noinclude></includeonly>
11609 |d</includeonly></includeonly>
11610 |}
11611 !! html
11612 <table>
11613 <tr>
11614 <td>a
11615 </td>
11616 <td>b
11617 </td>
11618 <td>c&lt;/includeonly&gt;
11619 </td>
11620 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
11621 </td></tr></table>
11622
11623 !!end
11624
11625 !! article
11626 Template:Includeonly section
11627 !! text
11628 <includeonly>
11629 ==Includeonly section==
11630 </includeonly>
11631 ==Section T-1==
11632 !!endarticle
11633
11634 !! test
11635 T8563: Edit link generation for section shown by <includeonly>
11636 !! wikitext
11637 {{includeonly section}}
11638 !! html
11639 <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>
11640 <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>
11641
11642 !! end
11643
11644 # Uses same input as the contents of [[Template:Includeonly section]]
11645 !! test
11646 T8563: Section extraction for section shown by <includeonly>
11647 !! options
11648 section=T-2
11649 !! wikitext
11650 <includeonly>
11651 ==Includeonly section==
11652 </includeonly>
11653 ==Section T-2==
11654 !! html
11655 ==Section T-2==
11656 !! end
11657
11658 !! test
11659 T8563: Edit link generation for section suppressed by <includeonly>
11660 !! wikitext
11661 <includeonly>
11662 ==Includeonly section==
11663 </includeonly>
11664 ==Section 1==
11665 !! html
11666 <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>
11667
11668 !! end
11669
11670 !! test
11671 T8563: Section extraction for section suppressed by <includeonly>
11672 !! options
11673 section=1
11674 !! wikitext
11675 <includeonly>
11676 ==Includeonly section==
11677 </includeonly>
11678 ==Section 1==
11679 !! html
11680 ==Section 1==
11681 !! end
11682
11683 !! test
11684 Un-closed <includeonly>
11685 !! wikitext
11686 <includeonly>
11687 !! html/php
11688 !! html/parsoid
11689 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}'/>
11690 !! end
11691
11692 ## We used to, but no longer wt2wt this test since the default serializer
11693 ## will normalize the include directives to serialize on their own line.
11694 ## Selser will take care of preserving formatting in scenarios where they
11695 ## intermingled with other wikitext.
11696 !! test
11697 Includes and comments at SOL
11698 !! options
11699 parsoid=wt2html,html2html
11700 !! wikitext
11701 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->== hu ==
11702
11703 <noinclude>
11704 some
11705 </noinclude>* stuff
11706 * here
11707
11708 <includeonly>can have stuff</includeonly>=== here ===
11709
11710 !! html/php
11711 <h2><span class="mw-headline" id="hu">hu</span></h2>
11712 <p>some
11713 </p>
11714 <ul><li> stuff</li>
11715 <li> here</li></ul>
11716 <h3><span class="mw-headline" id="here">here</span></h3>
11717
11718 !! html/parsoid
11719 <!-- 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>
11720
11721 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
11722 <p>some</p>
11723 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li> stuff</li>
11724 <li> here</li></ul>
11725
11726 <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>
11727
11728 !! end
11729
11730 # TODO: test with DOM fragment reuse!
11731 !! test
11732 Parsoid: DOM fragment reuse
11733 !! options
11734 parsoid=wt2wt,wt2html
11735 !! wikitext
11736 a{{echo|b<table></table>c}}d
11737
11738 a{{echo|b
11739 <table></table>
11740 c}}d
11741
11742 {{echo|a
11743
11744 <table></table>
11745
11746 b}}
11747 !! html
11748 <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>
11749
11750 <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">
11751 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
11752 </span><p about="#mwt2">cd</p>
11753
11754 <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">
11755
11756 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
11757
11758 </span><p about="#mwt3">b</p>
11759 !! end
11760
11761 !! test
11762 Parsoid: Merge double tds (T52603)
11763 !! options
11764 parsoid
11765 !! wikitext
11766 {|
11767 |{{echo|{{!}} foo}}
11768 |}
11769 !! html
11770 <table><tbody>
11771 <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>
11772 </tbody></table>
11773 !! end
11774
11775 !! test
11776 Parsoid: Merge double tds in nested transclusion content (T52603)
11777 !! options
11778 parsoid
11779 !! wikitext
11780 {{echo|<div>}}
11781 {|
11782 |{{echo|{{!}} foo}}
11783 |}
11784 {{echo|</div>}}
11785 !! html
11786 <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}}]}'>
11787 <table><tbody>
11788 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
11789 </tbody></table>
11790 </div>
11791 !! end
11792
11793 ###
11794 ### <includeonly> and <noinclude> in attributes
11795 ###
11796 !!test
11797 0. includeonly around the entire attribute
11798 !! wikitext
11799 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
11800 !! html
11801 <p><span id="v2">bar</span>
11802 </p>
11803 !!end
11804
11805 !!test
11806 1. includeonly in html attr key
11807 !! wikitext
11808 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
11809 !! html
11810 <p><span id="foo">bar</span>
11811 </p>
11812 !!end
11813
11814 !!test
11815 2. includeonly in html attr value
11816 !! wikitext
11817 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
11818 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
11819 !! html
11820 <p><span id="v1">bar</span>
11821 <span id="v1">bar</span>
11822 </p>
11823 !!end
11824
11825 !!test
11826 3. includeonly in part of an attr value
11827 !! wikitext
11828 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
11829 !! html
11830 <p><span style="color:red;">bar</span>
11831 </p>
11832 !!end
11833
11834 !!test
11835 4. includeonly in table attributes
11836 !! wikitext
11837 {|
11838 |- <noinclude>
11839 |-
11840 |a
11841 </noinclude>
11842 |- <includeonly>
11843 |-
11844 |b
11845 </includeonly>
11846 |}
11847 !! html
11848 <table>
11849
11850
11851 <tr>
11852 <td>a
11853 </td></tr>
11854 </table>
11855
11856 !!end
11857
11858 ###
11859 ### Preprocessor precedence tests
11860 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
11861 ###
11862 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
11863 !! test
11864 Preprocessor precedence 1: link is rightmost opening
11865 !! wikitext
11866 {{[[Foo|bar}}]]
11867
11868 But close-brace is not a valid character in a link title:
11869 {{[[Foo}}|bar]]
11870
11871 However, we can still tell this was handled as a link in the preprocessor:
11872 {{echo|[[Foo}}|bar]]|bat}}
11873 !! html
11874 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
11875 </p><p>But close-brace is not a valid character in a link title:
11876 {{[[Foo}}|bar]]
11877 </p><p>However, we can still tell this was handled as a link in the preprocessor:
11878 [[Foo}}|bar]]
11879 </p>
11880 !! end
11881
11882 !! test
11883 Preprocessor precedence 2: template is rightmost opening
11884 !! options
11885 language=zh
11886 !! wikitext
11887 -{{echo|foo}-}}-
11888 !! html
11889 <p>-foo}--
11890 </p>
11891 !! end
11892
11893 !! test
11894 Preprocessor precedence 3: language converter is rightmost opening
11895 !! options
11896 language=zh
11897 !! wikitext
11898 {{echo|hi}}
11899
11900 {{-{R|echo|hi}}}-
11901
11902 [[-{R|raw]]}-
11903 !! html
11904 <p>hi
11905 </p><p>{{echo|hi}}
11906 </p><p>[[raw]]
11907 </p>
11908 !! end
11909
11910 !! test
11911 Preprocessor precedence 4: left-most angle bracket
11912 !! options
11913 language=zh
11914 !! wikitext
11915 <!--{raw}-->
11916 !! html
11917 !! end
11918
11919 !! article
11920 Template:Precedence5
11921 !! text
11922 {{{{{1}}}}}
11923 !! endarticle
11924
11925 !! test
11926 Preprocessor precedence 5: tplarg takes precedence over template
11927 !! wikitext
11928 {{Precedence5|Bullet}}
11929 !! html
11930 <ul><li> Bar</li></ul>
11931
11932 !! end
11933
11934 !! test
11935 Preprocessor precedence 6: broken link is rightmost opening
11936 !! wikitext
11937 {{echo|[[Foo}}
11938
11939 {{echo|[[Foo|bar|bat=baz}}
11940 !! html
11941 <p>{{echo|[[Foo}}
11942 </p><p>{{echo|[[Foo|bar|bat=baz}}
11943 </p>
11944 !! end
11945
11946 # This next test exposes a difference between PHP and Parsoid:
11947 # Given [[Foo|{{echo|Bar]]x}}y]]z:
11948 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
11949 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
11950 # outer `[[Foo` extends until the `y]]`
11951 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
11952 # intermediate result (after template expansion), and link processing
11953 # happens on this intermediate result, which moves the wikilink
11954 # boundary leftward to `[[Foo|Bar]]`
11955 # 2b) Parsoid works in a single step, so it's going to keep the
11956 # wikilink as extending to the `y]]`
11957 # 3a) Then PHP does linktrail processing which slurps up the trailing
11958 # `xy` inside the link.
11959 # 3b) Parsoid will do linktrail processing to slurp up the trailing
11960 # `z` inside the link.
11961 # This is "correct" behavior. Parsoid's basic worldview is that the
11962 # `]]` inside the template shouldn't be allowed to leak out to affect
11963 # the surrounding wikilink. PHP may match Parsoid (in the future)
11964 # if you use {{#balance}} (T114445).
11965
11966 !! test
11967 Preprocessor precedence 7: broken template is rightmost opening
11968 !! wikitext
11969 [[Foo|{{echo|Bar]]
11970
11971 [[Foo|{{echo|Bar]]-x}}-y]]-z
11972
11973 Careful: linktrails can move the end of the wikilink:
11974 [[Foo|{{echo|y']]a}}l]]l
11975 !! html
11976 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
11977 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
11978 </p><p>Careful: linktrails can move the end of the wikilink:
11979 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
11980 </p>
11981 !! end
11982
11983 !! test
11984 Preprocessor precedence 8: broken language converter is rightmost opening
11985 !! options
11986 language=zh
11987 !! wikitext
11988 [[Foo-{R|raw]]
11989 !! html
11990 <p>[[Foo-{R|raw]]
11991 </p>
11992 !! end
11993
11994 !! article
11995 Template:Preprocessor_precedence_9
11996 !! text
11997 ;4: {{{{1}}}}
11998 ;5: {{{{{2}}}}}
11999 ;6: {{{{{{3}}}}}}
12000 ;7: {{{{{{{4}}}}}}}
12001 !! endarticle
12002
12003 !! test
12004 Preprocessor precedence 9: groups of braces
12005 !! wikitext
12006 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12007 !! html
12008 <dl><dt>4</dt>
12009 <dd> {Four}</dd>
12010 <dt>5</dt>
12011 <dd> </dd></dl>
12012 <ul><li> Bar</li></ul>
12013 <dl><dt>6</dt>
12014 <dd> Four</dd>
12015 <dt>7</dt>
12016 <dd> {Bullet}</dd></dl>
12017
12018 !! end
12019
12020 !! article
12021 Template:Preprocessor_precedence_10
12022 !! text
12023 ;1: -{R|raw}-
12024 ;2: -{{Bullet}}-
12025 ;3: -{{{1}}}-
12026 ;4: -{{{{2}}}}-
12027 ;5: -{{{{{3}}}}}-
12028 ;6: -{{{{{{4}}}}}}-
12029 ;7: -{{{{{{{5}}}}}}}-
12030 !! endarticle
12031
12032 !! test
12033 Preprocessor precedence 10: groups of braces with leading dash
12034 !! options
12035 language=zh
12036 !! wikitext
12037 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12038 !! html
12039 <dl><dt>1</dt>
12040 <dd> raw</dd>
12041 <dt>2</dt>
12042 <dd> -</dd></dl>
12043 <ul><li> Bar-</li></ul>
12044 <dl><dt>3</dt>
12045 <dd> -Three-</dd>
12046 <dt>4</dt>
12047 <dd> raw2</dd>
12048 <dt>5</dt>
12049 <dd> -</dd></dl>
12050 <ul><li> Bar-</li></ul>
12051 <dl><dt>6</dt>
12052 <dd> -Three-</dd>
12053 <dt>7</dt>
12054 <dd> raw2</dd></dl>
12055
12056 !! end
12057
12058 !! test
12059 Preprocessor precedence 11: found during visual diff testing
12060 !! wikitext
12061 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12062
12063 {{echo|-{{echo|-{{echo|x}}}}}}
12064
12065 {{echo|-{{echo|x}}}}
12066 !! html
12067 <p><span>-<span>-x</span></span>
12068 </p><p>--x
12069 </p><p>-x
12070 </p>
12071 !! end
12072
12073 !! test
12074 Preprocessor precedence 12: broken language converter closed by brace.
12075 !! wikitext
12076 This form breaks the template, which is unfortunate:
12077 * {{echo|foo-{bar}bat}}
12078
12079 But if the broken language converter markup is inside an extension
12080 tag, nothing bad happens:
12081 * <nowiki>foo-{bar}bat</nowiki>
12082 * {{echo|<nowiki>foo-{bar}bat</nowiki>}}
12083 * <pre>foo-{bar}bat</pre>
12084 * {{echo|<pre>foo-{bar}bat</pre>}}
12085
12086 <tag>foo-{bar}bat</tag>
12087 {{echo|<tag>foo-{bar}bat</tag>}}
12088
12089 !! html+tidy
12090 <p>This form breaks the template, which is unfortunate:</p>
12091 <ul>
12092 <li>{{echo|foo-{bar}bat}}</li>
12093 </ul>
12094 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12095 <ul>
12096 <li>foo-{bar}bat</li>
12097 <li>foo-{bar}bat</li>
12098 <li>
12099 <pre>
12100 foo-{bar}bat
12101 </pre></li>
12102 <li>
12103 <pre>
12104 foo-{bar}bat
12105 </pre></li>
12106 </ul>
12107 <pre>
12108 'foo-{bar}bat'
12109 array (
12110 )
12111 </pre>
12112 <pre>
12113 'foo-{bar}bat'
12114 array (
12115 )
12116 </pre>
12117 !! end
12118
12119 !! test
12120 Preprocessor precedence, 13: broken language converter in external link
12121 !! wikitext
12122 * [http://example.com/-{foo Example in URL]
12123 * [http://example.com Example in -{link} description]
12124 * {{echo|[http://example.com/-{foo Breaks template, however]}}
12125 !! html+tidy
12126 <ul>
12127 <li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12128 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12129 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12130 </ul>
12131 !! end
12132
12133 !! test
12134 Preprocessor precedence, 14: broken language converter in comment
12135 !! wikitext
12136 * <!--{{foo}}--> ...should be ok
12137 * <!---{{foo}}--> ...extra dashes
12138 * {{echo|foo<!-- -{bar} -->bat}} ...should be ok
12139 !! html+tidy
12140 <ul>
12141 <li>...should be ok</li>
12142 <li>...extra dashes</li>
12143 <li>foobat ...should be ok</li>
12144 </ul>
12145 !! end
12146
12147 !! test
12148 Preprocessor precedence, 15: broken brace markup in headings
12149 !! wikitext
12150 __NOTOC__ __NOEDITSECTION__
12151 ===1 foo[bar 1===
12152 1
12153 ===2 foo[[bar 2===
12154 2
12155 ===3 foo{bar 3===
12156 3
12157 ===4 foo{{bar 4===
12158 4
12159 ===5 foo{{{bar 5===
12160 5
12161 ===6 foo-{bar 6===
12162 6
12163 !! html+tidy
12164 <h3><span class="mw-headline" id="1_foo.5Bbar_1">1 foo[bar 1</span></h3>
12165 <p>1</p>
12166 <h3><span class="mw-headline" id="2_foo.5B.5Bbar_2">2 foo[[bar 2</span></h3>
12167 <p>2</p>
12168 <h3><span class="mw-headline" id="3_foo.7Bbar_3">3 foo{bar 3</span></h3>
12169 <p>3</p>
12170 <h3><span class="mw-headline" id="4_foo.7B.7Bbar_4">4 foo{{bar 4</span></h3>
12171 <p>4</p>
12172 <h3><span class="mw-headline" id="5_foo.7B.7B.7Bbar_5">5 foo{{{bar 5</span></h3>
12173 <p>5</p>
12174 <h3><span class="mw-headline" id="6_foo-.7Bbar_6">6 foo-{bar 6</span></h3>
12175 <p>6</p>
12176 !! end
12177
12178 ###
12179 ### Token Stream Patcher tests
12180 ###
12181 ### These tests won't always pass wt2wt and other modes because
12182 ### on serialization, the table will be output on a new line.
12183 ### For now, we are blacklisting them, and using this to test selser.
12184 ###
12185
12186 !!test
12187 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12188 !!options
12189 parsoid=wt2html,wt2wt
12190 !!wikitext
12191 {{echo|}}{| width = '100%'
12192 |foo
12193 |}
12194 !!html/parsoid
12195 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12196 <tbody><tr><td>foo</td></tr>
12197 </tbody></table>
12198 !!end
12199
12200 ## We used to, but no longer wt2wt this test since the default serializer
12201 ## will normalize the include directives to serialize on their own line.
12202 ## Selser will take care of preserving formatting in scenarios where they
12203 ## intermingled with other wikitext.
12204 !!test
12205 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12206 !!options
12207 parsoid=wt2html
12208 !!wikitext
12209 <includeonly>a</includeonly>{| {{{b}}}
12210 |c
12211 |}
12212 !!html/parsoid
12213 <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":""}]]}'>
12214 <tbody><tr><td>c</td></tr>
12215 </tbody></table>
12216 !!end
12217
12218 !! test
12219 Table wikitext syntax outside wiki-tables
12220 !! wikitext
12221 a
12222 |+ not a caption
12223 ! not a table heading
12224 |- not a table row
12225 | not a table cell
12226 | class="foo bar" | baz
12227 b
12228 |}
12229 |-
12230 c
12231 !! html
12232 <p>a
12233 |+ not a caption
12234 ! not a table heading
12235 |- not a table row
12236 | not a table cell
12237 | class="foo bar" | baz
12238 b
12239 |}
12240 |-
12241 c
12242 </p>
12243 !! end
12244
12245 ###
12246 ### Testing parsing of templates where a template arg
12247 ### has the same name as the template itself.
12248 ###
12249
12250 !! article
12251 Template:quote
12252 !! text
12253 {{{quote|{{{1}}}}}}
12254 !! endarticle
12255
12256 !!test
12257 Templates: Template Name/Arg clash: 1. Use of positional param
12258 !! wikitext
12259 {{quote|foo}}
12260 !! html
12261 <p>foo
12262 </p>
12263 !!end
12264
12265 !!test
12266 Templates: Template Name/Arg clash: 2. Use of named param
12267 !! wikitext
12268 {{quote|quote=foo}}
12269 !! html
12270 <p>foo
12271 </p>
12272 !!end
12273
12274 !!test
12275 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12276 !! wikitext
12277 {{quote|quote}}
12278 !! html
12279 <p>quote
12280 </p>
12281 !!end
12282
12283 ###
12284 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12285 ###
12286
12287 !!test
12288 Templates: 1. Simple use
12289 !! wikitext
12290 {{echo|Foo}}
12291 !! html
12292 <p>Foo
12293 </p>
12294 !!end
12295
12296 !!test
12297 Templates: 2. Inside a block tag
12298 !! wikitext
12299 <div>{{echo|Foo}}</div>
12300 <blockquote>{{echo|Foo}}</blockquote>
12301 !! html
12302 <div>Foo</div>
12303 <blockquote>Foo</blockquote>
12304
12305 !! html+tidy
12306 <div>Foo</div>
12307 <blockquote>
12308 <p>Foo</p>
12309 </blockquote>
12310 !!end
12311
12312 !!test
12313 Templates: P-wrapping: 1a. Templates on consecutive lines
12314 !! wikitext
12315 {{echo|Foo}}
12316 {{echo|bar}}
12317 !! html
12318 <p>Foo
12319 bar
12320 </p>
12321 !!end
12322
12323 !!test
12324 Templates: P-wrapping: 1b. Templates on consecutive lines
12325 !! wikitext
12326 Foo
12327
12328 {{echo|bar}}
12329 {{echo|baz}}
12330 !! html
12331 <p>Foo
12332 </p><p>bar
12333 baz
12334 </p>
12335 !!end
12336
12337 !!test
12338 Templates: P-wrapping: 1c. Templates on consecutive lines
12339 !! wikitext
12340 {{echo|Foo}}
12341 {{echo|bar}} <div>baz</div>
12342 !! html
12343 <p>Foo
12344 </p>
12345 bar <div>baz</div>
12346
12347 !! html+tidy
12348 <p>Foo</p>
12349 <p>bar</p>
12350 <div>baz</div>
12351 !! end
12352
12353 !!test
12354 Templates: P-wrapping: 1d. Template preceded by comment-only line
12355 !!options
12356 parsoid
12357 !! wikitext
12358 <!-- foo -->
12359 {{echo|Bar}}
12360 !! html
12361 <!-- foo -->
12362
12363 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
12364 !!end
12365
12366 !!test
12367 Templates: Inline Text: 1. Multiple template uses
12368 !! wikitext
12369 {{echo|Foo}}bar{{echo|baz}}
12370 !! html
12371 <p>Foobarbaz
12372 </p>
12373 !!end
12374
12375 !!test
12376 Templates: Inline Text: 2. Back-to-back template uses
12377 !! wikitext
12378 {{echo|Foo}}{{echo|bar}}
12379 !! html
12380 <p>Foobar
12381 </p>
12382 !!end
12383
12384 !!test
12385 Templates: Block Tags: 1. Multiple template uses
12386 !! wikitext
12387 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
12388 !! html
12389 <div>Foo</div><div>bar</div><div>baz</div>
12390
12391 !!end
12392
12393 !!test
12394 Templates: Block Tags: 2. Back-to-back template uses
12395 !! wikitext
12396 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
12397 !! html
12398 <div>Foo</div><div>bar</div>
12399
12400 !!end
12401
12402 # This is an edge case relating to paragraph wrapping.
12403 !!test
12404 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
12405 !! wikitext
12406 {{echo|a
12407 b</p>}}
12408 !! html/parsoid
12409 <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
12410 b</p>
12411 !!end
12412
12413 !!test
12414 Templates: Links: 1. Simple example
12415 !! wikitext
12416 {{echo|[[Foo|bar]]}}
12417 !! html
12418 <p><a href="/wiki/Foo" title="Foo">bar</a>
12419 </p>
12420 !!end
12421
12422 !!test
12423 Templates: Links: 2. Generation of link href
12424 !! wikitext
12425 [[{{echo|Foo}}|bar]]
12426 !! html
12427 <p><a href="/wiki/Foo" title="Foo">bar</a>
12428 </p>
12429 !!end
12430
12431 !!test
12432 Templates: Links: 3. Generation of part of a link href
12433 !! wikitext
12434 [[Fo{{echo|o}}|bar]]
12435
12436 [[Foo{{echo|bar}}]]
12437
12438 [[Foo{{echo|bar}}baz]]
12439
12440 [[Foo{{echo|bar}}|bar]]
12441
12442 [[:Foo{{echo|bar}}]]
12443
12444 [[:Foo{{echo|bar}}|bar]]
12445 !! html
12446 <p><a href="/wiki/Foo" title="Foo">bar</a>
12447 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12448 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
12449 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12450 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12451 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12452 </p>
12453 !!end
12454
12455 !!test
12456 Templates: Links: 4. Multiple templates generating link href
12457 !! wikitext
12458 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
12459 !! html
12460 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12461 </p>
12462 !!end
12463
12464 !!test
12465 Templates: Links: 5. Generation of link text
12466 !! wikitext
12467 [[Foo|{{echo|bar}}]]
12468 !! html
12469 <p><a href="/wiki/Foo" title="Foo">bar</a>
12470 </p>
12471 !!end
12472
12473 !!test
12474 Templates: Links: 5. Nested templates (only outermost template should be marked)
12475 !! wikitext
12476 {{echo|[[{{echo|Foo}}|bar]]}}
12477 !! html
12478 <p><a href="/wiki/Foo" title="Foo">bar</a>
12479 </p>
12480 !!end
12481
12482 !!test
12483 Templates: HTML Tag: 1. Generation of HTML attr. key
12484 !! wikitext
12485 <div {{echo|style}}="color:red;">foo</div>
12486 !! html
12487 <div style="color:red;">foo</div>
12488
12489 !!end
12490
12491 !!test
12492 Templates: HTML Tag: 2. Generation of HTML attr. value
12493 !! wikitext
12494 <div style={{echo|'color:red;'}}>foo</div>
12495 !! html
12496 <div style="color:red;">foo</div>
12497
12498 !!end
12499
12500 !!test
12501 Templates: HTML Tag: 3. Generation of HTML attr key and value
12502 !! wikitext
12503 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
12504 !! html
12505 <div style="color:red;">foo</div>
12506
12507 !!end
12508
12509 !!test
12510 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
12511 !! wikitext
12512 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
12513 !! html
12514 <div title="This is a long title with just one piece templated">foo</div>
12515
12516 !!end
12517
12518 !!test
12519 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
12520 !! wikitext
12521 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
12522 !! html
12523 <div title="This is a long title with just one piece templated">foo</div>
12524
12525 !!end
12526
12527 !!test
12528 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
12529 !! wikitext
12530 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
12531 !! html
12532 <div title="This is a long title with just one piece templated">foo</div>
12533
12534 !!end
12535
12536 # SSS FIXME: While it is great we added support for all this,
12537 # do we want to make this part of the spec? Maybe we want to
12538 # deprecate this kind of usage in the future?
12539 !!test
12540 Templates: HTML Tag: 7. Generation of partial attribute key string
12541 !! wikitext
12542 <div st{{echo|yle}}="color:red;">foo</div>
12543 !! html
12544 <div style="color:red;">foo</div>
12545
12546 !!end
12547
12548 !! test
12549 Templates: HTML Tag: 8. Template-generated attribute (k=v)
12550 !! wikitext
12551 <div {{echo|1=id="v1"}}>bar</div>
12552 !! html
12553 <div id="v1">bar</div>
12554
12555 !!end
12556
12557 !! test
12558 Templates: HTML Tag: 9. Multiple template-generated attributes
12559 !! wikitext
12560 <div {{echo|1=id="v1" title="foo"}}>bar</div>
12561 !! html
12562 <div id="v1" title="foo">bar</div>
12563
12564 !!end
12565
12566 !! test
12567 Templates: Support for templates generating attributes and content
12568 !! wikitext
12569 {| {{mixed_attr_content_template}}
12570 |-
12571 |bar
12572 |}
12573 !! html/php
12574 <table style="color:red;" title="T48811">
12575
12576 <tr>
12577 <td>foo
12578 </td></tr>
12579 <tr>
12580 <td>bar
12581 </td></tr></table>
12582
12583 !! html/parsoid
12584 <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|}"]}'>
12585 <tbody><tr>
12586 <td>foo</td></tr>
12587 <tr>
12588 <td>bar</td></tr>
12589 </tbody></table>
12590 !!end
12591
12592 !! test
12593 1. Entities and nowikis inside templated attributes should be handled correctly
12594 !! wikitext
12595 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
12596 !! html/php
12597 <div style="background:#f9f9f9;">foo</div>
12598
12599 !! html/parsoid
12600 <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>
12601 !! end
12602
12603 !! test
12604 2. Entities and nowikis inside templated attributes should be handled correctly
12605 !! wikitext
12606 {|
12607 |{{table_attribs_3}}
12608 |}
12609 !! html/php
12610 <table>
12611 <tr>
12612 <td style="background:#f9f9f9;">Foo
12613 </td></tr></table>
12614
12615 !! html/parsoid
12616 <table>
12617 <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>
12618 </tbody></table>
12619 !! end
12620
12621 !! test
12622 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
12623 !! wikitext
12624 {{tbl-start}}
12625 |{{table_attribs_3}}
12626 {{tbl-end}}
12627 !! html/php
12628 <table>
12629 <tr>
12630 <td style="background:#f9f9f9;">Foo
12631 </td></tr></table>
12632
12633 !! html/parsoid
12634 <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}}]}'>
12635 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
12636 </tbody></table>
12637 !! end
12638
12639 # T107622
12640 !! test
12641 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
12642 !! wikitext
12643 {|
12644 | {{table_attribs_6}} hi
12645 |}
12646 !! html/php
12647 <table>
12648 <tr>
12649 <td style="background: red;"> hi
12650 </td></tr></table>
12651
12652 !! html/parsoid
12653 <table>
12654 <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>
12655 </tbody></table>
12656 !! end
12657
12658 !!test
12659 Templates: HTML Tables: 1. Generating start of a HTML table
12660 !! wikitext
12661 {{echo|<table><tr><td>foo</td>}}</tr></table>
12662 !! html
12663 <table><tr><td>foo</td></tr></table>
12664
12665 !!end
12666
12667 !!test
12668 Templates: HTML Tables: 2a. Generating middle of a HTML table
12669 !! wikitext
12670 <table><tr>{{echo|<td>foo</td>}}</tr></table>
12671 !! html
12672 <table><tr><td>foo</td></tr></table>
12673
12674 !!end
12675
12676 !!test
12677 Templates: HTML Tables: 2b. Generating middle of a HTML table
12678 !! wikitext
12679 <table>{{echo|<tr><td>foo</td></tr>}}</table>
12680 !! html
12681 <table><tr><td>foo</td></tr></table>
12682
12683 !!end
12684
12685 !!test
12686 Templates: HTML Tables: 3. Generating end of a HTML table
12687 !! wikitext
12688 <table><tr>{{echo|<td>foo</td></tr></table>}}
12689 !! html
12690 <table><tr><td>foo</td></tr></table>
12691
12692 !!end
12693
12694 !!test
12695 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
12696 !! wikitext
12697 {{echo|<table>}}<tr><td>foo</td></tr></table>
12698 !! html
12699 <table><tr><td>foo</td></tr></table>
12700
12701 !!end
12702
12703 !!test
12704 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
12705 !! wikitext
12706 <table>{{echo|<tr>}}<td>foo</td></tr></table>
12707 !! html
12708 <table><tr><td>foo</td></tr></table>
12709
12710 !!end
12711
12712 !!test
12713 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
12714 !! wikitext
12715 <table><tr>{{echo|<td>}}foo</td></tr></table>
12716 !! html
12717 <table><tr><td>foo</td></tr></table>
12718
12719 !!end
12720
12721 !!test
12722 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
12723 !! wikitext
12724 <table><tr><td>foo{{echo|</td>}}</tr></table>
12725 !! html
12726 <table><tr><td>foo</td></tr></table>
12727
12728 !!end
12729
12730 !!test
12731 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
12732 !! wikitext
12733 <table><tr><td>foo</td>{{echo|</tr>}}</table>
12734 !! html
12735 <table><tr><td>foo</td></tr></table>
12736
12737 !!end
12738
12739 !!test
12740 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
12741 !! wikitext
12742 <table><tr><td>foo</td></tr>{{echo|</table>}}
12743 !! html
12744 <table><tr><td>foo</td></tr></table>
12745
12746 !!end
12747
12748 !!test
12749 Templates: HTML Tables: 5. Proper fostering of categories from inside
12750 !!options
12751 parsoid=wt2html,wt2wt
12752 !! wikitext
12753 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
12754 <!--Two categories (T52330)-->
12755 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
12756 !! html
12757 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
12758 <!--Two categories (T52330)-->
12759 <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>
12760 !!end
12761
12762 !!test
12763 Templates: Wiki Tables: 1a. Fostering of entire template content
12764 !! wikitext
12765 {|
12766 {{echo|a}}
12767 |}
12768 !! html
12769 <table>
12770 a
12771 <tr><td></td></tr></table>
12772
12773 !! html+tidy
12774 <p>a</p>
12775 <table>
12776 <tr>
12777 <td></td>
12778 </tr>
12779 </table>
12780 !! end
12781
12782 !!test
12783 Templates: Wiki Tables: 1b. Fostering of entire template content
12784 !! wikitext
12785 {|
12786 {{echo|<div>}}
12787 foo
12788 {{echo|</div>}}
12789 |}
12790 !! html
12791 <table>
12792 <div>
12793 <p>foo
12794 </p>
12795 </div>
12796 <tr><td></td></tr></table>
12797
12798 !! html+tidy
12799 <div>
12800 <p>foo</p>
12801 </div>
12802 <table>
12803 <tr>
12804 <td></td>
12805 </tr>
12806 </table>
12807 !! end
12808
12809 !!test
12810 Templates: Wiki Tables: 2. Fostering of partial template content
12811 !! wikitext
12812 {|
12813 {{echo|a
12814 <div>b</div>}}
12815 |}
12816 !! html
12817 <table>
12818 a
12819 <div>b</div>
12820 <tr><td></td></tr></table>
12821
12822 !! html+tidy
12823 <p>a</p>
12824 <div>b</div>
12825 <table>
12826 <tr>
12827 <td></td>
12828 </tr>
12829 </table>
12830 !! end
12831
12832 !!test
12833 Templates: Wiki Tables: 3. td-content via multiple templates
12834 !! wikitext
12835 {|
12836 {{echo|{{pipe}}a}}{{echo|b}}
12837 |}
12838 !! html
12839 <table>
12840 <tr>
12841 <td>ab
12842 </td></tr></table>
12843
12844 !!end
12845
12846 !!test
12847 Templates: Wiki Tables: 4. Templated tags, no content
12848 !! wikitext
12849 {{tbl-start}}
12850 {{tbl-end}}
12851 !! html
12852 <table>
12853 <tr><td></td></tr></table>
12854
12855 !!end
12856
12857 !!test
12858 Templates: Wiki Tables: 5. Templated tags, regular td-tags
12859 !! wikitext
12860 {{tbl-start}}
12861 |foo
12862 {{tbl-end}}
12863 !! html
12864 <table>
12865 <tr>
12866 <td>foo
12867 </td></tr></table>
12868
12869 !!end
12870
12871 !!test
12872 Templates: Wiki Tables: 6. Templated tags, templated td-tags
12873 !! wikitext
12874 {{tbl-start}}
12875 {{!}}foo
12876 {{tbl-end}}
12877 !! html
12878 <table>
12879 <tr>
12880 <td>foo
12881 </td></tr></table>
12882
12883 !!end
12884
12885 ## This test case is very specific to Parsoid's internals
12886 ## and is hence only tested for Parsoid's code. Parsoid uses
12887 ## a <meta> marker tag for <ref> tags and they are expanded
12888 ## much later. We are verifying that this <meta> tag usage
12889 ## doesn't prevent foster parenting.
12890 !!test
12891 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
12892 !!wikitext
12893 {{PartialTable}}<ref>foo</ref>
12894 |}
12895
12896 <references />
12897 !!html/parsoid
12898 <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">
12899 <tbody>
12900 </tbody></table>
12901
12902 <ol class="mw-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>
12903 !!end
12904
12905 !! test
12906 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
12907 !! wikitext
12908 {{echo|
12909 {{{!}}
12910 {{!}}-}}
12911 <onlyinclude>
12912 |foo
12913 </onlyinclude>
12914 {{!}}}
12915 !! html/parsoid
12916 <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{{!}}}"]}'>
12917 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
12918 <tbody><tr>
12919
12920 <td>foo
12921 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
12922 </tbody></table>
12923 !! end
12924
12925 !!test
12926 Templates: Lists: Multi-line list-items via templates
12927 !! wikitext
12928 *{{echo|a {{nonexistent|
12929 unused}}}}
12930 *{{echo|b {{nonexistent|
12931 unused}}}}
12932 !! html
12933 <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>
12934 <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>
12935
12936 !!end
12937
12938 !!test
12939 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
12940 !! wikitext
12941 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
12942 !! html
12943 <p><i>ab</i>c<i>d</i>e
12944 </p>
12945 !!end
12946
12947 !!test
12948 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
12949 (PHP parser generates misnested html)
12950 !! wikitext
12951 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
12952 !! html/parsoid
12953 <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>
12954 !!end
12955
12956 !!test
12957 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
12958 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
12959 !! options
12960 parsoid=wt2html,wt2wt
12961 !! wikitext
12962 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
12963 !! html
12964 <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>
12965 <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>
12966 <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>
12967 !!end
12968
12969 !!test
12970 Templates: Ugly nesting: 4. Divs opened/closed across templates
12971 !! wikitext
12972 a<div>b{{echo|c</div>d}}e
12973 !! html
12974 a<div>bc</div>de
12975
12976 !! html+tidy
12977 <p>a</p>
12978 <div>bc</div>
12979 <p>de</p>
12980 !! end
12981
12982 !!test
12983 Templates: Ugly templates: 1. Navbox template parses badly leading to table misnesting
12984 (Parsoid-centric)
12985 !! options
12986 parsoid
12987 !! wikitext
12988 {|
12989 |{{echo|foo</table>}}
12990 |bar
12991 |}
12992 !! html
12993 <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|}"]}'>
12994
12995 <tbody>
12996 <tr>
12997 <td>foo</td></tr></tbody></table><span about="#mwt1">
12998 </span><span about="#mwt1">|bar</span><span about="#mwt1">
12999 |}</span>
13000 !!end
13001
13002 !!test
13003 Templates: Ugly templates: 2. Navbox template parses badly leading to table misnesting
13004 (Parsoid-centric)
13005 !! options
13006 parsoid
13007 !! wikitext
13008 <table>
13009 <tr>
13010 <td>
13011 <table>
13012 <tr>
13013 <td>1. {{echo|foo </table>}}</td>
13014 <td> bar </td>
13015 <td>2. {{echo|baz </table>}}</td>
13016 </tr>
13017 <tr>
13018 <td>abc</td>
13019 </tr>
13020 </table>
13021 </td>
13022 </tr>
13023 <tr>
13024 <td>xyz</td>
13025 </tr>
13026 </table>
13027 !! html
13028 <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>"]}'>
13029 <tbody><tr>
13030 <td>
13031 <table>
13032 <tbody><tr>
13033 <td>1. foo </td></tr></tbody></table></td>
13034 <td> bar </td>
13035 <td>2. baz </td></tr></tbody></table><span about="#mwt2">
13036 </span><span about="#mwt2">
13037 </span><span about="#mwt2">
13038 </span><span about="#mwt2">abc</span><span about="#mwt2">
13039 </span><span about="#mwt2">
13040 </span><span about="#mwt2">
13041 </span><span about="#mwt2">
13042 </span><span about="#mwt2">
13043 </span><span about="#mwt2">
13044 </span><span about="#mwt2">xyz</span><span about="#mwt2">
13045 </span><span about="#mwt2">
13046 </span>
13047 !!end
13048
13049 !! test
13050 Templates: Ugly templates: 3. newline-only template parameter
13051 !! wikitext
13052 foo {{echo|
13053 }}
13054 !! html
13055 <p>foo
13056 </p>
13057 !! end
13058
13059 # This looks like a bug: a single newline triggers p/br for some reason.
13060 !! test
13061 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13062 !! wikitext
13063 {{echo|
13064 }}
13065 !! html
13066 <p><br />
13067 </p>
13068 !! end
13069
13070 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13071 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13072 !! test
13073 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13074 !! wikitext
13075 {{echo|<table>}}
13076 {{echo|<div>foo}}
13077 {{echo|</table>}}
13078 !! html/parsoid
13079 <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
13080 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13081 </table>
13082 !! end
13083
13084 # T66017 -- ugly wikitext with fostered content generates two template ranges
13085 # that are "identical" and generate nesting cycles in the algorithm
13086 !! test
13087 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13088 !! wikitext
13089 {{echo|<table><tr><td><table>}}
13090 {{echo|<div>}}
13091 {{echo|</div>}}
13092 !! html/parsoid
13093 <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"}'>
13094 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13095 </table></td></tr></tbody></table>
13096 !! end
13097
13098 !! test
13099 Templates: Parameters substituted at the top-level
13100 !! wikitext
13101 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13102
13103 {{{foo|bar|baz}}}
13104 !! html/php
13105 <p><i>who</i> me? <b>never!</b>
13106 </p><p>bar
13107 </p>
13108 !! html/parsoid
13109 <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>
13110
13111 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13112 !! end
13113
13114 !!test
13115 Parser Functions: 1. Simple example
13116 !! wikitext
13117 {{uc:foo}}
13118 !! html
13119 <p>FOO
13120 </p>
13121 !!end
13122
13123 !!test
13124 Parser Functions: 2. Nested use (only outermost should be marked up)
13125 !! wikitext
13126 {{uc:{{lc:FOO}}}}
13127 !! html
13128 <p>FOO
13129 </p>
13130 !!end
13131
13132 ###
13133 ### Pre-save transform tests
13134 ###
13135 !! test
13136 pre-save transform: subst:
13137 !! options
13138 pst
13139 !! wikitext
13140 {{subst:test}}
13141 !! html/php
13142 This is a test template
13143 !! end
13144
13145 !! test
13146 pre-save transform: normal template
13147 !! options
13148 pst
13149 !! wikitext
13150 {{test}}
13151 !! html/php
13152 {{test}}
13153 !! end
13154
13155 !! test
13156 pre-save transform: nonexistent template
13157 !! options
13158 pst
13159 !! wikitext
13160 {{thistemplatedoesnotexist}}
13161 !! html/php
13162 {{thistemplatedoesnotexist}}
13163 !! end
13164
13165 !! test
13166 pre-save transform: subst magic variables
13167 !! options
13168 pst
13169 !! wikitext
13170 {{subst:SITENAME}}
13171 !! html/php
13172 MediaWiki
13173 !! end
13174
13175 # This is T2089, which I fixed. -- wtm
13176 !! test
13177 pre-save transform: subst: templates with parameters
13178 !! options
13179 pst
13180 !! wikitext
13181 {{subst:paramtest|param="something else"}}
13182 !! html/php
13183 This is a test template with parameter "something else"
13184 !! end
13185
13186 !! article
13187 Template:nowikitest
13188 !! text
13189 <nowiki>'''not wiki'''</nowiki>
13190 !! endarticle
13191
13192 !! test
13193 pre-save transform: nowiki in subst (T3188)
13194 !! options
13195 pst
13196 !! wikitext
13197 {{subst:nowikitest}}
13198 !! html/php
13199 <nowiki>'''not wiki'''</nowiki>
13200 !! end
13201
13202 !! article
13203 Template:commenttest
13204 !! text
13205 This template has <!-- a comment --> in it.
13206 !! endarticle
13207
13208 !! test
13209 pre-save transform: comment in subst (T3936)
13210 !! options
13211 pst
13212 !! wikitext
13213 {{subst:commenttest}}
13214 !! html/php
13215 This template has <!-- a comment --> in it.
13216 !! end
13217
13218 !! test
13219 pre-save transform: unclosed tag
13220 !! options
13221 pst
13222 !! wikitext
13223 <nowiki>'''not wiki'''
13224 !! html/php
13225 <nowiki>'''not wiki'''
13226 !! end
13227
13228 !! test
13229 pre-save transform: mixed tag case
13230 !! options
13231 pst
13232 !! wikitext
13233 <NOwiki>'''not wiki'''</noWIKI>
13234 !! html/php
13235 <NOwiki>'''not wiki'''</noWIKI>
13236 !! end
13237
13238 !! test
13239 pre-save transform: unclosed comment in <nowiki>
13240 !! options
13241 pst
13242 !! wikitext
13243 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13244 !! html/php
13245 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13246 !!end
13247
13248 # Leading @ in this template definition works around a limitation
13249 # in parsoid's parserTests which otherwise strips the <span> from the
13250 # result (confusing it for a template wrapper)
13251 !! article
13252 Template:dangerous
13253 !!text
13254 @<span onmouseover="alert('crap')">Oh no</span>
13255 !!endarticle
13256
13257 !!test
13258 (confirming safety of fix for subst T3936)
13259 !! wikitext
13260 {{Template:dangerous}}
13261 !! html
13262 <p>@<span>Oh no</span>
13263 </p>
13264 !! end
13265
13266 !! test
13267 pre-save transform: comment containing gallery (T7024)
13268 !! options
13269 pst
13270 !! wikitext
13271 <!-- <gallery>data</gallery> -->
13272 !! html/php
13273 <!-- <gallery>data</gallery> -->
13274 !!end
13275
13276 !! test
13277 pre-save transform: comment containing extension
13278 !! options
13279 pst
13280 !! wikitext
13281 <!-- <tag>data</tag> -->
13282 !! html/php
13283 <!-- <tag>data</tag> -->
13284 !!end
13285
13286 !! test
13287 pre-save transform: comment containing nowiki
13288 !! options
13289 pst
13290 !! wikitext
13291 <!-- <nowiki>data</nowiki> -->
13292 !! html/php
13293 <!-- <nowiki>data</nowiki> -->
13294 !!end
13295
13296 !! test
13297 pre-save transform: <noinclude> in subst (T5298)
13298 !! options
13299 pst
13300 !! wikitext
13301 {{subst:Includes}}
13302 !! html/php
13303 Foobar
13304 !! end
13305
13306 !! test
13307 pre-save transform: <onlyinclude> in subst (T5298)
13308 !! options
13309 pst
13310 !! wikitext
13311 {{subst:Includes2}}
13312 !! html/php
13313 Foo
13314 !! end
13315
13316 !! article
13317 Template:SubstTest
13318 !!text
13319 {{<includeonly>subst:</includeonly>Includes}}
13320 !! endarticle
13321
13322 !! article
13323 Template:SafeSubstTest
13324 !! text
13325 {{<includeonly>safesubst:</includeonly>Includes}}
13326 !! endarticle
13327
13328 !! test
13329 T24297: safesubst: works during PST
13330 !! options
13331 pst
13332 !! wikitext
13333 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
13334 !! html/php
13335 FoobarFoobar
13336 !! end
13337
13338 !! test
13339 T24297: safesubst: works during normal parse
13340 !! wikitext
13341 {{SafeSubstTest}}
13342 !! html
13343 <p>Foobar
13344 </p>
13345 !! end
13346
13347 !! test
13348 subst: does not work during normal parse
13349 !! wikitext
13350 {{SubstTest}}
13351 !! html
13352 <p>{{subst:Includes}}
13353 </p>
13354 !! end
13355
13356 !! test
13357 pre-save transform: context links ("pipe trick")
13358 !! options
13359 pst
13360 !! wikitext
13361 [[Article (context)|]]
13362 [[Bar:Article|]]
13363 [[:Bar:Article|]]
13364 [[Bar:Article (context)|]]
13365 [[:Bar:Article (context)|]]
13366 [[|Article]]
13367 [[|Article (context)]]
13368 [[Bar:X (Y) Z|]]
13369 [[:Bar:X (Y) Z|]]
13370 !! html/php
13371 [[Article (context)|Article]]
13372 [[Bar:Article|Article]]
13373 [[:Bar:Article|Article]]
13374 [[Bar:Article (context)|Article]]
13375 [[:Bar:Article (context)|Article]]
13376 [[Article]]
13377 [[Article (context)]]
13378 [[Bar:X (Y) Z|X (Y) Z]]
13379 [[:Bar:X (Y) Z|X (Y) Z]]
13380 !! end
13381
13382 !! test
13383 pre-save transform: context links ("pipe trick") with interwiki prefix
13384 !! options
13385 pst
13386 !! wikitext
13387 [[interwiki:Article|]]
13388 [[:interwiki:Article|]]
13389 [[interwiki:Bar:Article|]]
13390 [[:interwiki:Bar:Article|]]
13391 !! html/php
13392 [[interwiki:Article|Article]]
13393 [[:interwiki:Article|Article]]
13394 [[interwiki:Bar:Article|Bar:Article]]
13395 [[:interwiki:Bar:Article|Bar:Article]]
13396 !! end
13397
13398 !! test
13399 pre-save transform: context links ("pipe trick") with parens in title
13400 !! options
13401 pst title=[[Somearticle (context)]]
13402 !! wikitext
13403 [[|Article]]
13404 !! html/php
13405 [[Article (context)|Article]]
13406 !! end
13407
13408 !! test
13409 pre-save transform: context links ("pipe trick") with comma in title
13410 !! options
13411 pst title=[[Someplace, Somewhere]]
13412 !! wikitext
13413 [[|Otherplace]]
13414 [[Otherplace, Elsewhere|]]
13415 [[Otherplace, Elsewhere, Anywhere|]]
13416 !! html/php
13417 [[Otherplace, Somewhere|Otherplace]]
13418 [[Otherplace, Elsewhere|Otherplace]]
13419 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
13420 !! end
13421
13422 !! test
13423 pre-save transform: context links ("pipe trick") with parens and comma
13424 !! options
13425 pst title=[[Someplace (IGNORED), Somewhere]]
13426 !! wikitext
13427 [[|Otherplace]]
13428 [[Otherplace (place), Elsewhere|]]
13429 !! html/php
13430 [[Otherplace, Somewhere|Otherplace]]
13431 [[Otherplace (place), Elsewhere|Otherplace]]
13432 !! end
13433
13434 !! test
13435 pre-save transform: context links ("pipe trick") with comma and parens
13436 !! options
13437 pst title=[[Who, me? (context)]]
13438 !! wikitext
13439 [[|Yes, you.]]
13440 [[Me, Myself, and I (1937 song)|]]
13441 !! html/php
13442 [[Yes, you. (context)|Yes, you.]]
13443 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
13444 !! end
13445
13446 !! test
13447 pre-save transform: context links ("pipe trick") with namespace
13448 !! options
13449 pst title=[[Ns:Somearticle]]
13450 !! wikitext
13451 [[|Article]]
13452 !! html/php
13453 [[Ns:Article|Article]]
13454 !! end
13455
13456 !! test
13457 pre-save transform: context links ("pipe trick") with namespace and parens
13458 !! options
13459 pst title=[[Ns:Somearticle (context)]]
13460 !! wikitext
13461 [[|Article]]
13462 !! html/php
13463 [[Ns:Article (context)|Article]]
13464 !! end
13465
13466 !! test
13467 pre-save transform: context links ("pipe trick") with namespace and comma
13468 !! options
13469 pst title=[[Ns:Somearticle, Context, Whatever]]
13470 !! wikitext
13471 [[|Article]]
13472 !! html/php
13473 [[Ns:Article, Context, Whatever|Article]]
13474 !! end
13475
13476 !! test
13477 pre-save transform: context links ("pipe trick") with namespace, comma and parens
13478 !! options
13479 pst title=[[Ns:Somearticle, Context (context)]]
13480 !! wikitext
13481 [[|Article]]
13482 !! html/php
13483 [[Ns:Article (context)|Article]]
13484 !! end
13485
13486 !! test
13487 pre-save transform: context links ("pipe trick") with namespace, parens and comma
13488 !! options
13489 pst title=[[Ns:Somearticle (IGNORED), Context]]
13490 !! wikitext
13491 [[|Article]]
13492 !! html/php
13493 [[Ns:Article, Context|Article]]
13494 !! end
13495
13496 !! test
13497 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
13498 !! options
13499 pst
13500 !! wikitext
13501 [[Article(context)|]]
13502 [[Bar:Article(context)|]]
13503 [[:Bar:Article(context)|]]
13504 [[|Article(context)]]
13505 [[Bar:X(Y)Z|]]
13506 [[:Bar:X(Y)Z|]]
13507 !! html/php
13508 [[Article(context)|Article]]
13509 [[Bar:Article(context)|Article]]
13510 [[:Bar:Article(context)|Article]]
13511 [[Article(context)]]
13512 [[Bar:X(Y)Z|X(Y)Z]]
13513 [[:Bar:X(Y)Z|X(Y)Z]]
13514 !! end
13515
13516 !! test
13517 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
13518 !! options
13519 pst
13520 !! wikitext
13521 [[Article (context)|]]
13522 [[Bar:Article (context)|]]
13523 [[:Bar:Article (context)|]]
13524 [[|Article (context)]]
13525 [[Bar:X (Y) Z|]]
13526 [[:Bar:X (Y) Z|]]
13527 !! html/php
13528 [[Article (context)|Article]]
13529 [[Bar:Article (context)|Article]]
13530 [[:Bar:Article (context)|Article]]
13531 [[Article (context)]]
13532 [[Bar:X (Y) Z|X (Y) Z]]
13533 [[:Bar:X (Y) Z|X (Y) Z]]
13534 !! end
13535
13536 !! test
13537 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
13538 !! options
13539 pst
13540 !! wikitext
13541 [[Article(context)|]]
13542 [[Bar:Article(context)|]]
13543 [[:Bar:Article(context)|]]
13544 [[|Article(context)]]
13545 [[Bar:X(Y)Z|]]
13546 [[:Bar:X(Y)Z|]]
13547 !! html/php
13548 [[Article(context)|Article]]
13549 [[Bar:Article(context)|Article]]
13550 [[:Bar:Article(context)|Article]]
13551 [[Article(context)]]
13552 [[Bar:X(Y)Z|X(Y)Z]]
13553 [[:Bar:X(Y)Z|X(Y)Z]]
13554 !! end
13555
13556 !! test
13557 pre-save transform: context links ("pipe trick") with commas (T23660)
13558 !! options
13559 pst
13560 !! wikitext
13561 [[Article (context), context|]]
13562 [[Article (context),context|]]
13563 [[Bar:Article (context), context|]]
13564 [[Bar:Article (context),context|]]
13565 [[:Bar:Article (context), context|]]
13566 [[:Bar:Article (context),context|]]
13567 !! html/php
13568 [[Article (context), context|Article]]
13569 [[Article (context),context|Article]]
13570 [[Bar:Article (context), context|Article]]
13571 [[Bar:Article (context),context|Article]]
13572 [[:Bar:Article (context), context|Article]]
13573 [[:Bar:Article (context),context|Article]]
13574 !! end
13575
13576 !! test
13577 Parsoid: backwards pipe trick
13578 !! wikitext
13579 [[|'''bar''']]
13580 !! html/php
13581 <p>[[|<b>bar</b>]]
13582 </p>
13583 !! html/parsoid
13584 <p>[[|<b>bar</b>]]</p>
13585 !! end
13586
13587 !! test
13588 pre-save transform: trim trailing empty lines
13589 !! options
13590 pst
13591 !! wikitext
13592 Empty lines are trimmed
13593
13594
13595
13596
13597 !! html/php
13598 Empty lines are trimmed
13599 !! end
13600
13601 !! test
13602 pre-save transform: Signature expansion
13603 !! options
13604 pst
13605 !! wikitext
13606 * ~~~
13607 * <noinclude>~~~</noinclude>
13608 * <includeonly>~~~</includeonly>
13609 * <onlyinclude>~~~</onlyinclude>
13610 !! html/php
13611 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
13612 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
13613 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
13614 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
13615 !! end
13616
13617
13618 !! test
13619 pre-save transform: Signature expansion in nowiki tags (T2093)
13620 !! options
13621 pst disabled
13622 !! wikitext
13623 Shall not expand:
13624
13625 <nowiki>~~~~</nowiki>
13626
13627 <includeonly><nowiki>~~~~</nowiki></includeonly>
13628
13629 <noinclude><nowiki>~~~~</nowiki></noinclude>
13630
13631 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13632
13633 {{subst:Foo}} shall be converted to FOO
13634
13635 As well as inside noinclude/onlyinclude
13636 <noinclude>{{subst:Foo}}</noinclude>
13637 <onlyinclude>{{subst:Foo}}</onlyinclude>
13638
13639 But not inside includeonly
13640 <includeonly>{{subst:Foo}}</includeonly>
13641 !! html/php
13642 Shall not expand:
13643
13644 <nowiki>~~~~</nowiki>
13645
13646 <includeonly><nowiki>~~~~</nowiki></includeonly>
13647
13648 <noinclude><nowiki>~~~~</nowiki></noinclude>
13649
13650 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13651
13652 FOO shall be converted to FOO
13653
13654 As well as inside noinclude/onlyinclude
13655 <noinclude>FOO</noinclude>
13656 <onlyinclude>FOO</onlyinclude>
13657
13658 But not inside includeonly
13659 <includeonly>{{subst:Foo}}</includeonly>
13660 !! end
13661
13662 !! test
13663 Parsoid: Recognize nowiki with trailing space in tags
13664 !! options
13665 parsoid=wt2html
13666 !! wikitext
13667 <nowiki ><div>[[foo]]</nowiki >
13668
13669 a<nowiki / >b
13670
13671 c<nowiki />d
13672
13673 e<nowiki/ >f
13674 !! html
13675 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
13676 <p>ab</p>
13677 <p>cd</p>
13678 <p>ef</p>
13679 !! end
13680
13681 !! test
13682 Parsoid: Recognize nowiki with odd capitalization
13683 !! options
13684 parsoid=wt2html
13685 !! wikitext
13686 <noWikI ><div>[[foo]]</Nowiki >
13687 !! html
13688 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
13689 !! end
13690
13691
13692 !! test
13693 Parsoid: Escape nowiki with trailing space in tags
13694 !! options
13695 parsoid=html2wt
13696 !! html/parsoid
13697 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
13698 <p>a&lt;nowiki /&gt;b</p>
13699 <p>c&lt;nowiki/ &gt;d</p>
13700 !! wikitext
13701 &lt;nowiki &gt; foo &lt;/nowiki &gt;
13702
13703 a&lt;nowiki /&gt;b
13704
13705 c&lt;nowiki/ &gt;d
13706 !! end
13707
13708 !! test
13709 Parsoid: Escape weird noWikI capitalizations
13710 !! options
13711 parsoid=html2wt
13712 !! html/parsoid
13713 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
13714 !! wikitext
13715 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
13716 !! end
13717
13718 ###
13719 ### Message transform tests
13720 ###
13721 !! test
13722 message transform: magic variables
13723 !! options
13724 msg
13725 !! wikitext
13726 {{SITENAME}}
13727 !! html
13728 MediaWiki
13729 !! end
13730
13731 !! test
13732 message transform: should not transform wiki markup
13733 !! options
13734 msg
13735 !! wikitext
13736 ''test''
13737 !! html
13738 ''test''
13739 !! end
13740
13741 !! test
13742 message transform: <noinclude> in transcluded template (T6926)
13743 !! options
13744 msg
13745 !! wikitext
13746 {{Includes}}
13747 !! html
13748 Foobar
13749 !! end
13750
13751 !! test
13752 message transform: <onlyinclude> in transcluded template (T6926)
13753 !! options
13754 msg
13755 !! wikitext
13756 {{Includes2}}
13757 !! html
13758 Foo
13759 !! end
13760
13761 !! test
13762 {{#special:}} page name, known
13763 !! options
13764 msg
13765 !! wikitext
13766 {{#special:Recentchanges}}
13767 !! html
13768 Special:RecentChanges
13769 !! end
13770
13771 !! test
13772 {{#special:}} page name with subpage, known
13773 !! options
13774 msg
13775 !! wikitext
13776 {{#special:Recentchanges/param}}
13777 !! html
13778 Special:RecentChanges/param
13779 !! end
13780
13781 !! test
13782 {{#special:}} page name, unknown
13783 !! options
13784 msg
13785 !! wikitext
13786 {{#special:foobar nonexistent}}
13787 !! html
13788 Special:Foobar nonexistent
13789 !! end
13790
13791 !! test
13792 {{#speciale:}} page name, known
13793 !! options
13794 msg
13795 !! wikitext
13796 {{#speciale:Recentchanges}}
13797 !! html
13798 Special:RecentChanges
13799 !! end
13800
13801 !! test
13802 {{#speciale:}} page name with subpage, known
13803 !! options
13804 msg
13805 !! wikitext
13806 {{#speciale:Recentchanges/param}}
13807 !! html
13808 Special:RecentChanges/param
13809 !! end
13810
13811 !! test
13812 {{#speciale:}} page name, unknown
13813 !! options
13814 msg
13815 !! wikitext
13816 {{#speciale:foobar nonexistent}}
13817 !! html
13818 Special:Foobar_nonexistent
13819 !! end
13820
13821 ###
13822 ### Images
13823 ###
13824 ### For Parsoid-specific tests, see
13825 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
13826
13827 !! test
13828 Simple image
13829 !! options
13830 parsoid=wt2html,wt2wt,html2html
13831 !! wikitext
13832 [[Image:foobar.jpg]]
13833 !! html/php
13834 <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>
13835 </p>
13836 !! html/parsoid
13837 <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>
13838 !! end
13839
13840 !! test
13841 Simple image (using File: namespace, now canonical)
13842 !! wikitext
13843 [[File:Foobar.jpg]]
13844 !! html/php
13845 <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>
13846 </p>
13847 !! html/parsoid
13848 <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>
13849 !! end
13850
13851 !! test
13852 Right-aligned image
13853 !! wikitext
13854 [[File:Foobar.jpg|right]]
13855 !! html/php
13856 <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>
13857
13858 !! html/parsoid
13859 <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>
13860 !! end
13861
13862 !! test
13863 Image with caption
13864 !! wikitext
13865 [[File:Foobar.jpg|right|Caption text]]
13866 !! html/php
13867 <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>
13868
13869 !! html/parsoid
13870 <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>
13871 !! end
13872
13873 !! test
13874 Image with caption, T55312 #1
13875 !! wikitext
13876 [[File:Foobar.jpg|right|Caption page stuff]]
13877 !! html/php
13878 <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>
13879
13880 !! html/parsoid
13881 <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>
13882 !! end
13883
13884 !! test
13885 Image with caption, T55312 #2
13886 !! wikitext
13887 [[File:Foobar.jpg|right|Caption page=]]
13888 !! html/php
13889 <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>
13890
13891 !! html/parsoid
13892 <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>
13893 !! end
13894
13895 !! test
13896 Image with caption, T55312 #3
13897 !! wikitext
13898 [[File:Foobar.jpg|right|Caption page=stuff]]
13899 !! html/php
13900 <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>
13901
13902 !! html/parsoid
13903 <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>
13904 !! end
13905
13906 !! test
13907 Allow empty links in image captions (T62753)
13908 !! options
13909 thumbsize=220
13910 !! wikitext
13911 [[File:Foobar.jpg|thumb|Caption [[Link1]]
13912 [[]]
13913 [[Link2]]
13914 ]]
13915 !! html/php
13916 <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>
13917
13918 !! html/parsoid
13919 <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>
13920 [[]]
13921 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
13922 </figcaption></figure>
13923 !! end
13924
13925 !! test
13926 Titles in unlinked images (T23454)
13927 !! wikitext
13928 [[File:Foobar.jpg|link=|stuff]]
13929 !! html/php
13930 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
13931 </p>
13932 !! end
13933
13934 !! test
13935 Link with empty target
13936 !! wikitext
13937 [[]]
13938 !! html
13939 <p>[[]]
13940 </p>
13941 !! end
13942
13943 !! test
13944 Image with link trail
13945 !! wikitext
13946 Linktrails should not work for images: [[File:Foobar.jpg]]s
13947 !! html/php
13948 <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
13949 </p>
13950 !! html/parsoid
13951 <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>
13952 !! end
13953
13954 !! test
13955 Image with empty attribute
13956 !! options
13957 parsoid=wt2html,wt2wt,html2html
13958 !! wikitext
13959 [[File:Foobar.jpg|right||Caption text]]
13960 !! html/php
13961 <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>
13962
13963 !! html/parsoid
13964 <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>
13965 !! end
13966
13967 !! test
13968 1. Block image with individual attributes from templates
13969 !! wikitext
13970 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
13971 !! html/php
13972 <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>
13973
13974 !! html/parsoid
13975 <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>
13976 !! end
13977
13978 !! test
13979 2. Block Image with individual attributes from templates
13980 !! wikitext
13981 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
13982 !! html/php
13983 <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>
13984
13985 !! html/parsoid
13986 <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>
13987 !! end
13988
13989 !! test
13990 3. Inline image with individual attributes from templates
13991 !! wikitext
13992 [[File:Foobar.jpg|{{echo|50px}}]]
13993 !! html/php
13994 <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>
13995 </p>
13996 !! html/parsoid
13997 <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>
13998 !! end
13999
14000 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14001 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14002 !! test
14003 Image with multiple attributes from the same template
14004 !! wikitext
14005 [[File:Foobar.jpg|{{image_attribs}}]]
14006 !! html/php
14007 <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>
14008
14009 !! html/parsoid
14010 <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>
14011 !! end
14012
14013 !! test
14014 Image with link tails
14015 !! options
14016 thumbsize=220
14017 !! wikitext
14018 123[[File:Foobar.jpg]]456
14019 123[[File:Foobar.jpg|right]]456
14020 123[[File:Foobar.jpg|thumb]]456
14021 !! html/php
14022 <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
14023 </p>
14024 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
14025 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
14026
14027 !! html/php+tidy
14028 <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>
14029 <p>123</p>
14030 <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>
14031 <p>456 123</p>
14032 <div class="thumb tright">
14033 <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>
14034 <div class="thumbcaption">
14035 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
14036 </div>
14037 </div>
14038 </div>
14039 <p>456</p>
14040 !! html/parsoid
14041 <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>
14042 <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>
14043 <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>
14044 !! end
14045
14046 !! test
14047 Image with multiple captions -- only last one is accepted
14048 !! wikitext
14049 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14050 !! html/php
14051 <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>
14052
14053 !! html/parsoid
14054 <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>
14055 !! end
14056
14057 !! test
14058 Image with multiple widths -- use last
14059 !! wikitext
14060 [[File:Foobar.jpg|200px|300px|caption]]
14061 !! html/php
14062 <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>
14063 </p>
14064 !! html/parsoid
14065 <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>
14066 !! end
14067
14068 !! test
14069 Image with multiple alignments -- use first (T50664)
14070 !! options
14071 thumbsize=220
14072 !! wikitext
14073 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14074
14075 [[File:Foobar.jpg|middle|text-top|caption]]
14076 !! html/php
14077 <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>
14078 <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>
14079 </p>
14080 !! html/parsoid
14081 <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>
14082 <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>
14083 !! end
14084
14085 !! test
14086 Image with width attribute at different positions
14087 !! wikitext
14088 [[File:Foobar.jpg|200px|right|Caption]]
14089 [[File:Foobar.jpg|right|200px|Caption]]
14090 [[File:Foobar.jpg|right|Caption|200px]]
14091 !! html/php
14092 <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>
14093 <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>
14094 <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>
14095
14096 !! html/parsoid
14097 <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>
14098 <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>
14099 <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>
14100 !! end
14101
14102 # a sad bit of backward-compatibility
14103 !! test
14104 Image with size specified with pxpx (T15500, T53628)
14105 !! options
14106 parsoid=wt2html,wt2wt,html2html
14107 !! wikitext
14108 [[File:Foobar.jpg|20pxpx]]
14109 [[File:Foobar.jpg|200x20pxpx]]
14110 !! html/php
14111 <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>
14112 <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>
14113 </p>
14114 !! html/parsoid
14115 <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>
14116 !! end
14117
14118 !! test
14119 Image with link parameter, wiki target
14120 !! wikitext
14121 [[File:Foobar.jpg|link=Main Page]]
14122 !! html/php
14123 <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>
14124 </p>
14125 !! html/parsoid
14126 <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>
14127 !! end
14128
14129 # parsoid T51293 (part 1)
14130 !! test
14131 Image with link parameter, URL target
14132 !! wikitext
14133 [[File:Foobar.jpg|link=http://example.com/]]
14134 !! html/php
14135 <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>
14136 </p>
14137 !! html/parsoid
14138 <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>
14139 !! end
14140
14141 # parsoid T51293 (part 2)
14142 !! test
14143 Image with link parameter, protocol-less URL target
14144 !! wikitext
14145 [[File:Foobar.jpg|link=//example.com/]]
14146 !! html/php
14147 <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>
14148 </p>
14149 !! html/parsoid
14150 <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>
14151 !! end
14152
14153 !! test
14154 Escaping non-block captions (T107435)
14155 !! options
14156 parsoid={
14157 "modes": ["wt2wt"],
14158 "changes": [
14159 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14160 ]
14161 }
14162 !! wikitext
14163 [[Image:Foobar.jpg|caption]]
14164 !! wikitext/edited
14165 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14166 !! end
14167
14168 # wgExternalLinkTarget not supported by Parsoid
14169 !! test
14170 Image with link parameter, wgExternalLinkTarget
14171 !! wikitext
14172 [[Image:foobar.jpg|link=http://example.com/]]
14173 !! config
14174 wgExternalLinkTarget='foobar'
14175 !! html/php
14176 <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>
14177 </p>
14178 !! end
14179
14180 !! test
14181 Image with link parameter, wgNoFollowLinks set to false
14182 !! wikitext
14183 [[Image:foobar.jpg|link=http://example.com/]]
14184 !! config
14185 wgNoFollowLinks=false
14186 !! html
14187 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14188 </p>
14189 !! end
14190
14191 !! test
14192 Image with link parameter, wgNoFollowDomainExceptions
14193 !! wikitext
14194 [[Image:foobar.jpg|link=http://example.com/]]
14195 !! config
14196 wgNoFollowDomainExceptions='example.com'
14197 !! html
14198 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14199 </p>
14200 !! end
14201
14202 # wgExternalLinkTarget not supported by Parsoid
14203 !! test
14204 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14205 !! wikitext
14206 [[Image:foobar.jpg|link=http://example.com/|Title]]
14207 !! config
14208 wgExternalLinkTarget='foobar'
14209 !! html/php
14210 <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>
14211 </p>
14212 !! end
14213
14214 !! test
14215 Image with empty link parameter
14216 !! wikitext
14217 [[File:Foobar.jpg|link=]]
14218 !! html/php
14219 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14220 </p>
14221 !! html/parsoid
14222 <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>
14223 !! end
14224
14225 !! test
14226 Image with link parameter (wiki target) and unnamed parameter
14227 !! wikitext
14228 [[File:Foobar.jpg|link=Main_Page|Title]]
14229 !! html/php
14230 <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>
14231 </p>
14232 !! html/parsoid
14233 <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>
14234 !! end
14235
14236 !! test
14237 Image with link parameter (URL target) and unnamed parameter
14238 !! wikitext
14239 [[File:Foobar.jpg|link=http://example.com/|Title]]
14240 !! html/php
14241 <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>
14242 </p>
14243 !! html/parsoid
14244 <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>
14245 !! end
14246
14247 !! test
14248 Thumbnail image with link parameter
14249 !! options
14250 thumbsize=220
14251 parsoid=wt2html,wt2wt,html2html
14252 !! wikitext
14253 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14254 !! html/php
14255 <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>
14256
14257 !! html/parsoid
14258 <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>
14259 !! end
14260
14261 !! test
14262 Manually-specified thumbnail image
14263 !! options
14264 thumbsize=220
14265 !! wikitext
14266 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14267 !! html/php
14268 <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>
14269
14270 !! html/parsoid
14271 <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>
14272 !! end
14273
14274 !! test
14275 Manually-specified thumbnail image with explicit link to wiki page
14276 !! options
14277 thumbsize=220
14278 parsoid=wt2html,wt2wt,html2html
14279 !! wikitext
14280 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14281 !! html/php
14282 <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>
14283
14284 !! html/parsoid
14285 <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>
14286 !! end
14287
14288 !! test
14289 Manually-specified thumbnail image with explicit link to url
14290 !! options
14291 thumbsize=220
14292 parsoid=wt2html,wt2wt,html2html
14293 !! wikitext
14294 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14295 !! html/php
14296 <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>
14297
14298 !! html/parsoid
14299 <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>
14300 !! end
14301
14302 !! test
14303 Manually-specified thumbnail image with explicit no link
14304 !! options
14305 thumbsize=220
14306 parsoid=wt2html,wt2wt,html2html
14307 !! wikitext
14308 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14309 !! html/php
14310 <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>
14311
14312 !! html/parsoid
14313 <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>
14314 !! end
14315
14316 !! test
14317 Manually-specified thumbnail image with explicit link and alt text
14318 !! options
14319 thumbsize=220
14320 parsoid=wt2html,wt2wt,html2html
14321 !! wikitext
14322 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14323 !! html/php
14324 <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>
14325
14326 !! html/parsoid
14327 <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>
14328 !! end
14329
14330 !! test
14331 Image with frame and link
14332 !! options
14333 parsoid=wt2html,wt2wt,html2html
14334 !! wikitext
14335 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14336 !! html/php
14337 <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>
14338
14339 !! html/parsoid
14340 <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>
14341 !! end
14342
14343 !! test
14344 Image with frame and link and explicit alt
14345 !! options
14346 parsoid=wt2html,wt2wt,html2html
14347 !! wikitext
14348 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
14349 !! html/php
14350 <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>
14351
14352 !! html/parsoid
14353 <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>
14354 !! end
14355
14356 !! test
14357 Image with wiki markup in implicit alt
14358 !! wikitext
14359 [[Image:Foobar.jpg|testing '''bold''' in alt]]
14360
14361 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
14362 !! html/php
14363 <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>
14364 </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>
14365 </p>
14366 !! html/parsoid
14367 <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>
14368
14369 <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>
14370 !! end
14371
14372 !! test
14373 Alt image option should handle most kinds of wikitext without barfing
14374 !! wikitext
14375 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
14376 !! html/php
14377 <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>
14378
14379 !! html/parsoid
14380 <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|&#39;&#39;bold template&#39;&#39;}}."}]}' data-mw='{"attribs":[["thumbnail",{"html":"thumb"}],["alt",{"html":"alt=This is a &lt;a rel=\"mw:WikiLink\" href=\"./Link\" title=\"Link\" data-parsoid=&#39;{\"stx\":\"simple\",\"a\":{\"href\":\"./Link\"},\"sa\":{\"href\":\"link\"},\"dsr\":[65,73,2,2]}&#39;>link&lt;/a> and a &lt;i about=\"#mwt1\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"dsr\":[80,106,null,null],\"pi\":[[{\"k\":\"1\"}]]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"echo\",\"href\":\"./Template:Echo\"},\"params\":{\"1\":{\"wt\":\"&amp;#39;&amp;#39;bold template&amp;#39;&amp;#39;\"}},\"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>
14381 !! end
14382
14383 ###################
14384 # Conflicting image format options.
14385 # First option specified should 'win'.
14386 # All three cases in each test should be identical.
14387
14388 !! test
14389 Image with 'frameless' first.
14390 !! options
14391 parsoid=wt2html,wt2wt,html2html
14392 !! wikitext
14393 [[File:Foobar.jpg|frameless|caption]]
14394
14395 [[File:Foobar.jpg|frameless|frame|caption]]
14396
14397 [[File:Foobar.jpg|frameless|thumb|caption]]
14398 !! html/php
14399 <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>
14400 </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>
14401 </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>
14402 </p>
14403 !! html/parsoid
14404 <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>
14405 <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>
14406 <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>
14407 !! end
14408
14409 !! test
14410 Image with 'frame' first.
14411 !! options
14412 parsoid=wt2html,wt2wt,html2html
14413 !! wikitext
14414 [[File:Foobar.jpg|frame|caption]]
14415 [[File:Foobar.jpg|frame|frameless|caption]]
14416 [[File:Foobar.jpg|frame|thumb|caption]]
14417 !! html/php
14418 <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>
14419 <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>
14420 <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>
14421
14422 !! html/parsoid
14423 <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>
14424 <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>
14425 <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>
14426 !! end
14427
14428 !! test
14429 Image with 'thumb' first.
14430 !! options
14431 parsoid=wt2html,wt2wt,html2html
14432 !! wikitext
14433 [[File:Foobar.jpg|thumb|caption]]
14434 [[File:Foobar.jpg|thumb|frameless|caption]]
14435 [[File:Foobar.jpg|thumb|frame|caption]]
14436 !! html/php
14437 <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>
14438 <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>
14439 <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>
14440
14441 !! html/parsoid
14442 <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>
14443 <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>
14444 <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>
14445 !! end
14446
14447 ###################
14448 # Image sizing.
14449 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
14450 # and https://phabricator.wikimedia.org/T64258
14451 # Foobar has actual size of 1941x220
14452 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
14453 # a scalable format.
14454 # 2. Framed images always ignore size options; always render at default size.
14455 # 3. "Unspecified format" and border are the only types which can be
14456 # enlarged.
14457
14458 !! test
14459 Image: "unspecified format" and border enlarge
14460 !! options
14461 parsoid=wt2html,wt2wt,html2html
14462 !! wikitext
14463 [[File:Foobar.jpg|2000px]]
14464
14465 [[File:Foobar.jpg|border|2000px]]
14466 !! html/php
14467 <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>
14468 </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>
14469 </p>
14470 !! html/parsoid
14471 <p><span typeof="mw:Image"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/1941px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="227" width="2000"/></a></span></p>
14472 <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/1941px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="227" width="2000"/></a></span></p>
14473 !! end
14474
14475 !! test
14476 Image: "unspecified format" and border reduce
14477 !! options
14478 parsoid=wt2html,wt2wt,html2html
14479 !! wikitext
14480 [[File:Foobar.jpg|1000px]]
14481
14482 [[File:Foobar.jpg|border|1000px]]
14483 !! html/php
14484 <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>
14485 </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>
14486 </p>
14487 !! html/parsoid
14488 <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>
14489 <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>
14490 !! end
14491
14492 !! test
14493 Image: thumbs reduce
14494 !! options
14495 parsoid=wt2html,wt2wt,html2html
14496 !! wikitext
14497 [[File:Foobar.jpg|thumb|50px]]
14498 !! html/php
14499 <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>
14500
14501 !! html/parsoid
14502 <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>
14503 !! end
14504
14505 !! test
14506 Image: bitmap thumbs can't be enlarged past original size, but vector can.
14507 !! options
14508 parsoid=wt2html,wt2wt,html2html
14509 !! wikitext
14510 [[File:Foobar.jpg|thumb|2000px]]
14511
14512 [[File:Foobar.svg|thumb|2000px]]
14513 !! html/php
14514 <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>
14515 <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>
14516
14517 !! html/parsoid
14518 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/1941px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></figure>
14519 <figure typeof="mw:Image/Thumb"><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/thumb/f/ff/Foobar.svg/240px-Foobar.svg" data-file-width="240" data-file-height="180" data-file-type="drawing" height="1500" width="2000"/></a></figure>
14520 !! end
14521
14522 !! test
14523 Image: frameless can reduce in size
14524 !! options
14525 parsoid=wt2html,wt2wt,html2html
14526 !! wikitext
14527 [[File:Foobar.jpg|frameless|50px]]
14528 !! html/php
14529 <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>
14530 </p>
14531 !! html/parsoid
14532 <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>
14533 !! end
14534
14535 !! test
14536 Image: bitmap frameless can't be enlarged past original size, but vector can
14537 !! options
14538 parsoid=wt2html,wt2wt,html2html
14539 !! wikitext
14540 [[File:Foobar.jpg|frameless|2000px]]
14541
14542 [[File:Foobar.svg|frameless|2000px]]
14543 !! html/php
14544 <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>
14545 </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>
14546 </p>
14547 !! html/parsoid
14548 <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/1941px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941"/></a></span></p>
14549 <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/240px-Foobar.svg" data-file-width="240" data-file-height="180" data-file-type="drawing" height="1500" width="2000"/></a></span></p>
14550 !! end
14551
14552 !! test
14553 Image: framed images are always unscaled.
14554 !! options
14555 parsoid=wt2html,wt2wt,html2html
14556 !! wikitext
14557 [[File:Foobar.jpg|frame]]
14558
14559 [[File:Foobar.jpg|frame|50px]]
14560
14561 [[File:Foobar.jpg|frame|50x50px]]
14562
14563 [[File:Foobar.jpg|frame|2000px]]
14564 !! html/php
14565 <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>
14566 <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>
14567 <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>
14568 <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>
14569
14570 !! html/parsoid
14571 <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>
14572 <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>
14573 <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>
14574 <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>
14575 !! end
14576
14577 ###################
14578
14579 !! test
14580 Link to image page- image page normally doesn't exists, hence edit link
14581 Add test with existing image page
14582 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
14583 !! wikitext
14584 [[:Image:test]]
14585 !! html
14586 <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>
14587 </p>
14588 !! end
14589
14590 !! test
14591 T20784 Link to non-existent image page with caption should use caption as link text
14592 !! wikitext
14593 [[:Image:test|caption]]
14594 !! html
14595 <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>
14596 </p>
14597 !! end
14598
14599 !! test
14600 Frameless image caption with a free URL
14601 !! wikitext
14602 [[File:Foobar.jpg|http://example.com]]
14603 !! html/php
14604 <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>
14605 </p>
14606 !! html/parsoid
14607 <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>
14608 !! end
14609
14610 !! test
14611 Thumbnail image caption with a free URL
14612 !! options
14613 thumbsize=220
14614 !! wikitext
14615 [[File:Foobar.jpg|thumb|http://example.com]]
14616 !! html/php
14617 <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>
14618
14619 !! html/parsoid
14620 <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>
14621 !! end
14622
14623 !! test
14624 Thumbnail image caption with a free URL and explicit alt
14625 !! options
14626 thumbsize=220
14627 parsoid=wt2html,wt2wt,html2html
14628 !! wikitext
14629 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
14630 !! html/php
14631 <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>
14632
14633 !! html/parsoid
14634 <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>
14635 !! end
14636
14637 !! test
14638 SVG thumbnails with no language set
14639 !! options
14640 !! wikitext
14641 [[File:Foobar.svg|thumb|caption]]
14642 !! html/php
14643 <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>
14644
14645 !! html/parsoid
14646 <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" data-file-width="240" data-file-height="180" data-file-type="drawing" height="165" width="220"/></a><figcaption>caption</figcaption></figure>
14647 !! end
14648
14649 !! test
14650 SVG thumbnails with language de
14651 !! options
14652 parsoid=wt2html,wt2wt,html2html
14653 !! wikitext
14654 [[File:Foobar.svg|thumb|caption|lang=de]]
14655 !! html/php
14656 <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>
14657
14658 !! html/parsoid
14659 <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" lang="de" data-file-width="240" data-file-height="180" data-file-type="drawing" height="165" width="220"/></a><figcaption>caption</figcaption></figure>
14660 !! end
14661
14662 !! test
14663 SVG thumbnails with invalid language code
14664 !! options
14665 parsoid=wt2html,wt2wt,html2html
14666 !! wikitext
14667 [[File:Foobar.svg|thumb|caption|lang=invalid.language.code]]
14668 !! html/php
14669 <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>
14670
14671 !! html/parsoid
14672 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.svg"><img resource="./File:Foobar.svg" src="//example.com/images/f/ff/Foobar.svg" data-file-width="240" data-file-height="180" data-file-type="drawing" height="165" width="220"/></a><figcaption>lang=invalid.language.code</figcaption></figure>
14673 !! end
14674
14675 !! test
14676 T3887: A ISBN with a thumbnail
14677 !! wikitext
14678 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
14679 !! html/php
14680 <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>
14681
14682 !! html/parsoid
14683 <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>
14684 !! end
14685
14686 !! test
14687 T3887: A RFC with a thumbnail
14688 !! wikitext
14689 [[File:Foobar.jpg|thumb|This is RFC 12354]]
14690 !! html/php
14691 <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="//tools.ietf.org/html/rfc12354">RFC 12354</a></div></div></div>
14692
14693 !! html/parsoid
14694 <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="//tools.ietf.org/html/rfc12354" rel="mw:ExtLink">RFC 12354</a></figcaption></figure>
14695 !! end
14696
14697 !! test
14698 T3887: A mailto link with a thumbnail
14699 !! wikitext
14700 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
14701 !! html/php
14702 <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>
14703
14704 !! html/parsoid
14705 <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>
14706 !! end
14707
14708 # Pending resolution to T2368
14709 !! test
14710 T2648: Frameless image caption with a link
14711 !! wikitext
14712 [[File:Foobar.jpg|text with a [[link]] in it]]
14713 !! html/php
14714 <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>
14715 </p>
14716 !! html/parsoid
14717 <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>
14718 !! end
14719
14720 !! test
14721 T2648: Frameless image caption with a link (suffix)
14722 !! wikitext
14723 [[File:Foobar.jpg|text with a [[link]]foo in it]]
14724 !! html/php
14725 <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>
14726 </p>
14727 !! html/parsoid
14728 <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>
14729 !! end
14730
14731 !! test
14732 T2648: Frameless image caption with an interwiki link
14733 !! wikitext
14734 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
14735 !! html/php
14736 <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>
14737 </p>
14738 !! html/parsoid
14739 <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>
14740 !! end
14741
14742 !! test
14743 T2648: Frameless image caption with a piped interwiki link
14744 !! wikitext
14745 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
14746 !! html/php
14747 <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>
14748 </p>
14749 !! html/parsoid
14750 <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>
14751 !! end
14752
14753 !! test
14754 T107474: Frameless image caption with <nowiki>
14755 !! wikitext
14756 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
14757 !! html/parsoid
14758 <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>
14759 !! end
14760
14761 !! test
14762 Escape HTML special chars in image alt text
14763 !! wikitext
14764 [[File:Foobar.jpg|& < > "]]
14765 !! html/php
14766 <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>
14767 </p>
14768 !! html/parsoid
14769 <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>
14770 !! end
14771
14772 !! test
14773 Escape HTML special chars in image alt text with LanguageConverter
14774 !! options
14775 language=zh
14776 !! wikitext
14777 [[File:Foobar.jpg|& < > "]]
14778 !! html/php
14779 <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>
14780 </p>
14781 !! html/parsoid
14782 <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>
14783 !! end
14784
14785 !! test
14786 Entities in file name and attributes
14787 !! wikitext
14788 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
14789 !! html/php
14790 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
14791 </p>
14792 !! html/parsoid
14793 <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>
14794 !! end
14795
14796 !! test
14797 T2499: Alt text should have &#1234;, not &amp;1234;
14798 !! wikitext
14799 [[File:Foobar.jpg|&#9792;]]
14800 !! html/php
14801 <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>
14802 </p>
14803 !! html/parsoid
14804 <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>
14805 !! end
14806
14807 !! test
14808 Broken image caption with link
14809 !! options
14810 parsoid=wt2html,wt2wt,html2html
14811 !! wikitext
14812 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
14813 !! html/php
14814 <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.
14815 </p>
14816 !! html/parsoid
14817 <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>
14818 !! end
14819
14820 !! test
14821 Image caption containing another image
14822 !! wikitext
14823 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
14824 !! html/php
14825 <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>
14826
14827 !! html/parsoid
14828 <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>
14829 !! end
14830
14831 !! test
14832 Image: caption containing a newline
14833 !! wikitext
14834 [[File:Foobar.jpg|This
14835 *is some text]]
14836 !! html/php
14837 <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>
14838 </p>
14839 !! html/parsoid
14840 <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>
14841 !!end
14842
14843 !!test
14844 Image: caption containing leading space
14845 (The leading space should not trigger nowiki escaping in wt2wt mode)
14846 !! wikitext
14847 [[File:Foobar.jpg|thumb| bar]]
14848 !! html/php
14849 <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>
14850
14851 !! html/parsoid
14852 <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>
14853 !!end
14854
14855 !! test
14856 Image: caption containing a table
14857 !! options
14858 parsoid=wt2html,wt2wt,html2html
14859 !! wikitext
14860 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
14861 {|
14862 ! Foo !! Bar
14863 |-
14864 | Foo1 || Bar1
14865 |}
14866 and some more text.]]
14867 !! html/php
14868 <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>
14869
14870 !! html/parsoid
14871 <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
14872 <table>
14873 <tbody>
14874 <tr><th>Foo </th><th>Bar</th></tr>
14875 <tr>
14876 <td>Foo1 </td>
14877 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
14878 !! end
14879
14880 !! test
14881 T5090: External links other than http: in image captions
14882 !! wikitext
14883 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
14884 !! html/php
14885 <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>
14886
14887 !! html/parsoid
14888 <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>
14889 !! end
14890
14891 !! test
14892 Custom class
14893 !! options
14894 parsoid=wt2html,wt2wt,html2html
14895 !! wikitext
14896 [[Image:foobar.jpg|a|class=b]]
14897 !! html/php
14898 <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>
14899 </p>
14900 !! html/parsoid
14901 <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>
14902 !! end
14903
14904 !! test
14905 Localized image handling (1).
14906 !! options
14907 parsoid=wt2html,wt2wt,html2html
14908 language=es
14909 !! wikitext
14910 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
14911 !! html/php
14912 <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>
14913
14914 !! html/parsoid
14915 <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>
14916 !! end
14917
14918 !! test
14919 Localized image handling (2).
14920 !! options
14921 thumbsize=220
14922 parsoid=wt2html,wt2wt,html2html
14923 language=es
14924 !! wikitext
14925 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
14926 !! html/php
14927 <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>
14928
14929 !! html/parsoid
14930 <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>
14931 !! end
14932
14933 !! test
14934 Localized image handling (3).
14935 !! options
14936 language=fa
14937 parsoid=html2wt
14938 !! html/parsoid
14939 <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>
14940 !! wikitext
14941 [[File:Foobar.jpg|بندانگشتی]]
14942 !! end
14943
14944 !! test
14945 "border", "frameless" and "class" attributes on an image.
14946 !! options
14947 thumbsize=220
14948 parsoid=wt2html,wt2wt,html2html
14949 !! wikitext
14950 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
14951 !! html/php
14952 <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>
14953 </p>
14954 !! html/parsoid
14955 <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>
14956 !! end
14957
14958 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
14959 !! test
14960 Invalid image attributes (T64500)
14961 !! options
14962 thumbsize=220
14963 parsoid=wt2html,wt2wt,html2html
14964 !! wikitext
14965 [[File:Foobar.jpg|thumb|float|left|caption]]
14966
14967 [[File:Foobar.jpg|thumb|righ|caption]]
14968
14969 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
14970 !! html/php
14971 <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>
14972 <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>
14973 <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>
14974
14975 !! html/parsoid
14976 <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>
14977 <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>
14978 <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>
14979 !! end
14980
14981 !! article
14982 File:Barfoo.jpg
14983 !! text
14984 #REDIRECT [[File:Barfoo.jpg]]
14985 !! endarticle
14986
14987 # FIXME: Parsoid should run this test -- but we'd need to teach the
14988 # mockAPI about the redirected Barfoo.jpg image.
14989 !! test
14990 Redirected image
14991 !! wikitext
14992 [[Image:Barfoo.jpg]]
14993 !! html/php
14994 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
14995 </p>
14996 !! end
14997
14998 !! test
14999 Missing image with uploads disabled
15000 !! options
15001 wgEnableUploads=0
15002 !! wikitext
15003 [[File:Foobaz.jpg]]
15004 !! html/php
15005 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
15006 </p>
15007 !! html/parsoid
15008 <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>
15009 !! end
15010
15011 # Parsoid-specific testing for images
15012 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
15013 # Currently imperfect due to a flaw in the Parsoid testrunner
15014 # Work in progress
15015 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
15016 # image tests.
15017
15018 !! test
15019 Parsoid-specific image handling - simple image with size and middle alignment
15020 !! wikitext
15021 [[File:Foobar.jpg|middle|50px]]
15022 !! html/parsoid
15023 <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>
15024 !! end
15025
15026 !! test
15027 Parsoid-specific image handling - simple image with size, middle alignment,
15028 non-standard namespace alias
15029 !! options
15030 parsoid=wt2wt,wt2html,html2html
15031 !! wikitext
15032 [[Image:Foobar.jpg|middle|50px]]
15033 !! html/parsoid
15034 <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>
15035 !! end
15036
15037 !! test
15038 Parsoid-specific image handling - simple image with size and middle alignment
15039 (existing content)
15040 !! wikitext
15041 [[File:Foobar.jpg|50px|middle]]
15042 !! html/parsoid
15043 <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>
15044 !! end
15045
15046 !! test
15047 Parsoid-specific image handling - simple image with size and middle alignment
15048 and non-standard namespace name
15049 !! options
15050 parsoid=wt2html,wt2wt,html2html
15051 !! wikitext
15052 [[Image:Foobar.jpg|50px|middle]]
15053 !! html/parsoid
15054 <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>
15055 !! end
15056
15057 !! test
15058 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
15059 !! wikitext
15060 [[File:Foobar.jpg|500x10px|baseline|caption]]
15061 !! html/parsoid
15062 <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>
15063 !! end
15064
15065 !! test
15066 Parsoid-specific image handling - simple image with border and size spec
15067 !! wikitext
15068 [[File:Foobar.jpg|50px|border|caption]]
15069 !! html/parsoid
15070 <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>
15071 !! end
15072
15073 !! test
15074 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15075 !! wikitext
15076 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
15077 !! html/parsoid
15078 <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>
15079 !! end
15080
15081 !! test
15082 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15083 (existing content)
15084 !! wikitext
15085 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
15086 !! html/parsoid
15087 <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>
15088 !! end
15089
15090 !! test
15091 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
15092 !! wikitext
15093 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
15094 !! html/parsoid
15095 <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>
15096 !! end
15097
15098 !! test
15099 Parsoid-specific image handling - thumbnail with specific size, halign,
15100 valign, and caption (existing content)
15101 !! wikitext
15102 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
15103 !! html/parsoid
15104 <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>
15105 !! end
15106
15107 !! test
15108 Parsoid-specific image handling - framed image with specific size and caption
15109 (size is ignored)
15110 !! options
15111 parsoid=wt2html,wt2wt,html2html
15112 !! wikitext
15113 [[File:Foobar.jpg|frame|500x50px|caption]]
15114 !! html/parsoid
15115 <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>
15116 !! end
15117
15118 !! test
15119 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption
15120 (size is ignored)
15121 !! options
15122 parsoid=wt2html,wt2wt,html2html
15123 !! wikitext
15124 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
15125 !! html/parsoid
15126 <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>
15127 !! end
15128
15129 !! test
15130 Parsoid-specific image handling - frameless image with specific size, border, and caption
15131 !! wikitext
15132 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
15133 !! html/parsoid
15134 <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>
15135 !! end
15136
15137 !! test
15138 Parsoid-specific image handling - simple image with a formatted caption
15139 !! wikitext
15140 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
15141 !! html/parsoid
15142 <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>
15143 !! end
15144
15145 !! test
15146 Parsoid-specific image handling - caption with a template in it
15147 !! wikitext
15148 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
15149 !! html/parsoid
15150 <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>
15151 !! end
15152
15153 !! test
15154 Parsoid-specific image handling - caption with unbalanced tags in it
15155 !! options
15156 parsoid=wt2html,wt2wt,html2html
15157 !! wikitext
15158 foo
15159 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
15160 bar
15161 !! html/parsoid
15162 <p>foo</p>
15163 <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>
15164 <p>bar</p>
15165 !! end
15166
15167 !! test
15168 Parsoid-specific image handling - empty caption (1)
15169 !! options
15170 parsoid=wt2html,wt2wt
15171 !! wikitext
15172 [[File:Foobar.jpg|thumb|]]
15173 !! html/parsoid
15174 <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>
15175 !! end
15176
15177 # empty captions don't get serialized unless we're in the "round trip" case
15178 !! test
15179 Parsoid-specific image handling - empty caption (2)
15180 !! options
15181 parsoid=html2wt
15182 !! html/parsoid
15183 <figure class="mw-default-size" typeof="mw:Image/Thumb">
15184 <a href="./File:Foobar.jpg">
15185 <img resource="./File:Foobar.jpg"
15186 src="//example.com/images/3/3a/Foobar.jpg"
15187 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
15188 height="25" width="220"/>
15189 </a>
15190 <figcaption></figcaption>
15191 </figure>
15192 !! wikitext
15193 [[File:Foobar.jpg|thumb]]
15194 !! end
15195
15196 !! test
15197 Parsoid-specific image handling - whitespace caption
15198 !! wikitext
15199 [[File:Foobar.jpg|thumb| ]]
15200 !! html/parsoid
15201 <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>
15202 !! end
15203
15204 !! test
15205 Parsoid-specific image handling - lang option
15206 !! wikitext
15207 foo
15208 [[File:Foobar.svg|lang=de|caption]]
15209 bar
15210 !! html/parsoid
15211 <p>foo
15212 <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>
15213 bar</p>
15214 !! end
15215
15216 ## Edge case bugs in Parsoid from T93580
15217 !! test
15218 T93580: 1. Templated <ref> inside block images
15219 !! wikitext
15220 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
15221
15222 <references />
15223 !! html/parsoid
15224 <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>
15225
15226 <ol class="mw-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>
15227 !! end
15228
15229 !! test
15230 T93580: 2. <ref> inside inline images
15231 !! wikitext
15232 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
15233
15234 <references />
15235 !! html/parsoid
15236 <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>&lt;meta typeof=\"mw:Extension/ref/Marker\" about=\"#mwt2\" data-parsoid=&#39;{\"group\":\"\",\"name\":\"\",\"content\":\"foo\",\"hasRefInRef\":false,\"dsr\":[64,78,5,6]}&#39;/>"}'><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>
15237
15238 <ol class="mw-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" data-parsoid="{}">foo</span></li></ol>
15239 !! end
15240
15241 !! test
15242 T93580: 3. Templated <ref> inside inline images
15243 !! wikitext
15244 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
15245
15246 <references />
15247 !! html/parsoid
15248 <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>&lt;meta typeof=\"mw:Transclusion mw:Extension/ref/Marker\" about=\"#mwt2\" data-parsoid=&#39;{\"group\":\"\",\"name\":\"\",\"content\":\"foo\",\"hasRefInRef\":false,\"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;/>"}'><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>
15249
15250 <ol class="mw-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>
15251 !! end
15252
15253 ###
15254 ### Subpages
15255 ###
15256 !! article
15257 Subpage test/subpage
15258 !! text
15259 foo
15260 !! endarticle
15261
15262 !! test
15263 Subpage link
15264 !! options
15265 subpage title=[[Subpage test]]
15266 !! wikitext
15267 [[/subpage]]
15268 !! html
15269 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
15270 </p>
15271 !! end
15272
15273 !! test
15274 Subpage noslash link
15275 !! options
15276 subpage title=[[Subpage test]]
15277 !! wikitext
15278 [[/subpage/]]
15279 !! html
15280 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
15281 </p>
15282 !! end
15283
15284 !! article
15285 Subpage test/1/2/subpage
15286 !! text
15287 blah
15288 !! endarticle
15289
15290 !! test
15291 Relative subpage noslash link
15292 !! options
15293 parsoid=wt2wt,wt2html,html2html
15294 subpage title=[[Subpage test/1/2/3/4]]
15295 !! wikitext
15296 [[../../subpage/]]
15297
15298 [[../../subpage]]
15299 !! html/php
15300 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
15301 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
15302 </p>
15303 !! html/parsoid
15304 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
15305 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
15306 !! end
15307
15308 !! test
15309 Parsoid: dot-slash prefixed wikilinks
15310 !! wikitext
15311 [[./foo]]
15312
15313 [[././bar]]
15314
15315 [[././baz/]]
15316 !! html/php
15317 <p>[[./foo]]
15318 </p><p>[[././bar]]
15319 </p><p>[[././baz/]]
15320 </p>
15321 !! html/parsoid
15322 <p>[[./foo]]
15323 </p><p>[[././bar]]
15324 </p><p>[[././baz/]]
15325 </p>
15326 !! end
15327
15328 !! test
15329 Render invalid page names as plain text (T53090)
15330 !! wikitext
15331 [[./../foo|bar]]
15332 [[foo�|bar]]
15333 [[foo/.|bar]]
15334 [[foo/..|bar]]
15335 [[foo~~~bar]]
15336 [[foo>bar]]
15337 [[foo[bar]]
15338 [[.]]
15339 [[..]]
15340 [[foo././bar]]
15341 [[foo[http://example.com]xyz]]
15342
15343 [[{{echo|./../foo}}|bar]]
15344 [[{{echo|foo/.}}|bar]]
15345 [[{{echo|foo/..}}|bar]]
15346 [[{{echo|foo~~~~bar}}]]
15347 [[{{echo|foo>bar}}]]
15348 [[{{echo|foo././bar}}]]
15349 [[{{echo|foo{bar}}]]
15350 [[{{echo|foo}bar}}]]
15351 [[{{echo|foo[bar}}]]
15352 [[{{echo|foo]bar}}]]
15353 [[{{echo|foo<bar}}]]
15354 !!html/php
15355 <p>[[./../foo|bar]]
15356 [[foo�|bar]]
15357 [[foo/.|bar]]
15358 [[foo/..|bar]]
15359 [[foo~~~bar]]
15360 [[foo&gt;bar]]
15361 [[foo[bar]]
15362 [[.]]
15363 [[..]]
15364 [[foo././bar]]
15365 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
15366 </p><p>[[./../foo|bar]]
15367 [[foo/.|bar]]
15368 [[foo/..|bar]]
15369 [[foo~~~~bar]]
15370 [[foo&gt;bar]]
15371 [[foo././bar]]
15372 [[foo{bar]]
15373 [[foo}bar]]
15374 [[foo[bar]]
15375 [[foo]bar]]
15376 [[foo&lt;bar]]
15377 </p>
15378 !!html/parsoid
15379 <p>[[./../foo|bar]]
15380 [[foo�|bar]]
15381 [[foo/.|bar]]
15382 [[foo/..|bar]]
15383 [[foo~~~bar]]
15384 [[foo>bar]]
15385 [[foo[bar]]
15386 [[.]]
15387 [[..]]
15388 [[foo././bar]]
15389 [[foo<a rel="mw:ExtLink" href="http://example.com"></a>xyz]]</p>
15390
15391 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
15392 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
15393 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
15394 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
15395 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
15396 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
15397 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
15398 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
15399 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
15400 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
15401 [[<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>
15402 !!end
15403
15404 !! test
15405 Disabled subpages
15406 !! wikitext
15407 [[/subpage]]
15408 !! html
15409 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
15410 </p>
15411 !! end
15412
15413 !! test
15414 T2561: {{/Subpage}}
15415 !! options
15416 subpage title=[[Page]]
15417 !! wikitext
15418 {{/Subpage}}
15419 !! html
15420 <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>
15421 </p>
15422 !! end
15423
15424 ###
15425 ### Categories
15426 ###
15427 !! article
15428 Category:MediaWiki User's Guide
15429 !! text
15430 blah
15431 !! endarticle
15432
15433 !! test
15434 Link to category
15435 !! wikitext
15436 [[:Category:MediaWiki User's Guide]]
15437 !! html
15438 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
15439 </p>
15440 !! end
15441
15442 !! test
15443 Simple category
15444 !! options
15445 cat
15446 !! wikitext
15447 [[Category:MediaWiki User's Guide]]
15448 !! html/php
15449 cat=MediaWiki_User's_Guide sort=
15450 !! html/parsoid
15451 <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"}}'/>
15452 !! end
15453
15454 !! test
15455 PAGESINCATEGORY invalid title fatal (r33546 fix)
15456 !! wikitext
15457 {{PAGESINCATEGORY:<bogus>}}
15458 !! html
15459 <p>0
15460 </p>
15461 !! end
15462
15463 !! test
15464 Category with different sort key
15465 !! options
15466 cat
15467 !! wikitext
15468 [[Category:MediaWiki User's Guide|Foo]]
15469 !! html/php
15470 cat=MediaWiki_User's_Guide sort=Foo
15471 !! html/parsoid
15472 <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"}}'/>
15473 !! end
15474
15475 !! test
15476 Category with identical sort key
15477 !! options
15478 cat
15479 !! wikitext
15480 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15481 !! html/php
15482 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
15483 !! html/parsoid
15484 <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"}}'/>
15485 !! end
15486
15487 !! test
15488 Category with empty sort key
15489 !! options
15490 cat
15491 pst
15492 !! wikitext
15493 [[Category:MediaWiki User's Guide|]]
15494 !! html/php
15495 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15496 !! end
15497
15498 !! test
15499 Category with empty sort key and parentheses
15500 !! options
15501 cat
15502 pst
15503 !! wikitext
15504 [[Category:Foo (bar)|]]
15505 !! html/php
15506 [[Category:Foo (bar)|Foo]]
15507 !! end
15508
15509 !! test
15510 Category with link tail
15511 !! options
15512 cat
15513 pst
15514 !! wikitext
15515 123[[Category:Foo]]456
15516 !! html/php
15517 123[[Category:Foo]]456
15518 !! end
15519
15520 !! test
15521 Category with template
15522 !! options
15523 cat
15524 pst
15525 !! wikitext
15526 [[Category:{{echo|Foo}}]]
15527 !! html/php
15528 [[Category:{{echo|Foo}}]]
15529 !! end
15530
15531 !! test
15532 Category with template in sort key
15533 !! options
15534 cat
15535 pst
15536 !! wikitext
15537 [[Category:Foo|{{echo|Bar}}]]
15538 !! html/php
15539 [[Category:Foo|{{echo|Bar}}]]
15540 !! end
15541
15542 !! test
15543 Category with template in sort key and title
15544 !! options
15545 cat
15546 pst
15547 !! wikitext
15548 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15549 !! html/php
15550 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15551 !! end
15552
15553 ## We used to, but no longer wt2wt this test since the default serializer
15554 ## will normalize all categories to serialize on their own line.
15555 ## This wikitext usage is going to be fairly uncommon in production and
15556 ## selser will take care of preserving formatting in those scenarios.
15557 !! test
15558 Category / paragraph interactions
15559 !! options
15560 parsoid=wt2html
15561 !! wikitext
15562 Foo [[Category:Baz]] Bar
15563
15564 Foo [[Category:Baz]]
15565 Bar
15566
15567 Foo
15568 [[Category:Baz]]
15569 Bar
15570
15571 Foo
15572 [[Category:Baz]] Bar
15573
15574 Foo
15575 [[Category:Baz]]
15576 [[Category:Baz]]
15577 [[Category:Baz]]
15578 Bar
15579
15580 [[Category:Baz]]
15581 [[Category:Baz]]
15582 [[Category:Baz]]
15583
15584 [[Category:Baz]]
15585 {{echo|[[Category:Baz]]}}
15586 [[Category:Baz]]
15587 !! html/php
15588 <p>Foo Bar
15589 </p><p>Foo
15590 Bar
15591 </p><p>Foo
15592 Bar
15593 </p><p>Foo Bar
15594 </p><p>Foo
15595 Bar
15596 </p>
15597 !! html/parsoid
15598 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15599 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15600 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15601 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15602 <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>
15603 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
15604 !! end
15605
15606 ## We used to, but no longer wt2wt this test since the default serializer
15607 ## will normalize all categories to serialize on their own line.
15608 ## This wikitext usage is going to be fairly uncommon in production and
15609 ## selser will take care of preserving formatting in those scenarios.
15610 ##
15611 ## The whitespace on the empty line is part of the test. Please do not delete
15612 !! test
15613 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
15614 !! options
15615 parsoid=wt2html
15616 !! wikitext
15617 This
15618
15619 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
15620
15621 {{echo|[[Category:Foo]] and so should this!}}
15622 !! html/php
15623 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
15624 </p>
15625 !! html/parsoid
15626 <p>This
15627
15628 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
15629
15630 <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>
15631 !! end
15632
15633 ## Parsoid will not try to wt2wt this while preserving newlines because
15634 ## it suppresses excess newlines within list items -- and we don't want to
15635 ## introduce a special case just for categories, which is, in reality somewhat
15636 ## odd behavior -- categories are unlikely to be used in list items like this
15637 ## in top-level pages and are only likely to show up in template-generated
15638 ## list items where this RT-ing is a non-issue.
15639 ##
15640 ## The whitespace on the empty line is part of the test. Please do not delete
15641 !! test
15642 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
15643 !! options
15644 parsoid=wt2html
15645 !! wikitext
15646 * This
15647
15648 [[Category:Foo]] and this should be part of the same list item
15649 * So should this
15650
15651 {{echo|[[Category:Foo]] and this should be part of the same list item}}
15652 !! html
15653 <ul><li>This and this should be part of the same list item</li>
15654 <li>So should this and this should be part of the same list item</li></ul>
15655 !! html/parsoid
15656 <ul>
15657 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
15658 <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>
15659 </ul>
15660 !! end
15661
15662 ## Newlines and categories that follow the last item of a list
15663 ## are treated differently because this (list followed by categories)
15664 ## is an extremely common pattern on wikis.
15665 !! test
15666 3. Categories and newlines: newline suppression for last list item should RT properly
15667 !! wikitext
15668 * a
15669 * b
15670
15671 [[Category:Foo]]
15672
15673 [[Category:Bar]]
15674 [[Category:Baz]]
15675 !! html/parsoid
15676 <ul><li> a</li>
15677 <li> b</li></ul>
15678
15679 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
15680
15681 <link rel="mw:PageProp/Category" href="./Category:Bar" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
15682 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
15683 !! end
15684
15685 !! test
15686 4. Categories and newlines: newline suppression for last list item should RT properly
15687 !! wikitext
15688 * a
15689 **** b
15690
15691 [[Category:Foo]]
15692 !! html/parsoid
15693 <ul><li> a
15694 <ul><li><ul><li><ul><li> b</li></ul></li></ul></li></ul></li></ul>
15695
15696 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
15697 !! end
15698
15699 ## only wt2html for this to make sure the algo only applies to the rightmost path
15700 !! test
15701 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
15702 !! options
15703 parsoid=wt2html
15704 !! wikitext
15705 * a
15706 ** b
15707 [[Category:Foo]]
15708 * c
15709 ** d
15710 [[Category:Foo]]
15711 !! html/parsoid
15712 <ul><li> a
15713 <ul><li> b
15714 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
15715 <li> c
15716 <ul><li> d</li></ul></li></ul>
15717 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
15718 !! end
15719
15720 ## We used to, but no longer wt2wt this test since the default serializer
15721 ## will normalize all categories to serialize on their own line.
15722 ## This wikitext usage is going to be fairly uncommon in production and
15723 ## selser will take care of preserving formatting in those scenarios.
15724 !! test
15725 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
15726 !! options
15727 parsoid=wt2html
15728 !! wikitext
15729 * a [[Category:Foo]]
15730 !! html/parsoid
15731 <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>
15732 !! end
15733
15734 # This test also demonstrates because of newline+category tunneling
15735 # through the list hander, template wrapping doesn't expand to the
15736 # containing list when the list item swallows the category.
15737 !! test
15738 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
15739 !! wikitext
15740 * {{echo|a
15741 [[Category:Foo]]}}
15742 !! html/parsoid
15743 <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
15744 </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>
15745 !! end
15746
15747 !! test
15748 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
15749 !! wikitext
15750 * a
15751
15752 {{echo|[[Category:Foo]]
15753 [[Category:Bar]]}}
15754 [[Category:Baz]]
15755 !! html/parsoid
15756 <ul><li> a</li></ul>
15757
15758 <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">
15759 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
15760 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
15761 !! end
15762
15763 !! test
15764 Category links with multiple namespaces
15765 !! wikitext
15766 [[Category:Project:Foo]]
15767 !! html/parsoid
15768 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
15769 !! end
15770
15771 !! test
15772 Parsoid: Serialize link to category page with colon escape
15773 !! options
15774 parsoid
15775 !! wikitext
15776
15777 [[:Category:Foo]]
15778 [[:Category:Foo|Bar]]
15779 !! html
15780 <p>
15781 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
15782 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
15783 </p>
15784 !! end
15785
15786 # We used to, but no longer wt2wt this test since the default serializer
15787 # will normalize all categories to serialize on their own line.
15788 # This wikitext usage is going to be fairly uncommon in production and
15789 # selser will take care of preventing whitespace insertion if this
15790 # occurs in an article.
15791 #
15792 # html2html disabled for the same reason (whitespace insertion between
15793 # x and y).
15794 #
15795 # html2wt disabled because it localizes the "Category" namespace.
15796 !! test
15797 Link prefix/suffixes aren't applied to category links
15798 !! options
15799 parsoid=wt2html
15800 language=is
15801 !! wikitext
15802 x[[Category:Foo]]y
15803 !! html/php
15804 <p>xy
15805 </p>
15806 !! html/parsoid
15807 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
15808 !! end
15809
15810 !! test
15811 Parsoid: Serialize link to file page with colon escape
15812 !! options
15813 parsoid
15814 !! wikitext
15815
15816 [[:File:Foo.png]]
15817 [[:File:Foo.png|Bar]]
15818 !! html
15819 <p>
15820 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
15821 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
15822 </p>
15823 !! end
15824
15825 !! test
15826 Parsoid: Serialize a genuine category link without colon escape
15827 !! options
15828 parsoid
15829 !! wikitext
15830 [[Category:Foo]]
15831 [[Category:Foo|Bar]]
15832 !! html
15833 <link rel="mw:PageProp/Category" href="./Category:Foo">
15834 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
15835 !! end
15836
15837 !! test
15838 Normalize hrefs properly before testing for invalid link targets (T72894)
15839 !! options
15840 parsoid=html2wt
15841 !! html/parsoid
15842 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
15843 !! wikitext
15844 [[Category:Toxine bactérienne]]
15845 !! end
15846
15847 !! test
15848 Parsoid: Defaultsort
15849 !! wikitext
15850 {{DEFAULTSORT:Foo}}
15851 !! html/parsoid
15852 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
15853 !! end
15854
15855 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
15856 # But, this is a limitation of our representation and is documented in
15857 # TemplateHandler.js in processSpecialMagicWord
15858 !! test
15859 Parsoid: Defaultsort (template-generated)
15860 !! wikitext
15861 {{{{echo|DEFAULTSORT}}:Foo}}
15862 !! html/parsoid
15863 <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"}]]}'/>
15864 !! end
15865
15866 ###
15867 ### Inter-language links
15868 ###
15869 !! test
15870 Interlanguage links
15871 !! options
15872 ill
15873 !! wikitext
15874 [[es:Alimento]]
15875 [[fr:Nourriture]]
15876 [[zh:食品]]
15877 !! html/php
15878 es:Alimento fr:Nourriture zh:食品
15879 !! html/parsoid
15880 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
15881 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
15882 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
15883 !! end
15884
15885 !! test
15886 Duplicate interlanguage links (T26502)
15887 !! options
15888 ill
15889 !! wikitext
15890 [[es:1]]
15891 [[es:2]]
15892 [[fr:1]]
15893 [[fr:2]]
15894 !! html/php
15895 es:1 fr:1
15896 !! html/parsoid
15897 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
15898 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
15899 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
15900 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
15901 !! end
15902
15903 ###
15904 ### Sections
15905 ###
15906 !! test
15907 Basic section headings
15908 !! wikitext
15909 == Headline 1 ==
15910 Some text
15911
15912 ==Headline 2==
15913 More
15914 ===Smaller headline===
15915 Blah blah
15916 !! html
15917 <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>
15918 <p>Some text
15919 </p>
15920 <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>
15921 <p>More
15922 </p>
15923 <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>
15924 <p>Blah blah
15925 </p>
15926 !! end
15927
15928 !! test
15929 Section headings with TOC
15930 !! wikitext
15931 == Headline 1 ==
15932 === Subheadline 1 ===
15933 ===== Skipping a level =====
15934 ====== Skipping a level ======
15935
15936 == Headline 2 ==
15937 Some text
15938 ===Another headline===
15939 !! html
15940 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
15941 <ul>
15942 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
15943 <ul>
15944 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
15945 <ul>
15946 <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>
15947 <ul>
15948 <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>
15949 </ul>
15950 </li>
15951 </ul>
15952 </li>
15953 </ul>
15954 </li>
15955 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
15956 <ul>
15957 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
15958 </ul>
15959 </li>
15960 </ul>
15961 </div>
15962
15963 <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>
15964 <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>
15965 <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>
15966 <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>
15967 <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>
15968 <p>Some text
15969 </p>
15970 <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>
15971
15972 !! end
15973
15974 !! test
15975 TOC anchors don't collide
15976 !! wikitext
15977 __FORCETOC__
15978 == Headline 2 ==
15979 == Headline ==
15980 == Headline 2 ==
15981 == Headline ==
15982 !! html/php
15983 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
15984 <ul>
15985 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
15986 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
15987 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
15988 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
15989 </ul>
15990 </div>
15991
15992 <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>
15993 <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>
15994 <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>
15995 <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>
15996
15997 !! end
15998
15999 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
16000 !! test
16001 Handling of sections up to level 6 and beyond
16002 !! wikitext
16003 = Level 1 Heading=
16004 == Level 2 Heading==
16005 === Level 3 Heading===
16006 ==== Level 4 Heading====
16007 ===== Level 5 Heading=====
16008 ====== Level 6 Heading======
16009 ======= Level 7 Heading=======
16010 ======== Level 8 Heading========
16011 ========= Level 9 Heading=========
16012 ========== Level 10 Heading==========
16013 !! html
16014 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
16015 <ul>
16016 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
16017 <ul>
16018 <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>
16019 <ul>
16020 <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>
16021 <ul>
16022 <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>
16023 <ul>
16024 <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>
16025 <ul>
16026 <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>
16027 <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>
16028 <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>
16029 <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>
16030 <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>
16031 </ul>
16032 </li>
16033 </ul>
16034 </li>
16035 </ul>
16036 </li>
16037 </ul>
16038 </li>
16039 </ul>
16040 </li>
16041 </ul>
16042 </div>
16043
16044 <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>
16045 <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>
16046 <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>
16047 <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>
16048 <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>
16049 <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>
16050 <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>
16051 <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>
16052 <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>
16053 <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>
16054
16055 !! end
16056
16057 !! test
16058 TOC regression (T11764)
16059 !! wikitext
16060 == title 1 ==
16061 === title 1.1 ===
16062 ==== title 1.1.1 ====
16063 === title 1.2 ===
16064 == title 2 ==
16065 === title 2.1 ===
16066 !! html
16067 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
16068 <ul>
16069 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16070 <ul>
16071 <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>
16072 <ul>
16073 <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>
16074 </ul>
16075 </li>
16076 <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>
16077 </ul>
16078 </li>
16079 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16080 <ul>
16081 <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>
16082 </ul>
16083 </li>
16084 </ul>
16085 </div>
16086
16087 <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>
16088 <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>
16089 <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>
16090 <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>
16091 <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>
16092 <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>
16093
16094 !! end
16095
16096 !! test
16097 TOC for heading containing <span id="..."></span> (T96153)
16098 !! wikitext
16099 __FORCETOC__
16100 ==<span id="old-anchor"></span>New title==
16101 !! html/php
16102 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
16103 <ul>
16104 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
16105 </ul>
16106 </div>
16107
16108 <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>
16109
16110 !! end
16111
16112 !! test
16113 TOC with wgMaxTocLevel=3 (T8204)
16114 !! options
16115 wgMaxTocLevel=3
16116 !! wikitext
16117 == title 1 ==
16118 === title 1.1 ===
16119 ==== title 1.1.1 ====
16120 === title 1.2 ===
16121 == title 2 ==
16122 === title 2.1 ===
16123 !! html
16124 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
16125 <ul>
16126 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16127 <ul>
16128 <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>
16129 <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>
16130 </ul>
16131 </li>
16132 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16133 <ul>
16134 <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>
16135 </ul>
16136 </li>
16137 </ul>
16138 </div>
16139
16140 <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>
16141 <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>
16142 <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>
16143 <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>
16144 <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>
16145 <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>
16146
16147 !! end
16148
16149 !! test
16150 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
16151 !! options
16152 wgMaxTocLevel=3
16153 !! wikitext
16154 ==Section 1==
16155 ===Section 1.1===
16156 ====Section 1.1.1====
16157 ====Section 1.1.1.1====
16158 ==Section 2==
16159 !! html
16160 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
16161 <ul>
16162 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
16163 <ul>
16164 <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>
16165 </ul>
16166 </li>
16167 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
16168 </ul>
16169 </div>
16170
16171 <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>
16172 <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>
16173 <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>
16174 <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>
16175 <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>
16176
16177 !! end
16178
16179
16180 !! test
16181 Resolving duplicate section names
16182 !! wikitext
16183 == Foo bar ==
16184 == Foo bar ==
16185 !! html
16186 <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>
16187 <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>
16188
16189 !! end
16190
16191 !! test
16192 Resolving duplicate section names with differing case (T12721)
16193 !! wikitext
16194 == Foo bar ==
16195 == Foo Bar ==
16196 !! html
16197 <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>
16198 <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>
16199
16200 !! end
16201
16202 !! article
16203 Template:sections
16204 !! text
16205 ===Section 1===
16206 ==Section 2==
16207 !! endarticle
16208
16209 !! test
16210 Template with sections, __NOTOC__
16211 !! wikitext
16212 __NOTOC__
16213 ==Section 0==
16214 {{sections}}
16215 ==Section 4==
16216 !! html
16217 <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>
16218 <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>
16219 <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>
16220 <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>
16221
16222 !! end
16223
16224 !! test
16225 __NOEDITSECTION__ keyword
16226 !! wikitext
16227 __NOEDITSECTION__
16228 ==Section 1==
16229 ==Section 2==
16230 !! html
16231 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
16232 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
16233
16234 !! end
16235
16236 !! test
16237 Link inside a section heading
16238 !! wikitext
16239 ==Section with a [[Main Page|link]] in it==
16240 !! html
16241 <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>
16242
16243 !! end
16244
16245 !! test
16246 TOC regression (T14077)
16247 !! wikitext
16248 __TOC__
16249 == title 1 ==
16250 === title 1.1 ===
16251 == title 2 ==
16252 !! html
16253 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
16254 <ul>
16255 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16256 <ul>
16257 <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>
16258 </ul>
16259 </li>
16260 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
16261 </ul>
16262 </div>
16263
16264 <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>
16265 <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>
16266 <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>
16267
16268 !! end
16269
16270 !! test
16271 T3219 URL next to image (good)
16272 !! wikitext
16273 http://example.com [[File:Foobar.jpg]]
16274 !! html/php
16275 <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>
16276 </p>
16277 !! html/parsoid
16278 <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>
16279 !!end
16280
16281 !! test
16282 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
16283 !! wikitext
16284 ===
16285 The line above must have a trailing space!
16286 === <!--
16287 --> <!-- -->
16288 But just in case it doesn't...
16289 !! html
16290 <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>
16291 <p>The line above must have a trailing space!
16292 </p>
16293 <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>
16294 <p>But just in case it doesn't...
16295 </p>
16296 !! end
16297
16298 !! test
16299 Header with special characters (T27462)
16300 !! wikitext
16301 The tooltips shall not show entities to the user (ie. be double escaped)
16302
16303 == text > text ==
16304 section 1
16305
16306 == text < text ==
16307 section 2
16308
16309 == text & text ==
16310 section 3
16311
16312 == text ' text ==
16313 section 4
16314
16315 == text " text ==
16316 section 5
16317 !! html
16318 <p>The tooltips shall not show entities to the user (ie. be double escaped)
16319 </p>
16320 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
16321 <ul>
16322 <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>
16323 <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>
16324 <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>
16325 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
16326 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
16327 </ul>
16328 </div>
16329
16330 <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>
16331 <p>section 1
16332 </p>
16333 <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>
16334 <p>section 2
16335 </p>
16336 <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>
16337 <p>section 3
16338 </p>
16339 <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 ' text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
16340 <p>section 4
16341 </p>
16342 <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>
16343 <p>section 5
16344 </p>
16345 !! end
16346
16347 !! test
16348 Header with space, plus and underscore as entity
16349 !! wikitext
16350 Id should not contain + for spaces
16351
16352 == Space between Text ==
16353 section 1
16354
16355 == Space-Entity&#32;between&#32;Text ==
16356 section 2
16357
16358 == Plus+between+Text ==
16359 section 3
16360
16361 == Plus-Entity&#43;between&#43;Text ==
16362 section 4
16363
16364 == Underscore_between_Text ==
16365 section 5
16366
16367 == Underscore-Entity&#95;between&#95;Text ==
16368 section 6
16369
16370 [[#Space between Text]]
16371 [[#Space-Entity&#32;between&#32;Text]]
16372 [[#Plus+between+Text]]
16373 [[#Plus-Entity&#43;between&#43;Text]]
16374 [[#Underscore_between_Text]]
16375 [[#Underscore-Entity&#95;between&#95;Text]]
16376 !! html
16377 <p>Id should not contain + for spaces
16378 </p>
16379 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
16380 <ul>
16381 <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>
16382 <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>
16383 <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>
16384 <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>
16385 <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>
16386 <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>
16387 </ul>
16388 </div>
16389
16390 <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>
16391 <p>section 1
16392 </p>
16393 <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>
16394 <p>section 2
16395 </p>
16396 <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>
16397 <p>section 3
16398 </p>
16399 <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>
16400 <p>section 4
16401 </p>
16402 <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>
16403 <p>section 5
16404 </p>
16405 <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>
16406 <p>section 6
16407 </p><p><a href="#Space_between_Text">#Space between Text</a>
16408 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
16409 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
16410 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
16411 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
16412 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
16413 </p>
16414 !! end
16415
16416 !! test
16417 Headers with excess '=' characters
16418 (Are similar tests necessary beyond the 1st level?)
16419 !! wikitext
16420 =foo==
16421 ==foo=
16422 =''italic'' heading==
16423 ==''italic'' heading=
16424 !! html
16425 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
16426 <ul>
16427 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
16428 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
16429 <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>
16430 <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>
16431 </ul>
16432 </div>
16433
16434 <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>
16435 <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>
16436 <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>
16437 <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>
16438
16439 !! end
16440
16441 !! test
16442 HTML headers vs TOC (T25393)
16443 (__NOEDITSECTION__ for clearer output, doesn't matter here)
16444 !! wikitext
16445 <h1>Header 1</h1>
16446 == Header 1.1 ==
16447 == Header 1.2 ==
16448
16449 <h1>Header 2
16450 </h1>
16451 == Header 2.1 ==
16452 == Header 2.2 ==
16453 __NOEDITSECTION__
16454 !! html
16455 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
16456 <ul>
16457 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
16458 <ul>
16459 <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>
16460 <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>
16461 </ul>
16462 </li>
16463 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
16464 <ul>
16465 <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>
16466 <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>
16467 </ul>
16468 </li>
16469 </ul>
16470 </div>
16471
16472 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
16473 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
16474 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
16475 <h1><span class="mw-headline" id="Header_2">Header 2</span></h1>
16476 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
16477 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
16478
16479 !! end
16480
16481 !! test
16482 Single-line or multiline-comments can follow headings
16483 !! options
16484 parsoid=wt2html,wt2wt
16485 !! wikitext
16486 ==foo==<!---->
16487 ==bar==<!--c1-->
16488 ==baz==<!--
16489 c2
16490 c3-->
16491 !! html
16492 <h2><span class="mw-headline" id="foo">foo</span></h2>
16493 <h2><span class="mw-headline" id="bar">bar</span></h2>
16494 <h2><span class="mw-headline" id="baz">baz</span></h2>
16495
16496 !! end
16497
16498 !! test
16499 T3219 URL next to image (broken)
16500 !! wikitext
16501 http://example.com[[File:Foobar.jpg]]
16502 !! html/php
16503 <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>
16504 </p>
16505 !! html/parsoid
16506 <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>
16507 !!end
16508
16509 !! test
16510 T3186 news: in the middle of text
16511 !! wikitext
16512 http://en.wikinews.org/wiki/Wikinews:Workplace
16513 !! html
16514 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
16515 </p>
16516 !!end
16517
16518
16519 !! test
16520 Namespaced link must have a title
16521 !! wikitext
16522 [[Project:]]
16523 !! html
16524 <p>[[Project:]]
16525 </p>
16526 !!end
16527
16528 !! test
16529 Namespaced link must have a title (bad fragment version)
16530 !! wikitext
16531 [[Project:#fragment]]
16532 !! html
16533 <p>[[Project:#fragment]]
16534 </p>
16535 !!end
16536
16537
16538 ###
16539 ### HTML tags and HTML attributes
16540 ###
16541
16542 !! test
16543 div with no attributes
16544 !! wikitext
16545 <div>HTML rocks</div>
16546 !! html
16547 <div>HTML rocks</div>
16548
16549 !! end
16550
16551 !! test
16552 div with double-quoted attribute
16553 !! wikitext
16554 <div id="rock">HTML rocks</div>
16555 !! html
16556 <div id="rock">HTML rocks</div>
16557
16558 !! end
16559
16560 !! test
16561 div with single-quoted attribute
16562 !! wikitext
16563 <div id='rock'>HTML rocks</div>
16564 !! html
16565 <div id="rock">HTML rocks</div>
16566
16567 !! end
16568
16569 !! test
16570 div with unquoted attribute
16571 !! wikitext
16572 <div id=rock>HTML rocks</div>
16573 !! html
16574 <div id="rock">HTML rocks</div>
16575
16576 !! end
16577
16578 !! test
16579 div with illegal double attributes
16580 !! wikitext
16581 <div id="a" id="b">HTML rocks</div>
16582 !! html
16583 <div id="b">HTML rocks</div>
16584
16585 !!end
16586
16587 !! test
16588 div with empty attribute value, space before equals
16589 !! options
16590 parsoid=wt2html,html2html
16591 !! wikitext
16592 <div class =>HTML rocks</div>
16593 !! html/php
16594 <div class="">HTML rocks</div>
16595
16596 !! html/parsoid
16597 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
16598 !! end
16599
16600 !! test
16601 div with multiple empty attribute values
16602 !! options
16603 parsoid=wt2html,html2html
16604 !! wikitext
16605 <div id= title=>HTML rocks</div>
16606 !! html/php
16607 <div id="title.3D">HTML rocks</div>
16608
16609 !! html/parsoid
16610 <div id="title.3D" data-parsoid='{"stx":"html"}'>HTML rocks</div>
16611 !! end
16612
16613 !! test
16614 table with multiple empty attribute values
16615 !! options
16616 parsoid=wt2html,html2html
16617 !! wikitext
16618 {| title= id=
16619 | hi
16620 |}
16621 !! html/php
16622 <table title="id=">
16623 <tr>
16624 <td> hi
16625 </td></tr></table>
16626
16627 !! html/parsoid
16628 <table title="id=">
16629 <tbody><tr><td> hi</td></tr>
16630 </tbody></table>
16631 !! end
16632
16633 !! test
16634 div with braces in attribute value
16635 !! wikitext
16636 <div title="{}">Foo</div>
16637 !! html/php
16638 <div title="&#123;&#125;">Foo</div>
16639
16640 !! html/parsoid
16641 <div title="{}">Foo</div>
16642 !! end
16643
16644 !! test
16645 div with empty attribute value, no space before equals
16646 !! options
16647 parsoid=wt2html,html2html
16648 !! wikitext
16649 <div class=>HTML rocks</div>
16650 !! html/php
16651 <div class="">HTML rocks</div>
16652
16653 !! html/parsoid
16654 <div class="">HTML rocks</div>
16655 !! end
16656
16657 !! test
16658 HTML multiple attributes correction
16659 !! wikitext
16660 <p class="error" class="awesome">Awesome!</p>
16661 !! html
16662 <p class="awesome">Awesome!</p>
16663
16664 !!end
16665
16666 !! test
16667 Table multiple attributes correction
16668 !! wikitext
16669 {|
16670 !+ class="error" class="awesome"| status
16671 |}
16672 !! html
16673 <table>
16674 <tr>
16675 <th class="awesome"> status
16676 </th></tr></table>
16677
16678 !!end
16679
16680 !! test
16681 DIV IN UPPERCASE
16682 !! wikitext
16683 <DIV ID="x">HTML ROCKS</DIV>
16684 !! html
16685 <div id="x">HTML ROCKS</div>
16686
16687 !!end
16688
16689 !! test
16690 Non-ASCII pseudo-tags are rendered as text
16691 !! wikitext
16692 <khyô>
16693 !! html
16694 <p>&lt;khyô&gt;
16695 </p>
16696 !! end
16697
16698 !! test
16699 Pseudo-tag with URL 'name' renders as url link
16700 !! wikitext
16701 <http://example.com/>
16702 !! html
16703 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
16704 </p>
16705 !! end
16706
16707 !! test
16708 text with amp in the middle of nowhere
16709 !! wikitext
16710 Remember AT&T?
16711 !! html
16712 <p>Remember AT&amp;T?
16713 </p>
16714 !! end
16715
16716 !! test
16717 text with character entity: eacute
16718 !! wikitext
16719 I always thought &eacute; was a cute letter.
16720 !! html
16721 <p>I always thought &#233; was a cute letter.
16722 </p>
16723 !! html+tidy
16724 <p>I always thought é was a cute letter.</p>
16725 !! end
16726
16727 !! test
16728 text with entity-escaped character entity-like string: eacute
16729 !! wikitext
16730 I always thought &amp;eacute; was a cute letter.
16731 !! html
16732 <p>I always thought &amp;eacute; was a cute letter.
16733 </p>
16734 !! end
16735
16736 !! test
16737 text with undefined character entity: xacute
16738 !! wikitext
16739 I always thought &xacute; was a cute letter.
16740 !! html
16741 <p>I always thought &amp;xacute; was a cute letter.
16742 </p>
16743 !! end
16744
16745 !! test
16746 HTML5 tags
16747 !! wikitext
16748 <data value="5">five</data>
16749 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
16750 <mark>This highlighted text</mark>
16751 !! html
16752 <p><data value="5">five</data>
16753 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
16754 <mark>This highlighted text</mark>
16755 </p>
16756 !! end
16757
16758 !! test
16759 HTML tag with leading space is parsed as text
16760 !! wikitext
16761 < div>foo< /div>
16762 !! html
16763 <p>&lt; div&gt;foo&lt; /div&gt;
16764 </p>
16765 !! end
16766
16767 ###
16768 ### Nesting tests (see T43545, T52604, T53081)
16769 ###
16770
16771 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
16772 # Note that html2wt is considerably more difficult if we use <b> in
16773 # the test case, instead of <small>
16774 !! test
16775 Ensure that HTML adoption agency algorithm is properly implemented.
16776 !! wikitext
16777 <small>X<small>Y</small>Z</small>
16778 !! html
16779 <p><small>X<small>Y</small>Z</small>
16780 </p>
16781 !! end
16782
16783 # This was T43545 in the PHP parser.
16784 # Note that tidy doesn't handle this correctly.
16785 !! test
16786 Nesting of <kbd>
16787 !! wikitext
16788 <kbd>X<kbd>Y</kbd>Z</kbd>
16789 !! html
16790 <p><kbd>X<kbd>Y</kbd>Z</kbd>
16791 </p>
16792 !! end
16793
16794 # The following cases were T53081 in the PHP parser.
16795 # Note that there are some other nestable tags (b, i, etc) which are
16796 # not covered; see T53081 for discussion.
16797
16798 # Note that tidy doesn't handle this correctly.
16799 !! test
16800 Nesting of <em>
16801 !! wikitext
16802 <em>X<em>Y</em>Z</em>
16803 !! html
16804 <p><em>X<em>Y</em>Z</em>
16805 </p>
16806 !! end
16807
16808 # Note that tidy doesn't handle this correctly.
16809 !! test
16810 Nesting of <strong>
16811 !! wikitext
16812 <strong>X<strong>Y</strong>Z</strong>
16813 !! html
16814 <p><strong>X<strong>Y</strong>Z</strong>
16815 </p>
16816 !! end
16817
16818 !! test
16819 Nesting of <q>
16820 !! wikitext
16821 <q>X<q>Y</q>Z</q>
16822 !! html+tidy
16823 <p><q>X<q>Y</q>Z</q></p>
16824 !! end
16825
16826 # Note that tidy doesn't handle this correctly.
16827 !! test
16828 Nesting of <ruby>
16829 !! wikitext
16830 <ruby>X<ruby>Y</ruby>Z</ruby>
16831 !! html
16832 <p><ruby>X<ruby>Y</ruby>Z</ruby>
16833 </p>
16834 !! end
16835
16836 # Note that tidy doesn't handle this correctly.
16837 !! test
16838 Nesting of <bdo>
16839 !! wikitext
16840 <bdo>X<bdo>Y</bdo>Z</bdo>
16841 !! html
16842 <p><bdo>X<bdo>Y</bdo>Z</bdo>
16843 </p>
16844 !! end
16845
16846
16847 ###
16848 ### Media links
16849 ###
16850
16851 !! test
16852 Media link
16853 !! wikitext
16854 [[Media:Foobar.jpg]]
16855 !! html/php
16856 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
16857 </p>
16858 !! html/parsoid
16859 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a></p>
16860 !! end
16861
16862 !! test
16863 Media link with text
16864 !! wikitext
16865 [[Media:Foobar.jpg|A neat file to look at]]
16866 !! html/php
16867 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
16868 </p>
16869 !! html/parsoid
16870 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
16871 !! end
16872
16873 # FIXME: this is still bad HTML tag nesting
16874 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
16875 !! test
16876 Media link with nasty text
16877 !! wikitext
16878 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
16879 !! html/php
16880 <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>
16881
16882 !! html+php/tidy
16883 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link</a></p>
16884 <div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div>
16885 !! html/parsoid
16886 <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>
16887
16888 !! end
16889
16890 !! test
16891 Media link to nonexistent file (T3702)
16892 !! wikitext
16893 [[Media:No such.jpg]]
16894 [[Media:No_such file.jpg]]
16895 !! html/php
16896 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
16897 <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>
16898 </p>
16899 !! html/parsoid
16900 <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>
16901 <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>
16902 !! end
16903
16904 !! test
16905 Image link to nonexistent file (T3850 - good)
16906 !! wikitext
16907 [[File:No_such.jpg]]
16908 !! html/php
16909 <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>
16910 </p>
16911 !! html/parsoid
16912 <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>
16913 !! end
16914
16915 !! test
16916 :Image link to nonexistent file (T3850 - bad)
16917 !! wikitext
16918 [[:Image:No such.jpg]]
16919 !! html/php
16920 <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>
16921 </p>
16922 !! html/parsoid
16923 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
16924 !! end
16925
16926
16927
16928 !! test
16929 Character reference normalization in link text (T3938)
16930 !! wikitext
16931 [[Main Page|this&that]]
16932 !! html
16933 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
16934 </p>
16935 !!end
16936
16937 !! article
16938 אַ
16939 !! text
16940 Test for unicode normalization
16941
16942 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
16943 !! endarticle
16944
16945 !! test
16946 (T21451) Links should refer to the normalized form.
16947 !! wikitext
16948 [[&#xFB2E;]]
16949 [[&#x5d0;&#x5b7;]]
16950 [[&#x5d0;ַ]]
16951 [[א&#x5b7;]]
16952 [[אַ]]
16953 !! html
16954 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
16955 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
16956 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
16957 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
16958 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
16959 </p>
16960 !! end
16961
16962 !! test
16963 Empty attribute crash test (T4067)
16964 !! wikitext
16965 <font color="">foo</font>
16966 !! html
16967 <p><font color="">foo</font>
16968 </p>
16969 !! end
16970
16971 !! test
16972 Empty attribute crash test single-quotes (T4067)
16973 !! wikitext
16974 <font color=''>foo</font>
16975 !! html
16976 <p><font color="">foo</font>
16977 </p>
16978 !! end
16979
16980 !! test
16981 Attribute test: equals, then nothing
16982 !! options
16983 parsoid=wt2html,html2html
16984 !! wikitext
16985 <font color=>foo</font>
16986 !! html/php
16987 <p><font color="">foo</font>
16988 </p>
16989 !! html/parsoid
16990 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
16991 !! end
16992
16993 !! test
16994 Attribute test: unquoted value
16995 !! options
16996 parsoid=wt2html,html2html
16997 !! wikitext
16998 <font color=x>foo</font>
16999 !! html/php
17000 <p><font color="x">foo</font>
17001 </p>
17002 !! html/parsoid
17003 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
17004 !! end
17005
17006 !! test
17007 Attribute test: unquoted but illegal value (hash)
17008 !! wikitext
17009 <font color=#x>foo</font>
17010 !! html
17011 <p><font color="#x">foo</font>
17012 </p>
17013 !! end
17014
17015 # Parsoid does not serialize to empty attribute syntax,
17016 # so wt2wt and html2wt cases are skipped
17017 !! test
17018 Attribute test: no value (T54330)
17019 !! options
17020 parsoid=wt2html,html2html
17021 !! wikitext
17022 <font color>foo</font>
17023 !! html/php
17024 <p><font color="">foo</font>
17025 </p>
17026 !! html/parsoid
17027 <p><font color="">foo</font></p>
17028 !! end
17029
17030 !! test
17031 T4095: link with three closing brackets
17032 !! wikitext
17033 [[Main Page]]]
17034 !! html/php
17035 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
17036 </p>
17037 !! html/parsoid
17038 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
17039 !! end
17040
17041 !! test
17042 T4095: link with pipe and three closing brackets
17043 !! wikitext
17044 [[Main Page|link]]]
17045 !! html/php
17046 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
17047 </p>
17048 !! html/parsoid
17049 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
17050 !! end
17051
17052 !! test
17053 T4095: link with pipe and three closing brackets, version 2
17054 !! wikitext
17055 [[Main Page|[http://example.com/]]]
17056 !! html/php
17057 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
17058 </p>
17059 !! html/parsoid
17060 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
17061 !! end
17062
17063
17064 ###
17065 ### Safety
17066 ###
17067
17068 !! article
17069 Template:Dangerous attribute
17070 !! text
17071 " onmouseover="alert(document.cookie)
17072 !! endarticle
17073
17074 !! article
17075 Template:Dangerous style attribute
17076 !! text
17077 border-size: expression(alert(document.cookie))
17078 !! endarticle
17079
17080 !! article
17081 Template:Div style
17082 !! text
17083 <div style="float: right; {{{1}}}">Magic div</div>
17084 !! endarticle
17085
17086 !! test
17087 T4304: HTML attribute safety (safe template; regression T4309)
17088 !! wikitext
17089 <div title="{{test}}"></div>
17090 !! html/php
17091 <div title="This is a test template"></div>
17092
17093 !! html/parsoid
17094 <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>
17095 !! end
17096
17097 # Parsoid has enough context to handle this case
17098 !! test
17099 T4304: HTML attribute safety (dangerous template; 2309)
17100 !! wikitext
17101 <div title="{{dangerous attribute}}"></div>
17102 !! html/php
17103 <div title=""></div>
17104
17105 !! html/parsoid
17106 <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>
17107 !! end
17108
17109 !! test
17110 T4304: HTML attribute safety (dangerous style template; 2309)
17111 !! wikitext
17112 <div style="{{dangerous style attribute}}"></div>
17113 !! html/php
17114 <div style="/* insecure input */"></div>
17115
17116 !! html/parsoid
17117 <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>
17118 !! end
17119
17120 !! test
17121 T4304: HTML attribute safety (safe parameter; 2309)
17122 !! wikitext
17123 {{div style|width: 200px}}
17124 !! html/php
17125 <div style="float: right; width: 200px">Magic div</div>
17126
17127 !! html/parsoid
17128 <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>
17129 !! end
17130
17131 !! test
17132 T4304: HTML attribute safety (unsafe parameter; 2309)
17133 !! wikitext
17134 {{div style|width: expression(alert(document.cookie))}}
17135 !! html/php
17136 <div style="/* insecure input */">Magic div</div>
17137
17138 !! html/parsoid
17139 <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>
17140 !! end
17141
17142 ## Parsoid output here differs; needs investigation.
17143 !! test
17144 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
17145 !! wikitext
17146 {{div style|"><script>alert(document.cookie)</script>}}
17147 !! html
17148 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17149
17150 !! end
17151
17152 ## Parsoid output here differs; needs investigation.
17153 !! test
17154 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
17155 !! wikitext
17156 {{div style|" ><script>alert(document.cookie)</script>}}
17157 !! html
17158 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17159
17160 !! end
17161
17162 !! test
17163 T4304: HTML attribute safety (link)
17164 !! wikitext
17165 <div title="[[Main Page]]"></div>
17166 !! html
17167 <div title="&#91;&#91;Main Page]]"></div>
17168
17169 !! end
17170
17171 !! test
17172 T4304: HTML attribute safety (italics)
17173 !! wikitext
17174 <div title="''foobar''"></div>
17175 !! html
17176 <div title="&#39;&#39;foobar&#39;&#39;"></div>
17177
17178 !! end
17179
17180 !! test
17181 T4304: HTML attribute safety (bold)
17182 !! wikitext
17183 <div title="'''foobar'''"></div>
17184 !! html
17185 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
17186
17187 !! end
17188
17189 !! test
17190 T4304: HTML attribute safety (ISBN)
17191 !! wikitext
17192 <div title="ISBN 1234567890"></div>
17193 !! html
17194 <div title="&#73;SBN 1234567890"></div>
17195
17196 !! end
17197
17198 !! test
17199 T4304: HTML attribute safety (RFC)
17200 !! wikitext
17201 <div title="RFC 1234"></div>
17202 !! html
17203 <div title="&#82;FC 1234"></div>
17204
17205 !! end
17206
17207 !! test
17208 T4304: HTML attribute safety (PMID)
17209 !! wikitext
17210 <div title="PMID 1234567890"></div>
17211 !! html
17212 <div title="&#80;MID 1234567890"></div>
17213
17214 !! end
17215
17216 !! test
17217 T4304: HTML attribute safety (web link)
17218 !! wikitext
17219 <div title="http://example.com/"></div>
17220 !! html
17221 <div title="http&#58;//example.com/"></div>
17222
17223 !! end
17224
17225 !! test
17226 T4304: HTML attribute safety (named web link)
17227 !! wikitext
17228 <div title="[http://example.com/ link]"></div>
17229 !! html
17230 <div title="&#91;http&#58;//example.com/ link]"></div>
17231
17232 !! end
17233
17234 !! test
17235 T5244: HTML attribute safety (extension; safe)
17236 !! wikitext
17237 <div style="<nowiki>background:blue</nowiki>"></div>
17238 !! html/php
17239 <div style="background:blue"></div>
17240
17241 !! html/parsoid
17242 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
17243 !! end
17244
17245 !! test
17246 T5244: HTML attribute safety (extension; unsafe)
17247 !! wikitext
17248 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
17249 !! html/php
17250 <div style="/* insecure input */"></div>
17251
17252 !! html/parsoid
17253 <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>
17254 !! end
17255
17256 # More MSIE fun discovered by Tom Gilder
17257
17258 !! test
17259 MSIE CSS safety test: spurious slash
17260 !! wikitext
17261 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
17262 !! html/php
17263 <div style="/* insecure input */">evil</div>
17264
17265 !! html/parsoid
17266 <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>
17267 !! end
17268
17269 !! test
17270 MSIE CSS safety test: hex code
17271 !! wikitext
17272 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
17273 !! html/php
17274 <div style="/* insecure input */">evil</div>
17275
17276 !! html/parsoid
17277 <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>
17278 !! end
17279
17280 !! test
17281 MSIE CSS safety test: comment in url
17282 !! wikitext
17283 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
17284 !! html/php
17285 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
17286
17287 !! html/parsoid
17288 <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>
17289 !! end
17290
17291 !! test
17292 MSIE CSS safety test: comment in expression
17293 !! wikitext
17294 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
17295 !! html/php
17296 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
17297
17298 !! html/parsoid
17299 <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>
17300 !! end
17301
17302 !! test
17303 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
17304 !! wikitext
17305 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
17306 !! html/php
17307 <p style="/* invalid control char */">A</p>
17308
17309 !! html/parsoid
17310 <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>
17311 !! end
17312
17313 !! test
17314 MSIE 6 CSS safety test: Fullwidth (T57332)
17315 !! wikitext
17316 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
17317 <div style="top:EXPRESSION(alert())">B</div>
17318 !! html/php
17319 <p style="/* insecure input */">A</p>
17320 <div style="/* insecure input */">B</div>
17321
17322 !! html/parsoid
17323 <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>
17324 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
17325 !! end
17326
17327 !! test
17328 MSIE 6 CSS safety test: IPA extensions (T57332)
17329 !! wikitext
17330 <div style="background-image:uʀʟ(javascript:alert())">A</div>
17331 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
17332 !! html/php
17333 <div style="/* insecure input */">A</div>
17334 <p style="/* insecure input */">B</p>
17335
17336 !! html/parsoid
17337 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
17338 <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>
17339 !! end
17340
17341 !! test
17342 MSIE 6 CSS safety test: sup/sub script (T57332)
17343 !! wikitext
17344 <div style="background-image:url⁽javascript:alert())">A</div>
17345 <div style="background-image:url₍javascript:alert())">B</div>
17346 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
17347 !! html/php
17348 <div style="/* insecure input */">A</div>
17349 <div style="/* insecure input */">B</div>
17350 <p style="/* insecure input */">C</p>
17351
17352 !! html/parsoid
17353 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
17354 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
17355 <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>
17356 !! end
17357
17358 !! test
17359 Opera -o-link CSS
17360 !! options
17361 parsoid=wt2html,html2html
17362 !! wikitext
17363 <div
17364 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;"
17365 style="-o-link:attr(title);-o-link-source:current">X</div>
17366 !! html/php
17367 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
17368
17369 !! html/parsoid
17370 <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>
17371 !! end
17372
17373 !! test
17374 MSIE 6 CSS safety test: Repetition markers (T57332)
17375 !! wikitext
17376 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
17377 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
17378 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
17379 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
17380 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
17381 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
17382 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
17383 !! html/php
17384 <p style="/* insecure input */">A</p>
17385 <p style="/* insecure input */">B</p>
17386 <p style="/* insecure input */">C</p>
17387 <p style="/* insecure input */">D</p>
17388 <p style="/* insecure input */">E</p>
17389 <p style="/* insecure input */">F</p>
17390 <p style="/* insecure input */">G</p>
17391
17392 !! html/parsoid
17393 <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>
17394 <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>
17395 <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>
17396 <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>
17397 <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>
17398 <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>
17399 <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>
17400 !! end
17401
17402 !! test
17403 Table attribute legitimate extension
17404 !! wikitext
17405 {|
17406 !+ style="<nowiki>color:blue</nowiki>"| status
17407 |}
17408 !! html
17409 <table>
17410 <tr>
17411 <th style="color:blue"> status
17412 </th></tr></table>
17413
17414 !!end
17415
17416 !! test
17417 Table attribute safety
17418 !! wikitext
17419 {|
17420 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
17421 |}
17422 !! html
17423 <table>
17424 <tr>
17425 <th style="/* insecure input */"> status
17426 </th></tr></table>
17427
17428 !! end
17429
17430 !! test
17431 CSS line continuation 1
17432 !! wikitext
17433 <div style="background-image: u\&#10;rl(test.jpg);"></div>
17434 !! html
17435 <div style="/* insecure input */"></div>
17436
17437 !! end
17438
17439 !! test
17440 CSS line continuation 2
17441 !! wikitext
17442 <div style="background-image: u\&#13;rl(test.jpg); "></div>
17443 !! html
17444 <div style="/* invalid control char */"></div>
17445
17446 !! end
17447
17448 !! article
17449 Template:Identity
17450 !! text
17451 {{{1}}}
17452 !! endarticle
17453
17454 !! test
17455 Expansion of multi-line templates in attribute values (T8255)
17456 !! wikitext
17457 <div style="background: {{identity|#00FF00}}">-</div>
17458 !! html
17459 <div style="background: #00FF00">-</div>
17460
17461 !! end
17462
17463 !! test
17464 Expansion of multi-line templates in attribute values (T8255 sanity check)
17465 !! wikitext
17466 <div style="background:
17467 #00FF00">-</div>
17468 !! html/php
17469 <div style="background: #00FF00">-</div>
17470
17471 !! html/parsoid
17472 <div style="background:
17473 #00FF00">-</div>
17474 !! end
17475
17476 !! test
17477 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
17478 !! wikitext
17479 <div style="background: &#10;#00FF00">-</div>
17480 !! html
17481 <div style="background: &#10;#00FF00">-</div>
17482
17483 !! end
17484
17485 !! test
17486 Tags which are hidden from Tidy cannot pass through the Sanitizer
17487 !! wikitext
17488 <mw:toc><script>alert();</script></mw:toc>
17489 !! html+tidy
17490 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;</p>
17491 !! end
17492
17493 ###
17494 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
17495 ###
17496
17497 !! test
17498 Parser hook: empty input
17499 !! wikitext
17500 <tag></tag>
17501 !! html/php
17502 <pre>
17503 ''
17504 array (
17505 )
17506 </pre>
17507
17508 !! html/parsoid
17509 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17510 !! end
17511
17512 ## Don't expect parsoid to rt this form.
17513 !! test
17514 Parser hook: empty input using terminated empty elements
17515 !! options
17516 parsoid=wt2html,html2html
17517 !! wikitext
17518 <tag/>
17519 !! html/php
17520 <pre>
17521 NULL
17522 array (
17523 )
17524 </pre>
17525
17526 !! html/parsoid
17527 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
17528 !! end
17529
17530 !! test
17531 Parser hook: empty input using terminated empty elements (space before)
17532 !! wikitext
17533 <tag />
17534 !! html/php
17535 <pre>
17536 NULL
17537 array (
17538 )
17539 </pre>
17540
17541 !! html/parsoid
17542 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
17543 !! end
17544
17545 !! test
17546 Parser hook: basic input
17547 !! wikitext
17548 <tag>input</tag>
17549 !! html/php
17550 <pre>
17551 'input'
17552 array (
17553 )
17554 </pre>
17555
17556 !! html/parsoid
17557 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
17558 !! end
17559
17560 ## Don't expect parsoid to rt this form.
17561 !! test
17562 Parser hook: case insensitive
17563 !! options
17564 parsoid=wt2html,html2html
17565 !! wikitext
17566 <TAG>input</TAG>
17567 !! html/php
17568 <pre>
17569 'input'
17570 array (
17571 )
17572 </pre>
17573
17574 !! html/parsoid
17575 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
17576 !! end
17577
17578 ## Don't expect parsoid to rt this form.
17579 !! test
17580 Parser hook: case insensitive, redux
17581 !! options
17582 parsoid=wt2html,html2html
17583 !! wikitext
17584 <TaG>input</TAg>
17585 !! html/php
17586 <pre>
17587 'input'
17588 array (
17589 )
17590 </pre>
17591
17592 !! html/parsoid
17593 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
17594 !! end
17595
17596 !! test
17597 Parser hook: nested tags
17598 !! wikitext
17599 <tag><tag></tag></tag>
17600 !! html/php
17601 <pre>
17602 '<tag>'
17603 array (
17604 )
17605 </pre>&lt;/tag&gt;
17606
17607 !! html/parsoid
17608 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}' data-parsoid='{}' about="#mwt2"></pre>&lt;/tag>
17609 !! end
17610
17611 !! test
17612 Parser hook: basic arguments
17613 !! wikitext
17614 <tag width="200" height="100" depth="50" square=""></tag>
17615 !! html/php
17616 <pre>
17617 ''
17618 array (
17619 'width' => '200',
17620 'height' => '100',
17621 'depth' => '50',
17622 'square' => '',
17623 )
17624 </pre>
17625
17626 !! html/parsoid
17627 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17628 !! end
17629
17630 ## Don't expect parsoid to rt this form.
17631 !! test
17632 Parser hook: basic arguments, variations
17633 !! options
17634 parsoid=wt2html,html2html
17635 !! wikitext
17636 <tag width=200 height = "100" depth = '50' square></tag>
17637 !! html/php
17638 <pre>
17639 ''
17640 array (
17641 'width' => '200',
17642 'height' => '100',
17643 'depth' => '50',
17644 'square' => '',
17645 )
17646 </pre>
17647
17648 !! html/parsoid
17649 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17650 !! end
17651
17652 !! test
17653 Parser hook: argument containing a forward slash (T7344)
17654 !! wikitext
17655 <tag filename="/tmp/bla"></tag>
17656 !! html/php
17657 <pre>
17658 ''
17659 array (
17660 'filename' => '/tmp/bla',
17661 )
17662 </pre>
17663
17664 !! html/parsoid
17665 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17666 !! end
17667
17668 ## Don't expect parsoid to rt this form.
17669 !! test
17670 Parser hook: empty input using terminated empty elements (T4374)
17671 !! options
17672 parsoid=wt2html,html2html
17673 !! wikitext
17674 <tag foo=bar/>text
17675 !! html/php
17676 <pre>
17677 NULL
17678 array (
17679 'foo' => 'bar',
17680 )
17681 </pre>text
17682
17683 !! html/parsoid
17684 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text
17685 !! end
17686
17687 ## </tag> should be output literally since there is no matching tag that begins it
17688 ## Don't expect parsoid to rt this form.
17689 !! test
17690 Parser hook: basic arguments using terminated empty elements (T4374)
17691 !! options
17692 parsoid=wt2html
17693 !! wikitext
17694 <tag width=200 height = "100" depth = '50' square/>
17695 other stuff
17696 </tag>
17697 !! html/php
17698 <pre>
17699 NULL
17700 array (
17701 'width' => '200',
17702 'height' => '100',
17703 'depth' => '50',
17704 'square' => '',
17705 )
17706 </pre>
17707 <p>other stuff
17708 &lt;/tag&gt;
17709 </p>
17710 !! html/parsoid
17711 <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
17712 &lt;/tag></p>
17713 !! end
17714
17715 ## Don't expect parsoid to rt this form.
17716 !! test
17717 Parser hook: Don't allow unclosed extension tags
17718 !! options
17719 parsoid=wt2html
17720 !! wikitext
17721 test <tag>123
17722
17723 this is a '''test'''
17724 !! html/php
17725 <p>test &lt;tag&gt;123
17726 </p><p>this is a <b>test</b>
17727 </p>
17728 !! html/parsoid
17729 <p>test &lt;tag>123</p>
17730
17731 <p>this is a <b>test</b></p>
17732 !! end
17733
17734 ###
17735 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
17736 ###
17737
17738 !! test
17739 Parser hook: static parser hook not inside a comment
17740 !! wikitext
17741 <statictag>hello, world</statictag>
17742
17743 <statictag action="flush" />
17744 !! html/php
17745 <p><br />
17746 hello, world
17747 </p>
17748 !! html/parsoid
17749 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
17750 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p>
17751 !! end
17752
17753 !! test
17754 Parser hook: static parser hook inside a comment
17755 !! wikitext
17756 <!-- <statictag>hello, world</statictag> -->
17757 <statictag action="flush" />
17758 !! html/php
17759 <p><br />
17760 </p>
17761 !! html/parsoid
17762 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
17763 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt2"></p>
17764 !! end
17765
17766 # Nested template calls; this case was broken by Parser.php rev 1.506,
17767 # since reverted.
17768
17769 !! article
17770 Template:One-parameter
17771 !! text
17772 (My parameter is: {{{1}}})
17773 !! endarticle
17774
17775 !! article
17776 Template:Map-one-parameter
17777 !! text
17778 {{{{{1}}}|{{{2}}}}}
17779 !! endarticle
17780
17781 !! test
17782 Nested template calls
17783 !! wikitext
17784 {{Map-one-parameter|One-parameter|param}}
17785 !! html
17786 <p>(My parameter is: param)
17787 </p>
17788 !! end
17789
17790
17791 ###
17792 ### Sanitizer
17793 ###
17794
17795 # HTML+Tidy effectively strips out the empty tags completely
17796 # But since Parsoid doesn't it wraps the <s></s> tags in p-tags
17797 # which Tidy would have done for the PHP parser had there been content inside it.
17798 !! test
17799 Sanitizer: Closing of open tags
17800 !! wikitext
17801 <s></s><table></table>
17802 !! html
17803 <s></s><table></table>
17804
17805 !! html/parsoid
17806 <p><s></s></p><table></table>
17807 !! end
17808
17809 !! test
17810 Sanitizer: Closing of open but not closed tags
17811 !! wikitext
17812 <s>foo
17813 !! html
17814 <p><s>foo</s>
17815 </p>
17816 !! end
17817
17818 !! test
17819 Sanitizer: Closing of closed but not open tags
17820 !! options
17821 parsoid=wt2html
17822 !! wikitext
17823 </s>
17824 !! html/php+tidy
17825 !! html/parsoid
17826 !! end
17827
17828 !! test
17829 Sanitizer: Closing of closed but not open table tags
17830 !! options
17831 parsoid=wt2html
17832 !! wikitext
17833 Table not started</td></tr></table>
17834 !! html/php+tidy
17835 <p>Table not started</p>
17836 !! html/parsoid
17837 <p>Table not started</p>
17838 !! end
17839
17840 !! test
17841 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
17842 !! wikitext
17843 <span id="æ: v">byte</span>[[#æ: v|backlink]]
17844 !! html/php
17845 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
17846 </p>
17847 !! html/parsoid
17848 <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>
17849 !! end
17850
17851 # In HTML5, the restrictions are that id must contain at least one character,
17852 # and must not contain any space characters.
17853 !! test
17854 Sanitizer: Validating the contents of the id attribute (T6515)
17855 !! options
17856 disabled
17857 !! wikitext
17858 <br id="" /><br id="a space" />
17859 !! html
17860 Something ...
17861 !! end
17862
17863 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
17864 !! test
17865 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
17866 !! options
17867 disabled
17868 !! wikitext
17869 <br id="foo" /><br id="foo" />
17870 !! html
17871 Something need to be done. foo-2 ?
17872 !! end
17873
17874 !! test
17875 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
17876 !! wikitext
17877 <div itemscope>
17878 <meta itemprop="hello" content="world">
17879 <meta http-equiv="refresh" content="5">
17880 <meta itemprop="hello" http-equiv="refresh" content="5">
17881 <link itemprop="hello" href="{{SERVER}}">
17882 <link rel="stylesheet" href="{{SERVER}}">
17883 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
17884 </div>
17885 !! html
17886 <div itemscope="">
17887 <p> <meta itemprop="hello" content="world" />
17888 &lt;meta http-equiv="refresh" content="5"&gt;
17889 <meta itemprop="hello" content="5" />
17890 <link itemprop="hello" href="http&#58;//example.org" />
17891 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
17892 <link itemprop="hello" href="http&#58;//example.org" />
17893 </p>
17894 </div>
17895
17896 !! end
17897
17898 !! test
17899 Language converter: output gets cut off unexpectedly (T7757)
17900 !! options
17901 language=zh
17902 !! wikitext
17903 this bit is safe: }-
17904
17905 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
17906
17907 then we get cut off here: }-
17908
17909 all additional text is vanished
17910 !! html
17911 <p>this bit is safe: }-
17912 </p><p>but if we add a conversion instance: xxx
17913 </p><p>then we get cut off here: }-
17914 </p><p>all additional text is vanished
17915 </p>
17916 !! end
17917
17918 !! test
17919 Self closed html pairs (T7487)
17920 !! wikitext
17921 <center><font id="bug" />Centered text</center>
17922 <div><font id="bug2" />In div text</div>
17923 !! html+tidy
17924 <center><font id="bug"></font>Centered text</center>
17925 <div><font id="bug2"></font>In div text</div>
17926 !! end
17927
17928 #
17929 #
17930 #
17931
17932 !! test
17933 Punctuation: nbsp before exclamation
17934 !! wikitext
17935 C'est grave !
17936 !! html
17937 <p>C'est grave&#160;!
17938 </p>
17939 !! end
17940
17941 !! test
17942 Punctuation: CSS !important (T13874)
17943 !! wikitext
17944 <div style="width:50% !important">important</div>
17945 !! html
17946 <div style="width:50% !important">important</div>
17947
17948 !!end
17949
17950 !! test
17951 Punctuation: CSS ! important (T13874; with space after)
17952 !! wikitext
17953 <div style="width:50% ! important">important</div>
17954 !! html
17955 <div style="width:50% ! important">important</div>
17956
17957 !!end
17958
17959 !! test
17960 HTML bullet list, closed tags (T7497)
17961 !! wikitext
17962 <ul>
17963 <li>One</li>
17964 <li>Two</li>
17965 </ul>
17966 !! html/php
17967 <ul>
17968 <li>One</li>
17969 <li>Two</li>
17970 </ul>
17971
17972 !! html/parsoid
17973 <ul data-parsoid='{"stx":"html"}'>
17974 <li data-parsoid='{"stx":"html"}'>One</li>
17975 <li data-parsoid='{"stx":"html"}'>Two</li>
17976 </ul>
17977
17978 !! end
17979
17980 !! test
17981 HTML bullet list, unclosed tags (T7497)
17982 !! wikitext
17983 <ul>
17984 <li>One
17985 <li>Two
17986 </ul>
17987 !! html/php+tidy
17988 <ul>
17989 <li>One</li>
17990 <li>Two</li>
17991 </ul>
17992 !! html/parsoid
17993 <ul data-parsoid='{"stx":"html"}'>
17994 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
17995 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
17996 </ul>
17997
17998 !! end
17999
18000 !! test
18001 HTML ordered list, closed tags (T7497)
18002 !! wikitext
18003 <ol>
18004 <li>One</li>
18005 <li>Two</li>
18006 </ol>
18007 !! html/php
18008 <ol>
18009 <li>One</li>
18010 <li>Two</li>
18011 </ol>
18012
18013 !! html/parsoid
18014 <ol data-parsoid='{"stx":"html"}'>
18015 <li data-parsoid='{"stx":"html"}'>One</li>
18016 <li data-parsoid='{"stx":"html"}'>Two</li>
18017 </ol>
18018
18019 !! end
18020
18021 !! test
18022 HTML ordered list, unclosed tags (T7497)
18023 !! options
18024 !! wikitext
18025 <ol>
18026 <li>One
18027 <li>Two
18028 </ol>
18029 !! html/php+tidy
18030 <ol>
18031 <li>One</li>
18032 <li>Two</li>
18033 </ol>
18034 !! html/parsoid
18035 <ol data-parsoid='{"stx":"html"}'>
18036 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18037 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18038 </ol>
18039
18040 !! end
18041
18042 !! test
18043 HTML nested bullet list, closed tags (T7497)
18044 !! wikitext
18045 <ul>
18046 <li>One</li>
18047 <li>Two:
18048 <ul>
18049 <li>Sub-one</li>
18050 <li>Sub-two</li>
18051 </ul>
18052 </li>
18053 </ul>
18054 !! html/php
18055 <ul>
18056 <li>One</li>
18057 <li>Two:
18058 <ul>
18059 <li>Sub-one</li>
18060 <li>Sub-two</li>
18061 </ul>
18062 </li>
18063 </ul>
18064
18065 !! html/parsoid
18066 <ul data-parsoid='{"stx":"html"}'>
18067 <li data-parsoid='{"stx":"html"}'>One</li>
18068 <li data-parsoid='{"stx":"html"}'>Two:
18069 <ul data-parsoid='{"stx":"html"}'>
18070 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
18071 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
18072 </ul>
18073 </li>
18074 </ul>
18075 !! end
18076
18077 !! test
18078 HTML nested bullet list, open tags (T7497)
18079 !! wikitext
18080 <ul>
18081 <li>One
18082 <li>Two:
18083 <ul>
18084 <li>Sub-one
18085 <li>Sub-two
18086 </ul>
18087 </ul>
18088 !! html/php+tidy
18089 <ul>
18090 <li>One</li>
18091 <li>Two:
18092 <ul>
18093 <li>Sub-one</li>
18094 <li>Sub-two</li>
18095 </ul>
18096 </li>
18097 </ul>
18098 !! html/parsoid
18099 <ul>
18100 <li>One
18101 </li>
18102 <li>Two:
18103 <ul>
18104 <li>Sub-one
18105 </li>
18106 <li>Sub-two
18107 </li>
18108 </ul>
18109 </li>
18110 </ul>
18111
18112 !! end
18113
18114 !! test
18115 HTML nested ordered list, closed tags (T7497)
18116 !! wikitext
18117 <ol>
18118 <li>One</li>
18119 <li>Two:
18120 <ol>
18121 <li>Sub-one</li>
18122 <li>Sub-two</li>
18123 </ol>
18124 </li>
18125 </ol>
18126 !! html
18127 <ol>
18128 <li>One</li>
18129 <li>Two:
18130 <ol>
18131 <li>Sub-one</li>
18132 <li>Sub-two</li>
18133 </ol>
18134 </li>
18135 </ol>
18136
18137 !! end
18138
18139 !! test
18140 HTML nested ordered list, open tags (T7497)
18141 !! wikitext
18142 <ol>
18143 <li>One
18144 <li>Two:
18145 <ol>
18146 <li>Sub-one
18147 <li>Sub-two
18148 </ol>
18149 </ol>
18150 !! html/php
18151 <ol>
18152 <li>One
18153 <li>Two:
18154 <ol>
18155 <li>Sub-one
18156 <li>Sub-two
18157 </ol>
18158 </ol>
18159
18160 !! html/parsoid
18161 <ol>
18162 <li>One
18163 </li>
18164 <li>Two:
18165 <ol>
18166 <li>Sub-one
18167 </li>
18168 <li>Sub-two
18169 </li>
18170 </ol>
18171 </li>
18172 </ol>
18173
18174 !! end
18175
18176 !! test
18177 HTML ordered list item with parameters oddity
18178 !! wikitext
18179 <ol><li id="fragment">One</li>
18180 </ol>
18181 !! html
18182 <ol><li id="fragment">One</li>
18183 </ol>
18184
18185 !! end
18186
18187 # parsoid doesn't explicitly mark autonumbered links, see T55505
18188 !!test
18189 T7918: autonumbering
18190 !! wikitext
18191 [http://first/] [http://second] [ftp://ftp]
18192
18193 ftp://inlineftp
18194
18195 [mailto:enclosed@mail.tld With target]
18196
18197 [mailto:enclosed@mail.tld]
18198
18199 mailto:inline@mail.tld
18200 !! html/php
18201 <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>
18202 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
18203 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
18204 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
18205 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
18206 </p>
18207 !! html/parsoid
18208 <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>
18209 <p><a rel="mw:ExtLink" href="ftp://inlineftp">ftp://inlineftp</a></p>
18210 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld">With target</a></p>
18211 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld"></a></p>
18212 <p><a rel="mw:ExtLink" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
18213 !! end
18214
18215
18216 #
18217 # Security and HTML correctness
18218 # From Nick Jenkins' fuzz testing
18219 #
18220
18221 !! test
18222 Fuzz testing: Parser13
18223 !! wikitext
18224 {|
18225 | http://a|
18226 !! html
18227 <table>
18228 <tr>
18229 <td>
18230 </td>
18231 </tr>
18232 </table>
18233
18234 !! end
18235
18236 !! test
18237 Fuzz testing: Parser14
18238 !! wikitext
18239 == onmouseover= ==
18240 http://__TOC__
18241 !! html
18242 <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>
18243 http://<div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
18244 <ul>
18245 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18246 </ul>
18247 </div>
18248
18249
18250 !! html+tidy
18251 <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>
18252 <p>http://</p>
18253 <div id="toc" class="toc">
18254 <div id="toctitle" class="toctitle">
18255 <h2>Contents</h2>
18256 </div>
18257 <ul>
18258 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18259 </ul>
18260 </div>
18261 <p></p>
18262 !! end
18263
18264 !! test
18265 Fuzz testing: Parser14-table
18266 !! options
18267 parsoid=wt2html,html2html
18268 !! wikitext
18269 ==a==
18270 {| STYLE=__TOC__
18271 !! html
18272 <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>
18273 <table style="&#95;_TOC&#95;_">
18274 <tr><td></td></tr>
18275 </table>
18276
18277 !! html+tidy
18278 <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>
18279 <table style="__TOC__">
18280 <tr>
18281 <td></td>
18282 </tr>
18283 </table>
18284 !! html/parsoid
18285 <h2>a</h2>
18286 <table style="__TOC__"></table>
18287 !! end
18288
18289 # Known to produce bogus xml (extra </td>)
18290 !! test
18291 Fuzz testing: Parser16
18292 !! wikitext
18293 {|
18294 !https://||||||
18295 !! html
18296 <table>
18297 <tr>
18298 <th>https://</th>
18299 <th></th>
18300 <th></th>
18301 <th>
18302 </td>
18303 </tr>
18304 </table>
18305
18306 !! html+tidy
18307 <table>
18308 <tr>
18309 <th>https://</th>
18310 <th></th>
18311 <th></th>
18312 <th></th>
18313 </tr>
18314 </table>
18315 !! end
18316
18317 !! test
18318 Fuzz testing: Parser21
18319 !! wikitext
18320 {|
18321 ! irc://{{ftp://a" onmouseover="alert('hello world');"
18322 |
18323 !! html
18324 <table>
18325 <tr>
18326 <th> <a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
18327 </th>
18328 <td>
18329 </td>
18330 </tr>
18331 </table>
18332
18333 !! end
18334
18335 !! test
18336 Fuzz testing: Parser22
18337 !! wikitext
18338 http://===r:::https://b
18339
18340 {|
18341 !! html
18342 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
18343 </p>
18344 <table>
18345 <tr><td></td></tr>
18346 </table>
18347
18348 !! end
18349
18350 # Known to produce bad XML for now
18351 !! test
18352 Fuzz testing: Parser24
18353 !! options
18354 parsoid=wt2html
18355 !! wikitext
18356 {|
18357 {{{|
18358 <u CLASS=
18359 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
18360 <br style="onmouseover='alert(document.cookie);' " />
18361
18362 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
18363 |
18364 !! html/php
18365 <table>
18366 {{{|
18367 <u class="&#124;">}}}} &gt;
18368 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
18369
18370 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
18371 <tr>
18372 <td></u>
18373 </td>
18374 </tr>
18375 </table>
18376
18377 !! html/parsoid
18378 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
18379 <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>"}'/>}}}} >
18380 <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}'>
18381
18382
18383
18384 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table>
18385 !! end
18386
18387 # Note: the current result listed for this is not what the original one was,
18388 # but the original bug was JavaScript injection, which is fixed in any case.
18389 # It's not clear that the original result listed was any more correct than the
18390 # current one. Original result:
18391 # <p>{{{|
18392 # </p>
18393 # <li class="&#124;&#124;">
18394 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
18395 !!test
18396 Fuzz testing: Parser25 (T8055)
18397 !! wikitext
18398 {{{
18399 |
18400 <LI CLASS=||
18401 >
18402 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
18403 !! html/php
18404 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
18405 </p>
18406 !! html/parsoid
18407 <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"]}'>
18408 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
18409 !! end
18410
18411 !!test
18412 Fuzz testing: URL adjacent extension (with space, clean)
18413 !! wikitext
18414 http://example.com <nowiki>junk</nowiki>
18415 !! html/php
18416 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
18417 </p>
18418 !! html/parsoid
18419 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a> <span typeof="mw:Nowiki">junk</span></p>
18420 !! end
18421
18422 !!test
18423 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
18424 !! wikitext
18425 http://example.com<nowiki>junk</nowiki>
18426 !! html/php
18427 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
18428 </p>
18429 !! html/parsoid
18430 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a><span typeof="mw:Nowiki">junk</span></p>
18431 !! end
18432
18433 !! test
18434 Fuzz testing: URL adjacent extension (no space, dirty; pre)
18435 !! wikitext
18436 http://example.com<pre>junk</pre>
18437 !! html/php
18438 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
18439
18440 !! html/php+tidy
18441 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p>
18442 <pre>
18443 junk
18444 </pre>
18445 !! html/parsoid
18446 <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>
18447 !! end
18448
18449 !! test
18450 Fuzz testing: image with bogus manual thumbnail
18451 !! wikitext
18452 [[Image:foobar.jpg|thumbnail= ]]
18453 !! html/php
18454 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
18455
18456 !! html/parsoid
18457 <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>
18458 !! end
18459
18460 !! test
18461 Fuzz testing: encoded newline in generated HTML replacements (T8577)
18462 !! wikitext
18463 <pre dir="&#10;"></pre>
18464 !! html/php
18465 <pre dir="&#10;"></pre>
18466
18467 !! html/parsoid
18468 <pre typeof="mw:Extension/pre" about="#mwt2" dir="&amp;#10;" data-mw='{"name":"pre","attrs":{"dir":"&amp;#10;"},"body":{"extsrc":""}}'></pre>
18469 !! end
18470
18471 !! test
18472 Parsing optional HTML elements (T8171)
18473 !! options
18474 !! wikitext
18475 <table>
18476 <tr>
18477 <td> Some tabular data</td>
18478 <td> More tabular data ...
18479 <td> And yet som tabular data</td>
18480 </tr>
18481 </table>
18482 !! html
18483 <table>
18484 <tr>
18485 <td> Some tabular data</td>
18486 <td> More tabular data ...
18487 </td><td> And yet som tabular data</td>
18488 </tr>
18489 </table>
18490
18491 !! end
18492
18493 !! test
18494 Correct handling of <td>, <tr> (T8171)
18495 !! options
18496 !! wikitext
18497 <table>
18498 <tr>
18499 <td> Some tabular data</td>
18500 <td> More tabular data ...</td>
18501 <td> And yet som tabular data</td>
18502 </tr>
18503 </table>
18504 !! html
18505 <table>
18506 <tr>
18507 <td> Some tabular data</td>
18508 <td> More tabular data ...</td>
18509 <td> And yet som tabular data</td>
18510 </tr>
18511 </table>
18512
18513 !! end
18514
18515
18516 !! test
18517 Parsing crashing regression (fr:JavaScript)
18518 !! wikitext
18519 </body></x>
18520 !! html
18521 <p>&lt;/body&gt;&lt;/x&gt;
18522 </p>
18523 !! end
18524
18525 !! test
18526 Inline wiki vs wiki block nesting
18527 !! wikitext
18528 '''Bold paragraph
18529
18530 New wiki paragraph
18531 !! html
18532 <p><b>Bold paragraph</b>
18533 </p><p>New wiki paragraph
18534 </p>
18535 !! end
18536
18537 # FIXME: The current php output is documented
18538 # and desired output is the parsoid target.
18539 !! test
18540 Inline HTML vs wiki block nesting
18541 !! wikitext
18542 <b>Bold paragraph
18543
18544 New wiki paragraph
18545 !! html/php
18546 <p><b>Bold paragraph
18547 </p><p>New wiki paragraph</b>
18548 </p>
18549 !! html/parsoid
18550 <p><b>Bold paragraph</b>
18551 </p><p>New wiki paragraph
18552 </p>
18553 !! end
18554
18555 # Original result was this:
18556 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
18557 # </p>
18558 # While that might be marginally more intuitive, maybe, the six-apostrophe
18559 # construct is clearly pathological and the result stated here (which is what
18560 # the parser actually does) is about as reasonable as anything.
18561 !!test
18562 Mixing markup for italics and bold
18563 !! options
18564 !! wikitext
18565 '''bold''''''bold''bolditalics'''''
18566 !! html
18567 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
18568 </p>
18569 !! end
18570
18571
18572 !! article
18573 Xyzzyx
18574 !! text
18575 Article for special page transclusion test
18576 !! endarticle
18577
18578 !! test
18579 Special page transclusion
18580 !! options
18581 !! wikitext
18582 {{Special:Prefixindex/Xyzzyx}}
18583 !! html
18584 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
18585 </ul>
18586
18587 !! end
18588
18589 !! test
18590 Special page transclusion twice (T7021)
18591 !! options
18592 !! wikitext
18593 {{Special:Prefixindex/Xyzzyx}}
18594 {{Special:Prefixindex/Xyzzyx}}
18595 !! html
18596 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
18597 </ul>
18598 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
18599 </ul>
18600
18601 !! end
18602
18603 !! test
18604 Transclusion of default MediaWiki message
18605 !! wikitext
18606 {{MediaWiki:Mainpage}}
18607 !! html
18608 <p>Main Page
18609 </p>
18610 !! end
18611
18612 !! test
18613 Transclusion of nonexistent MediaWiki message
18614 !! wikitext
18615 {{MediaWiki:Mainpagexxx}}
18616 !! html
18617 <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>
18618 </p>
18619 !! end
18620
18621 !! test
18622 Transclusion of MediaWiki message with underscore
18623 !! wikitext
18624 {{MediaWiki:history_short}}
18625 !! html
18626 <p>History
18627 </p>
18628 !! end
18629
18630 !! test
18631 Transclusion of MediaWiki message with space
18632 !! wikitext
18633 {{MediaWiki:history short}}
18634 !! html
18635 <p>History
18636 </p>
18637 !! end
18638
18639 !! test
18640 Invalid header with following text
18641 !! wikitext
18642 = x = y
18643 !! html
18644 <p>= x = y
18645 </p>
18646 !! end
18647
18648
18649 !! test
18650 Section extraction test (section 0)
18651 !! options
18652 section=0
18653 !! wikitext
18654 start
18655 ==a==
18656 ===aa===
18657 ====aaa====
18658 ==b==
18659 ===ba===
18660 ===bb===
18661 ====bba====
18662 ===bc===
18663 ==c==
18664 ===ca===
18665 !! html/php
18666 start
18667 !! end
18668
18669 !! test
18670 Section extraction test (section 1)
18671 !! options
18672 section=1
18673 !! wikitext
18674 start
18675 ==a==
18676 ===aa===
18677 ====aaa====
18678 ==b==
18679 ===ba===
18680 ===bb===
18681 ====bba====
18682 ===bc===
18683 ==c==
18684 ===ca===
18685 !! html/php
18686 ==a==
18687 ===aa===
18688 ====aaa====
18689 !! end
18690
18691 !! test
18692 Section extraction test (section 2)
18693 !! options
18694 section=2
18695 !! wikitext
18696 start
18697 ==a==
18698 ===aa===
18699 ====aaa====
18700 ==b==
18701 ===ba===
18702 ===bb===
18703 ====bba====
18704 ===bc===
18705 ==c==
18706 ===ca===
18707 !! html/php
18708 ===aa===
18709 ====aaa====
18710 !! end
18711
18712 !! test
18713 Section extraction test (section 3)
18714 !! options
18715 section=3
18716 !! wikitext
18717 start
18718 ==a==
18719 ===aa===
18720 ====aaa====
18721 ==b==
18722 ===ba===
18723 ===bb===
18724 ====bba====
18725 ===bc===
18726 ==c==
18727 ===ca===
18728 !! html/php
18729 ====aaa====
18730 !! end
18731
18732 !! test
18733 Section extraction test (section 4)
18734 !! options
18735 section=4
18736 !! wikitext
18737 start
18738 ==a==
18739 ===aa===
18740 ====aaa====
18741 ==b==
18742 ===ba===
18743 ===bb===
18744 ====bba====
18745 ===bc===
18746 ==c==
18747 ===ca===
18748 !! html/php
18749 ==b==
18750 ===ba===
18751 ===bb===
18752 ====bba====
18753 ===bc===
18754 !! end
18755
18756 !! test
18757 Section extraction test (section 5)
18758 !! options
18759 section=5
18760 !! wikitext
18761 start
18762 ==a==
18763 ===aa===
18764 ====aaa====
18765 ==b==
18766 ===ba===
18767 ===bb===
18768 ====bba====
18769 ===bc===
18770 ==c==
18771 ===ca===
18772 !! html/php
18773 ===ba===
18774 !! end
18775
18776 !! test
18777 Section extraction test (section 6)
18778 !! options
18779 section=6
18780 !! wikitext
18781 start
18782 ==a==
18783 ===aa===
18784 ====aaa====
18785 ==b==
18786 ===ba===
18787 ===bb===
18788 ====bba====
18789 ===bc===
18790 ==c==
18791 ===ca===
18792 !! html/php
18793 ===bb===
18794 ====bba====
18795 !! end
18796
18797 !! test
18798 Section extraction test (section 7)
18799 !! options
18800 section=7
18801 !! wikitext
18802 start
18803 ==a==
18804 ===aa===
18805 ====aaa====
18806 ==b==
18807 ===ba===
18808 ===bb===
18809 ====bba====
18810 ===bc===
18811 ==c==
18812 ===ca===
18813 !! html/php
18814 ====bba====
18815 !! end
18816
18817 !! test
18818 Section extraction test (section 8)
18819 !! options
18820 section=8
18821 !! wikitext
18822 start
18823 ==a==
18824 ===aa===
18825 ====aaa====
18826 ==b==
18827 ===ba===
18828 ===bb===
18829 ====bba====
18830 ===bc===
18831 ==c==
18832 ===ca===
18833 !! html/php
18834 ===bc===
18835 !! end
18836
18837 !! test
18838 Section extraction test (section 9)
18839 !! options
18840 section=9
18841 !! wikitext
18842 start
18843 ==a==
18844 ===aa===
18845 ====aaa====
18846 ==b==
18847 ===ba===
18848 ===bb===
18849 ====bba====
18850 ===bc===
18851 ==c==
18852 ===ca===
18853 !! html/php
18854 ==c==
18855 ===ca===
18856 !! end
18857
18858 !! test
18859 Section extraction test (section 10)
18860 !! options
18861 section=10
18862 !! wikitext
18863 start
18864 ==a==
18865 ===aa===
18866 ====aaa====
18867 ==b==
18868 ===ba===
18869 ===bb===
18870 ====bba====
18871 ===bc===
18872 ==c==
18873 ===ca===
18874 !! html/php
18875 ===ca===
18876 !! end
18877
18878 !! test
18879 Section extraction test (nonexistent section 11)
18880 !! options
18881 section=11
18882 !! wikitext
18883 start
18884 ==a==
18885 ===aa===
18886 ====aaa====
18887 ==b==
18888 ===ba===
18889 ===bb===
18890 ====bba====
18891 ===bc===
18892 ==c==
18893 ===ca===
18894 !! html/php
18895 !! end
18896
18897 !! test
18898 Section extraction test with bogus heading (section 1)
18899 !! options
18900 section=1
18901 !! wikitext
18902 ==a==
18903 ==bogus== not a legal section
18904 ==b==
18905 !! html/php
18906 ==a==
18907 ==bogus== not a legal section
18908 !! end
18909
18910 !! test
18911 Section extraction test with bogus heading (section 2)
18912 !! options
18913 section=2
18914 !! wikitext
18915 ==a==
18916 ==bogus== not a legal section
18917 ==b==
18918 !! html/php
18919 ==b==
18920 !! end
18921
18922 !! test
18923 Section extraction test with comment after heading (section 1)
18924 !! options
18925 section=1
18926 !! wikitext
18927 ==a==
18928 ==b== <!-- -->
18929 ==c==
18930 !! html/php
18931 ==a==
18932 !! end
18933
18934 !! test
18935 Section extraction test with comment after heading (section 2)
18936 !! options
18937 section=2
18938 !! wikitext
18939 ==a==
18940 ==b== <!-- -->
18941 ==c==
18942 !! html/php
18943 ==b== <!-- -->
18944 !! end
18945
18946 !! test
18947 Section extraction test with bogus <nowiki> heading (section 1)
18948 !! options
18949 section=1
18950 !! wikitext
18951 ==a==
18952 ==bogus== <nowiki>not a legal section</nowiki>
18953 ==b==
18954 !! html/php
18955 ==a==
18956 ==bogus== <nowiki>not a legal section</nowiki>
18957 !! end
18958
18959 !! test
18960 Section extraction test with bogus <nowiki> heading (section 2)
18961 !! options
18962 section=2
18963 !! wikitext
18964 ==a==
18965 ==bogus== <nowiki>not a legal section</nowiki>
18966 ==b==
18967 !! html/php
18968 ==b==
18969 !! end
18970
18971 # Formerly testing for T4587, now resolved by the use of unmarked sections
18972 # instead of respecting commented sections
18973 !! test
18974 Section extraction prefixed by comment (section 1)
18975 !! options
18976 section=1
18977 !! wikitext
18978 <!-- -->==sec1==
18979 ==sec2==
18980 !! html/php
18981 ==sec2==
18982 !!end
18983
18984 !! test
18985 Section extraction prefixed by comment (section 2)
18986 !! options
18987 section=2
18988 !! wikitext
18989 <!-- -->==sec1==
18990 ==sec2==
18991 !! html/php
18992
18993 !!end
18994
18995 # Formerly testing for T4607, now resolved by the use of unmarked sections
18996 # instead of respecting HTML-style headings
18997 !! test
18998 Section extraction, mixed wiki and html (section 1)
18999 !! options
19000 section=1
19001 !! wikitext
19002 <h2>unmarked</h2>
19003 unmarked
19004 ==1==
19005 one
19006 ==2==
19007 two
19008 !! html/php
19009 ==1==
19010 one
19011 !! end
19012
19013 !! test
19014 Section extraction, mixed wiki and html (section 2)
19015 !! options
19016 section=2
19017 !! wikitext
19018 <h2>unmarked</h2>
19019 unmarked
19020 ==1==
19021 one
19022 ==2==
19023 two
19024 !! html/php
19025 ==2==
19026 two
19027 !! end
19028
19029
19030 # Formerly testing for T5342
19031 !! test
19032 Section extraction, heading surrounded by <noinclude>
19033 !! options
19034 section=1
19035 !! wikitext
19036 <noinclude>==unmarked==</noinclude>
19037 ==marked==
19038 !! html/php
19039 ==marked==
19040 !!end
19041
19042 # Test behavior of T21910
19043 !! test
19044 Sectiion with all-equals
19045 !! options
19046 section=2
19047 !! wikitext
19048 ===
19049 The line above must have a trailing space
19050 === <!--
19051 --> <!-- -->
19052 But just in case it doesn't...
19053 !! html/php
19054 === <!--
19055 --> <!-- -->
19056 But just in case it doesn't...
19057 !! end
19058
19059 !! test
19060 Section replacement test (section 0)
19061 !! options
19062 replace=0,"xxx"
19063 !! wikitext
19064 start
19065 ==a==
19066 ===aa===
19067 ====aaa====
19068 ==b==
19069 ===ba===
19070 ===bb===
19071 ====bba====
19072 ===bc===
19073 ==c==
19074 ===ca===
19075 !! html/php
19076 xxx
19077
19078 ==a==
19079 ===aa===
19080 ====aaa====
19081 ==b==
19082 ===ba===
19083 ===bb===
19084 ====bba====
19085 ===bc===
19086 ==c==
19087 ===ca===
19088 !! end
19089
19090 !! test
19091 Section replacement test (section 1)
19092 !! options
19093 replace=1,"xxx"
19094 !! wikitext
19095 start
19096 ==a==
19097 ===aa===
19098 ====aaa====
19099 ==b==
19100 ===ba===
19101 ===bb===
19102 ====bba====
19103 ===bc===
19104 ==c==
19105 ===ca===
19106 !! html/php
19107 start
19108 xxx
19109
19110 ==b==
19111 ===ba===
19112 ===bb===
19113 ====bba====
19114 ===bc===
19115 ==c==
19116 ===ca===
19117 !! end
19118
19119 !! test
19120 Section replacement test (section 2)
19121 !! options
19122 replace=2,"xxx"
19123 !! wikitext
19124 start
19125 ==a==
19126 ===aa===
19127 ====aaa====
19128 ==b==
19129 ===ba===
19130 ===bb===
19131 ====bba====
19132 ===bc===
19133 ==c==
19134 ===ca===
19135 !! html/php
19136 start
19137 ==a==
19138 xxx
19139
19140 ==b==
19141 ===ba===
19142 ===bb===
19143 ====bba====
19144 ===bc===
19145 ==c==
19146 ===ca===
19147 !! end
19148
19149 !! test
19150 Section replacement test (section 3)
19151 !! options
19152 replace=3,"xxx"
19153 !! wikitext
19154 start
19155 ==a==
19156 ===aa===
19157 ====aaa====
19158 ==b==
19159 ===ba===
19160 ===bb===
19161 ====bba====
19162 ===bc===
19163 ==c==
19164 ===ca===
19165 !! html/php
19166 start
19167 ==a==
19168 ===aa===
19169 xxx
19170
19171 ==b==
19172 ===ba===
19173 ===bb===
19174 ====bba====
19175 ===bc===
19176 ==c==
19177 ===ca===
19178 !! end
19179
19180 !! test
19181 Section replacement test (section 4)
19182 !! options
19183 replace=4,"xxx"
19184 !! wikitext
19185 start
19186 ==a==
19187 ===aa===
19188 ====aaa====
19189 ==b==
19190 ===ba===
19191 ===bb===
19192 ====bba====
19193 ===bc===
19194 ==c==
19195 ===ca===
19196 !! html/php
19197 start
19198 ==a==
19199 ===aa===
19200 ====aaa====
19201 xxx
19202
19203 ==c==
19204 ===ca===
19205 !! end
19206
19207 !! test
19208 Section replacement test (section 5)
19209 !! options
19210 replace=5,"xxx"
19211 !! wikitext
19212 start
19213 ==a==
19214 ===aa===
19215 ====aaa====
19216 ==b==
19217 ===ba===
19218 ===bb===
19219 ====bba====
19220 ===bc===
19221 ==c==
19222 ===ca===
19223 !! html/php
19224 start
19225 ==a==
19226 ===aa===
19227 ====aaa====
19228 ==b==
19229 xxx
19230
19231 ===bb===
19232 ====bba====
19233 ===bc===
19234 ==c==
19235 ===ca===
19236 !! end
19237
19238 !! test
19239 Section replacement test (section 6)
19240 !! options
19241 replace=6,"xxx"
19242 !! wikitext
19243 start
19244 ==a==
19245 ===aa===
19246 ====aaa====
19247 ==b==
19248 ===ba===
19249 ===bb===
19250 ====bba====
19251 ===bc===
19252 ==c==
19253 ===ca===
19254 !! html/php
19255 start
19256 ==a==
19257 ===aa===
19258 ====aaa====
19259 ==b==
19260 ===ba===
19261 xxx
19262
19263 ===bc===
19264 ==c==
19265 ===ca===
19266 !! end
19267
19268 !! test
19269 Section replacement test (section 7)
19270 !! options
19271 replace=7,"xxx"
19272 !! wikitext
19273 start
19274 ==a==
19275 ===aa===
19276 ====aaa====
19277 ==b==
19278 ===ba===
19279 ===bb===
19280 ====bba====
19281 ===bc===
19282 ==c==
19283 ===ca===
19284 !! html/php
19285 start
19286 ==a==
19287 ===aa===
19288 ====aaa====
19289 ==b==
19290 ===ba===
19291 ===bb===
19292 xxx
19293
19294 ===bc===
19295 ==c==
19296 ===ca===
19297 !! end
19298
19299 !! test
19300 Section replacement test (section 8)
19301 !! options
19302 replace=8,"xxx"
19303 !! wikitext
19304 start
19305 ==a==
19306 ===aa===
19307 ====aaa====
19308 ==b==
19309 ===ba===
19310 ===bb===
19311 ====bba====
19312 ===bc===
19313 ==c==
19314 ===ca===
19315 !! html/php
19316 start
19317 ==a==
19318 ===aa===
19319 ====aaa====
19320 ==b==
19321 ===ba===
19322 ===bb===
19323 ====bba====
19324 xxx
19325
19326 ==c==
19327 ===ca===
19328 !!end
19329
19330 !! test
19331 Section replacement test (section 9)
19332 !! options
19333 replace=9,"xxx"
19334 !! wikitext
19335 start
19336 ==a==
19337 ===aa===
19338 ====aaa====
19339 ==b==
19340 ===ba===
19341 ===bb===
19342 ====bba====
19343 ===bc===
19344 ==c==
19345 ===ca===
19346 !! html/php
19347 start
19348 ==a==
19349 ===aa===
19350 ====aaa====
19351 ==b==
19352 ===ba===
19353 ===bb===
19354 ====bba====
19355 ===bc===
19356 xxx
19357 !! end
19358
19359 !! test
19360 Section replacement test (section 10)
19361 !! options
19362 replace=10,"xxx"
19363 !! wikitext
19364 start
19365 ==a==
19366 ===aa===
19367 ====aaa====
19368 ==b==
19369 ===ba===
19370 ===bb===
19371 ====bba====
19372 ===bc===
19373 ==c==
19374 ===ca===
19375 !! html/php
19376 start
19377 ==a==
19378 ===aa===
19379 ====aaa====
19380 ==b==
19381 ===ba===
19382 ===bb===
19383 ====bba====
19384 ===bc===
19385 ==c==
19386 xxx
19387 !! end
19388
19389 !! test
19390 Section replacement test with initial whitespace (T15728)
19391 !! options
19392 replace=2,"xxx"
19393 !! wikitext
19394 Preformatted initial line
19395 ==a==
19396 ===a===
19397 !! html/php
19398 Preformatted initial line
19399 ==a==
19400 xxx
19401 !! end
19402
19403
19404 !! test
19405 Section extraction, heading followed by pre with 20 spaces (T8398)
19406 !! options
19407 section=1
19408 !! wikitext
19409 ==a==
19410 a
19411 !! html/php
19412 ==a==
19413 a
19414 !! end
19415
19416 !! test
19417 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
19418 !! options
19419 section=1
19420 !! wikitext
19421 ==a==
19422 a
19423 !! html/php
19424 ==a==
19425 a
19426 !! end
19427
19428
19429 !! test
19430 Section extraction, <pre> around bogus header (T12309)
19431 !! options
19432 section=2
19433 !! wikitext
19434 == Section One ==
19435 <pre>
19436 =======
19437 </pre>
19438
19439 == Section Two ==
19440 stuff
19441 !! html/php
19442 == Section Two ==
19443 stuff
19444 !! end
19445
19446 !! test
19447 Section replacement, <pre> around bogus header (T12309)
19448 !! options
19449 replace=2,"xxx"
19450 !! wikitext
19451 == Section One ==
19452 <pre>
19453 =======
19454 </pre>
19455
19456 == Section Two ==
19457 stuff
19458 !! html/php
19459 == Section One ==
19460 <pre>
19461 =======
19462 </pre>
19463
19464 xxx
19465 !! end
19466
19467 !! test
19468 Handling of &#x0A; in URLs
19469 !! wikitext
19470 ** irc://&#x0A;a
19471 !! html/php
19472 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
19473
19474 !! html/parsoid
19475 <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>
19476 !! end
19477
19478 !! test
19479 Handling of %0A in URLs
19480 !! wikitext
19481 ** irc://%0Aa
19482 !! html/php
19483 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
19484
19485 !! html/parsoid
19486 <ul><li><ul><li> <a rel="mw:ExtLink" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
19487 !! end
19488
19489 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
19490 !! test
19491 5 quotes, code coverage +1 line
19492 !! options
19493 parsoid=wt2html
19494 !! wikitext
19495 '''''
19496 !! html/php
19497 !! html/parsoid
19498 <p><b><i></i></b></p>
19499 !! end
19500
19501 # same html as previous, but wikitext adjusted to match parsoid html2wt
19502 # note that wt2html and html2html will put the <i> before the <b>
19503 !! test
19504 5 quotes, code coverage +1 line w/ nowiki (1)
19505 !! options
19506 parsoid=wt2wt,html2wt
19507 !! wikitext
19508 '''''<nowiki/>'''''
19509 !! html/php
19510 <p><i></i>
19511 </p>
19512 !! html/parsoid
19513 <p><b><i></i></b></p>
19514 !! end
19515
19516 # same as previous, just swapping the <i> and <b>
19517 !! test
19518 5 quotes, code coverage +1 line w/ nowiki (2)
19519 !! wikitext
19520 '''''<nowiki/>'''''
19521 !! html/php
19522 <p><i></i>
19523 </p>
19524 !! html/parsoid
19525 <p><i><b></b></i></p>
19526 !! end
19527
19528 !! test
19529 Special:Search page linking.
19530 !! wikitext
19531 {{Special:search}}
19532 !! html
19533 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
19534 </p>
19535 !! end
19536
19537 !! test
19538 {{!}} is a magic word
19539 !! wikitext
19540 {{!}} is a magic word there and {{!}} is still a magic word here
19541 | is not a magic word here but {{!}} is still a magic word here
19542 !! html/php
19543 <p>| is a magic word there and | is still a magic word here
19544 | is not a magic word here but | is still a magic word here
19545 </p>
19546 !! html/parsoid
19547 <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
19548 | 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>
19549 !! end
19550
19551 !! test
19552 Say the magic word
19553 !! options
19554 title=[[Parser test]]
19555 !! wikitext
19556 * {{PAGENAME}}
19557 * {{PAGENAMEE}}
19558 * {{FULLPAGENAME}}
19559 * {{FULLPAGENAMEE}}
19560 * {{BASEPAGENAME}}
19561 * {{BASEPAGENAMEE}}
19562 * {{SUBPAGENAME}}
19563 * {{SUBPAGENAMEE}}
19564 * {{ROOTPAGENAME}}
19565 * {{ROOTPAGENAMEE}}
19566 * {{TALKPAGENAME}}
19567 * {{TALKPAGENAMEE}}
19568 * {{SUBJECTPAGENAME}}
19569 * {{SUBJECTPAGENAMEE}}
19570 * {{NAMESPACEE}}
19571 * {{NAMESPACE}}
19572 * {{NAMESPACENUMBER}}
19573 * {{TALKSPACE}}
19574 * {{TALKSPACEE}}
19575 * {{SUBJECTSPACE}}
19576 * {{SUBJECTSPACEE}}
19577 * {{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
19578 !! html
19579 <ul><li> Parser test</li>
19580 <li> Parser_test</li>
19581 <li> Parser test</li>
19582 <li> Parser_test</li>
19583 <li> Parser test</li>
19584 <li> Parser_test</li>
19585 <li> Parser test</li>
19586 <li> Parser_test</li>
19587 <li> Parser test</li>
19588 <li> Parser_test</li>
19589 <li> Talk:Parser test</li>
19590 <li> Talk:Parser_test</li>
19591 <li> Parser test</li>
19592 <li> Parser_test</li>
19593 <li> </li>
19594 <li> </li>
19595 <li> 0</li>
19596 <li> Talk</li>
19597 <li> Talk</li>
19598 <li> </li>
19599 <li> </li>
19600 <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>
19601
19602 !! end
19603 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
19604
19605 !! test
19606 Gallery with valid attributes
19607 !! wikitext
19608 <gallery type="123" summary="345">
19609 File:File:Foobar.jpg
19610 </gallery>
19611 !! html/php
19612 <ul class="gallery mw-gallery-traditional" type="123">
19613 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19614 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
19615 <div class="gallerytext">
19616 </div>
19617 </div></li>
19618 </ul>
19619
19620 !! html/parsoid
19621 <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"}}'>
19622 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:File:Foobar.jpg</span></div><div class="gallerytext"></div></li>
19623 </ul>
19624 !! end
19625
19626 ## Parsoid thinks the "centre" here is a property, not a caption.
19627 !! test
19628 Gallery
19629 !! options
19630 parsoid={
19631 "modes": ["wt2html"],
19632 "nativeGallery": true
19633 }
19634 !! wikitext
19635 <gallery>
19636 image1.png |
19637 image2.gif|||||
19638
19639 image3|
19640 image4 |300px| centre
19641 image5.svg| http://///////
19642 [[x|xx]]]]
19643 * image6
19644 </gallery>
19645 !! html/php
19646 <ul class="gallery mw-gallery-traditional">
19647 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19648 <div class="thumb" style="height: 150px;">Image1.png</div>
19649 <div class="gallerytext">
19650 </div>
19651 </div></li>
19652 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19653 <div class="thumb" style="height: 150px;">Image2.gif</div>
19654 <div class="gallerytext">
19655 </div>
19656 </div></li>
19657 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19658 <div class="thumb" style="height: 150px;">Image3</div>
19659 <div class="gallerytext">
19660 </div>
19661 </div></li>
19662 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19663 <div class="thumb" style="height: 150px;">Image4</div>
19664 <div class="gallerytext">
19665 <pre>centre
19666 </pre>
19667 </div>
19668 </div></li>
19669 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19670 <div class="thumb" style="height: 150px;">Image5.svg</div>
19671 <div class="gallerytext">
19672 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
19673 </p>
19674 </div>
19675 </div></li>
19676 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19677 <div class="thumb" style="height: 150px;">* image6</div>
19678 <div class="gallerytext">
19679 </div>
19680 </div></li>
19681 </ul>
19682
19683 !! html/parsoid
19684 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19685 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">image1.png </span></div><div class="gallerytext"></div></li>
19686 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">image2.gif</span></div><div class="gallerytext"></div></li>
19687 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">image3</span></div><div class="gallerytext"></div></li>
19688 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">image4 </span></div><div class="gallerytext"></div></li>
19689 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;"> image5.svg</span></div><div class="gallerytext"> <a rel="mw:ExtLink" href="http://///////">http://///////</a></div></li>
19690 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">* image6</span></div><div class="gallerytext"></div></li>
19691 </ul>
19692 !! end
19693
19694 !! test
19695 Gallery (with options, html)
19696 !! options
19697 parsoid={
19698 "modes": ["wt2html", "html2html"],
19699 "nativeGallery": true
19700 }
19701 !! wikitext
19702 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
19703 File:Nonexistent.jpg|caption
19704 File:Nonexistent.jpg
19705 image:foobar.jpg|some '''caption''' [[Main Page]]
19706 image:foobar.jpg
19707 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
19708 </gallery>
19709 !! html/php
19710 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
19711 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
19712 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19713 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19714 <div class="gallerytext">
19715 <p>caption
19716 </p>
19717 </div>
19718 </div></li>
19719 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19720 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19721 <div class="gallerytext">
19722 </div>
19723 </div></li>
19724 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19725 <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>
19726 <div class="gallerytext">
19727 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
19728 </p>
19729 </div>
19730 </div></li>
19731 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19732 <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>
19733 <div class="gallerytext">
19734 </div>
19735 </div></li>
19736 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19737 <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>
19738 <div class="gallerytext">
19739 <p>blabla.
19740 </p>
19741 </div>
19742 </div></li>
19743 </ul>
19744
19745 !! html/parsoid
19746 <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":{}}'>
19747 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
19748 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Nonexistent.jpg</span></div><div class="gallerytext">caption</div></li>
19749 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Nonexistent.jpg</span></div><div class="gallerytext"></div></li>
19750 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
19751 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
19752 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
19753 </ul>
19754 !! end
19755
19756 !! test
19757 Gallery (with options, extsrc)
19758 !! options
19759 parsoid={
19760 "nativeGallery": false
19761 }
19762 !! wikitext
19763 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
19764 File:Nonexistent.jpg|caption
19765 File:Nonexistent.jpg
19766 image:foobar.jpg|some '''caption''' [[Main Page]]
19767 image:foobar.jpg
19768 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
19769 </gallery>
19770 !! html/php
19771 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
19772 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
19773 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19774 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19775 <div class="gallerytext">
19776 <p>caption
19777 </p>
19778 </div>
19779 </div></li>
19780 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19781 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19782 <div class="gallerytext">
19783 </div>
19784 </div></li>
19785 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19786 <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>
19787 <div class="gallerytext">
19788 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
19789 </p>
19790 </div>
19791 </div></li>
19792 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19793 <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>
19794 <div class="gallerytext">
19795 </div>
19796 </div></li>
19797 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19798 <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>
19799 <div class="gallerytext">
19800 <p>blabla.
19801 </p>
19802 </div>
19803 </div></li>
19804 </ul>
19805
19806 !! html/parsoid
19807 <ul class="gallery mw-gallery-traditional" style="max-width: 226px; _width: 226px;" typeof="mw:Extension/gallery" about="#mwt3" data-parsoid='{}' 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"}}'>
19808 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
19809 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Nonexistent.jpg</span></div><div class="gallerytext">caption</div></li>
19810 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Nonexistent.jpg</span></div><div class="gallerytext"></div></li>
19811 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
19812 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
19813 <li class="gallerybox" style="width: 105px;"><div class="thumb" style="width: 100px; height: 70px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
19814 </ul>
19815 !! end
19816
19817 !! test
19818 Gallery with link that has fragment
19819 !! options
19820 parsoid={
19821 "modes": ["wt2html", "html2html"],
19822 "nativeGallery": true
19823 }
19824 !! wikitext
19825 <gallery>
19826 image:foobar.jpg|link=Main_Page
19827 image:foobar.jpg|link=Main_Page#section
19828 image:foobar.jpg|link=Main Page#section|caption
19829 </gallery>
19830 !! html/php
19831 <ul class="gallery mw-gallery-traditional">
19832 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19833 <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>
19834 <div class="gallerytext">
19835 </div>
19836 </div></li>
19837 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19838 <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>
19839 <div class="gallerytext">
19840 </div>
19841 </div></li>
19842 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19843 <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>
19844 <div class="gallerytext">
19845 <p>caption
19846 </p>
19847 </div>
19848 </div></li>
19849 </ul>
19850
19851 !! html/parsoid
19852 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19853 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
19854 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
19855 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
19856 </ul>
19857 !! end
19858
19859 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
19860 !! test
19861 Gallery with template inside caption
19862 !! options
19863 parsoid={
19864 "nativeGallery": true
19865 }
19866 !! wikitext
19867 <gallery caption="{{echo|hi}}">
19868 File:Foobar.jpg|{{echo|ho}}
19869 </gallery>
19870 !! html/php
19871 <ul class="gallery mw-gallery-traditional">
19872 <li class='gallerycaption'>{{echo|hi}}</li>
19873 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19874 <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>
19875 <div class="gallerytext">
19876 <p>ho
19877 </p>
19878 </div>
19879 </div></li>
19880 </ul>
19881
19882 !! html/parsoid
19883 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19884 <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>
19885 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
19886 </ul>
19887 !! end
19888
19889 !! test
19890 Gallery with wikitext inside caption
19891 !! options
19892 parsoid={
19893 "nativeGallery": true
19894 }
19895 !! wikitext
19896 <gallery>
19897 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
19898 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
19899 </gallery>
19900 !! html/php
19901 <ul class="gallery mw-gallery-traditional">
19902 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19903 <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>
19904 <div class="gallerytext">
19905 <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>
19906 </p>
19907 </div>
19908 </div></li>
19909 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19910 <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>
19911 <div class="gallerytext">
19912 <p>This is a test template
19913 </p>
19914 </div>
19915 </div></li>
19916 </ul>
19917
19918 !! html/parsoid
19919 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19920 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
19921 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
19922 </ul>
19923 !! end
19924
19925 !! test
19926 Gallery (with showfilename option)
19927 !! options
19928 parsoid={
19929 "nativeGallery": true
19930 }
19931 !! wikitext
19932 <gallery showfilename="">
19933 File:Nonexistent.jpg|caption
19934 File:Nonexistent.jpg
19935 File:Foobar.jpg|some '''caption''' [[Main Page]]
19936 File:Foobar.jpg
19937 </gallery>
19938 !! html/php
19939 <ul class="gallery mw-gallery-traditional">
19940 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19941 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
19942 <div class="gallerytext">
19943 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
19944 caption
19945 </p>
19946 </div>
19947 </div></li>
19948 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19949 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
19950 <div class="gallerytext">
19951 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
19952 </p>
19953 </div>
19954 </div></li>
19955 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19956 <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>
19957 <div class="gallerytext">
19958 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
19959 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
19960 </p>
19961 </div>
19962 </div></li>
19963 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19964 <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>
19965 <div class="gallerytext">
19966 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
19967 </p>
19968 </div>
19969 </div></li>
19970 </ul>
19971
19972 !! html/parsoid
19973 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
19974 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Nonexistent.jpg</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>
19975 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Nonexistent.jpg</span></div><div class="gallerytext"><a href="./File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">File:Nonexistent.jpg</a></div></li>
19976 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
19977 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
19978 </ul>
19979 !! end
19980
19981 ## Should Parsoid be preserving these variations?
19982 !! test
19983 Gallery (with namespace-less filenames)
19984 !! options
19985 parsoid={
19986 "modes": ["wt2html", "html2html"],
19987 "nativeGallery": true
19988 }
19989 !! wikitext
19990 <gallery>
19991 File:Nonexistent.jpg
19992 Nonexistent.jpg
19993 image:foobar.jpg
19994 foobar.jpg
19995 </gallery>
19996 !! html/php
19997 <ul class="gallery mw-gallery-traditional">
19998 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19999 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20000 <div class="gallerytext">
20001 </div>
20002 </div></li>
20003 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20004 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20005 <div class="gallerytext">
20006 </div>
20007 </div></li>
20008 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20009 <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>
20010 <div class="gallerytext">
20011 </div>
20012 </div></li>
20013 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20014 <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>
20015 <div class="gallerytext">
20016 </div>
20017 </div></li>
20018 </ul>
20019
20020 !! html/parsoid
20021 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20022 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Nonexistent.jpg</span></div><div class="gallerytext"></div></li>
20023 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">Nonexistent.jpg</span></div><div class="gallerytext"></div></li>
20024 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
20025 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
20026 </ul>
20027 !! end
20028
20029 !! test
20030 Gallery override link with WikiLink (T36852)
20031 !! options
20032 parsoid={
20033 "nativeGallery": true
20034 }
20035 !! wikitext
20036 <gallery>
20037 File:Foobar.jpg|alt=galleryalt|link=InterWikiLink
20038 </gallery>
20039 !! html/php
20040 <ul class="gallery mw-gallery-traditional">
20041 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20042 <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>
20043 <div class="gallerytext">
20044 </div>
20045 </div></li>
20046 </ul>
20047
20048 !! html/parsoid
20049 <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":{}}'>
20050 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
20051 </ul>
20052 !! end
20053
20054 !! test
20055 Gallery override link with absolute external link (T36852)
20056 !! options
20057 parsoid={
20058 "nativeGallery": true
20059 }
20060 !! wikitext
20061 <gallery>
20062 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
20063 </gallery>
20064 !! html/php
20065 <ul class="gallery mw-gallery-traditional">
20066 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20067 <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>
20068 <div class="gallerytext">
20069 </div>
20070 </div></li>
20071 </ul>
20072
20073 !! html/parsoid
20074 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20075 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
20076 </ul>
20077 !! end
20078
20079 !! test
20080 Gallery override link with absolute external link with LanguageConverter
20081 !! options
20082 language=zh
20083 !! input
20084 <gallery>
20085 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
20086 </gallery>
20087 !! result
20088 <ul class="gallery mw-gallery-traditional">
20089 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20090 <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>
20091 <div class="gallerytext">
20092 <p>caption
20093 </p>
20094 </div>
20095 </div></li>
20096 </ul>
20097
20098 !! end
20099
20100 !! test
20101 Gallery override link with malicious javascript (T36852)
20102 !! options
20103 parsoid={
20104 "modes": ["wt2html", "html2html"],
20105 "nativeGallery": true
20106 }
20107 !! wikitext
20108 <gallery>
20109 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
20110 </gallery>
20111 !! html/php
20112 <ul class="gallery mw-gallery-traditional">
20113 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20114 <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>
20115 <div class="gallerytext">
20116 </div>
20117 </div></li>
20118 </ul>
20119
20120 !! html/parsoid
20121 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20122 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
20123 </ul>
20124 !! end
20125
20126 !! test
20127 Gallery with invalid title as link (T45964)
20128 !! options
20129 parsoid={
20130 "modes": ["wt2html", "html2html"],
20131 "nativeGallery": true
20132 }
20133 !! wikitext
20134 <gallery>
20135 File:Foobar.jpg|link=<
20136 </gallery>
20137 !! html/php
20138 <ul class="gallery mw-gallery-traditional">
20139 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20140 <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>
20141 <div class="gallerytext">
20142 </div>
20143 </div></li>
20144 </ul>
20145
20146 !! html/parsoid
20147 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20148 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
20149 </ul>
20150 !! end
20151
20152 !! test
20153 Serialize gallery without attrs in data-mw
20154 !! options
20155 parsoid={
20156 "modes": ["html2wt"],
20157 "nativeGallery": true
20158 }
20159 !! html/parsoid
20160 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
20161 <li class="gallerycaption">123</li>
20162 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Test.png</span></div><div class="gallerytext"></div></li>
20163 </ul>
20164 !! wikitext
20165 <gallery caption="123">
20166 File:Test.png
20167 </gallery>
20168 !! end
20169
20170 !! test
20171 Gallery with class and style attributes
20172 !! options
20173 parsoid={
20174 "nativeGallery": true
20175 }
20176 !! wikitext
20177 <gallery class="center" style="text-align: center;">
20178 File:Foobar.jpg
20179 </gallery>
20180 !! html/php
20181 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
20182 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20183 <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>
20184 <div class="gallerytext">
20185 </div>
20186 </div></li>
20187 </ul>
20188
20189 !! html/parsoid
20190 <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":{}}'>
20191 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><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>
20192 </ul>
20193 !! end
20194
20195 !! test
20196 Gallery in slideshow mode
20197 !! options
20198 parsoid={
20199 "nativeGallery": true
20200 }
20201 !! wikitext
20202 <gallery mode="slideshow" showthumbnails="">
20203 File:Foobar.jpg
20204 </gallery>
20205 !! html/php
20206 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
20207 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20208 <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>
20209 <div class="gallerytext">
20210 </div>
20211 </div></li>
20212 </ul>
20213
20214 !! html/parsoid
20215 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
20216 <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>
20217 </ul>
20218 !! end
20219
20220 !! test
20221 HTML Hex character encoding (spells the word "JavaScript")
20222 !! options
20223 parsoid=wt2html,wt2wt,html2html
20224 !! wikitext
20225 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
20226 !! html/php
20227 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
20228 </p>
20229 !! html/php+tidy
20230 <p>JavaScript</p>
20231 !! html/parsoid
20232 <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>
20233 !! end
20234
20235 !! test
20236 HTML Hex character encoding bogus encoding (T28437 regression check)
20237 !! wikitext
20238 &#xsee;&#XSEE;
20239 !! html/php
20240 <p>&amp;#xsee;&amp;#XSEE;
20241 </p>
20242 !! html/parsoid
20243 <p>&amp;#xsee;&amp;#XSEE;</p>
20244 !! end
20245
20246 !! test
20247 HTML Hex character encoding mixed case
20248 !! options
20249 parsoid=wt2html,wt2wt,html2html
20250 !! wikitext
20251 &#xEE;&#Xee;
20252 !! html/php
20253 <p>&#xee;&#xee;
20254 </p>
20255 !! html/php+tidy
20256 <p>îî</p>
20257 !! html/parsoid
20258 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
20259 !! end
20260
20261 # See: https://www.w3.org/TR/html5/syntax.html#character-references
20262 # Note that U+000C (form feed) is not a valid XML character, so
20263 # it is banned even though allowed in HTML5.
20264 !! test
20265 Illegal character references (T106578)
20266 !! wikitext
20267 ; Null: &#00;
20268 ; FF: &#xC;
20269 ; CR: &#xD;
20270 ; Control (low): &#8;
20271 ; Control (high): &#x7F; &#x9F;
20272 ; Surrogate: &#xD83D;&#xDCA9;
20273 ; This is an okay astral character: &#x1F4A9;
20274 !! html+tidy
20275 <dl>
20276 <dt>Null</dt>
20277 <dd>&amp;#00;</dd>
20278 <dt>FF</dt>
20279 <dd>&amp;#xC;</dd>
20280 <dt>CR</dt>
20281 <dd>&amp;#xD;</dd>
20282 <dt>Control (low)</dt>
20283 <dd>&amp;#8;</dd>
20284 <dt>Control (high)</dt>
20285 <dd>&amp;#x7F; &amp;#x9F;</dd>
20286 <dt>Surrogate</dt>
20287 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
20288 <dt>This is an okay astral character</dt>
20289 <dd>💩</dd>
20290 </dl>
20291 !! end
20292
20293 !! test
20294 __FORCETOC__ override
20295 !! wikitext
20296 __NEWSECTIONLINK__
20297 __FORCETOC__
20298 !! html/php
20299 <p><br />
20300 </p>
20301 !! end
20302
20303 !! test
20304 ISBN code coverage
20305 !! wikitext
20306 ISBN 978-0-1234-56&#x20;789
20307 !! html
20308 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
20309 </p>
20310 !! html+tidy
20311 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a> 789</p>
20312 !! html/parsoid
20313 <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>
20314 !! end
20315
20316 !! test
20317 ISBN followed by 5 spaces
20318 !! wikitext
20319 ISBN
20320 !! html
20321 <p>ISBN
20322 </p>
20323 !! end
20324
20325 !! test
20326 Double ISBN
20327 !! wikitext
20328 ISBN ISBN 1234567890
20329 !! html/php
20330 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20331 </p>
20332 !! html/parsoid
20333 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
20334 !! end
20335
20336 # Uppercase X and lowercase x as well
20337 !! test
20338 ISBN with an X
20339 !! wikitext
20340 ISBN 3-462-04561-X
20341 ISBN 3-462-04561-x
20342 ISBN 080442957X
20343 ISBN 080442957x
20344 ISBN 978080442957X
20345 ISBN 978080442957x
20346 !! html/php
20347 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
20348 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
20349 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
20350 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
20351 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
20352 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
20353 </p>
20354 !! html/parsoid
20355 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
20356 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
20357 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
20358 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
20359 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
20360 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
20361 !! end
20362
20363 !! test
20364 ISBN with empty prefix (parsoid test)
20365 !! wikitext
20366 ISBN 1234567890
20367 !! html/php
20368 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20369 </p>
20370 !! html/parsoid
20371 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
20372 !! end
20373
20374 !! test
20375 T24905: <abbr> followed by ISBN followed by </a>
20376 !! wikitext
20377 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
20378 !! html/php
20379 <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>
20380 </p>
20381 !! html/parsoid
20382 <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>
20383 !! end
20384
20385 !! test
20386 Double RFC
20387 !! wikitext
20388 RFC RFC 1234
20389 !! html
20390 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a>
20391 </p>
20392 !! end
20393
20394 !! test
20395 Double RFC with a wiki link
20396 !! wikitext
20397 RFC [[RFC 1234]]
20398 !! html
20399 <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>
20400 </p>
20401 !! end
20402
20403 !! test
20404 RFC code coverage
20405 !! wikitext
20406 RFC 983&#x20;987
20407 !! html
20408 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
20409 </p>
20410 !! html+tidy
20411 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a> 987</p>
20412 !! end
20413
20414 !! test
20415 Centre-aligned image
20416 !! wikitext
20417 [[Image:foobar.jpg|centre]]
20418 !! html
20419 <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>
20420
20421 !!end
20422
20423 !! test
20424 None-aligned image
20425 !! wikitext
20426 [[Image:foobar.jpg|none]]
20427 !! html
20428 <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>
20429
20430 !!end
20431
20432 !! test
20433 Width + Height sized image (using px) (height is ignored)
20434 !! wikitext
20435 [[Image:foobar.jpg|640x480px]]
20436 !! html
20437 <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>
20438 </p>
20439 !!end
20440
20441 !! test
20442 Width-sized image (using px, no following whitespace)
20443 !! wikitext
20444 [[Image:foobar.jpg|640px]]
20445 !! html
20446 <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>
20447 </p>
20448 !!end
20449
20450 !! test
20451 Width-sized image (using px, with following whitespace - test regression from r39467)
20452 !! wikitext
20453 [[Image:foobar.jpg|640px ]]
20454 !! html
20455 <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>
20456 </p>
20457 !!end
20458
20459 !! test
20460 Width-sized image (using px, with preceding whitespace - test regression from r39467)
20461 !! wikitext
20462 [[Image:foobar.jpg| 640px]]
20463 !! html
20464 <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>
20465 </p>
20466 !!end
20467
20468 !! test
20469 Image with page parameter
20470 !! options
20471 djvu
20472 !! wikitext
20473 [[File:LoremIpsum.djvu|page=2]]
20474 !! html/php
20475 <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>
20476 </p>
20477 !! html/parsoid
20478 <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>
20479 !! end
20480
20481 !! test
20482 Another italics / bold test
20483 !! wikitext
20484 ''' ''x'
20485 !! html
20486 <pre>'<i> </i>x'
20487 </pre>
20488 !!end
20489
20490 # FIXME: The php output seems broken. It's interleaving some open/close tags.
20491 !! test
20492 dt/dd/dl test
20493 !! wikitext
20494 :;;;::
20495 !! html/php
20496 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
20497
20498 !! html/parsoid
20499 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
20500
20501 !!end
20502
20503 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
20504 !! test
20505 Images with the "|" character in the comment
20506 !! wikitext
20507 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
20508 !! html/php
20509 <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>
20510
20511 !! html/parsoid
20512 <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>
20513 !! end
20514
20515 !! test
20516 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
20517 !! wikitext
20518 <html><script>alert(1);</script></html>
20519 !! html
20520 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
20521 </p>
20522 !! end
20523
20524 !! test
20525 HTML with raw HTML ($wgRawHtml==true)
20526 !! options
20527 wgRawHtml=1
20528 !! wikitext
20529 <html><script>alert(1);</script></html>
20530 !! html
20531 <p><script>alert(1);</script>
20532 </p>
20533 !! end
20534
20535 !! test
20536 Parents of subpages, one level up
20537 !! options
20538 subpage title=[[Subpage test/L1/L2/L3]]
20539 !! wikitext
20540 [[../|L2]]
20541 !! html
20542 <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>
20543 </p>
20544 !! end
20545
20546
20547 !! test
20548 Parents of subpages, one level up, not named
20549 !! options
20550 subpage title=[[Subpage test/L1/L2/L3]]
20551 !! wikitext
20552 [[../]]
20553 !! html
20554 <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>
20555 </p>
20556 !! end
20557
20558
20559
20560 !! test
20561 Parents of subpages, two levels up
20562 !! options
20563 subpage title=[[Subpage test/L1/L2/L3]]
20564 !! wikitext
20565 [[../../|L1]]2
20566
20567 [[../../|L1]]l
20568 !! html
20569 <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
20570 </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>
20571 </p>
20572 !! end
20573
20574 !! test
20575 Parents of subpages, two levels up, without trailing slash or name.
20576 !! options
20577 subpage title=[[Subpage test/L1/L2/L3]]
20578 !! wikitext
20579 [[../..]]
20580 !! html
20581 <p>[[../..]]
20582 </p>
20583 !! end
20584
20585 !! test
20586 Parents of subpages, two levels up, with lots of extra trailing slashes.
20587 !! options
20588 subpage title=[[Subpage test/L1/L2/L3]]
20589 !! wikitext
20590 [[../../////]]
20591 !! html
20592 <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>
20593 </p>
20594 !! end
20595
20596 !! article
20597 Subpage test/L1/L2/L3Sibling
20598 !! text
20599 Sibling article
20600 !! endarticle
20601
20602 !! test
20603 Transclusion of a sibling page (one level up)
20604 !! options
20605 subpage title=[[Subpage test/L1/L2/L3]]
20606 !! wikitext
20607 {{../L3Sibling}}
20608 !! html
20609 <p>Sibling article
20610 </p>
20611 !! end
20612
20613 !! test
20614 Transclusion of a child page
20615 !! options
20616 subpage title=[[Subpage test/L1/L2]]
20617 !! wikitext
20618 {{/L3Sibling}}
20619 !! html
20620 <p>Sibling article
20621 </p>
20622 !! end
20623
20624 # This is wt2html only in Parsoid because we add <nowiki>
20625 # because of {{..}} and we don't expect to fix that to
20626 # eliminate the nowikis selective for {{..}} markup.
20627 !! test
20628 Non-transclusion because of too many up levels
20629 !! options
20630 subpage title=[[Subpage test/L1/L2/L3]]
20631 parsoid=wt2html
20632 !! wikitext
20633 {{../../../../More than parent}}
20634 !! html/php
20635 <p>{{../../../../More than parent}}
20636 </p>
20637 !! html/parsoid
20638 <p>{{../../../../More than parent}}</p>
20639 !! end
20640
20641 !! test
20642 Definition list code coverage
20643 !! wikitext
20644 ; title : def
20645 ; title : def
20646 ;title: def
20647 !! html/php
20648 <dl><dt> title &#160;</dt>
20649 <dd> def</dd>
20650 <dt> title&#160;</dt>
20651 <dd> def</dd>
20652 <dt>title</dt>
20653 <dd> def</dd></dl>
20654
20655 !! html/parsoid
20656 <dl><dt> title <span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
20657 <dt> title<span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
20658 <dt>title</dt><dd> def</dd></dl>
20659 !! end
20660
20661 !! test
20662 Don't fall for the self-closing div
20663 !! wikitext
20664 <div>hello world</div/>
20665 !! html
20666 <div>hello world</div>
20667
20668 !! end
20669
20670 !! test
20671 MSGNW magic word
20672 !! wikitext
20673 {{MSGNW:msg}}
20674 !! html/php
20675 <p>&#91;&#91;:Template:Msg&#93;&#93;
20676 </p>
20677 !! end
20678
20679 !! test
20680 RAW magic word
20681 !! wikitext
20682 {{RAW:QUERTY}}
20683 !! html
20684 <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>
20685 </p>
20686 !! end
20687
20688 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
20689 !! test
20690 Always escape literal '>' in output, not just after '<'
20691 !! wikitext
20692 ><>
20693 !! html
20694 <p>&gt;&lt;&gt;
20695 </p>
20696 !! end
20697
20698 !! test
20699 Template caching
20700 !! wikitext
20701 {{Test}}
20702 {{Test}}
20703 !! html
20704 <p>This is a test template
20705 This is a test template
20706 </p>
20707 !! end
20708
20709
20710 !! article
20711 MediaWiki:Fake
20712 !! text
20713 ==header==
20714 !! endarticle
20715
20716 !! test
20717 Inclusion of !userCanEdit() content
20718 !! wikitext
20719 {{MediaWiki:Fake}}
20720 !! html
20721 <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>
20722
20723 !! end
20724
20725
20726 !! test
20727 Out-of-order TOC heading levels
20728 !! wikitext
20729 ==2==
20730 ======6======
20731 ===3===
20732 =1=
20733 =====5=====
20734 ==2==
20735 !! html
20736 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
20737 <ul>
20738 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
20739 <ul>
20740 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
20741 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
20742 </ul>
20743 </li>
20744 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
20745 <ul>
20746 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
20747 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
20748 </ul>
20749 </li>
20750 </ul>
20751 </div>
20752
20753 <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>
20754 <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>
20755 <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>
20756 <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>
20757 <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>
20758 <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>
20759
20760 !! end
20761
20762
20763 !! test
20764 ISBN with a dummy number
20765 !! wikitext
20766 ISBN ---
20767 !! html
20768 <p>ISBN ---
20769 </p>
20770 !! end
20771
20772
20773 !! test
20774 ISBN with space-delimited number
20775 !! wikitext
20776 ISBN 92 9017 032 8
20777 !! html/php
20778 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
20779 </p>
20780 !! html/parsoid
20781 <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>
20782 !! end
20783
20784
20785 !! test
20786 ISBN with multiple spaces, no number
20787 !! wikitext
20788 ISBN foo
20789 !! html
20790 <p>ISBN foo
20791 </p>
20792 !! end
20793
20794
20795 !! test
20796 ISBN length
20797 !! wikitext
20798 ISBN 123456789
20799
20800 ISBN 1234567890
20801
20802 ISBN 12345678901
20803 !! html/php
20804 <p>ISBN 123456789
20805 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20806 </p><p>ISBN 12345678901
20807 </p>
20808 !! html/parsoid
20809 <p>ISBN 123456789</p>
20810
20811 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
20812
20813 <p>ISBN 12345678901</p>
20814 !! end
20815
20816
20817 !! test
20818 ISBN with trailing year (T9110)
20819 !! wikitext
20820 ISBN 1-234-56789-0 - 2006
20821
20822 ISBN 1 234 56789 0 - 2006
20823 !! html/php
20824 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
20825 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
20826 </p>
20827 !! html/parsoid
20828 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
20829
20830 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
20831 !! end
20832
20833
20834 !! test
20835 anchorencode
20836 !! wikitext
20837 {{anchorencode:foo bar©#%n}}
20838 !! html
20839 <p>foo_bar.C2.A9.23.25n
20840 </p>
20841 !! end
20842
20843 !! test
20844 anchorencode trims spaces
20845 !! wikitext
20846 {{anchorencode: __pretty__please__}}
20847 !! html
20848 <p>pretty_please
20849 </p>
20850 !! end
20851
20852 !! test
20853 anchorencode deals with links
20854 !! wikitext
20855 {{anchorencode: [[hello|world]] [[hi]]}}
20856 !! html
20857 <p>world_hi
20858 </p>
20859 !! end
20860
20861 !! test
20862 anchorencode deals with templates
20863 !! wikitext
20864 {{anchorencode: {{Foo}} }}
20865 !! html
20866 <p>FOO
20867 </p>
20868 !! end
20869
20870 !! test
20871 anchorencode encodes like the TOC generator: (T20431)
20872 !! wikitext
20873 === _ +:.3A%3A&&amp;]] ===
20874 {{anchorencode: _ +:.3A%3A&&amp;]] }}
20875 __NOEDITSECTION__
20876 !! html
20877 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
20878 <p>.2B:.3A.253A.26.26.5D.5D
20879 </p>
20880 !! end
20881
20882 !! test
20883 T8200: blockquotes and paragraph formatting
20884 !! wikitext
20885 <blockquote>
20886 foo
20887 </blockquote>
20888
20889 bar
20890
20891 baz
20892 !! html
20893 <blockquote>
20894 <p>foo
20895 </p>
20896 </blockquote>
20897 <p>bar
20898 </p>
20899 <pre>baz
20900 </pre>
20901 !! end
20902
20903 !! test
20904 T10293: Use of center tag ruins paragraph formatting
20905 !! wikitext
20906 <center>
20907 foo
20908 </center>
20909
20910 bar
20911
20912 baz
20913 !! html
20914 <center>
20915 <p>foo
20916 </p>
20917 </center>
20918 <p>bar
20919 </p>
20920 <pre>baz
20921 </pre>
20922 !! end
20923
20924 !!test
20925 Parsing of overlapping (improperly nested) inline html tags
20926 !! wikitext
20927 <span><s>x</span></s>
20928 !! html/php
20929 <p><span><s>x&lt;/span&gt;</s></span>
20930 </p>
20931 !! html/parsoid
20932 <p><span><s>x</s></span>
20933 </p>
20934 !!end
20935
20936 ###
20937 ### Language variants related tests
20938 ###
20939 !! test
20940 Self-link in language variants
20941 !! options
20942 title=[[Dunav]] language=sr
20943 !! wikitext
20944 Both [[Dunav]] and [[Дунав]] are names for this river.
20945 !! html
20946 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
20947 </p>
20948 !!end
20949
20950 !! article
20951 Дуна
20952 !! text
20953 content
20954 !! endarticle
20955
20956 !! test
20957 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
20958 !! options
20959 title=[[Duna]] language=sr
20960 !! wikitext
20961 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
20962 !! html
20963 <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.
20964 </p>
20965 !! end
20966
20967 !! test
20968 Link to a section of a variant of this title shouldn't be parsed as self-link
20969 !! options
20970 title=[[Duna]] language=sr
20971 !! wikitext
20972 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
20973 !! html
20974 <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.
20975 </p>
20976 !! end
20977
20978 !! test
20979 Link to pages in language variants
20980 !! options
20981 language=sr
20982 !! wikitext
20983 Main Page can be written as [[Маин Паге]]
20984 !! html
20985 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
20986 </p>
20987 !!end
20988
20989
20990 !! test
20991 Multiple links to pages in language variants
20992 !! options
20993 language=sr
20994 !! wikitext
20995 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
20996 !! html
20997 <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>.
20998 </p>
20999 !!end
21000
21001
21002 !! test
21003 Simple template in language variants
21004 !! options
21005 language=sr
21006 !! wikitext
21007 {{тест}}
21008 !! html
21009 <p>This is a test template
21010 </p>
21011 !! end
21012
21013
21014 !! test
21015 Template with explicit namespace in language variants
21016 !! options
21017 language=sr
21018 !! wikitext
21019 {{Template:тест}}
21020 !! html
21021 <p>This is a test template
21022 </p>
21023 !! end
21024
21025
21026 !! test
21027 Basic test for template parameter in language variants
21028 !! options
21029 language=sr
21030 !! wikitext
21031 {{парамтест|param=foo}}
21032 !! html
21033 <p>This is a test template with parameter foo
21034 </p>
21035 !! end
21036
21037 !! test
21038 Simple category in language variants
21039 !! options
21040 language=sr cat
21041 !! wikitext
21042 [[Category:МедиаWики Усер'с Гуиде]]
21043 !! html/php
21044 cat=МедиаWики_Усер'с_Гуиде sort=
21045 !! html/parsoid
21046 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
21047 !! end
21048
21049 !! article
21050 Category:分类
21051 !! text
21052 blah
21053 !! endarticle
21054
21055 !! article
21056 Category:分類
21057 !! text
21058 blah
21059 !! endarticle
21060
21061 ## We used to, but no longer wt2wt this test since the default serializer
21062 ## will normalize all categories to serialize on their own line.
21063 ## This wikitext usage is going to be fairly uncommon in production and
21064 ## selser will take care of preserving formatting in those scenarios.
21065 !! test
21066 Don't convert blue categorylinks to another variant (T35210)
21067 !! options
21068 cat
21069 language=zh
21070 parsoid=wt2html
21071 !! wikitext
21072 [[A]][[Category:分类]]
21073 !! html/php
21074 cat=分类 sort=
21075 !! html/parsoid
21076 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
21077 <link rel="mw:PageProp/Category" href="./Category:分类"/>
21078 !! end
21079
21080 !! test
21081 Stripping -{}- tags (language variants)
21082 !! options
21083 language=sr
21084 !! wikitext
21085 Latin proverb: -{Ne nuntium necare}-
21086 !! html
21087 <p>Latin proverb: Ne nuntium necare
21088 </p>
21089 !! end
21090
21091
21092 !! test
21093 Prevent conversion with -{}- tags (language variants)
21094 !! options
21095 language=sr variant=sr-ec
21096 !! wikitext
21097 Latinski: -{Ne nuntium necare}-
21098 !! html
21099 <p>Латински: Ne nuntium necare
21100 </p>
21101 !! end
21102
21103
21104 !! test
21105 Prevent conversion of text with -{}- tags (language variants)
21106 !! options
21107 language=sr variant=sr-ec
21108 !! wikitext
21109 Latinski: -{Ne nuntium necare}-
21110 !! html
21111 <p>Латински: Ne nuntium necare
21112 </p>
21113 !! end
21114
21115
21116 !! test
21117 Prevent conversion of links with -{}- tags (language variants)
21118 !! options
21119 language=sr variant=sr-ec
21120 !! wikitext
21121 -{[[Main Page]]}-
21122 !! html
21123 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21124 </p>
21125 !! end
21126
21127
21128 !! test
21129 -{}- tags within headlines (within html for parserConvert())
21130 !! options
21131 language=sr variant=sr-ec
21132 !! wikitext
21133 == -{Naslov}- ==
21134 !! html
21135 <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>
21136
21137 !! end
21138
21139
21140 !! test
21141 Explicit definition of language variant alternatives
21142 !! options
21143 language=zh variant=zh-tw
21144 !! wikitext
21145 -{zh:China;zh-tw:Taiwan}-, not China
21146 !! html
21147 <p>Taiwan, not China
21148 </p>
21149 !! end
21150
21151
21152 !! test
21153 Conversion around HTML tags
21154 !! options
21155 language=sr variant=sr-ec
21156 !! wikitext
21157 -{H|span=>sr-ec:script;title=>sr-ec:src;}-
21158 <span title="La-{sr-el:L;sr-ec:C;}-tin">ski</span>
21159 !! html
21160 <p>
21161 <span title="ЛаCтин">ски</span>
21162 </p>
21163 !! end
21164
21165
21166 !! test
21167 Explicit session-wise language variant mapping (A flag and - flag)
21168 !! options
21169 language=zh variant=zh-tw
21170 !! wikitext
21171 Taiwan is not China.
21172 But -{A|zh:China;zh-tw:Taiwan}- is China,
21173 (This-{-|zh:China;zh-tw:Taiwan}- should be stripped!)
21174 and -{China}- is China.
21175 !! html
21176 <p>Taiwan is not China.
21177 But Taiwan is Taiwan,
21178 (This should be stripped!)
21179 and China is China.
21180 </p>
21181 !! end
21182
21183 !! test
21184 Explicit session-wise language variant mapping (H flag for hide)
21185 !! options
21186 language=zh variant=zh-tw
21187 !! wikitext
21188 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
21189 Taiwan is China.
21190 !! html
21191 <p>(This should be stripped!)
21192 Taiwan is Taiwan.
21193 </p>
21194 !! end
21195
21196 !! test
21197 Adding explicit conversion rule for title (T flag)
21198 !! options
21199 language=zh variant=zh-tw showtitle
21200 !! wikitext
21201 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
21202 !! html
21203 Taiwan
21204 <p>Should be stripped!
21205 </p>
21206 !! end
21207
21208 !! test
21209 Testing that changing the language variant here in the tests actually works
21210 !! options
21211 language=zh variant=zh showtitle
21212 !! wikitext
21213 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
21214 !! html
21215 China
21216 <p>Should be stripped!
21217 </p>
21218 !! end
21219
21220 !! test
21221 Recursive conversion of alt and title attrs shouldn't clear converter state
21222 !! options
21223 language=zh variant=zh-cn showtitle
21224 !! wikitext
21225 -{H|zh-cn:Exclamation;zh-tw:exclamation;}-
21226 Should be stripped-{T|zh-cn:China;zh-tw:Taiwan}-<span title="exclamation">!</span>
21227 !! html
21228 China
21229 <p>
21230 Should be stripped<span title="Exclamation">!</span>
21231 </p>
21232 !! end
21233
21234 !! test
21235 T26072: more test on conversion rule for title
21236 !! options
21237 language=zh variant=zh-tw showtitle
21238 !! wikitext
21239 This should be stripped-{T|zh:China;zh-tw:Taiwan}-!
21240 This won't take interferes with the title rule-{H|zh:Beijing;zh-tw:Taipei}-.
21241 !! html
21242 Taiwan
21243 <p>This should be stripped!
21244 This won't take interferes with the title rule.
21245 </p>
21246 !! end
21247
21248 !! test
21249 Partly disable title conversion if variant == main language code
21250 !! options
21251 language=zh variant=zh title=[[ZH]] showtitle
21252 !! wikitext
21253 -{T|zh-cn:CN;zh-tw:TW}-
21254 !! html
21255 ZH
21256 <p>
21257 </p>
21258 !! end
21259
21260 !! test
21261 Partly disable title conversion if variant == main language code, more
21262 !! options
21263 language=zh variant=zh title=[[ZH]] showtitle
21264 !! wikitext
21265 -{T|TW}-
21266 !! html
21267 ZH
21268 <p>
21269 </p>
21270 !! end
21271
21272 !! test
21273 Raw output of variant escape tags (R flag)
21274 !! options
21275 language=zh variant=zh-tw
21276 !! wikitext
21277 Raw: -{R|zh:China;zh-tw:Taiwan}-
21278 !! html
21279 <p>Raw: zh:China;zh-tw:Taiwan
21280 </p>
21281 !! end
21282
21283 !! test
21284 Nested markup inside raw output of variant escape tags (R flag)
21285 !! options
21286 language=zh variant=zh-tw
21287 !! wikitext
21288 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
21289 !! html
21290 <p>Nested raw: nested Taiwan nested
21291 </p>
21292 !! end
21293
21294 !! test
21295 Templates inside raw output of variant escape tags (R flag)
21296 !! options
21297 language=zh variant=zh-tw
21298 !! wikitext
21299 Nested raw: -{R|nested {{echo|hi}} templates}-
21300 !! html
21301 <p>Nested raw: nested hi templates
21302 </p>
21303 !! end
21304
21305 !! test
21306 Strings evaluating false shouldn't be ignored by Language converter (T51072)
21307 !! options
21308 language=zh variant=zh-cn
21309 !! input
21310 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
21311 !! result
21312 <p>0
21313 </p>
21314 !! end
21315
21316 !! test
21317 Conversion rules from [numeric-only string] to [something else] (T48634)
21318 !! options
21319 language=zh variant=zh-cn
21320 !! input
21321 -{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
21322 !! result
21323 <p>D12345EE12345
21324 </p>
21325 !! end
21326
21327 !! test
21328 Bidirectional converter rule entries with an empty value should be ignored (T53551)
21329 !! options
21330 language=zh variant=zh-cn
21331 !! input
21332 -{H|zh-cn:foo;zh-tw:;}-foobar
21333 !! result
21334 <p>foobar
21335 </p>
21336 !! end
21337
21338 !! test
21339 Unidirectional converter rule entries with an empty "from" string should be ignored (T53551)
21340 !! options
21341 language=zh variant=zh-cn
21342 !! input
21343 -{H|=>zh-cn:foo;}-foobar
21344 !! result
21345 <p>foobar
21346 </p>
21347 !! end
21348
21349 !! test
21350 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
21351 !! options
21352 language=zh variant=zh-cn
21353 !! input
21354 -{H|}-foobar
21355 !! result
21356 <p>foobar
21357 </p>
21358 !! end
21359
21360 !! test
21361 Nested using of manual convert syntax
21362 !! options
21363 language=zh variant=zh-hk
21364 !! wikitext
21365 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
21366 !! html
21367 <p>Nested: Hello Hong Kong!
21368 </p>
21369 !! end
21370
21371 !! test
21372 HTML markups with conversion syntax in attribs, nested in other conversion blocks
21373 !! options
21374 language=zh variant=zh-cn
21375 !! wikitext
21376 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
21377 !! html
21378 <p><span title="X">A</span>
21379 </p>
21380 !! end
21381
21382 !! test
21383 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet)
21384 !! options
21385 language=zh variant=zh-cn disabled
21386 !! wikitext
21387 -{<span title="-{X}-">A</span>}-
21388 !! html
21389 <p><span title="X">A</span>
21390 </p>
21391 !! end
21392
21393 # Since Parsoid is starting to emit canonical wikitext for links,
21394 # [http://example.com http://example.com] will not RT back to that
21395 # form anymore.
21396 !! test
21397 Proper conversion of text in external links
21398 !! options
21399 language=sr variant=sr-ec
21400 parsoid=wt2html
21401 !! wikitext
21402 http://www.google.com
21403 gopher://www.google.com
21404 [http://www.google.com http://www.google.com]
21405 [gopher://www.google.com gopher://www.google.com]
21406 [https://www.google.com irc://www.google.com]
21407 [ftp://www.google.com www.google.com/ftp://dir]
21408 [//www.google.com www.google.com]
21409 !! html/php
21410 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
21411 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
21412 <a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
21413 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
21414 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
21415 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
21416 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
21417 </p>
21418 !! html/parsoid
21419 <p><a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
21420 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
21421 <a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
21422 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
21423 <a rel="mw:ExtLink" href="https://www.google.com">irc://www.google.com</a>
21424 <a rel="mw:ExtLink" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
21425 <a rel="mw:ExtLink" href="//www.google.com">www.гоогле.цом</a></p>
21426 !! end
21427
21428 !! test
21429 Do not convert roman numbers to language variants
21430 !! options
21431 language=sr variant=sr-ec
21432 !! wikitext
21433 Fridrih IV je car.
21434 !! html
21435 <p>Фридрих IV је цар.
21436 </p>
21437 !! end
21438
21439 !! test
21440 Unclosed language converter markup "-{"
21441 !! options
21442 language=sr
21443 !! wikitext
21444 -{T|hello
21445 !! html
21446 <p>-{T|hello
21447 </p>
21448 !! end
21449
21450 !! test
21451 Don't convert raw rule "-{R|=&gt;}-" to "=>"
21452 !! options
21453 language=sr
21454 !! wikitext
21455 -{R|=&gt;}-
21456 !! html
21457 <p>=&gt;
21458 </p>
21459 !!end
21460
21461 !! test
21462 Don't break link parsing if language converter markup is in the caption.
21463 !! options
21464 language=sr variant=sr-ec
21465 !! wikitext
21466 [[Main Page|-{R|main page}-]]
21467 !! html
21468 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
21469 </p>
21470 !! end
21471
21472 !! test
21473 T146304: Don't break template parsing if language converter markup is in the parameter.
21474 !! options
21475 language=sr variant=sr-ec
21476 !! wikitext
21477 {{echo|-{R|foo}-}}
21478 !! html/php
21479 <p>foo
21480 </p>
21481 !! end
21482
21483 !! test
21484 T146305: Don't break image parsing if language converter markup is in the caption.
21485 !! options
21486 language=sr
21487 !! wikitext
21488 [[File:Foobar.jpg|thumb|-{R|caption:}-]]
21489 !! html/php
21490 <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>
21491
21492 !! html/parsoid
21493 <figure class="mw-default-size" typeof="mw:Image/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='{"disabled":true,"show":true,"text":"caption:"}'></span></figcaption></figure>
21494 !! end
21495
21496 !! test
21497 T146305: Don't break image parsing if nested language converter markup is in the caption.
21498 !! options
21499 language=zh variant=zh-cn
21500 !! wikitext
21501 [[File:Foobar.jpg|thumb|-{zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
21502 !! html/php
21503 <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>
21504
21505 !! html/parsoid
21506 <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><span typeof="mw:LanguageVariant" data-mw='{"bidir":[{"l":"zh-cn","t":"blog (hk: &lt;span typeof=\"mw:LanguageVariant\" data-parsoid=&#39;{\"fl\":[\"zh-hans\"],\"dsr\":[42,64,null,2]}&#39; data-mw=&#39;{\"filter\":[\"zh-hans\"],\"text\":\"WEBJOURNAL\"}&#39;>&lt;/span>, tw: &lt;span typeof=\"mw:LanguageVariant\" data-parsoid=&#39;{\"fl\":[\"zh-hans\"],\"dsr\":[70,88,null,2]}&#39; data-mw=&#39;{\"filter\":[\"zh-hans\"],\"text\":\"WEBLOG\"}&#39;>&lt;/span>)"}],"show":true}'></span></figcaption></figure>
21507 !! end
21508
21509 !! test
21510 Don't break gallery if language converter markup is inside.
21511 !! options
21512 language=zh
21513 !! wikitext
21514 <gallery>
21515 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
21516 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
21517 </gallery>
21518 !! html
21519 <ul class="gallery mw-gallery-traditional">
21520 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21521 <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>
21522 <div class="gallerytext">
21523 <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>
21524 </p>
21525 </div>
21526 </div></li>
21527 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21528 <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>
21529 <div class="gallerytext">
21530 <p>This is a test template
21531 </p>
21532 </div>
21533 </div></li>
21534 </ul>
21535
21536 !! end
21537
21538 !! test
21539 T153135: Don't break list handling if language converter markup is in the item.
21540 !! options
21541 language=zh variant=zh-cn
21542 !! wikitext
21543 ;-{zh-cn:AAA;zh-tw:BBB}-
21544 ;-{R|foo:bar}-
21545 !! html/php
21546 <dl><dt>AAA</dt>
21547 <dt>foo:bar</dt></dl>
21548
21549 !! html/parsoid
21550 <dl>
21551 <dt><span typeof="mw:LanguageVariant" data-mw='{"bidir":[{"l":"zh-cn","t":"AAA"},{"l":"zh-tw","t":"BBB"}],"show":true}'></span></dt>
21552 <dt><span typeof="mw:LanguageVariant" data-mw='{"disabled":true,"show":true,"text":"foo:bar"}'></span></dt>
21553 </dl>
21554 !! end
21555
21556 // Note that parsoid does not protect colons unless language converter
21557 // markup is properly nested, because it is a backtracking parser.
21558 !! test
21559 T153135: Unclosed markup in definition list (code coverage)
21560 !! options
21561 language=zh variant=zh-cn
21562 !! wikitext
21563 ;<b>foo:bar
21564 ;-{zh-cn:AAA
21565 !! html/php
21566 <dl><dt><b>foo:bar</dt>
21567 <dt>-{zh-cn:AAA</b></dt></dl>
21568
21569 !! html/parsoid
21570 <dl>
21571 <dt><b>foo:bar</b></dt>
21572 <b>
21573 <dt>-{zh-cn</dt>
21574 <dd>AAA</dd>
21575 </b></dl>
21576 !! end
21577
21578 !! test
21579 T153135: Nested language converter markup in definition list (code coverage)
21580 !! options
21581 language=zh variant=zh-cn
21582 !! wikitext
21583 ;-{zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
21584 !! html/php
21585 <dl><dt>AAA foo:bar bat:baz</dt>
21586 <dd>def</dd></dl>
21587
21588 !! html/parsoid
21589 <dl>
21590 <dt><span typeof="mw:LanguageVariant" data-mw='{"bidir":[{"l":"zh-cn","t":"AAA &lt;span typeof=\"mw:LanguageVariant\" data-parsoid=&#39;{\"fl\":[\"zh-hans\"],\"dsr\":[13,32,null,2]}&#39; data-mw=&#39;{\"filter\":[\"zh-hans\"],\"text\":\"bar\"}&#39;>&lt;/span> &lt;span typeof=\"mw:LanguageVariant\" data-parsoid=&#39;{\"fl\":[\"R\"],\"dsr\":[33,46,null,2]}&#39; data-mw=&#39;{\"disabled\":true,\"show\":true,\"text\":\"bat:baz\"}&#39;>&lt;/span>"}],"show":true}'></span></dt>
21591 <dd>def</dd>
21592 </dl>
21593 !! end
21594
21595 !! test
21596 T153140: Don't break table handling if language converter markup is in the cell.
21597 !! options
21598 language=sr variant=sr-ec
21599 !! wikitext
21600 {|
21601 |-
21602 | -{R|B}-
21603 |}
21604 !! html/php
21605 <table>
21606
21607 <tr>
21608 <td> B
21609 </td></tr></table>
21610
21611 !! html/parsoid
21612 <table>
21613
21614 <tr>
21615 <td> B
21616 </td></tr></table>
21617
21618 !! end
21619
21620 !! test
21621 T2529: Uncovered bullet
21622 !! wikitext
21623 * Foo {{bullet}}
21624 !! html
21625 <ul><li> Foo </li>
21626 <li> Bar</li></ul>
21627
21628 !! end
21629
21630 # Plain MediaWiki does not remove empty lists, but tidy actually does.
21631 # Templates in Wikipedia rely on this behavior, as tidy has always been
21632 # enabled there. These tests are normally run *without* tidy, so specify the
21633 # full output here.
21634 # To test realistic parsing behavior, apply a tidy-like transformation to both
21635 # the expected output and your parser's output.
21636 !! test
21637 T2529: Uncovered bullet leaving empty list, normally removed by tidy
21638 !! wikitext
21639 ******* Foo {{bullet}}
21640 !! html
21641 <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>
21642 <li> Bar</li></ul>
21643
21644 !! end
21645
21646 !! test
21647 T2529: Uncovered table already at line-start
21648 !! wikitext
21649 x
21650
21651 {{table}}
21652 y
21653 !! html
21654 <p>x
21655 </p>
21656 <table>
21657 <tr>
21658 <td> 1 </td>
21659 <td> 2
21660 </td></tr>
21661 <tr>
21662 <td> 3 </td>
21663 <td> 4
21664 </td></tr></table>
21665 <p>y
21666 </p>
21667 !! end
21668
21669 !! test
21670 T2529: Uncovered bullet in parser function result
21671 !! wikitext
21672 * Foo {{lc:{{bullet}} }}
21673 !! html
21674 <ul><li> Foo </li>
21675 <li> bar</li></ul>
21676
21677 !! end
21678
21679 !! test
21680 T7678: Double-parsed template argument
21681 !! wikitext
21682 {{lc:{{{1}}}|hello}}
21683 !! html
21684 <p>{{{1}}}
21685 </p>
21686 !! end
21687
21688 !! test
21689 T7678: Double-parsed template invocation
21690 !! wikitext
21691 {{lc:{{paramtest {{!}} param = hello }} }}
21692 !! html
21693 <p>{{paramtest | param = hello }}
21694 </p>
21695 !! end
21696
21697 !! test
21698 Case insensitivity of parser functions for non-ASCII characters (T10143)
21699 !! options
21700 language=cs
21701 title=[[Main Page]]
21702 !! wikitext
21703 {{PRVNÍVELKÉ:ěščř}}
21704 {{prvnívelké:ěščř}}
21705 {{PRVNÍMALÉ:ěščř}}
21706 {{prvnímalé:ěščř}}
21707 {{MALÁ:ěščř}}
21708 {{malá:ěščř}}
21709 {{VELKÁ:ěščř}}
21710 {{velká:ěščř}}
21711 !! html
21712 <p>Ěščř
21713 Ěščř
21714 ěščř
21715 ěščř
21716 ěščř
21717 ěščř
21718 ĚŠČŘ
21719 ĚŠČŘ
21720 </p>
21721 !! end
21722
21723 !! test
21724 Morwen/13: Unclosed link followed by heading
21725 !! wikitext
21726 [[link
21727 ==heading==
21728 !! html
21729 <p>[[link
21730 </p>
21731 <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>
21732
21733 !! end
21734
21735 !! test
21736 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
21737 !! wikitext
21738 {{foo|
21739 =heading=
21740 !! html
21741 <p>{{foo|
21742 </p>
21743 <h1><span class="mw-headline" id="heading">heading</span></h1>
21744
21745 !! end
21746
21747 !! test
21748 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
21749 !! wikitext
21750 {{foo|
21751 ==heading==
21752 !! html
21753 <p>{{foo|
21754 </p>
21755 <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>
21756
21757 !! end
21758
21759 !! test
21760 Tildes in comments
21761 !! options
21762 pst
21763 !! wikitext
21764 <!-- ~~~~ -->
21765 !! html/php
21766 <!-- ~~~~ -->
21767 !! end
21768
21769 !! test
21770 Paragraphs inside divs (no extra line breaks)
21771 !! wikitext
21772 <div>Line one
21773
21774 Line two</div>
21775 !! html
21776 <div>Line one
21777 Line two</div>
21778
21779 !! end
21780
21781 !! test
21782 Paragraphs inside divs (extra line break on open)
21783 !! wikitext
21784 <div>
21785 Line one
21786
21787 Line two</div>
21788 !! html
21789 <div>
21790 <p>Line one
21791 </p>
21792 Line two</div>
21793
21794 !! end
21795
21796 !! test
21797 Paragraphs inside divs (extra line break on close)
21798 !! wikitext
21799 <div>Line one
21800
21801 Line two
21802 </div>
21803 !! html
21804 <div>Line one
21805 <p>Line two
21806 </p>
21807 </div>
21808
21809 !! end
21810
21811 !! test
21812 Paragraphs inside divs (extra line break on open and close)
21813 !! wikitext
21814 <div>
21815 Line one
21816
21817 Line two
21818 </div>
21819 !! html
21820 <div>
21821 <p>Line one
21822 </p><p>Line two
21823 </p>
21824 </div>
21825
21826 !! end
21827
21828 !! test
21829 Nesting tags, paragraphs on lines which begin with <div>
21830 !! wikitext
21831 <div></div><strong>A
21832 B</strong>
21833 !! html/php+tidy
21834 <p><strong>A</strong></p>
21835 <p><strong>B</strong></p>
21836 !! html/parsoid
21837 <div></div>
21838 <p><strong>A
21839 B</strong>
21840 </p>
21841 !! end
21842
21843 # T8200: <blockquote> should behave like <div> with respect to line breaks
21844 !! test
21845 T8200: paragraphs inside blockquotes (no extra line breaks)
21846 !! wikitext
21847 <blockquote>Line one
21848
21849 Line two</blockquote>
21850 !! html
21851 <blockquote>Line one
21852 Line two</blockquote>
21853
21854 !! html+tidy
21855 <blockquote>
21856 <p>Line one Line two</p>
21857 </blockquote>
21858 !! end
21859
21860 !! test
21861 T8200: paragraphs inside blockquotes (extra line break on open)
21862 !! wikitext
21863 <blockquote>
21864 Line one
21865
21866 Line two</blockquote>
21867 !! html
21868 <blockquote>
21869 <p>Line one
21870 </p>
21871 Line two</blockquote>
21872
21873 !! html+tidy
21874 <blockquote>
21875 <p>Line one</p>
21876 Line two</blockquote>
21877 !! end
21878
21879 !! test
21880 T8200: paragraphs inside blockquotes (extra line break on close)
21881 !! wikitext
21882 <blockquote>Line one
21883
21884 Line two
21885 </blockquote>
21886 !! html
21887 <blockquote>Line one
21888 <p>Line two
21889 </p>
21890 </blockquote>
21891
21892 !! html+tidy
21893 <blockquote>
21894 <p>Line one</p>
21895 <p>Line two</p>
21896 </blockquote>
21897 !! end
21898
21899 !! test
21900 T8200: paragraphs inside blockquotes (extra line break on open and close)
21901 !! wikitext
21902 <blockquote>
21903 Line one
21904
21905 Line two
21906 </blockquote>
21907 !! html
21908 <blockquote>
21909 <p>Line one
21910 </p><p>Line two
21911 </p>
21912 </blockquote>
21913
21914 !! html+tidy
21915 <blockquote>
21916 <p>Line one</p>
21917 <p>Line two</p>
21918 </blockquote>
21919 !! end
21920
21921 !! test
21922 Paragraphs inside blockquotes/divs (no extra line breaks)
21923 !! wikitext
21924 <blockquote><div>Line one
21925
21926 Line two</div></blockquote>
21927 !! html
21928 <blockquote><div>Line one
21929 Line two</div></blockquote>
21930
21931 !! end
21932
21933 !! test
21934 Paragraphs inside blockquotes/divs (extra line break on open)
21935 !! wikitext
21936 <blockquote><div>
21937 Line one
21938
21939 Line two</div></blockquote>
21940 !! html
21941 <blockquote><div>
21942 <p>Line one
21943 </p>
21944 Line two</div></blockquote>
21945
21946 !! end
21947
21948 !! test
21949 Paragraphs inside blockquotes/divs (extra line break on close)
21950 !! wikitext
21951 <blockquote><div>Line one
21952
21953 Line two
21954 </div></blockquote>
21955 !! html
21956 <blockquote><div>Line one
21957 <p>Line two
21958 </p>
21959 </div></blockquote>
21960
21961 !! end
21962
21963 !! test
21964 Paragraphs inside blockquotes/divs (extra line break on open and close)
21965 !! wikitext
21966 <blockquote><div>
21967 Line one
21968
21969 Line two
21970 </div></blockquote>
21971 !! html
21972 <blockquote><div>
21973 <p>Line one
21974 </p><p>Line two
21975 </p>
21976 </div></blockquote>
21977
21978 !! end
21979
21980 !! test
21981 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
21982 !! options
21983 wgLinkHolderBatchSize=0
21984 !! wikitext
21985 [[meatball:1]]
21986 [[meatball:2]]
21987 [[meatball:3]]
21988 !! html
21989 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
21990 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
21991 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
21992 </p>
21993 !! end
21994
21995 !! test
21996 Free external link invading image caption
21997 !! wikitext
21998 [[Image:Foobar.jpg|thumb|http://x|hello]]
21999 !! html
22000 <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>
22001
22002 !! end
22003
22004 !! test
22005 T17196: localised external link numbers
22006 !! options
22007 language=fa
22008 !! wikitext
22009 [http://en.wikipedia.org/]
22010 !! html/php
22011 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
22012 </p>
22013 !! html/parsoid
22014 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/"></a></p>
22015 !! end
22016
22017 !! test
22018 Multibyte character in padleft
22019 !! wikitext
22020 {{padleft:-Hello|7|Æ}}
22021 !! html
22022 <p>Æ-Hello
22023 </p>
22024 !! end
22025
22026 !! test
22027 Multibyte character in padright
22028 !! wikitext
22029 {{padright:Hello-|7|Æ}}
22030 !! html
22031 <p>Hello-Æ
22032 </p>
22033 !! end
22034
22035 !!test
22036 formatdate parser function
22037 !! wikitext
22038 {{#formatdate:2009-03-24}}
22039 !! html
22040 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
22041 </p>
22042 !! end
22043
22044 !!test
22045 formatdate parser function, with default format
22046 !! wikitext
22047 {{#formatdate:2009-03-24|mdy}}
22048 !! html
22049 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
22050 </p>
22051 !! end
22052
22053 !! test
22054 Spacing of numbers in formatted dates
22055 !! wikitext
22056 {{#formatdate:January 15}}
22057 !! html
22058 <p><span class="mw-formatted-date" title="01-15">January 15</span>
22059 </p>
22060 !! end
22061
22062 !! test
22063 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
22064 !! options
22065 language=nl title=[[MediaWiki:Common.css]]
22066 !! wikitext
22067 {{#formatdate:2009-03-24|dmy}}
22068 !! html
22069 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
22070 </p>
22071 !! end
22072
22073 #
22074 #
22075 #
22076
22077 #
22078 # Edit comments
22079 #
22080
22081 !! test
22082 Edit comment with link
22083 !! options
22084 comment
22085 !! wikitext
22086 I like the [[Main Page]] a lot
22087 !! html/php
22088 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
22089 !!end
22090
22091 !! test
22092 Edit comment with link and link text
22093 !! options
22094 comment
22095 !! wikitext
22096 I like the [[Main Page|best pages]] a lot
22097 !! html/php
22098 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
22099 !!end
22100
22101 !! test
22102 Edit comment with link and link text with suffix
22103 !! options
22104 comment
22105 !! wikitext
22106 I like the [[Main Page|best page]]s a lot
22107 !! html/php
22108 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
22109 !!end
22110
22111 !! test
22112 Edit comment with section link (non-local, eg in history list)
22113 !! options
22114 comment title=[[Main Page]]
22115 !! wikitext
22116 /* External links */ removed bogus entries
22117 !! html/php
22118 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
22119 !!end
22120
22121 !! test
22122 Edit comment with section link and text before it (non-local, eg in history list)
22123 !! options
22124 comment title=[[Main Page]]
22125 !! wikitext
22126 pre-comment text /* External links */ removed bogus entries
22127 !! html/php
22128 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>
22129 !!end
22130
22131 !! test
22132 Edit comment with section link (local, eg in diff view)
22133 !! options
22134 comment local title=[[Main Page]]
22135 !! wikitext
22136 /* External links */ removed bogus entries
22137 !! html/php
22138 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
22139 !!end
22140
22141 !! test
22142 Edit comment with subpage link (T16080)
22143 !! options
22144 comment
22145 subpage
22146 title=[[Subpage test]]
22147 !! wikitext
22148 Poked at a [[/subpage]] here...
22149 !! html/php
22150 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
22151 !!end
22152
22153 !! test
22154 Edit comment with subpage link and link text (T16080)
22155 !! options
22156 comment
22157 subpage
22158 title=[[Subpage test]]
22159 !! wikitext
22160 Poked at a [[/subpage|neat little page]] here...
22161 !! html/php
22162 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
22163 !!end
22164
22165 !! test
22166 Edit comment with bogus subpage link in non-subpage NS (T16080)
22167 !! options
22168 comment
22169 title=[[Subpage test]]
22170 !! wikitext
22171 Poked at a [[/subpage]] here...
22172 !! html/php
22173 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...
22174 !!end
22175
22176 !! test
22177 Edit comment with bare anchor link (local, as on diff)
22178 !! options
22179 comment
22180 local
22181 title=[[Main Page]]
22182 !! wikitext
22183 [[#section]]
22184 !! html/php
22185 <a href="#section">#section</a>
22186 !! end
22187
22188 !! test
22189 Edit comment with bare anchor link (non-local, as on history)
22190 !! options
22191 comment
22192 title=[[Main Page]]
22193 !! wikitext
22194 [[#section]]
22195 !! html/php
22196 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
22197 !! end
22198
22199 !! test
22200 Anchor starting with underscore
22201 !! options
22202 title=[[Foo]]
22203 !! wikitext
22204 [[#_ref|One]]
22205 !! html/php
22206 <p><a href="#_ref">One</a>
22207 </p>
22208 !! html/parsoid
22209 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
22210 !! end
22211
22212 !! test
22213 Id starting with underscore
22214 !! wikitext
22215 <div id="_ref"></div>
22216 !! html/*
22217 <div id="_ref"></div>
22218
22219 !! end
22220
22221 !! test
22222 Edit comment with link with more than one pipe (T99346)
22223 !! options
22224 comment
22225 !! wikitext
22226 [[Main Page|Many|pipes]]
22227 !! html/php
22228 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
22229 !! end
22230
22231 !! test
22232 Complex edit comment with link with more than one pipe (T99346)
22233 !! options
22234 comment
22235 !! wikitext
22236 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
22237 !! html/php
22238 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;
22239 !! end
22240
22241 !! test
22242 Space normalisation on autocomment (T24784)
22243 !! options
22244 comment
22245 title=[[Main Page]]
22246 !! wikitext
22247 /* __hello__world__ */
22248 !! html/php
22249 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
22250 !! end
22251
22252 !! test
22253 percent-encoding and + signs in comments (T28410)
22254 !! options
22255 comment
22256 !! wikitext
22257 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
22258 !! html/php
22259 <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>
22260 !! end
22261
22262 # Parsoid doesn't support this yet: see T75581
22263 # but it *should* omit the 'src' attribute if the image is bad.
22264 # PHP side of tests was disabled in
22265 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
22266 # because of issues in the PHP parserTests infrastructure
22267 # (but the output below is indeed what the PHP side emits)
22268 !! test
22269 Bad images - basic functionality
22270 !! wikitext
22271 [[File:Bad.jpg]]
22272 !! DISABLED/html/php
22273 !! html/parsoid
22274 <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>
22275 !! end
22276
22277 !! test
22278 Bad images - T18039: text after bad image disappears
22279 !! wikitext
22280 Foo bar
22281 [[File:Bad.jpg]]
22282 Bar foo
22283 !! DISABLED/html/php
22284 <p>Foo bar
22285 </p><p>Bar foo
22286 </p>
22287 !! html/parsoid
22288 <p>Foo bar
22289 <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>
22290 Bar foo</p>
22291 !! end
22292
22293 !! test
22294 Verify that displaytitle works (T24501) no displaytitle
22295 !! options
22296 showtitle
22297 !! config
22298 wgAllowDisplayTitle=true
22299 wgRestrictDisplayTitle=false
22300 !! wikitext
22301 this is not the the title
22302 !! html/php
22303 Parser test
22304 <p>this is not the the title
22305 </p>
22306 !! end
22307
22308 !! test
22309 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
22310 !! options
22311 showtitle
22312 title=[[Screen]]
22313 !! config
22314 wgAllowDisplayTitle=true
22315 wgRestrictDisplayTitle=false
22316 !! wikitext
22317 this is not the the title
22318 {{DISPLAYTITLE:whatever}}
22319 !! html/php
22320 whatever
22321 <p>this is not the the title
22322 </p>
22323 !! end
22324
22325 !! test
22326 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
22327 !! options
22328 showtitle
22329 title=[[Screen]]
22330 !! config
22331 wgAllowDisplayTitle=true
22332 wgRestrictDisplayTitle=true
22333 !! wikitext
22334 this is not the the title
22335 {{DISPLAYTITLE:whatever}}
22336 !! html/php
22337 Screen
22338 <p>this is not the the title
22339 </p>
22340 !! end
22341
22342 !! test
22343 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
22344 !! options
22345 showtitle
22346 title=[[Screen]]
22347 !! config
22348 wgAllowDisplayTitle=true
22349 wgRestrictDisplayTitle=true
22350 !! wikitext
22351 this is not the the title
22352 {{DISPLAYTITLE:screen}}
22353 !! html/php
22354 screen
22355 <p>this is not the the title
22356 </p>
22357 !! end
22358
22359 !! test
22360 Verify that displaytitle works (T24501) AllowDisplayTitle=false
22361 !! options
22362 showtitle
22363 title=[[Screen]]
22364 !! config
22365 wgAllowDisplayTitle=false
22366 !! wikitext
22367 this is not the the title
22368 {{DISPLAYTITLE:screen}}
22369 !! html/php
22370 Screen
22371 <p>this is not the the title
22372 <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>
22373 </p>
22374 !! end
22375
22376 !! test
22377 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
22378 !! options
22379 showtitle
22380 title=[[Screen]]
22381 !! config
22382 wgAllowDisplayTitle=false
22383 !! wikitext
22384 this is not the the title
22385 !! html/php
22386 Screen
22387 <p>this is not the the title
22388 </p>
22389 !! end
22390
22391 !! test
22392 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
22393 !! options
22394 showtitle
22395 title=[[Screen]]
22396 !! config
22397 wgAllowDisplayTitle=true
22398 wgRestrictDisplayTitle=true
22399 !! wikitext
22400 this is not the the title
22401 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
22402 !! html/php
22403 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
22404 <p>this is not the the title
22405 </p>
22406 !! end
22407
22408 !! test
22409 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
22410 !! options
22411 showtitle
22412 title=[[Screen]]
22413 !! config
22414 wgAllowDisplayTitle=true
22415 wgRestrictDisplayTitle=true
22416 !! wikitext
22417 this is not the the title
22418 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
22419 !! html/php
22420 <span style="color: red;">s</span>creen
22421 <p>this is not the the title
22422 </p>
22423 !! end
22424
22425 !! test
22426 Page status indicators: Empty name is invalid
22427 !! options
22428 showindicators
22429 !! wikitext
22430 <indicator name=" "></indicator>
22431 <indicator></indicator>
22432 !! html/php
22433 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
22434 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
22435 </p>
22436 !! end
22437
22438 !! test
22439 Page status indicators: Weird syntaxes that are okay
22440 !! options
22441 showindicators
22442 !! wikitext
22443 <indicator name="empty" />
22444 <indicator name="name"></indicator>
22445 !! html/php
22446 empty=
22447 name=
22448 <p><br />
22449 </p>
22450 !! end
22451
22452 !! test
22453 Page status indicators: Torture test
22454 !! options
22455 showindicators
22456 !! wikitext
22457 <indicator name="01">hello world</indicator>
22458 <indicator name="02">[[Main Page]]</indicator>
22459 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
22460 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
22461 <indicator name="05">* foo
22462 * bar</indicator>
22463 <indicator name="06"><nowiki>foo</nowiki></indicator>
22464 <indicator name="07"> Preformatted</indicator>
22465 <indicator name="08"><div>Broken tag</indicator>
22466 <indicator name="09">{| class=wikitable
22467 | cell
22468 |}</indicator>
22469 <indicator name="10">Two
22470
22471 paragraphs</indicator>
22472 !! html/php
22473 01=hello world
22474 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22475 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" />
22476 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>
22477 05=<ul><li> foo</li>
22478 <li> bar</li></ul>
22479
22480 06=foo
22481 07=<pre>Preformatted
22482 </pre>
22483 08=<div>Broken tag</div>
22484
22485 09=<table class="wikitable">
22486 <tr>
22487 <td> cell
22488 </td></tr></table>
22489
22490 10=<p>Two
22491 </p><p>paragraphs
22492 </p>
22493 <p><br />
22494 </p><p><br />
22495 </p><p><br />
22496 </p><p><br />
22497 </p><p><br />
22498 </p>
22499 !! end
22500
22501 !! test
22502 preload: check <noinclude> and <includeonly>
22503 !! options
22504 preload
22505 !! wikitext
22506 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
22507 !! html/php
22508 Hello kind world.
22509 !! end
22510
22511 !! test
22512 preload: check <onlyinclude>
22513 !! options
22514 preload
22515 !! wikitext
22516 Goodbye <onlyinclude>Hello world</onlyinclude>
22517 !! html/php
22518 Hello world
22519 !! end
22520
22521 !! test
22522 preload: can pass tags through if we want to
22523 !! options
22524 preload
22525 !! wikitext
22526 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
22527 !! html/php
22528 <includeonly>Hello world</includeonly>
22529 !! end
22530
22531 !! test
22532 preload: check that it doesn't try to do tricks
22533 !! options
22534 preload
22535 !! wikitext
22536 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
22537 !! html/php
22538 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
22539 !! end
22540
22541 !! test
22542 Play a bit with r67090 and T5158
22543 !! wikitext
22544 <div style="width:50% !important">&nbsp;</div>
22545 <div style="width:50%&nbsp;!important">&nbsp;</div>
22546 <div style="width:50%&#160;!important">&nbsp;</div>
22547 <div style="border : solid;">&nbsp;</div>
22548 !! html/php
22549 <div style="width:50% !important">&#160;</div>
22550 <div style="width:50% !important">&#160;</div>
22551 <div style="width:50% !important">&#160;</div>
22552 <div style="border&#160;: solid;">&#160;</div>
22553
22554 !! html/parsoid
22555 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
22556 <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>
22557 <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>
22558 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
22559
22560 !! end
22561
22562 !! test
22563 HTML5 data attributes
22564 !! wikitext
22565 <span data-foo="bar">Baz</span>
22566 <p data-abc-def_hij="">Quuz</p>
22567 !! html/php
22568 <p><span data-foo="bar">Baz</span>
22569 </p>
22570 <p data-abc-def_hij="">Quuz</p>
22571
22572 !! html/parsoid
22573 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
22574 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
22575 !! end
22576
22577 !! test
22578 Strip reserved data attributes
22579 !! wikitext
22580 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
22581 !! html/php
22582 <div data-ok="fred">d</div>
22583
22584 !! html/parsoid
22585 <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>
22586 !! end
22587
22588 !! test
22589 percent-encoding and + signs in internal links (T28410)
22590 !! wikitext
22591 [[User:+%]] [[Page+title%]]
22592 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
22593 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
22594 [[%33%45]] [[%33%45+]]
22595 !! html/php
22596 <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>
22597 <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>
22598 <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>
22599 <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>
22600 </p>
22601 !! html/parsoid
22602 <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>
22603 <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>
22604 <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>
22605 <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>
22606 !! end
22607
22608 !! test
22609 Special characters in embedded file links (T29679)
22610 !! wikitext
22611 [[File:Contains & ampersand.jpg]]
22612 [[File:Does not exist.jpg|Title with & ampersand]]
22613 !! html/php
22614 <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>
22615 <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>
22616 </p>
22617 !! html/parsoid
22618 <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>
22619 <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>
22620 !! end
22621
22622 !! test
22623 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
22624 !! wikitext
22625 Text&apos;s been normalized?
22626 !! html
22627 <p>Text&#39;s been normalized?
22628 </p>
22629 !! end
22630
22631 !! test
22632 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
22633 !! wikitext
22634 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
22635 !! html
22636 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
22637 </p>
22638 !! end
22639
22640 !! test
22641 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
22642 !! wikitext
22643 [http://www.example.org/ ideograms]
22644 !! html
22645 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
22646 </p>
22647 !! end
22648
22649 !! test
22650 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
22651 !! wikitext
22652 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
22653 !! html
22654 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
22655 </p>
22656 !! end
22657
22658 !! article
22659 Mediawiki:loop1
22660 !! text
22661 {{Identical|A}}
22662 !! endarticle
22663
22664 !! article
22665 Mediawiki:loop2
22666 !! text
22667 {{Identical|B}}
22668 !! endarticle
22669
22670 !! article
22671 Template:Identical
22672 !! text
22673 {{int:loop1}}
22674 {{int:loop2}}
22675 !! endarticle
22676
22677 !! test
22678 T33098 Template which includes system messages which includes the template
22679 !! wikitext
22680 {{Identical}}
22681 !! html
22682 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
22683 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
22684 </p>
22685 !! end
22686
22687 !! test
22688 T33490 Turkish: ucfirst 'blah'
22689 !! options
22690 language=tr
22691 !! wikitext
22692 {{ucfirst:blah}}
22693 !! html
22694 <p>Blah
22695 </p>
22696 !! end
22697
22698 !! test
22699 T33490 Turkish: ucfirst 'ix'
22700 !! options
22701 language=tr
22702 !! wikitext
22703 {{ucfirst:ix}}
22704 !! html
22705 <p>İx
22706 </p>
22707 !! end
22708
22709 !! test
22710 T33490 Turkish: lcfirst 'BLAH'
22711 !! options
22712 language=tr
22713 !! wikitext
22714 {{lcfirst:BLAH}}
22715 !! html
22716 <p>bLAH
22717 </p>
22718 !! end
22719
22720 !! test
22721 T33490 Turkish: ucfırst (with a dotless i)
22722 !! options
22723 language=tr
22724 !! wikitext
22725 {{ucfırst:blah}}
22726 !! html
22727 <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>
22728 </p>
22729 !! end
22730
22731 !! test
22732 T33490 ucfırst (with a dotless i) with English language
22733 !! options
22734 language=en
22735 !! wikitext
22736 {{ucfırst:blah}}
22737 !! html
22738 <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>
22739 </p>
22740 !! end
22741
22742 # Note that Parsoid doesn't emit an explicit TOC.
22743 # Note also that the html2wt direction tends to emit an extra newline
22744 # between the __TOC__ magicword and the first heading unless *both*
22745 # the <meta> and the <h2> have a data-parsoid attribute set (even if
22746 # it's "{}").
22747
22748 !! test
22749 T28375: TOC with italics
22750 !! options
22751 title=[[Main Page]]
22752 !! wikitext
22753 __TOC__
22754 == ''Lost'' episodes ==
22755 !! html/php
22756 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
22757 <ul>
22758 <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>
22759 </ul>
22760 </div>
22761
22762 <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>
22763
22764 !! html/parsoid
22765 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22766 <h2 data-parsoid='{}'> <i>Lost</i> episodes </h2>
22767 !! end
22768
22769 !! test
22770 T28375: TOC with bold
22771 !! options
22772 title=[[Main Page]]
22773 !! wikitext
22774 __TOC__
22775 == '''should be bold''' then normal text ==
22776 !! html/php
22777 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
22778 <ul>
22779 <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>
22780 </ul>
22781 </div>
22782
22783 <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>
22784
22785 !! html/parsoid
22786 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22787 <h2 data-parsoid='{}'> <b>should be bold</b> then normal text </h2>
22788 !! end
22789
22790 !! test
22791 T35845: Headings become cursive in TOC when they contain an image
22792 !! options
22793 title=[[Main Page]]
22794 !! wikitext
22795 __TOC__
22796 == Image [[Image:foobar.jpg]] ==
22797 !! html/php
22798 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
22799 <ul>
22800 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
22801 </ul>
22802 </div>
22803
22804 <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>
22805
22806 !! html/parsoid
22807 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22808 <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>
22809 !! end
22810
22811 !! test
22812 T35845 (2): Headings become bold in TOC when they contain a blockquote
22813 !! options
22814 title=[[Main Page]]
22815 !! wikitext
22816 __TOC__
22817 == <blockquote>Quote</blockquote> ==
22818 !! html/php
22819 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
22820 <ul>
22821 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
22822 </ul>
22823 </div>
22824
22825 <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>
22826
22827 !! html/php+tidy
22828 <p></p>
22829 <div id="toc" class="toc">
22830 <div id="toctitle" class="toctitle">
22831 <h2>Contents</h2>
22832 </div>
22833 <ul>
22834 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
22835 </ul>
22836 </div>
22837 <p></p>
22838 <h2><span class="mw-headline" id="Quote"></span></h2>
22839 <blockquote>
22840 <p><span class="mw-headline" id="Quote">Quote</span></p>
22841 </blockquote>
22842 <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>
22843 !! html/parsoid
22844 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22845 <h2 data-parsoid='{}'> <blockquote>Quote</blockquote> </h2>
22846 !! end
22847
22848 !! test
22849 Unclosed tags in TOC
22850 !! options
22851 title=[[Main Page]]
22852 !! wikitext
22853 __TOC__
22854 == Proof: 2 < 3 ==
22855 <small>Hanc marginis exiguitas non caperet.</small>
22856 QED
22857 !! html/php
22858 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
22859 <ul>
22860 <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>
22861 </ul>
22862 </div>
22863
22864 <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>
22865 <p><small>Hanc marginis exiguitas non caperet.</small>
22866 QED
22867 </p>
22868 !! html/parsoid
22869 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22870 <h2 data-parsoid='{}'> Proof: 2 &lt; 3 </h2>
22871 <p><small>Hanc marginis exiguitas non caperet.</small>
22872 QED</p>
22873 !! end
22874
22875 !! test
22876 Multiple tags in TOC
22877 !! wikitext
22878 __TOC__
22879 == <i>Foo</i> <b>Bar</b> ==
22880
22881 == <i>Foo</i> <blockquote>Bar</blockquote> ==
22882 !! html/php
22883 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
22884 <ul>
22885 <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>
22886 <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>
22887 </ul>
22888 </div>
22889
22890 <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>
22891 <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>
22892
22893 !! html/php+tidy
22894 <p></p>
22895 <div id="toc" class="toc">
22896 <div id="toctitle" class="toctitle">
22897 <h2>Contents</h2>
22898 </div>
22899 <ul>
22900 <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>
22901 <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>
22902 </ul>
22903 </div>
22904 <p></p>
22905 <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>
22906 <h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i></span></h2>
22907 <blockquote>
22908 <p><span class="mw-headline" id="Foo_Bar_2">Bar</span></p>
22909 </blockquote>
22910 <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>
22911 !! html/parsoid
22912 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22913 <h2 data-parsoid='{}'> <i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b> </h2>
22914 <h2> <i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote> </h2>
22915 !! end
22916
22917 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
22918 # html5 tag parsing.
22919 !! test
22920 Tags with parameters in TOC
22921 !! options
22922 parsoid=wt2html
22923 !! wikitext
22924 __TOC__
22925 == <sup class="in-h2">Hello</sup> ==
22926
22927 == <sup class="a > b">Evilbye</sup> ==
22928 !! html/php
22929 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
22930 <ul>
22931 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
22932 <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>
22933 </ul>
22934 </div>
22935
22936 <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>
22937 <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>
22938
22939 !! html/parsoid
22940 <meta property="mw:PageProp/toc" />
22941 <h2> <sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup> </h2>
22942
22943 <h2> <sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup> </h2>
22944 !! end
22945
22946 !! test
22947 span tags with directionality in TOC
22948 !! wikitext
22949 __TOC__
22950 == <span dir="ltr">C++</span> ==
22951
22952 == <span dir="rtl">זבנג!</span> ==
22953
22954 == <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> ==
22955
22956 == <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> ==
22957
22958 == <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> ==
22959 !! html/php
22960 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
22961 <ul>
22962 <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>
22963 <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>
22964 <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>
22965 <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>
22966 <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>
22967 </ul>
22968 </div>
22969
22970 <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>
22971 <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>
22972 <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>
22973 <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>
22974 <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>
22975
22976 !! html/parsoid
22977 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22978 <h2 data-parsoid='{}'> <span dir="ltr">C++</span> </h2>
22979 <h2> <span dir="rtl">זבנג!</span> </h2>
22980 <h2> <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> </h2>
22981 <h2> <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> </h2>
22982 <h2> <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> </h2>
22983 !! end
22984
22985 !! test
22986 T74884: bdi element in ToC
22987 !! wikitext
22988 __TOC__
22989 == <bdi>test</bdi> ==
22990 !! html/php
22991 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
22992 <ul>
22993 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
22994 </ul>
22995 </div>
22996
22997 <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>
22998
22999 !! html/parsoid
23000 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23001 <h2 data-parsoid='{}'> <bdi>test</bdi> </h2>
23002 !! end
23003
23004 !! test
23005 T35715: s/strike element in ToC
23006 !! wikitext
23007 __TOC__
23008 == <s>test</s> test <strike>test</strike> ==
23009 !! html/php
23010 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
23011 <ul>
23012 <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>
23013 </ul>
23014 </div>
23015
23016 <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>
23017
23018 !! html/parsoid
23019 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23020 <h2 data-parsoid='{}'> <s>test</s> test <strike>test</strike> </h2>
23021 !! end
23022
23023 # Note that the html output does not have the <p></p>, but the
23024 # html+tidy output *does*. This is because the empty <p></p> is
23025 # removed by the sanitizer, but only when tidy is *not* enabled (!).
23026 !! test
23027 Empty <p> tag in TOC, removed by Sanitizer (T92892)
23028 !! wikitext
23029 __TOC__
23030 == x ==
23031 !! html/php
23032 <div id="toc" class="toc"><div id="toctitle" class="toctitle"><h2>Contents</h2></div>
23033 <ul>
23034 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
23035 </ul>
23036 </div>
23037
23038 <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>
23039
23040 !! html/php+tidy
23041 <p></p>
23042 <div id="toc" class="toc">
23043 <div id="toctitle" class="toctitle">
23044 <h2>Contents</h2>
23045 </div>
23046 <ul>
23047 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
23048 </ul>
23049 </div>
23050 <p></p>
23051 <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>
23052 !! html/parsoid
23053 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23054 <h2 data-parsoid='{}'> x </h2>
23055 !! end
23056
23057 !! article
23058 MediaWiki:T34057
23059 !! text
23060 == {{int:headline_sample}} ==
23061 !! endarticle
23062
23063 !! test
23064 T34057: Title needed when expanding <h> nodes.
23065 !! options
23066 title=[[Main Page]]
23067 !! wikitext
23068 {{int:T34057}}
23069 !! html
23070 <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>
23071
23072 !! end
23073
23074 !! test
23075 Strip marker in urlencode
23076 !! wikitext
23077 {{urlencode:x<nowiki/>y}}
23078 {{urlencode:x<nowiki/>y|wiki}}
23079 {{urlencode:x<nowiki/>y|path}}
23080 {{urlencode:x<pre id="one">two</pre>y}}
23081 !! html/php
23082 <p>xy
23083 xy
23084 xy
23085 xy
23086 </p>
23087 !! end
23088
23089 !! test
23090 Strip marker in lc
23091 !! wikitext
23092 {{lc:x<nowiki/>y}}
23093 !! html
23094 <p>xy
23095 </p>
23096 !! end
23097
23098 !! test
23099 Strip marker in uc
23100 !! wikitext
23101 {{uc:x<nowiki/>y}}
23102 !! html
23103 <p>XY
23104 </p>
23105 !! end
23106
23107 !! test
23108 Strip marker in formatNum
23109 !! wikitext
23110 {{formatnum:1<nowiki/>2}}
23111 {{formatnum:1<nowiki/>2|R}}
23112 !! html
23113 <p>12
23114 12
23115 </p>
23116 !! end
23117
23118 !! test
23119 Check noCommafy in formatNum
23120 !! options
23121 language=be-tarask
23122 !! wikitext
23123 {{formatnum:123456.78}}
23124 {{formatnum:123456.78|NOSEP}}
23125 !! html
23126 <p>123 456,78
23127 123456.78
23128 </p>
23129 !! end
23130
23131 !! test
23132 Wrong option for formatNum (T58199)
23133 !! wikitext
23134 {{formatnum:1,234.56|Random}}
23135 {{formatnum:1,234.56|EVERYTHING}}
23136 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
23137 !! html
23138 <p>1,234.56
23139 1,234.56
23140 1,234.56
23141 </p>
23142 !! end
23143
23144 !! test
23145 Strip marker in grammar
23146 !! options
23147 language=fi
23148 !! wikitext
23149 {{grammar:elative|foo<nowiki/>bar}}
23150 !! html
23151 <p>foobarista
23152 </p>
23153 !! end
23154
23155 !! test
23156 Strip marker in padleft
23157 !! wikitext
23158 {{padleft:|2|x<nowiki/>y}}
23159 !! html
23160 <p>xy
23161 </p>
23162 !! end
23163
23164 !! test
23165 Strip marker in padright
23166 !! wikitext
23167 {{padright:|2|x<nowiki/>y}}
23168 !! html
23169 <p>xy
23170 </p>
23171 !! end
23172
23173 !! test
23174 Strip marker in anchorencode
23175 !! wikitext
23176 {{anchorencode:x<nowiki/>y}}
23177 !! html
23178 <p>xy
23179 </p>
23180 !! end
23181
23182 !! test
23183 nowiki inside link inside heading (T20295)
23184 !! wikitext
23185 ==[[foo|x<nowiki>y</nowiki>z]]==
23186 !! html
23187 <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>
23188
23189 !! end
23190
23191 !! test
23192 new support for bdi element (T33817)
23193 !! wikitext
23194 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
23195 !! html
23196 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
23197
23198 !!end
23199
23200 !! test
23201 Ignore pipe between table row attributes
23202 !! wikitext
23203 {|
23204 | quux
23205 |- id=foo | style='color: red'
23206 | bar
23207 |}
23208 !! html
23209 <table>
23210 <tr>
23211 <td> quux
23212 </td></tr>
23213 <tr id="foo" style="color: red">
23214 <td> bar
23215 </td></tr></table>
23216
23217 !! end
23218
23219 !!test
23220 Language parser function
23221 !! wikitext
23222 {{#language:ar}}
23223 !! html
23224 <p>العربية
23225 </p>
23226 !! end
23227
23228 !!test
23229 Padleft and padright as substr
23230 !! wikitext
23231 {{padleft:|3|abcde}}
23232 {{padright:|3|abcde}}
23233 !! html
23234 <p>abc
23235 abc
23236 </p>
23237 !! end
23238
23239 !!test
23240 Special parser function
23241 !! wikitext
23242 {{#special:RandomPage}}
23243 {{#special:BaDtItLe}}
23244 {{#special:Foobar}}
23245 !! html
23246 <p>Special:Random
23247 Special:Badtitle
23248 Special:Foobar
23249 </p>
23250 !! end
23251
23252 !!test
23253 T36939 - Case insensitive link parsing ([HttP://])
23254 !! wikitext
23255 [HttP://MediaWiki.Org/]
23256 !! html/php
23257 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
23258 </p>
23259 !! html/parsoid
23260 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/"></a></p>
23261 !! end
23262
23263 !!test
23264 T36939 - Case insensitive link parsing ([HttP:// title])
23265 !! wikitext
23266 [HttP://MediaWiki.Org/ MediaWiki]
23267 !! html
23268 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
23269 </p>
23270 !! end
23271
23272 !!test
23273 T36939 - Case insensitive link parsing (HttP://)
23274 !! wikitext
23275 HttP://MediaWiki.Org/
23276 !! html/php
23277 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
23278 </p>
23279 !! html/parsoid
23280 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
23281 !! end
23282
23283 !!test
23284 Disable TOC
23285 !! options
23286 notoc
23287 !! wikitext
23288 Lead
23289 == Section 1 ==
23290 == Section 2 ==
23291 == Section 3 ==
23292 == Section 4 ==
23293 == Section 5 ==
23294 !! html
23295 <p>Lead
23296 </p>
23297
23298 <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>
23299 <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>
23300 <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>
23301 <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>
23302 <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>
23303
23304 !! end
23305
23306
23307 ###
23308 ### Parsoid-specific tests
23309 ### Parsoid-PHP parser incompatibilities
23310 ###
23311 !!test
23312 1. SOL-sensitive wikitext tokens as template-args
23313 !!options
23314 parsoid=wt2html,wt2wt
23315 !! wikitext
23316 {{echo|*a}}
23317 {{echo|#a}}
23318 {{echo|:a}}
23319 !! html
23320 <span about="#mwt1" typeof="mw:Transclusion">
23321 </span><ul about="#mwt1"><li>a</li>
23322 </ul>
23323 <span about="#mwt2" typeof="mw:Transclusion">
23324 </span><ol about="#mwt2"><li>a</li>
23325 </ol>
23326 <span about="#mwt3" typeof="mw:Transclusion">
23327 </span><dl about="#mwt3"><dd>a</dd>
23328 </dl>
23329 !!end
23330
23331 #### -----------------------------------------------------------------
23332 #### Parsoid-specific functionality tests
23333 #### -----------------------------------------------------------------
23334
23335 # T65642/T68749: Formatting elt fixup around images is cleaned up.
23336 # We know wt2wt will fail, but we expect selser to pass.
23337 # Due to the nature of our testing, wt2wt and selser tests will enter the
23338 # blacklist and we'll catch selser regressions based on changes to the
23339 # blacklist entries for selser tests.
23340 !! test
23341 1. Bad treebuilder fixup of formatting elt is cleaned up
23342 !! options
23343 parsoid=wt2html,wt2wt
23344 !! wikitext
23345 {|
23346 |
23347 <small>
23348 [[Image:Foobar.jpg|right|Test]]
23349 </small>
23350 |}
23351 !! html/parsoid
23352 <table>
23353 <tbody><tr><td>
23354 <small>
23355 <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>
23356 </small>
23357 </td></tr>
23358 </tbody></table>
23359 !! end
23360
23361 !! test
23362 2. Bad treebuilder fixup of formatting elt is cleaned up
23363 !! options
23364 parsoid=wt2html,wt2wt
23365 !! wikitext
23366 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
23367
23368 <small>[[Image:Foobar.jpg|right|300px]]</small>
23369 !! html/parsoid
23370
23371 <p><b>foo</b></p>
23372 <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>
23373 <p><b>bar</b></p>
23374 <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>
23375 !! end
23376
23377 !! test
23378 3. Bad treebuilder fixup of formatting elt is cleaned up
23379 !! options
23380 parsoid=wt2html,wt2wt
23381 !! wikitext
23382 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
23383 !! html/parsoid
23384 <p><small><b>foo</b></small></p>
23385 <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>
23386 <p><small><b>bar</b></small></p>
23387 !! end
23388
23389 !! test
23390 4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
23391 !! options
23392 parsoid=wt2html,wt2wt
23393 !! wikitext
23394 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
23395 !! html/parsoid
23396 <p><b><small></small></b></p>
23397 <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>
23398 <p></p>
23399 !! end
23400
23401 #### ----------------------------------------------------------------
23402 #### Parsoid-only testing of Parsoid's impl of LST
23403 #### Not implemented yet, see
23404 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
23405 #### ----------------------------------------------------------------
23406
23407 ## We still need to support serializing the older format while content is stored.
23408 !! test
23409 LST Sections: Backwards compatibility
23410 !! options
23411 parsoid={
23412 "suppressErrors": true,
23413 "modes": ["html2wt"]
23414 }
23415 !! wikitext
23416 <section begin="2011-05-16" />
23417 <section end="2014-04-10 (MW 1.23wmf22)" />
23418 !! html/parsoid
23419 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
23420 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
23421 !! end
23422
23423 ## The unconventional output is the result of `usePHPPreProcessor` being
23424 ## disabled in parserTests.js. This test is mainly just to show <section> is
23425 ## recognized as an extension tag w/o a native handler.
23426 !! test
23427 LST Sections: Newfangled approach
23428 !! wikitext
23429 <section begin="2011-05-16" />
23430 <section end="2014-04-10 (MW 1.23wmf22)" />
23431 !! html/parsoid
23432 <p><span typeof="mw:Error mw:Extension/section" about="#mwt1" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null,"errors":[{"key":"mw-api-extexpand-error","message":"Could not expand extension source."}]}'>&lt;section begin="2011-05-16" /></span>
23433 <span typeof="mw:Error mw:Extension/section" about="#mwt2" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null,"errors":[{"key":"mw-api-extexpand-error","message":"Could not expand extension source."}]}'>&lt;section end="2014-04-10 (MW 1.23wmf22)" /></span></p>
23434 !! end
23435
23436 #--------- Test stripping of empty nodes in template content ----------
23437 !!test
23438 Empty LI and TR nodes should be stripped from template content
23439 !!wikitext
23440 {{EmptyLITest}}
23441 {{EmptyTRTest}}
23442 !!html/parsoid
23443 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
23444 <li>a</li>
23445 <li>b</li>
23446 </ul>
23447 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
23448 <tbody>
23449 <tr>
23450 <td>foo</td>
23451 </tr>
23452 <tr>
23453 <td>bar</td>
23454 </tr>
23455 </tbody>
23456 </table>
23457 !!end
23458
23459 !!test
23460 Empty LI and TR nodes should not be stripped from top-level content
23461 !!wikitext
23462 * a
23463 *
23464 * b
23465 {|
23466 |-
23467 |-
23468 |foo
23469 |}
23470 !!html/parsoid
23471 <ul>
23472 <li> a</li>
23473 <li></li>
23474 <li> b</li>
23475 </ul>
23476 <table>
23477 <tbody>
23478 <tr></tr>
23479 <tr>
23480 <td>foo</td>
23481 </tr>
23482 </tbody>
23483 </table>
23484 !!end
23485
23486 !!test
23487 Empty TR nodes should not be stripped if they have any attributes set
23488 !!wikitext
23489 {{EmptyTRWithHTMLAttrTest}}
23490 !!html/parsoid
23491 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
23492 <tr align="center"></tr>
23493 <tr><td>foo</td></tr>
23494 <tr align="center"></tr>
23495 <tr><td>bar</td></tr>
23496 </table>
23497 !!end
23498
23499 #### ----------------------------------------------------------------
23500 #### The following section of tests are primarily to test
23501 #### wikitext escaping capabilities of Parsoid. Given that
23502 #### escaping can be done any number of ways, the wikitext (input)
23503 #### is always adjusted to reflect how Parsoid adds nowiki
23504 #### escape tags.
23505 ####
23506 #### We are marking several tests as parsoid-only since the
23507 #### HTML in the result section is different from what the
23508 #### PHP parser generates for it.
23509 #### ----------------------------------------------------------------
23510
23511
23512 #### --------------- Headings ---------------
23513 #### 0. Unnested
23514 #### 1. Nested inside html <h1>=foo=</h1>
23515 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
23516 #### 3. Nested inside html with wikitext split by html tags
23517 #### 4. No escape needed
23518 #### 5. Empty headings <h1></h1>
23519 #### 6. Heading chars in SOL context
23520 #### ----------------------------------------
23521 !! test
23522 Headings: 0. Unnested
23523 !! options
23524 parsoid=html2wt
23525 !! html/parsoid
23526 <p>=foo=</p>
23527
23528 <p> =foo=
23529 <!--cmt-->
23530 =foo=</p>
23531
23532 <p>=foo<i>a</i>=</p>
23533 !! wikitext
23534 <nowiki>=foo=</nowiki>
23535
23536 <nowiki> </nowiki>=foo=
23537 <!--cmt-->
23538 <nowiki>=foo=</nowiki>
23539
23540 =foo''a''<nowiki>=</nowiki>
23541 !!end
23542
23543 # New headings and existing headings are handled differently
23544 !! test
23545 Headings: 1. Nested inside html
23546 !! options
23547 parsoid=html2wt
23548 !! html/parsoid
23549 <h1>=foo=</h1>
23550 <h2>=foo=</h2>
23551 <h3>=foo=</h3>
23552
23553 <h1 data-parsoid=''>=foo=</h1>
23554 <h2 data-parsoid=''>=foo=</h2>
23555 <h3 data-parsoid=''>=foo=</h3>
23556 <h4 data-parsoid=''>=foo=</h4>
23557 <h5 data-parsoid=''>=foo=</h5>
23558 <h6 data-parsoid=''>=foo=</h6>
23559 !! wikitext
23560 = =foo= =
23561
23562 == =foo= ==
23563
23564 === =foo= ===
23565
23566 =<nowiki>=foo=</nowiki>=
23567 ==<nowiki>=foo=</nowiki>==
23568 ===<nowiki>=foo=</nowiki>===
23569 ====<nowiki>=foo=</nowiki>====
23570 =====<nowiki>=foo=</nowiki>=====
23571 ======<nowiki>=foo=</nowiki>======
23572
23573 !!end
23574
23575 !! test
23576 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
23577 !! options
23578 parsoid=html2wt
23579 !! html/parsoid
23580 <h1>foo</h1>*bar
23581 <h1>foo</h1>=bar
23582 <h1>foo</h1>=bar=
23583 !! wikitext
23584 = foo =
23585 <nowiki>*</nowiki>bar
23586
23587 = foo =
23588 =bar
23589
23590 = foo =
23591 <nowiki>=bar=</nowiki>
23592 !!end
23593
23594 !! test
23595 Headings: 3. Nested inside html with wikitext split by html tags
23596 !! options
23597 parsoid=html2wt
23598 !! html/parsoid
23599 <h1>=<b>bold</b>foo=</h1>
23600 !! wikitext
23601 = ='''bold'''foo= =
23602 !!end
23603
23604 !! test
23605 Headings: 4a. No escaping needed (testing just h1 and h2)
23606 !! options
23607 parsoid=html2wt
23608 !! html/parsoid
23609 <h1>=foo</h1>
23610 <h1>foo=</h1>
23611 <h1> =foo= </h1>
23612 <h1>=foo= bar</h1>
23613 <h2>=foo</h2>
23614 <h2>foo=</h2>
23615 <h1>=</h1>
23616 <h1><i>=</i>foo=</h1>
23617 !! wikitext
23618 = =foo =
23619
23620 = foo= =
23621
23622 = =foo= =
23623
23624 = =foo= bar =
23625
23626 == =foo ==
23627
23628 == foo= ==
23629
23630 = = =
23631
23632 = ''=''foo= =
23633 !!end
23634
23635 !! test
23636 Headings: 4b. No escaping needed (inside p-tags)
23637 !! options
23638 parsoid=html2wt
23639 !! html/parsoid
23640 <p>===
23641 =foo= x
23642 =foo= <s></s>
23643 </p>
23644 !! wikitext
23645 ===
23646 =foo= x
23647 =foo= <s></s>
23648 !!end
23649
23650 !! test
23651 Headings: 5. Empty headings
23652 !! options
23653 parsoid=html2wt
23654 !! html/parsoid
23655 <h1 data-parsoid='{}'></h1>
23656
23657 <h2 data-parsoid='{}'></h2>
23658
23659 <h3 data-parsoid='{}'></h3>
23660
23661 <h4 data-parsoid='{}'></h4>
23662
23663 <h5 data-parsoid='{}'></h5>
23664
23665 <h6 data-parsoid='{}'></h6>
23666 !! wikitext
23667 =<nowiki/>=
23668
23669 ==<nowiki/>==
23670
23671 ===<nowiki/>===
23672
23673 ====<nowiki/>====
23674
23675 =====<nowiki/>=====
23676
23677 ======<nowiki/>======
23678 !!end
23679
23680 !! test
23681 Headings: 6a. Heading chars in SOL context (with trailing spaces)
23682 !! options
23683 parsoid=html2wt
23684 !! html/parsoid
23685 <p>=a=</p>
23686
23687 <p>=a=</p>
23688
23689 <p>=a=</p>
23690 !! wikitext
23691 <nowiki>=a=</nowiki>
23692
23693 <nowiki>=a=</nowiki>
23694
23695 <nowiki>=a=</nowiki>
23696 !!end
23697
23698 !! test
23699 Headings: 6b. Heading chars in SOL context (with trailing newlines)
23700 !! options
23701 parsoid=html2wt
23702 !! html/parsoid
23703 <p>=a=
23704 b</p>
23705
23706 <p>=a=
23707 b</p>
23708
23709 <p>=a=
23710 b</p>
23711 !! wikitext
23712 <nowiki>=a=</nowiki>
23713 b
23714
23715 <nowiki>=a=</nowiki>
23716 b
23717
23718 <nowiki>=a=</nowiki>
23719 b
23720 !!end
23721
23722 !! test
23723 Headings: 6c. Heading chars in SOL context (leading newline break)
23724 !! options
23725 parsoid=html2wt
23726 !! html/parsoid
23727 <p>a
23728 =b=</p>
23729 !! wikitext
23730 a
23731 <nowiki>=b=</nowiki>
23732 !!end
23733
23734 !! test
23735 Headings: 6d. Heading chars in SOL context (with interspersed comments)
23736 !! options
23737 parsoid=html2wt
23738 !! html/parsoid
23739 <!--c0--><p>=a=</p>
23740
23741 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
23742 !! wikitext
23743 <!--c0--><nowiki>=a=</nowiki>
23744
23745 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
23746 !!end
23747
23748 !! test
23749 Headings: 6d. Heading chars in SOL context (No escaping needed)
23750 !! options
23751 parsoid=html2wt
23752 !! html/parsoid
23753 =a=<div>b</div>
23754 !! wikitext
23755 =a=<div>b</div>
23756 !!end
23757
23758 !! test
23759 Headings: 7. Insert a newline between new content and headings
23760 !! options
23761 parsoid=html2wt
23762 !! html/parsoid
23763 <h2>NEW</h2>
23764 <p>new</p>
23765 <h2 data-parsoid='{}'>A</h2>
23766 <p data-parsoid='{}'>a</p>
23767 !! wikitext
23768 == NEW ==
23769 new
23770
23771 ==A==
23772 a
23773
23774 !! end
23775
23776 #### --------------- Lists ---------------
23777 #### 0. Outside nests (*foo, etc.)
23778 #### 1. Nested inside html <ul><li>*foo</li></ul>
23779 #### 2. Inside definition lists
23780 #### 3. Only bullets at start should be escaped
23781 #### 4. No escapes needed
23782 #### 5. No unnecessary escapes
23783 #### 6. Escape bullets in SOL position
23784 #### 7. Escape bullets in a multi-line context
23785 #### ----------------------------------------
23786
23787 !! test
23788 Lists: 0. Outside nests
23789 !! options
23790 parsoid=html2wt
23791 !! html/parsoid
23792 <p>*foo</p>
23793
23794 <p>#foo</p>
23795
23796 <p>;Foo:bar</p>
23797 !! wikitext
23798 <nowiki>*</nowiki>foo
23799
23800 <nowiki>#</nowiki>foo
23801
23802 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
23803 !!end
23804
23805 ## Making these next 3 tests Parsoid-only since they are html2wt tests
23806 ## to test wikitext escaping, and insignificant whitespace diffs
23807 ## cause PHP parser tests to barf
23808 !! test
23809 Lists: 1. Nested inside html (No unnecessary escapes)
23810 !! options
23811 parsoid=html2wt
23812 !! html/parsoid
23813 <ul>
23814 <li>*foo</li>
23815 <li>#foo</li>
23816 <li>:foo</li>
23817 <li>;foo</li>
23818 <li data-parsoid='{}'>*foo</li>
23819 <li data-parsoid='{}'>#foo</li>
23820 <li data-parsoid='{}'>:foo</li>
23821 <li data-parsoid='{}'>;foo</li>
23822 </ul>
23823
23824 <ol>
23825 <li>*foo</li>
23826 <li>#foo</li>
23827 <li>:foo</li>
23828 <li>;foo</li>
23829 <li data-parsoid='{}'>*foo</li>
23830 <li data-parsoid='{}'>#foo</li>
23831 <li data-parsoid='{}'>:foo</li>
23832 <li data-parsoid='{}'>;foo</li>
23833 </ol>
23834 !! wikitext
23835 * *foo
23836 * #foo
23837 * :foo
23838 * ;foo
23839 *<nowiki>*foo</nowiki>
23840 *<nowiki>#foo</nowiki>
23841 *<nowiki>:foo</nowiki>
23842 *<nowiki>;foo</nowiki>
23843
23844 # *foo
23845 # #foo
23846 # :foo
23847 # ;foo
23848 #<nowiki>*foo</nowiki>
23849 #<nowiki>#foo</nowiki>
23850 #<nowiki>:foo</nowiki>
23851 #<nowiki>;foo</nowiki>
23852 !!end
23853
23854 !! test
23855 Lists: 2. Inside definition lists
23856 !! options
23857 parsoid=html2wt
23858 !! html/parsoid
23859 <dl><dt>;foo</dt></dl>
23860 <dl><dt>:foo</dt></dl>
23861 <dl><dt>:foo</dt>
23862 <dd>bar</dd></dl>
23863 <dl><dd>:foo</dd></dl>
23864 !! wikitext
23865 ; ;foo
23866
23867 ; <nowiki>:foo</nowiki>
23868
23869 ; <nowiki>:foo</nowiki>
23870 : bar
23871
23872 : :foo
23873 !!end
23874
23875 !! test
23876 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
23877 !! options
23878 parsoid=html2wt
23879 !! html/parsoid
23880 <ul>
23881 <li>*foo*bar</li>
23882 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
23883 </ul>
23884 !! wikitext
23885 * *foo*bar
23886 *<nowiki>*foo</nowiki>''it''*bar
23887 !!end
23888
23889 !! test
23890 Lists: 4. No escapes needed
23891 !! options
23892 parsoid=html2wt
23893 !! html/parsoid
23894 <ul>
23895 <li>foo*bar
23896 </li>
23897 </ul>
23898 <ul>
23899 <li><i>foo</i>*bar
23900 </li>
23901 </ul>
23902 <ul>
23903 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
23904 </li>
23905 </ul>
23906 <ul>
23907 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
23908 </li>
23909 </ul>
23910 !! wikitext
23911 *foo*bar
23912
23913 *''foo''*bar
23914
23915 *[[Foo]]: bar
23916
23917 *[[Foo]]*bar
23918 !!end
23919
23920 !! test
23921 Lists: 5. No unnecessary escapes
23922 !! options
23923 parsoid=html2wt
23924 !! html/parsoid
23925 <ul><li> bar <span>[[foo]]</span></li></ul>
23926 <ul><li> =bar <span>[[foo]]</span></li></ul>
23927 <ul><li> [[bar <span>[[foo]]</span></li></ul>
23928 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
23929 <ul><li> =bar <span>foo]]</span>=</li></ul>
23930 <ul><li> <s></s>: a</li></ul>
23931 <ul><li> <i>* foo</i></li></ul>
23932
23933 !! wikitext
23934 * bar <span><nowiki>[[foo]]</nowiki></span>
23935
23936 * =bar <span><nowiki>[[foo]]</nowiki></span>
23937
23938 * [[bar <span><nowiki>[[foo]]</nowiki></span>
23939
23940 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
23941
23942 * =bar <span>foo]]</span>=
23943
23944 * <s></s>: a
23945
23946 * ''* foo''
23947 !!end
23948
23949 !! test
23950 Lists: 6. Escape bullets in SOL position
23951 !! options
23952 parsoid=html2wt
23953 !! html/parsoid
23954 <p><!--cmt-->*foo</p>
23955 !! wikitext
23956 <!--cmt--><nowiki>*</nowiki>foo
23957 !!end
23958
23959 !! test
23960 Lists: 7. Escape bullets in a multi-line context
23961 !! options
23962 parsoid=html2wt
23963 !! html/parsoid
23964 <p>a
23965 *b
23966 </p>
23967 !! wikitext
23968 a
23969 <nowiki>*</nowiki>b
23970 !!end
23971
23972 !! test
23973 Lists: 8. Escape colons only if not present in tags
23974 !! options
23975 parsoid=html2wt
23976 !! html/parsoid
23977 <dl><dt>a:b<i>c:d</i></dt></dl>
23978 !! wikitext
23979 ; <nowiki>a:b</nowiki>''c:d''
23980 !! end
23981
23982 #### --------------- HRs ---------------
23983 #### 1. Single line
23984 #### -----------------------------------
23985
23986 !! test
23987 HRs: 1. Single line
23988 !! options
23989 parsoid=html2wt
23990 !! html/parsoid
23991 <hr />----
23992 <hr />=foo=
23993 <hr />*foo
23994 !! wikitext
23995 ----<nowiki>----</nowiki>
23996 ----=foo=
23997 ----*foo
23998 !! end
23999
24000 #### --------------- Tables ---------------
24001 #### 1a. Simple example
24002 #### 1b. No escaping needed (!foo)
24003 #### 1c. No escaping needed (|foo)
24004 #### 1d. No escaping needed (|}foo)
24005 ####
24006 #### 2a. Nested in td (<td>foo|bar</td>)
24007 #### 2b. Nested in td (<td>foo||bar</td>)
24008 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
24009 ####
24010 #### 3a. Nested in th (<th>foo!bar</th>)
24011 #### 3b. Nested in th (<th>foo!!bar</th>)
24012 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
24013 ####
24014 #### 4a. Escape -
24015 #### 4b. Escape +
24016 #### 4c. No escaping needed
24017 #### --------------------------------------
24018
24019 !! test
24020 Tables: 1a. Simple example
24021 !! options
24022 parsoid=html2wt
24023 !! html/parsoid
24024 <p>{|
24025 |}
24026 </p>
24027 !! wikitext
24028 <nowiki>{|</nowiki>
24029 |}
24030 !! end
24031
24032 !! test
24033 Tables: 1b. No escaping needed
24034 !! options
24035 parsoid=html2wt
24036 !! html/parsoid
24037 <p>!foo
24038 </p>
24039 !! wikitext
24040 !foo
24041 !! end
24042
24043 !! test
24044 Tables: 1c. No escaping needed
24045 !! options
24046 parsoid=html2wt
24047 !! html/parsoid
24048 <p>|foo
24049 </p>
24050 !! wikitext
24051 |foo
24052 !! end
24053
24054 !! test
24055 Tables: 1d. No escaping needed
24056 !! options
24057 parsoid=html2wt
24058 !! html/parsoid
24059 <p>|}foo
24060 </p>
24061 !! wikitext
24062 |}foo
24063 !! end
24064
24065 !! test
24066 Tables: 2a. Nested in td
24067 !! options
24068 parsoid=html2wt
24069 !! html/parsoid
24070 <table><tbody><tr>
24071 <td>foo|bar</td></tr>
24072 <tr><td>x<div>a|b</div></td>
24073 </tbody></table>
24074 !! wikitext
24075 {|
24076 |<nowiki>foo|bar</nowiki>
24077 |-
24078 |x<div><nowiki>a|b</nowiki></div>
24079 |}
24080 !! html/php+tidy
24081 <table>
24082 <tr>
24083 <td>foo|bar</td>
24084 </tr>
24085 <tr>
24086 <td>x
24087 <div>a|b</div>
24088 </td>
24089 </tr>
24090 </table>
24091 !! end
24092
24093 !! test
24094 Tables: 2b. Nested in td
24095 !! options
24096 parsoid=html2wt
24097 !! html/parsoid
24098 <table><tbody><tr>
24099 <td>foo||bar</td>
24100 <td>a<i>b||c</i></td>
24101 <td>a<i><div>b||c</div></i></td>
24102 </tr></tbody></table>
24103 !! wikitext
24104 {|
24105 |<nowiki>foo||bar</nowiki>
24106 |a''<nowiki>b||c</nowiki>''
24107 |a''<div><nowiki>b||c</nowiki></div>''
24108 |}
24109 !! html/php
24110 <table>
24111 <tr>
24112 <td>foo||bar
24113 </td>
24114 <td>a<i>b||c</i>
24115 </td>
24116 <td>a<i><div>b||c</div></i>
24117 </td></tr></table>
24118
24119 !! end
24120
24121 !! test
24122 Tables: 2c. Nested in td -- no escaping needed
24123 !! options
24124 parsoid=html2wt
24125 !! html/*
24126 <table>
24127 <tr>
24128 <td>foo!!bar
24129 </td></tr></table>
24130
24131 !! wikitext
24132 {|
24133 |foo!!bar
24134 |}
24135 !! end
24136
24137 !! test
24138 Tables: 3a. Nested in th
24139 !! options
24140 parsoid=html2wt
24141 !! html/*
24142 <table>
24143 <tr>
24144 <th>foo!bar
24145 </th></tr></table>
24146
24147 !! wikitext
24148 {|
24149 !foo!bar
24150 |}
24151 !! end
24152
24153 !! test
24154 Tables: 3b. Nested in th
24155 !! options
24156 parsoid=html2wt
24157 !! html/parsoid
24158 <table><tbody>
24159 <tr><th>foo!!bar</th>
24160 <th><i>foo|bar</i></th>
24161 <th><i>foo!!bar</i></th>
24162 <th><i><span>foo!!bar</span></i></th>
24163 </tr></tbody></table>
24164 !! wikitext
24165 {|
24166 !<nowiki>foo!!bar</nowiki>
24167 !''<nowiki>foo|bar</nowiki>''
24168 !''<nowiki>foo!!bar</nowiki>''
24169 !''<span><nowiki>foo!!bar</nowiki></span>''
24170 |}
24171 !! html/php
24172 <table>
24173 <tr>
24174 <th>foo!!bar
24175 </th>
24176 <th><i>foo|bar</i>
24177 </th>
24178 <th><i>foo!!bar</i>
24179 </th>
24180 <th><i><span>foo!!bar</span></i>
24181 </th></tr></table>
24182
24183 !! end
24184
24185 !! test
24186 Tables: 3c. Nested in th
24187 !! options
24188 parsoid=html2wt
24189 !! html/parsoid
24190 <table><tbody>
24191 <tr><th>foo||bar</th>
24192 <th><span typeof="mw:Nowiki">foo||bar</span></th>
24193 </tr></tbody></table>
24194 !! wikitext
24195 {|
24196 !<nowiki>foo||bar</nowiki>
24197 !<nowiki>foo||bar</nowiki>
24198 |}
24199 !! html/php
24200 <table>
24201 <tr>
24202 <th>foo||bar
24203 </th>
24204 <th>foo||bar
24205 </th></tr></table>
24206
24207 !! end
24208
24209 !! test
24210 Tables: 4a. Escape -
24211 !! options
24212 parsoid=html2wt
24213 !! html/*
24214 <table>
24215 <tr>
24216 <th>-bar
24217 </th></tr>
24218 <tr>
24219 <td>-bar
24220 </td></tr></table>
24221
24222 !! wikitext
24223 {|
24224 !-bar
24225 |-
24226 |<nowiki>-bar</nowiki>
24227 |}
24228 !! end
24229
24230 !! test
24231 Tables: 4b. Escape +
24232 !! options
24233 parsoid=html2wt
24234 !! html/*
24235 <table>
24236 <tr>
24237 <th>+bar
24238 </th></tr>
24239 <tr>
24240 <td>+bar
24241 </td></tr></table>
24242
24243 !! wikitext
24244 {|
24245 !+bar
24246 |-
24247 |<nowiki>+bar</nowiki>
24248 |}
24249 !! end
24250
24251 !! test
24252 Tables: 4c. No escaping needed
24253 !! options
24254 parsoid=html2wt
24255 !! html/parsoid
24256 <table><tbody>
24257 <tr><td>foo-bar</td><td>foo+bar</td></tr>
24258 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
24259 <tr><td>foo
24260 <p>bar|baz
24261 +bar
24262 -bar</p></td></tr>
24263 <tr><td>x
24264 <div>a|b</div></td>
24265 </tbody></table>
24266 !! wikitext
24267 {|
24268 |foo-bar
24269 |foo+bar
24270 |-
24271 |''foo''-bar
24272 |''foo''+bar
24273 |-
24274 |foo
24275 bar|baz
24276 +bar
24277 -bar
24278 |-
24279 |x
24280 <div>a|b</div>
24281 |}
24282 !! html/php
24283 <table>
24284 <tr>
24285 <td>foo-bar
24286 </td>
24287 <td>foo+bar
24288 </td></tr>
24289 <tr>
24290 <td><i>foo</i>-bar
24291 </td>
24292 <td><i>foo</i>+bar
24293 </td></tr>
24294 <tr>
24295 <td>foo
24296 <p>bar|baz
24297 +bar
24298 -bar
24299 </p>
24300 </td></tr>
24301 <tr>
24302 <td>x
24303 <div>a|b</div>
24304 </td></tr></table>
24305
24306 !! end
24307
24308 !! test
24309 Tables: 4d. No escaping needed
24310 !! options
24311 parsoid=html2wt
24312 !! html/parsoid
24313 <table>
24314 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
24315 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
24316 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
24317 </tbody></table>
24318 !! wikitext
24319 {|
24320 |[[Foo]]-bar
24321 ||+1
24322 ||-2
24323 |}
24324 !! html/php
24325 <table>
24326 <tr>
24327 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
24328 </td>
24329 <td>+1
24330 </td>
24331 <td>-2
24332 </td></tr></table>
24333
24334 !! end
24335
24336 !! test
24337 T97430: Don't emit empty nowiki pairs around marker meta tags
24338 !! options
24339 parsoid=html2wt
24340 !! html/parsoid
24341 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
24342 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
24343 !! wikitext
24344 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
24345 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
24346 !! end
24347
24348 !! test
24349 Unclosed xmlish element in table line shouldn't eat end delimiters
24350 !! options
24351 parsoid=html2wt
24352 !! html/parsoid
24353 <table>
24354 <tbody><tr><td> &lt;foo</td>
24355 <td> bar></td></tr>
24356 </tbody></table>
24357 !! wikitext
24358 {|
24359 | <foo
24360 | bar>
24361 |}
24362 !! html/php
24363 <table>
24364 <tr>
24365 <td> &lt;foo
24366 </td>
24367 <td> bar&gt;
24368 </td></tr></table>
24369
24370 !! end
24371
24372 #### --------------- Links ----------------
24373 #### 1. Quote marks in link text
24374 #### 2. Wikilinks: Escapes needed
24375 #### 3. Wikilinks: No escapes needed
24376 #### 4. Extlinks: Escapes needed
24377 #### 5. Extlinks: No escapes needed
24378 #### --------------------------------------
24379 !! test
24380 Links 1. WikiLinks: No escapes needed
24381 !! options
24382 parsoid=html2wt
24383 !! html/parsoid
24384 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
24385 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
24386 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
24387 !! wikitext
24388 [[Foo|Foo''boo'']]
24389 [[Foo|[Foobar]]]
24390 [[Foo|x [Foobar] x]]
24391 !! html/php
24392 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
24393 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
24394 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
24395 </p>
24396 !! end
24397
24398 !! test
24399 Links 2. WikiLinks: Escapes needed
24400 !! options
24401 parsoid=html2wt
24402 !! html/parsoid
24403 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
24404 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
24405 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
24406 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
24407 <a href="Foo" rel="mw:WikiLink">|Bar</a>
24408 <a href="Foo" rel="mw:WikiLink">]]bar</a>
24409 <a href="Foo" rel="mw:WikiLink">[[bar</a>
24410 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
24411 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
24412 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
24413 !! wikitext
24414 [[Foo|<nowiki>Foobar]</nowiki>]]
24415 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
24416 [[Foo|<nowiki>[[Bar]]</nowiki>]]
24417 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
24418 [[Foo|<nowiki>|Bar</nowiki>]]
24419 [[Foo|<nowiki>]]bar</nowiki>]]
24420 [[Foo|<nowiki>[[bar</nowiki>]]
24421 [[Foo|<nowiki>x [[ y</nowiki>]]
24422 [[Foo|<nowiki>x ]] y</nowiki>]]
24423 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
24424 !! html/php
24425 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
24426 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
24427 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
24428 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
24429 <a href="/wiki/Foo" title="Foo">|Bar</a>
24430 <a href="/wiki/Foo" title="Foo">]]bar</a>
24431 <a href="/wiki/Foo" title="Foo">[[bar</a>
24432 <a href="/wiki/Foo" title="Foo">x [[ y</a>
24433 <a href="/wiki/Foo" title="Foo">x ]] y</a>
24434 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
24435 </p>
24436 !! end
24437
24438 !! test
24439 Links 3. WikiLinks: No escapes needed
24440 !! options
24441 parsoid=html2wt
24442 !! html/parsoid
24443 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
24444 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
24445 !! wikitext
24446 [[Foo|[Foobar]]
24447 [[Foo|foo|bar]]
24448 !! html/php
24449 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
24450 <a href="/wiki/Foo" title="Foo">foo|bar</a>
24451 </p>
24452 !! end
24453
24454 !! test
24455 Links 4. ExtLinks: Escapes needed
24456 !! options
24457 parsoid=html2wt
24458 !! html/parsoid
24459 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
24460 <a rel="mw:ExtLink" href="http://google.com">google]</a>
24461 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
24462 <p>[http://google.com]</p>
24463 <p>[http://google.com google]</p>
24464 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
24465 <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>
24466 !! wikitext
24467 [http://google.com <nowiki>[google]</nowiki>]
24468 [http://google.com <nowiki>google]</nowiki>]
24469 [http://google.com <nowiki>goog] le</nowiki>]
24470
24471 <nowiki>[http://google.com]</nowiki>
24472
24473 <nowiki>[http://google.com google]</nowiki>
24474
24475 [http://google.com<nowiki>]</nowiki>
24476
24477 [{{echo|http://google.com}}<nowiki>]</nowiki>
24478 !! html/php
24479 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
24480 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
24481 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
24482 </p><p>[http://google.com]
24483 </p><p>[http://google.com google]
24484 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
24485 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
24486 </p>
24487 !! end
24488
24489 !! test
24490 Links 5. ExtLinks: No escapes needed
24491 !! options
24492 parsoid=html2wt
24493 !! html/parsoid
24494 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
24495 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
24496 !! wikitext
24497 [http://google.com [google]
24498
24499 [[http://google.com]]
24500 !! html/php
24501 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
24502 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
24503 </p>
24504 !! end
24505
24506 !! test
24507 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
24508 !! options
24509 parsoid=html2wt
24510 !! html/parsoid
24511 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
24512 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
24513 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
24514 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
24515 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
24516 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
24517 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
24518 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
24519 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
24520 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
24521 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
24522 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
24523 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
24524 </p>
24525 !! wikitext
24526 x<nowiki/>http://example.com<nowiki/>y
24527 http://example.com<nowiki/>?x
24528 http://example.com<nowiki/>&x
24529 http://example.com<nowiki/>'x
24530 http://example.com<nowiki/>,x
24531 http://example.com<nowiki/>.x
24532 http://example.com<nowiki/>;x
24533 http://example.com<nowiki/>:x
24534 http://example.com<nowiki/>;x
24535 http://example.com<nowiki/>!x
24536 http://example.com<nowiki/>=x
24537 http://example.com<nowiki/>(x)
24538 http://example.com(x<nowiki/>)
24539 !! end
24540
24541 !! test
24542 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
24543 !! options
24544 parsoid=html2wt
24545 !! html/parsoid
24546 <p>x
24547 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
24548 y
24549 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
24550 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
24551 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
24552 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
24553 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
24554 </p>
24555 !! wikitext
24556 x
24557 http://example.com
24558 y
24559 "http://example.com"
24560 (http://example.com)
24561 (http://example.com) foo
24562 http://example.com,
24563 http://example.com, foo
24564 !! html/php
24565 <p>x
24566 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
24567 y
24568 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
24569 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
24570 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
24571 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
24572 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
24573 </p>
24574 !! end
24575
24576 !! test
24577 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
24578 !! options
24579 parsoid=html2wt
24580 !! html/parsoid
24581 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
24582 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
24583 !! wikitext
24584 http://example.com.,;:!?\
24585 -http://example.com:
24586 !! html/php
24587 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
24588 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
24589 </p>
24590 !! end
24591
24592 !! test
24593 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
24594 !! options
24595 parsoid=html2wt
24596 !! html/parsoid
24597 <p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
24598 <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
24599 X<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
24600 !! wikitext
24601 RFC 123<nowiki/>4
24602 RFC 123<nowiki/>y
24603 X<nowiki/>RFC 123<nowiki/>y
24604 !! end
24605
24606 !! test
24607 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
24608 !! options
24609 parsoid=html2wt
24610 !! html/parsoid
24611 <p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
24612 <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
24613 -<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
24614 </p>
24615 !! wikitext
24616 RFC 123?foo
24617 RFC 123&foo
24618 -RFC 123-
24619 !! html/php
24620 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>?foo
24621 <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
24622 -<a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>-
24623 </p>
24624 !! end
24625
24626 !! test
24627 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
24628 !! options
24629 parsoid=html2wt
24630 !! html/parsoid
24631 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
24632 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
24633 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
24634 !! wikitext
24635 PMID 123<nowiki/>4
24636 PMID 123<nowiki/>y
24637 X<nowiki/>PMID 123<nowiki/>y
24638 !! end
24639
24640 !! test
24641 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
24642 !! options
24643 parsoid=html2wt
24644 !! html/parsoid
24645 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
24646 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
24647 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
24648 </p>
24649 !! wikitext
24650 PMID 123?foo
24651 PMID 123&foo
24652 -PMID 123-
24653 !! html/php
24654 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
24655 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
24656 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
24657 </p>
24658 !! end
24659
24660 !! test
24661 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
24662 !! options
24663 parsoid=html2wt
24664 !! html/parsoid
24665 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
24666 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
24667 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
24668 </p>
24669 !! wikitext
24670 ISBN 1234567890<nowiki/>1
24671 ISBN 1234567890<nowiki/>x
24672 a<nowiki/>ISBN 1234567890<nowiki/>b
24673 !! end
24674
24675 !! test
24676 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
24677 !! options
24678 parsoid=html2wt
24679 !! html/parsoid
24680 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
24681 !! wikitext
24682 -ISBN 1234567890's
24683 !! html/php
24684 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
24685 </p>
24686 !! end
24687
24688 !! test
24689 Links 14. Protect link-like plain text. (Parsoid bug T78425)
24690 !! options
24691 parsoid=html2wt
24692 !! html/*
24693 <p>this is not a link: http://example.com
24694 </p>
24695 !! wikitext
24696 this is not a link: <nowiki>http://example.com</nowiki>
24697 !! end
24698
24699 !! test
24700 Links 15. Link trails can't become link prefixes.
24701 !! options
24702 language=is
24703 parsoid=html2wt
24704 !! html/parsoid
24705 <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>
24706 !! wikitext
24707 [[Söfnuður]]-[[00]]
24708 !! html/php
24709 <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>
24710 </p>
24711 !! end
24712
24713 #### --------------- Quotes ---------------
24714 #### 1. Quotes inside <b> and <i>
24715 #### 2. Link fragments separated by <i> and <b> tags
24716 #### 3. Link fragments inside <i> and <b>
24717 #### 4. No escaping needed
24718 #### --------------------------------------
24719 !! test
24720 1a. Quotes inside <b> and <i>
24721 !! options
24722 parsoid=html2wt
24723 !! html/*
24724 <p><i>'foo'</i>
24725 <i>''foo''</i>
24726 <i>'''foo'''</i>
24727 <i>foo</i>'s
24728 <b>'foo'</b>
24729 <b>''foo''</b>
24730 <b>'''foo'''</b>
24731 <b>foo'<i>bar'</i>baz</b>
24732 <b>foo</b>'s
24733 '<i>foo</i>
24734 <i>foo</i>'
24735 <i>foo'</i>'
24736 '<i>foo</i>'
24737 '<b>foo</b>
24738 <b>foo</b>'
24739 '<b>foo</b>'
24740 <i>fools'<span> errand</span></i>
24741 <i><span>fool</span>'s errand</i>
24742 '<i>foo</i> bar '<i>baz</i>
24743 a|!*#-:;+-~[]{}b'<i>x</i>
24744 </p>
24745 !! wikitext
24746 ''<nowiki/>'foo'''
24747 ''<nowiki>''foo''</nowiki>''
24748 ''<nowiki>'''foo'''</nowiki>''
24749 ''foo''<nowiki/>'s
24750 '''<nowiki/>'foo''''
24751 '''<nowiki>''foo''</nowiki>'''
24752 '''<nowiki>'''foo'''</nowiki>'''
24753 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
24754 '''foo'''<nowiki/>'s
24755 '''foo''
24756 ''foo''<nowiki/>'
24757 ''foo'''<nowiki/>'
24758 '''foo''<nowiki/>'
24759 ''''foo'''
24760 '''foo'''<nowiki/>'
24761 ''''foo'''<nowiki/>'
24762 ''fools'<span> errand</span>''
24763 ''<span>fool</span>'s errand''
24764 '<nowiki/>''foo'' bar '''baz''
24765 a|!*#-:;+-~[]{}b'''x''
24766 !! end
24767
24768 !! test
24769 1b. Quotes inside <b> and <i> with other tags on same line
24770 !! options
24771 parsoid=html2wt
24772 !! html/parsoid
24773 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
24774 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
24775 <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>
24776 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
24777 '<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>
24778 '<i>foo</i> <div title="name">test</div>
24779 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
24780 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
24781 <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>
24782 </ol>
24783 !! wikitext
24784 '''a'' foo ''[[bar]]''
24785 ''a''' foo ''[[bar]]''
24786 ''a''' foo '''{{echo|[[bar]]}}'''
24787 [[foo]] x'''[[bar]]''
24788 '''foo'' <ref>test</ref>
24789 '''foo'' <div title="name">test</div>
24790 '''foo'' and <br> bar
24791 <references />
24792 !! end
24793
24794 !! test
24795 2. Link fragments separated by <i> and <b> tags
24796 !! options
24797 parsoid=html2wt
24798 !! html/parsoid
24799 <p>[[<i>foo</i>hello]]</p>
24800 <p>[[<b>foo</b>hello]]</p>
24801 !! wikitext
24802 [[''foo''<nowiki>hello]]</nowiki>
24803
24804 [['''foo'''<nowiki>hello]]</nowiki>
24805 !! end
24806
24807 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
24808 # this is one of the shortcomings of this format
24809 !! test
24810 3. Link fragments inside <i> and <b>
24811 !! options
24812 parsoid=html2wt
24813 !! html/parsoid
24814 <p><i>[[foo</i>]]</p>
24815 <p><b>[[foo</b>]]</p>
24816 !! wikitext
24817 ''[[foo''<nowiki>]]</nowiki>
24818
24819 '''[[foo'''<nowiki>]]</nowiki>
24820 !! end
24821
24822 !! test
24823 4. No escaping needed
24824 !! options
24825 parsoid=html2wt
24826 !! html/parsoid
24827 <p>'<span><i>bar</i></span>'
24828 '<span><b>bar</b></span>'
24829 'a:b'foo
24830 </p>
24831 !! wikitext
24832 '<span>''bar''</span>'
24833 '<span>'''bar'''</span>'
24834 'a:b'foo
24835 !! end
24836
24837 #### ----------- Paragraphs ---------------
24838 #### 1. No unnecessary escapes
24839 #### --------------------------------------
24840
24841 !! test
24842 1. No unnecessary escapes
24843 !! options
24844 parsoid=html2wt
24845 !! html/parsoid
24846 <p>bar <span>[[foo]]</span>
24847 </p><p>=bar <span>[[foo]]</span>
24848 </p><p>[[bar <span>[[foo]]</span>
24849 </p><p>]]bar <span>[[foo]]</span>
24850 </p><p>=bar <span>foo]]</span>=
24851 </p>
24852 !! wikitext
24853 bar <span><nowiki>[[foo]]</nowiki></span>
24854
24855 =bar <span><nowiki>[[foo]]</nowiki></span>
24856
24857 [[bar <span><nowiki>[[foo]]</nowiki></span>
24858
24859 ]]bar <span><nowiki>[[foo]]</nowiki></span>
24860
24861 =bar <span>foo]]</span><nowiki>=</nowiki>
24862 !!end
24863
24864 #### ----------------------- PRE --------------------------
24865 #### 1. Leading whitespace in SOL context should be escaped
24866 #### ------------------------------------------------------
24867 !! test
24868 1. Leading whitespace in SOL context should be escaped
24869 !! options
24870 parsoid=html2wt
24871 !! html/parsoid
24872 <p> a</p>
24873
24874 <p> a</p>
24875
24876 <p> a(tab)</p>
24877
24878 <p> a
24879 <!--cmt-->
24880 a</p>
24881
24882 <p>a
24883 b</p>
24884
24885 <p>a
24886 b</p>
24887
24888 <p>a
24889 b</p>
24890 !! wikitext
24891 <nowiki> </nowiki>a
24892
24893 <nowiki> </nowiki> a
24894
24895 a(tab)
24896
24897 <nowiki> </nowiki> a
24898 <!--cmt-->
24899 <nowiki> </nowiki>a
24900
24901 a
24902 <nowiki> </nowiki>b
24903
24904 a
24905 b
24906
24907 a
24908 b
24909 !! html/php
24910 <p> a
24911 </p><p> a
24912 </p><p> a(tab)
24913 </p><p> a
24914 a
24915 </p><p>a
24916 b
24917 </p><p>a
24918 b
24919 </p><p>a
24920 b
24921 </p>
24922 !! end
24923
24924 !! test
24925 2. Leading whitespace in non-indent-pre contexts should not be escaped
24926 !! options
24927 parsoid=html2wt
24928 !! html/parsoid
24929 <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>
24930 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
24931 <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>
24932 b</span></li>
24933 </ol>
24934 !! wikitext
24935 foo <ref>''a''
24936 b</ref>
24937 <references />
24938 !! end
24939
24940 !! test
24941 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
24942 !! options
24943 parsoid=html2wt
24944 !! html/parsoid
24945 <blockquote>
24946 <p>
24947 a
24948 <span>b</span>
24949 c</p>
24950 </blockquote>
24951 !! wikitext
24952 <blockquote>
24953 a
24954 <span>b</span>
24955 c
24956 </blockquote>
24957 !! end
24958
24959 !! test
24960 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
24961 !! options
24962 parsoid=html2wt
24963 !! html/parsoid
24964 <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>
24965 !! wikitext
24966 [[File:Foobar.jpg|thumb|caption]]
24967 !! end
24968
24969 !! test
24970 5. Nowiki escaping should account for indent-pres
24971 !! options
24972 parsoid=html2wt
24973 !! html/parsoid
24974 <pre>==foo==</pre>
24975 !! wikitext
24976 ==foo==
24977 !! end
24978
24979 !!test
24980 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
24981 !! options
24982 parsoid=html2wt
24983 !! html/parsoid
24984 <pre>
24985 * foo
24986 * bar
24987 </pre>
24988 !! wikitext
24989 * foo
24990 * bar
24991 !! end
24992
24993 #### --------------- Behavior Switches --------------------
24994
24995 !! test
24996 1. Valid behavior switches should be escaped
24997 !! options
24998 parsoid=html2wt
24999 !! html/parsoid
25000 __TOC__
25001 <i>__TOC__</i>
25002 !! wikitext
25003 <nowiki>__TOC__</nowiki>
25004 ''<nowiki>__TOC__</nowiki>''
25005 !! end
25006
25007 !! test
25008 2. Invalid behavior switches should not be escaped
25009 !! options
25010 parsoid=html2wt
25011 !! html/parsoid
25012 __TOO__
25013 __|__
25014 !! wikitext
25015 __TOO__
25016 __|__
25017 !! end
25018
25019 # We use indent-pre as an indirect way to test for sol-transparent behavior.
25020 !! test
25021 Behavior switches should be SOL-transparent
25022 !! options
25023 parsoid=html2wt
25024 !! html/parsoid
25025 <meta property="mw:PageProp/toc" />
25026
25027 <!-- this one's bogus -->
25028 <pre>__TOO__</pre>
25029
25030 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
25031
25032 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
25033 !! wikitext
25034 __TOC__
25035
25036 <!-- this one's bogus -->
25037 __TOO__
25038
25039 __TOC__ foo
25040
25041 __TOC__
25042 bar
25043 !! end
25044
25045 #### --------------- HTML tags ---------------
25046 #### 1. a tags
25047 #### 2. other tags
25048 #### 3. multi-line html tag
25049 #### 4. extension tags
25050 #### -----------------------------------------
25051 !! test
25052 1. a tags
25053 !! options
25054 parsoid=html2wt
25055 !! html/parsoid
25056 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
25057 !! wikitext
25058 <a href="http://google.com">google</a>
25059 !! end
25060
25061 !! test
25062 2. other tags
25063 !! options
25064 parsoid=html2wt
25065 !! html/parsoid
25066 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
25067 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
25068 <li> &lt;td&gt;</li></ul>
25069
25070 !! wikitext
25071 * <nowiki><div>foo</div></nowiki>
25072 * <nowiki><div style="color:red">foo</div></nowiki>
25073 * <nowiki><td></nowiki>
25074 !! end
25075
25076 !! test
25077 3. multi-line html tag
25078 !! options
25079 parsoid=html2wt
25080 !! html/parsoid
25081 <p>&lt;div
25082 &gt;foo&lt;/div
25083 &gt;
25084 </p>
25085 !! wikitext
25086 <nowiki><div
25087 >foo</div
25088 ></nowiki>
25089 !! end
25090
25091 !! test
25092 4. extension tags
25093 !! options
25094 parsoid=html2wt
25095 !! html/parsoid
25096 <p>&lt;ref&gt;foo&lt;/ref&gt;
25097 </p><p>&lt;ref&gt;bar
25098 </p><p>baz&lt;/ref&gt;
25099 </p>
25100 !! wikitext
25101 <nowiki><ref>foo</ref></nowiki>
25102
25103 <nowiki><ref>bar</nowiki>
25104
25105 baz<nowiki></ref></nowiki>
25106 !! end
25107
25108 #### --------------- Others ---------------
25109 !! test
25110 Escaping nowikis
25111 !! options
25112 parsoid=html2wt
25113 !! html/parsoid
25114 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
25115 </p>
25116 !! wikitext
25117 &lt;nowiki&gt;foo&lt;/nowiki&gt;
25118 !! end
25119
25120 ## The quote-char in the input is necessary for triggering the bug
25121 !! test
25122 (T54035) Nowiki-escaping should not get tripped by " :" in text
25123 !! options
25124 parsoid=html2wt
25125 !! html/parsoid
25126 <p>foo's bar :</p>
25127 !! wikitext
25128 foo's bar :
25129 !! end
25130
25131 #----------- End of wikitext escaping tests --------------
25132
25133 !! test
25134
25135 Tag-like HTML structures are passed through as text
25136 !! wikitext
25137 <x y>
25138
25139 <x.y>
25140
25141 <x-y>
25142
25143 1>2
25144
25145 x<y
25146
25147 a>b
25148
25149 1<d e>f
25150 !! html
25151 <p>&lt;x y&gt;
25152 </p><p>&lt;x.y&gt;
25153 </p><p>&lt;x-y&gt;
25154 </p><p>1&gt;2
25155 </p><p>x&lt;y
25156 </p><p>a&gt;b
25157 </p><p>1&lt;d e&gt;f
25158 </p>
25159 !! end
25160
25161 !! test
25162 HTML tag with necessary entities in attributes
25163 !! wikitext
25164 <span title="&amp;amp;">foo</span>
25165 !! html
25166 <p><span title="&amp;amp;">foo</span>
25167 </p>
25168 !! end
25169
25170 !! test
25171 HTML tag with 'unnecessary' entity encoding in attributes
25172 !! wikitext
25173 <span title="&amp;">foo</span>
25174 !! html
25175 <p><span title="&amp;">foo</span>
25176 </p>
25177 !! end
25178
25179 !! test
25180 HTML tag with broken attribute value quoting
25181 !! options
25182 parsoid=wt2html,html2html
25183 !! wikitext
25184 <span title="Hello world>Foo</span>
25185 !! html/php
25186 <p><span title="Hello world">Foo</span>
25187 </p>
25188 !! html/parsoid
25189 <p><span title="Hello world">Foo</span></p>
25190 !! end
25191
25192 !! test
25193 Self-closed tag with broken attribute value quoting
25194 !! options
25195 parsoid=wt2html,html2html
25196 !! wikitext
25197 <div title="Hello world />Foo
25198 !! html/php+tidy
25199 <div title="Hello world"></div>
25200 <p>Foo</p>
25201 !! html/parsoid
25202 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
25203 !! end
25204
25205 !! test
25206 Table with broken attribute value quoting
25207 !! options
25208 parsoid=wt2html,html2html
25209 !! wikitext
25210 {|
25211 | title="Hello world|Foo
25212 |}
25213 !! html/php
25214 <table>
25215 <tr>
25216 <td title="Hello world">Foo
25217 </td></tr></table>
25218
25219 !! html/parsoid
25220 <table>
25221 <tr>
25222 <td title="Hello world">Foo
25223 </td></tr></table>
25224
25225 !! end
25226
25227 !! test
25228 Table with broken attribute value quoting on consecutive lines
25229 !! options
25230 parsoid=wt2html,html2html
25231 !! wikitext
25232 {|
25233 | title="Hello world|Foo
25234 | style="color:red|Bar
25235 |}
25236 !! html/php
25237 <table>
25238 <tr>
25239 <td title="Hello world">Foo
25240 </td>
25241 <td style="color:red">Bar
25242 </td></tr></table>
25243
25244 !! html/parsoid
25245 <table><tbody>
25246 <tr>
25247 <td title="Hello world">Foo
25248 </td><td style="color: red">Bar
25249 </td></tr></tbody></table>
25250
25251 !! end
25252
25253 !!test
25254 Accept empty td cell attribute
25255 !! wikitext
25256 {|
25257 | align="center" | foo || |
25258 |}
25259 !! html
25260 <table>
25261 <tr>
25262 <td align="center"> foo </td>
25263 <td>
25264 </td></tr></table>
25265
25266 !!end
25267
25268 !!test
25269 Non-empty attributes in th-cells
25270 !! wikitext
25271 {|
25272 ! Foo !! style="color: red" | Bar
25273 |}
25274 !! html
25275 <table>
25276 <tr>
25277 <th> Foo </th>
25278 <th style="color: red"> Bar
25279 </th></tr></table>
25280
25281 !!end
25282
25283 !!test
25284 Accept empty attributes in th-cells
25285 !! wikitext
25286 {|
25287 !| foo !!| bar
25288 |}
25289 !! html
25290 <table>
25291 <tr>
25292 <th> foo </th>
25293 <th> bar
25294 </th></tr></table>
25295
25296 !!end
25297
25298 !!test
25299 Empty table rows go away
25300 !! wikitext
25301 {|
25302 | Hello
25303 | there
25304 |- class="foo"
25305 |-
25306 |}
25307 !! html
25308 <table>
25309 <tr>
25310 <td> Hello
25311 </td>
25312 <td> there
25313 </td></tr>
25314
25315 </table>
25316
25317 !! end
25318
25319 ###
25320 ### Parsoid-centric tests for testing RTing of inter-element separators
25321 ### Edge cases not tested by existing parser tests and specific to
25322 ### Parsoid-specific serialization strategies.
25323 ###
25324
25325 !!test
25326 RT-ed inter-element separators should be valid separators
25327 !! wikitext
25328 {|
25329 |- [[foo]]
25330 |}
25331 !! html/php
25332 <table>
25333
25334 </table>
25335
25336 !! html/parsoid
25337 <table>
25338 <tbody><tr data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
25339 </tbody></table>
25340 !!end
25341
25342 # Parsoid-only since PHP parser relies on Tidy for correct output
25343 !!test
25344 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
25345 !!options
25346 parsoid
25347 !! wikitext
25348 {|
25349 |<small>foo
25350 bar
25351 |}
25352
25353 {|
25354 |<small>foo<small>
25355 |}
25356 !! html
25357 <table>
25358 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
25359 <p>bar</p></small></td></tr>
25360 </tbody></table>
25361
25362 <table>
25363 <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>
25364 </tbody></table>
25365 !!end
25366
25367 # Note that the "style" attribute is really a template parameter here.
25368 # The = would have to be {{=}} if you wanted the literal.
25369 !!test
25370 Empty TD followed by TD with tpl-generated attribute
25371 !! wikitext
25372 {|
25373 |-
25374 |
25375 |{{echo|style='color:red'}}|foo
25376 |}
25377 !! html
25378 <table>
25379
25380 <tr>
25381 <td>
25382 </td>
25383 <td>foo
25384 </td></tr></table>
25385
25386 !!end
25387
25388 !!test
25389 Indented table with an empty td
25390 !! wikitext
25391 {|
25392 |-
25393 |
25394 |foo
25395 |}
25396 !! html
25397 <table>
25398
25399 <tr>
25400 <td>
25401 </td>
25402 <td>foo
25403 </td></tr></table>
25404
25405 !!end
25406
25407 ## We have some newline diffs RT-ing this edge case
25408 ## and it is not important enough -- we seem to be emitting
25409 ## at most 2 newlines after a </tr> and this is unrelated to
25410 ## the issue from T85627 that this is testing.
25411 !!test
25412 Indented table with blank lines in between (T85627)
25413 !! options
25414 parsoid=wt2html
25415 !! wikitext
25416 {|
25417 |foo
25418
25419
25420 |}
25421 !! html
25422 <table>
25423
25424 <tr>
25425 <td>foo
25426 </td></tr></table>
25427
25428 !!end
25429
25430 !!test
25431 Indented block & table
25432 !! wikitext
25433 <div>foo</div>
25434 {|
25435 |foo
25436 |}
25437 !! html/php
25438 <div>foo</div>
25439 <table>
25440 <tr>
25441 <td>foo
25442 </td></tr></table>
25443
25444 !! html/parsoid
25445 <div data-parsoid='{"stx":"html"}'>foo</div>
25446 <table><tbody>
25447 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
25448 </tbody></table>
25449 !!end
25450
25451 !! test
25452 Indent and comment before table row
25453 !! wikitext
25454 {|
25455 <!--hi-->|-
25456 | there
25457 |}
25458 !! html/php
25459 <table>
25460
25461 <tr>
25462 <td> there
25463 </td></tr></table>
25464
25465 !! html/parsoid
25466 <table>
25467 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
25468 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
25469 </tbody></table>
25470 !! end
25471
25472 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
25473 !!test
25474 Empty TR followed by a template-generated TR
25475 !!options
25476 parsoid
25477 !! wikitext
25478 {|
25479 |-
25480 {{echo|<tr><td>foo</td></tr>}}
25481 |}
25482 !! html
25483 <table>
25484 <tbody>
25485 <tr></tr>
25486 <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}}]}'>
25487 <td>foo</td></tr>
25488 </tbody></table>
25489 !!end
25490
25491 ## PHP and parsoid output differ for this, and since this is primarily
25492 ## for testing Parsoid's serializer, marking this Parsoid only
25493 !!test
25494 Empty TR followed by mixed-ws-comment line should RT correctly
25495 !!options
25496 parsoid
25497 !! wikitext
25498 {|
25499 |-
25500 <!--c-->
25501 |-
25502 <!--c--> <!--d-->
25503 |}
25504 !! html
25505 <table>
25506 <tbody>
25507 <tr></tr>
25508 <!--c-->
25509 <tr>
25510 <!--c--> </tr><!--d-->
25511 </tbody></table>
25512
25513 !!end
25514
25515 !!test
25516 Multi-line image caption generated by templates with/without trailing newlines
25517 !! wikitext
25518 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
25519 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
25520 !! html/parsoid
25521 <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>
25522 <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>
25523 !!end
25524
25525 !! test
25526 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
25527 !! options
25528 parsoid=html2wt
25529 !! html/parsoid
25530 <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>
25531
25532 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
25533 !! wikitext
25534 <includeonly>foo</includeonly>
25535 new para
25536
25537 [[Category:Foo]]
25538
25539 = new heading =
25540 !! end
25541
25542 ## PHP emits broken html for this, and since this is primarily
25543 ## a Parsoid serializer test, marking this Parsoid only
25544 !!test
25545 Improperly nested inline or quotes tags with whitespace in between
25546 !! wikitext
25547 <span> <s>x</span> </s>
25548 ''' ''x''' ''
25549 !! html/parsoid
25550 <p><span> <s>x</s></span><s> </s>
25551 <b> <i>x</i></b><i> </i>
25552 </p>
25553 !!end
25554
25555 !!test
25556 Encapsulate protected attributes from wt
25557 !! wikitext
25558 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
25559
25560 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
25561 | ok
25562 |}
25563 !! html/parsoid
25564 <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>
25565
25566 <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">
25567 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'> ok</td></tr>
25568 </tbody></table>
25569 !!end
25570
25571 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
25572 ## Having nested or stray pre tags results in the attempt to add duplicates,
25573 ## causing an assertion fail. This test tries to prevent that situation.
25574 !!test
25575 Ensure ParagraphWrapper can deal with stray closing pre tags
25576 !!options
25577 parsoid=wt2html
25578 !! wikitext
25579 plain text</pre>
25580 !! html/parsoid
25581 plain text
25582 !!end
25583
25584 !!test
25585 1. Ensure fostered text content is wrapped in element nodes
25586 !!options
25587 parsoid=wt2html
25588 !! wikitext
25589 <table>hi</table><table>ho</table>
25590 !! html/parsoid
25591 <p>hi</p>
25592 <table></table>
25593 <p>ho</p>
25594 <table></table>
25595 !!end
25596
25597 !!test
25598 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
25599 !!options
25600 parsoid=wt2html,wt2wt
25601 !! wikitext
25602 <table>
25603 <tr> || ||
25604 <td> a
25605 </table>
25606 !! html/parsoid
25607 <p> || ||
25608 </p><table>
25609 <tbody><tr><td> a</td></tr>
25610 </tbody></table>
25611 !!end
25612
25613 !!test
25614 Encapsulation properly handles null DSR information from foster box
25615 !!options
25616 parsoid=wt2html,wt2wt
25617 !! wikitext
25618 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
25619 !! html/parsoid
25620 <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>
25621 !!end
25622
25623 !!test
25624 1. Encapsulate foster-parented transclusion content
25625 !!options
25626 parsoid=wt2wt,wt2html
25627 !! wikitext
25628 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
25629 !! html/parsoid
25630 <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>
25631 <tbody>
25632 <tr>
25633 <td>bar</td>
25634 </tr>
25635 </tbody>
25636 </table>
25637 !!end
25638
25639 !!test
25640 2. Encapsulate foster-parented transclusion content
25641 !!options
25642 parsoid=wt2wt,wt2html
25643 !! wikitext
25644 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
25645 !! html/parsoid
25646 <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>
25647 <table>
25648 <tbody>
25649 <tr>
25650 <td>bar</td>
25651 </tr>
25652 </tbody>
25653 </table>
25654 !!end
25655
25656 !!test
25657 3. Encapsulate foster-parented transclusion content
25658 !!options
25659 parsoid=wt2wt,wt2html
25660 !! wikitext
25661 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
25662 !! html/parsoid
25663 <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;]}">
25664 <p>foo</p>
25665 </div>
25666 <table>
25667 <tbody>
25668 <tr>
25669 <td>bar</td>
25670 </tr>
25671 </tbody>
25672 </table>
25673 !!end
25674
25675 !!test
25676 4. Encapsulate foster-parented transclusion content
25677 !!options
25678 parsoid=wt2wt,wt2html
25679 !! wikitext
25680 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
25681 !! html/parsoid
25682 <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;]}">
25683 <p>foo</p>
25684 </div>
25685 <table>
25686 <tbody>
25687 <tr>
25688 <td>bar</td>
25689 </tr>
25690 </tbody>
25691 </table>
25692 !!end
25693
25694 !!test
25695 5. Encapsulate foster-parented transclusion content
25696 !!options
25697 parsoid=wt2wt,wt2html
25698 !! wikitext
25699 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
25700 !! html/parsoid
25701 <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>
25702 <table>
25703 <tbody>
25704 <tr>
25705 <td>
25706 <div>
25707 <p>foo</p>
25708 </div>
25709 </td>
25710 </tr>
25711 </tbody>
25712 </table>
25713 !!end
25714
25715 !!test
25716 6. Encapsulate foster-parented transclusion content
25717 !!options
25718 parsoid=wt2wt,wt2html
25719 !! wikitext
25720 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
25721 !! html/parsoid
25722 <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>
25723 <table>
25724 <tbody>
25725 <tr>
25726 <td>
25727 <div>
25728 <p>foo</p>
25729 </div>
25730 </td>
25731 </tr>
25732 </tbody>
25733 </table>
25734 <p>ok</p>
25735 !!end
25736
25737 !!test
25738 7. Encapsulate foster-parented transclusion content
25739 !!options
25740 parsoid=wt2wt,wt2html
25741 !! wikitext
25742 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
25743 !! html/parsoid
25744 <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>
25745 <table>
25746 <tbody>
25747 <tr>
25748 <td>bar</td>
25749 </tr>
25750 </tbody>
25751 </table>
25752 !!end
25753
25754 # Note that the wt is broken on purpose: the = should be {{=}} if you
25755 # don't want it to be a template parameter key.
25756 !!test
25757 8. Encapsulate foster-parented transclusion content
25758 !!options
25759 parsoid=wt2wt,wt2html
25760 !! wikitext
25761 {{echo|a
25762 }}{|{{echo|style='color:red'}}
25763 |-
25764 |b
25765 |}
25766 !! html/parsoid
25767 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}'>a</p>
25768 <span> </span>
25769 <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>
25770 <table>
25771 <tbody>
25772 <tr>
25773 <td>b</td>
25774 </tr>
25775 </tbody>
25776 </table>
25777 !!end
25778
25779 !!test
25780 9. Encapsulate foster-parented transclusion content
25781 !!options
25782 parsoid=wt2wt,wt2html
25783 !! wikitext
25784 <table>{{echo|hi</table>hello}}
25785 !! html/parsoid
25786 <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>
25787 !!end
25788
25789 !!test
25790 Table in fosterable position
25791 !!options
25792 parsoid=wt2html
25793 !! wikitext
25794 {{OpenTable}}
25795 <div>
25796 {|
25797 |}
25798 </div>
25799 |}
25800 !! html/parsoid
25801 <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">
25802 </span>
25803 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
25804
25805 <table>
25806 </table>
25807 !!end
25808
25809 # Parsoid only for T66747
25810 !! test
25811 Properly encapsulate empty-content transclusions in fosterable positions
25812 !! wikitext
25813 <table>
25814 {{#if:|
25815 <td>foo</td>
25816 }}
25817 </table>
25818 !! html/parsoid
25819 <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"}]]}'>
25820
25821 </table>
25822 !! end
25823
25824 !! test
25825 Always encapsulate foster box when template range is expanded to table
25826 !! options
25827 parsoid=wt2wt
25828 !! wikitext
25829 {|
25830 hello
25831 {{OpenTable}}
25832 |}
25833 !! html/parsoid
25834
25835 !! end
25836
25837 !! test
25838 T115289: Unclosed table
25839 !! wikitext
25840 {{echo|<table>}}<!--c-->[[Category:Two]]
25841 !! html/parsoid
25842 <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>
25843 !! end
25844
25845 !! test
25846 T115289: Don't migrate newlines out of tables with fostered content
25847 !! wikitext
25848 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
25849 !! html/parsoid
25850 <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>
25851 !! end
25852
25853 !! test
25854 T73074: More fostering fun
25855 !! wikitext
25856 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
25857 !! html/parsoid
25858 <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>
25859 !! end
25860
25861 !!test
25862 Support <object> element with .data attribute
25863 !!options
25864 parsoid=html2wt
25865 !! html/parsoid
25866 <object data="test.swf"></object>
25867 !! wikitext
25868 <object data="test.swf"></object>
25869 !!end
25870
25871 !! test
25872 Don't block XML namespace declaration
25873 !! wikitext
25874 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
25875 !! html/php
25876 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
25877 </p>
25878 !! html/parsoid
25879 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
25880 !! end
25881
25882 # -----------------------------------------------------------------
25883 # The following section of tests are primarily to spec requirements
25884 # around Parsoid's serialization (old, new, edited content)
25885 #
25886 # All these tests are marked Parsoid html2wt and html2html only
25887 # ----------------------------------------------------------------
25888
25889 !! test
25890 Ignore rel attribute in a-tags during serialization to url-links
25891 !! options
25892 parsoid=html2wt
25893 !! html/parsoid
25894 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
25895 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
25896 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
25897 !! wikitext
25898 http://en.wikipedia.org/wiki/Foobar
25899 http://en.wikipedia.org/wiki/Foobar
25900 http://en.wikipedia.org/wiki/Foobar
25901 !! end
25902
25903 # 'mi' is a localinterwiki prefix as well as a language
25904 !! test
25905 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
25906 !! options
25907 parsoid=html2wt
25908 !! html/parsoid
25909 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
25910 !! wikitext
25911 [[Foo]]
25912 !! end
25913
25914 # See T93839
25915 !! test
25916 New wikilinks should be serialized properly
25917 !! options
25918 parsoid=html2wt
25919 !! html/parsoid
25920 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
25921 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
25922 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
25923 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
25924 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
25925 !! wikitext
25926 [[Foo]]
25927 [[Foo]]
25928 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
25929 http://en.wikipedia.org/wiki/Foo
25930 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
25931 !! end
25932
25933 !! test
25934 New wiki links (href variations)
25935 !! options
25936 parsoid=html2wt
25937 !! html/parsoid
25938 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
25939 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
25940 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
25941 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
25942 !! wikitext
25943 [[Foo_bar]]
25944 [[Foo_bar]]
25945 [[Foo_bar]]
25946 [[Toxine bactérienne]]
25947 !! end
25948
25949 !! test
25950 New wiki links (content string variations)
25951 !! options
25952 parsoid=html2wt
25953 !! html/parsoid
25954 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
25955 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
25956 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
25957 !! wikitext
25958 [[Foo_bar]]
25959 [[Foo bar]]
25960 [[Foo_bar|./Foo_bar]]
25961 !! end
25962
25963 !! test
25964 New category links (href variations)
25965 !! options
25966 parsoid=html2wt
25967 !! html/parsoid
25968 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
25969 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
25970 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
25971 !! wikitext
25972 [[Category:Toxine bactérienne]]
25973 [[Category:Toxine bactérienne]]
25974 [[Category:Toxine bactérienne]]
25975 !! end
25976
25977 !! test
25978 New sol transparent links don't need indent-pre nowiki protection
25979 !! options
25980 parsoid=html2wt
25981 language=de
25982 !! html/parsoid
25983 <link rel="mw:PageProp/redirect" href="./Main_Page">
25984 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
25985 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
25986 !! wikitext
25987 #WEITERLEITUNG [[Main Page]]
25988 <!-- this is good --> [[Category:Good]]
25989 <!-- this is great --> [[Kategorie:Great]]
25990 !! end
25991
25992 !! test
25993 New interlanguage links (href variations)
25994 !! options
25995 parsoid=html2wt
25996 !! html/parsoid
25997 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
25998 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
25999 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
26000 !! wikitext
26001 [[es:Toxine bactérienne]]
26002 [[es:Toxine_bactérienne]]
26003 [[es:Toxine_bactérienne]]
26004 !! end
26005
26006 !! test
26007 Image: Modifying size of an image (1)
26008 !! options
26009 parsoid={
26010 "modes": ["wt2wt"],
26011 "changes": [
26012 ["img[height]", "attr", "height", "22"],
26013 ["img[width]", "attr", "width", "200"]
26014 ]
26015 }
26016 !! wikitext
26017 [[Image:Foobar.jpg|230x230px]]
26018 !! wikitext/edited
26019 [[Image:Foobar.jpg|200x200px]]
26020 !!end
26021
26022 !! test
26023 Image: Modifying size of an image (2)
26024 !! options
26025 parsoid={
26026 "modes": ["wt2wt"],
26027 "changes": [
26028 ["img[height]", "attr", "height", "100"],
26029 ["img[width]", "attr", "width", "500"]
26030 ]
26031 }
26032 !! wikitext
26033 [[Image:Foobar.jpg|230x230px]]
26034 !! wikitext/edited
26035 [[Image:Foobar.jpg|500x500px]]
26036 !!end
26037
26038 # Change in size is ignored so long as class='mw-default-size'
26039 !! test
26040 Image: Modifying size of an image (3)
26041 !! options
26042 parsoid={
26043 "modes": ["wt2wt"],
26044 "changes": [
26045 ["figure[class]", "removeClass", "mw-default-size"],
26046 ["figure img", "attr", "height", "19"],
26047 ["figure img", "attr", "width", "170"]
26048 ]
26049 }
26050 !! wikitext
26051 [[Image:Foobar.jpg|thumb]]
26052 !! wikitext/edited
26053 [[Image:Foobar.jpg|thumb|170x170px]]
26054 !!end
26055
26056 !! test
26057 Image: Modifying alignment of an image (T50665)
26058 !! options
26059 parsoid={
26060 "modes": ["wt2wt"],
26061 "changes": [
26062 ["figure[class]", "removeClass", "mw-halign-right"],
26063 ["figure[class]", "addClass", "mw-halign-left"]
26064 ]
26065 }
26066 !! wikitext
26067 [[Image:Foobar.jpg|thumb|caption|right]]
26068 !! wikitext/edited
26069 [[Image:Foobar.jpg|thumb|caption|left]]
26070 !! end
26071
26072 !! test
26073 Image: Modifying mw-default-size of an frameless image (T64805)
26074 !! options
26075 parsoid={
26076 "modes": ["wt2wt"],
26077 "changes": [
26078 ["figure.mw-default-size", "removeClass", "mw-default-size"]
26079 ]
26080 }
26081 !! wikitext
26082 [[Image:Foobar.jpg|frameless|right]]
26083 !! wikitext/edited
26084 [[Image:Foobar.jpg|frameless|right|220x220px]]
26085 !! end
26086
26087 !! test
26088 Image: Modifying valign of an image (T51221)
26089 !! options
26090 parsoid={
26091 "modes": ["wt2wt"],
26092 "changes": [
26093 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
26094 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
26095 ]
26096 }
26097 !! wikitext
26098 [[File:Foobar.jpg|20px|middle]]
26099 !! wikitext/edited
26100 [[File:Foobar.jpg|20px|text-top]]
26101 !! end
26102
26103 !! test
26104 Image: Modifying alt attribute of an image (T58400)
26105 !! options
26106 parsoid={
26107 "modes": ["wt2wt"],
26108 "changes": [
26109 ["img[alt]", "attr", "alt", "some alternate edited text"]
26110 ]
26111 }
26112 !! wikitext
26113 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
26114 !! wikitext/edited
26115 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
26116 !!end
26117
26118 !! test
26119 Image: Modifying caption of an image
26120 !! options
26121 parsoid={
26122 "modes": ["wt2wt"],
26123 "changes": [
26124 ["figcaption", "text", "new caption"]
26125 ]
26126 }
26127 !! wikitext
26128 [[Image:Foobar.jpg|thumb|original caption]]
26129 !! wikitext/edited
26130 [[Image:Foobar.jpg|thumb|new caption]]
26131 !!end
26132
26133 !! test
26134 Image: empty alt attribute (T50924)
26135 !! options
26136 parsoid
26137 !! wikitext
26138 [[File:Foobar.jpg|thumb|alt=|bar]]
26139 !! html
26140 <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>
26141 !! end
26142
26143 !! test
26144 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
26145 !! options
26146 parsoid=html2wt
26147 language=ar
26148 disabled
26149 !! html/parsoid
26150 <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>
26151 !! wikitext
26152 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
26153 !! end
26154
26155 !! test
26156 Image: Block level image should have \n before and after
26157 !! wikitext
26158 123
26159 [[File:Foobar.jpg|right|thumb|150x150px]]
26160 456
26161 !! html/parsoid
26162 <p>123</p>
26163 <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>
26164 <p>456</p>
26165 !!end
26166
26167 !! test
26168 Image: New block level image should have \n before and after (existing content)
26169 !! wikitext
26170 123
26171 [[File:Foobar.jpg|right|thumb|150x150px]]
26172 456
26173 !! html/parsoid
26174 <p>123</p>
26175 <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>
26176 <p>456</p>
26177 !!end
26178
26179 !! test
26180 Image: upright option (parsoid)
26181 !! wikitext
26182 [[File:Foobar.jpg|thumb|upright|caption]]
26183 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
26184 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
26185 !! html/parsoid
26186 <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>
26187 <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>
26188 <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>
26189 !!end
26190
26191 !! test
26192 Image: upright option is ignored on inline and frame images (parsoid)
26193 !! wikitext
26194 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
26195 !! html/parsoid
26196 <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>
26197 !!end
26198
26199 !! test
26200 Image: from basic HTML (1)
26201 !! options
26202 parsoid=html2wt
26203 !! html/parsoid
26204 <span typeof="mw:Image">
26205 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
26206 </span>
26207 !! wikitext
26208 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
26209 !! end
26210
26211 !! test
26212 Image: from basic HTML (2)
26213 !! options
26214 parsoid=html2wt
26215 !! html/parsoid
26216 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
26217 !! wikitext
26218 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
26219 !! end
26220
26221 !! test
26222 Image: from basic HTML (3)
26223 !! options
26224 parsoid=html2wt
26225 !! html/parsoid
26226 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
26227 !! wikitext
26228 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
26229 !! end
26230
26231 !! test
26232 Image: from basic HTML (4)
26233 !! options
26234 parsoid=html2wt
26235 !! html/parsoid
26236 <img src="./File:Foobar.jpg">
26237 !! wikitext
26238 [[File:Foobar.jpg|link=]]
26239 !! end
26240
26241 !! test
26242 Image: Invalid title as link
26243 !! wikitext
26244 [[File:Foobar.jpg|link=<]]
26245 !! html/php
26246 <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>
26247 </p>
26248 !! html/parsoid
26249 <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>
26250 !! end
26251
26252 !! test
26253 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
26254 !! options
26255 parsoid=html2wt
26256 !! html/parsoid
26257 <ul>
26258 <li><p>foo</p></li>
26259 </ul>
26260 !! wikitext
26261 * foo
26262 !! end
26263
26264 !! test
26265 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
26266 !! options
26267 parsoid=html2wt
26268 !! html/parsoid
26269 <ul> <li>foo</li></ul>
26270 !! wikitext
26271 * foo
26272 !! end
26273
26274 !! test
26275 Don't strip leading whitespace when handling indent-pre suppressing tags
26276 !! options
26277 parsoid=html2wt
26278 !! html/parsoid
26279 <table>
26280 <tr><td> indented row</td></tr>
26281 </table>
26282 <blockquote><p>
26283 <b>This is very bold of you!</b>
26284 </p>
26285 <table><tr><td>
26286 indented cell (no pre-wrapping!)
26287 </td></tr></table>
26288 </blockquote>
26289 <p>foo</p>
26290 <div>bar</div>
26291 !! wikitext
26292 {|
26293 | indented row
26294 |}
26295 <blockquote>
26296 '''This is very bold of you!'''
26297
26298 {|
26299 |
26300 indented cell (no pre-wrapping!)
26301 |}
26302 </blockquote>
26303 foo
26304 <div>bar</div>
26305 !! end
26306
26307 !! test
26308 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
26309 !! options
26310 parsoid=html2wt
26311 !! html/parsoid
26312 <p>foo</p>
26313 <span>bar</span>
26314
26315 <span>foo2
26316 </span>bar2
26317
26318 <div>foo</div>
26319 <span>bar</span>
26320
26321 <div>
26322 <span>foo</span>
26323 </div>
26324 !! wikitext
26325 foo
26326
26327 <span>bar</span>
26328
26329 <span>foo2
26330 <nowiki> </nowiki></span>bar2
26331
26332 <div>foo</div>
26333 <nowiki> </nowiki><span>bar</span>
26334
26335 <div>
26336 <nowiki> </nowiki><span>foo</span>
26337 </div>
26338 !! end
26339
26340 !! test
26341 Lists: Dont insert newlines in a serialized list item.
26342 !! options
26343 parsoid=html2wt
26344 !! html/parsoid
26345 <ul><li>a<br>b</li><li>c</li></ul>
26346 !! wikitext
26347 * a<br>b
26348 * c
26349 !! end
26350
26351 !! test
26352 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
26353 !! options
26354 parsoid={
26355 "modes": ["html2wt"],
26356 "scrubWikitext": false
26357 }
26358 !! html/parsoid
26359 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
26360 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
26361
26362 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
26363 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
26364
26365 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
26366
26367 <h2><meta property="mw:PageProp/toc" /> ok</h2>
26368 !! wikitext
26369 == hello there [[Category:A1]] ==
26370
26371 == [[Category:A2]] hi pal ==
26372
26373 == <!--foo--> [[Category:A3]] how goes it ==
26374
26375 == it goes well [[Category:A4]] <!--bar--> ==
26376
26377 ==howdy [[Category:A5]]==
26378
26379 == __TOC__ ok ==
26380 !! end
26381
26382 !! test
26383 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
26384 !! options
26385 parsoid={
26386 "modes": ["html2wt"],
26387 "scrubWikitext": true
26388 }
26389 !! html/parsoid
26390 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
26391 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
26392
26393 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
26394 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
26395
26396 <h2><meta property="mw:PageProp/toc" /> ok</h2>
26397 !! wikitext
26398 == hello there ==
26399 [[Category:A1]]
26400 [[Category:A2]]
26401
26402 == hi pal ==
26403
26404 <!--foo--> [[Category:A3]]
26405
26406 == how goes it ==
26407
26408 == it goes well ==
26409 [[Category:A4]] <!--bar-->
26410
26411 __TOC__
26412
26413 == ok ==
26414 !! end
26415
26416 !! test
26417 Headings: Don't hoist metas that come from templates
26418 !! options
26419 parsoid={
26420 "modes": ["html2wt"],
26421 "scrubWikitext": true
26422 }
26423 !! html/parsoid
26424 <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>
26425 !! wikitext
26426 == {{echo|foo [[Category:Foo]]}} ==
26427 !! end
26428
26429 !! test
26430 Headings: Category in ref isn't hoisted
26431 !! options
26432 parsoid={
26433 "modes": ["html2wt"],
26434 "scrubWikitext": true
26435 }
26436 !! html/parsoid
26437 <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>
26438
26439 <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>
26440 !! wikitext
26441 == foo <ref>bar
26442 [[Category:Baz]] </ref> ==
26443
26444 <references />
26445 !! end
26446
26447 !! test
26448 Parsoid: Serialize positional parameters with = in them as named parameter
26449 !! options
26450 parsoid=html2wt
26451 !! html/parsoid
26452 <p about="#mwt1" typeof="mw:Transclusion"
26453 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
26454
26455 <p about="#mwt1" typeof="mw:Transclusion"
26456 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
26457
26458 <!--Orig params with data-parsoid has heuristics for handling = chars-->
26459 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
26460 <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>
26461 !! wikitext
26462 {{echo|1=f=oo}}
26463
26464 {{echo|1=f=oo|2=bar}}
26465
26466 <!--Orig params with data-parsoid has heuristics for handling = chars-->
26467 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
26468 {{echo|<nowiki>f=oo</nowiki>|bar}}
26469 !! end
26470
26471 !! test
26472 Parsoid: Serialize positional parameters with = in extlink as named parameter
26473 !! options
26474 parsoid=html2wt
26475 !! html/parsoid
26476 <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>
26477 !! wikitext
26478 {{echo|1=http://stuff?is=ok}}
26479 !! end
26480
26481 !! test
26482 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
26483 !! options
26484 parsoid=html2wt
26485 !! html/parsoid
26486 <div>a<p>b</p></div>
26487 <div>a
26488 <p>b</p></div>
26489 <div>
26490 a
26491 <p>b</p></div>
26492 !! wikitext
26493 <div>a
26494 b
26495 </div>
26496 <div>a
26497 b
26498 </div>
26499 <div>
26500 a
26501
26502 b
26503 </div>
26504 !! end
26505
26506 !! test
26507 Substrings resembling wikitext in hrefs should not get nowiki escapes
26508 !! options
26509 parsoid=html2wt
26510 !! html/parsoid
26511 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
26512 !! wikitext
26513 [[Foo''bar''baz]]
26514 !! end
26515
26516 !! test
26517 Enforce single-line context in the serializer
26518 !! options
26519 parsoid=html2wt
26520 !! html/parsoid
26521 <h2>testing
26522 123</h2>
26523
26524 <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">
26525 </span><span about="#mwt1">you</span> </h2>
26526
26527 <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>
26528
26529 <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
26530 there</span></li></ol>
26531
26532 <ul><li>asd
26533 sdf</li></ul>
26534
26535 <ul><li>foo
26536 bar
26537 baz</li>
26538 <li>foo <b>bar</b>
26539 baz</li></ul>
26540
26541 <dl><dt>hi
26542 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
26543 ho</dd></dl>
26544
26545 <dl><dd> <table>
26546 <tbody><tr><td> ha
26547 ha
26548 ha</td></tr>
26549 </tbody></table></dd></dl>
26550 !! wikitext
26551 == testing 123 ==
26552
26553 == hi {{bogus|there
26554 you}} ==
26555
26556 == foo <ref>hello
26557 there</ref> ==
26558
26559 <references />
26560
26561 * asd sdf
26562
26563 * foo bar baz
26564 * foo '''bar''' baz
26565
26566 ; hi ho : hi ho
26567
26568 : {|
26569 | ha
26570 ha
26571 ha
26572 |}
26573 !! end
26574
26575 !! test
26576 Serialize new placeholder space without spans
26577 !! options
26578 parsoid=html2wt
26579 !! html/parsoid
26580 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
26581
26582 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
26583
26584 <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>
26585 !! wikitext
26586 foo : bar
26587
26588 foo : bar
26589
26590 <ref>foo : bar</ref>ok
26591 !! end
26592
26593
26594 #-----------------------
26595 # Tag minimization tests
26596 #-----------------------
26597
26598 !! test
26599 1. I/B quote minimization: wikitext-only tags should be combined
26600 !! options
26601 parsoid=html2wt
26602 !! html/parsoid
26603 <p><i>A</i><i>B</i></p>
26604 <p><b>A</b><b>B</b></p>
26605 <p><i>A</i><b><i>B</i></b></p>
26606 <p><b>A</b><i><b>B</b></i></p>
26607 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
26608 <p><i><b>A</b></i><i><b>B</b></i></p>
26609 <p><i><b>A</b></i><b><i>B</i></b></p>
26610 <p><b><i>A</i></b><i><b>B</b></i></p>
26611 !! wikitext
26612 ''AB''
26613
26614 '''AB'''
26615
26616 ''A'''B'''''
26617
26618 '''A''B'''''
26619
26620 '''A''BC''D'''
26621
26622 '''''AB'''''
26623
26624 '''''AB'''''
26625
26626 '''''AB'''''
26627 !! end
26628
26629 !! test
26630 2. I/B quote minimization: wikitext and html tags should not be combined
26631 !! options
26632 parsoid=html2wt
26633 !! html/parsoid
26634 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
26635 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
26636 !! wikitext
26637 ''A''<i>B</i>
26638
26639 ''A''<nowiki/>'''<i>B</i>'''
26640 !! end
26641
26642 !! test
26643 3. I/B quote minimization: templated content stops minimization
26644 !! options
26645 parsoid=html2wt
26646 !! html/parsoid
26647 <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>
26648 <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>
26649 !! wikitext
26650 ''A''{{echo|''B''}}
26651
26652 ''A''{{echo|'''''B'''''}}
26653 !! end
26654
26655 !! test
26656 4. I/B quote minimization: new content should be mimimized with adjacent old content
26657 !! options
26658 parsoid=html2wt
26659 !! html/parsoid
26660 <p><i>A</i><i>B</i></p>
26661 <p><b>A</b><b>B</b></p>
26662 <p><i>A</i><b><i>B</i></b></p>
26663 !! wikitext
26664 ''AB''
26665
26666 '''AB'''
26667
26668 ''A'''B'''''
26669 !! end
26670
26671 !! test
26672 5a. Merge adjacent quote nodes if they've been edited
26673 !! options
26674 parsoid={
26675 "modes": ["wt2wt", "selser"],
26676 "changes": [
26677 ["p", "contents", "remove", ":contains('b')"]
26678 ]
26679 }
26680 !! wikitext
26681 ''a''b''c''
26682 !! wikitext/edited
26683 ''ac''
26684 !! end
26685
26686 !! test
26687 5b. Merge adjacent quote nodes if they've been edited
26688 !! options
26689 parsoid={
26690 "modes": ["wt2wt", "selser"],
26691 "changes": [
26692 ["#x", "remove"]
26693 ]
26694 }
26695 !! wikitext
26696 ''a''<span id="x">b</span>''c''
26697 !! wikitext/edited
26698 ''ac''
26699 !! end
26700
26701 !! test
26702 1. Merge adjacent link nodes as long as at least one element is new
26703 !! options
26704 parsoid={
26705 "modes": ["html2wt"],
26706 "scrubWikitext": true
26707 }
26708 !! html/parsoid
26709 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
26710 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
26711 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
26712 !! wikitext
26713 [[Football]]
26714 [[Football]]
26715 [[Football|Foot]][[Football|ball]]
26716 !! end
26717
26718 !! test
26719 2. Merge adjacent link nodes and enable additional normalizations
26720 !! options
26721 parsoid={
26722 "modes": ["html2wt"],
26723 "scrubWikitext": true
26724 }
26725 !! html/parsoid
26726 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
26727 !! wikitext
26728 [[Football|''Football'']]
26729 !! end
26730
26731 !! test
26732 3. Don't merge adjacent link nodes if scrubWikitext is false
26733 !! options
26734 parsoid={
26735 "modes": ["html2wt"],
26736 "scrubWikitext": false
26737 }
26738 !! html/parsoid
26739 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
26740 !! wikitext
26741 [[Football|Foot]][[Football|ball]]
26742 !! end
26743
26744 #------------------------------
26745 # End of tag minimization tests
26746 #------------------------------
26747
26748 !!test
26749 T56262: New entities
26750 !! options
26751 parsoid=html2wt
26752 !! html/parsoid
26753 <span typeof="mw:Entity">&nbsp;</span>
26754 !! wikitext
26755 &nbsp;
26756 !! end
26757
26758 ## Note that there is no wikitext output for 'unknownproperty' ##
26759 ## Unknown magic words are silently dropped ##
26760
26761 !! test
26762 Magic words
26763 !! options
26764 parsoid=html2wt
26765 !! html/parsoid
26766 <meta property='mw:PageProp/toc' />
26767 <meta property='mw:PageProp/notoc' />
26768 <meta property='mw:PageProp/forcetoc' />
26769 <meta property='mw:PageProp/index' />
26770 <meta property='mw:PageProp/noindex' />
26771 <meta property='mw:PageProp/nogallery' />
26772 <meta property='mw:PageProp/noeditsection' />
26773 <meta property='mw:PageProp/notitleconvert' />
26774 <meta property='mw:PageProp/nocontentconvert' />
26775 <meta property='mw:PageProp/unknownproperty' />
26776 !! wikitext
26777 __TOC__
26778 __NOTOC__
26779 __FORCETOC__
26780 __INDEX__
26781 __NOINDEX__
26782 __NOGALLERY__
26783 __NOEDITSECTION__
26784 __NOTITLECONVERT__
26785 __NOCONTENTCONVERT__
26786 !! end
26787
26788 !! test
26789 Consecutive <pre>s should not get merged
26790 !! options
26791 parsoid=html2wt,html2html
26792 !! html/parsoid
26793 <pre>a</pre><pre>b</pre>
26794
26795 <pre>c
26796 </pre><pre>
26797 d</pre>
26798
26799 <pre>e
26800
26801 </pre><pre>
26802
26803 f</pre>
26804 !! wikitext
26805 a
26806
26807 b
26808
26809 c
26810
26811 d
26812
26813 e
26814
26815
26816
26817 f
26818 !! end
26819
26820 !! test
26821 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
26822 !! options
26823 parsoid=html2wt
26824 !! html/parsoid
26825 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
26826 !! wikitext
26827 [[Special:BookSources/1234567890|ISBN 1234567895]]
26828 !! end
26829
26830 !! test
26831 Edited RFC links not serializable as RFC links should serialize as extlinks
26832 !! options
26833 parsoid=html2wt
26834 !! html/parsoid
26835 <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
26836 !! wikitext
26837 [//tools.ietf.org/html/rfc123 New RFC]
26838 !! end
26839
26840 !! test
26841 Edited PMID links not serializable as PMID links should serialize as extlinks
26842 !! options
26843 parsoid=html2wt
26844 !! html/parsoid
26845 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
26846 !! wikitext
26847 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
26848 !! end
26849
26850 !! test
26851 WTS of autolinks with trailing/surrounding context
26852 !! options
26853 parsoid=html2wt
26854 !! html/parsoid
26855 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
26856 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
26857 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
26858 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
26859 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
26860 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
26861 !! wikitext
26862 http://cscott.net'''foo'''
26863
26864 http://cscott.net<b>foo</b>
26865
26866 '''http://cscott.net'''
26867
26868 '''http://cscott.net '''
26869
26870 '''http://cscott.net<nowiki/>x'''
26871
26872 http://cscott.net<nowiki/>x
26873 !! end
26874
26875 !! test
26876 WTS of autolinks with nowikis (round-trip)
26877 !! wikitext
26878 x<nowiki/>http://cscott.net<nowiki/>x
26879 !! html/parsoid
26880 <p>x<a rel="mw:ExtLink" href="http://cscott.net">http://cscott.net</a>x</p>
26881 !! end
26882
26883 # this is the "easy" test because it leaves in place all the
26884 # data-parsoid information indicating this is an autolink
26885 !! test
26886 WTS of autolinks with escapes (editing)
26887 !! options
26888 parsoid={
26889 "modes": ["wt2wt"],
26890 "changes": [
26891 [ "span", "remove" ]
26892 ]
26893 }
26894 !! wikitext
26895 x<nowiki/>http://cscott.net<nowiki/>x
26896 !! wikitext/edited
26897 x<nowiki/>http://cscott.net<nowiki/>x
26898 !! end
26899
26900 !! test
26901 WTS of edited autolink-like text (T103364)
26902 !! options
26903 parsoid={
26904 "modes": ["wt2wt"],
26905 "changes": [
26906 [ "span[typeof]", "removeAttr", "typeof" ]
26907 ]
26908 }
26909 !! wikitext
26910 Not a link: <nowiki>http://example.com</nowiki>.
26911 !! wikitext/edited
26912 Not a link: <span><nowiki>http://example.com</nowiki></span>.
26913 !! end
26914
26915 !! test
26916 WTS of newly-authored autolink-like text (T103364)
26917 !! options
26918 parsoid=html2wt
26919 !! html/parsoid
26920 <p>http://example.com is not a link.</p>
26921 !! wikitext
26922 <nowiki>http://example.com</nowiki> is not a link.
26923 !! end
26924
26925 !! test
26926 WTS of autolink-like text after an autolink (T108563)
26927 !! options
26928 parsoid=html2wt
26929 !! html/parsoid
26930 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
26931 !! wikitext
26932 http://example.com <nowiki>http://example.com</nowiki> is not a link.
26933 !! end
26934
26935 !! test
26936 Magic links inside links (not autolinked)
26937 !! wikitext
26938 [[Foo|http://example.com]]
26939 [[Foo|RFC 1234]]
26940 [[Foo|PMID 1234]]
26941 [[Foo|ISBN 123456789x]]
26942
26943 [http://foo.com http://example.com]
26944 [http://foo.com RFC 1234]
26945 [http://foo.com PMID 1234]
26946 [http://foo.com ISBN 123456789x]
26947 !! html+tidy
26948 <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>
26949 <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>
26950 !! html/parsoid
26951 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
26952 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
26953 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
26954 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
26955
26956 <p><a rel="mw:ExtLink" href="http://foo.com">http://example.com</a>
26957 <a rel="mw:ExtLink" href="http://foo.com">RFC 1234</a>
26958 <a rel="mw:ExtLink" href="http://foo.com">PMID 1234</a>
26959 <a rel="mw:ExtLink" href="http://foo.com">ISBN 123456789x</a></p>
26960 !! end
26961
26962 !! test
26963 Magic links inside image captions (autolinked)
26964 !! wikitext
26965 [[File:Foobar.jpg|thumb|http://example.com]]
26966 [[File:Foobar.jpg|thumb|RFC 1234]]
26967 [[File:Foobar.jpg|thumb|PMID 1234]]
26968 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
26969 !! html+tidy
26970 <div class="thumb tright">
26971 <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>
26972 <div class="thumbcaption">
26973 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
26974 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div>
26975 </div>
26976 </div>
26977 <div class="thumb tright">
26978 <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>
26979 <div class="thumbcaption">
26980 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
26981 <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a></div>
26982 </div>
26983 </div>
26984 <div class="thumb tright">
26985 <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>
26986 <div class="thumbcaption">
26987 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
26988 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a></div>
26989 </div>
26990 </div>
26991 <div class="thumb tright">
26992 <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>
26993 <div class="thumbcaption">
26994 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
26995 <a href="/wiki/Special:BookSources/123456789X" class="internal mw-magiclink-isbn">ISBN 123456789x</a></div>
26996 </div>
26997 </div>
26998 !! html/parsoid
26999 <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>
27000 <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="//tools.ietf.org/html/rfc1234" rel="mw:ExtLink">RFC 1234</a></figcaption></figure>
27001 <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>
27002 <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>
27003 !! end
27004
27005 !! test
27006 WTS of magic word text (T109371)
27007 !! options
27008 parsoid=html2wt
27009 !! html/parsoid
27010 <p>RFC 1234</p>
27011 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
27012 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
27013 !! wikitext
27014 <nowiki>RFC 1234</nowiki>
27015
27016 [http://foo.com RFC 1234]
27017
27018 [[Foo|RFC 1234]]
27019 !! end
27020
27021 !! test
27022 Edited Redirect link should emit a non-piped wikitext link
27023 !! options
27024 parsoid=html2wt
27025 !! html/parsoid
27026 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
27027 !! wikitext
27028 #REDIRECT [[Bar]]
27029 !! end
27030
27031 !! test
27032 T75121: Infer extension name from typeOf if data-mw is not present
27033 !! options
27034 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
27035 !! html/parsoid
27036 <div typeOf="mw:Extension/foo"></div>
27037 !! wikitext
27038 <foo />
27039 !! end
27040
27041 # Note that the <p> wrapping isn't present in PHP parser output
27042 # The important thing for this test is that P-wrapping doesn't
27043 # interfere with the <nowiki> protection for leading - in <td>
27044 # (which isn't necessary for <th>).
27045 !! test
27046 T88318: p-wrapped dash in table.
27047 !! options
27048 parsoid=html2wt,wt2wt
27049 !! html/parsoid
27050 <table><tbody>
27051 <tr><th><p>-</p></th><th><p>- </p></th></tr>
27052 <tr><td><p>-</p></td><td><p>- </p></td></tr>
27053 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
27054 </tbody></table>
27055 !! wikitext
27056 {|
27057 !-
27058 !-
27059 |-
27060 |<nowiki>-</nowiki>
27061 |<nowiki>- </nowiki>
27062 |-
27063 |<small>-</small>
27064 |<br>
27065 -
27066 |<br>
27067 -
27068 |}
27069 !! html/php+tidy
27070 <table>
27071 <tr>
27072 <th>-</th>
27073 <th>-</th>
27074 </tr>
27075 <tr>
27076 <td>-</td>
27077 <td>-</td>
27078 </tr>
27079 <tr>
27080 <td><small>-</small></td>
27081 <td><br />
27082 <p>-</p>
27083 </td>
27084 <td><br />
27085 <p>-</p>
27086 </td>
27087 </tr>
27088 </table>
27089 !! end
27090
27091 !! test
27092 T149209: WTS: Handle newlines in table cells properly
27093 !! options
27094 parsoid=html2wt
27095 !! html/parsoid
27096 <table>
27097 <tbody>
27098 <tr><td>a
27099 b
27100 </td><td data-parsoid='{"stx_v":"row"}'>c</td></tr>
27101 <tr><td><p>x</p>
27102 </td><td data-parsoid='{"stx_v":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
27103 </tbody></table>
27104 <table>
27105 <tbody>
27106 <tr><th>a
27107 b
27108 </th><th data-parsoid='{"stx_v":"row"}'>c</th></tr>
27109 <tr><th><p>x</h>
27110 </th><th data-parsoid='{"stx_v":"row"}'>y</th></tr>
27111 </tbody></table>
27112 !! wikitext
27113 {|
27114 |a
27115 b
27116 |c
27117 |-
27118 |x
27119 {{!}}y
27120 |}
27121 {|
27122 !a
27123 b
27124 !c
27125 |-
27126 !x
27127 !y
27128 |}
27129 !! end
27130
27131 !! test
27132 T149209: Selser: Handle newlines in table cells properly
27133 !! options
27134 parsoid={
27135 "modes": ["selser"],
27136 "changes": [
27137 [ "#h1", "html", "a\nb\n" ],
27138 [ "#h2", "html", "a\nb\n" ],
27139 [ "#c1", "html", "a\nb\n" ],
27140 [ "#c2", "html", "<p>a</p>" ],
27141 [ "#c3", "html", "<p>a</p>" ],
27142 [ "#c4", "html", "edit-me<p>a</p>" ]
27143 ]
27144 }
27145 !! wikitext
27146 {|
27147 ! id="h1" |edit-me!!1
27148 |-
27149 ! id="h2" |edit-me||2
27150 |-
27151 | id="c1" |edit-me||3
27152 |-
27153 | id="c2" |edit-me||4
27154 |-
27155 | id="c3" |edit-me||p||q||r
27156 |-
27157 | id="c4" |edit-me||p||q||r
27158 |}
27159 !! wikitext/edited
27160 {|
27161 ! id="h1" |a
27162 b
27163 !1
27164 |-
27165 ! id="h2" |a
27166 b
27167 !2
27168 |-
27169 | id="c1" |a
27170 b
27171 |3
27172 |-
27173 | id="c2" |a
27174 |4
27175 |-
27176 | id="c3" |a
27177 |p||q||r
27178 |-
27179 | id="c4" |edit-me
27180 a
27181 |p||q||r
27182 |}
27183 !! end
27184
27185 !! test
27186 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
27187 !! options
27188 parsoid=html2wt
27189 !! html/parsoid
27190 <table id='mwAb'>
27191 <td id='mwAc'>foo</td>
27192 <td id='serialize-this'>bar</td>
27193 </table>
27194 !! wikitext
27195 {|
27196 |foo
27197 | id="serialize-this" |bar
27198 |}
27199 !! end
27200
27201 !! test
27202 Parsoid-like element ids should not be serialized to wikitext unless shadowed
27203 !! options
27204 parsoid=html2wt
27205 !! html/parsoid
27206 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
27207 !! wikitext
27208 <div id="hello">ok</div>
27209 !! end
27210
27211 !! test
27212 WTS change modes
27213 !! options
27214 parsoid={
27215 "modes": ["wt2wt"],
27216 "changes": [
27217 [ "#xyz", "before", "<b>before</b> stuff " ],
27218 [ "#xyz", "after", " stuff <i>after</i>" ],
27219 [ "#xyz", "html", "x <b>y</b> z" ]
27220 ]
27221 }
27222 !! wikitext
27223 <span id="xyz">hello</span>
27224 !! wikitext/edited
27225 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
27226 !! end
27227
27228 !! test
27229 Never serialize a-tag as html, regardless of what data-parsoid has to say
27230 !! options
27231 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
27232 !! html/parsoid
27233 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
27234 !! wikitext
27235 [[Foo]]
27236 !! end
27237
27238 ## SSS FIXME: This is broken output nevertheless.
27239 ## What might be a reasonable non-broken output for this?
27240 ## This is an edge case unlikely to be seen in production
27241 ## that I am not wasting more time on this right now.
27242 !! test
27243 Never serialize a-tag as html, no matter what attributes it has
27244 !! options
27245 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
27246 !! html/parsoid
27247 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
27248 !! wikitext
27249 [http://boo.org http://boohoo.org]
27250 !! end
27251
27252 # Misnested is an indication that selser can reuse the source but these have
27253 # shown to sneak through on occasion. See T101768.
27254 # The original wikitext here is: [http://test.com [[one]] two three]
27255 !! test
27256 Strip span tags added to mark misnested links
27257 !! options
27258 parsoid=html2wt
27259 !! html/parsoid
27260 <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>
27261 !! wikitext
27262 [http://test.com][[one]] two three
27263 !! end
27264
27265 !! test
27266 Catch regression when unpacking misnested links
27267 !! options
27268 parsoid=wt2html
27269 !! wikitext
27270 {{echo|hi}}[http://example.com [[ho]]]
27271 !! html/parsoid
27272 <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>
27273 !! end
27274
27275 !! test
27276 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
27277 !! options
27278 parsoid=html2wt
27279 !! html/parsoid
27280 <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|}"]}'>
27281 <tbody><tr><td>d
27282 </td></tr>
27283 </tbody></table>
27284 !! wikitext
27285 {{echo|a}}
27286 {|{{echo|c
27287 {{!}}d
27288 }}
27289 |}
27290 !! end
27291
27292 ## This test verifies the presence and computation of this attribute indirectly
27293 ## by making an edit and ensuring that the serialization is correct (which it would be
27294 ## only if firstWikitextNode is properly set).
27295 !! test
27296 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
27297 !! options
27298 parsoid= {
27299 "modes": ["wt2wt"],
27300 "changes": [
27301 [ "div#x", "remove" ],
27302 [ "div", "before", "<div>new</div>" ]
27303 ]
27304 }
27305 !! wikitext
27306 <div id="x">foo</div>
27307 {|
27308 {{echo|<div>boo</div>
27309 {{!}}b}}
27310 |c
27311 |}
27312 !! wikitext/edited
27313
27314 <div>new</div>
27315 {|
27316 {{echo|<div>boo</div>
27317 {{!}}b}}
27318 |c
27319 |}
27320 !! end
27321
27322 # --------------------------------------------
27323 # Tests spec'ing wikitext serialization norms |
27324 # --------------------------------------------
27325
27326 !! test
27327 Serialize multi-line indent-pre starting with wikitext syntax
27328 !! options
27329 parsoid=html2wt
27330 !! html/parsoid
27331 <pre>* 1
27332 ** 2
27333 * 3</pre>
27334 !! wikitext
27335 * 1
27336 ** 2
27337 * 3
27338 !! end
27339
27340 !! test
27341 1. Categories should always be serialized on their own line
27342 !! options
27343 parsoid=html2wt
27344 !! html/parsoid
27345 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
27346 !! wikitext
27347 foo
27348 [[Category:Foo]]
27349 bar
27350 !! end
27351
27352 !! test
27353 2. Categories that are part of templates should not introduce a line break
27354 !! wikitext
27355 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
27356 !! html/parsoid
27357 <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>
27358 !! end
27359
27360 # Careful while editing these next 2 tests. There are \u200f characters
27361 # before and after the <link> tags in the HTML and following some
27362 # of the categories in wikitext
27363 # Do not remove these characters in edits.
27364 #
27365 # As part of the serialization, these bidi characters will get stripped.
27366 !! test
27367 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
27368 !! options
27369 parsoid={
27370 "modes": ["html2wt"],
27371 "scrubWikitext": true
27372 }
27373 !! html/parsoid
27374 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
27375 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
27376 !! wikitext
27377 [[קטגוריה:טקסים]]
27378 [[קטגוריה: שיטות משפט]]
27379 !! end
27380
27381 !! test
27382 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
27383 !! options
27384 parsoid={
27385 "modes": ["html2wt"],
27386 "scrubWikitext": true
27387 }
27388 !! html/parsoid
27389 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
27390 !! wikitext
27391 [[קטגוריה:טקסים]]
27392 ‏y
27393 !! end
27394
27395 !! test
27396 Lists: Add space after bullets
27397 !! options
27398 parsoid=html2wt
27399 !! html/parsoid
27400 <ul>
27401 <li>foo</li>
27402 <li> bar</li>
27403 <li><span> baz</span></li>
27404 </ul>
27405 !! wikitext
27406 * foo
27407 * bar
27408 * <span> baz</span>
27409 !! end
27410
27411 !! test
27412 1. Headings: Add space before/after == (T53744)
27413 !! options
27414 parsoid=html2wt
27415 !! html/parsoid
27416 <h2>foo</h2>
27417 <h2> bar</h2>
27418 <h2>baz </h2>
27419 <h2><span> baz</span></h2>
27420 !! wikitext
27421 == foo ==
27422
27423 == bar ==
27424
27425 == baz ==
27426
27427 == <span> baz</span> ==
27428 !! end
27429
27430 !! test
27431 2. Headings: Add space before/after == even after hoisted content
27432 !! options
27433 parsoid={
27434 "modes": ["html2wt"],
27435 "scrubWikitext": true
27436 }
27437 !! html/parsoid
27438 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
27439 !! wikitext
27440 [[Category:A2]]
27441
27442 == ok ==
27443 !! end
27444
27445 !! test
27446 1. Headings: suppress newly created empty headings
27447 !! options
27448 parsoid={
27449 "modes": ["html2wt"],
27450 "scrubWikitext": true
27451 }
27452 !! html/parsoid
27453 <h2></h2>
27454 !! wikitext
27455 !! end
27456
27457 !! test
27458 2. Headings: don't suppress empty headings if scrubWikitext is false
27459 !! options
27460 parsoid=html2wt
27461 !! html/parsoid
27462 <h2></h2>
27463 !! wikitext
27464 ==<nowiki/>==
27465 !! end
27466
27467 !! test
27468 3. Headings: suppress empty headings on edits
27469 !! options
27470 parsoid={
27471 "modes": ["selser"],
27472 "scrubWikitext": true,
27473 "changes": [
27474 [ "#x", "remove"]
27475 ]
27476 }
27477 !! wikitext
27478 ==<span id="x">foo</span>==
27479 !! wikitext/edited
27480 !! end
27481
27482 !! test
27483 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
27484 !! options
27485 parsoid={
27486 "modes": ["html2wt"],
27487 "scrubWikitext": true
27488 }
27489 !! html/parsoid
27490 <h2>foo<br/>bar</h2>
27491 <h2>foo <span><br/>bar</span> baz</h2>
27492 !! wikitext
27493 == foo bar ==
27494
27495 == foo <span> bar</span> baz ==
27496 !! end
27497
27498 !! test
27499 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
27500 !! options
27501 parsoid={
27502 "modes": ["html2wt"],
27503 "scrubWikitext": false
27504 }
27505 !! html/parsoid
27506 <h2>foo<br/>bar</h2>
27507 !! wikitext
27508 == foo<br> bar ==
27509 !! end
27510
27511 !! test
27512 1. WT Quote Tags: suppress newly created empty style tags
27513 !! options
27514 parsoid={
27515 "modes": ["html2wt"],
27516 "scrubWikitext": true
27517 }
27518 !! html/parsoid
27519 <i></i><b></b>
27520 !! wikitext
27521 !! end
27522
27523 !! test
27524 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
27525 !! options
27526 parsoid=html2wt
27527 !! html/parsoid
27528 <i></i><b></b>
27529 !! wikitext
27530 ''<nowiki/>'''''<nowiki/>'''
27531 !! end
27532
27533 !! test
27534 3. WT Quote Tags: suppress empty style tags on edits
27535 !! options
27536 parsoid={
27537 "modes": ["selser"],
27538 "scrubWikitext": true,
27539 "changes": [
27540 [ "#x", "remove"]
27541 ]
27542 }
27543 !! wikitext
27544 '''<span id="x">foo</span>'''
27545 !! wikitext/edited
27546 !! end
27547
27548 !! test
27549 1. Anchors: suppress newly created empty anchors
27550 !! options
27551 parsoid={
27552 "modes": ["html2wt"],
27553 "scrubWikitext": true
27554 }
27555 !! html/parsoid
27556 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
27557 !! wikitext
27558 !! end
27559
27560 !! test
27561 2. Anchors: don't suppress empty anchors if scrubWikitext is false
27562 !! options
27563 parsoid={
27564 "modes": ["html2wt"],
27565 "scrubWikitext": false
27566 }
27567 !! html/parsoid
27568 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
27569 !! wikitext
27570 [[Test|<nowiki/>]]
27571 !! end
27572
27573 !! test
27574 3. Anchors: suppress empty anchors on edits
27575 !! options
27576 parsoid={
27577 "modes": ["selser"],
27578 "scrubWikitext": true,
27579 "changes": [
27580 [ "#x", "remove"]
27581 ]
27582 }
27583 !! wikitext
27584 [[Test|<span id="x">foo</span>]]
27585 !! wikitext/edited
27586 !! end
27587
27588 !! test
27589 3a. Anchors: do not suppress numbered extlinks
27590 !! options
27591 parsoid={
27592 "modes": ["wt2wt"],
27593 "scrubWikitext": true
27594 }
27595 !! wikitext
27596 [http://foo.com]
27597 !! html/parsoid
27598 <a rel="mw:ExtLink" href="http://foo.com"></a>
27599 !! end
27600
27601 !! test
27602 3b. Anchors: do not suppress numbered extlinks
27603 !! options
27604 parsoid={
27605 "modes": ["wt2wt"],
27606 "scrubWikitext": true,
27607 "changes": [
27608 [ "#x", "remove"]
27609 ]
27610 }
27611 !! wikitext
27612 [http://foo.com <span id="x">foo</span>]
27613 !! wikitext/edited
27614 [http://foo.com]
27615 !! end
27616
27617 !!test
27618 Normalizations should be restricted to edited content
27619 !!options
27620 parsoid={
27621 "modes": ["selser"],
27622 "scrubWikitext": true,
27623 "changes": [
27624 [ "h1", "before", "<i></i>"]
27625 ]
27626 }
27627 !!wikitext
27628 a
27629 = =
27630 b
27631 !!wikitext/edited
27632 a
27633 = =
27634 b
27635 !!end
27636
27637 !! test
27638 1. Multiple normalizations (html2wt)
27639 !! options
27640 parsoid={
27641 "modes": ["html2wt"],
27642 "scrubWikitext": true
27643 }
27644 !! html
27645 <h2><i></i></h2>
27646 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
27647 </a><b><i></i></b>x</p>
27648 !! wikitext
27649
27650 [[foo]]
27651 x
27652
27653 !! end
27654
27655 !! test
27656 2. Multiple normalizations (selser)
27657 !! options
27658 parsoid={
27659 "modes": ["selser"],
27660 "scrubWikitext": true,
27661 "changes": [
27662 [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
27663 ]
27664 }
27665 !! wikitext
27666 <span id="x">foo</span>
27667 !! wikitext/edited
27668 <span id="x">foo</span>
27669
27670 x
27671 !! end
27672
27673 !! test
27674 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
27675 !! options
27676 parsoid={
27677 "modes": ["html2wt"],
27678 "scrubWikitext": true
27679 }
27680 !! html/parsoid
27681 <p> hi</p>
27682 <p> hello</p>
27683 !! wikitext
27684 hi
27685
27686 hello
27687 !! end
27688
27689 !! test
27690 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
27691 !! options
27692 parsoid=html2wt
27693 !! html/parsoid
27694 <p> hi</p>
27695 <p> hello</p>
27696 !! wikitext
27697 <nowiki> </nowiki>hi
27698
27699 <nowiki> </nowiki> hello
27700 !! end
27701
27702 !! test
27703 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
27704 !! options
27705 parsoid={
27706 "modes": ["html2wt"],
27707 "scrubWikitext": true
27708 }
27709 !! html/parsoid
27710 <p>Foo
27711 bar
27712 baz</p>
27713
27714 <table><tr><td>Foo
27715 bar
27716 baz bang</td></tr></table>
27717
27718 <p><!--boo--> foo
27719 bar</p>
27720
27721 <p> foo
27722 bar<span>boo</span></p>
27723 !! wikitext
27724 Foo
27725 bar
27726 baz
27727
27728 {|
27729 |Foo
27730 bar
27731 baz bang
27732 |}
27733
27734 <!--boo-->foo
27735 bar
27736
27737 foo
27738 bar<span>boo</span>
27739 !! end
27740
27741 !! test
27742 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
27743 !! options
27744 parsoid={
27745 "modes": ["selser"],
27746 "scrubWikitext": true,
27747 "changes": [
27748 [ "p", "html", " a\n b" ]
27749 ]
27750 }
27751 !! wikitext
27752 xyz
27753 !! wikitext/edited
27754 a
27755 b
27756 !! end
27757
27758 !! test
27759 1. New links that end in spaces
27760 !! options
27761 parsoid={
27762 "modes": ["html2wt"],
27763 "scrubWikitext": false
27764 }
27765 !! html/parsoid
27766 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
27767 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
27768 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
27769 !! wikitext
27770 [[Berlin ]]<nowiki/>is the capital of Germany.
27771
27772 [[Foo ]]'''bar'''
27773
27774 [[Boston ]] is a city.
27775 !! end
27776
27777 !! test
27778 2. New links that end in spaces
27779 !! options
27780 parsoid={
27781 "modes": ["html2wt"],
27782 "scrubWikitext": true
27783 }
27784 !! html/parsoid
27785 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
27786 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
27787 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
27788 !! wikitext
27789 [[Berlin]] is the capital of Germany.
27790
27791 [[Foo]] '''bar'''
27792
27793 [[Boston]] is a city.
27794 !! end
27795
27796 !! test
27797 1. Table cells with escapable prefixes
27798 !! options
27799 parsoid={
27800 "modes": ["html2wt"],
27801 "scrubWikitext": false
27802 }
27803 !! html
27804 <table>
27805 <tr><td>a</td></tr>
27806 <tr><td>-</td></tr>
27807 <tr><td>+</td></tr>
27808 </table>
27809 !! wikitext
27810 {|
27811 |a
27812 |-
27813 |<nowiki>-</nowiki>
27814 |-
27815 |<nowiki>+</nowiki>
27816 |}
27817 !! end
27818
27819 !! test
27820 2. Table cells with escapable prefixes
27821 !! options
27822 parsoid={
27823 "modes": ["html2wt"],
27824 "scrubWikitext": true
27825 }
27826 !! html
27827 <table>
27828 <tr><td>a</td></tr>
27829 <tr><td>-</td></tr>
27830 <tr><td>+</td></tr>
27831 </table>
27832 !! wikitext
27833 {|
27834 |a
27835 |-
27836 | -
27837 |-
27838 | +
27839 |}
27840 !! end
27841
27842 !! test
27843 3a. Table cells with escapable prefixes after edits
27844 !! options
27845 parsoid={
27846 "modes": ["selser"],
27847 "scrubWikitext": true,
27848 "changes": [
27849 [ "table tbody tr:first-child td:first-child", "remove"]
27850 ]
27851 }
27852 !! wikitext
27853 {|
27854 |a||-
27855 |}
27856 !! wikitext/edited
27857 {|
27858 | -
27859 |}
27860 !! end
27861
27862 !! test
27863 3b. Table cells with escapable prefixes after edits
27864 !! options
27865 parsoid={
27866 "modes": ["selser"],
27867 "scrubWikitext": true,
27868 "changes": [
27869 [ "table tbody tr:first-child td:first-child", "html", "-" ],
27870 [ "#x", "remove" ]
27871 ]
27872 }
27873 !! wikitext
27874 {|
27875 |pqr
27876 |<span id="x">foo</span>+
27877 |}
27878 !! wikitext/edited
27879 {|
27880 | -
27881 | +
27882 |}
27883 !! end
27884
27885 # FIXME: This test will fail because
27886 # normalization doesn't realize that the id attribute
27887 # will eliminate the escapable scenario
27888 !! test
27889 4a. Table cells without escapable prefixes after edits
27890 !! options
27891 parsoid={
27892 "modes": ["selser"],
27893 "scrubWikitext": true,
27894 "changes": [
27895 [ "#x", "html", "-" ]
27896 ]
27897 }
27898 !! wikitext
27899 {|
27900 | id="x" |abcd
27901 |}
27902 !! wikitext/edited
27903 {|
27904 | id="x" |-
27905 |}
27906 !! end
27907
27908 ## This tests normalizer's ability to discriminate between
27909 ## cells having identical content.
27910 !! test
27911 4b. Table cells without escapable prefixes after edits
27912 !! options
27913 parsoid={
27914 "modes": ["selser"],
27915 "scrubWikitext": true,
27916 "changes": [
27917 [ "td", "html", "-" ]
27918 ]
27919 }
27920 !! wikitext
27921 {|
27922 |a||b
27923 |}
27924 !! wikitext/edited
27925 {|
27926 | -||-
27927 |}
27928 !! end
27929
27930 ## This tests normalizer's ability to not be tripped by
27931 ## comments (and whitespace)
27932 !! test
27933 4c. Table cells without escapable prefixes after edits
27934 !! options
27935 parsoid={
27936 "modes": ["selser"],
27937 "scrubWikitext": true,
27938 "changes": [
27939 [ "table tbody tr td:first-child", "remove" ]
27940 ]
27941 }
27942 !! wikitext
27943 {|
27944 |-
27945 <!--foo--> |a||-
27946 |}
27947 !! wikitext/edited
27948 {|
27949 |-
27950 <!--foo--> | -
27951 |}
27952 !! end
27953
27954 ## This tests normalizer's ability to handle HTML cells
27955 !! test
27956 4d. Table cells without escapable prefixes after edits
27957 !! options
27958 parsoid={
27959 "modes": ["selser"],
27960 "scrubWikitext": true,
27961 "changes": [
27962 [ "td", "html", "-" ]
27963 ]
27964 }
27965 !! wikitext
27966 <table>
27967 <tr><td>a</td></tr>
27968 </table>
27969 !! wikitext/edited
27970 <table>
27971 <tr><td>-</td></tr>
27972 </table>
27973 !! end
27974
27975 ## T111151 Remove font elements without attributes
27976 !! test
27977 5a. font tags without attributes should be dropped in scrubWikitext mode
27978 !! options
27979 parsoid={
27980 "modes": ["html2wt"],
27981 "scrubWikitext": true
27982 }
27983 !! html
27984 <font>foo</font>
27985 <font><font>bar</font></font>
27986 <font class="x">boo</font>
27987 !! wikitext
27988 foo
27989 bar
27990 <font class="x">boo</font>
27991 !! end
27992
27993 !! test
27994 5b. font tags should not be dropped without scrubWikitext being enabled
27995 !! options
27996 parsoid={
27997 "modes": ["html2wt"],
27998 "scrubWikitext": false
27999 }
28000 !! html
28001 <font>foo</font>
28002 !! wikitext
28003 <font>foo</font>
28004 !! end
28005
28006 !! test
28007 Escape nowiki DOM elements
28008 !! options
28009 parsoid=html2wt
28010 !! html/parsoid
28011 <nowiki><i>foo</i></nowiki>
28012 !! wikitext
28013 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
28014 !! end
28015
28016 # This is meant to be an interim fix while we go about figuring out
28017 # how to not introduce these trailing <nowiki/>s in the first place.
28018 !! test
28019 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
28020 !! options
28021 parsoid=html2wt
28022 !! html/parsoid
28023 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
28024 y</p>
28025 <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>
28026 <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>
28027 !! wikitext
28028 x
28029 y
28030
28031 {{echo|
28032 1 = <nowiki/>}}
28033
28034 {{echo|
28035 1 = <nowiki/>
28036 }}
28037 !! end
28038
28039 # ---------------------------------------------------
28040 # End of tests spec'ing wikitext serialization norms |
28041 # ---------------------------------------------------
28042
28043 # T104032
28044 !! test
28045 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
28046 !! options
28047 parsoid=html2wt
28048 !! html/parsoid
28049 a<p>b</p>
28050 <b>c</b><p>d</p>
28051 <table><tr>
28052 <td>a<p>b</p></td>
28053 <td><b>c</b><p>d</p></td>
28054 </tr></table>
28055 !! wikitext
28056 a
28057
28058 b
28059
28060 '''c'''
28061
28062 d
28063 {|
28064 |a
28065 b
28066 |'''c'''
28067 d
28068 |}
28069 !! end
28070
28071 !! test
28072 Anchor without href scenarios
28073 !! options
28074 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28075 !! html/parsoid
28076 <a class="bc"></a>
28077 <a class="no">dice</a>
28078 <a name="foo"></a>
28079 !! wikitext
28080
28081 dice
28082 <span name="foo"></span>
28083 !! end
28084
28085 # -----------------------------------------------------------------
28086 # End of section for Parsoid-only html2wt tests for serialization
28087 # of new content
28088 # -----------------------------------------------------------------
28089
28090 # -----------------------------------------------------------------
28091 # The following section of tests are primarily to spec behavior of
28092 # the selective serializer. All these tests have manual selser
28093 # changes. The automated selser changes for all tests handle the
28094 # wide variation of changes, but these tests here capture specs
28095 # deterministically.
28096 # ----------------------------------------------------------------
28097
28098 ## T90517
28099 !! test
28100 Selser: New comments should not be lost
28101 !! options
28102 parsoid={
28103 "modes": ["selser"],
28104 "changes": [
28105 [ "#a", "after", "<!--c1-->" ],
28106 [ "#b", "before", "<!--c2-->" ]
28107 ]
28108 }
28109 !! wikitext
28110 <span id="a">a</span>
28111
28112 <span id="b">b</span>
28113 !! wikitext/edited
28114 <span id="a">a</span><!--c1-->
28115
28116 <!--c2--><span id="b">b</span>
28117 !! end
28118
28119 ## T89383
28120 !! test
28121 Selser: Check for validity of DSR before using it
28122 !! options
28123 parsoid={
28124 "modes": ["selser"],
28125 "changes": [
28126 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
28127 ]
28128 }
28129 !! wikitext
28130 <span id="a">a</span>
28131 !! wikitext/edited
28132 {{DISPLAYTITLE:foo}}
28133 <span id="a">a</span>
28134 !! end
28135
28136 !! test
28137 1. DOMDiff: Changes to <ref> content should be looked up using id
28138 !! options
28139 parsoid={
28140 "modes": ["selser"],
28141 "changes": [
28142 ["#X", "after", "bar"],
28143 ["#Y", "after", "baz"]
28144 ]
28145 }
28146 !! wikitext
28147 X <ref><span id="X">foo</span></ref>
28148 Y <ref name="a" />
28149 <references>
28150 <ref name="a"><span id="Y">foo</span></ref>
28151 </references>
28152 !! wikitext/edited
28153 X <ref><span id="X">foo</span>bar</ref>
28154 Y <ref name="a" />
28155 <references>
28156 <ref name="a"><span id="Y">foo</span>baz</ref>
28157 </references>
28158 !! end
28159
28160 !! test
28161 2. DOMDiff: Changes to <ref> content should be looked up using id
28162 !! options
28163 parsoid={
28164 "modes": ["selser"],
28165 "changes": [
28166 ["#Z", "after", "bar"]
28167 ]
28168 }
28169 !! wikitext
28170 A <ref>foo bar for a</ref>
28171 B <ref group="X" name="b" />
28172
28173 <references />
28174
28175 <references group="X">
28176 <ref name="b"><span id="Z">foo</span></ref>
28177 </references>
28178 !! wikitext/edited
28179 A <ref>foo bar for a</ref>
28180 B <ref group="X" name="b" />
28181
28182 <references />
28183
28184 <references group="X">
28185 <ref name="b"><span id="Z">foo</span>bar</ref>
28186 </references>
28187 !! end
28188
28189 !! test
28190 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
28191 !! options
28192 parsoid={
28193 "modes": ["selser"],
28194 "changes": [
28195 [ "div:first-child", "text", "bar" ]
28196 ]
28197 }
28198 !! wikitext
28199 <div style="{{1x|color:red;}}%">foo</div>
28200 !! wikitext/edited
28201 <div style="{{1x|color:red;}}%">bar</div>
28202 !! end
28203
28204 !! test
28205 Empty LI (T49673)
28206 !! wikitext
28207 * a
28208 *
28209 *
28210 * b
28211 !! html/php+tidy
28212 <ul>
28213 <li>a</li>
28214 <li class="mw-empty-elt"></li>
28215 <li class="mw-empty-elt"></li>
28216 <li>b</li>
28217 </ul>
28218 !! end
28219
28220 !! test
28221 Thumbnail output
28222 !! wikitext
28223 [[File:Thumb.png|thumb]]
28224 !! html/php+tidy
28225 <div class="thumb tright">
28226 <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>
28227 <div class="thumbcaption">
28228 <div class="magnify"><a href="/wiki/File:Thumb.png" class="internal" title="Enlarge"></a></div>
28229 </div>
28230 </div>
28231 </div>
28232 !! end
28233
28234 !! test
28235 unclosed internal link XSS (T137264)
28236 !! wikitext
28237 [[#%3Cscript%3Ealert(1)%3C/script%3E|
28238 !! html/php
28239 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
28240 </p>
28241 !! html/parsoid
28242 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
28243 !! end