Merge "Refactor UploadBase::checkWarnings into smaller methods"
[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 Serialization of purely hash wikilink
8306 !! options
8307 title=[[User:Test/123]]
8308 subpage
8309 parsoid=html2wt
8310 !! html/parsoid
8311 <p><a href="#a">[[</a></p>
8312 !! wikitext
8313 [[#a|<nowiki>[[</nowiki>]]
8314 !! html/php
8315 <p><a href="#a">[[</a>
8316 </p>
8317 !! end
8318
8319 !! test
8320 1. Interaction of linktrail and template encapsulation
8321 !! wikitext
8322 {{echo|[[Foo]]}}l
8323 !! html/parsoid
8324 <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>
8325 !! end
8326
8327 !! test
8328 2. Interaction of linktrail and template encapsulation
8329 !! options
8330 parsoid
8331 !! wikitext
8332 {{echo|Some [[Fool]]}}s
8333 !! html
8334 <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>
8335 !! end
8336
8337 !! test
8338 3. Interaction of linktrail and template encapsulation
8339 !! options
8340 parsoid
8341 !! wikitext
8342 {{echo|Some [[Fool]]s are '''bold and foolish'''}}
8343 !! html
8344 <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>
8345 !! end
8346
8347 !! article
8348 Söfnuður
8349 !! text
8350 Test.
8351 !! endarticle
8352
8353 !! test
8354 Internal link with is link prefix
8355 !! options
8356 language=is
8357 !! wikitext
8358 Aðrir mótmælenda[[söfnuður|söfnuðir]] og
8359 !! html
8360 <p>Aðrir <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a> og
8361 </p>
8362 !! end
8363
8364 !! article
8365 Mótmælendatrú
8366 !! text
8367 Test.
8368 !! endarticle
8369
8370 !! test
8371 Internal link with is link trail and link prefix
8372 !! options
8373 language=is
8374 !! wikitext
8375 [[mótmælendatrú|xxx]]ar
8376 [[mótmælendatrú]]ar
8377 mótmælenda[[söfnuður]]
8378 mótmælenda[[söfnuður|söfnuðir]]
8379 mótmælenda[[söfnuður|söfnuðir]]xxx
8380 !! html
8381 <p><a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">xxxar</a>
8382 <a href="/wiki/M%C3%B3tm%C3%A6lendatr%C3%BA" title="Mótmælendatrú">mótmælendatrúar</a>
8383 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuður</a>
8384 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðir</a>
8385 <a href="/wiki/S%C3%B6fnu%C3%B0ur" title="Söfnuður">mótmælendasöfnuðirxxx</a>
8386 </p>
8387 !! end
8388
8389 !! test
8390 Parsoid link trail escaping
8391 !! options
8392 parsoid=html2wt,html2html
8393 !! html/parsoid
8394 <p><a rel="mw:WikiLink" href="./Apple" title="Apple">apple</a>s</p>
8395 !! wikitext
8396 [[apple]]<nowiki/>s
8397 !! end
8398
8399 !! test
8400 Parsoid link prefix escaping
8401 !! options
8402 language=is
8403 parsoid=html2wt,html2html
8404 !! html/parsoid
8405 <p>Aðrir mótmælenda<a rel="mw:WikiLink" href="./Söfnuður" title="Söfnuður">söfnuður</a></p>
8406 !! wikitext
8407 Aðrir mótmælenda<nowiki/>[[söfnuður]]
8408 !! end
8409
8410 !! test
8411 Parsoid-centric test: Whitespace in ext- and wiki-links should be preserved
8412 !! wikitext
8413 [[Foo| bar]]
8414
8415 [[Foo| ''bar'']]
8416
8417 [http://wp.org foo]
8418
8419 [http://wp.org ''foo'']
8420 !! html
8421 <p><a href="/wiki/Foo" title="Foo"> bar</a>
8422 </p><p><a href="/wiki/Foo" title="Foo"> <i>bar</i></a>
8423 </p><p><a rel="nofollow" class="external text" href="http://wp.org">foo</a>
8424 </p><p><a rel="nofollow" class="external text" href="http://wp.org"><i>foo</i></a>
8425 </p>
8426 !! end
8427
8428 !! test
8429 Parsoid: Scoped parsing should handle mixed transclusions and plain text
8430 !! wikitext
8431 [[Foo|{{echo|a}} b {{echo|c}}]]
8432 !! html/parsoid
8433 <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>
8434 !! end
8435
8436 !! test
8437 Link with angle bracket after anchor
8438 !! wikitext
8439 [[Foo#<bar>]]
8440 !! html/php
8441 <p><a href="/wiki/Foo#.3Cbar.3E" title="Foo">Foo#&lt;bar&gt;</a>
8442 </p>
8443 !! html/parsoid
8444 <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>
8445 !! end
8446
8447 ###
8448 ### Interwiki links (see maintenance/interwiki.sql)
8449 ###
8450
8451 !! test
8452 Inline interwiki link
8453 !! options
8454 parsoid=wt2html,wt2wt,html2html
8455 !! wikitext
8456 [[MeatBall:SoftSecurity]]
8457 !! html/php
8458 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a>
8459 </p>
8460 !! html/parsoid
8461 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity" title="meatball:SoftSecurity">MeatBall:SoftSecurity</a></p>
8462 !! end
8463
8464 !! test
8465 Inline interwiki link with empty title (T4372)
8466 !! options
8467 parsoid=wt2html,wt2wt,html2html
8468 !! wikitext
8469 [[MeatBall:]]
8470 !! html/php
8471 <p><a href="http://www.usemod.com/cgi-bin/mb.pl" class="extiw" title="meatball:">MeatBall:</a>
8472 </p>
8473 !! html/parsoid
8474 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?" title="meatball:">MeatBall:</a></p>
8475 !! end
8476
8477 !! test
8478 Interwiki link encoding conversion (T3636)
8479 !! wikitext
8480 *[[Wikipedia:ro:Olteni&#0355;a]]
8481 *[[Wikipedia:ro:Olteni&#355;a]]
8482 !! html
8483 <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>
8484 <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>
8485
8486 !! html+tidy
8487 <ul>
8488 <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>
8489 <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>
8490 </ul>
8491 !! end
8492
8493 !! test
8494 Interwiki link with fragment (T4130)
8495 !! wikitext
8496 [[MeatBall:SoftSecurity#foo]]
8497 !! html
8498 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?SoftSecurity#foo" class="extiw" title="meatball:SoftSecurity">MeatBall:SoftSecurity#foo</a>
8499 </p>
8500 !! end
8501
8502 !! test
8503 Link scenarios with escaped fragments
8504 !! wikitext
8505 [[#Is this great?]]
8506 [[Foo#Is this great?]]
8507 [[meatball:Foo#Is this great?]]
8508 !! html/php
8509 <p><a href="#Is_this_great.3F">#Is this great?</a>
8510 <a href="/wiki/Foo#Is_this_great.3F" title="Foo">Foo#Is this great?</a>
8511 <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>
8512 </p>
8513 !! html/parsoid
8514 <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>
8515 <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>
8516 <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>
8517 !! end
8518
8519 # Ideally the wikipedia: prefix here should be proto-relative too
8520 # [CSA]: this is kind of a bogus test, as the PHP parser test doesn't
8521 # define the 'en' prefix, and originally the test used 'wikipedia',
8522 # which isn't a localinterwiki prefix hence the links to the 'en:Foo'
8523 # article.
8524 !! test
8525 Different interwiki prefixes mapping to the same URL
8526 !! wikitext
8527 [[:en:Foo]]
8528
8529 [[:en:Foo|Foo]]
8530
8531 [[wikipedia:Foo]]
8532
8533 [[:wikipedia:Foo|Foo]]
8534
8535 [[wikipedia:en:Foo]]
8536
8537 [[:wikipedia:en:Foo]]
8538
8539 [[ wikiPEdia :Foo]]
8540 !! html/parsoid
8541 <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>
8542
8543 <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>
8544
8545 <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>
8546
8547 <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>
8548
8549 <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>
8550
8551 <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>
8552
8553 <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>
8554 !! end
8555
8556 !! test
8557 Interwiki links that cannot be represented in wiki syntax
8558 !! wikitext
8559 [[meatball:ok]]
8560 [[meatball:ok#foo|ok with fragment]]
8561 [[meatball:ok_as_well?|ok ending with ? mark]]
8562 [http://de.wikipedia.org/wiki/Foo?action=history has query]
8563 [http://de.wikipedia.org/wiki/#foo is just fragment]
8564
8565 !! html/php
8566 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?ok" class="extiw" title="meatball:ok">meatball:ok</a>
8567 <a href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" class="extiw" title="meatball:ok">ok with fragment</a>
8568 <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>
8569 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8570 <a rel="nofollow" class="external text" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a>
8571 </p>
8572 !! html/parsoid
8573 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?ok" title="meatball:ok">meatball:ok</a>
8574 <a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?ok#foo" title="meatball:ok">ok with fragment</a>
8575 <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>
8576 <a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/Foo?action=history">has query</a>
8577 <a rel="mw:ExtLink" href="http://de.wikipedia.org/wiki/#foo">is just fragment</a></p>
8578 !! end
8579
8580 !! test
8581 Interwiki links: trail
8582 !! wikitext
8583 [[wikipedia:Foo|Ba]]r
8584 !! html/php
8585 <p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
8586 </p>
8587 !! html/parsoid
8588 <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>
8589 !! end
8590
8591 !! test
8592 Local interwiki link
8593 !! options
8594 parsoid=wt2html,wt2wt,html2html
8595 !! wikitext
8596 [[local:Template:Foo]]
8597 !! html/php
8598 <p><a href="/wiki/Template:Foo" title="Template:Foo">local:Template:Foo</a>
8599 </p>
8600 !! html/parsoid
8601 <p><a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">local:Template:Foo</a></p>
8602 !! end
8603
8604 # Parsoid does not mark self-links, by design.
8605 !! test
8606 Local interwiki link: self-link to current page
8607 !! options
8608 title=[[Main Page]]
8609 parsoid=wt2html,wt2wt,html2html
8610 !! wikitext
8611 [[local:Main Page]]
8612 !! html/php
8613 <p><a class="mw-selflink selflink">local:Main Page</a>
8614 </p>
8615 !! html/parsoid
8616 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:Main Page</a></p>
8617 !! end
8618
8619 !! test
8620 Local interwiki link: prefix only (T66167)
8621 !! options
8622 parsoid=wt2html,wt2wt,html2html
8623 !! wikitext
8624 [[local:]]
8625 !! html/php
8626 <p><a href="/wiki/Main_Page" title="Main Page">local:</a>
8627 </p>
8628 !! html/parsoid
8629 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">local:</a></p>
8630 !! end
8631
8632 !! test
8633 Local interwiki link: with additional interwiki prefix (T63357)
8634 !! options
8635 parsoid=wt2html,wt2wt,html2html
8636 !! wikitext
8637 [[local:meatball:Hello]]
8638 !! html/php
8639 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?Hello" class="extiw" title="meatball:Hello">local:meatball:Hello</a>
8640 </p>
8641 !! html/parsoid
8642 <p><a rel="mw:ExtLink" href="http://www.usemod.com/cgi-bin/mb.pl?Hello" title="meatball:Hello">local:meatball:Hello</a></p>
8643 !! end
8644
8645 !! test
8646 Multiple local interwiki link prefixes
8647 !! wikitext
8648 [[local:local:local:local:mi:local:Foo]]
8649 !! options
8650 parsoid=wt2html,wt2wt,html2html
8651 !! html/php
8652 <p><a href="/wiki/Foo" title="Foo">local:local:local:local:mi:local:Foo</a>
8653 </p>
8654 !! html/parsoid
8655 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">local:local:local:local:mi:local:Foo</a></p>
8656 !! end
8657
8658 ###
8659 ### Interlanguage links
8660 ### Language links (so that searching for '### language' matches..)
8661 ###
8662
8663 !! test
8664 Interlanguage link
8665 !! wikitext
8666 Blah blah blah
8667 [[zh:Chinese]]
8668 !! html/php
8669 <p>Blah blah blah
8670 </p>
8671 !! html/parsoid
8672 <p>Blah blah blah</p>
8673 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8674 !! end
8675
8676 ## parsoid html2wt will lose the space variations
8677 !! test
8678 Interlanguage link with spacing
8679 !! options
8680 parsoid=wt2html,wt2wt,html2html
8681 !! wikitext
8682 Blah blah blah
8683 [[ zh : Chinese ]]
8684 !! html/php
8685 <p>Blah blah blah
8686 </p>
8687 !! html/parsoid
8688 <p>Blah blah blah</p>
8689 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8690 !! end
8691
8692 !! test
8693 Double interlanguage link
8694 !! wikitext
8695 Blah blah blah
8696 [[es:Spanish]]
8697 [[zh:Chinese]]
8698 !! html/php
8699 <p>Blah blah blah
8700 </p>
8701 !! html/parsoid
8702 <p>Blah blah blah</p>
8703 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8704 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8705 !! end
8706
8707 ## parsoid html2wt will lose the space variations
8708 !! test
8709 Interlanguage link variations
8710 !! options
8711 parsoid=wt2html,wt2wt,html2html
8712 !! wikitext
8713 Blah blah blah
8714 [[ es :Spanish]]
8715 [[ ZH :Chinese]]
8716 [[es:Foo_bar]]
8717 !! html/php
8718 <p>Blah blah blah
8719 </p>
8720 !! html/parsoid
8721 <p>Blah blah blah</p>
8722 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish" />
8723 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese" />
8724 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Foo_bar" />
8725 !! end
8726
8727 !! test
8728 Escaping of interlanguage links (T129218, T156308)
8729 !! wikitext
8730 Blah blah blah
8731 [[:es:Spanish]]
8732 [[ : zh : Chinese ]]
8733 !! html/php
8734 <p>Blah blah blah
8735 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">es:Spanish</a>
8736 <a href="http://zh.wikipedia.org/wiki/Chinese" class="extiw" title="zh:Chinese"> zh : Chinese </a>
8737 </p>
8738 !! html/parsoid
8739 <p>Blah blah blah
8740 <a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">es:Spanish</a>
8741 <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese"> zh : Chinese </a></p>
8742 !! end
8743
8744 ## parsoid html2wt will normalize the space to _
8745 !! test
8746 Space and question mark encoding in interlanguage links (T95473)
8747 !! options
8748 parsoid=wt2html,wt2wt,html2html
8749 !! wikitext
8750 Blah blah blah
8751 [[es:Foo bar?]]
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://es.wikipedia.org/wiki/Foo_bar%3F" />
8758 !! end
8759
8760 !! test
8761 Interlanguage link, with prefix links
8762 !! options
8763 language=ln
8764 !! wikitext
8765 Blah blah blah
8766 [[zh:Chinese]]
8767 !! html/php
8768 <p>Blah blah blah
8769 </p>
8770 !! html/parsoid
8771 <p>Blah blah blah</p>
8772 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8773 !! end
8774
8775 !! test
8776 Double interlanguage link, with prefix links (T10897)
8777 !! options
8778 language=ln
8779 !! wikitext
8780 Blah blah blah
8781 [[es:Spanish]]
8782 [[zh:Chinese]]
8783 !! html/php
8784 <p>Blah blah blah
8785 </p>
8786 !! html/parsoid
8787 <p>Blah blah blah</p>
8788 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Spanish"/>
8789 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/Chinese"/>
8790 !! end
8791
8792 !! test
8793 "Extra" interlanguage links (T34189 / gerrit 111390)
8794 !! wikitext
8795 Blah blah blah
8796 [[mul:Article]]
8797 !! html/php
8798 <p>Blah blah blah
8799 </p>
8800 !! html/parsoid
8801 <p>Blah blah blah</p>
8802 <link rel="mw:PageProp/Language" title="Multilingual" href="http://wikisource.org/wiki/Article"/>
8803 !! end
8804
8805 ## PHP parser tests script needs an update
8806 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8807 !! test
8808 Language links render as inline links if $wgInterwikiMagic=false
8809 !! options
8810 wgInterwikiMagic=false
8811 parsoid=wt2html,wt2wt,html2html
8812 !! wikitext
8813 Blah blah blah
8814 [[zh:Chinese]]
8815 !! html/parsoid
8816 <p>Blah blah blah <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
8817 !! end
8818
8819 ## PHP parser tests script needs an update
8820 ## Parsoid html2wt will normalize output to [[:zh:Chinese]]
8821 !! test
8822 Language links render as inline links in the Talk namespace
8823 !! options
8824 title=Talk:Foo
8825 parsoid=wt2html,wt2wt,html2html
8826 !! wikitext
8827 Blah blah blah
8828 [[zh:Chinese]]
8829 !! html/parsoid
8830 <p>Blah blah blah <a rel="mw:ExtLink" href="http://zh.wikipedia.org/wiki/Chinese" title="zh:Chinese">zh:Chinese</a></p>
8831 !! end
8832
8833 !! test
8834 Parsoid-specific test: Wikilinks with &nbsp; should RT properly
8835 !! options
8836 language=ln
8837 !! wikitext
8838 [[WW&nbsp;II]]
8839 !! html
8840 <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>
8841 </p>
8842 !! end
8843
8844 !! test
8845 Parsoid T55221: Wikilinks should be properly entity-escaped
8846 !! options
8847 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
8848 !! html/parsoid
8849 <p>He&amp;nbsp;llo <a href="./Foo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
8850 <p>He&amp;nbsp;llo <a href="./He&amp;nbsp;llo" rel="mw:WikiLink">He&amp;nbsp;llo</a></p>
8851 !! wikitext
8852 He&amp;nbsp;llo [[Foo|He&amp;nbsp;llo]]
8853
8854 He&amp;nbsp;llo He&amp;nbsp;llo
8855 !! html/php
8856 <p>He&amp;nbsp;llo <a href="/wiki/Foo" title="Foo">He&amp;nbsp;llo</a>
8857 </p><p>He&amp;nbsp;llo He&amp;nbsp;llo
8858 </p>
8859 !! end
8860
8861 # html2wt will fail because of title normalization without data-parsoid
8862 !! test
8863 Parsoid: handle constructor well
8864 !! options
8865 parsoid=wt2html,wt2wt
8866 !! wikitext
8867 [[constructor]]
8868
8869 [[constructor:foo]]
8870 !! html/php
8871 <p><a href="/index.php?title=Constructor&amp;action=edit&amp;redlink=1" class="new" title="Constructor (page does not exist)">constructor</a>
8872 </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>
8873 </p>
8874 !! html/parsoid
8875 <p><a rel="mw:WikiLink" href="./Constructor" title="Constructor" data-parsoid='{"stx":"simple","a":{"href":"./Constructor"},"sa":{"href":"constructor"}}'>constructor</a></p>
8876
8877 <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>
8878 !! end
8879
8880 !! article
8881 ko:
8882 !! text
8883 Test.
8884 !! endarticle
8885
8886 # Note that `ko` isn't a known interlanguage prefix
8887 !! test
8888 Parsoid: recognize interlanguage links without a target page
8889 !! options
8890 ill
8891 !! wikitext
8892 [[es:]]
8893
8894 [[ko:]]
8895 !! html/php
8896 es:
8897 !! html/parsoid
8898 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/"/>
8899
8900 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
8901 !! end
8902
8903 # Note that `ko` isn't a known interwiki prefix
8904 !! test
8905 Parsoid: recognize interwiki links without a target page
8906 !! options
8907 parsoid=wt2html,wt2wt,html2html
8908 !! wikitext
8909 [[:es:]]
8910
8911 [[:ko:]]
8912 !! html/php
8913 <p><a href="http://es.wikipedia.org/wiki/" class="extiw" title="es:">es:</a>
8914 </p><p><a href="/wiki/Ko:" title="Ko:">ko:</a>
8915 </p>
8916 !! html/parsoid
8917 <p><a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/" title="es:">es:</a></p>
8918 <p><a rel="mw:WikiLink" href="./Ko:" title="Ko:">ko:</a></p>
8919 !! end
8920
8921 !! test
8922 Handle interwiki links pointing to the current wiki as plain wiki links (T47209)
8923 !! wikitext
8924 [[mi:Foo]]
8925 !! html/php
8926 <p><a href="/wiki/Foo" title="Foo">mi:Foo</a>
8927 </p>
8928 !! html/parsoid
8929 <p><a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"simple","a":{"href":"./Foo"},"sa":{"href":"mi:Foo"}}'>mi:Foo</a></p>
8930 !! end
8931
8932 !! test
8933 Interlanguage link with preceding local interwiki link (T70085)
8934 !! options
8935 parsoid=wt2html,wt2wt,html2html
8936 !! wikitext
8937 Blah blah blah
8938 [[local:es:Spanish]]
8939 !! html/php
8940 <p>Blah blah blah
8941 <a href="http://es.wikipedia.org/wiki/Spanish" class="extiw" title="es:Spanish">local:es:Spanish</a>
8942 </p>
8943 !! html/parsoid
8944 <p>Blah blah blah
8945 <a rel="mw:ExtLink" href="http://es.wikipedia.org/wiki/Spanish" title="es:Spanish">local:es:Spanish</a></p>
8946 !! end
8947
8948 !! test
8949 Looks like an interlanguage link, but is actually a local interwiki
8950 !! options
8951 parsoid=wt2html,wt2wt,html2html
8952 !! wikitext
8953 Blah blah blah
8954 [[mi:Template:Foo]]
8955 !! html/php
8956 <p>Blah blah blah
8957 <a href="/wiki/Template:Foo" title="Template:Foo">mi:Template:Foo</a>
8958 </p>
8959 !! html/parsoid
8960 <p>Blah blah blah
8961 <a rel="mw:WikiLink" href="./Template:Foo" title="Template:Foo">mi:Template:Foo</a></p>
8962 !! end
8963
8964 ###
8965 ### Redirects, Parsoid-only
8966 ###
8967
8968 !! test
8969 1. Simple redirect to page
8970 !! wikitext
8971 #REDIRECT [[Main Page]]
8972 !! html/parsoid
8973 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
8974 !! end
8975
8976 !! test
8977 2. Other redirect variants
8978 !! wikitext
8979 #REDIRECT [[Main_Page]]
8980 !! html/parsoid
8981 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./Main_Page"},"sa":{"href":"Main_Page"}}'/>
8982 !! end
8983
8984 # Not a valid redirect in PHP (although perhaps it was, once upon a time)
8985 # This tests the Parsoid bail-out code.
8986 !! test
8987 3. Other redirect variants
8988 !! wikitext
8989 #REDIRECT [[<nowiki>[[Bar]]</nowiki>]]
8990 !! html/parsoid
8991 <ol><li data-parsoid>REDIRECT [[[[Bar]]]]</li></ol>
8992 !! end
8993
8994 !! test
8995 4. Redirect to a templated destination
8996 !! wikitext
8997 #REDIRECT [[{{echo|Foo}}bar]]
8998 !! html/parsoid
8999 <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"}]]}'/>
9000 !! end
9001
9002 !! test
9003 Empty redirect
9004 !! options
9005 parsoid=wt2html,wt2wt
9006 !! wikitext
9007 #REDIRECT [[]]
9008 !! html/parsoid
9009 <ol>
9010 <li>REDIRECT [[]]</li></ol>
9011 !! end
9012
9013 !! test
9014 Optional colon in #REDIRECT
9015 !! options
9016 # the colon is archaic syntax. we support it for wt2html, but we
9017 # don't care that it roundtrips back to the modern syntax.
9018 parsoid=wt2html,html2html
9019 !! wikitext
9020 #REDIRECT:[[Main Page]]
9021 !! html/parsoid
9022 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9023 !! end
9024
9025 !! test
9026 Whitespace in #REDIRECT with optional colon
9027 !! options
9028 # the colon and gratuitous whitespace is archaic syntax. we support
9029 # it for wt2html, but we don't care that it roundtrips back to the
9030 # modern syntax (without extra whitespace)
9031 parsoid=wt2html,html2html
9032 !! wikitext
9033
9034 #REDIRECT
9035 :
9036 [[Main Page]]
9037 !! html/parsoid
9038 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9039 !! end
9040
9041 !! test
9042 Piped link in #REDIRECT
9043 !! options
9044 # content after piped link is ignored. we support this syntax,
9045 # but don't care that the piped link is lost when we roundtrip this.
9046 parsoid=wt2html
9047 !! wikitext
9048 #REDIRECT [[Main Page|bar]]
9049 !! html/parsoid
9050 <link rel="mw:PageProp/redirect" href="./Main_Page"/>
9051 !! end
9052
9053 !! test
9054 Redirect to category (T104502)
9055 !! options
9056 parsoid=wt2html,wt2wt
9057 !! wikitext
9058 #REDIRECT [[Category:Foo]]
9059 !! html/parsoid
9060 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9061 !! end
9062
9063 !! test
9064 Redirect to category with URL encoding (T104502)
9065 !! options
9066 parsoid=wt2html
9067 !! wikitext
9068 #REDIRECT [[Category%3AFoo]]
9069 !! html/parsoid
9070 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9071 !! end
9072
9073 !! test
9074 Redirect to category page
9075 !! wikitext
9076 #REDIRECT [[:Category:Foo]]
9077 !! html/parsoid
9078 <link rel="mw:PageProp/redirect" href="./Category:Foo"/>
9079 !! end
9080
9081 !! test
9082 Redirect to image page (1)
9083 !! wikitext
9084 #REDIRECT [[File:Wiki.png]]
9085 !! html/parsoid
9086 <link rel="mw:PageProp/redirect" href="./File:Wiki.png"/>
9087 !! end
9088
9089 !! test
9090 Redirect to image page (2)
9091 !! wikitext
9092 #REDIRECT [[Image:Wiki.png]]
9093 !! html/parsoid
9094 <link rel="mw:PageProp/redirect" href="./File:Wiki.png" data-parsoid='{"src":"#REDIRECT ","a":{"href":"./File:Wiki.png"},"sa":{"href":"Image:Wiki.png"}}'/>
9095 !! end
9096
9097 # html2wt disabled because wts serializes as "#REDIRECT [[:en:File:Wiki.png]]"
9098 # Next test confirms this.
9099 !! test
9100 Redirect to language (1) (T104918)
9101 !! options
9102 parsoid=wt2html,wt2wt,html2html
9103 !! wikitext
9104 #REDIRECT [[en:File:Wiki.png]]
9105 !! html/parsoid
9106 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9107 !! end
9108
9109 !! test
9110 Redirect to language (2) (T104918)
9111 !! wikitext
9112 #REDIRECT [[:en:File:Wiki.png]]
9113 !! html/parsoid
9114 <link rel="mw:PageProp/redirect" href="//en.wikipedia.org/wiki/File:Wiki.png"/>
9115 !! end
9116
9117 !! test
9118 Redirect to interwiki (T104918)
9119 !! wikitext
9120 #REDIRECT [[meatball:File:Wiki.png]]
9121 !! html/parsoid
9122 <link rel="mw:PageProp/redirect" href="http://www.usemod.com/cgi-bin/mb.pl?File:Wiki.png"/>
9123 !! end
9124
9125 !! test
9126 Non-English #REDIRECT
9127 !! options
9128 language=is
9129 !! wikitext
9130 #TILVÍSUN [[Main Page]]
9131 !! html/parsoid
9132 <link rel="mw:PageProp/redirect" href="./Main_Page" data-parsoid='{"src":"#TILVÍSUN ","a":{"href":"./Main_Page"},"sa":{"href":"Main Page"}}'/>
9133 !! end
9134
9135 !! test
9136 Redirect syntax under text isn't considered a redirect
9137 !! wikitext
9138 some text
9139 #redirect [[Main Page]]
9140 !! html/parsoid
9141 <p>some text</p>
9142 <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>
9143 !! end
9144
9145 # FIXME: Should hoist the redirect to the top of the page and ensure there
9146 # is only one.
9147 !! test
9148 New redirect
9149 !! options
9150 parsoid=html2wt
9151 !! html/parsoid
9152 <p>Foo<link rel="mw:PageProp/redirect" href="./Foo"/></p>
9153 !! wikitext
9154 Foo
9155 #REDIRECT [[Foo]]
9156 !! end
9157
9158 ##
9159 ## XHTML tidiness
9160 ###
9161
9162 !! test
9163 <br> to <br />
9164 !! wikitext
9165 1<br>2<br />3
9166 !! html
9167 <p>1<br />2<br />3
9168 </p>
9169 !! end
9170
9171 !! test
9172 Broken br tag sanitization
9173 !! wikitext
9174 </br>
9175 !! html/php
9176 <p>&lt;/br&gt;
9177 </p>
9178 !! end
9179
9180 # TODO: Fix html2html mode (T53055)!
9181 !! test
9182 Parsoid: Broken br tag recognition
9183 !! options
9184 parsoid=wt2html
9185 !! wikitext
9186 </br>
9187
9188 <br/ >
9189 !! html+tidy
9190 <p><br /></p>
9191 <p><br /></p>
9192 !! end
9193
9194 !! test
9195 Incorrecly removing closing slashes from correctly formed XHTML
9196 !! wikitext
9197 <br style="clear:both;" />
9198 !! html
9199 <p><br style="clear:both;" />
9200 </p>
9201 !! end
9202
9203 !! test
9204 Failing to transform badly formed HTML into correct XHTML
9205 !! wikitext
9206 <br style="clear: left;">
9207 <br style="clear: right;">
9208 <br style="clear: both;">
9209 !! html
9210 <p><br style="clear: left;" />
9211 <br style="clear: right;" />
9212 <br style="clear: both;" />
9213 </p>
9214 !!end
9215
9216 ## FIXME: Is Parsoid's acceptance of self-closing html-tags
9217 ## a feature or a bug? See https://phabricator.wikimedia.org/T76962
9218 !! test
9219 Handling html with a div self-closing tag
9220 !! wikitext
9221 <div title />
9222 <div title/>
9223 <div title/ >
9224 <div title=bar />
9225 <div title=bar/>
9226 <div title=bar/ >
9227 !! html/php
9228 <p>&lt;div title /&gt;
9229 &lt;div title/&gt;
9230 </p>
9231 <div>
9232 <p>&lt;div title=bar /&gt;
9233 &lt;div title=bar/&gt;
9234 </p>
9235 <div title="bar/"></div>
9236 </div>
9237
9238 !! html/parsoid
9239 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9240 <div title="" data-parsoid='{"stx":"html","selfClose":true}'></div>
9241 <div title="" data-parsoid='{"stx":"html","selfClose":true,"brokenHTMLTag":true}'></div>
9242 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9243 <div title="bar" data-parsoid='{"stx":"html","selfClose":true}'></div>
9244 <div title="bar/" data-parsoid='{"stx":"html","autoInsertedEnd":true}'></div>
9245 !! end
9246
9247 !! test
9248 Handling html with a br self-closing tag
9249 !! wikitext
9250 <br title />
9251 <br title/>
9252 <br title/ >
9253 <br title=bar />
9254 <br title=bar/>
9255 <br title=bar/ >
9256 !! html/php
9257 <p><br title="" />
9258 <br title="" />
9259 <br />
9260 <br title="bar" />
9261 <br title="bar" />
9262 <br title="bar/" />
9263 </p>
9264 !! html/parsoid
9265 <p><br title="" />
9266 <br title="" />
9267 <br title="" />
9268 <br title="bar" />
9269 <br title="bar" />
9270 <br title="bar/" />
9271 </p>
9272 !! end
9273
9274 !! test
9275 Horizontal ruler (should it add that extra space?)
9276 !! wikitext
9277 <hr>
9278 <hr >
9279 foo <hr
9280 > bar
9281 !! html+tidy
9282 <hr />
9283 <hr />
9284 <p>foo</p>
9285 <hr />
9286 <p>bar</p>
9287 !! end
9288
9289 !! test
9290 Horizontal ruler -- 4+ dashes render hr
9291 !! wikitext
9292 ----
9293 !! html
9294 <hr />
9295
9296 !! end
9297
9298 !! test
9299 Horizontal ruler -- eats additional dashes on the same line
9300 !! wikitext
9301 ---------
9302 !! html
9303 <hr />
9304
9305 !! end
9306
9307 !! test
9308 Horizontal ruler -- does not collapse dashes on consecutive lines
9309 !! wikitext
9310 ----
9311 ----
9312 !! html
9313 <hr />
9314 <hr />
9315
9316 !! end
9317
9318 !! test
9319 Horizontal ruler -- <4 dashes render as plain text
9320 !! wikitext
9321 ---
9322 !! html
9323 <p>---
9324 </p>
9325 !! end
9326
9327 !! test
9328 Horizontal ruler -- Supports content following dashes on same line
9329 !! wikitext
9330 ---- Foo
9331 !! html
9332 <hr /> Foo
9333
9334 !! html+tidy
9335 <hr />
9336 <p>Foo</p>
9337 !! end
9338
9339 ###
9340 ### Block-level elements
9341 ###
9342 !! test
9343 Common list
9344 !! wikitext
9345 *Common list
9346 * item 2
9347 *item 3
9348 !! html
9349 <ul><li>Common list</li>
9350 <li> item 2</li>
9351 <li>item 3</li></ul>
9352
9353 !! end
9354
9355 !! test
9356 Numbered list
9357 !! wikitext
9358 #Numbered list
9359 #item 2
9360 # item 3
9361 !! html
9362 <ol><li>Numbered list</li>
9363 <li>item 2</li>
9364 <li> item 3</li></ol>
9365
9366 !! end
9367
9368 !! test
9369 Mixed list
9370 !! wikitext
9371 *Mixed list
9372 *# with numbers
9373 ** and bullets
9374 *# and numbers
9375 *bullets again
9376 **bullet level 2
9377 ***bullet level 3
9378 ***#Number on level 4
9379 **bullet level 2
9380 **#Number on level 3
9381 **#Number on level 3
9382 *#number level 2
9383 *Level 1
9384 *** Level 3
9385 #** Level 3, but ordered
9386 !! html
9387 <ul><li>Mixed list
9388 <ol><li> with numbers</li></ol>
9389 <ul><li> and bullets</li></ul>
9390 <ol><li> and numbers</li></ol></li>
9391 <li>bullets again
9392 <ul><li>bullet level 2
9393 <ul><li>bullet level 3
9394 <ol><li>Number on level 4</li></ol></li></ul></li>
9395 <li>bullet level 2
9396 <ol><li>Number on level 3</li>
9397 <li>Number on level 3</li></ol></li></ul>
9398 <ol><li>number level 2</li></ol></li>
9399 <li>Level 1
9400 <ul><li><ul><li> Level 3</li></ul></li></ul></li></ul>
9401 <ol><li><ul><li><ul><li> Level 3, but ordered</li></ul></li></ul></li></ol>
9402
9403 !! end
9404
9405 !! test
9406 1. Nested mixed wikitext and html list
9407 !! wikitext
9408 * hi
9409 * <ul><li>ho</li></ul>
9410 * hi
9411 ** ho
9412 !! html/php
9413 <ul><li> hi</li>
9414 <li> <ul><li>ho</li></ul></li>
9415 <li> hi
9416 <ul><li> ho</li></ul></li></ul>
9417
9418 !! html/parsoid
9419 <ul><li> hi</li>
9420 <li> <ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>ho</li></ul></li>
9421 <li> hi
9422 <ul><li> ho</li></ul></li></ul>
9423 !! end
9424
9425 !! test
9426 2. Nested mixed wikitext and html list (incompatible)
9427 !! wikitext
9428 ; hi
9429 : {{echo|<li>ho</li>}}
9430 !! html/php
9431 <dl><dt> hi</dt>
9432 <dd> <li>ho</li></dd></dl>
9433
9434 !! html/parsoid
9435 <dl><dt> hi</dt>
9436 <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>
9437 !! end
9438
9439 !! test
9440 Nested lists 1
9441 !! wikitext
9442 *foo
9443 **bar
9444 !! html
9445 <ul><li>foo
9446 <ul><li>bar</li></ul></li></ul>
9447
9448 !! end
9449
9450 !! test
9451 Nested lists 2
9452 !! wikitext
9453 **foo
9454 *bar
9455 !! html
9456 <ul><li><ul><li>foo</li></ul></li>
9457 <li>bar</li></ul>
9458
9459 !! end
9460
9461 !! test
9462 Nested lists 3 (first element empty)
9463 !! wikitext
9464 *
9465 **bar
9466 !! html
9467 <ul><li>
9468 <ul><li>bar</li></ul></li></ul>
9469
9470 !! end
9471
9472 !! test
9473 Nested lists 4 (first element empty)
9474 !! wikitext
9475 **
9476 *bar
9477 !! html
9478 <ul><li><ul><li></li></ul></li>
9479 <li>bar</li></ul>
9480
9481 !! end
9482
9483 !! test
9484 Nested lists 5 (both elements empty)
9485 !! wikitext
9486 **
9487 *
9488 !! html
9489 <ul><li><ul><li></li></ul></li>
9490 <li></li></ul>
9491
9492 !! end
9493
9494 !! test
9495 Nested lists 6 (both elements empty)
9496 !! wikitext
9497 *
9498 **
9499 !! html
9500 <ul><li>
9501 <ul><li></li></ul></li></ul>
9502
9503 !! end
9504
9505 !! test
9506 Nested lists 7 (skip initial nesting levels)
9507 !! wikitext
9508 *** foo
9509 !! html
9510 <ul><li><ul><li><ul><li> foo</li></ul></li></ul></li></ul>
9511
9512 !! end
9513
9514 !! test
9515 Nested lists 8 (multiple nesting transitions)
9516 !! wikitext
9517 * foo
9518 *** bar
9519 ** baz
9520 * boo
9521 !! html
9522 <ul><li> foo
9523 <ul><li><ul><li> bar</li></ul></li>
9524 <li> baz</li></ul></li>
9525 <li> boo</li></ul>
9526
9527 !! end
9528
9529 !! test
9530 Nested lists 9 (extension interaction)
9531 !! options
9532 parsoid
9533 !! wikitext
9534 *<references />
9535 !! html/parsoid
9536 <ul><li data-parsoid='{}'><ol class="mw-references" typeof="mw:Extension/references" about="#mwt2" data-parsoid='{}' data-mw='{"name":"references","attrs":{}}'></ol></li></ul>
9537 !! end
9538
9539 !! test
9540 1. Lists with start-of-line-transparent tokens before bullets: Comments
9541 !! wikitext
9542 *foo
9543 *<!--cmt-->bar
9544 <!--cmt-->*baz
9545 !! html
9546 <ul><li>foo</li>
9547 <li>bar</li>
9548 <li>baz</li></ul>
9549
9550 !! end
9551
9552 !! test
9553 2. Lists with start-of-line-transparent tokens before bullets: Template close
9554 !! wikitext
9555 *foo {{echo|bar
9556 }}*baz
9557 !! html
9558 <ul><li>foo bar</li>
9559 <li>baz</li></ul>
9560
9561 !! end
9562
9563 !! test
9564 List items are not parsed correctly following a <pre> block (T2785)
9565 !! wikitext
9566 * <pre>foo</pre>
9567 * <pre>bar</pre>
9568 * zar
9569 !! html/php
9570 <ul><li> <pre>foo</pre></li>
9571 <li> <pre>bar</pre></li>
9572 <li> zar</li></ul>
9573
9574 !! html/parsoid
9575 <ul><li> <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre></li>
9576 <li> <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"bar"}}'>bar</pre></li>
9577 <li> zar</li></ul>
9578 !! end
9579
9580 !! test
9581 List items from template
9582 !! wikitext
9583
9584 {{inner list}}
9585 * item 2
9586
9587 * item 0
9588 {{inner list}}
9589 * item 2
9590
9591 * item 0
9592 * notSOL{{inner list}}
9593 * item 2
9594 !! html
9595 <ul><li> item 1</li>
9596 <li> item 2</li></ul>
9597 <ul><li> item 0</li>
9598 <li> item 1</li>
9599 <li> item 2</li></ul>
9600 <ul><li> item 0</li>
9601 <li> notSOL</li>
9602 <li> item 1</li>
9603 <li> item 2</li></ul>
9604
9605 !! end
9606
9607 !! test
9608 List interrupted by empty line or heading
9609 !! wikitext
9610 * foo
9611
9612 ** bar
9613 == A heading ==
9614 * Another list item
9615 !! html
9616 <ul><li> foo</li></ul>
9617 <ul><li><ul><li> bar</li></ul></li></ul>
9618 <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>
9619 <ul><li> Another list item</li></ul>
9620
9621 !!end
9622
9623 !!test
9624 Multiple list tags generated by templates
9625 !! wikitext
9626 {{echo|<li>}}a
9627 {{echo|<li>}}b
9628 {{echo|<li>}}c
9629 !! html
9630 <li>a
9631 <li>b
9632 <li>c</li>
9633 </li>
9634 </li>
9635
9636 !! html+tidy
9637 <ul>
9638 <li>a</li>
9639 <li>b</li>
9640 <li>c</li>
9641 </ul>
9642 !!end
9643
9644 !!test
9645 Single-comment whitespace lines dont break lists, and neither do multi-comment whitespace lines
9646 !! wikitext
9647 *a
9648 <!--This line will NOT split the list-->
9649 *b
9650 <!--This line will NOT split the list either-->
9651 *c
9652 <!--foo--> <!----> <!--This line NOT split the list either-->
9653 *d
9654 !! html
9655 <ul><li>a</li>
9656 <li>b</li>
9657 <li>c</li>
9658 <li>d</li></ul>
9659
9660 !!end
9661
9662 !!test
9663 Replacing whitespace with tabs still doesn't break the list (gerrit 78327)
9664 !! wikitext
9665 *a
9666 <!--This line will NOT split the list-->
9667 *b
9668 <!--This line will NOT split the list either-->
9669 *c
9670 <!--foo--> <!----> <!--This line NOT split the list
9671 either-->
9672 *d
9673 !! html
9674 <ul><li>a</li>
9675 <li>b</li>
9676 <li>c</li>
9677 <li>d</li></ul>
9678
9679 !!end
9680
9681 !!test
9682 Test the li-hack
9683 (The PHP parser relies on Tidy for the hack)
9684 !!options
9685 parsoid=wt2html,wt2wt
9686 !! wikitext
9687 * foo
9688 * <li>li-hack
9689 * {{echo|<li>templated li-hack}}
9690 * <!--foo--> <li> unsupported li-hack with preceding comments
9691
9692 <ul>
9693 <li><li>not a li-hack
9694 </li>
9695 </ul>
9696 !! html+tidy
9697 <ul>
9698 <li>foo</li>
9699 <li>li-hack</li>
9700 <li>templated li-hack</li>
9701 <li>unsupported li-hack with preceding comments</li>
9702 </ul>
9703 <ul>
9704 <li>not a li-hack</li>
9705 </ul>
9706 !!end
9707
9708 !! test
9709 Parsoid: Make sure nested lists are serialized on their own line even if HTML contains no newlines
9710 !! options
9711 parsoid
9712 !! wikitext
9713 # foo
9714 ## bar
9715 * foo
9716 ** bar
9717 : foo
9718 :: bar
9719 !! html
9720 <ol>
9721 <li> foo<ol>
9722 <li> bar</li>
9723 </ol></li>
9724 </ol><ul>
9725 <li> foo<ul>
9726 <li> bar</li>
9727 </ul></li>
9728 </ul><dl>
9729 <dd> foo<dl>
9730 <dd> bar</dd>
9731 </dl></dd>
9732 </dl>
9733 !! end
9734
9735 !! test
9736 Parsoid: Test of whitespace serialization with Templated bullets
9737 !! options
9738 parsoid
9739 !! wikitext
9740 * {{bullet}}
9741 !! html
9742 <ul>
9743 <li> </li><li about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"bullet","href":"./Template:Bullet"},"params":{},"i":0}}]}'> Bar</li>
9744 </ul>
9745 !! end
9746
9747 # ------------------------------------------------------------------------
9748 # The next set of tests are about Parsoid's ability to handle badly nested
9749 # tags (parse, minimize scope of fixup, and roundtrip back)
9750 # ------------------------------------------------------------------------
9751
9752 !! test
9753 Unbalanced closing block tags break a list
9754 (php parser relies on Tidy to fix up)
9755 !! wikitext
9756 <div>
9757 *a</div><div>
9758 *b</div>
9759 !! html+tidy
9760 <div>
9761 <ul>
9762 <li>a</li>
9763 </ul>
9764 </div>
9765 <div>
9766 <ul>
9767 <li>b</li>
9768 </ul>
9769 </div>
9770 !! end
9771
9772 # Parsoid fails this test, but it might be tricky to support properly.
9773 # See T70395.
9774 !! test
9775 Unbalanced closing non-block tags don't break a list
9776 (php parser relies on Tidy to fix up)
9777 !! wikitext
9778 <span>
9779 *a</span><span>
9780 *b</span>
9781 !! html/php+tidy
9782 <ul>
9783 <li><span>a</span></li>
9784 <li><span>b</span></li>
9785 </ul>
9786 !! html/parsoid
9787 <span>
9788 <ul>
9789 <li>a<span></span>
9790 </li>
9791 <li>b
9792 </li>
9793 </ul>
9794 </span>
9795 !! end
9796
9797 !! test
9798 Unclosed formatting tags that straddle lists are closed and reopened
9799 (php parser relies on Tidy to fix up)
9800 !! options
9801 parsoid=wt2html,wt2wt,html2html
9802 !! wikitext
9803 # <s> a
9804 # b </s>
9805 !! html/php+tidy
9806 <ol>
9807 <li><s>a</s></li>
9808 <li><s>b</s></li>
9809 </ol>
9810 !! html/parsoid
9811 <ol><li> <s> a</s></li>
9812 <li><s> b </s></li></ol>
9813 !! end
9814
9815 # See T70395.
9816 !!test
9817 1. List embedded in a formatting tag
9818 !! wikitext
9819 <small>
9820 * foo
9821 </small>
9822 !! html/php+tidy
9823 <ul>
9824 <li><small>foo</small></li>
9825 </ul>
9826 !! html/parsoid
9827 <small>
9828 <ul>
9829 <li> foo</li>
9830 </ul>
9831 </small>
9832 !!end
9833
9834 ## Ugly Parsoid output here
9835 ## Not sure what the right output is.
9836 !!test
9837 2. List embedded in a formatting tag
9838 !! wikitext
9839 <small>
9840 *a
9841 *b</small>
9842 !! html/php+tidy
9843 <ul>
9844 <li><small>a</small></li>
9845 <li><small>b</small></li>
9846 </ul>
9847 !! html/parsoid
9848 <small></small>
9849 <ul><small>
9850 <li>a</li>
9851 </small>
9852 <li><small>b</small></li>
9853 </ul>
9854 !!end
9855
9856 # Ugly Parsoid and PHP parser output here
9857 # Not sure if we want to make this a test!
9858 #
9859 ## !!test
9860 ## 3. Unclosed formatting tags in list elements
9861 ## !! wikitext
9862 ## *<small>a
9863 ## *<small>b
9864 ## !! html/php+tidy
9865 ## <ul>
9866 ## <li><small>a</small></li>
9867 ## <li><small><small>b</small></small></li>
9868 ## </ul>
9869 ## !! html/parsoid
9870 ## <ul>
9871 ## <li><small>a</small></li>
9872 ## <small>
9873 ## <li><small>b</small></li>
9874 ## </small></ul>
9875 ## !!end
9876
9877 # This is a bug in the PHP parser + tidy combination.
9878 # (The </tr> tag gets parsed as text and html-escaped by PHP,
9879 # and then fostered out of the table by tidy.)
9880 # We believe the Parsoid output to be correct.
9881 !! test
9882 Table with missing opening <tr> tag
9883 !! options
9884 parsoid=wt2html,wt2wt
9885 !! wikitext
9886 <table>
9887 <td>foo</td>
9888 </tr>
9889 </table>
9890 !! html+tidy
9891 <table>
9892 <tr>
9893 <td>foo</td>
9894 </tr>
9895 </table>
9896 !! end
9897
9898 ###
9899 ### Magic Words
9900 ###
9901
9902 # Note that the current date is hard-coded as
9903 # 1970-01-01T00:02:03Z (a Thursday)
9904 # when running parser tests. The timezone is also fixed to GMT, so
9905 # local date will be identical to current date.
9906
9907 !! test
9908 Magic Word: {{CURRENTDAY}}
9909 !! wikitext
9910 {{CURRENTDAY}}
9911 !! html
9912 <p>1
9913 </p>
9914 !! end
9915
9916 !! test
9917 Magic Word: {{CURRENTDAY2}}
9918 !! wikitext
9919 {{CURRENTDAY2}}
9920 !! html
9921 <p>01
9922 </p>
9923 !! end
9924
9925 !! test
9926 Magic Word: {{CURRENTDAYNAME}}
9927 !! wikitext
9928 {{CURRENTDAYNAME}}
9929 !! html
9930 <p>Thursday
9931 </p>
9932 !! end
9933
9934 !! test
9935 Magic Word: {{CURRENTDOW}}
9936 !! wikitext
9937 {{CURRENTDOW}}
9938 !! html
9939 <p>4
9940 </p>
9941 !! end
9942
9943 !! test
9944 Magic Word: {{CURRENTMONTH}}
9945 !! wikitext
9946 {{CURRENTMONTH}}
9947 !! html
9948 <p>01
9949 </p>
9950 !! end
9951
9952 !! test
9953 Magic Word: {{CURRENTMONTH1}}
9954 !! wikitext
9955 {{CURRENTMONTH1}}
9956 !! html
9957 <p>1
9958 </p>
9959 !! end
9960
9961 !! test
9962 Magic Word: {{CURRENTMONTHABBREV}}
9963 !! wikitext
9964 {{CURRENTMONTHABBREV}}
9965 !! html
9966 <p>Jan
9967 </p>
9968 !! end
9969
9970 !! test
9971 Magic Word: {{CURRENTMONTHNAME}}
9972 !! wikitext
9973 {{CURRENTMONTHNAME}}
9974 !! html
9975 <p>January
9976 </p>
9977 !! end
9978
9979 !! test
9980 Magic Word: {{CURRENTMONTHNAMEGEN}}
9981 !! wikitext
9982 {{CURRENTMONTHNAMEGEN}}
9983 !! html
9984 <p>January
9985 </p>
9986 !! end
9987
9988 !! test
9989 Magic Word: {{CURRENTTIME}}
9990 !! wikitext
9991 {{CURRENTTIME}}
9992 !! html
9993 <p>00:02
9994 </p>
9995 !! end
9996
9997 !! test
9998 Magic Word: {{CURRENTHOUR}}
9999 !! wikitext
10000 {{CURRENTHOUR}}
10001 !! html
10002 <p>00
10003 </p>
10004 !! end
10005
10006 !! test
10007 Magic Word: {{CURRENTWEEK}} (T6594)
10008 !! wikitext
10009 {{CURRENTWEEK}}
10010 !! html
10011 <p>1
10012 </p>
10013 !! end
10014
10015 !! test
10016 Magic Word: {{CURRENTYEAR}}
10017 !! wikitext
10018 {{CURRENTYEAR}}
10019 !! html
10020 <p>1970
10021 </p>
10022 !! end
10023
10024 !! test
10025 Magic Word: {{CURRENTTIMESTAMP}}
10026 !! wikitext
10027 {{CURRENTTIMESTAMP}}
10028 !! html
10029 <p>19700101000203
10030 </p>
10031 !! end
10032
10033 !! test
10034 Magic Words LOCAL (UTC)
10035 !! wikitext
10036 * {{LOCALMONTH}}
10037 * {{LOCALMONTH1}}
10038 * {{LOCALMONTHNAME}}
10039 * {{LOCALMONTHNAMEGEN}}
10040 * {{LOCALMONTHABBREV}}
10041 * {{LOCALDAY}}
10042 * {{LOCALDAY2}}
10043 * {{LOCALDAYNAME}}
10044 * {{LOCALYEAR}}
10045 * {{LOCALTIME}}
10046 * {{LOCALHOUR}}
10047 * {{LOCALWEEK}}
10048 * {{LOCALDOW}}
10049 * {{LOCALTIMESTAMP}}
10050 !! html
10051 <ul><li> 01</li>
10052 <li> 1</li>
10053 <li> January</li>
10054 <li> January</li>
10055 <li> Jan</li>
10056 <li> 1</li>
10057 <li> 01</li>
10058 <li> Thursday</li>
10059 <li> 1970</li>
10060 <li> 00:02</li>
10061 <li> 00</li>
10062 <li> 1</li>
10063 <li> 4</li>
10064 <li> 19700101000203</li></ul>
10065
10066 !! end
10067
10068 !! test
10069 Magic Word: {{FULLPAGENAME}}
10070 !! options
10071 title=[[User:Ævar Arnfjörð Bjarmason]]
10072 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10073 !! wikitext
10074 {{FULLPAGENAME}}
10075 !! html/*
10076 <p>User:Ævar Arnfjörð Bjarmason
10077 </p>
10078 !! end
10079
10080 !! test
10081 Magic Word: {{FULLPAGENAMEE}}
10082 !! options
10083 title=[[User:Ævar Arnfjörð Bjarmason]]
10084 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10085 !! wikitext
10086 {{FULLPAGENAMEE}}
10087 !! html/*
10088 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10089 </p>
10090 !! end
10091
10092 !! test
10093 Magic Word: {{TALKSPACE}}
10094 !! options
10095 title=[[User:Ævar Arnfjörð Bjarmason]]
10096 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10097 !! wikitext
10098 {{TALKSPACE}}
10099 !! html/*
10100 <p>User talk
10101 </p>
10102 !! end
10103
10104 !! test
10105 Magic Word: {{TALKSPACE}}, same namespace
10106 !! options
10107 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10108 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10109 !! wikitext
10110 {{TALKSPACE}}
10111 !! html/*
10112 <p>User talk
10113 </p>
10114 !! end
10115
10116 !! test
10117 Magic Word: {{TALKSPACE}}, main namespace
10118 !! options
10119 title=[[Parser Test]]
10120 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10121 !! wikitext
10122 {{TALKSPACE}}
10123 !! html/*
10124 <p>Talk
10125 </p>
10126 !! end
10127
10128 !! test
10129 Magic Word: {{TALKSPACEE}}
10130 !! options
10131 title=[[User:Ævar Arnfjörð Bjarmason]]
10132 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10133 !! wikitext
10134 {{TALKSPACEE}}
10135 !! html/*
10136 <p>User_talk
10137 </p>
10138 !! end
10139
10140 !! test
10141 Magic Word: {{SUBJECTSPACE}}
10142 !! options
10143 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10144 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10145 !! wikitext
10146 {{SUBJECTSPACE}}
10147 !! html/*
10148 <p>User
10149 </p>
10150 !! end
10151
10152 !! test
10153 Magic Word: {{SUBJECTSPACE}}, same namespace
10154 !! options
10155 title=[[User:Ævar Arnfjörð Bjarmason]]
10156 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10157 !! wikitext
10158 {{SUBJECTSPACE}}
10159 !! html/*
10160 <p>User
10161 </p>
10162 !! end
10163
10164 !! test
10165 Magic Word: {{SUBJECTSPACE}}, main namespace
10166 !! options
10167 title=[[Parser Test]]
10168 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10169 !! wikitext
10170 {{SUBJECTSPACE}}
10171 !! html/*
10172
10173 !! end
10174
10175 !! test
10176 Magic Word: {{SUBJECTSPACEE}}
10177 !! options
10178 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10179 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10180 !! wikitext
10181 {{SUBJECTSPACEE}}
10182 !! html/*
10183 <p>User
10184 </p>
10185 !! end
10186
10187 !! test
10188 Magic Word: {{NAMESPACE}}
10189 !! options
10190 title=[[User:Ævar Arnfjörð Bjarmason]]
10191 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10192 !! wikitext
10193 {{NAMESPACE}}
10194 !! html/*
10195 <p>User
10196 </p>
10197 !! end
10198
10199 !! test
10200 Magic Word: {{NAMESPACEE}}
10201 !! options
10202 title=[[User:Ævar Arnfjörð Bjarmason]]
10203 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10204 !! wikitext
10205 {{NAMESPACEE}}
10206 !! html/*
10207 <p>User
10208 </p>
10209 !! end
10210
10211 !! test
10212 Magic Word: {{NAMESPACENUMBER}}
10213 !! options
10214 title=[[User:Ævar Arnfjörð Bjarmason]]
10215 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10216 !! wikitext
10217 {{NAMESPACENUMBER}}
10218 !! html/*
10219 <p>2
10220 </p>
10221 !! end
10222
10223 !! test
10224 Magic Word: {{SUBPAGENAME}}
10225 !! options
10226 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10227 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10228 !! wikitext
10229 {{SUBPAGENAME}}
10230 !! html/*
10231 <p>sub ö
10232 </p>
10233 !! end
10234
10235 !! test
10236 Magic Word: {{SUBPAGENAMEE}}
10237 !! options
10238 title=[[Ævar Arnfjörð Bjarmason/sub ö]] subpage
10239 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10240 !! wikitext
10241 {{SUBPAGENAMEE}}
10242 !! html/*
10243 <p>sub_%C3%B6
10244 </p>
10245 !! end
10246
10247 !! test
10248 Magic Word: {{ROOTPAGENAME}}
10249 !! options
10250 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10251 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10252 !! wikitext
10253 {{ROOTPAGENAME}}
10254 !! html/*
10255 <p>Ævar Arnfjörð Bjarmason
10256 </p>
10257 !! end
10258
10259 !! test
10260 Magic Word: {{ROOTPAGENAMEE}}
10261 !! options
10262 title=[[Ævar Arnfjörð Bjarmason/sub/sub2]] subpage
10263 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10264 !! wikitext
10265 {{ROOTPAGENAMEE}}
10266 !! html/*
10267 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10268 </p>
10269 !! end
10270
10271 !! test
10272 Magic Word: {{BASEPAGENAME}}
10273 !! options
10274 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10275 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10276 !! wikitext
10277 {{BASEPAGENAME}}
10278 !! html/*
10279 <p>Ævar Arnfjörð Bjarmason
10280 </p>
10281 !! end
10282
10283 !! test
10284 Magic Word: {{BASEPAGENAMEE}}
10285 !! options
10286 title=[[Ævar Arnfjörð Bjarmason/sub]] subpage
10287 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10288 !! wikitext
10289 {{BASEPAGENAMEE}}
10290 !! html/*
10291 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10292 </p>
10293 !! end
10294
10295 !! test
10296 Magic Word: {{TALKPAGENAME}}
10297 !! options
10298 title=[[User:Ævar Arnfjörð Bjarmason]]
10299 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10300 !! wikitext
10301 {{TALKPAGENAME}}
10302 !! html/*
10303 <p>User talk:Ævar Arnfjörð Bjarmason
10304 </p>
10305 !! end
10306
10307 !! test
10308 Magic Word: {{TALKPAGENAMEE}}
10309 !! options
10310 title=[[User:Ævar Arnfjörð Bjarmason]]
10311 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10312 !! wikitext
10313 {{TALKPAGENAMEE}}
10314 !! html/*
10315 <p>User_talk:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10316 </p>
10317 !! end
10318
10319 !! test
10320 Magic Word: {{SUBJECTPAGENAME}}
10321 !! options
10322 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10323 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10324 !! wikitext
10325 {{SUBJECTPAGENAME}}
10326 !! html/*
10327 <p>User:Ævar Arnfjörð Bjarmason
10328 </p>
10329 !! end
10330
10331 !! test
10332 Magic Word: {{SUBJECTPAGENAMEE}}
10333 !! options
10334 title=[[User talk:Ævar Arnfjörð Bjarmason]]
10335 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10336 !! wikitext
10337 {{SUBJECTPAGENAMEE}}
10338 !! html/*
10339 <p>User:%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10340 </p>
10341 !! end
10342
10343 !! test
10344 Magic Word: {{NUMBEROFFILES}}
10345 !! options
10346 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10347 !! wikitext
10348 {{NUMBEROFFILES}}
10349 !! html/*
10350 <p>7
10351 </p>
10352 !! end
10353
10354 !! test
10355 Magic Word: {{PAGENAME}}
10356 !! options
10357 title=[[User:Ævar Arnfjörð Bjarmason]]
10358 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10359 !! wikitext
10360 {{PAGENAME}}
10361 !! html/*
10362 <p>Ævar Arnfjörð Bjarmason
10363 </p>
10364 !! end
10365
10366 !! test
10367 Magic Word: {{PAGENAME}} with metacharacters
10368 !! options
10369 title=[['foo & bar = baz']]
10370 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10371 !! wikitext
10372 ''{{PAGENAME}}''
10373 !! html/php
10374 <p><i>&#39;foo &#38; bar &#61; baz&#39;</i>
10375 </p>
10376 !! html+tidy
10377 <p><i>'foo &amp; bar = baz'</i></p>
10378 !! end
10379
10380 !! test
10381 Magic Word: {{PAGENAME}} with metacharacters (T28781)
10382 !! options
10383 title=[[*RFC 1234 http://example.com/]]
10384 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10385 !! wikitext
10386 {{PAGENAME}}
10387 !! html/php
10388 <p>&#42;RFC&#32;1234 http&#58;//example.com/
10389 </p>
10390 !! html+tidy
10391 <p>*RFC 1234 http://example.com/</p>
10392 !! end
10393
10394 !! test
10395 Magic Word: {{PAGENAMEE}}
10396 !! options
10397 title=[[User:Ævar Arnfjörð Bjarmason]]
10398 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10399 !! wikitext
10400 {{PAGENAMEE}}
10401 !! html/*
10402 <p>%C3%86var_Arnfj%C3%B6r%C3%B0_Bjarmason
10403 </p>
10404 !! end
10405
10406 !! test
10407 Magic Word: {{PAGENAMEE}} with metacharacters (T28781)
10408 !! options
10409 title=[[*RFC 1234 http://example.com/]]
10410 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10411 !! wikitext
10412 {{PAGENAMEE}}
10413 !! html/php
10414 <p>&#42;RFC_1234_http&#58;//example.com/
10415 </p>
10416 !! html+tidy
10417 <p>*RFC_1234_http://example.com/</p>
10418 !! end
10419
10420 !! test
10421 Magic Word: {{REVISIONID}}
10422 !! options
10423 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10424 showflags
10425 !! wikitext
10426 {{REVISIONID}}
10427 !! html/*
10428 <p>1337
10429 </p>
10430 flags=vary-revision-id
10431 !! end
10432
10433 !! test
10434 Magic Word: {{SCRIPTPATH}}
10435 !! options
10436 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10437 !! wikitext
10438 {{SCRIPTPATH}}
10439 !! html/*
10440
10441 !! end
10442
10443 !! test
10444 Magic Word: {{STYLEPATH}}
10445 !! options
10446 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10447 !! wikitext
10448 {{STYLEPATH}}
10449 !! html/*
10450 <p>/skins
10451 </p>
10452 !! end
10453
10454 !! test
10455 Magic Word: {{SERVER}}
10456 !! options
10457 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10458 !! wikitext
10459 {{SERVER}}
10460 !! html/*
10461 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10462 </p>
10463 !! end
10464
10465 !! test
10466 Magic Word: {{SERVERNAME}}
10467 !! options
10468 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10469 !! wikitext
10470 {{SERVERNAME}}
10471 !! html/*
10472 <p>example.org
10473 </p>
10474 !! end
10475
10476 !! test
10477 Magic Word: {{SITENAME}}
10478 !! options
10479 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10480 !! wikitext
10481 {{SITENAME}}
10482 !! html/*
10483 <p>MediaWiki
10484 </p>
10485 !! end
10486
10487 !! test
10488 Magic Word: {{PAGELANGUAGE}}
10489 !! options
10490 language=fr
10491 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10492 !! wikitext
10493 {{PAGELANGUAGE}}
10494 !! html/*
10495 <p>fr
10496 </p>
10497 !! end
10498
10499 !! test
10500 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10501 !! options
10502 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10503 !! wikitext
10504 {{PAGELANGUAGE}}
10505 !! html/*
10506 <p>en
10507 </p>
10508 !! end
10509
10510 !! test
10511 Case-sensitive magic words, when cased differently, should just be template transclusions
10512 !! wikitext
10513 {{CurrentMonth}}
10514 {{currentday}}
10515 {{cURreNTweEK}}
10516 {{currentHour}}
10517 !! html
10518 <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>
10519 <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>
10520 <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>
10521 <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>
10522 </p>
10523 !! end
10524
10525 !! test
10526 Case-insensitive magic words should still work with weird casing.
10527 !! wikitext
10528 {{sErVeRNaMe}}
10529 {{LCFirst:AOEU}}
10530 {{ucFIRST:aoeu}}
10531 {{SERver}}
10532 !! html
10533 <p>example.org
10534 aOEU
10535 Aoeu
10536 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10537 </p>
10538 !! end
10539
10540 # From plwiki:PLOS_ONE
10541 !! test
10542 Parsoid: Page property magic word with magic word contents
10543 !! wikitext
10544 {{DISPLAYTITLE:''{{PAGENAME}}''}}
10545 !! html/parsoid
10546 <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>"}]]}'/>
10547 !! end
10548
10549 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
10550 # But, this is a limitation of our representation and is documented in
10551 # TemplateHandler.js in processSpecialMagicWord
10552 !! test
10553 Parsoid: Template-generated DISPLAYTITLE
10554 !! wikitext
10555 {{{{echo|DISPLAYTITLE}}:Foo}}
10556 !! options
10557 showtitle
10558 !! config
10559 wgAllowDisplayTitle=true
10560 wgRestrictDisplayTitle=false
10561 !! html/php
10562 Foo
10563
10564 !! html/parsoid
10565 <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"}]]}'/>
10566 !! end
10567
10568 !! test
10569 Namespace 1 {{ns:1}}
10570 !! wikitext
10571 {{ns:1}}
10572 !! html
10573 <p>Talk
10574 </p>
10575 !! end
10576
10577 !! test
10578 Namespace 1 {{ns:01}}
10579 !! wikitext
10580 {{ns:01}}
10581 !! html
10582 <p>Talk
10583 </p>
10584 !! end
10585
10586 !! test
10587 Namespace 0 {{ns:0}} (T6783)
10588 !! wikitext
10589 {{ns:0}}
10590 !! html
10591
10592 !! end
10593
10594 !! test
10595 Namespace 0 {{ns:00}} (T6783)
10596 !! wikitext
10597 {{ns:00}}
10598 !! html
10599
10600 !! end
10601
10602 !! test
10603 Namespace -1 {{ns:-1}}
10604 !! wikitext
10605 {{ns:-1}}
10606 !! html
10607 <p>Special
10608 </p>
10609 !! end
10610
10611 !! test
10612 Namespace User {{ns:User}}
10613 !! wikitext
10614 {{ns:User}}
10615 !! html
10616 <p>User
10617 </p>
10618 !! end
10619
10620 !! test
10621 Namespace User talk {{ns:User_talk}}
10622 !! wikitext
10623 {{ns:User_talk}}
10624 !! html
10625 <p>User talk
10626 </p>
10627 !! end
10628
10629 !! test
10630 Namespace User talk {{ns:uSeR tAlK}}
10631 !! wikitext
10632 {{ns:uSeR tAlK}}
10633 !! html
10634 <p>User talk
10635 </p>
10636 !! end
10637
10638 !! test
10639 Namespace File {{ns:File}}
10640 !! wikitext
10641 {{ns:File}}
10642 !! html
10643 <p>File
10644 </p>
10645 !! end
10646
10647 !! test
10648 Namespace File {{ns:Image}}
10649 !! wikitext
10650 {{ns:Image}}
10651 !! html
10652 <p>File
10653 </p>
10654 !! end
10655
10656 !! test
10657 Namespace (lang=de) Benutzer {{ns:User}}
10658 !! options
10659 language=de
10660 !! wikitext
10661 {{ns:User}}
10662 !! html
10663 <p>Benutzer
10664 </p>
10665 !! end
10666
10667 !! test
10668 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
10669 !! options
10670 language=de
10671 !! wikitext
10672 {{ns:3}}
10673 !! html
10674 <p>Benutzer Diskussion
10675 </p>
10676 !! end
10677
10678 !! test
10679 Urlencode
10680 !! wikitext
10681 {{urlencode:hi world?!}}
10682 {{urlencode:hi world?!|WIKI}}
10683 {{urlencode:hi world?!|PATH}}
10684 {{urlencode:hi world?!|QUERY}}
10685 !! html/php
10686 <p>hi+world%3F%21
10687 hi_world%3F!
10688 hi%20world%3F%21
10689 hi+world%3F%21
10690 </p>
10691 !! end
10692
10693 !! test
10694 Magic Word: prioritize type info over data-parsoid
10695 !! options
10696 parsoid=html2wt
10697 !! html/parsoid
10698 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
10699 !! wikitext
10700 __FORCETOC__
10701 !! end
10702
10703 !! test
10704 Magic Word: serialize on separate line (parsoid)
10705 !! options
10706 parsoid=wt2wt,html2wt
10707 !! wikitext
10708 foo
10709 __NOTOC__
10710 bar
10711 !! html/parsoid
10712 foo<meta property="mw:PageProp/notoc"/>bar
10713 !! end
10714
10715 !! test
10716 Magic Word: rt non-english wikis
10717 !! options
10718 parsoid=wt2wt
10719 language=de
10720 !! wikitext
10721 __NOEDITSECTION__
10722 !! html/parsoid
10723 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
10724 !! end
10725
10726 !!test
10727 __proto__ is treated as normal wikitext (T105997)
10728 !!wikitext
10729 __proto__
10730 !!html
10731 <p>__proto__
10732 </p>
10733 !!end
10734
10735 ###
10736 ### Magic links
10737 ###
10738 !! test
10739 Magic links: internal link to RFC (T2479)
10740 !! wikitext
10741 [[RFC 123]]
10742 !! html/php
10743 <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>
10744 </p>
10745 !! html/parsoid
10746 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
10747 !! end
10748
10749 !! test
10750 Magic links: RFC (T2479)
10751 !! wikitext
10752 RFC 822
10753 !! html/php
10754 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
10755 </p>
10756 !! html/parsoid
10757 <p><a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a></p>
10758 !! end
10759
10760 !! test
10761 Magic links: RFC (T67278)
10762 !! wikitext
10763 This is RFC 822 but thisRFC 822 is not RFC 822linked.
10764 !! html/php
10765 <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.
10766 </p>
10767 !! html/parsoid
10768 <p>This is <a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
10769 !! end
10770
10771 !! test
10772 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
10773 !! wikitext
10774 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
10775 RFC
10776 822
10777 !! html/php
10778 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
10779 RFC
10780 822
10781 </p>
10782 !! html/parsoid
10783 <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>
10784 RFC
10785 822</p>
10786 !! end
10787
10788 !! test
10789 Magic links: ISBN (T3937)
10790 !! wikitext
10791 ISBN 0-306-40615-2
10792 !! html/php
10793 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
10794 </p>
10795 !! html/parsoid
10796 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
10797 !! end
10798
10799 !! test
10800 Magic links: ISBN (T67278)
10801 !! wikitext
10802 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
10803 !! html/php
10804 <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.
10805 </p>
10806 !! html/parsoid
10807 <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>
10808 !! end
10809
10810 !! test
10811 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
10812 !! wikitext
10813 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
10814 ISBN
10815 9780316098113
10816 ISBN 978
10817 0316098113
10818 !! html/php
10819 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
10820 ISBN
10821 9780316098113
10822 ISBN 978
10823 0316098113
10824 </p>
10825 !! html/parsoid
10826 <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>
10827 ISBN
10828 9780316098113
10829 ISBN 978
10830 0316098113</p>
10831 !! end
10832
10833 !! test
10834 Magic links: PMID incorrectly converts space to underscore
10835 !! wikitext
10836 PMID 1234
10837 !! html/php
10838 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
10839 </p>
10840 !! html/parsoid
10841 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a></p>
10842 !! end
10843
10844 !! test
10845 Magic links: PMID (T67278)
10846 !! wikitext
10847 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
10848 !! html/php
10849 <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.
10850 </p>
10851 !! html/parsoid
10852 <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>
10853 !! end
10854
10855 !! test
10856 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
10857 !! wikitext
10858 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
10859 PMID
10860 1234
10861 !! html/php
10862 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
10863 PMID
10864 1234
10865 </p>
10866 !! html/parsoid
10867 <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>
10868 PMID
10869 1234</p>
10870 !! end
10871
10872 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
10873 # since these are ExtLinkText, not MagicLinkText
10874 !! test
10875 Magic links: use appropriate serialization for "almost" magic links.
10876 !! wikitext
10877 X[[Special:BookSources/0978739256|foo]]
10878
10879 X[//tools.ietf.org/html/rfc1234 foo]
10880 !! html/php
10881 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
10882 </p><p>X<a rel="nofollow" class="external text" href="//tools.ietf.org/html/rfc1234">foo</a>
10883 </p>
10884 !! html/parsoid
10885 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
10886 <p>X<a rel="mw:ExtLink" href="//tools.ietf.org/html/rfc1234">foo</a></p>
10887 !! end
10888
10889 !! test
10890 Magic links: All disabled (T47942)
10891 !! options
10892 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
10893 !! wikitext
10894 ISBN 0-306-40615-2
10895 PMID 1234
10896 RFC 4321
10897 !! html/php
10898 <p>ISBN 0-306-40615-2
10899 PMID 1234
10900 RFC 4321
10901 </p>
10902 !! end
10903
10904 ###
10905 ### Templates
10906 ####
10907
10908 !! test
10909 Nonexistent template
10910 !! wikitext
10911 {{thistemplatedoesnotexist}}
10912 !! html
10913 <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>
10914 </p>
10915 !! end
10916
10917 !! test
10918 Template with invalid target containing tags
10919 !! wikitext
10920 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
10921 !! html
10922 <p>{{a<b>b</b>|foo|a=b|a = b}}
10923 </p>
10924 !! end
10925
10926 !! test
10927 Template with invalid target containing unclosed tag
10928 !! wikitext
10929 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
10930 !! html
10931 <p>{{a<b>|foo|a=b|a = b}}</b>
10932 </p>
10933 !! end
10934
10935 !! test
10936 Template with invalid target containing wikilink
10937 !! wikitext
10938 {{[[Main Page]]}}
10939 !! html/php
10940 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
10941 </p>
10942 !! html/parsoid
10943 <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>
10944 !! end
10945
10946 !! test
10947 Template with just whitespace in it, T70421
10948 !! wikitext
10949 {{echo|{{ }}}}
10950 !! html/parsoid
10951 <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>
10952 !! end
10953
10954 !! article
10955 Template:test
10956 !! text
10957 This is a test template
10958 !! endarticle
10959
10960 !! test
10961 Simple template
10962 !! wikitext
10963 {{test}}
10964 !! html
10965 <p>This is a test template
10966 </p>
10967 !! end
10968
10969 !! test
10970 Template with explicit namespace
10971 !! wikitext
10972 {{Template:test}}
10973 !! html
10974 <p>This is a test template
10975 </p>
10976 !! end
10977
10978
10979 !! article
10980 Template:paramtest
10981 !! text
10982 This is a test template with parameter {{{param}}}
10983 !! endarticle
10984
10985 !! test
10986 Template parameter
10987 !! wikitext
10988 {{paramtest|param=foo}}
10989 !! html
10990 <p>This is a test template with parameter foo
10991 </p>
10992 !! end
10993
10994 !! article
10995 Template:paramtestnum
10996 !! text
10997 [[{{{1}}}|{{{2}}}]]
10998 !! endarticle
10999
11000 !! test
11001 Template unnamed parameter
11002 !! wikitext
11003 {{paramtestnum|Main Page|the main page}}
11004 !! html
11005 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11006 </p>
11007 !! end
11008
11009 !! article
11010 Template:templatesimple
11011 !! text
11012 (test)
11013 !! endarticle
11014
11015 !! article
11016 Template:templateredirect
11017 !! text
11018 #redirect [[Template:templatesimple]]
11019 !! endarticle
11020
11021 !! article
11022 Template:templateasargtestnum
11023 !! text
11024 {{{{{1}}}}}
11025 !! endarticle
11026
11027 !! article
11028 Template:templateasargtest
11029 !! text
11030 {{template{{{templ}}}}}
11031 !! endarticle
11032
11033 !! article
11034 Template:templateasargtest2
11035 !! text
11036 {{{{{templ}}}}}
11037 !! endarticle
11038
11039 !! test
11040 Template with template name as unnamed argument
11041 !! wikitext
11042 {{templateasargtestnum|templatesimple}}
11043 !! html
11044 <p>(test)
11045 </p>
11046 !! end
11047
11048 !! test
11049 Template with template name as argument
11050 !! wikitext
11051 {{templateasargtest|templ=simple}}
11052 !! html
11053 <p>(test)
11054 </p>
11055 !! end
11056
11057 !! test
11058 Template with template name as argument (2)
11059 !! wikitext
11060 {{templateasargtest2|templ=templatesimple}}
11061 !! html
11062 <p>(test)
11063 </p>
11064 !! end
11065
11066 !! article
11067 Template:templateasargtestdefault
11068 !! text
11069 {{{{{templ|templatesimple}}}}}
11070 !! endarticle
11071
11072 !! article
11073 Template:templa
11074 !! text
11075 '''templ'''
11076 !! endarticle
11077
11078 !! test
11079 Template with default value
11080 !! wikitext
11081 {{templateasargtestdefault}}
11082 !! html
11083 <p>(test)
11084 </p>
11085 !! end
11086
11087 !! test
11088 Template with default value (value set)
11089 !! wikitext
11090 {{templateasargtestdefault|templ=templa}}
11091 !! html
11092 <p><b>templ</b>
11093 </p>
11094 !! end
11095
11096 !! test
11097 Template redirect
11098 !! wikitext
11099 {{templateredirect}}
11100 !! html/php
11101 <p>(test)
11102 </p>
11103 !! html/parsoid
11104 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11105 !! end
11106
11107 !! test
11108 Template with argument in separate line
11109 !! wikitext
11110 {{ templateasargtest |
11111 templ = simple }}
11112 !! html
11113 <p>(test)
11114 </p>
11115 !! end
11116
11117 !! test
11118 Template with complex template as argument
11119 !! wikitext
11120 {{paramtest|
11121 param ={{ templateasargtest |
11122 templ = simple }}}}
11123 !! html
11124 <p>This is a test template with parameter (test)
11125 </p>
11126 !! end
11127
11128 !! test
11129 Templates with templated name
11130 !! wikitext
11131 {{{{echo|echo}}|foo}}
11132 {{{{echo|inner list}} }}
11133 !! html
11134 <p>foo
11135 </p>
11136 <ul><li> item 1</li></ul>
11137
11138 !! html/parsoid
11139 <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>
11140 <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>
11141 !! end
11142
11143 # Parsoid markup is deliberate "broken". This is an edge case.
11144 # See long comment in TemplateHandler.js:convertAttribsToString.
11145 !! test
11146 Templates with invalid templated targets
11147 !! wikitext
11148 {{echo
11149 {{echo|foo}}
11150 }}
11151 !! html/php
11152 <p>{{echo
11153 foo
11154 }}
11155 </p>
11156 !! html/parsoid
11157 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11158 foo }}</p>
11159 !! end
11160
11161 !! test
11162 Template with thumb image (with link in description)
11163 !! wikitext
11164 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11165 !! html/php
11166 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>
11167
11168 !! html+tidy
11169 <p>This is a test template with parameter</p>
11170 <div class="thumb tright">
11171 <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>
11172 <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>
11173 </div>
11174 </div>
11175 !! html/parsoid
11176 <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>
11177 !! end
11178
11179 !! article
11180 Template:complextemplate
11181 !! text
11182 {{{1}}} {{paramtest|
11183 param ={{{param}}}}}
11184 !! endarticle
11185
11186 !! test
11187 Template with complex arguments
11188 !! wikitext
11189 {{complextemplate|
11190 param ={{ templateasargtest |
11191 templ = simple }}|[[Template:complextemplate|link]]}}
11192 !! html
11193 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11194 </p>
11195 !! end
11196
11197 !! test
11198 T2553: link with two variables in a piped link
11199 !! wikitext
11200 {|
11201 |[[{{{1}}}|{{{2}}}]]
11202 |}
11203 !! html/php
11204 <table>
11205 <tr>
11206 <td>[[{{{1}}}|{{{2}}}]]
11207 </td></tr></table>
11208
11209 !! html/parsoid
11210 <table>
11211 <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>
11212 </tbody></table>
11213 !! end
11214
11215 # See: T2553
11216 !! test
11217 Abort table cell attribute parsing on wikilink
11218 !! wikitext
11219 {|
11220 | testing [[one|two]] | three || four
11221 | testing one two | three || four
11222 | testing="[[one|two]]" | three || four
11223 |}
11224 !! html/php
11225 <table>
11226 <tr>
11227 <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>
11228 <td> four
11229 </td>
11230 <td> three </td>
11231 <td> four
11232 </td>
11233 <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>
11234 <td> four
11235 </td></tr></table>
11236
11237 !! html/parsoid
11238 <table>
11239 <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>
11240 <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>
11241 <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>
11242 </tbody></table>
11243 !! end
11244
11245 !! test
11246 Don't abort table cell attribute parsing if wikilink is found in template arg
11247 !! wikitext
11248 {|
11249 | Test {{#tag:ref|One two "[[three]]" four}}
11250 |}
11251 !! html/parsoid
11252 <table>
11253 <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>
11254 </tbody></table>
11255 !! end
11256
11257 !! test
11258 Magic variable as template parameter
11259 !! wikitext
11260 {{paramtest|param={{SITENAME}}}}
11261 !! html
11262 <p>This is a test template with parameter MediaWiki
11263 </p>
11264 !! end
11265
11266 !! article
11267 Template:linktest
11268 !! text
11269 [[{{{param}}}|link]]
11270 !! endarticle
11271
11272 !! test
11273 Template parameter as link source
11274 !! wikitext
11275 {{linktest|param=Main Page}}
11276 !! html
11277 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11278 </p>
11279 !! end
11280
11281 !!article
11282 Template:paramtest2
11283 !! text
11284 including another template, {{paramtest|param={{{arg}}}}}
11285 !! endarticle
11286
11287 !! test
11288 Template passing argument to another template
11289 !! wikitext
11290 {{paramtest2|arg='hmm'}}
11291 !! html
11292 <p>including another template, This is a test template with parameter 'hmm'
11293 </p>
11294 !! end
11295
11296 !! article
11297 Template:Linktest2
11298 !! text
11299 Main Page
11300 !! endarticle
11301
11302 !! test
11303 Template as link source
11304 !! wikitext
11305 [[{{linktest2}}]]
11306
11307 [[{{linktest2}}|Main Page]]
11308
11309 [[{{linktest2}}]]Page
11310 !! html
11311 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11312 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11313 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11314 </p>
11315 !! end
11316
11317
11318 !! article
11319 Template:loop1
11320 !! text
11321 {{loop2}}
11322 !! endarticle
11323
11324 !! article
11325 Template:loop2
11326 !! text
11327 {{loop1}}
11328 !! endarticle
11329
11330 !! test
11331 Template infinite loop
11332 !! wikitext
11333 {{loop1}}
11334 !! html
11335 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11336 </p>
11337 !! end
11338
11339 !! test
11340 Template from main namespace
11341 !! wikitext
11342 {{:Main Page}}
11343 !! html
11344 <p>blah blah
11345 </p>
11346 !! end
11347
11348 !! article
11349 Template:table
11350 !! text
11351 {|
11352 | 1 || 2
11353 |-
11354 | 3 || 4
11355 |}
11356 !! endarticle
11357
11358 !! test
11359 T2529: Template with table, not included at beginning of line
11360 !! wikitext
11361 foo {{table}}
11362 !! html
11363 <p>foo
11364 </p>
11365 <table>
11366 <tr>
11367 <td> 1 </td>
11368 <td> 2
11369 </td></tr>
11370 <tr>
11371 <td> 3 </td>
11372 <td> 4
11373 </td></tr></table>
11374
11375 !! end
11376
11377 !! test
11378 T2523: Template shouldn't eat newline (or add an extra one before table)
11379 !! wikitext
11380 foo
11381 {{table}}
11382 !! html
11383 <p>foo
11384 </p>
11385 <table>
11386 <tr>
11387 <td> 1 </td>
11388 <td> 2
11389 </td></tr>
11390 <tr>
11391 <td> 3 </td>
11392 <td> 4
11393 </td></tr></table>
11394
11395 !! end
11396
11397 !! test
11398 T2041: Template parameters shown as broken links
11399 !! wikitext
11400 {{{parameter}}}
11401 !! html
11402 <p>{{{parameter}}}
11403 </p>
11404 !! end
11405
11406 !! test
11407 Template with targets containing wikilinks
11408 !! options
11409 parsoid=wt2html
11410 !! wikitext
11411 {{[[foo]]}}
11412
11413 {{[[{{echo|foo}}]]}}
11414
11415 {{{{echo|[[foo}}]]}}
11416 !! html/php
11417 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11418 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11419 </p><p>{{[[foo}}]]
11420 </p>
11421 !! html/parsoid
11422 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11423 <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>
11424 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11425 !! end
11426
11427 !! article
11428 Template:''
11429 !! text
11430 bar
11431 !! endarticle
11432
11433 !! test
11434 Templates: Double quotes as template target
11435 !! wikitext
11436 foo {{''}} baz
11437 !! html/php
11438 <p>foo bar baz
11439 </p>
11440 !! html/parsoid
11441 <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
11442 </p>
11443 !! end
11444
11445 ## This test is about making sure Parsoid's data-mw is well formed in the
11446 ## face of multiple templates with intersecting and overlapping ranges. The
11447 ## wikitext itself is wretched.
11448 !! test
11449 Templates with intersecting and overlapping ranges
11450 !! wikitext
11451 {|{{echo|
11452 <p>ha</p>}}
11453 {|{{echo|
11454 <p>ho</p>}}
11455 {{echo|{{!}}hi}}
11456 |}
11457 !! html/php+tidy
11458 <p>ha</p>
11459 <p>ho</p>
11460 <table>
11461 <tr>
11462 <td></td>
11463 </tr>
11464 <tr>
11465 <td>hi</td>
11466 </tr>
11467 </table>
11468 <table>
11469 <tr>
11470 <td></td>
11471 </tr>
11472 </table>
11473 !! html/parsoid
11474 <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":""}]]}'>
11475
11476 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11477
11478 <tbody><tr><td>hi</td></tr>
11479 </tbody></table>
11480 !! end
11481
11482 !! article
11483 Template:MSGNW test
11484 !! text
11485 ''None'' of '''this''' should be
11486 * interpreted
11487 but rather passed unmodified
11488 {{test}}
11489 <gallery>
11490 File:Foobar.jpg
11491 </gallery>
11492 <!-- comment -->
11493 !! endarticle
11494
11495 # hmm, fix this or just deprecate msgnw and document its behavior?
11496 !! test
11497 msgnw keyword
11498 !! wikitext
11499 {{msgnw:MSGNW test}}
11500 !! html/php
11501 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11502 &#42; interpreted
11503 &#32;but rather passed unmodified
11504 &#123;&#123;test&#125;&#125;
11505 &#60;gallery&#62;
11506 File:Foobar.jpg
11507 &#60;/gallery&#62;
11508 &#60;!-- comment --&#62;
11509 </p>
11510 !! end
11511
11512 !! test
11513 int keyword
11514 !! wikitext
11515 {{int:youhavenewmessages|lots of money|not!}}
11516 !! html
11517 <p>You have lots of money (not!).
11518 </p>
11519 !! end
11520
11521 !! test
11522 int keyword - non-existing message
11523 !! wikitext
11524 {{int:var}}
11525 !! html
11526 <p>⧼var⧽
11527 </p>
11528 !! end
11529
11530 !! article
11531 Template:Includes
11532 !! text
11533 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11534 !! endarticle
11535
11536 !! test
11537 <includeonly> and <noinclude> being included
11538 !! wikitext
11539 {{Includes}}
11540 !! html
11541 <p>Foobar
11542 </p>
11543 !! end
11544
11545 !! article
11546 Template:Includes2
11547 !! text
11548 <onlyinclude>Foo</onlyinclude>bar
11549 !! endarticle
11550
11551 !! test
11552 <onlyinclude> being included
11553 !! wikitext
11554 {{Includes2}}
11555 !! html
11556 <p>Foo
11557 </p>
11558 !! end
11559
11560
11561 !! article
11562 Template:Includes3
11563 !! text
11564 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
11565 !! endarticle
11566
11567 !! test
11568 <onlyinclude> and <includeonly> being included
11569 !! wikitext
11570 {{Includes3}}
11571 !! html
11572 <p>Foo
11573 </p>
11574 !! end
11575
11576 !! test
11577 <includeonly> and <noinclude> on a page
11578 !! wikitext
11579 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11580 !! html
11581 <p>Foozar
11582 </p>
11583 !! end
11584
11585 !! test
11586 Un-closed <noinclude>
11587 !! wikitext
11588 <noinclude>
11589 !! html
11590 !! end
11591
11592 !! test
11593 <onlyinclude> on a page
11594 !! wikitext
11595 <onlyinclude>Foo</onlyinclude>bar
11596 !! html
11597 <p>Foobar
11598 </p>
11599 !! end
11600
11601 !! test
11602 Un-closed <onlyinclude>
11603 !! wikitext
11604 <onlyinclude>
11605 !! html
11606 !! end
11607
11608 !!test
11609 Self-closed noinclude, includeonly, onlyinclude tags
11610 !! wikitext
11611 <noinclude />
11612 <includeonly />
11613 <onlyinclude />
11614 !! html
11615 <p><br />
11616 </p>
11617 !!end
11618
11619 !!test
11620 Unbalanced includeonly and noinclude tags
11621 !! wikitext
11622 {|
11623 |a</noinclude>
11624 |b</noinclude></noinclude>
11625 |c</noinclude></includeonly>
11626 |d</includeonly></includeonly>
11627 |}
11628 !! html
11629 <table>
11630 <tr>
11631 <td>a
11632 </td>
11633 <td>b
11634 </td>
11635 <td>c&lt;/includeonly&gt;
11636 </td>
11637 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
11638 </td></tr></table>
11639
11640 !!end
11641
11642 !! article
11643 Template:Includeonly section
11644 !! text
11645 <includeonly>
11646 ==Includeonly section==
11647 </includeonly>
11648 ==Section T-1==
11649 !!endarticle
11650
11651 !! test
11652 T8563: Edit link generation for section shown by <includeonly>
11653 !! wikitext
11654 {{includeonly section}}
11655 !! html
11656 <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>
11657 <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>
11658
11659 !! end
11660
11661 # Uses same input as the contents of [[Template:Includeonly section]]
11662 !! test
11663 T8563: Section extraction for section shown by <includeonly>
11664 !! options
11665 section=T-2
11666 !! wikitext
11667 <includeonly>
11668 ==Includeonly section==
11669 </includeonly>
11670 ==Section T-2==
11671 !! html
11672 ==Section T-2==
11673 !! end
11674
11675 !! test
11676 T8563: Edit link generation for section suppressed by <includeonly>
11677 !! wikitext
11678 <includeonly>
11679 ==Includeonly section==
11680 </includeonly>
11681 ==Section 1==
11682 !! html
11683 <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>
11684
11685 !! end
11686
11687 !! test
11688 T8563: Section extraction for section suppressed by <includeonly>
11689 !! options
11690 section=1
11691 !! wikitext
11692 <includeonly>
11693 ==Includeonly section==
11694 </includeonly>
11695 ==Section 1==
11696 !! html
11697 ==Section 1==
11698 !! end
11699
11700 !! test
11701 Un-closed <includeonly>
11702 !! wikitext
11703 <includeonly>
11704 !! html/php
11705 !! html/parsoid
11706 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}'/>
11707 !! end
11708
11709 ## We used to, but no longer wt2wt this test since the default serializer
11710 ## will normalize the include directives to serialize on their own line.
11711 ## Selser will take care of preserving formatting in scenarios where they
11712 ## intermingled with other wikitext.
11713 !! test
11714 Includes and comments at SOL
11715 !! options
11716 parsoid=wt2html,html2html
11717 !! wikitext
11718 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->== hu ==
11719
11720 <noinclude>
11721 some
11722 </noinclude>* stuff
11723 * here
11724
11725 <includeonly>can have stuff</includeonly>=== here ===
11726
11727 !! html/php
11728 <h2><span class="mw-headline" id="hu">hu</span></h2>
11729 <p>some
11730 </p>
11731 <ul><li> stuff</li>
11732 <li> here</li></ul>
11733 <h3><span class="mw-headline" id="here">here</span></h3>
11734
11735 !! html/parsoid
11736 <!-- 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>
11737
11738 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
11739 <p>some</p>
11740 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li> stuff</li>
11741 <li> here</li></ul>
11742
11743 <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>
11744
11745 !! end
11746
11747 # TODO: test with DOM fragment reuse!
11748 !! test
11749 Parsoid: DOM fragment reuse
11750 !! options
11751 parsoid=wt2wt,wt2html
11752 !! wikitext
11753 a{{echo|b<table></table>c}}d
11754
11755 a{{echo|b
11756 <table></table>
11757 c}}d
11758
11759 {{echo|a
11760
11761 <table></table>
11762
11763 b}}
11764 !! html
11765 <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>
11766
11767 <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">
11768 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
11769 </span><p about="#mwt2">cd</p>
11770
11771 <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">
11772
11773 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
11774
11775 </span><p about="#mwt3">b</p>
11776 !! end
11777
11778 !! test
11779 Parsoid: Merge double tds (T52603)
11780 !! options
11781 parsoid
11782 !! wikitext
11783 {|
11784 |{{echo|{{!}} foo}}
11785 |}
11786 !! html
11787 <table><tbody>
11788 <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>
11789 </tbody></table>
11790 !! end
11791
11792 !! test
11793 Parsoid: Merge double tds in nested transclusion content (T52603)
11794 !! options
11795 parsoid
11796 !! wikitext
11797 {{echo|<div>}}
11798 {|
11799 |{{echo|{{!}} foo}}
11800 |}
11801 {{echo|</div>}}
11802 !! html
11803 <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}}]}'>
11804 <table><tbody>
11805 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
11806 </tbody></table>
11807 </div>
11808 !! end
11809
11810 ###
11811 ### <includeonly> and <noinclude> in attributes
11812 ###
11813 !!test
11814 0. includeonly around the entire attribute
11815 !! wikitext
11816 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
11817 !! html
11818 <p><span id="v2">bar</span>
11819 </p>
11820 !!end
11821
11822 !!test
11823 1. includeonly in html attr key
11824 !! wikitext
11825 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
11826 !! html
11827 <p><span id="foo">bar</span>
11828 </p>
11829 !!end
11830
11831 !!test
11832 2. includeonly in html attr value
11833 !! wikitext
11834 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
11835 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
11836 !! html
11837 <p><span id="v1">bar</span>
11838 <span id="v1">bar</span>
11839 </p>
11840 !!end
11841
11842 !!test
11843 3. includeonly in part of an attr value
11844 !! wikitext
11845 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
11846 !! html
11847 <p><span style="color:red;">bar</span>
11848 </p>
11849 !!end
11850
11851 !!test
11852 4. includeonly in table attributes
11853 !! wikitext
11854 {|
11855 |- <noinclude>
11856 |-
11857 |a
11858 </noinclude>
11859 |- <includeonly>
11860 |-
11861 |b
11862 </includeonly>
11863 |}
11864 !! html
11865 <table>
11866
11867
11868 <tr>
11869 <td>a
11870 </td></tr>
11871 </table>
11872
11873 !!end
11874
11875 ###
11876 ### Preprocessor precedence tests
11877 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
11878 ###
11879 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
11880 !! test
11881 Preprocessor precedence 1: link is rightmost opening
11882 !! wikitext
11883 {{[[Foo|bar}}]]
11884
11885 But close-brace is not a valid character in a link title:
11886 {{[[Foo}}|bar]]
11887
11888 However, we can still tell this was handled as a link in the preprocessor:
11889 {{echo|[[Foo}}|bar]]|bat}}
11890 !! html
11891 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
11892 </p><p>But close-brace is not a valid character in a link title:
11893 {{[[Foo}}|bar]]
11894 </p><p>However, we can still tell this was handled as a link in the preprocessor:
11895 [[Foo}}|bar]]
11896 </p>
11897 !! end
11898
11899 !! test
11900 Preprocessor precedence 2: template is rightmost opening
11901 !! options
11902 language=zh
11903 !! wikitext
11904 -{{echo|foo}-}}-
11905 !! html
11906 <p>-foo}--
11907 </p>
11908 !! end
11909
11910 !! test
11911 Preprocessor precedence 3: language converter is rightmost opening
11912 !! options
11913 language=zh
11914 !! wikitext
11915 {{echo|hi}}
11916
11917 {{-{R|echo|hi}}}-
11918
11919 [[-{R|raw]]}-
11920 !! html
11921 <p>hi
11922 </p><p>{{echo|hi}}
11923 </p><p>[[raw]]
11924 </p>
11925 !! end
11926
11927 !! test
11928 Preprocessor precedence 4: left-most angle bracket
11929 !! options
11930 language=zh
11931 !! wikitext
11932 <!--{raw}-->
11933 !! html
11934 !! end
11935
11936 !! article
11937 Template:Precedence5
11938 !! text
11939 {{{{{1}}}}}
11940 !! endarticle
11941
11942 !! test
11943 Preprocessor precedence 5: tplarg takes precedence over template
11944 !! wikitext
11945 {{Precedence5|Bullet}}
11946 !! html
11947 <ul><li> Bar</li></ul>
11948
11949 !! end
11950
11951 !! test
11952 Preprocessor precedence 6: broken link is rightmost opening
11953 !! wikitext
11954 {{echo|[[Foo}}
11955
11956 {{echo|[[Foo|bar|bat=baz}}
11957 !! html
11958 <p>{{echo|[[Foo}}
11959 </p><p>{{echo|[[Foo|bar|bat=baz}}
11960 </p>
11961 !! end
11962
11963 # This next test exposes a difference between PHP and Parsoid:
11964 # Given [[Foo|{{echo|Bar]]x}}y]]z:
11965 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
11966 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
11967 # outer `[[Foo` extends until the `y]]`
11968 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
11969 # intermediate result (after template expansion), and link processing
11970 # happens on this intermediate result, which moves the wikilink
11971 # boundary leftward to `[[Foo|Bar]]`
11972 # 2b) Parsoid works in a single step, so it's going to keep the
11973 # wikilink as extending to the `y]]`
11974 # 3a) Then PHP does linktrail processing which slurps up the trailing
11975 # `xy` inside the link.
11976 # 3b) Parsoid will do linktrail processing to slurp up the trailing
11977 # `z` inside the link.
11978 # This is "correct" behavior. Parsoid's basic worldview is that the
11979 # `]]` inside the template shouldn't be allowed to leak out to affect
11980 # the surrounding wikilink. PHP may match Parsoid (in the future)
11981 # if you use {{#balance}} (T114445).
11982
11983 !! test
11984 Preprocessor precedence 7: broken template is rightmost opening
11985 !! wikitext
11986 [[Foo|{{echo|Bar]]
11987
11988 [[Foo|{{echo|Bar]]-x}}-y]]-z
11989
11990 Careful: linktrails can move the end of the wikilink:
11991 [[Foo|{{echo|y']]a}}l]]l
11992 !! html
11993 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
11994 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
11995 </p><p>Careful: linktrails can move the end of the wikilink:
11996 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
11997 </p>
11998 !! end
11999
12000 !! test
12001 Preprocessor precedence 8: broken language converter is rightmost opening
12002 !! options
12003 language=zh
12004 !! wikitext
12005 [[Foo-{R|raw]]
12006 !! html
12007 <p>[[Foo-{R|raw]]
12008 </p>
12009 !! end
12010
12011 !! article
12012 Template:Preprocessor_precedence_9
12013 !! text
12014 ;4: {{{{1}}}}
12015 ;5: {{{{{2}}}}}
12016 ;6: {{{{{{3}}}}}}
12017 ;7: {{{{{{{4}}}}}}}
12018 !! endarticle
12019
12020 !! test
12021 Preprocessor precedence 9: groups of braces
12022 !! wikitext
12023 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12024 !! html
12025 <dl><dt>4</dt>
12026 <dd> {Four}</dd>
12027 <dt>5</dt>
12028 <dd> </dd></dl>
12029 <ul><li> Bar</li></ul>
12030 <dl><dt>6</dt>
12031 <dd> Four</dd>
12032 <dt>7</dt>
12033 <dd> {Bullet}</dd></dl>
12034
12035 !! end
12036
12037 !! article
12038 Template:Preprocessor_precedence_10
12039 !! text
12040 ;1: -{R|raw}-
12041 ;2: -{{Bullet}}-
12042 ;3: -{{{1}}}-
12043 ;4: -{{{{2}}}}-
12044 ;5: -{{{{{3}}}}}-
12045 ;6: -{{{{{{4}}}}}}-
12046 ;7: -{{{{{{{5}}}}}}}-
12047 !! endarticle
12048
12049 !! test
12050 Preprocessor precedence 10: groups of braces with leading dash
12051 !! options
12052 language=zh
12053 !! wikitext
12054 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12055 !! html
12056 <dl><dt>1</dt>
12057 <dd> raw</dd>
12058 <dt>2</dt>
12059 <dd> -</dd></dl>
12060 <ul><li> Bar-</li></ul>
12061 <dl><dt>3</dt>
12062 <dd> -Three-</dd>
12063 <dt>4</dt>
12064 <dd> raw2</dd>
12065 <dt>5</dt>
12066 <dd> -</dd></dl>
12067 <ul><li> Bar-</li></ul>
12068 <dl><dt>6</dt>
12069 <dd> -Three-</dd>
12070 <dt>7</dt>
12071 <dd> raw2</dd></dl>
12072
12073 !! end
12074
12075 !! test
12076 Preprocessor precedence 11: found during visual diff testing
12077 !! wikitext
12078 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12079
12080 {{echo|-{{echo|-{{echo|x}}}}}}
12081
12082 {{echo|-{{echo|x}}}}
12083 !! html
12084 <p><span>-<span>-x</span></span>
12085 </p><p>--x
12086 </p><p>-x
12087 </p>
12088 !! end
12089
12090 !! test
12091 Preprocessor precedence 12: broken language converter closed by brace.
12092 !! wikitext
12093 This form breaks the template, which is unfortunate:
12094 * {{echo|foo-{bar}bat}}
12095
12096 But if the broken language converter markup is inside an extension
12097 tag, nothing bad happens:
12098 * <nowiki>foo-{bar}bat</nowiki>
12099 * {{echo|<nowiki>foo-{bar}bat</nowiki>}}
12100 * <pre>foo-{bar}bat</pre>
12101 * {{echo|<pre>foo-{bar}bat</pre>}}
12102
12103 <tag>foo-{bar}bat</tag>
12104 {{echo|<tag>foo-{bar}bat</tag>}}
12105
12106 !! html+tidy
12107 <p>This form breaks the template, which is unfortunate:</p>
12108 <ul>
12109 <li>{{echo|foo-{bar}bat}}</li>
12110 </ul>
12111 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12112 <ul>
12113 <li>foo-{bar}bat</li>
12114 <li>foo-{bar}bat</li>
12115 <li>
12116 <pre>
12117 foo-{bar}bat
12118 </pre></li>
12119 <li>
12120 <pre>
12121 foo-{bar}bat
12122 </pre></li>
12123 </ul>
12124 <pre>
12125 'foo-{bar}bat'
12126 array (
12127 )
12128 </pre>
12129 <pre>
12130 'foo-{bar}bat'
12131 array (
12132 )
12133 </pre>
12134 !! end
12135
12136 !! test
12137 Preprocessor precedence, 13: broken language converter in external link
12138 !! wikitext
12139 * [http://example.com/-{foo Example in URL]
12140 * [http://example.com Example in -{link} description]
12141 * {{echo|[http://example.com/-{foo Breaks template, however]}}
12142 !! html+tidy
12143 <ul>
12144 <li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12145 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12146 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12147 </ul>
12148 !! end
12149
12150 !! test
12151 Preprocessor precedence, 14: broken language converter in comment
12152 !! wikitext
12153 * <!--{{foo}}--> ...should be ok
12154 * <!---{{foo}}--> ...extra dashes
12155 * {{echo|foo<!-- -{bar} -->bat}} ...should be ok
12156 !! html+tidy
12157 <ul>
12158 <li>...should be ok</li>
12159 <li>...extra dashes</li>
12160 <li>foobat ...should be ok</li>
12161 </ul>
12162 !! end
12163
12164 !! test
12165 Preprocessor precedence, 15: broken brace markup in headings
12166 !! wikitext
12167 __NOTOC__ __NOEDITSECTION__
12168 ===1 foo[bar 1===
12169 1
12170 ===2 foo[[bar 2===
12171 2
12172 ===3 foo{bar 3===
12173 3
12174 ===4 foo{{bar 4===
12175 4
12176 ===5 foo{{{bar 5===
12177 5
12178 ===6 foo-{bar 6===
12179 6
12180 !! html+tidy
12181 <h3><span class="mw-headline" id="1_foo.5Bbar_1">1 foo[bar 1</span></h3>
12182 <p>1</p>
12183 <h3><span class="mw-headline" id="2_foo.5B.5Bbar_2">2 foo[[bar 2</span></h3>
12184 <p>2</p>
12185 <h3><span class="mw-headline" id="3_foo.7Bbar_3">3 foo{bar 3</span></h3>
12186 <p>3</p>
12187 <h3><span class="mw-headline" id="4_foo.7B.7Bbar_4">4 foo{{bar 4</span></h3>
12188 <p>4</p>
12189 <h3><span class="mw-headline" id="5_foo.7B.7B.7Bbar_5">5 foo{{{bar 5</span></h3>
12190 <p>5</p>
12191 <h3><span class="mw-headline" id="6_foo-.7Bbar_6">6 foo-{bar 6</span></h3>
12192 <p>6</p>
12193 !! end
12194
12195 ###
12196 ### Token Stream Patcher tests
12197 ###
12198 ### These tests won't always pass wt2wt and other modes because
12199 ### on serialization, the table will be output on a new line.
12200 ### For now, we are blacklisting them, and using this to test selser.
12201 ###
12202
12203 !!test
12204 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12205 !!options
12206 parsoid=wt2html,wt2wt
12207 !!wikitext
12208 {{echo|}}{| width = '100%'
12209 |foo
12210 |}
12211 !!html/parsoid
12212 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12213 <tbody><tr><td>foo</td></tr>
12214 </tbody></table>
12215 !!end
12216
12217 ## We used to, but no longer wt2wt this test since the default serializer
12218 ## will normalize the include directives to serialize on their own line.
12219 ## Selser will take care of preserving formatting in scenarios where they
12220 ## intermingled with other wikitext.
12221 !!test
12222 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12223 !!options
12224 parsoid=wt2html
12225 !!wikitext
12226 <includeonly>a</includeonly>{| {{{b}}}
12227 |c
12228 |}
12229 !!html/parsoid
12230 <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":""}]]}'>
12231 <tbody><tr><td>c</td></tr>
12232 </tbody></table>
12233 !!end
12234
12235 !! test
12236 Table wikitext syntax outside wiki-tables
12237 !! wikitext
12238 a
12239 |+ not a caption
12240 ! not a table heading
12241 |- not a table row
12242 | not a table cell
12243 | class="foo bar" | baz
12244 b
12245 |}
12246 |-
12247 c
12248 !! html
12249 <p>a
12250 |+ not a caption
12251 ! not a table heading
12252 |- not a table row
12253 | not a table cell
12254 | class="foo bar" | baz
12255 b
12256 |}
12257 |-
12258 c
12259 </p>
12260 !! end
12261
12262 ###
12263 ### Testing parsing of templates where a template arg
12264 ### has the same name as the template itself.
12265 ###
12266
12267 !! article
12268 Template:quote
12269 !! text
12270 {{{quote|{{{1}}}}}}
12271 !! endarticle
12272
12273 !!test
12274 Templates: Template Name/Arg clash: 1. Use of positional param
12275 !! wikitext
12276 {{quote|foo}}
12277 !! html
12278 <p>foo
12279 </p>
12280 !!end
12281
12282 !!test
12283 Templates: Template Name/Arg clash: 2. Use of named param
12284 !! wikitext
12285 {{quote|quote=foo}}
12286 !! html
12287 <p>foo
12288 </p>
12289 !!end
12290
12291 !!test
12292 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12293 !! wikitext
12294 {{quote|quote}}
12295 !! html
12296 <p>quote
12297 </p>
12298 !!end
12299
12300 ###
12301 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12302 ###
12303
12304 !!test
12305 Templates: 1. Simple use
12306 !! wikitext
12307 {{echo|Foo}}
12308 !! html
12309 <p>Foo
12310 </p>
12311 !!end
12312
12313 !!test
12314 Templates: 2. Inside a block tag
12315 !! wikitext
12316 <div>{{echo|Foo}}</div>
12317 <blockquote>{{echo|Foo}}</blockquote>
12318 !! html
12319 <div>Foo</div>
12320 <blockquote>Foo</blockquote>
12321
12322 !! html+tidy
12323 <div>Foo</div>
12324 <blockquote>
12325 <p>Foo</p>
12326 </blockquote>
12327 !!end
12328
12329 !!test
12330 Templates: P-wrapping: 1a. Templates on consecutive lines
12331 !! wikitext
12332 {{echo|Foo}}
12333 {{echo|bar}}
12334 !! html
12335 <p>Foo
12336 bar
12337 </p>
12338 !!end
12339
12340 !!test
12341 Templates: P-wrapping: 1b. Templates on consecutive lines
12342 !! wikitext
12343 Foo
12344
12345 {{echo|bar}}
12346 {{echo|baz}}
12347 !! html
12348 <p>Foo
12349 </p><p>bar
12350 baz
12351 </p>
12352 !!end
12353
12354 !!test
12355 Templates: P-wrapping: 1c. Templates on consecutive lines
12356 !! wikitext
12357 {{echo|Foo}}
12358 {{echo|bar}} <div>baz</div>
12359 !! html
12360 <p>Foo
12361 </p>
12362 bar <div>baz</div>
12363
12364 !! html+tidy
12365 <p>Foo</p>
12366 <p>bar</p>
12367 <div>baz</div>
12368 !! end
12369
12370 !!test
12371 Templates: P-wrapping: 1d. Template preceded by comment-only line
12372 !!options
12373 parsoid
12374 !! wikitext
12375 <!-- foo -->
12376 {{echo|Bar}}
12377 !! html
12378 <!-- foo -->
12379
12380 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
12381 !!end
12382
12383 !!test
12384 Templates: Inline Text: 1. Multiple template uses
12385 !! wikitext
12386 {{echo|Foo}}bar{{echo|baz}}
12387 !! html
12388 <p>Foobarbaz
12389 </p>
12390 !!end
12391
12392 !!test
12393 Templates: Inline Text: 2. Back-to-back template uses
12394 !! wikitext
12395 {{echo|Foo}}{{echo|bar}}
12396 !! html
12397 <p>Foobar
12398 </p>
12399 !!end
12400
12401 !!test
12402 Templates: Block Tags: 1. Multiple template uses
12403 !! wikitext
12404 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
12405 !! html
12406 <div>Foo</div><div>bar</div><div>baz</div>
12407
12408 !!end
12409
12410 !!test
12411 Templates: Block Tags: 2. Back-to-back template uses
12412 !! wikitext
12413 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
12414 !! html
12415 <div>Foo</div><div>bar</div>
12416
12417 !!end
12418
12419 # This is an edge case relating to paragraph wrapping.
12420 !!test
12421 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
12422 !! wikitext
12423 {{echo|a
12424 b</p>}}
12425 !! html/parsoid
12426 <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
12427 b</p>
12428 !!end
12429
12430 !!test
12431 Templates: Links: 1. Simple example
12432 !! wikitext
12433 {{echo|[[Foo|bar]]}}
12434 !! html
12435 <p><a href="/wiki/Foo" title="Foo">bar</a>
12436 </p>
12437 !!end
12438
12439 !!test
12440 Templates: Links: 2. Generation of link href
12441 !! wikitext
12442 [[{{echo|Foo}}|bar]]
12443 !! html
12444 <p><a href="/wiki/Foo" title="Foo">bar</a>
12445 </p>
12446 !!end
12447
12448 !!test
12449 Templates: Links: 3. Generation of part of a link href
12450 !! wikitext
12451 [[Fo{{echo|o}}|bar]]
12452
12453 [[Foo{{echo|bar}}]]
12454
12455 [[Foo{{echo|bar}}baz]]
12456
12457 [[Foo{{echo|bar}}|bar]]
12458
12459 [[:Foo{{echo|bar}}]]
12460
12461 [[:Foo{{echo|bar}}|bar]]
12462 !! html
12463 <p><a href="/wiki/Foo" title="Foo">bar</a>
12464 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12465 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
12466 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12467 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12468 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12469 </p>
12470 !!end
12471
12472 !!test
12473 Templates: Links: 4. Multiple templates generating link href
12474 !! wikitext
12475 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
12476 !! html
12477 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12478 </p>
12479 !!end
12480
12481 !!test
12482 Templates: Links: 5. Generation of link text
12483 !! wikitext
12484 [[Foo|{{echo|bar}}]]
12485 !! html
12486 <p><a href="/wiki/Foo" title="Foo">bar</a>
12487 </p>
12488 !!end
12489
12490 !!test
12491 Templates: Links: 5. Nested templates (only outermost template should be marked)
12492 !! wikitext
12493 {{echo|[[{{echo|Foo}}|bar]]}}
12494 !! html
12495 <p><a href="/wiki/Foo" title="Foo">bar</a>
12496 </p>
12497 !!end
12498
12499 !!test
12500 Templates: HTML Tag: 1. Generation of HTML attr. key
12501 !! wikitext
12502 <div {{echo|style}}="color:red;">foo</div>
12503 !! html
12504 <div style="color:red;">foo</div>
12505
12506 !!end
12507
12508 !!test
12509 Templates: HTML Tag: 2. Generation of HTML attr. value
12510 !! wikitext
12511 <div style={{echo|'color:red;'}}>foo</div>
12512 !! html
12513 <div style="color:red;">foo</div>
12514
12515 !!end
12516
12517 !!test
12518 Templates: HTML Tag: 3. Generation of HTML attr key and value
12519 !! wikitext
12520 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
12521 !! html
12522 <div style="color:red;">foo</div>
12523
12524 !!end
12525
12526 !!test
12527 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
12528 !! wikitext
12529 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
12530 !! html
12531 <div title="This is a long title with just one piece templated">foo</div>
12532
12533 !!end
12534
12535 !!test
12536 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
12537 !! wikitext
12538 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
12539 !! html
12540 <div title="This is a long title with just one piece templated">foo</div>
12541
12542 !!end
12543
12544 !!test
12545 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
12546 !! wikitext
12547 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
12548 !! html
12549 <div title="This is a long title with just one piece templated">foo</div>
12550
12551 !!end
12552
12553 # SSS FIXME: While it is great we added support for all this,
12554 # do we want to make this part of the spec? Maybe we want to
12555 # deprecate this kind of usage in the future?
12556 !!test
12557 Templates: HTML Tag: 7. Generation of partial attribute key string
12558 !! wikitext
12559 <div st{{echo|yle}}="color:red;">foo</div>
12560 !! html
12561 <div style="color:red;">foo</div>
12562
12563 !!end
12564
12565 !! test
12566 Templates: HTML Tag: 8. Template-generated attribute (k=v)
12567 !! wikitext
12568 <div {{echo|1=id="v1"}}>bar</div>
12569 !! html
12570 <div id="v1">bar</div>
12571
12572 !!end
12573
12574 !! test
12575 Templates: HTML Tag: 9. Multiple template-generated attributes
12576 !! wikitext
12577 <div {{echo|1=id="v1" title="foo"}}>bar</div>
12578 !! html
12579 <div id="v1" title="foo">bar</div>
12580
12581 !!end
12582
12583 !! test
12584 Templates: Support for templates generating attributes and content
12585 !! wikitext
12586 {| {{mixed_attr_content_template}}
12587 |-
12588 |bar
12589 |}
12590 !! html/php
12591 <table style="color:red;" title="T48811">
12592
12593 <tr>
12594 <td>foo
12595 </td></tr>
12596 <tr>
12597 <td>bar
12598 </td></tr></table>
12599
12600 !! html/parsoid
12601 <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|}"]}'>
12602 <tbody><tr>
12603 <td>foo</td></tr>
12604 <tr>
12605 <td>bar</td></tr>
12606 </tbody></table>
12607 !!end
12608
12609 !! test
12610 1. Entities and nowikis inside templated attributes should be handled correctly
12611 !! wikitext
12612 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
12613 !! html/php
12614 <div style="background:#f9f9f9;">foo</div>
12615
12616 !! html/parsoid
12617 <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>
12618 !! end
12619
12620 !! test
12621 2. Entities and nowikis inside templated attributes should be handled correctly
12622 !! wikitext
12623 {|
12624 |{{table_attribs_3}}
12625 |}
12626 !! html/php
12627 <table>
12628 <tr>
12629 <td style="background:#f9f9f9;">Foo
12630 </td></tr></table>
12631
12632 !! html/parsoid
12633 <table>
12634 <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>
12635 </tbody></table>
12636 !! end
12637
12638 !! test
12639 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
12640 !! wikitext
12641 {{tbl-start}}
12642 |{{table_attribs_3}}
12643 {{tbl-end}}
12644 !! html/php
12645 <table>
12646 <tr>
12647 <td style="background:#f9f9f9;">Foo
12648 </td></tr></table>
12649
12650 !! html/parsoid
12651 <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}}]}'>
12652 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
12653 </tbody></table>
12654 !! end
12655
12656 # T107622
12657 !! test
12658 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
12659 !! wikitext
12660 {|
12661 | {{table_attribs_6}} hi
12662 |}
12663 !! html/php
12664 <table>
12665 <tr>
12666 <td style="background: red;"> hi
12667 </td></tr></table>
12668
12669 !! html/parsoid
12670 <table>
12671 <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>
12672 </tbody></table>
12673 !! end
12674
12675 !!test
12676 Templates: HTML Tables: 1. Generating start of a HTML table
12677 !! wikitext
12678 {{echo|<table><tr><td>foo</td>}}</tr></table>
12679 !! html
12680 <table><tr><td>foo</td></tr></table>
12681
12682 !!end
12683
12684 !!test
12685 Templates: HTML Tables: 2a. Generating middle of a HTML table
12686 !! wikitext
12687 <table><tr>{{echo|<td>foo</td>}}</tr></table>
12688 !! html
12689 <table><tr><td>foo</td></tr></table>
12690
12691 !!end
12692
12693 !!test
12694 Templates: HTML Tables: 2b. Generating middle of a HTML table
12695 !! wikitext
12696 <table>{{echo|<tr><td>foo</td></tr>}}</table>
12697 !! html
12698 <table><tr><td>foo</td></tr></table>
12699
12700 !!end
12701
12702 !!test
12703 Templates: HTML Tables: 3. Generating end of a HTML table
12704 !! wikitext
12705 <table><tr>{{echo|<td>foo</td></tr></table>}}
12706 !! html
12707 <table><tr><td>foo</td></tr></table>
12708
12709 !!end
12710
12711 !!test
12712 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
12713 !! wikitext
12714 {{echo|<table>}}<tr><td>foo</td></tr></table>
12715 !! html
12716 <table><tr><td>foo</td></tr></table>
12717
12718 !!end
12719
12720 !!test
12721 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
12722 !! wikitext
12723 <table>{{echo|<tr>}}<td>foo</td></tr></table>
12724 !! html
12725 <table><tr><td>foo</td></tr></table>
12726
12727 !!end
12728
12729 !!test
12730 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
12731 !! wikitext
12732 <table><tr>{{echo|<td>}}foo</td></tr></table>
12733 !! html
12734 <table><tr><td>foo</td></tr></table>
12735
12736 !!end
12737
12738 !!test
12739 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
12740 !! wikitext
12741 <table><tr><td>foo{{echo|</td>}}</tr></table>
12742 !! html
12743 <table><tr><td>foo</td></tr></table>
12744
12745 !!end
12746
12747 !!test
12748 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
12749 !! wikitext
12750 <table><tr><td>foo</td>{{echo|</tr>}}</table>
12751 !! html
12752 <table><tr><td>foo</td></tr></table>
12753
12754 !!end
12755
12756 !!test
12757 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
12758 !! wikitext
12759 <table><tr><td>foo</td></tr>{{echo|</table>}}
12760 !! html
12761 <table><tr><td>foo</td></tr></table>
12762
12763 !!end
12764
12765 !!test
12766 Templates: HTML Tables: 5. Proper fostering of categories from inside
12767 !!options
12768 parsoid=wt2html,wt2wt
12769 !! wikitext
12770 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
12771 <!--Two categories (T52330)-->
12772 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
12773 !! html
12774 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
12775 <!--Two categories (T52330)-->
12776 <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>
12777 !!end
12778
12779 !!test
12780 Templates: Wiki Tables: 1a. Fostering of entire template content
12781 !! wikitext
12782 {|
12783 {{echo|a}}
12784 |}
12785 !! html
12786 <table>
12787 a
12788 <tr><td></td></tr></table>
12789
12790 !! html+tidy
12791 <p>a</p>
12792 <table>
12793 <tr>
12794 <td></td>
12795 </tr>
12796 </table>
12797 !! end
12798
12799 !!test
12800 Templates: Wiki Tables: 1b. Fostering of entire template content
12801 !! wikitext
12802 {|
12803 {{echo|<div>}}
12804 foo
12805 {{echo|</div>}}
12806 |}
12807 !! html
12808 <table>
12809 <div>
12810 <p>foo
12811 </p>
12812 </div>
12813 <tr><td></td></tr></table>
12814
12815 !! html+tidy
12816 <div>
12817 <p>foo</p>
12818 </div>
12819 <table>
12820 <tr>
12821 <td></td>
12822 </tr>
12823 </table>
12824 !! end
12825
12826 !!test
12827 Templates: Wiki Tables: 2. Fostering of partial template content
12828 !! wikitext
12829 {|
12830 {{echo|a
12831 <div>b</div>}}
12832 |}
12833 !! html
12834 <table>
12835 a
12836 <div>b</div>
12837 <tr><td></td></tr></table>
12838
12839 !! html+tidy
12840 <p>a</p>
12841 <div>b</div>
12842 <table>
12843 <tr>
12844 <td></td>
12845 </tr>
12846 </table>
12847 !! end
12848
12849 !!test
12850 Templates: Wiki Tables: 3. td-content via multiple templates
12851 !! wikitext
12852 {|
12853 {{echo|{{pipe}}a}}{{echo|b}}
12854 |}
12855 !! html
12856 <table>
12857 <tr>
12858 <td>ab
12859 </td></tr></table>
12860
12861 !!end
12862
12863 !!test
12864 Templates: Wiki Tables: 4. Templated tags, no content
12865 !! wikitext
12866 {{tbl-start}}
12867 {{tbl-end}}
12868 !! html
12869 <table>
12870 <tr><td></td></tr></table>
12871
12872 !!end
12873
12874 !!test
12875 Templates: Wiki Tables: 5. Templated tags, regular td-tags
12876 !! wikitext
12877 {{tbl-start}}
12878 |foo
12879 {{tbl-end}}
12880 !! html
12881 <table>
12882 <tr>
12883 <td>foo
12884 </td></tr></table>
12885
12886 !!end
12887
12888 !!test
12889 Templates: Wiki Tables: 6. Templated tags, templated td-tags
12890 !! wikitext
12891 {{tbl-start}}
12892 {{!}}foo
12893 {{tbl-end}}
12894 !! html
12895 <table>
12896 <tr>
12897 <td>foo
12898 </td></tr></table>
12899
12900 !!end
12901
12902 ## This test case is very specific to Parsoid's internals
12903 ## and is hence only tested for Parsoid's code. Parsoid uses
12904 ## a <meta> marker tag for <ref> tags and they are expanded
12905 ## much later. We are verifying that this <meta> tag usage
12906 ## doesn't prevent foster parenting.
12907 !!test
12908 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
12909 !!wikitext
12910 {{PartialTable}}<ref>foo</ref>
12911 |}
12912
12913 <references />
12914 !!html/parsoid
12915 <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">
12916 <tbody>
12917 </tbody></table>
12918
12919 <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>
12920 !!end
12921
12922 !! test
12923 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
12924 !! wikitext
12925 {{echo|
12926 {{{!}}
12927 {{!}}-}}
12928 <onlyinclude>
12929 |foo
12930 </onlyinclude>
12931 {{!}}}
12932 !! html/parsoid
12933 <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{{!}}}"]}'>
12934 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
12935 <tbody><tr>
12936
12937 <td>foo
12938 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
12939 </tbody></table>
12940 !! end
12941
12942 !!test
12943 Templates: Lists: Multi-line list-items via templates
12944 !! wikitext
12945 *{{echo|a {{nonexistent|
12946 unused}}}}
12947 *{{echo|b {{nonexistent|
12948 unused}}}}
12949 !! html
12950 <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>
12951 <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>
12952
12953 !!end
12954
12955 !!test
12956 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
12957 !! wikitext
12958 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
12959 !! html
12960 <p><i>ab</i>c<i>d</i>e
12961 </p>
12962 !!end
12963
12964 !!test
12965 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
12966 (PHP parser generates misnested html)
12967 !! wikitext
12968 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
12969 !! html/parsoid
12970 <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>
12971 !!end
12972
12973 !!test
12974 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
12975 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
12976 !! options
12977 parsoid=wt2html,wt2wt
12978 !! wikitext
12979 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
12980 !! html
12981 <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>
12982 <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>
12983 <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>
12984 !!end
12985
12986 !!test
12987 Templates: Ugly nesting: 4. Divs opened/closed across templates
12988 !! wikitext
12989 a<div>b{{echo|c</div>d}}e
12990 !! html
12991 a<div>bc</div>de
12992
12993 !! html+tidy
12994 <p>a</p>
12995 <div>bc</div>
12996 <p>de</p>
12997 !! end
12998
12999 !!test
13000 Templates: Ugly templates: 1. Navbox template parses badly leading to table misnesting
13001 (Parsoid-centric)
13002 !! options
13003 parsoid
13004 !! wikitext
13005 {|
13006 |{{echo|foo</table>}}
13007 |bar
13008 |}
13009 !! html
13010 <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|}"]}'>
13011
13012 <tbody>
13013 <tr>
13014 <td>foo</td></tr></tbody></table><span about="#mwt1">
13015 </span><span about="#mwt1">|bar</span><span about="#mwt1">
13016 |}</span>
13017 !!end
13018
13019 !!test
13020 Templates: Ugly templates: 2. Navbox template parses badly leading to table misnesting
13021 (Parsoid-centric)
13022 !! options
13023 parsoid
13024 !! wikitext
13025 <table>
13026 <tr>
13027 <td>
13028 <table>
13029 <tr>
13030 <td>1. {{echo|foo </table>}}</td>
13031 <td> bar </td>
13032 <td>2. {{echo|baz </table>}}</td>
13033 </tr>
13034 <tr>
13035 <td>abc</td>
13036 </tr>
13037 </table>
13038 </td>
13039 </tr>
13040 <tr>
13041 <td>xyz</td>
13042 </tr>
13043 </table>
13044 !! html
13045 <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>"]}'>
13046 <tbody><tr>
13047 <td>
13048 <table>
13049 <tbody><tr>
13050 <td>1. foo </td></tr></tbody></table></td>
13051 <td> bar </td>
13052 <td>2. baz </td></tr></tbody></table><span about="#mwt2">
13053 </span><span about="#mwt2">
13054 </span><span about="#mwt2">
13055 </span><span about="#mwt2">abc</span><span about="#mwt2">
13056 </span><span about="#mwt2">
13057 </span><span about="#mwt2">
13058 </span><span about="#mwt2">
13059 </span><span about="#mwt2">
13060 </span><span about="#mwt2">
13061 </span><span about="#mwt2">xyz</span><span about="#mwt2">
13062 </span><span about="#mwt2">
13063 </span>
13064 !!end
13065
13066 !! test
13067 Templates: Ugly templates: 3. newline-only template parameter
13068 !! wikitext
13069 foo {{echo|
13070 }}
13071 !! html
13072 <p>foo
13073 </p>
13074 !! end
13075
13076 # This looks like a bug: a single newline triggers p/br for some reason.
13077 !! test
13078 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13079 !! wikitext
13080 {{echo|
13081 }}
13082 !! html
13083 <p><br />
13084 </p>
13085 !! end
13086
13087 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13088 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13089 !! test
13090 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13091 !! wikitext
13092 {{echo|<table>}}
13093 {{echo|<div>foo}}
13094 {{echo|</table>}}
13095 !! html/parsoid
13096 <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
13097 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13098 </table>
13099 !! end
13100
13101 # T66017 -- ugly wikitext with fostered content generates two template ranges
13102 # that are "identical" and generate nesting cycles in the algorithm
13103 !! test
13104 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13105 !! wikitext
13106 {{echo|<table><tr><td><table>}}
13107 {{echo|<div>}}
13108 {{echo|</div>}}
13109 !! html/parsoid
13110 <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"}'>
13111 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13112 </table></td></tr></tbody></table>
13113 !! end
13114
13115 !! test
13116 Templates: Parameters substituted at the top-level
13117 !! wikitext
13118 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13119
13120 {{{foo|bar|baz}}}
13121 !! html/php
13122 <p><i>who</i> me? <b>never!</b>
13123 </p><p>bar
13124 </p>
13125 !! html/parsoid
13126 <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>
13127
13128 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13129 !! end
13130
13131 !!test
13132 Parser Functions: 1. Simple example
13133 !! wikitext
13134 {{uc:foo}}
13135 !! html
13136 <p>FOO
13137 </p>
13138 !!end
13139
13140 !!test
13141 Parser Functions: 2. Nested use (only outermost should be marked up)
13142 !! wikitext
13143 {{uc:{{lc:FOO}}}}
13144 !! html
13145 <p>FOO
13146 </p>
13147 !!end
13148
13149 ###
13150 ### Pre-save transform tests
13151 ###
13152 !! test
13153 pre-save transform: subst:
13154 !! options
13155 pst
13156 !! wikitext
13157 {{subst:test}}
13158 !! html/php
13159 This is a test template
13160 !! end
13161
13162 !! test
13163 pre-save transform: normal template
13164 !! options
13165 pst
13166 !! wikitext
13167 {{test}}
13168 !! html/php
13169 {{test}}
13170 !! end
13171
13172 !! test
13173 pre-save transform: nonexistent template
13174 !! options
13175 pst
13176 !! wikitext
13177 {{thistemplatedoesnotexist}}
13178 !! html/php
13179 {{thistemplatedoesnotexist}}
13180 !! end
13181
13182 !! test
13183 pre-save transform: subst magic variables
13184 !! options
13185 pst
13186 !! wikitext
13187 {{subst:SITENAME}}
13188 !! html/php
13189 MediaWiki
13190 !! end
13191
13192 # This is T2089, which I fixed. -- wtm
13193 !! test
13194 pre-save transform: subst: templates with parameters
13195 !! options
13196 pst
13197 !! wikitext
13198 {{subst:paramtest|param="something else"}}
13199 !! html/php
13200 This is a test template with parameter "something else"
13201 !! end
13202
13203 !! article
13204 Template:nowikitest
13205 !! text
13206 <nowiki>'''not wiki'''</nowiki>
13207 !! endarticle
13208
13209 !! test
13210 pre-save transform: nowiki in subst (T3188)
13211 !! options
13212 pst
13213 !! wikitext
13214 {{subst:nowikitest}}
13215 !! html/php
13216 <nowiki>'''not wiki'''</nowiki>
13217 !! end
13218
13219 !! article
13220 Template:commenttest
13221 !! text
13222 This template has <!-- a comment --> in it.
13223 !! endarticle
13224
13225 !! test
13226 pre-save transform: comment in subst (T3936)
13227 !! options
13228 pst
13229 !! wikitext
13230 {{subst:commenttest}}
13231 !! html/php
13232 This template has <!-- a comment --> in it.
13233 !! end
13234
13235 !! test
13236 pre-save transform: unclosed tag
13237 !! options
13238 pst
13239 !! wikitext
13240 <nowiki>'''not wiki'''
13241 !! html/php
13242 <nowiki>'''not wiki'''
13243 !! end
13244
13245 !! test
13246 pre-save transform: mixed tag case
13247 !! options
13248 pst
13249 !! wikitext
13250 <NOwiki>'''not wiki'''</noWIKI>
13251 !! html/php
13252 <NOwiki>'''not wiki'''</noWIKI>
13253 !! end
13254
13255 !! test
13256 pre-save transform: unclosed comment in <nowiki>
13257 !! options
13258 pst
13259 !! wikitext
13260 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13261 !! html/php
13262 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13263 !!end
13264
13265 # Leading @ in this template definition works around a limitation
13266 # in parsoid's parserTests which otherwise strips the <span> from the
13267 # result (confusing it for a template wrapper)
13268 !! article
13269 Template:dangerous
13270 !!text
13271 @<span onmouseover="alert('crap')">Oh no</span>
13272 !!endarticle
13273
13274 !!test
13275 (confirming safety of fix for subst T3936)
13276 !! wikitext
13277 {{Template:dangerous}}
13278 !! html
13279 <p>@<span>Oh no</span>
13280 </p>
13281 !! end
13282
13283 !! test
13284 pre-save transform: comment containing gallery (T7024)
13285 !! options
13286 pst
13287 !! wikitext
13288 <!-- <gallery>data</gallery> -->
13289 !! html/php
13290 <!-- <gallery>data</gallery> -->
13291 !!end
13292
13293 !! test
13294 pre-save transform: comment containing extension
13295 !! options
13296 pst
13297 !! wikitext
13298 <!-- <tag>data</tag> -->
13299 !! html/php
13300 <!-- <tag>data</tag> -->
13301 !!end
13302
13303 !! test
13304 pre-save transform: comment containing nowiki
13305 !! options
13306 pst
13307 !! wikitext
13308 <!-- <nowiki>data</nowiki> -->
13309 !! html/php
13310 <!-- <nowiki>data</nowiki> -->
13311 !!end
13312
13313 !! test
13314 pre-save transform: <noinclude> in subst (T5298)
13315 !! options
13316 pst
13317 !! wikitext
13318 {{subst:Includes}}
13319 !! html/php
13320 Foobar
13321 !! end
13322
13323 !! test
13324 pre-save transform: <onlyinclude> in subst (T5298)
13325 !! options
13326 pst
13327 !! wikitext
13328 {{subst:Includes2}}
13329 !! html/php
13330 Foo
13331 !! end
13332
13333 !! article
13334 Template:SubstTest
13335 !!text
13336 {{<includeonly>subst:</includeonly>Includes}}
13337 !! endarticle
13338
13339 !! article
13340 Template:SafeSubstTest
13341 !! text
13342 {{<includeonly>safesubst:</includeonly>Includes}}
13343 !! endarticle
13344
13345 !! test
13346 T24297: safesubst: works during PST
13347 !! options
13348 pst
13349 !! wikitext
13350 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
13351 !! html/php
13352 FoobarFoobar
13353 !! end
13354
13355 !! test
13356 T24297: safesubst: works during normal parse
13357 !! wikitext
13358 {{SafeSubstTest}}
13359 !! html
13360 <p>Foobar
13361 </p>
13362 !! end
13363
13364 !! test
13365 subst: does not work during normal parse
13366 !! wikitext
13367 {{SubstTest}}
13368 !! html
13369 <p>{{subst:Includes}}
13370 </p>
13371 !! end
13372
13373 !! test
13374 pre-save transform: context links ("pipe trick")
13375 !! options
13376 pst
13377 !! wikitext
13378 [[Article (context)|]]
13379 [[Bar:Article|]]
13380 [[:Bar:Article|]]
13381 [[Bar:Article (context)|]]
13382 [[:Bar:Article (context)|]]
13383 [[|Article]]
13384 [[|Article (context)]]
13385 [[Bar:X (Y) Z|]]
13386 [[:Bar:X (Y) Z|]]
13387 !! html/php
13388 [[Article (context)|Article]]
13389 [[Bar:Article|Article]]
13390 [[:Bar:Article|Article]]
13391 [[Bar:Article (context)|Article]]
13392 [[:Bar:Article (context)|Article]]
13393 [[Article]]
13394 [[Article (context)]]
13395 [[Bar:X (Y) Z|X (Y) Z]]
13396 [[:Bar:X (Y) Z|X (Y) Z]]
13397 !! end
13398
13399 !! test
13400 pre-save transform: context links ("pipe trick") with interwiki prefix
13401 !! options
13402 pst
13403 !! wikitext
13404 [[interwiki:Article|]]
13405 [[:interwiki:Article|]]
13406 [[interwiki:Bar:Article|]]
13407 [[:interwiki:Bar:Article|]]
13408 !! html/php
13409 [[interwiki:Article|Article]]
13410 [[:interwiki:Article|Article]]
13411 [[interwiki:Bar:Article|Bar:Article]]
13412 [[:interwiki:Bar:Article|Bar:Article]]
13413 !! end
13414
13415 !! test
13416 pre-save transform: context links ("pipe trick") with parens in title
13417 !! options
13418 pst title=[[Somearticle (context)]]
13419 !! wikitext
13420 [[|Article]]
13421 !! html/php
13422 [[Article (context)|Article]]
13423 !! end
13424
13425 !! test
13426 pre-save transform: context links ("pipe trick") with comma in title
13427 !! options
13428 pst title=[[Someplace, Somewhere]]
13429 !! wikitext
13430 [[|Otherplace]]
13431 [[Otherplace, Elsewhere|]]
13432 [[Otherplace, Elsewhere, Anywhere|]]
13433 !! html/php
13434 [[Otherplace, Somewhere|Otherplace]]
13435 [[Otherplace, Elsewhere|Otherplace]]
13436 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
13437 !! end
13438
13439 !! test
13440 pre-save transform: context links ("pipe trick") with parens and comma
13441 !! options
13442 pst title=[[Someplace (IGNORED), Somewhere]]
13443 !! wikitext
13444 [[|Otherplace]]
13445 [[Otherplace (place), Elsewhere|]]
13446 !! html/php
13447 [[Otherplace, Somewhere|Otherplace]]
13448 [[Otherplace (place), Elsewhere|Otherplace]]
13449 !! end
13450
13451 !! test
13452 pre-save transform: context links ("pipe trick") with comma and parens
13453 !! options
13454 pst title=[[Who, me? (context)]]
13455 !! wikitext
13456 [[|Yes, you.]]
13457 [[Me, Myself, and I (1937 song)|]]
13458 !! html/php
13459 [[Yes, you. (context)|Yes, you.]]
13460 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
13461 !! end
13462
13463 !! test
13464 pre-save transform: context links ("pipe trick") with namespace
13465 !! options
13466 pst title=[[Ns:Somearticle]]
13467 !! wikitext
13468 [[|Article]]
13469 !! html/php
13470 [[Ns:Article|Article]]
13471 !! end
13472
13473 !! test
13474 pre-save transform: context links ("pipe trick") with namespace and parens
13475 !! options
13476 pst title=[[Ns:Somearticle (context)]]
13477 !! wikitext
13478 [[|Article]]
13479 !! html/php
13480 [[Ns:Article (context)|Article]]
13481 !! end
13482
13483 !! test
13484 pre-save transform: context links ("pipe trick") with namespace and comma
13485 !! options
13486 pst title=[[Ns:Somearticle, Context, Whatever]]
13487 !! wikitext
13488 [[|Article]]
13489 !! html/php
13490 [[Ns:Article, Context, Whatever|Article]]
13491 !! end
13492
13493 !! test
13494 pre-save transform: context links ("pipe trick") with namespace, comma and parens
13495 !! options
13496 pst title=[[Ns:Somearticle, Context (context)]]
13497 !! wikitext
13498 [[|Article]]
13499 !! html/php
13500 [[Ns:Article (context)|Article]]
13501 !! end
13502
13503 !! test
13504 pre-save transform: context links ("pipe trick") with namespace, parens and comma
13505 !! options
13506 pst title=[[Ns:Somearticle (IGNORED), Context]]
13507 !! wikitext
13508 [[|Article]]
13509 !! html/php
13510 [[Ns:Article, Context|Article]]
13511 !! end
13512
13513 !! test
13514 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
13515 !! options
13516 pst
13517 !! wikitext
13518 [[Article(context)|]]
13519 [[Bar:Article(context)|]]
13520 [[:Bar:Article(context)|]]
13521 [[|Article(context)]]
13522 [[Bar:X(Y)Z|]]
13523 [[:Bar:X(Y)Z|]]
13524 !! html/php
13525 [[Article(context)|Article]]
13526 [[Bar:Article(context)|Article]]
13527 [[:Bar:Article(context)|Article]]
13528 [[Article(context)]]
13529 [[Bar:X(Y)Z|X(Y)Z]]
13530 [[:Bar:X(Y)Z|X(Y)Z]]
13531 !! end
13532
13533 !! test
13534 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
13535 !! options
13536 pst
13537 !! wikitext
13538 [[Article (context)|]]
13539 [[Bar:Article (context)|]]
13540 [[:Bar:Article (context)|]]
13541 [[|Article (context)]]
13542 [[Bar:X (Y) Z|]]
13543 [[:Bar:X (Y) Z|]]
13544 !! html/php
13545 [[Article (context)|Article]]
13546 [[Bar:Article (context)|Article]]
13547 [[:Bar:Article (context)|Article]]
13548 [[Article (context)]]
13549 [[Bar:X (Y) Z|X (Y) Z]]
13550 [[:Bar:X (Y) Z|X (Y) Z]]
13551 !! end
13552
13553 !! test
13554 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
13555 !! options
13556 pst
13557 !! wikitext
13558 [[Article(context)|]]
13559 [[Bar:Article(context)|]]
13560 [[:Bar:Article(context)|]]
13561 [[|Article(context)]]
13562 [[Bar:X(Y)Z|]]
13563 [[:Bar:X(Y)Z|]]
13564 !! html/php
13565 [[Article(context)|Article]]
13566 [[Bar:Article(context)|Article]]
13567 [[:Bar:Article(context)|Article]]
13568 [[Article(context)]]
13569 [[Bar:X(Y)Z|X(Y)Z]]
13570 [[:Bar:X(Y)Z|X(Y)Z]]
13571 !! end
13572
13573 !! test
13574 pre-save transform: context links ("pipe trick") with commas (T23660)
13575 !! options
13576 pst
13577 !! wikitext
13578 [[Article (context), context|]]
13579 [[Article (context),context|]]
13580 [[Bar:Article (context), context|]]
13581 [[Bar:Article (context),context|]]
13582 [[:Bar:Article (context), context|]]
13583 [[:Bar:Article (context),context|]]
13584 !! html/php
13585 [[Article (context), context|Article]]
13586 [[Article (context),context|Article]]
13587 [[Bar:Article (context), context|Article]]
13588 [[Bar:Article (context),context|Article]]
13589 [[:Bar:Article (context), context|Article]]
13590 [[:Bar:Article (context),context|Article]]
13591 !! end
13592
13593 !! test
13594 Parsoid: backwards pipe trick
13595 !! wikitext
13596 [[|'''bar''']]
13597 !! html/php
13598 <p>[[|<b>bar</b>]]
13599 </p>
13600 !! html/parsoid
13601 <p>[[|<b>bar</b>]]</p>
13602 !! end
13603
13604 !! test
13605 pre-save transform: trim trailing empty lines
13606 !! options
13607 pst
13608 !! wikitext
13609 Empty lines are trimmed
13610
13611
13612
13613
13614 !! html/php
13615 Empty lines are trimmed
13616 !! end
13617
13618 !! test
13619 pre-save transform: Signature expansion
13620 !! options
13621 pst
13622 !! wikitext
13623 * ~~~
13624 * ~~~~
13625 * ~~~~~
13626 * <noinclude>~~~</noinclude>
13627 * <includeonly>~~~</includeonly>
13628 * <onlyinclude>~~~</onlyinclude>
13629 !! html/php
13630 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
13631 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
13632 * 00:02, 1 January 1970 (UTC)
13633 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
13634 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
13635 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
13636 !! end
13637
13638
13639 !! test
13640 ParserOutput flags from signature expansion (T84843)
13641 !! options
13642 pst
13643 showflags
13644 !! wikitext
13645 ~~~~
13646 !! html/php
13647 [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
13648 flags=user-signature
13649 !! end
13650
13651
13652 !! test
13653 pre-save transform: Signature expansion in nowiki tags (T2093)
13654 !! options
13655 pst disabled
13656 !! wikitext
13657 Shall not expand:
13658
13659 <nowiki>~~~~</nowiki>
13660
13661 <includeonly><nowiki>~~~~</nowiki></includeonly>
13662
13663 <noinclude><nowiki>~~~~</nowiki></noinclude>
13664
13665 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13666
13667 {{subst:Foo}} shall be converted to FOO
13668
13669 As well as inside noinclude/onlyinclude
13670 <noinclude>{{subst:Foo}}</noinclude>
13671 <onlyinclude>{{subst:Foo}}</onlyinclude>
13672
13673 But not inside includeonly
13674 <includeonly>{{subst:Foo}}</includeonly>
13675 !! html/php
13676 Shall not expand:
13677
13678 <nowiki>~~~~</nowiki>
13679
13680 <includeonly><nowiki>~~~~</nowiki></includeonly>
13681
13682 <noinclude><nowiki>~~~~</nowiki></noinclude>
13683
13684 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13685
13686 FOO shall be converted to FOO
13687
13688 As well as inside noinclude/onlyinclude
13689 <noinclude>FOO</noinclude>
13690 <onlyinclude>FOO</onlyinclude>
13691
13692 But not inside includeonly
13693 <includeonly>{{subst:Foo}}</includeonly>
13694 !! end
13695
13696 !! test
13697 Parsoid: Recognize nowiki with trailing space in tags
13698 !! options
13699 parsoid=wt2html
13700 !! wikitext
13701 <nowiki ><div>[[foo]]</nowiki >
13702
13703 a<nowiki / >b
13704
13705 c<nowiki />d
13706
13707 e<nowiki/ >f
13708 !! html
13709 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
13710 <p>ab</p>
13711 <p>cd</p>
13712 <p>ef</p>
13713 !! end
13714
13715 !! test
13716 Parsoid: Recognize nowiki with odd capitalization
13717 !! options
13718 parsoid=wt2html
13719 !! wikitext
13720 <noWikI ><div>[[foo]]</Nowiki >
13721 !! html
13722 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
13723 !! end
13724
13725
13726 !! test
13727 Parsoid: Escape nowiki with trailing space in tags
13728 !! options
13729 parsoid=html2wt
13730 !! html/parsoid
13731 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
13732 <p>a&lt;nowiki /&gt;b</p>
13733 <p>c&lt;nowiki/ &gt;d</p>
13734 !! wikitext
13735 &lt;nowiki &gt; foo &lt;/nowiki &gt;
13736
13737 a&lt;nowiki /&gt;b
13738
13739 c&lt;nowiki/ &gt;d
13740 !! end
13741
13742 !! test
13743 Parsoid: Escape weird noWikI capitalizations
13744 !! options
13745 parsoid=html2wt
13746 !! html/parsoid
13747 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
13748 !! wikitext
13749 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
13750 !! end
13751
13752 ###
13753 ### Message transform tests
13754 ###
13755 !! test
13756 message transform: magic variables
13757 !! options
13758 msg
13759 !! wikitext
13760 {{SITENAME}}
13761 !! html
13762 MediaWiki
13763 !! end
13764
13765 !! test
13766 message transform: should not transform wiki markup
13767 !! options
13768 msg
13769 !! wikitext
13770 ''test''
13771 !! html
13772 ''test''
13773 !! end
13774
13775 !! test
13776 message transform: <noinclude> in transcluded template (T6926)
13777 !! options
13778 msg
13779 !! wikitext
13780 {{Includes}}
13781 !! html
13782 Foobar
13783 !! end
13784
13785 !! test
13786 message transform: <onlyinclude> in transcluded template (T6926)
13787 !! options
13788 msg
13789 !! wikitext
13790 {{Includes2}}
13791 !! html
13792 Foo
13793 !! end
13794
13795 !! test
13796 {{#special:}} page name, known
13797 !! options
13798 msg
13799 !! wikitext
13800 {{#special:Recentchanges}}
13801 !! html
13802 Special:RecentChanges
13803 !! end
13804
13805 !! test
13806 {{#special:}} page name with subpage, known
13807 !! options
13808 msg
13809 !! wikitext
13810 {{#special:Recentchanges/param}}
13811 !! html
13812 Special:RecentChanges/param
13813 !! end
13814
13815 !! test
13816 {{#special:}} page name, unknown
13817 !! options
13818 msg
13819 !! wikitext
13820 {{#special:foobar nonexistent}}
13821 !! html
13822 Special:Foobar nonexistent
13823 !! end
13824
13825 !! test
13826 {{#speciale:}} page name, known
13827 !! options
13828 msg
13829 !! wikitext
13830 {{#speciale:Recentchanges}}
13831 !! html
13832 Special:RecentChanges
13833 !! end
13834
13835 !! test
13836 {{#speciale:}} page name with subpage, known
13837 !! options
13838 msg
13839 !! wikitext
13840 {{#speciale:Recentchanges/param}}
13841 !! html
13842 Special:RecentChanges/param
13843 !! end
13844
13845 !! test
13846 {{#speciale:}} page name, unknown
13847 !! options
13848 msg
13849 !! wikitext
13850 {{#speciale:foobar nonexistent}}
13851 !! html
13852 Special:Foobar_nonexistent
13853 !! end
13854
13855 ###
13856 ### Images
13857 ###
13858 ### For Parsoid-specific tests, see
13859 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
13860
13861 !! test
13862 Simple image
13863 !! options
13864 parsoid=wt2html,wt2wt,html2html
13865 !! wikitext
13866 [[Image:foobar.jpg]]
13867 !! html/php
13868 <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>
13869 </p>
13870 !! html/parsoid
13871 <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>
13872 !! end
13873
13874 !! test
13875 Simple image (using File: namespace, now canonical)
13876 !! wikitext
13877 [[File:Foobar.jpg]]
13878 !! html/php
13879 <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>
13880 </p>
13881 !! html/parsoid
13882 <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>
13883 !! end
13884
13885 !! test
13886 Right-aligned image
13887 !! wikitext
13888 [[File:Foobar.jpg|right]]
13889 !! html/php
13890 <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>
13891
13892 !! html/parsoid
13893 <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>
13894 !! end
13895
13896 !! test
13897 Image with caption
13898 !! wikitext
13899 [[File:Foobar.jpg|right|Caption text]]
13900 !! html/php
13901 <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>
13902
13903 !! html/parsoid
13904 <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>
13905 !! end
13906
13907 !! test
13908 Image with caption, T55312 #1
13909 !! wikitext
13910 [[File:Foobar.jpg|right|Caption page stuff]]
13911 !! html/php
13912 <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>
13913
13914 !! html/parsoid
13915 <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>
13916 !! end
13917
13918 !! test
13919 Image with caption, T55312 #2
13920 !! wikitext
13921 [[File:Foobar.jpg|right|Caption page=]]
13922 !! html/php
13923 <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>
13924
13925 !! html/parsoid
13926 <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>
13927 !! end
13928
13929 !! test
13930 Image with caption, T55312 #3
13931 !! wikitext
13932 [[File:Foobar.jpg|right|Caption page=stuff]]
13933 !! html/php
13934 <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>
13935
13936 !! html/parsoid
13937 <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>
13938 !! end
13939
13940 !! test
13941 Allow empty links in image captions (T62753)
13942 !! options
13943 thumbsize=220
13944 !! wikitext
13945 [[File:Foobar.jpg|thumb|Caption [[Link1]]
13946 [[]]
13947 [[Link2]]
13948 ]]
13949 !! html/php
13950 <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>
13951
13952 !! html/parsoid
13953 <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>
13954 [[]]
13955 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
13956 </figcaption></figure>
13957 !! end
13958
13959 !! test
13960 Titles in unlinked images (T23454)
13961 !! wikitext
13962 [[File:Foobar.jpg|link=|stuff]]
13963 !! html/php
13964 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
13965 </p>
13966 !! end
13967
13968 !! test
13969 Link with empty target
13970 !! wikitext
13971 [[]]
13972 !! html
13973 <p>[[]]
13974 </p>
13975 !! end
13976
13977 !! test
13978 Image with link trail
13979 !! wikitext
13980 Linktrails should not work for images: [[File:Foobar.jpg]]s
13981 !! html/php
13982 <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
13983 </p>
13984 !! html/parsoid
13985 <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>
13986 !! end
13987
13988 !! test
13989 Image with empty attribute
13990 !! options
13991 parsoid=wt2html,wt2wt,html2html
13992 !! wikitext
13993 [[File:Foobar.jpg|right||Caption text]]
13994 !! html/php
13995 <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>
13996
13997 !! html/parsoid
13998 <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>
13999 !! end
14000
14001 !! test
14002 1. Block image with individual attributes from templates
14003 !! wikitext
14004 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
14005 !! html/php
14006 <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>
14007
14008 !! html/parsoid
14009 <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>
14010 !! end
14011
14012 !! test
14013 2. Block Image with individual attributes from templates
14014 !! wikitext
14015 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14016 !! html/php
14017 <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>
14018
14019 !! html/parsoid
14020 <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>
14021 !! end
14022
14023 !! test
14024 3. Inline image with individual attributes from templates
14025 !! wikitext
14026 [[File:Foobar.jpg|{{echo|50px}}]]
14027 !! html/php
14028 <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>
14029 </p>
14030 !! html/parsoid
14031 <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>
14032 !! end
14033
14034 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14035 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14036 !! test
14037 Image with multiple attributes from the same template
14038 !! wikitext
14039 [[File:Foobar.jpg|{{image_attribs}}]]
14040 !! html/php
14041 <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>
14042
14043 !! html/parsoid
14044 <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>
14045 !! end
14046
14047 !! test
14048 Image with link tails
14049 !! options
14050 thumbsize=220
14051 !! wikitext
14052 123[[File:Foobar.jpg]]456
14053 123[[File:Foobar.jpg|right]]456
14054 123[[File:Foobar.jpg|thumb]]456
14055 !! html/php
14056 <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
14057 </p>
14058 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
14059 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
14060
14061 !! html/php+tidy
14062 <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>
14063 <p>123</p>
14064 <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>
14065 <p>456 123</p>
14066 <div class="thumb tright">
14067 <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>
14068 <div class="thumbcaption">
14069 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
14070 </div>
14071 </div>
14072 </div>
14073 <p>456</p>
14074 !! html/parsoid
14075 <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>
14076 <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>
14077 <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>
14078 !! end
14079
14080 !! test
14081 Image with multiple captions -- only last one is accepted
14082 !! wikitext
14083 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14084 !! html/php
14085 <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>
14086
14087 !! html/parsoid
14088 <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>
14089 !! end
14090
14091 !! test
14092 Image with multiple widths -- use last
14093 !! wikitext
14094 [[File:Foobar.jpg|200px|300px|caption]]
14095 !! html/php
14096 <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>
14097 </p>
14098 !! html/parsoid
14099 <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>
14100 !! end
14101
14102 !! test
14103 Image with multiple alignments -- use first (T50664)
14104 !! options
14105 thumbsize=220
14106 !! wikitext
14107 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14108
14109 [[File:Foobar.jpg|middle|text-top|caption]]
14110 !! html/php
14111 <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>
14112 <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>
14113 </p>
14114 !! html/parsoid
14115 <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>
14116 <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>
14117 !! end
14118
14119 !! test
14120 Image with width attribute at different positions
14121 !! wikitext
14122 [[File:Foobar.jpg|200px|right|Caption]]
14123 [[File:Foobar.jpg|right|200px|Caption]]
14124 [[File:Foobar.jpg|right|Caption|200px]]
14125 !! html/php
14126 <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>
14127 <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>
14128 <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>
14129
14130 !! html/parsoid
14131 <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>
14132 <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>
14133 <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>
14134 !! end
14135
14136 # a sad bit of backward-compatibility
14137 !! test
14138 Image with size specified with pxpx (T15500, T53628)
14139 !! options
14140 parsoid=wt2html,wt2wt,html2html
14141 !! wikitext
14142 [[File:Foobar.jpg|20pxpx]]
14143 [[File:Foobar.jpg|200x20pxpx]]
14144 !! html/php
14145 <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>
14146 <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>
14147 </p>
14148 !! html/parsoid
14149 <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>
14150 !! end
14151
14152 !! test
14153 Image with link parameter, wiki target
14154 !! wikitext
14155 [[File:Foobar.jpg|link=Main Page]]
14156 !! html/php
14157 <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>
14158 </p>
14159 !! html/parsoid
14160 <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>
14161 !! end
14162
14163 # parsoid T51293 (part 1)
14164 !! test
14165 Image with link parameter, URL target
14166 !! wikitext
14167 [[File:Foobar.jpg|link=http://example.com/]]
14168 !! html/php
14169 <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>
14170 </p>
14171 !! html/parsoid
14172 <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>
14173 !! end
14174
14175 # parsoid T51293 (part 2)
14176 !! test
14177 Image with link parameter, protocol-less URL target
14178 !! wikitext
14179 [[File:Foobar.jpg|link=//example.com/]]
14180 !! html/php
14181 <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>
14182 </p>
14183 !! html/parsoid
14184 <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>
14185 !! end
14186
14187 !! test
14188 Escaping non-block captions (T107435)
14189 !! options
14190 parsoid={
14191 "modes": ["wt2wt"],
14192 "changes": [
14193 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14194 ]
14195 }
14196 !! wikitext
14197 [[Image:Foobar.jpg|caption]]
14198 !! wikitext/edited
14199 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14200 !! end
14201
14202 # wgExternalLinkTarget not supported by Parsoid
14203 !! test
14204 Image with link parameter, wgExternalLinkTarget
14205 !! wikitext
14206 [[Image:foobar.jpg|link=http://example.com/]]
14207 !! config
14208 wgExternalLinkTarget='foobar'
14209 !! html/php
14210 <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>
14211 </p>
14212 !! end
14213
14214 !! test
14215 Image with link parameter, wgNoFollowLinks set to false
14216 !! wikitext
14217 [[Image:foobar.jpg|link=http://example.com/]]
14218 !! config
14219 wgNoFollowLinks=false
14220 !! html
14221 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14222 </p>
14223 !! end
14224
14225 !! test
14226 Image with link parameter, wgNoFollowDomainExceptions
14227 !! wikitext
14228 [[Image:foobar.jpg|link=http://example.com/]]
14229 !! config
14230 wgNoFollowDomainExceptions='example.com'
14231 !! html
14232 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14233 </p>
14234 !! end
14235
14236 # wgExternalLinkTarget not supported by Parsoid
14237 !! test
14238 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14239 !! wikitext
14240 [[Image:foobar.jpg|link=http://example.com/|Title]]
14241 !! config
14242 wgExternalLinkTarget='foobar'
14243 !! html/php
14244 <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>
14245 </p>
14246 !! end
14247
14248 !! test
14249 Image with empty link parameter
14250 !! wikitext
14251 [[File:Foobar.jpg|link=]]
14252 !! html/php
14253 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14254 </p>
14255 !! html/parsoid
14256 <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>
14257 !! end
14258
14259 !! test
14260 Image with link parameter (wiki target) and unnamed parameter
14261 !! wikitext
14262 [[File:Foobar.jpg|link=Main_Page|Title]]
14263 !! html/php
14264 <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>
14265 </p>
14266 !! html/parsoid
14267 <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>
14268 !! end
14269
14270 !! test
14271 Image with link parameter (URL target) and unnamed parameter
14272 !! wikitext
14273 [[File:Foobar.jpg|link=http://example.com/|Title]]
14274 !! html/php
14275 <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>
14276 </p>
14277 !! html/parsoid
14278 <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>
14279 !! end
14280
14281 !! test
14282 Thumbnail image with link parameter
14283 !! options
14284 thumbsize=220
14285 parsoid=wt2html,wt2wt,html2html
14286 !! wikitext
14287 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14288 !! html/php
14289 <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>
14290
14291 !! html/parsoid
14292 <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>
14293 !! end
14294
14295 !! test
14296 Manually-specified thumbnail image
14297 !! options
14298 thumbsize=220
14299 !! wikitext
14300 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14301 !! html/php
14302 <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>
14303
14304 !! html/parsoid
14305 <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>
14306 !! end
14307
14308 !! test
14309 Manually-specified thumbnail image with explicit link to wiki page
14310 !! options
14311 thumbsize=220
14312 parsoid=wt2html,wt2wt,html2html
14313 !! wikitext
14314 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14315 !! html/php
14316 <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>
14317
14318 !! html/parsoid
14319 <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>
14320 !! end
14321
14322 !! test
14323 Manually-specified thumbnail image with explicit link to url
14324 !! options
14325 thumbsize=220
14326 parsoid=wt2html,wt2wt,html2html
14327 !! wikitext
14328 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14329 !! html/php
14330 <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>
14331
14332 !! html/parsoid
14333 <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>
14334 !! end
14335
14336 !! test
14337 Manually-specified thumbnail image with explicit no link
14338 !! options
14339 thumbsize=220
14340 parsoid=wt2html,wt2wt,html2html
14341 !! wikitext
14342 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14343 !! html/php
14344 <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>
14345
14346 !! html/parsoid
14347 <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>
14348 !! end
14349
14350 !! test
14351 Manually-specified thumbnail image with explicit link and alt text
14352 !! options
14353 thumbsize=220
14354 parsoid=wt2html,wt2wt,html2html
14355 !! wikitext
14356 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14357 !! html/php
14358 <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>
14359
14360 !! html/parsoid
14361 <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>
14362 !! end
14363
14364 !! test
14365 Image with frame and link
14366 !! options
14367 parsoid=wt2html,wt2wt,html2html
14368 !! wikitext
14369 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14370 !! html/php
14371 <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>
14372
14373 !! html/parsoid
14374 <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>
14375 !! end
14376
14377 !! test
14378 Image with frame and link and explicit alt
14379 !! options
14380 parsoid=wt2html,wt2wt,html2html
14381 !! wikitext
14382 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
14383 !! html/php
14384 <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>
14385
14386 !! html/parsoid
14387 <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>
14388 !! end
14389
14390 !! test
14391 Image with wiki markup in implicit alt
14392 !! wikitext
14393 [[Image:Foobar.jpg|testing '''bold''' in alt]]
14394
14395 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
14396 !! html/php
14397 <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>
14398 </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>
14399 </p>
14400 !! html/parsoid
14401 <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>
14402
14403 <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>
14404 !! end
14405
14406 !! test
14407 Alt image option should handle most kinds of wikitext without barfing
14408 !! wikitext
14409 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
14410 !! html/php
14411 <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>
14412
14413 !! html/parsoid
14414 <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>
14415 !! end
14416
14417 ###################
14418 # Conflicting image format options.
14419 # First option specified should 'win'.
14420 # All three cases in each test should be identical.
14421
14422 !! test
14423 Image with 'frameless' first.
14424 !! options
14425 parsoid=wt2html,wt2wt,html2html
14426 !! wikitext
14427 [[File:Foobar.jpg|frameless|caption]]
14428
14429 [[File:Foobar.jpg|frameless|frame|caption]]
14430
14431 [[File:Foobar.jpg|frameless|thumb|caption]]
14432 !! html/php
14433 <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>
14434 </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>
14435 </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>
14436 </p>
14437 !! html/parsoid
14438 <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>
14439 <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>
14440 <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>
14441 !! end
14442
14443 !! test
14444 Image with 'frame' first.
14445 !! options
14446 parsoid=wt2html,wt2wt,html2html
14447 !! wikitext
14448 [[File:Foobar.jpg|frame|caption]]
14449 [[File:Foobar.jpg|frame|frameless|caption]]
14450 [[File:Foobar.jpg|frame|thumb|caption]]
14451 !! html/php
14452 <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>
14453 <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>
14454 <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>
14455
14456 !! html/parsoid
14457 <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>
14458 <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>
14459 <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>
14460 !! end
14461
14462 !! test
14463 Image with 'thumb' first.
14464 !! options
14465 parsoid=wt2html,wt2wt,html2html
14466 !! wikitext
14467 [[File:Foobar.jpg|thumb|caption]]
14468 [[File:Foobar.jpg|thumb|frameless|caption]]
14469 [[File:Foobar.jpg|thumb|frame|caption]]
14470 !! html/php
14471 <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>
14472 <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>
14473 <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>
14474
14475 !! html/parsoid
14476 <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>
14477 <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>
14478 <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>
14479 !! end
14480
14481 ###################
14482 # Image sizing.
14483 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
14484 # and https://phabricator.wikimedia.org/T64258
14485 # Foobar has actual size of 1941x220
14486 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
14487 # a scalable format.
14488 # 2. Framed images always ignore size options; always render at default size.
14489 # 3. "Unspecified format" and border are the only types which can be
14490 # enlarged.
14491
14492 !! test
14493 Image: "unspecified format" and border enlarge
14494 !! options
14495 parsoid=wt2html,wt2wt,html2html
14496 !! wikitext
14497 [[File:Foobar.jpg|2000px]]
14498
14499 [[File:Foobar.jpg|border|2000px]]
14500 !! html/php
14501 <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>
14502 </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>
14503 </p>
14504 !! html/parsoid
14505 <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>
14506 <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>
14507 !! end
14508
14509 !! test
14510 Image: "unspecified format" and border reduce
14511 !! options
14512 parsoid=wt2html,wt2wt,html2html
14513 !! wikitext
14514 [[File:Foobar.jpg|1000px]]
14515
14516 [[File:Foobar.jpg|border|1000px]]
14517 !! html/php
14518 <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>
14519 </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>
14520 </p>
14521 !! html/parsoid
14522 <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>
14523 <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>
14524 !! end
14525
14526 !! test
14527 Image: thumbs reduce
14528 !! options
14529 parsoid=wt2html,wt2wt,html2html
14530 !! wikitext
14531 [[File:Foobar.jpg|thumb|50px]]
14532 !! html/php
14533 <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>
14534
14535 !! html/parsoid
14536 <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>
14537 !! end
14538
14539 !! test
14540 Image: bitmap thumbs can't be enlarged past original size, but vector can.
14541 !! options
14542 parsoid=wt2html,wt2wt,html2html
14543 !! wikitext
14544 [[File:Foobar.jpg|thumb|2000px]]
14545
14546 [[File:Foobar.svg|thumb|2000px]]
14547 !! html/php
14548 <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>
14549 <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>
14550
14551 !! html/parsoid
14552 <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>
14553 <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>
14554 !! end
14555
14556 !! test
14557 Image: frameless can reduce in size
14558 !! options
14559 parsoid=wt2html,wt2wt,html2html
14560 !! wikitext
14561 [[File:Foobar.jpg|frameless|50px]]
14562 !! html/php
14563 <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>
14564 </p>
14565 !! html/parsoid
14566 <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>
14567 !! end
14568
14569 !! test
14570 Image: bitmap frameless can't be enlarged past original size, but vector can
14571 !! options
14572 parsoid=wt2html,wt2wt,html2html
14573 !! wikitext
14574 [[File:Foobar.jpg|frameless|2000px]]
14575
14576 [[File:Foobar.svg|frameless|2000px]]
14577 !! html/php
14578 <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>
14579 </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>
14580 </p>
14581 !! html/parsoid
14582 <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>
14583 <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>
14584 !! end
14585
14586 !! test
14587 Image: framed images are always unscaled.
14588 !! options
14589 parsoid=wt2html,wt2wt,html2html
14590 !! wikitext
14591 [[File:Foobar.jpg|frame]]
14592
14593 [[File:Foobar.jpg|frame|50px]]
14594
14595 [[File:Foobar.jpg|frame|50x50px]]
14596
14597 [[File:Foobar.jpg|frame|2000px]]
14598 !! html/php
14599 <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>
14600 <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>
14601 <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>
14602 <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>
14603
14604 !! html/parsoid
14605 <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>
14606 <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>
14607 <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>
14608 <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>
14609 !! end
14610
14611 ###################
14612
14613 !! test
14614 Link to image page- image page normally doesn't exists, hence edit link
14615 Add test with existing image page
14616 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
14617 !! wikitext
14618 [[:Image:test]]
14619 !! html
14620 <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>
14621 </p>
14622 !! end
14623
14624 !! test
14625 T20784 Link to non-existent image page with caption should use caption as link text
14626 !! wikitext
14627 [[:Image:test|caption]]
14628 !! html
14629 <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>
14630 </p>
14631 !! end
14632
14633 !! test
14634 Frameless image caption with a free URL
14635 !! wikitext
14636 [[File:Foobar.jpg|http://example.com]]
14637 !! html/php
14638 <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>
14639 </p>
14640 !! html/parsoid
14641 <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>
14642 !! end
14643
14644 !! test
14645 Thumbnail image caption with a free URL
14646 !! options
14647 thumbsize=220
14648 !! wikitext
14649 [[File:Foobar.jpg|thumb|http://example.com]]
14650 !! html/php
14651 <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>
14652
14653 !! html/parsoid
14654 <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>
14655 !! end
14656
14657 !! test
14658 Thumbnail image caption with a free URL and explicit alt
14659 !! options
14660 thumbsize=220
14661 parsoid=wt2html,wt2wt,html2html
14662 !! wikitext
14663 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
14664 !! html/php
14665 <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>
14666
14667 !! html/parsoid
14668 <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>
14669 !! end
14670
14671 !! test
14672 SVG thumbnails with no language set
14673 !! options
14674 !! wikitext
14675 [[File:Foobar.svg|thumb|caption]]
14676 !! html/php
14677 <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>
14678
14679 !! html/parsoid
14680 <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>
14681 !! end
14682
14683 !! test
14684 SVG thumbnails with language de
14685 !! options
14686 parsoid=wt2html,wt2wt,html2html
14687 !! wikitext
14688 [[File:Foobar.svg|thumb|caption|lang=de]]
14689 !! html/php
14690 <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>
14691
14692 !! html/parsoid
14693 <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>
14694 !! end
14695
14696 !! test
14697 SVG thumbnails with invalid language code
14698 !! options
14699 parsoid=wt2html,wt2wt,html2html
14700 !! wikitext
14701 [[File:Foobar.svg|thumb|caption|lang=invalid.language.code]]
14702 !! html/php
14703 <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>
14704
14705 !! html/parsoid
14706 <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>
14707 !! end
14708
14709 !! test
14710 T3887: A ISBN with a thumbnail
14711 !! wikitext
14712 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
14713 !! html/php
14714 <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>
14715
14716 !! html/parsoid
14717 <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>
14718 !! end
14719
14720 !! test
14721 T3887: A RFC with a thumbnail
14722 !! wikitext
14723 [[File:Foobar.jpg|thumb|This is RFC 12354]]
14724 !! html/php
14725 <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>
14726
14727 !! html/parsoid
14728 <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>
14729 !! end
14730
14731 !! test
14732 T3887: A mailto link with a thumbnail
14733 !! wikitext
14734 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
14735 !! html/php
14736 <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>
14737
14738 !! html/parsoid
14739 <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>
14740 !! end
14741
14742 # Pending resolution to T2368
14743 !! test
14744 T2648: Frameless image caption with a link
14745 !! wikitext
14746 [[File:Foobar.jpg|text with a [[link]] in it]]
14747 !! html/php
14748 <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>
14749 </p>
14750 !! html/parsoid
14751 <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>
14752 !! end
14753
14754 !! test
14755 T2648: Frameless image caption with a link (suffix)
14756 !! wikitext
14757 [[File:Foobar.jpg|text with a [[link]]foo in it]]
14758 !! html/php
14759 <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>
14760 </p>
14761 !! html/parsoid
14762 <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>
14763 !! end
14764
14765 !! test
14766 T2648: Frameless image caption with an interwiki link
14767 !! wikitext
14768 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
14769 !! html/php
14770 <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>
14771 </p>
14772 !! html/parsoid
14773 <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>
14774 !! end
14775
14776 !! test
14777 T2648: Frameless image caption with a piped interwiki link
14778 !! wikitext
14779 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
14780 !! html/php
14781 <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>
14782 </p>
14783 !! html/parsoid
14784 <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>
14785 !! end
14786
14787 !! test
14788 T107474: Frameless image caption with <nowiki>
14789 !! wikitext
14790 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
14791 !! html/parsoid
14792 <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>
14793 !! end
14794
14795 !! test
14796 Escape HTML special chars in image alt text
14797 !! wikitext
14798 [[File:Foobar.jpg|& < > "]]
14799 !! html/php
14800 <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>
14801 </p>
14802 !! html/parsoid
14803 <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>
14804 !! end
14805
14806 !! test
14807 Escape HTML special chars in image alt text with LanguageConverter
14808 !! options
14809 language=zh
14810 !! wikitext
14811 [[File:Foobar.jpg|& < > "]]
14812 !! html/php
14813 <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>
14814 </p>
14815 !! html/parsoid
14816 <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>
14817 !! end
14818
14819 !! test
14820 Entities in file name and attributes
14821 !! wikitext
14822 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
14823 !! html/php
14824 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
14825 </p>
14826 !! html/parsoid
14827 <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>
14828 !! end
14829
14830 !! test
14831 T2499: Alt text should have &#1234;, not &amp;1234;
14832 !! wikitext
14833 [[File:Foobar.jpg|&#9792;]]
14834 !! html/php
14835 <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>
14836 </p>
14837 !! html/parsoid
14838 <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>
14839 !! end
14840
14841 !! test
14842 Broken image caption with link
14843 !! options
14844 parsoid=wt2html,wt2wt,html2html
14845 !! wikitext
14846 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
14847 !! html/php
14848 <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.
14849 </p>
14850 !! html/parsoid
14851 <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>
14852 !! end
14853
14854 !! test
14855 Image caption containing another image
14856 !! wikitext
14857 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
14858 !! html/php
14859 <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>
14860
14861 !! html/parsoid
14862 <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>
14863 !! end
14864
14865 !! test
14866 Image: caption containing a newline
14867 !! wikitext
14868 [[File:Foobar.jpg|This
14869 *is some text]]
14870 !! html/php
14871 <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>
14872 </p>
14873 !! html/parsoid
14874 <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>
14875 !!end
14876
14877 !!test
14878 Image: caption containing leading space
14879 (The leading space should not trigger nowiki escaping in wt2wt mode)
14880 !! wikitext
14881 [[File:Foobar.jpg|thumb| bar]]
14882 !! html/php
14883 <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>
14884
14885 !! html/parsoid
14886 <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>
14887 !!end
14888
14889 !! test
14890 Image: caption containing a table
14891 !! options
14892 parsoid=wt2html,wt2wt,html2html
14893 !! wikitext
14894 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
14895 {|
14896 ! Foo !! Bar
14897 |-
14898 | Foo1 || Bar1
14899 |}
14900 and some more text.]]
14901 !! html/php
14902 <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>
14903
14904 !! html/parsoid
14905 <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
14906 <table>
14907 <tbody>
14908 <tr><th>Foo </th><th>Bar</th></tr>
14909 <tr>
14910 <td>Foo1 </td>
14911 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
14912 !! end
14913
14914 !! test
14915 T5090: External links other than http: in image captions
14916 !! wikitext
14917 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
14918 !! html/php
14919 <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>
14920
14921 !! html/parsoid
14922 <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>
14923 !! end
14924
14925 !! test
14926 Custom class
14927 !! options
14928 parsoid=wt2html,wt2wt,html2html
14929 !! wikitext
14930 [[Image:foobar.jpg|a|class=b]]
14931 !! html/php
14932 <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>
14933 </p>
14934 !! html/parsoid
14935 <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>
14936 !! end
14937
14938 !! test
14939 Localized image handling (1).
14940 !! options
14941 parsoid=wt2html,wt2wt,html2html
14942 language=es
14943 !! wikitext
14944 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
14945 !! html/php
14946 <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>
14947
14948 !! html/parsoid
14949 <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>
14950 !! end
14951
14952 !! test
14953 Localized image handling (2).
14954 !! options
14955 thumbsize=220
14956 parsoid=wt2html,wt2wt,html2html
14957 language=es
14958 !! wikitext
14959 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
14960 !! html/php
14961 <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>
14962
14963 !! html/parsoid
14964 <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>
14965 !! end
14966
14967 !! test
14968 Localized image handling (3).
14969 !! options
14970 language=fa
14971 parsoid=html2wt
14972 !! html/parsoid
14973 <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>
14974 !! wikitext
14975 [[File:Foobar.jpg|بندانگشتی]]
14976 !! end
14977
14978 !! test
14979 "border", "frameless" and "class" attributes on an image.
14980 !! options
14981 thumbsize=220
14982 parsoid=wt2html,wt2wt,html2html
14983 !! wikitext
14984 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
14985 !! html/php
14986 <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>
14987 </p>
14988 !! html/parsoid
14989 <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>
14990 !! end
14991
14992 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
14993 !! test
14994 Invalid image attributes (T64500)
14995 !! options
14996 thumbsize=220
14997 parsoid=wt2html,wt2wt,html2html
14998 !! wikitext
14999 [[File:Foobar.jpg|thumb|float|left|caption]]
15000
15001 [[File:Foobar.jpg|thumb|righ|caption]]
15002
15003 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
15004 !! html/php
15005 <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>
15006 <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>
15007 <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>
15008
15009 !! html/parsoid
15010 <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>
15011 <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>
15012 <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>
15013 !! end
15014
15015 !! article
15016 File:Barfoo.jpg
15017 !! text
15018 #REDIRECT [[File:Barfoo.jpg]]
15019 !! endarticle
15020
15021 # FIXME: Parsoid should run this test -- but we'd need to teach the
15022 # mockAPI about the redirected Barfoo.jpg image.
15023 !! test
15024 Redirected image
15025 !! wikitext
15026 [[Image:Barfoo.jpg]]
15027 !! html/php
15028 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
15029 </p>
15030 !! end
15031
15032 !! test
15033 Missing image with uploads disabled
15034 !! options
15035 wgEnableUploads=0
15036 !! wikitext
15037 [[File:Foobaz.jpg]]
15038 !! html/php
15039 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
15040 </p>
15041 !! html/parsoid
15042 <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>
15043 !! end
15044
15045 # Parsoid-specific testing for images
15046 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
15047 # Currently imperfect due to a flaw in the Parsoid testrunner
15048 # Work in progress
15049 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
15050 # image tests.
15051
15052 !! test
15053 Parsoid-specific image handling - simple image with size and middle alignment
15054 !! wikitext
15055 [[File:Foobar.jpg|middle|50px]]
15056 !! html/parsoid
15057 <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>
15058 !! end
15059
15060 !! test
15061 Parsoid-specific image handling - simple image with size, middle alignment,
15062 non-standard namespace alias
15063 !! options
15064 parsoid=wt2wt,wt2html,html2html
15065 !! wikitext
15066 [[Image:Foobar.jpg|middle|50px]]
15067 !! html/parsoid
15068 <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>
15069 !! end
15070
15071 !! test
15072 Parsoid-specific image handling - simple image with size and middle alignment
15073 (existing content)
15074 !! wikitext
15075 [[File:Foobar.jpg|50px|middle]]
15076 !! html/parsoid
15077 <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>
15078 !! end
15079
15080 !! test
15081 Parsoid-specific image handling - simple image with size and middle alignment
15082 and non-standard namespace name
15083 !! options
15084 parsoid=wt2html,wt2wt,html2html
15085 !! wikitext
15086 [[Image:Foobar.jpg|50px|middle]]
15087 !! html/parsoid
15088 <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>
15089 !! end
15090
15091 !! test
15092 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
15093 !! wikitext
15094 [[File:Foobar.jpg|500x10px|baseline|caption]]
15095 !! html/parsoid
15096 <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>
15097 !! end
15098
15099 !! test
15100 Parsoid-specific image handling - simple image with border and size spec
15101 !! wikitext
15102 [[File:Foobar.jpg|50px|border|caption]]
15103 !! html/parsoid
15104 <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>
15105 !! end
15106
15107 !! test
15108 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15109 !! wikitext
15110 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
15111 !! html/parsoid
15112 <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>
15113 !! end
15114
15115 !! test
15116 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15117 (existing content)
15118 !! wikitext
15119 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
15120 !! html/parsoid
15121 <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>
15122 !! end
15123
15124 !! test
15125 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
15126 !! wikitext
15127 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
15128 !! html/parsoid
15129 <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>
15130 !! end
15131
15132 !! test
15133 Parsoid-specific image handling - thumbnail with specific size, halign,
15134 valign, and caption (existing content)
15135 !! wikitext
15136 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
15137 !! html/parsoid
15138 <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>
15139 !! end
15140
15141 !! test
15142 Parsoid-specific image handling - framed image with specific size and caption
15143 (size is ignored)
15144 !! options
15145 parsoid=wt2html,wt2wt,html2html
15146 !! wikitext
15147 [[File:Foobar.jpg|frame|500x50px|caption]]
15148 !! html/parsoid
15149 <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>
15150 !! end
15151
15152 !! test
15153 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption
15154 (size is ignored)
15155 !! options
15156 parsoid=wt2html,wt2wt,html2html
15157 !! wikitext
15158 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
15159 !! html/parsoid
15160 <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>
15161 !! end
15162
15163 !! test
15164 Parsoid-specific image handling - frameless image with specific size, border, and caption
15165 !! wikitext
15166 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
15167 !! html/parsoid
15168 <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>
15169 !! end
15170
15171 !! test
15172 Parsoid-specific image handling - simple image with a formatted caption
15173 !! wikitext
15174 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
15175 !! html/parsoid
15176 <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>
15177 !! end
15178
15179 !! test
15180 Parsoid-specific image handling - caption with a template in it
15181 !! wikitext
15182 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
15183 !! html/parsoid
15184 <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>
15185 !! end
15186
15187 !! test
15188 Parsoid-specific image handling - caption with unbalanced tags in it
15189 !! options
15190 parsoid=wt2html,wt2wt,html2html
15191 !! wikitext
15192 foo
15193 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
15194 bar
15195 !! html/parsoid
15196 <p>foo</p>
15197 <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>
15198 <p>bar</p>
15199 !! end
15200
15201 !! test
15202 Parsoid-specific image handling - empty caption (1)
15203 !! options
15204 parsoid=wt2html,wt2wt
15205 !! wikitext
15206 [[File:Foobar.jpg|thumb|]]
15207 !! html/parsoid
15208 <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>
15209 !! end
15210
15211 # empty captions don't get serialized unless we're in the "round trip" case
15212 !! test
15213 Parsoid-specific image handling - empty caption (2)
15214 !! options
15215 parsoid=html2wt
15216 !! html/parsoid
15217 <figure class="mw-default-size" typeof="mw:Image/Thumb">
15218 <a href="./File:Foobar.jpg">
15219 <img resource="./File:Foobar.jpg"
15220 src="//example.com/images/3/3a/Foobar.jpg"
15221 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
15222 height="25" width="220"/>
15223 </a>
15224 <figcaption></figcaption>
15225 </figure>
15226 !! wikitext
15227 [[File:Foobar.jpg|thumb]]
15228 !! end
15229
15230 !! test
15231 Parsoid-specific image handling - whitespace caption
15232 !! wikitext
15233 [[File:Foobar.jpg|thumb| ]]
15234 !! html/parsoid
15235 <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>
15236 !! end
15237
15238 !! test
15239 Parsoid-specific image handling - lang option
15240 !! wikitext
15241 foo
15242 [[File:Foobar.svg|lang=de|caption]]
15243 bar
15244 !! html/parsoid
15245 <p>foo
15246 <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>
15247 bar</p>
15248 !! end
15249
15250 ## Edge case bugs in Parsoid from T93580
15251 !! test
15252 T93580: 1. Templated <ref> inside block images
15253 !! wikitext
15254 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
15255
15256 <references />
15257 !! html/parsoid
15258 <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>
15259
15260 <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>
15261 !! end
15262
15263 !! test
15264 T93580: 2. <ref> inside inline images
15265 !! wikitext
15266 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
15267
15268 <references />
15269 !! html/parsoid
15270 <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>
15271
15272 <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>
15273 !! end
15274
15275 !! test
15276 T93580: 3. Templated <ref> inside inline images
15277 !! wikitext
15278 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
15279
15280 <references />
15281 !! html/parsoid
15282 <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>
15283
15284 <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>
15285 !! end
15286
15287 ###
15288 ### Subpages
15289 ###
15290 !! article
15291 Subpage test/subpage
15292 !! text
15293 foo
15294 !! endarticle
15295
15296 !! test
15297 Subpage link
15298 !! options
15299 subpage title=[[Subpage test]]
15300 !! wikitext
15301 [[/subpage]]
15302 !! html
15303 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
15304 </p>
15305 !! end
15306
15307 !! test
15308 Subpage noslash link
15309 !! options
15310 subpage title=[[Subpage test]]
15311 !! wikitext
15312 [[/subpage/]]
15313 !! html
15314 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
15315 </p>
15316 !! end
15317
15318 !! article
15319 Subpage test/1/2/subpage
15320 !! text
15321 blah
15322 !! endarticle
15323
15324 !! test
15325 Relative subpage noslash link
15326 !! options
15327 parsoid=wt2wt,wt2html,html2html
15328 subpage title=[[Subpage test/1/2/3/4]]
15329 !! wikitext
15330 [[../../subpage/]]
15331
15332 [[../../subpage]]
15333 !! html/php
15334 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
15335 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
15336 </p>
15337 !! html/parsoid
15338 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
15339 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
15340 !! end
15341
15342 !! test
15343 Parsoid: dot-slash prefixed wikilinks
15344 !! wikitext
15345 [[./foo]]
15346
15347 [[././bar]]
15348
15349 [[././baz/]]
15350 !! html/php
15351 <p>[[./foo]]
15352 </p><p>[[././bar]]
15353 </p><p>[[././baz/]]
15354 </p>
15355 !! html/parsoid
15356 <p>[[./foo]]
15357 </p><p>[[././bar]]
15358 </p><p>[[././baz/]]
15359 </p>
15360 !! end
15361
15362 !! test
15363 Render invalid page names as plain text (T53090)
15364 !! wikitext
15365 [[./../foo|bar]]
15366 [[foo�|bar]]
15367 [[foo/.|bar]]
15368 [[foo/..|bar]]
15369 [[foo~~~bar]]
15370 [[foo>bar]]
15371 [[foo[bar]]
15372 [[.]]
15373 [[..]]
15374 [[foo././bar]]
15375 [[foo[http://example.com]xyz]]
15376
15377 [[{{echo|./../foo}}|bar]]
15378 [[{{echo|foo/.}}|bar]]
15379 [[{{echo|foo/..}}|bar]]
15380 [[{{echo|foo~~~~bar}}]]
15381 [[{{echo|foo>bar}}]]
15382 [[{{echo|foo././bar}}]]
15383 [[{{echo|foo{bar}}]]
15384 [[{{echo|foo}bar}}]]
15385 [[{{echo|foo[bar}}]]
15386 [[{{echo|foo]bar}}]]
15387 [[{{echo|foo<bar}}]]
15388 !!html/php
15389 <p>[[./../foo|bar]]
15390 [[foo�|bar]]
15391 [[foo/.|bar]]
15392 [[foo/..|bar]]
15393 [[foo~~~bar]]
15394 [[foo&gt;bar]]
15395 [[foo[bar]]
15396 [[.]]
15397 [[..]]
15398 [[foo././bar]]
15399 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
15400 </p><p>[[./../foo|bar]]
15401 [[foo/.|bar]]
15402 [[foo/..|bar]]
15403 [[foo~~~~bar]]
15404 [[foo&gt;bar]]
15405 [[foo././bar]]
15406 [[foo{bar]]
15407 [[foo}bar]]
15408 [[foo[bar]]
15409 [[foo]bar]]
15410 [[foo&lt;bar]]
15411 </p>
15412 !!html/parsoid
15413 <p>[[./../foo|bar]]
15414 [[foo�|bar]]
15415 [[foo/.|bar]]
15416 [[foo/..|bar]]
15417 [[foo~~~bar]]
15418 [[foo>bar]]
15419 [[foo[bar]]
15420 [[.]]
15421 [[..]]
15422 [[foo././bar]]
15423 [[foo<a rel="mw:ExtLink" href="http://example.com"></a>xyz]]</p>
15424
15425 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
15426 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
15427 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
15428 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
15429 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
15430 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
15431 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
15432 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
15433 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
15434 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
15435 [[<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>
15436 !!end
15437
15438 !! test
15439 Disabled subpages
15440 !! wikitext
15441 [[/subpage]]
15442 !! html
15443 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
15444 </p>
15445 !! end
15446
15447 !! test
15448 T2561: {{/Subpage}}
15449 !! options
15450 subpage title=[[Page]]
15451 !! wikitext
15452 {{/Subpage}}
15453 !! html
15454 <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>
15455 </p>
15456 !! end
15457
15458 ###
15459 ### Categories
15460 ###
15461 !! article
15462 Category:MediaWiki User's Guide
15463 !! text
15464 blah
15465 !! endarticle
15466
15467 !! test
15468 Link to category
15469 !! wikitext
15470 [[:Category:MediaWiki User's Guide]]
15471 !! html
15472 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
15473 </p>
15474 !! end
15475
15476 !! test
15477 Simple category
15478 !! options
15479 cat
15480 !! wikitext
15481 [[Category:MediaWiki User's Guide]]
15482 !! html/php
15483 cat=MediaWiki_User's_Guide sort=
15484 !! html/parsoid
15485 <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"}}'/>
15486 !! end
15487
15488 !! test
15489 PAGESINCATEGORY invalid title fatal (r33546 fix)
15490 !! wikitext
15491 {{PAGESINCATEGORY:<bogus>}}
15492 !! html
15493 <p>0
15494 </p>
15495 !! end
15496
15497 !! test
15498 Category with different sort key
15499 !! options
15500 cat
15501 !! wikitext
15502 [[Category:MediaWiki User's Guide|Foo]]
15503 !! html/php
15504 cat=MediaWiki_User's_Guide sort=Foo
15505 !! html/parsoid
15506 <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"}}'/>
15507 !! end
15508
15509 !! test
15510 Category with identical sort key
15511 !! options
15512 cat
15513 !! wikitext
15514 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15515 !! html/php
15516 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
15517 !! html/parsoid
15518 <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"}}'/>
15519 !! end
15520
15521 !! test
15522 Category with empty sort key
15523 !! options
15524 cat
15525 pst
15526 !! wikitext
15527 [[Category:MediaWiki User's Guide|]]
15528 !! html/php
15529 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15530 !! end
15531
15532 !! test
15533 Category with empty sort key and parentheses
15534 !! options
15535 cat
15536 pst
15537 !! wikitext
15538 [[Category:Foo (bar)|]]
15539 !! html/php
15540 [[Category:Foo (bar)|Foo]]
15541 !! end
15542
15543 !! test
15544 Category with link tail
15545 !! options
15546 cat
15547 pst
15548 !! wikitext
15549 123[[Category:Foo]]456
15550 !! html/php
15551 123[[Category:Foo]]456
15552 !! end
15553
15554 !! test
15555 Category with template
15556 !! options
15557 cat
15558 pst
15559 !! wikitext
15560 [[Category:{{echo|Foo}}]]
15561 !! html/php
15562 [[Category:{{echo|Foo}}]]
15563 !! end
15564
15565 !! test
15566 Category with template in sort key
15567 !! options
15568 cat
15569 pst
15570 !! wikitext
15571 [[Category:Foo|{{echo|Bar}}]]
15572 !! html/php
15573 [[Category:Foo|{{echo|Bar}}]]
15574 !! end
15575
15576 !! test
15577 Category with template in sort key and title
15578 !! options
15579 cat
15580 pst
15581 !! wikitext
15582 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15583 !! html/php
15584 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15585 !! end
15586
15587 ## We used to, but no longer wt2wt this test since the default serializer
15588 ## will normalize all categories to serialize on their own line.
15589 ## This wikitext usage is going to be fairly uncommon in production and
15590 ## selser will take care of preserving formatting in those scenarios.
15591 !! test
15592 Category / paragraph interactions
15593 !! options
15594 parsoid=wt2html
15595 !! wikitext
15596 Foo [[Category:Baz]] Bar
15597
15598 Foo [[Category:Baz]]
15599 Bar
15600
15601 Foo
15602 [[Category:Baz]]
15603 Bar
15604
15605 Foo
15606 [[Category:Baz]] Bar
15607
15608 Foo
15609 [[Category:Baz]]
15610 [[Category:Baz]]
15611 [[Category:Baz]]
15612 Bar
15613
15614 [[Category:Baz]]
15615 [[Category:Baz]]
15616 [[Category:Baz]]
15617
15618 [[Category:Baz]]
15619 {{echo|[[Category:Baz]]}}
15620 [[Category:Baz]]
15621 !! html/php
15622 <p>Foo Bar
15623 </p><p>Foo
15624 Bar
15625 </p><p>Foo
15626 Bar
15627 </p><p>Foo Bar
15628 </p><p>Foo
15629 Bar
15630 </p>
15631 !! html/parsoid
15632 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15633 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15634 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15635 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15636 <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>
15637 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
15638 !! end
15639
15640 ## We used to, but no longer wt2wt this test since the default serializer
15641 ## will normalize all categories to serialize on their own line.
15642 ## This wikitext usage is going to be fairly uncommon in production and
15643 ## selser will take care of preserving formatting in those scenarios.
15644 ##
15645 ## The whitespace on the empty line is part of the test. Please do not delete
15646 !! test
15647 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
15648 !! options
15649 parsoid=wt2html
15650 !! wikitext
15651 This
15652
15653 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
15654
15655 {{echo|[[Category:Foo]] and so should this!}}
15656 !! html/php
15657 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
15658 </p>
15659 !! html/parsoid
15660 <p>This
15661
15662 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
15663
15664 <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>
15665 !! end
15666
15667 ## Parsoid will not try to wt2wt this while preserving newlines because
15668 ## it suppresses excess newlines within list items -- and we don't want to
15669 ## introduce a special case just for categories, which is, in reality somewhat
15670 ## odd behavior -- categories are unlikely to be used in list items like this
15671 ## in top-level pages and are only likely to show up in template-generated
15672 ## list items where this RT-ing is a non-issue.
15673 ##
15674 ## The whitespace on the empty line is part of the test. Please do not delete
15675 !! test
15676 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
15677 !! options
15678 parsoid=wt2html
15679 !! wikitext
15680 * This
15681
15682 [[Category:Foo]] and this should be part of the same list item
15683 * So should this
15684
15685 {{echo|[[Category:Foo]] and this should be part of the same list item}}
15686 !! html
15687 <ul><li>This and this should be part of the same list item</li>
15688 <li>So should this and this should be part of the same list item</li></ul>
15689 !! html/parsoid
15690 <ul>
15691 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
15692 <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>
15693 </ul>
15694 !! end
15695
15696 ## Newlines and categories that follow the last item of a list
15697 ## are treated differently because this (list followed by categories)
15698 ## is an extremely common pattern on wikis.
15699 !! test
15700 3. Categories and newlines: newline suppression for last list item should RT properly
15701 !! wikitext
15702 * a
15703 * b
15704
15705 [[Category:Foo]]
15706
15707 [[Category:Bar]]
15708 [[Category:Baz]]
15709 !! html/parsoid
15710 <ul><li> a</li>
15711 <li> b</li></ul>
15712
15713 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
15714
15715 <link rel="mw:PageProp/Category" href="./Category:Bar" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
15716 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
15717 !! end
15718
15719 !! test
15720 4. Categories and newlines: newline suppression for last list item should RT properly
15721 !! wikitext
15722 * a
15723 **** b
15724
15725 [[Category:Foo]]
15726 !! html/parsoid
15727 <ul><li> a
15728 <ul><li><ul><li><ul><li> b</li></ul></li></ul></li></ul></li></ul>
15729
15730 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
15731 !! end
15732
15733 ## only wt2html for this to make sure the algo only applies to the rightmost path
15734 !! test
15735 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
15736 !! options
15737 parsoid=wt2html
15738 !! wikitext
15739 * a
15740 ** b
15741 [[Category:Foo]]
15742 * c
15743 ** d
15744 [[Category:Foo]]
15745 !! html/parsoid
15746 <ul><li> a
15747 <ul><li> b
15748 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
15749 <li> c
15750 <ul><li> d</li></ul></li></ul>
15751 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
15752 !! end
15753
15754 ## We used to, but no longer wt2wt this test since the default serializer
15755 ## will normalize all categories to serialize on their own line.
15756 ## This wikitext usage is going to be fairly uncommon in production and
15757 ## selser will take care of preserving formatting in those scenarios.
15758 !! test
15759 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
15760 !! options
15761 parsoid=wt2html
15762 !! wikitext
15763 * a [[Category:Foo]]
15764 !! html/parsoid
15765 <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>
15766 !! end
15767
15768 # This test also demonstrates because of newline+category tunneling
15769 # through the list hander, template wrapping doesn't expand to the
15770 # containing list when the list item swallows the category.
15771 !! test
15772 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
15773 !! wikitext
15774 * {{echo|a
15775 [[Category:Foo]]}}
15776 !! html/parsoid
15777 <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
15778 </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>
15779 !! end
15780
15781 !! test
15782 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
15783 !! wikitext
15784 * a
15785
15786 {{echo|[[Category:Foo]]
15787 [[Category:Bar]]}}
15788 [[Category:Baz]]
15789 !! html/parsoid
15790 <ul><li> a</li></ul>
15791
15792 <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">
15793 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
15794 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
15795 !! end
15796
15797 !! test
15798 Category links with multiple namespaces
15799 !! wikitext
15800 [[Category:Project:Foo]]
15801 !! html/parsoid
15802 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
15803 !! end
15804
15805 !! test
15806 Parsoid: Serialize link to category page with colon escape
15807 !! options
15808 parsoid
15809 !! wikitext
15810
15811 [[:Category:Foo]]
15812 [[:Category:Foo|Bar]]
15813 !! html
15814 <p>
15815 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
15816 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
15817 </p>
15818 !! end
15819
15820 # We used to, but no longer wt2wt this test since the default serializer
15821 # will normalize all categories to serialize on their own line.
15822 # This wikitext usage is going to be fairly uncommon in production and
15823 # selser will take care of preventing whitespace insertion if this
15824 # occurs in an article.
15825 #
15826 # html2html disabled for the same reason (whitespace insertion between
15827 # x and y).
15828 #
15829 # html2wt disabled because it localizes the "Category" namespace.
15830 !! test
15831 Link prefix/suffixes aren't applied to category links
15832 !! options
15833 parsoid=wt2html
15834 language=is
15835 !! wikitext
15836 x[[Category:Foo]]y
15837 !! html/php
15838 <p>xy
15839 </p>
15840 !! html/parsoid
15841 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
15842 !! end
15843
15844 !! test
15845 Parsoid: Serialize link to file page with colon escape
15846 !! options
15847 parsoid
15848 !! wikitext
15849
15850 [[:File:Foo.png]]
15851 [[:File:Foo.png|Bar]]
15852 !! html
15853 <p>
15854 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
15855 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
15856 </p>
15857 !! end
15858
15859 !! test
15860 Parsoid: Serialize a genuine category link without colon escape
15861 !! options
15862 parsoid
15863 !! wikitext
15864 [[Category:Foo]]
15865 [[Category:Foo|Bar]]
15866 !! html
15867 <link rel="mw:PageProp/Category" href="./Category:Foo">
15868 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
15869 !! end
15870
15871 !! test
15872 Normalize hrefs properly before testing for invalid link targets (T72894)
15873 !! options
15874 parsoid=html2wt
15875 !! html/parsoid
15876 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
15877 !! wikitext
15878 [[Category:Toxine bactérienne]]
15879 !! end
15880
15881 !! test
15882 Parsoid: Defaultsort
15883 !! wikitext
15884 {{DEFAULTSORT:Foo}}
15885 !! html/parsoid
15886 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
15887 !! end
15888
15889 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
15890 # But, this is a limitation of our representation and is documented in
15891 # TemplateHandler.js in processSpecialMagicWord
15892 !! test
15893 Parsoid: Defaultsort (template-generated)
15894 !! wikitext
15895 {{{{echo|DEFAULTSORT}}:Foo}}
15896 !! html/parsoid
15897 <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"}]]}'/>
15898 !! end
15899
15900 ###
15901 ### Inter-language links
15902 ###
15903 !! test
15904 Interlanguage links
15905 !! options
15906 ill
15907 !! wikitext
15908 [[es:Alimento]]
15909 [[fr:Nourriture]]
15910 [[zh:食品]]
15911 !! html/php
15912 es:Alimento fr:Nourriture zh:食品
15913 !! html/parsoid
15914 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
15915 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
15916 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
15917 !! end
15918
15919 !! test
15920 Duplicate interlanguage links (T26502)
15921 !! options
15922 ill
15923 !! wikitext
15924 [[es:1]]
15925 [[es:2]]
15926 [[fr:1]]
15927 [[fr:2]]
15928 !! html/php
15929 es:1 fr:1
15930 !! html/parsoid
15931 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
15932 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
15933 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
15934 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
15935 !! end
15936
15937 ###
15938 ### Sections
15939 ###
15940 !! test
15941 Basic section headings
15942 !! wikitext
15943 == Headline 1 ==
15944 Some text
15945
15946 ==Headline 2==
15947 More
15948 ===Smaller headline===
15949 Blah blah
15950 !! html
15951 <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>
15952 <p>Some text
15953 </p>
15954 <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>
15955 <p>More
15956 </p>
15957 <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>
15958 <p>Blah blah
15959 </p>
15960 !! end
15961
15962 !! test
15963 Section headings with TOC
15964 !! wikitext
15965 == Headline 1 ==
15966 === Subheadline 1 ===
15967 ===== Skipping a level =====
15968 ====== Skipping a level ======
15969
15970 == Headline 2 ==
15971 Some text
15972 ===Another headline===
15973 !! html
15974 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
15975 <ul>
15976 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
15977 <ul>
15978 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
15979 <ul>
15980 <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>
15981 <ul>
15982 <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>
15983 </ul>
15984 </li>
15985 </ul>
15986 </li>
15987 </ul>
15988 </li>
15989 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
15990 <ul>
15991 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
15992 </ul>
15993 </li>
15994 </ul>
15995 </div>
15996
15997 <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>
15998 <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>
15999 <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>
16000 <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>
16001 <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>
16002 <p>Some text
16003 </p>
16004 <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>
16005
16006 !! end
16007
16008 !! test
16009 TOC anchors don't collide
16010 !! wikitext
16011 __FORCETOC__
16012 == Headline 2 ==
16013 == Headline ==
16014 == Headline 2 ==
16015 == Headline ==
16016 !! html/php
16017 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16018 <ul>
16019 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
16020 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
16021 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
16022 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
16023 </ul>
16024 </div>
16025
16026 <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>
16027 <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>
16028 <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>
16029 <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>
16030
16031 !! end
16032
16033 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
16034 !! test
16035 Handling of sections up to level 6 and beyond
16036 !! wikitext
16037 = Level 1 Heading=
16038 == Level 2 Heading==
16039 === Level 3 Heading===
16040 ==== Level 4 Heading====
16041 ===== Level 5 Heading=====
16042 ====== Level 6 Heading======
16043 ======= Level 7 Heading=======
16044 ======== Level 8 Heading========
16045 ========= Level 9 Heading=========
16046 ========== Level 10 Heading==========
16047 !! html
16048 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16049 <ul>
16050 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
16051 <ul>
16052 <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>
16053 <ul>
16054 <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>
16055 <ul>
16056 <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>
16057 <ul>
16058 <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>
16059 <ul>
16060 <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>
16061 <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>
16062 <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>
16063 <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>
16064 <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>
16065 </ul>
16066 </li>
16067 </ul>
16068 </li>
16069 </ul>
16070 </li>
16071 </ul>
16072 </li>
16073 </ul>
16074 </li>
16075 </ul>
16076 </div>
16077
16078 <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>
16079 <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>
16080 <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>
16081 <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>
16082 <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>
16083 <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>
16084 <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>
16085 <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>
16086 <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>
16087 <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>
16088
16089 !! end
16090
16091 !! test
16092 TOC regression (T11764)
16093 !! wikitext
16094 == title 1 ==
16095 === title 1.1 ===
16096 ==== title 1.1.1 ====
16097 === title 1.2 ===
16098 == title 2 ==
16099 === title 2.1 ===
16100 !! html
16101 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16102 <ul>
16103 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16104 <ul>
16105 <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>
16106 <ul>
16107 <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>
16108 </ul>
16109 </li>
16110 <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>
16111 </ul>
16112 </li>
16113 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16114 <ul>
16115 <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>
16116 </ul>
16117 </li>
16118 </ul>
16119 </div>
16120
16121 <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>
16122 <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>
16123 <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>
16124 <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>
16125 <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>
16126 <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>
16127
16128 !! end
16129
16130 !! test
16131 TOC for heading containing <span id="..."></span> (T96153)
16132 !! wikitext
16133 __FORCETOC__
16134 ==<span id="old-anchor"></span>New title==
16135 !! html/php
16136 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16137 <ul>
16138 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
16139 </ul>
16140 </div>
16141
16142 <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>
16143
16144 !! end
16145
16146 !! test
16147 TOC with wgMaxTocLevel=3 (T8204)
16148 !! options
16149 wgMaxTocLevel=3
16150 !! wikitext
16151 == title 1 ==
16152 === title 1.1 ===
16153 ==== title 1.1.1 ====
16154 === title 1.2 ===
16155 == title 2 ==
16156 === title 2.1 ===
16157 !! html
16158 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16159 <ul>
16160 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16161 <ul>
16162 <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>
16163 <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>
16164 </ul>
16165 </li>
16166 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16167 <ul>
16168 <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>
16169 </ul>
16170 </li>
16171 </ul>
16172 </div>
16173
16174 <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>
16175 <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>
16176 <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>
16177 <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>
16178 <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>
16179 <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>
16180
16181 !! end
16182
16183 !! test
16184 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
16185 !! options
16186 wgMaxTocLevel=3
16187 !! wikitext
16188 ==Section 1==
16189 ===Section 1.1===
16190 ====Section 1.1.1====
16191 ====Section 1.1.1.1====
16192 ==Section 2==
16193 !! html
16194 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16195 <ul>
16196 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
16197 <ul>
16198 <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>
16199 </ul>
16200 </li>
16201 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
16202 </ul>
16203 </div>
16204
16205 <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>
16206 <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>
16207 <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>
16208 <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>
16209 <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>
16210
16211 !! end
16212
16213
16214 !! test
16215 Resolving duplicate section names
16216 !! wikitext
16217 == Foo bar ==
16218 == Foo bar ==
16219 !! html
16220 <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>
16221 <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>
16222
16223 !! end
16224
16225 !! test
16226 Resolving duplicate section names with differing case (T12721)
16227 !! wikitext
16228 == Foo bar ==
16229 == Foo Bar ==
16230 !! html
16231 <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>
16232 <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>
16233
16234 !! end
16235
16236 !! article
16237 Template:sections
16238 !! text
16239 ===Section 1===
16240 ==Section 2==
16241 !! endarticle
16242
16243 !! test
16244 Template with sections, __NOTOC__
16245 !! wikitext
16246 __NOTOC__
16247 ==Section 0==
16248 {{sections}}
16249 ==Section 4==
16250 !! html
16251 <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>
16252 <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>
16253 <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>
16254 <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>
16255
16256 !! end
16257
16258 !! test
16259 __NOEDITSECTION__ keyword
16260 !! wikitext
16261 __NOEDITSECTION__
16262 ==Section 1==
16263 ==Section 2==
16264 !! html
16265 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
16266 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
16267
16268 !! end
16269
16270 !! test
16271 Link inside a section heading
16272 !! wikitext
16273 ==Section with a [[Main Page|link]] in it==
16274 !! html
16275 <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>
16276
16277 !! end
16278
16279 !! test
16280 TOC regression (T14077)
16281 !! wikitext
16282 __TOC__
16283 == title 1 ==
16284 === title 1.1 ===
16285 == title 2 ==
16286 !! html
16287 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16288 <ul>
16289 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16290 <ul>
16291 <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>
16292 </ul>
16293 </li>
16294 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
16295 </ul>
16296 </div>
16297
16298 <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>
16299 <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>
16300 <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>
16301
16302 !! end
16303
16304 !! test
16305 T3219 URL next to image (good)
16306 !! wikitext
16307 http://example.com [[File:Foobar.jpg]]
16308 !! html/php
16309 <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>
16310 </p>
16311 !! html/parsoid
16312 <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>
16313 !!end
16314
16315 !! test
16316 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
16317 !! wikitext
16318 ===
16319 The line above must have a trailing space!
16320 === <!--
16321 --> <!-- -->
16322 But just in case it doesn't...
16323 !! html
16324 <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>
16325 <p>The line above must have a trailing space!
16326 </p>
16327 <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>
16328 <p>But just in case it doesn't...
16329 </p>
16330 !! end
16331
16332 !! test
16333 Header with special characters (T27462)
16334 !! wikitext
16335 The tooltips shall not show entities to the user (ie. be double escaped)
16336
16337 == text > text ==
16338 section 1
16339
16340 == text < text ==
16341 section 2
16342
16343 == text & text ==
16344 section 3
16345
16346 == text ' text ==
16347 section 4
16348
16349 == text " text ==
16350 section 5
16351 !! html
16352 <p>The tooltips shall not show entities to the user (ie. be double escaped)
16353 </p>
16354 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16355 <ul>
16356 <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>
16357 <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>
16358 <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>
16359 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
16360 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
16361 </ul>
16362 </div>
16363
16364 <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>
16365 <p>section 1
16366 </p>
16367 <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>
16368 <p>section 2
16369 </p>
16370 <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>
16371 <p>section 3
16372 </p>
16373 <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>
16374 <p>section 4
16375 </p>
16376 <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>
16377 <p>section 5
16378 </p>
16379 !! end
16380
16381 !! test
16382 Header with space, plus and underscore as entity
16383 !! wikitext
16384 Id should not contain + for spaces
16385
16386 == Space between Text ==
16387 section 1
16388
16389 == Space-Entity&#32;between&#32;Text ==
16390 section 2
16391
16392 == Plus+between+Text ==
16393 section 3
16394
16395 == Plus-Entity&#43;between&#43;Text ==
16396 section 4
16397
16398 == Underscore_between_Text ==
16399 section 5
16400
16401 == Underscore-Entity&#95;between&#95;Text ==
16402 section 6
16403
16404 [[#Space between Text]]
16405 [[#Space-Entity&#32;between&#32;Text]]
16406 [[#Plus+between+Text]]
16407 [[#Plus-Entity&#43;between&#43;Text]]
16408 [[#Underscore_between_Text]]
16409 [[#Underscore-Entity&#95;between&#95;Text]]
16410 !! html
16411 <p>Id should not contain + for spaces
16412 </p>
16413 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16414 <ul>
16415 <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>
16416 <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>
16417 <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>
16418 <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>
16419 <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>
16420 <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>
16421 </ul>
16422 </div>
16423
16424 <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>
16425 <p>section 1
16426 </p>
16427 <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>
16428 <p>section 2
16429 </p>
16430 <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>
16431 <p>section 3
16432 </p>
16433 <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>
16434 <p>section 4
16435 </p>
16436 <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>
16437 <p>section 5
16438 </p>
16439 <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>
16440 <p>section 6
16441 </p><p><a href="#Space_between_Text">#Space between Text</a>
16442 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
16443 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
16444 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
16445 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
16446 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
16447 </p>
16448 !! end
16449
16450 !! test
16451 Headers with excess '=' characters
16452 (Are similar tests necessary beyond the 1st level?)
16453 !! wikitext
16454 =foo==
16455 ==foo=
16456 =''italic'' heading==
16457 ==''italic'' heading=
16458 !! html
16459 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16460 <ul>
16461 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
16462 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
16463 <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>
16464 <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>
16465 </ul>
16466 </div>
16467
16468 <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>
16469 <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>
16470 <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>
16471 <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>
16472
16473 !! end
16474
16475 !! test
16476 HTML headers vs TOC (T25393)
16477 (__NOEDITSECTION__ for clearer output, doesn't matter here)
16478 !! wikitext
16479 <h1>Header 1</h1>
16480 == Header 1.1 ==
16481 == Header 1.2 ==
16482
16483 <h1>Header 2
16484 </h1>
16485 == Header 2.1 ==
16486 == Header 2.2 ==
16487 __NOEDITSECTION__
16488 !! html
16489 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16490 <ul>
16491 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
16492 <ul>
16493 <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>
16494 <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>
16495 </ul>
16496 </li>
16497 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
16498 <ul>
16499 <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>
16500 <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>
16501 </ul>
16502 </li>
16503 </ul>
16504 </div>
16505
16506 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
16507 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
16508 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
16509 <h1><span class="mw-headline" id="Header_2">Header 2</span></h1>
16510 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
16511 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
16512
16513 !! end
16514
16515 !! test
16516 Single-line or multiline-comments can follow headings
16517 !! options
16518 parsoid=wt2html,wt2wt
16519 !! wikitext
16520 ==foo==<!---->
16521 ==bar==<!--c1-->
16522 ==baz==<!--
16523 c2
16524 c3-->
16525 !! html
16526 <h2><span class="mw-headline" id="foo">foo</span></h2>
16527 <h2><span class="mw-headline" id="bar">bar</span></h2>
16528 <h2><span class="mw-headline" id="baz">baz</span></h2>
16529
16530 !! end
16531
16532 !! test
16533 T3219 URL next to image (broken)
16534 !! wikitext
16535 http://example.com[[File:Foobar.jpg]]
16536 !! html/php
16537 <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>
16538 </p>
16539 !! html/parsoid
16540 <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>
16541 !!end
16542
16543 !! test
16544 T3186 news: in the middle of text
16545 !! wikitext
16546 http://en.wikinews.org/wiki/Wikinews:Workplace
16547 !! html
16548 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
16549 </p>
16550 !!end
16551
16552
16553 !! test
16554 Namespaced link must have a title
16555 !! wikitext
16556 [[Project:]]
16557 !! html
16558 <p>[[Project:]]
16559 </p>
16560 !!end
16561
16562 !! test
16563 Namespaced link must have a title (bad fragment version)
16564 !! wikitext
16565 [[Project:#fragment]]
16566 !! html
16567 <p>[[Project:#fragment]]
16568 </p>
16569 !!end
16570
16571
16572 ###
16573 ### HTML tags and HTML attributes
16574 ###
16575
16576 !! test
16577 div with no attributes
16578 !! wikitext
16579 <div>HTML rocks</div>
16580 !! html
16581 <div>HTML rocks</div>
16582
16583 !! end
16584
16585 !! test
16586 div with double-quoted attribute
16587 !! wikitext
16588 <div id="rock">HTML rocks</div>
16589 !! html
16590 <div id="rock">HTML rocks</div>
16591
16592 !! end
16593
16594 !! test
16595 div with single-quoted attribute
16596 !! wikitext
16597 <div id='rock'>HTML rocks</div>
16598 !! html
16599 <div id="rock">HTML rocks</div>
16600
16601 !! end
16602
16603 !! test
16604 div with unquoted attribute
16605 !! wikitext
16606 <div id=rock>HTML rocks</div>
16607 !! html
16608 <div id="rock">HTML rocks</div>
16609
16610 !! end
16611
16612 !! test
16613 div with illegal double attributes
16614 !! wikitext
16615 <div id="a" id="b">HTML rocks</div>
16616 !! html
16617 <div id="b">HTML rocks</div>
16618
16619 !!end
16620
16621 !! test
16622 div with empty attribute value, space before equals
16623 !! options
16624 parsoid=wt2html,html2html
16625 !! wikitext
16626 <div class =>HTML rocks</div>
16627 !! html/php
16628 <div class="">HTML rocks</div>
16629
16630 !! html/parsoid
16631 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
16632 !! end
16633
16634 !! test
16635 div with multiple empty attribute values
16636 !! options
16637 parsoid=wt2html,html2html
16638 !! wikitext
16639 <div id= title=>HTML rocks</div>
16640 !! html/php
16641 <div id="title.3D">HTML rocks</div>
16642
16643 !! html/parsoid
16644 <div id="title.3D" data-parsoid='{"stx":"html"}'>HTML rocks</div>
16645 !! end
16646
16647 !! test
16648 table with multiple empty attribute values
16649 !! options
16650 parsoid=wt2html,html2html
16651 !! wikitext
16652 {| title= id=
16653 | hi
16654 |}
16655 !! html/php
16656 <table title="id=">
16657 <tr>
16658 <td> hi
16659 </td></tr></table>
16660
16661 !! html/parsoid
16662 <table title="id=">
16663 <tbody><tr><td> hi</td></tr>
16664 </tbody></table>
16665 !! end
16666
16667 !! test
16668 div with braces in attribute value
16669 !! wikitext
16670 <div title="{}">Foo</div>
16671 !! html/php
16672 <div title="&#123;&#125;">Foo</div>
16673
16674 !! html/parsoid
16675 <div title="{}">Foo</div>
16676 !! end
16677
16678 !! test
16679 div with empty attribute value, no space before equals
16680 !! options
16681 parsoid=wt2html,html2html
16682 !! wikitext
16683 <div class=>HTML rocks</div>
16684 !! html/php
16685 <div class="">HTML rocks</div>
16686
16687 !! html/parsoid
16688 <div class="">HTML rocks</div>
16689 !! end
16690
16691 !! test
16692 HTML multiple attributes correction
16693 !! wikitext
16694 <p class="error" class="awesome">Awesome!</p>
16695 !! html
16696 <p class="awesome">Awesome!</p>
16697
16698 !!end
16699
16700 !! test
16701 Table multiple attributes correction
16702 !! wikitext
16703 {|
16704 !+ class="error" class="awesome"| status
16705 |}
16706 !! html
16707 <table>
16708 <tr>
16709 <th class="awesome"> status
16710 </th></tr></table>
16711
16712 !!end
16713
16714 !! test
16715 DIV IN UPPERCASE
16716 !! wikitext
16717 <DIV ID="x">HTML ROCKS</DIV>
16718 !! html
16719 <div id="x">HTML ROCKS</div>
16720
16721 !!end
16722
16723 !! test
16724 Non-ASCII pseudo-tags are rendered as text
16725 !! wikitext
16726 <khyô>
16727 !! html
16728 <p>&lt;khyô&gt;
16729 </p>
16730 !! end
16731
16732 !! test
16733 Pseudo-tag with URL 'name' renders as url link
16734 !! wikitext
16735 <http://example.com/>
16736 !! html
16737 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
16738 </p>
16739 !! end
16740
16741 !! test
16742 text with amp in the middle of nowhere
16743 !! wikitext
16744 Remember AT&T?
16745 !! html
16746 <p>Remember AT&amp;T?
16747 </p>
16748 !! end
16749
16750 !! test
16751 text with character entity: eacute
16752 !! wikitext
16753 I always thought &eacute; was a cute letter.
16754 !! html
16755 <p>I always thought &#233; was a cute letter.
16756 </p>
16757 !! html+tidy
16758 <p>I always thought é was a cute letter.</p>
16759 !! end
16760
16761 !! test
16762 text with entity-escaped character entity-like string: eacute
16763 !! wikitext
16764 I always thought &amp;eacute; was a cute letter.
16765 !! html
16766 <p>I always thought &amp;eacute; was a cute letter.
16767 </p>
16768 !! end
16769
16770 !! test
16771 text with undefined character entity: xacute
16772 !! wikitext
16773 I always thought &xacute; was a cute letter.
16774 !! html
16775 <p>I always thought &amp;xacute; was a cute letter.
16776 </p>
16777 !! end
16778
16779 !! test
16780 HTML5 tags
16781 !! wikitext
16782 <data value="5">five</data>
16783 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
16784 <mark>This highlighted text</mark>
16785 !! html
16786 <p><data value="5">five</data>
16787 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
16788 <mark>This highlighted text</mark>
16789 </p>
16790 !! end
16791
16792 !! test
16793 HTML tag with leading space is parsed as text
16794 !! wikitext
16795 < div>foo< /div>
16796 !! html
16797 <p>&lt; div&gt;foo&lt; /div&gt;
16798 </p>
16799 !! end
16800
16801 ###
16802 ### Nesting tests (see T43545, T52604, T53081)
16803 ###
16804
16805 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
16806 # Note that html2wt is considerably more difficult if we use <b> in
16807 # the test case, instead of <small>
16808 !! test
16809 Ensure that HTML adoption agency algorithm is properly implemented.
16810 !! wikitext
16811 <small>X<small>Y</small>Z</small>
16812 !! html
16813 <p><small>X<small>Y</small>Z</small>
16814 </p>
16815 !! end
16816
16817 # This was T43545 in the PHP parser.
16818 # Note that tidy doesn't handle this correctly.
16819 !! test
16820 Nesting of <kbd>
16821 !! wikitext
16822 <kbd>X<kbd>Y</kbd>Z</kbd>
16823 !! html
16824 <p><kbd>X<kbd>Y</kbd>Z</kbd>
16825 </p>
16826 !! end
16827
16828 # The following cases were T53081 in the PHP parser.
16829 # Note that there are some other nestable tags (b, i, etc) which are
16830 # not covered; see T53081 for discussion.
16831
16832 # Note that tidy doesn't handle this correctly.
16833 !! test
16834 Nesting of <em>
16835 !! wikitext
16836 <em>X<em>Y</em>Z</em>
16837 !! html
16838 <p><em>X<em>Y</em>Z</em>
16839 </p>
16840 !! end
16841
16842 # Note that tidy doesn't handle this correctly.
16843 !! test
16844 Nesting of <strong>
16845 !! wikitext
16846 <strong>X<strong>Y</strong>Z</strong>
16847 !! html
16848 <p><strong>X<strong>Y</strong>Z</strong>
16849 </p>
16850 !! end
16851
16852 !! test
16853 Nesting of <q>
16854 !! wikitext
16855 <q>X<q>Y</q>Z</q>
16856 !! html+tidy
16857 <p><q>X<q>Y</q>Z</q></p>
16858 !! end
16859
16860 # Note that tidy doesn't handle this correctly.
16861 !! test
16862 Nesting of <ruby>
16863 !! wikitext
16864 <ruby>X<ruby>Y</ruby>Z</ruby>
16865 !! html
16866 <p><ruby>X<ruby>Y</ruby>Z</ruby>
16867 </p>
16868 !! end
16869
16870 # Note that tidy doesn't handle this correctly.
16871 !! test
16872 Nesting of <bdo>
16873 !! wikitext
16874 <bdo>X<bdo>Y</bdo>Z</bdo>
16875 !! html
16876 <p><bdo>X<bdo>Y</bdo>Z</bdo>
16877 </p>
16878 !! end
16879
16880
16881 ###
16882 ### Media links
16883 ###
16884
16885 !! test
16886 Media link
16887 !! wikitext
16888 [[Media:Foobar.jpg]]
16889 !! html/php
16890 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
16891 </p>
16892 !! html/parsoid
16893 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a></p>
16894 !! end
16895
16896 !! test
16897 Media link with text
16898 !! wikitext
16899 [[Media:Foobar.jpg|A neat file to look at]]
16900 !! html/php
16901 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
16902 </p>
16903 !! html/parsoid
16904 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
16905 !! end
16906
16907 # FIXME: this is still bad HTML tag nesting
16908 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
16909 !! test
16910 Media link with nasty text
16911 !! wikitext
16912 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
16913 !! html/php
16914 <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>
16915
16916 !! html+php/tidy
16917 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link</a></p>
16918 <div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div>
16919 !! html/parsoid
16920 <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>
16921
16922 !! end
16923
16924 !! test
16925 Media link to nonexistent file (T3702)
16926 !! wikitext
16927 [[Media:No such.jpg]]
16928 [[Media:No_such file.jpg]]
16929 !! html/php
16930 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
16931 <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>
16932 </p>
16933 !! html/parsoid
16934 <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>
16935 <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>
16936 !! end
16937
16938 !! test
16939 Image link to nonexistent file (T3850 - good)
16940 !! wikitext
16941 [[File:No_such.jpg]]
16942 !! html/php
16943 <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>
16944 </p>
16945 !! html/parsoid
16946 <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>
16947 !! end
16948
16949 !! test
16950 :Image link to nonexistent file (T3850 - bad)
16951 !! wikitext
16952 [[:Image:No such.jpg]]
16953 !! html/php
16954 <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>
16955 </p>
16956 !! html/parsoid
16957 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
16958 !! end
16959
16960
16961
16962 !! test
16963 Character reference normalization in link text (T3938)
16964 !! wikitext
16965 [[Main Page|this&that]]
16966 !! html
16967 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
16968 </p>
16969 !!end
16970
16971 !! article
16972 אַ
16973 !! text
16974 Test for unicode normalization
16975
16976 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
16977 !! endarticle
16978
16979 !! test
16980 (T21451) Links should refer to the normalized form.
16981 !! wikitext
16982 [[&#xFB2E;]]
16983 [[&#x5d0;&#x5b7;]]
16984 [[&#x5d0;ַ]]
16985 [[א&#x5b7;]]
16986 [[אַ]]
16987 !! html
16988 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
16989 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
16990 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
16991 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
16992 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
16993 </p>
16994 !! end
16995
16996 !! test
16997 Empty attribute crash test (T4067)
16998 !! wikitext
16999 <font color="">foo</font>
17000 !! html
17001 <p><font color="">foo</font>
17002 </p>
17003 !! end
17004
17005 !! test
17006 Empty attribute crash test single-quotes (T4067)
17007 !! wikitext
17008 <font color=''>foo</font>
17009 !! html
17010 <p><font color="">foo</font>
17011 </p>
17012 !! end
17013
17014 !! test
17015 Attribute test: equals, then nothing
17016 !! options
17017 parsoid=wt2html,html2html
17018 !! wikitext
17019 <font color=>foo</font>
17020 !! html/php
17021 <p><font color="">foo</font>
17022 </p>
17023 !! html/parsoid
17024 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
17025 !! end
17026
17027 !! test
17028 Attribute test: unquoted value
17029 !! options
17030 parsoid=wt2html,html2html
17031 !! wikitext
17032 <font color=x>foo</font>
17033 !! html/php
17034 <p><font color="x">foo</font>
17035 </p>
17036 !! html/parsoid
17037 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
17038 !! end
17039
17040 !! test
17041 Attribute test: unquoted but illegal value (hash)
17042 !! wikitext
17043 <font color=#x>foo</font>
17044 !! html
17045 <p><font color="#x">foo</font>
17046 </p>
17047 !! end
17048
17049 # Parsoid does not serialize to empty attribute syntax,
17050 # so wt2wt and html2wt cases are skipped
17051 !! test
17052 Attribute test: no value (T54330)
17053 !! options
17054 parsoid=wt2html,html2html
17055 !! wikitext
17056 <font color>foo</font>
17057 !! html/php
17058 <p><font color="">foo</font>
17059 </p>
17060 !! html/parsoid
17061 <p><font color="">foo</font></p>
17062 !! end
17063
17064 !! test
17065 T4095: link with three closing brackets
17066 !! wikitext
17067 [[Main Page]]]
17068 !! html/php
17069 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
17070 </p>
17071 !! html/parsoid
17072 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
17073 !! end
17074
17075 !! test
17076 T4095: link with pipe and three closing brackets
17077 !! wikitext
17078 [[Main Page|link]]]
17079 !! html/php
17080 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
17081 </p>
17082 !! html/parsoid
17083 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
17084 !! end
17085
17086 !! test
17087 T4095: link with pipe and three closing brackets, version 2
17088 !! wikitext
17089 [[Main Page|[http://example.com/]]]
17090 !! html/php
17091 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
17092 </p>
17093 !! html/parsoid
17094 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
17095 !! end
17096
17097
17098 ###
17099 ### Safety
17100 ###
17101
17102 !! article
17103 Template:Dangerous attribute
17104 !! text
17105 " onmouseover="alert(document.cookie)
17106 !! endarticle
17107
17108 !! article
17109 Template:Dangerous style attribute
17110 !! text
17111 border-size: expression(alert(document.cookie))
17112 !! endarticle
17113
17114 !! article
17115 Template:Div style
17116 !! text
17117 <div style="float: right; {{{1}}}">Magic div</div>
17118 !! endarticle
17119
17120 !! test
17121 T4304: HTML attribute safety (safe template; regression T4309)
17122 !! wikitext
17123 <div title="{{test}}"></div>
17124 !! html/php
17125 <div title="This is a test template"></div>
17126
17127 !! html/parsoid
17128 <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>
17129 !! end
17130
17131 # Parsoid has enough context to handle this case
17132 !! test
17133 T4304: HTML attribute safety (dangerous template; 2309)
17134 !! wikitext
17135 <div title="{{dangerous attribute}}"></div>
17136 !! html/php
17137 <div title=""></div>
17138
17139 !! html/parsoid
17140 <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>
17141 !! end
17142
17143 !! test
17144 T4304: HTML attribute safety (dangerous style template; 2309)
17145 !! wikitext
17146 <div style="{{dangerous style attribute}}"></div>
17147 !! html/php
17148 <div style="/* insecure input */"></div>
17149
17150 !! html/parsoid
17151 <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>
17152 !! end
17153
17154 !! test
17155 T4304: HTML attribute safety (safe parameter; 2309)
17156 !! wikitext
17157 {{div style|width: 200px}}
17158 !! html/php
17159 <div style="float: right; width: 200px">Magic div</div>
17160
17161 !! html/parsoid
17162 <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>
17163 !! end
17164
17165 !! test
17166 T4304: HTML attribute safety (unsafe parameter; 2309)
17167 !! wikitext
17168 {{div style|width: expression(alert(document.cookie))}}
17169 !! html/php
17170 <div style="/* insecure input */">Magic div</div>
17171
17172 !! html/parsoid
17173 <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>
17174 !! end
17175
17176 ## Parsoid output here differs; needs investigation.
17177 !! test
17178 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
17179 !! wikitext
17180 {{div style|"><script>alert(document.cookie)</script>}}
17181 !! html
17182 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17183
17184 !! end
17185
17186 ## Parsoid output here differs; needs investigation.
17187 !! test
17188 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
17189 !! wikitext
17190 {{div style|" ><script>alert(document.cookie)</script>}}
17191 !! html
17192 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17193
17194 !! end
17195
17196 !! test
17197 T4304: HTML attribute safety (link)
17198 !! wikitext
17199 <div title="[[Main Page]]"></div>
17200 !! html
17201 <div title="&#91;&#91;Main Page]]"></div>
17202
17203 !! end
17204
17205 !! test
17206 T4304: HTML attribute safety (italics)
17207 !! wikitext
17208 <div title="''foobar''"></div>
17209 !! html
17210 <div title="&#39;&#39;foobar&#39;&#39;"></div>
17211
17212 !! end
17213
17214 !! test
17215 T4304: HTML attribute safety (bold)
17216 !! wikitext
17217 <div title="'''foobar'''"></div>
17218 !! html
17219 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
17220
17221 !! end
17222
17223 !! test
17224 T4304: HTML attribute safety (ISBN)
17225 !! wikitext
17226 <div title="ISBN 1234567890"></div>
17227 !! html
17228 <div title="&#73;SBN 1234567890"></div>
17229
17230 !! end
17231
17232 !! test
17233 T4304: HTML attribute safety (RFC)
17234 !! wikitext
17235 <div title="RFC 1234"></div>
17236 !! html
17237 <div title="&#82;FC 1234"></div>
17238
17239 !! end
17240
17241 !! test
17242 T4304: HTML attribute safety (PMID)
17243 !! wikitext
17244 <div title="PMID 1234567890"></div>
17245 !! html
17246 <div title="&#80;MID 1234567890"></div>
17247
17248 !! end
17249
17250 !! test
17251 T4304: HTML attribute safety (web link)
17252 !! wikitext
17253 <div title="http://example.com/"></div>
17254 !! html
17255 <div title="http&#58;//example.com/"></div>
17256
17257 !! end
17258
17259 !! test
17260 T4304: HTML attribute safety (named web link)
17261 !! wikitext
17262 <div title="[http://example.com/ link]"></div>
17263 !! html
17264 <div title="&#91;http&#58;//example.com/ link]"></div>
17265
17266 !! end
17267
17268 !! test
17269 T5244: HTML attribute safety (extension; safe)
17270 !! wikitext
17271 <div style="<nowiki>background:blue</nowiki>"></div>
17272 !! html/php
17273 <div style="background:blue"></div>
17274
17275 !! html/parsoid
17276 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
17277 !! end
17278
17279 !! test
17280 T5244: HTML attribute safety (extension; unsafe)
17281 !! wikitext
17282 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
17283 !! html/php
17284 <div style="/* insecure input */"></div>
17285
17286 !! html/parsoid
17287 <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>
17288 !! end
17289
17290 # More MSIE fun discovered by Tom Gilder
17291
17292 !! test
17293 MSIE CSS safety test: spurious slash
17294 !! wikitext
17295 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
17296 !! html/php
17297 <div style="/* insecure input */">evil</div>
17298
17299 !! html/parsoid
17300 <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>
17301 !! end
17302
17303 !! test
17304 MSIE CSS safety test: hex code
17305 !! wikitext
17306 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
17307 !! html/php
17308 <div style="/* insecure input */">evil</div>
17309
17310 !! html/parsoid
17311 <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>
17312 !! end
17313
17314 !! test
17315 MSIE CSS safety test: comment in url
17316 !! wikitext
17317 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
17318 !! html/php
17319 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
17320
17321 !! html/parsoid
17322 <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>
17323 !! end
17324
17325 !! test
17326 MSIE CSS safety test: comment in expression
17327 !! wikitext
17328 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
17329 !! html/php
17330 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
17331
17332 !! html/parsoid
17333 <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>
17334 !! end
17335
17336 !! test
17337 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
17338 !! wikitext
17339 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
17340 !! html/php
17341 <p style="/* invalid control char */">A</p>
17342
17343 !! html/parsoid
17344 <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>
17345 !! end
17346
17347 !! test
17348 MSIE 6 CSS safety test: Fullwidth (T57332)
17349 !! wikitext
17350 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
17351 <div style="top:EXPRESSION(alert())">B</div>
17352 !! html/php
17353 <p style="/* insecure input */">A</p>
17354 <div style="/* insecure input */">B</div>
17355
17356 !! html/parsoid
17357 <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>
17358 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
17359 !! end
17360
17361 !! test
17362 MSIE 6 CSS safety test: IPA extensions (T57332)
17363 !! wikitext
17364 <div style="background-image:uʀʟ(javascript:alert())">A</div>
17365 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
17366 !! html/php
17367 <div style="/* insecure input */">A</div>
17368 <p style="/* insecure input */">B</p>
17369
17370 !! html/parsoid
17371 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
17372 <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>
17373 !! end
17374
17375 !! test
17376 MSIE 6 CSS safety test: sup/sub script (T57332)
17377 !! wikitext
17378 <div style="background-image:url⁽javascript:alert())">A</div>
17379 <div style="background-image:url₍javascript:alert())">B</div>
17380 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
17381 !! html/php
17382 <div style="/* insecure input */">A</div>
17383 <div style="/* insecure input */">B</div>
17384 <p style="/* insecure input */">C</p>
17385
17386 !! html/parsoid
17387 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
17388 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
17389 <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>
17390 !! end
17391
17392 !! test
17393 Opera -o-link CSS
17394 !! options
17395 parsoid=wt2html,html2html
17396 !! wikitext
17397 <div
17398 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;"
17399 style="-o-link:attr(title);-o-link-source:current">X</div>
17400 !! html/php
17401 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
17402
17403 !! html/parsoid
17404 <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>
17405 !! end
17406
17407 !! test
17408 MSIE 6 CSS safety test: Repetition markers (T57332)
17409 !! wikitext
17410 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
17411 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
17412 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
17413 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
17414 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
17415 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
17416 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
17417 !! html/php
17418 <p style="/* insecure input */">A</p>
17419 <p style="/* insecure input */">B</p>
17420 <p style="/* insecure input */">C</p>
17421 <p style="/* insecure input */">D</p>
17422 <p style="/* insecure input */">E</p>
17423 <p style="/* insecure input */">F</p>
17424 <p style="/* insecure input */">G</p>
17425
17426 !! html/parsoid
17427 <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>
17428 <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>
17429 <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>
17430 <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>
17431 <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>
17432 <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>
17433 <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>
17434 !! end
17435
17436 !! test
17437 Table attribute legitimate extension
17438 !! wikitext
17439 {|
17440 !+ style="<nowiki>color:blue</nowiki>"| status
17441 |}
17442 !! html
17443 <table>
17444 <tr>
17445 <th style="color:blue"> status
17446 </th></tr></table>
17447
17448 !!end
17449
17450 !! test
17451 Table attribute safety
17452 !! wikitext
17453 {|
17454 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
17455 |}
17456 !! html
17457 <table>
17458 <tr>
17459 <th style="/* insecure input */"> status
17460 </th></tr></table>
17461
17462 !! end
17463
17464 !! test
17465 CSS line continuation 1
17466 !! wikitext
17467 <div style="background-image: u\&#10;rl(test.jpg);"></div>
17468 !! html
17469 <div style="/* insecure input */"></div>
17470
17471 !! end
17472
17473 !! test
17474 CSS line continuation 2
17475 !! wikitext
17476 <div style="background-image: u\&#13;rl(test.jpg); "></div>
17477 !! html
17478 <div style="/* invalid control char */"></div>
17479
17480 !! end
17481
17482 !! article
17483 Template:Identity
17484 !! text
17485 {{{1}}}
17486 !! endarticle
17487
17488 !! test
17489 Expansion of multi-line templates in attribute values (T8255)
17490 !! wikitext
17491 <div style="background: {{identity|#00FF00}}">-</div>
17492 !! html
17493 <div style="background: #00FF00">-</div>
17494
17495 !! end
17496
17497 !! test
17498 Expansion of multi-line templates in attribute values (T8255 sanity check)
17499 !! wikitext
17500 <div style="background:
17501 #00FF00">-</div>
17502 !! html/php
17503 <div style="background: #00FF00">-</div>
17504
17505 !! html/parsoid
17506 <div style="background:
17507 #00FF00">-</div>
17508 !! end
17509
17510 !! test
17511 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
17512 !! wikitext
17513 <div style="background: &#10;#00FF00">-</div>
17514 !! html
17515 <div style="background: &#10;#00FF00">-</div>
17516
17517 !! end
17518
17519 !! test
17520 Tags which are hidden from Tidy cannot pass through the Sanitizer
17521 !! wikitext
17522 <mw:toc><script>alert();</script></mw:toc>
17523 !! html+tidy
17524 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;</p>
17525 !! end
17526
17527 ###
17528 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
17529 ###
17530
17531 !! test
17532 Parser hook: empty input
17533 !! wikitext
17534 <tag></tag>
17535 !! html/php
17536 <pre>
17537 ''
17538 array (
17539 )
17540 </pre>
17541
17542 !! html/parsoid
17543 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17544 !! end
17545
17546 ## Don't expect parsoid to rt this form.
17547 !! test
17548 Parser hook: empty input using terminated empty elements
17549 !! options
17550 parsoid=wt2html,html2html
17551 !! wikitext
17552 <tag/>
17553 !! html/php
17554 <pre>
17555 NULL
17556 array (
17557 )
17558 </pre>
17559
17560 !! html/parsoid
17561 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
17562 !! end
17563
17564 !! test
17565 Parser hook: empty input using terminated empty elements (space before)
17566 !! wikitext
17567 <tag />
17568 !! html/php
17569 <pre>
17570 NULL
17571 array (
17572 )
17573 </pre>
17574
17575 !! html/parsoid
17576 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
17577 !! end
17578
17579 !! test
17580 Parser hook: basic input
17581 !! wikitext
17582 <tag>input</tag>
17583 !! html/php
17584 <pre>
17585 'input'
17586 array (
17587 )
17588 </pre>
17589
17590 !! html/parsoid
17591 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
17592 !! end
17593
17594 ## Don't expect parsoid to rt this form.
17595 !! test
17596 Parser hook: case insensitive
17597 !! options
17598 parsoid=wt2html,html2html
17599 !! wikitext
17600 <TAG>input</TAG>
17601 !! html/php
17602 <pre>
17603 'input'
17604 array (
17605 )
17606 </pre>
17607
17608 !! html/parsoid
17609 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
17610 !! end
17611
17612 ## Don't expect parsoid to rt this form.
17613 !! test
17614 Parser hook: case insensitive, redux
17615 !! options
17616 parsoid=wt2html,html2html
17617 !! wikitext
17618 <TaG>input</TAg>
17619 !! html/php
17620 <pre>
17621 'input'
17622 array (
17623 )
17624 </pre>
17625
17626 !! html/parsoid
17627 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
17628 !! end
17629
17630 !! test
17631 Parser hook: nested tags
17632 !! wikitext
17633 <tag><tag></tag></tag>
17634 !! html/php
17635 <pre>
17636 '<tag>'
17637 array (
17638 )
17639 </pre>&lt;/tag&gt;
17640
17641 !! html/parsoid
17642 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}' data-parsoid='{}' about="#mwt2"></pre>&lt;/tag>
17643 !! end
17644
17645 !! test
17646 Parser hook: basic arguments
17647 !! wikitext
17648 <tag width="200" height="100" depth="50" square=""></tag>
17649 !! html/php
17650 <pre>
17651 ''
17652 array (
17653 'width' => '200',
17654 'height' => '100',
17655 'depth' => '50',
17656 'square' => '',
17657 )
17658 </pre>
17659
17660 !! html/parsoid
17661 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17662 !! end
17663
17664 ## Don't expect parsoid to rt this form.
17665 !! test
17666 Parser hook: basic arguments, variations
17667 !! options
17668 parsoid=wt2html,html2html
17669 !! wikitext
17670 <tag width=200 height = "100" depth = '50' square></tag>
17671 !! html/php
17672 <pre>
17673 ''
17674 array (
17675 'width' => '200',
17676 'height' => '100',
17677 'depth' => '50',
17678 'square' => '',
17679 )
17680 </pre>
17681
17682 !! html/parsoid
17683 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17684 !! end
17685
17686 !! test
17687 Parser hook: argument containing a forward slash (T7344)
17688 !! wikitext
17689 <tag filename="/tmp/bla"></tag>
17690 !! html/php
17691 <pre>
17692 ''
17693 array (
17694 'filename' => '/tmp/bla',
17695 )
17696 </pre>
17697
17698 !! html/parsoid
17699 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17700 !! end
17701
17702 ## Don't expect parsoid to rt this form.
17703 !! test
17704 Parser hook: empty input using terminated empty elements (T4374)
17705 !! options
17706 parsoid=wt2html,html2html
17707 !! wikitext
17708 <tag foo=bar/>text
17709 !! html/php
17710 <pre>
17711 NULL
17712 array (
17713 'foo' => 'bar',
17714 )
17715 </pre>text
17716
17717 !! html/parsoid
17718 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text
17719 !! end
17720
17721 ## </tag> should be output literally since there is no matching tag that begins it
17722 ## Don't expect parsoid to rt this form.
17723 !! test
17724 Parser hook: basic arguments using terminated empty elements (T4374)
17725 !! options
17726 parsoid=wt2html
17727 !! wikitext
17728 <tag width=200 height = "100" depth = '50' square/>
17729 other stuff
17730 </tag>
17731 !! html/php
17732 <pre>
17733 NULL
17734 array (
17735 'width' => '200',
17736 'height' => '100',
17737 'depth' => '50',
17738 'square' => '',
17739 )
17740 </pre>
17741 <p>other stuff
17742 &lt;/tag&gt;
17743 </p>
17744 !! html/parsoid
17745 <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
17746 &lt;/tag></p>
17747 !! end
17748
17749 ## Don't expect parsoid to rt this form.
17750 !! test
17751 Parser hook: Don't allow unclosed extension tags
17752 !! options
17753 parsoid=wt2html
17754 !! wikitext
17755 test <tag>123
17756
17757 this is a '''test'''
17758 !! html/php
17759 <p>test &lt;tag&gt;123
17760 </p><p>this is a <b>test</b>
17761 </p>
17762 !! html/parsoid
17763 <p>test &lt;tag>123</p>
17764
17765 <p>this is a <b>test</b></p>
17766 !! end
17767
17768 ###
17769 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
17770 ###
17771
17772 !! test
17773 Parser hook: static parser hook not inside a comment
17774 !! wikitext
17775 <statictag>hello, world</statictag>
17776
17777 <statictag action="flush" />
17778 !! html/php
17779 <p><br />
17780 hello, world
17781 </p>
17782 !! html/parsoid
17783 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
17784 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p>
17785 !! end
17786
17787 !! test
17788 Parser hook: static parser hook inside a comment
17789 !! wikitext
17790 <!-- <statictag>hello, world</statictag> -->
17791 <statictag action="flush" />
17792 !! html/php
17793 <p><br />
17794 </p>
17795 !! html/parsoid
17796 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
17797 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt2"></p>
17798 !! end
17799
17800 # Nested template calls; this case was broken by Parser.php rev 1.506,
17801 # since reverted.
17802
17803 !! article
17804 Template:One-parameter
17805 !! text
17806 (My parameter is: {{{1}}})
17807 !! endarticle
17808
17809 !! article
17810 Template:Map-one-parameter
17811 !! text
17812 {{{{{1}}}|{{{2}}}}}
17813 !! endarticle
17814
17815 !! test
17816 Nested template calls
17817 !! wikitext
17818 {{Map-one-parameter|One-parameter|param}}
17819 !! html
17820 <p>(My parameter is: param)
17821 </p>
17822 !! end
17823
17824
17825 ###
17826 ### Sanitizer
17827 ###
17828
17829 # HTML+Tidy effectively strips out the empty tags completely
17830 # But since Parsoid doesn't it wraps the <s></s> tags in p-tags
17831 # which Tidy would have done for the PHP parser had there been content inside it.
17832 !! test
17833 Sanitizer: Closing of open tags
17834 !! wikitext
17835 <s></s><table></table>
17836 !! html
17837 <s></s><table></table>
17838
17839 !! html/parsoid
17840 <p><s></s></p><table></table>
17841 !! end
17842
17843 !! test
17844 Sanitizer: Closing of open but not closed tags
17845 !! wikitext
17846 <s>foo
17847 !! html
17848 <p><s>foo</s>
17849 </p>
17850 !! end
17851
17852 !! test
17853 Sanitizer: Closing of closed but not open tags
17854 !! options
17855 parsoid=wt2html
17856 !! wikitext
17857 </s>
17858 !! html/php+tidy
17859 !! html/parsoid
17860 !! end
17861
17862 !! test
17863 Sanitizer: Closing of closed but not open table tags
17864 !! options
17865 parsoid=wt2html
17866 !! wikitext
17867 Table not started</td></tr></table>
17868 !! html/php+tidy
17869 <p>Table not started</p>
17870 !! html/parsoid
17871 <p>Table not started</p>
17872 !! end
17873
17874 !! test
17875 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
17876 !! wikitext
17877 <span id="æ: v">byte</span>[[#æ: v|backlink]]
17878 !! html/php
17879 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
17880 </p>
17881 !! html/parsoid
17882 <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>
17883 !! end
17884
17885 # In HTML5, the restrictions are that id must contain at least one character,
17886 # and must not contain any space characters.
17887 !! test
17888 Sanitizer: Validating the contents of the id attribute (T6515)
17889 !! options
17890 disabled
17891 !! wikitext
17892 <br id="" /><br id="a space" />
17893 !! html
17894 Something ...
17895 !! end
17896
17897 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
17898 !! test
17899 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
17900 !! options
17901 disabled
17902 !! wikitext
17903 <br id="foo" /><br id="foo" />
17904 !! html
17905 Something need to be done. foo-2 ?
17906 !! end
17907
17908 !! test
17909 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
17910 !! wikitext
17911 <div itemscope>
17912 <meta itemprop="hello" content="world">
17913 <meta http-equiv="refresh" content="5">
17914 <meta itemprop="hello" http-equiv="refresh" content="5">
17915 <link itemprop="hello" href="{{SERVER}}">
17916 <link rel="stylesheet" href="{{SERVER}}">
17917 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
17918 </div>
17919 !! html
17920 <div itemscope="">
17921 <p> <meta itemprop="hello" content="world" />
17922 &lt;meta http-equiv="refresh" content="5"&gt;
17923 <meta itemprop="hello" content="5" />
17924 <link itemprop="hello" href="http&#58;//example.org" />
17925 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
17926 <link itemprop="hello" href="http&#58;//example.org" />
17927 </p>
17928 </div>
17929
17930 !! end
17931
17932 !! test
17933 Sanitizer: Strip comments from CSS attributes
17934 !! options
17935 parsoid=wt2html,wt2wt
17936 !! wikitext
17937 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
17938 !! html/php
17939 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
17940 </p>
17941 !! html/parsoid
17942 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
17943 !! end
17944
17945 !! test
17946 Language converter: output gets cut off unexpectedly (T7757)
17947 !! options
17948 language=zh
17949 !! wikitext
17950 this bit is safe: }-
17951
17952 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
17953
17954 then we get cut off here: }-
17955
17956 all additional text is vanished
17957 !! html
17958 <p>this bit is safe: }-
17959 </p><p>but if we add a conversion instance: xxx
17960 </p><p>then we get cut off here: }-
17961 </p><p>all additional text is vanished
17962 </p>
17963 !! end
17964
17965 !! test
17966 Self closed html pairs (T7487)
17967 !! wikitext
17968 <center><font id="bug" />Centered text</center>
17969 <div><font id="bug2" />In div text</div>
17970 !! html+tidy
17971 <center><font id="bug"></font>Centered text</center>
17972 <div><font id="bug2"></font>In div text</div>
17973 !! end
17974
17975 #
17976 #
17977 #
17978
17979 !! test
17980 Punctuation: nbsp before exclamation
17981 !! wikitext
17982 C'est grave !
17983 !! html
17984 <p>C'est grave&#160;!
17985 </p>
17986 !! end
17987
17988 !! test
17989 Punctuation: CSS !important (T13874)
17990 !! wikitext
17991 <div style="width:50% !important">important</div>
17992 !! html
17993 <div style="width:50% !important">important</div>
17994
17995 !!end
17996
17997 !! test
17998 Punctuation: CSS ! important (T13874; with space after)
17999 !! wikitext
18000 <div style="width:50% ! important">important</div>
18001 !! html
18002 <div style="width:50% ! important">important</div>
18003
18004 !!end
18005
18006 !! test
18007 HTML bullet list, closed tags (T7497)
18008 !! wikitext
18009 <ul>
18010 <li>One</li>
18011 <li>Two</li>
18012 </ul>
18013 !! html/php
18014 <ul>
18015 <li>One</li>
18016 <li>Two</li>
18017 </ul>
18018
18019 !! html/parsoid
18020 <ul data-parsoid='{"stx":"html"}'>
18021 <li data-parsoid='{"stx":"html"}'>One</li>
18022 <li data-parsoid='{"stx":"html"}'>Two</li>
18023 </ul>
18024
18025 !! end
18026
18027 !! test
18028 HTML bullet list, unclosed tags (T7497)
18029 !! wikitext
18030 <ul>
18031 <li>One
18032 <li>Two
18033 </ul>
18034 !! html/php+tidy
18035 <ul>
18036 <li>One</li>
18037 <li>Two</li>
18038 </ul>
18039 !! html/parsoid
18040 <ul data-parsoid='{"stx":"html"}'>
18041 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18042 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18043 </ul>
18044
18045 !! end
18046
18047 !! test
18048 HTML ordered list, closed tags (T7497)
18049 !! wikitext
18050 <ol>
18051 <li>One</li>
18052 <li>Two</li>
18053 </ol>
18054 !! html/php
18055 <ol>
18056 <li>One</li>
18057 <li>Two</li>
18058 </ol>
18059
18060 !! html/parsoid
18061 <ol data-parsoid='{"stx":"html"}'>
18062 <li data-parsoid='{"stx":"html"}'>One</li>
18063 <li data-parsoid='{"stx":"html"}'>Two</li>
18064 </ol>
18065
18066 !! end
18067
18068 !! test
18069 HTML ordered list, unclosed tags (T7497)
18070 !! options
18071 !! wikitext
18072 <ol>
18073 <li>One
18074 <li>Two
18075 </ol>
18076 !! html/php+tidy
18077 <ol>
18078 <li>One</li>
18079 <li>Two</li>
18080 </ol>
18081 !! html/parsoid
18082 <ol data-parsoid='{"stx":"html"}'>
18083 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18084 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18085 </ol>
18086
18087 !! end
18088
18089 !! test
18090 HTML nested bullet list, closed tags (T7497)
18091 !! wikitext
18092 <ul>
18093 <li>One</li>
18094 <li>Two:
18095 <ul>
18096 <li>Sub-one</li>
18097 <li>Sub-two</li>
18098 </ul>
18099 </li>
18100 </ul>
18101 !! html/php
18102 <ul>
18103 <li>One</li>
18104 <li>Two:
18105 <ul>
18106 <li>Sub-one</li>
18107 <li>Sub-two</li>
18108 </ul>
18109 </li>
18110 </ul>
18111
18112 !! html/parsoid
18113 <ul data-parsoid='{"stx":"html"}'>
18114 <li data-parsoid='{"stx":"html"}'>One</li>
18115 <li data-parsoid='{"stx":"html"}'>Two:
18116 <ul data-parsoid='{"stx":"html"}'>
18117 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
18118 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
18119 </ul>
18120 </li>
18121 </ul>
18122 !! end
18123
18124 !! test
18125 HTML nested bullet list, open tags (T7497)
18126 !! wikitext
18127 <ul>
18128 <li>One
18129 <li>Two:
18130 <ul>
18131 <li>Sub-one
18132 <li>Sub-two
18133 </ul>
18134 </ul>
18135 !! html/php+tidy
18136 <ul>
18137 <li>One</li>
18138 <li>Two:
18139 <ul>
18140 <li>Sub-one</li>
18141 <li>Sub-two</li>
18142 </ul>
18143 </li>
18144 </ul>
18145 !! html/parsoid
18146 <ul>
18147 <li>One
18148 </li>
18149 <li>Two:
18150 <ul>
18151 <li>Sub-one
18152 </li>
18153 <li>Sub-two
18154 </li>
18155 </ul>
18156 </li>
18157 </ul>
18158
18159 !! end
18160
18161 !! test
18162 HTML nested ordered list, closed tags (T7497)
18163 !! wikitext
18164 <ol>
18165 <li>One</li>
18166 <li>Two:
18167 <ol>
18168 <li>Sub-one</li>
18169 <li>Sub-two</li>
18170 </ol>
18171 </li>
18172 </ol>
18173 !! html
18174 <ol>
18175 <li>One</li>
18176 <li>Two:
18177 <ol>
18178 <li>Sub-one</li>
18179 <li>Sub-two</li>
18180 </ol>
18181 </li>
18182 </ol>
18183
18184 !! end
18185
18186 !! test
18187 HTML nested ordered list, open tags (T7497)
18188 !! wikitext
18189 <ol>
18190 <li>One
18191 <li>Two:
18192 <ol>
18193 <li>Sub-one
18194 <li>Sub-two
18195 </ol>
18196 </ol>
18197 !! html/php
18198 <ol>
18199 <li>One
18200 <li>Two:
18201 <ol>
18202 <li>Sub-one
18203 <li>Sub-two
18204 </ol>
18205 </ol>
18206
18207 !! html/parsoid
18208 <ol>
18209 <li>One
18210 </li>
18211 <li>Two:
18212 <ol>
18213 <li>Sub-one
18214 </li>
18215 <li>Sub-two
18216 </li>
18217 </ol>
18218 </li>
18219 </ol>
18220
18221 !! end
18222
18223 !! test
18224 HTML ordered list item with parameters oddity
18225 !! wikitext
18226 <ol><li id="fragment">One</li>
18227 </ol>
18228 !! html
18229 <ol><li id="fragment">One</li>
18230 </ol>
18231
18232 !! end
18233
18234 # parsoid doesn't explicitly mark autonumbered links, see T55505
18235 !!test
18236 T7918: autonumbering
18237 !! wikitext
18238 [http://first/] [http://second] [ftp://ftp]
18239
18240 ftp://inlineftp
18241
18242 [mailto:enclosed@mail.tld With target]
18243
18244 [mailto:enclosed@mail.tld]
18245
18246 mailto:inline@mail.tld
18247 !! html/php
18248 <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>
18249 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
18250 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
18251 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
18252 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
18253 </p>
18254 !! html/parsoid
18255 <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>
18256 <p><a rel="mw:ExtLink" href="ftp://inlineftp">ftp://inlineftp</a></p>
18257 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld">With target</a></p>
18258 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld"></a></p>
18259 <p><a rel="mw:ExtLink" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
18260 !! end
18261
18262
18263 #
18264 # Security and HTML correctness
18265 # From Nick Jenkins' fuzz testing
18266 #
18267
18268 !! test
18269 Fuzz testing: Parser13
18270 !! wikitext
18271 {|
18272 | http://a|
18273 !! html
18274 <table>
18275 <tr>
18276 <td>
18277 </td>
18278 </tr>
18279 </table>
18280
18281 !! end
18282
18283 !! test
18284 Fuzz testing: Parser14
18285 !! wikitext
18286 == onmouseover= ==
18287 http://__TOC__
18288 !! html
18289 <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>
18290 http://<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
18291 <ul>
18292 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18293 </ul>
18294 </div>
18295
18296
18297 !! html+tidy
18298 <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>
18299 <p>http://</p>
18300 <div id="toc" class="toc">
18301 <div class="toctitle">
18302 <h2>Contents</h2>
18303 </div>
18304 <ul>
18305 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18306 </ul>
18307 </div>
18308 <p></p>
18309 !! end
18310
18311 !! test
18312 Fuzz testing: Parser14-table
18313 !! options
18314 parsoid=wt2html,html2html
18315 !! wikitext
18316 ==a==
18317 {| STYLE=__TOC__
18318 !! html
18319 <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>
18320 <table style="&#95;_TOC&#95;_">
18321 <tr><td></td></tr>
18322 </table>
18323
18324 !! html+tidy
18325 <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>
18326 <table style="__TOC__">
18327 <tr>
18328 <td></td>
18329 </tr>
18330 </table>
18331 !! html/parsoid
18332 <h2>a</h2>
18333 <table style="__TOC__"></table>
18334 !! end
18335
18336 # Known to produce bogus xml (extra </td>)
18337 !! test
18338 Fuzz testing: Parser16
18339 !! wikitext
18340 {|
18341 !https://||||||
18342 !! html
18343 <table>
18344 <tr>
18345 <th>https://</th>
18346 <th></th>
18347 <th></th>
18348 <th>
18349 </td>
18350 </tr>
18351 </table>
18352
18353 !! html+tidy
18354 <table>
18355 <tr>
18356 <th>https://</th>
18357 <th></th>
18358 <th></th>
18359 <th></th>
18360 </tr>
18361 </table>
18362 !! end
18363
18364 !! test
18365 Fuzz testing: Parser21
18366 !! wikitext
18367 {|
18368 ! irc://{{ftp://a" onmouseover="alert('hello world');"
18369 |
18370 !! html
18371 <table>
18372 <tr>
18373 <th> <a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
18374 </th>
18375 <td>
18376 </td>
18377 </tr>
18378 </table>
18379
18380 !! end
18381
18382 !! test
18383 Fuzz testing: Parser22
18384 !! wikitext
18385 http://===r:::https://b
18386
18387 {|
18388 !! html
18389 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
18390 </p>
18391 <table>
18392 <tr><td></td></tr>
18393 </table>
18394
18395 !! end
18396
18397 # Known to produce bad XML for now
18398 !! test
18399 Fuzz testing: Parser24
18400 !! options
18401 parsoid=wt2html
18402 !! wikitext
18403 {|
18404 {{{|
18405 <u CLASS=
18406 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
18407 <br style="onmouseover='alert(document.cookie);' " />
18408
18409 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
18410 |
18411 !! html/php
18412 <table>
18413 {{{|
18414 <u class="&#124;">}}}} &gt;
18415 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
18416
18417 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
18418 <tr>
18419 <td></u>
18420 </td>
18421 </tr>
18422 </table>
18423
18424 !! html/parsoid
18425 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
18426 <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>"}'/>}}}} >
18427 <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}'>
18428
18429
18430
18431 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table>
18432 !! end
18433
18434 # Note: the current result listed for this is not what the original one was,
18435 # but the original bug was JavaScript injection, which is fixed in any case.
18436 # It's not clear that the original result listed was any more correct than the
18437 # current one. Original result:
18438 # <p>{{{|
18439 # </p>
18440 # <li class="&#124;&#124;">
18441 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
18442 !!test
18443 Fuzz testing: Parser25 (T8055)
18444 !! wikitext
18445 {{{
18446 |
18447 <LI CLASS=||
18448 >
18449 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
18450 !! html/php
18451 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
18452 </p>
18453 !! html/parsoid
18454 <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"]}'>
18455 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
18456 !! end
18457
18458 !!test
18459 Fuzz testing: URL adjacent extension (with space, clean)
18460 !! wikitext
18461 http://example.com <nowiki>junk</nowiki>
18462 !! html/php
18463 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
18464 </p>
18465 !! html/parsoid
18466 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a> <span typeof="mw:Nowiki">junk</span></p>
18467 !! end
18468
18469 !!test
18470 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
18471 !! wikitext
18472 http://example.com<nowiki>junk</nowiki>
18473 !! html/php
18474 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
18475 </p>
18476 !! html/parsoid
18477 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a><span typeof="mw:Nowiki">junk</span></p>
18478 !! end
18479
18480 !! test
18481 Fuzz testing: URL adjacent extension (no space, dirty; pre)
18482 !! wikitext
18483 http://example.com<pre>junk</pre>
18484 !! html/php
18485 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
18486
18487 !! html/php+tidy
18488 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p>
18489 <pre>
18490 junk
18491 </pre>
18492 !! html/parsoid
18493 <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>
18494 !! end
18495
18496 !! test
18497 Fuzz testing: image with bogus manual thumbnail
18498 !! wikitext
18499 [[Image:foobar.jpg|thumbnail= ]]
18500 !! html/php
18501 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
18502
18503 !! html/parsoid
18504 <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>
18505 !! end
18506
18507 !! test
18508 Fuzz testing: encoded newline in generated HTML replacements (T8577)
18509 !! wikitext
18510 <pre dir="&#10;"></pre>
18511 !! html/php
18512 <pre dir="&#10;"></pre>
18513
18514 !! html/parsoid
18515 <pre typeof="mw:Extension/pre" about="#mwt2" dir="&amp;#10;" data-mw='{"name":"pre","attrs":{"dir":"&amp;#10;"},"body":{"extsrc":""}}'></pre>
18516 !! end
18517
18518 !! test
18519 Parsing optional HTML elements (T8171)
18520 !! options
18521 !! wikitext
18522 <table>
18523 <tr>
18524 <td> Some tabular data</td>
18525 <td> More tabular data ...
18526 <td> And yet som tabular data</td>
18527 </tr>
18528 </table>
18529 !! html
18530 <table>
18531 <tr>
18532 <td> Some tabular data</td>
18533 <td> More tabular data ...
18534 </td><td> And yet som tabular data</td>
18535 </tr>
18536 </table>
18537
18538 !! end
18539
18540 !! test
18541 Correct handling of <td>, <tr> (T8171)
18542 !! options
18543 !! wikitext
18544 <table>
18545 <tr>
18546 <td> Some tabular data</td>
18547 <td> More tabular data ...</td>
18548 <td> And yet som tabular data</td>
18549 </tr>
18550 </table>
18551 !! html
18552 <table>
18553 <tr>
18554 <td> Some tabular data</td>
18555 <td> More tabular data ...</td>
18556 <td> And yet som tabular data</td>
18557 </tr>
18558 </table>
18559
18560 !! end
18561
18562
18563 !! test
18564 Parsing crashing regression (fr:JavaScript)
18565 !! wikitext
18566 </body></x>
18567 !! html
18568 <p>&lt;/body&gt;&lt;/x&gt;
18569 </p>
18570 !! end
18571
18572 !! test
18573 Inline wiki vs wiki block nesting
18574 !! wikitext
18575 '''Bold paragraph
18576
18577 New wiki paragraph
18578 !! html
18579 <p><b>Bold paragraph</b>
18580 </p><p>New wiki paragraph
18581 </p>
18582 !! end
18583
18584 # FIXME: The current php output is documented
18585 # and desired output is the parsoid target.
18586 !! test
18587 Inline HTML vs wiki block nesting
18588 !! wikitext
18589 <b>Bold paragraph
18590
18591 New wiki paragraph
18592 !! html/php
18593 <p><b>Bold paragraph
18594 </p><p>New wiki paragraph</b>
18595 </p>
18596 !! html/parsoid
18597 <p><b>Bold paragraph</b>
18598 </p><p>New wiki paragraph
18599 </p>
18600 !! end
18601
18602 # Original result was this:
18603 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
18604 # </p>
18605 # While that might be marginally more intuitive, maybe, the six-apostrophe
18606 # construct is clearly pathological and the result stated here (which is what
18607 # the parser actually does) is about as reasonable as anything.
18608 !!test
18609 Mixing markup for italics and bold
18610 !! options
18611 !! wikitext
18612 '''bold''''''bold''bolditalics'''''
18613 !! html
18614 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
18615 </p>
18616 !! end
18617
18618
18619 !! article
18620 Xyzzyx
18621 !! text
18622 Article for special page transclusion test
18623 !! endarticle
18624
18625 !! test
18626 Special page transclusion
18627 !! options
18628 !! wikitext
18629 {{Special:Prefixindex/Xyzzyx}}
18630 !! html
18631 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
18632 </ul>
18633
18634 !! end
18635
18636 !! test
18637 Special page transclusion twice (T7021)
18638 !! options
18639 !! wikitext
18640 {{Special:Prefixindex/Xyzzyx}}
18641 {{Special:Prefixindex/Xyzzyx}}
18642 !! html
18643 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
18644 </ul>
18645 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
18646 </ul>
18647
18648 !! end
18649
18650 !! test
18651 Transclusion of default MediaWiki message
18652 !! wikitext
18653 {{MediaWiki:Mainpage}}
18654 !! html
18655 <p>Main Page
18656 </p>
18657 !! end
18658
18659 !! test
18660 Transclusion of nonexistent MediaWiki message
18661 !! wikitext
18662 {{MediaWiki:Mainpagexxx}}
18663 !! html
18664 <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>
18665 </p>
18666 !! end
18667
18668 !! test
18669 Transclusion of MediaWiki message with underscore
18670 !! wikitext
18671 {{MediaWiki:history_short}}
18672 !! html
18673 <p>History
18674 </p>
18675 !! end
18676
18677 !! test
18678 Transclusion of MediaWiki message with space
18679 !! wikitext
18680 {{MediaWiki:history short}}
18681 !! html
18682 <p>History
18683 </p>
18684 !! end
18685
18686 !! test
18687 Invalid header with following text
18688 !! wikitext
18689 = x = y
18690 !! html
18691 <p>= x = y
18692 </p>
18693 !! end
18694
18695
18696 !! test
18697 Section extraction test (section 0)
18698 !! options
18699 section=0
18700 !! wikitext
18701 start
18702 ==a==
18703 ===aa===
18704 ====aaa====
18705 ==b==
18706 ===ba===
18707 ===bb===
18708 ====bba====
18709 ===bc===
18710 ==c==
18711 ===ca===
18712 !! html/php
18713 start
18714 !! end
18715
18716 !! test
18717 Section extraction test (section 1)
18718 !! options
18719 section=1
18720 !! wikitext
18721 start
18722 ==a==
18723 ===aa===
18724 ====aaa====
18725 ==b==
18726 ===ba===
18727 ===bb===
18728 ====bba====
18729 ===bc===
18730 ==c==
18731 ===ca===
18732 !! html/php
18733 ==a==
18734 ===aa===
18735 ====aaa====
18736 !! end
18737
18738 !! test
18739 Section extraction test (section 2)
18740 !! options
18741 section=2
18742 !! wikitext
18743 start
18744 ==a==
18745 ===aa===
18746 ====aaa====
18747 ==b==
18748 ===ba===
18749 ===bb===
18750 ====bba====
18751 ===bc===
18752 ==c==
18753 ===ca===
18754 !! html/php
18755 ===aa===
18756 ====aaa====
18757 !! end
18758
18759 !! test
18760 Section extraction test (section 3)
18761 !! options
18762 section=3
18763 !! wikitext
18764 start
18765 ==a==
18766 ===aa===
18767 ====aaa====
18768 ==b==
18769 ===ba===
18770 ===bb===
18771 ====bba====
18772 ===bc===
18773 ==c==
18774 ===ca===
18775 !! html/php
18776 ====aaa====
18777 !! end
18778
18779 !! test
18780 Section extraction test (section 4)
18781 !! options
18782 section=4
18783 !! wikitext
18784 start
18785 ==a==
18786 ===aa===
18787 ====aaa====
18788 ==b==
18789 ===ba===
18790 ===bb===
18791 ====bba====
18792 ===bc===
18793 ==c==
18794 ===ca===
18795 !! html/php
18796 ==b==
18797 ===ba===
18798 ===bb===
18799 ====bba====
18800 ===bc===
18801 !! end
18802
18803 !! test
18804 Section extraction test (section 5)
18805 !! options
18806 section=5
18807 !! wikitext
18808 start
18809 ==a==
18810 ===aa===
18811 ====aaa====
18812 ==b==
18813 ===ba===
18814 ===bb===
18815 ====bba====
18816 ===bc===
18817 ==c==
18818 ===ca===
18819 !! html/php
18820 ===ba===
18821 !! end
18822
18823 !! test
18824 Section extraction test (section 6)
18825 !! options
18826 section=6
18827 !! wikitext
18828 start
18829 ==a==
18830 ===aa===
18831 ====aaa====
18832 ==b==
18833 ===ba===
18834 ===bb===
18835 ====bba====
18836 ===bc===
18837 ==c==
18838 ===ca===
18839 !! html/php
18840 ===bb===
18841 ====bba====
18842 !! end
18843
18844 !! test
18845 Section extraction test (section 7)
18846 !! options
18847 section=7
18848 !! wikitext
18849 start
18850 ==a==
18851 ===aa===
18852 ====aaa====
18853 ==b==
18854 ===ba===
18855 ===bb===
18856 ====bba====
18857 ===bc===
18858 ==c==
18859 ===ca===
18860 !! html/php
18861 ====bba====
18862 !! end
18863
18864 !! test
18865 Section extraction test (section 8)
18866 !! options
18867 section=8
18868 !! wikitext
18869 start
18870 ==a==
18871 ===aa===
18872 ====aaa====
18873 ==b==
18874 ===ba===
18875 ===bb===
18876 ====bba====
18877 ===bc===
18878 ==c==
18879 ===ca===
18880 !! html/php
18881 ===bc===
18882 !! end
18883
18884 !! test
18885 Section extraction test (section 9)
18886 !! options
18887 section=9
18888 !! wikitext
18889 start
18890 ==a==
18891 ===aa===
18892 ====aaa====
18893 ==b==
18894 ===ba===
18895 ===bb===
18896 ====bba====
18897 ===bc===
18898 ==c==
18899 ===ca===
18900 !! html/php
18901 ==c==
18902 ===ca===
18903 !! end
18904
18905 !! test
18906 Section extraction test (section 10)
18907 !! options
18908 section=10
18909 !! wikitext
18910 start
18911 ==a==
18912 ===aa===
18913 ====aaa====
18914 ==b==
18915 ===ba===
18916 ===bb===
18917 ====bba====
18918 ===bc===
18919 ==c==
18920 ===ca===
18921 !! html/php
18922 ===ca===
18923 !! end
18924
18925 !! test
18926 Section extraction test (nonexistent section 11)
18927 !! options
18928 section=11
18929 !! wikitext
18930 start
18931 ==a==
18932 ===aa===
18933 ====aaa====
18934 ==b==
18935 ===ba===
18936 ===bb===
18937 ====bba====
18938 ===bc===
18939 ==c==
18940 ===ca===
18941 !! html/php
18942 !! end
18943
18944 !! test
18945 Section extraction test with bogus heading (section 1)
18946 !! options
18947 section=1
18948 !! wikitext
18949 ==a==
18950 ==bogus== not a legal section
18951 ==b==
18952 !! html/php
18953 ==a==
18954 ==bogus== not a legal section
18955 !! end
18956
18957 !! test
18958 Section extraction test with bogus heading (section 2)
18959 !! options
18960 section=2
18961 !! wikitext
18962 ==a==
18963 ==bogus== not a legal section
18964 ==b==
18965 !! html/php
18966 ==b==
18967 !! end
18968
18969 !! test
18970 Section extraction test with comment after heading (section 1)
18971 !! options
18972 section=1
18973 !! wikitext
18974 ==a==
18975 ==b== <!-- -->
18976 ==c==
18977 !! html/php
18978 ==a==
18979 !! end
18980
18981 !! test
18982 Section extraction test with comment after heading (section 2)
18983 !! options
18984 section=2
18985 !! wikitext
18986 ==a==
18987 ==b== <!-- -->
18988 ==c==
18989 !! html/php
18990 ==b== <!-- -->
18991 !! end
18992
18993 !! test
18994 Section extraction test with bogus <nowiki> heading (section 1)
18995 !! options
18996 section=1
18997 !! wikitext
18998 ==a==
18999 ==bogus== <nowiki>not a legal section</nowiki>
19000 ==b==
19001 !! html/php
19002 ==a==
19003 ==bogus== <nowiki>not a legal section</nowiki>
19004 !! end
19005
19006 !! test
19007 Section extraction test with bogus <nowiki> heading (section 2)
19008 !! options
19009 section=2
19010 !! wikitext
19011 ==a==
19012 ==bogus== <nowiki>not a legal section</nowiki>
19013 ==b==
19014 !! html/php
19015 ==b==
19016 !! end
19017
19018 # Formerly testing for T4587, now resolved by the use of unmarked sections
19019 # instead of respecting commented sections
19020 !! test
19021 Section extraction prefixed by comment (section 1)
19022 !! options
19023 section=1
19024 !! wikitext
19025 <!-- -->==sec1==
19026 ==sec2==
19027 !! html/php
19028 ==sec2==
19029 !!end
19030
19031 !! test
19032 Section extraction prefixed by comment (section 2)
19033 !! options
19034 section=2
19035 !! wikitext
19036 <!-- -->==sec1==
19037 ==sec2==
19038 !! html/php
19039
19040 !!end
19041
19042 # Formerly testing for T4607, now resolved by the use of unmarked sections
19043 # instead of respecting HTML-style headings
19044 !! test
19045 Section extraction, mixed wiki and html (section 1)
19046 !! options
19047 section=1
19048 !! wikitext
19049 <h2>unmarked</h2>
19050 unmarked
19051 ==1==
19052 one
19053 ==2==
19054 two
19055 !! html/php
19056 ==1==
19057 one
19058 !! end
19059
19060 !! test
19061 Section extraction, mixed wiki and html (section 2)
19062 !! options
19063 section=2
19064 !! wikitext
19065 <h2>unmarked</h2>
19066 unmarked
19067 ==1==
19068 one
19069 ==2==
19070 two
19071 !! html/php
19072 ==2==
19073 two
19074 !! end
19075
19076
19077 # Formerly testing for T5342
19078 !! test
19079 Section extraction, heading surrounded by <noinclude>
19080 !! options
19081 section=1
19082 !! wikitext
19083 <noinclude>==unmarked==</noinclude>
19084 ==marked==
19085 !! html/php
19086 ==marked==
19087 !!end
19088
19089 # Test behavior of T21910
19090 !! test
19091 Sectiion with all-equals
19092 !! options
19093 section=2
19094 !! wikitext
19095 ===
19096 The line above must have a trailing space
19097 === <!--
19098 --> <!-- -->
19099 But just in case it doesn't...
19100 !! html/php
19101 === <!--
19102 --> <!-- -->
19103 But just in case it doesn't...
19104 !! end
19105
19106 !! test
19107 Section replacement test (section 0)
19108 !! options
19109 replace=0,"xxx"
19110 !! wikitext
19111 start
19112 ==a==
19113 ===aa===
19114 ====aaa====
19115 ==b==
19116 ===ba===
19117 ===bb===
19118 ====bba====
19119 ===bc===
19120 ==c==
19121 ===ca===
19122 !! html/php
19123 xxx
19124
19125 ==a==
19126 ===aa===
19127 ====aaa====
19128 ==b==
19129 ===ba===
19130 ===bb===
19131 ====bba====
19132 ===bc===
19133 ==c==
19134 ===ca===
19135 !! end
19136
19137 !! test
19138 Section replacement test (section 1)
19139 !! options
19140 replace=1,"xxx"
19141 !! wikitext
19142 start
19143 ==a==
19144 ===aa===
19145 ====aaa====
19146 ==b==
19147 ===ba===
19148 ===bb===
19149 ====bba====
19150 ===bc===
19151 ==c==
19152 ===ca===
19153 !! html/php
19154 start
19155 xxx
19156
19157 ==b==
19158 ===ba===
19159 ===bb===
19160 ====bba====
19161 ===bc===
19162 ==c==
19163 ===ca===
19164 !! end
19165
19166 !! test
19167 Section replacement test (section 2)
19168 !! options
19169 replace=2,"xxx"
19170 !! wikitext
19171 start
19172 ==a==
19173 ===aa===
19174 ====aaa====
19175 ==b==
19176 ===ba===
19177 ===bb===
19178 ====bba====
19179 ===bc===
19180 ==c==
19181 ===ca===
19182 !! html/php
19183 start
19184 ==a==
19185 xxx
19186
19187 ==b==
19188 ===ba===
19189 ===bb===
19190 ====bba====
19191 ===bc===
19192 ==c==
19193 ===ca===
19194 !! end
19195
19196 !! test
19197 Section replacement test (section 3)
19198 !! options
19199 replace=3,"xxx"
19200 !! wikitext
19201 start
19202 ==a==
19203 ===aa===
19204 ====aaa====
19205 ==b==
19206 ===ba===
19207 ===bb===
19208 ====bba====
19209 ===bc===
19210 ==c==
19211 ===ca===
19212 !! html/php
19213 start
19214 ==a==
19215 ===aa===
19216 xxx
19217
19218 ==b==
19219 ===ba===
19220 ===bb===
19221 ====bba====
19222 ===bc===
19223 ==c==
19224 ===ca===
19225 !! end
19226
19227 !! test
19228 Section replacement test (section 4)
19229 !! options
19230 replace=4,"xxx"
19231 !! wikitext
19232 start
19233 ==a==
19234 ===aa===
19235 ====aaa====
19236 ==b==
19237 ===ba===
19238 ===bb===
19239 ====bba====
19240 ===bc===
19241 ==c==
19242 ===ca===
19243 !! html/php
19244 start
19245 ==a==
19246 ===aa===
19247 ====aaa====
19248 xxx
19249
19250 ==c==
19251 ===ca===
19252 !! end
19253
19254 !! test
19255 Section replacement test (section 5)
19256 !! options
19257 replace=5,"xxx"
19258 !! wikitext
19259 start
19260 ==a==
19261 ===aa===
19262 ====aaa====
19263 ==b==
19264 ===ba===
19265 ===bb===
19266 ====bba====
19267 ===bc===
19268 ==c==
19269 ===ca===
19270 !! html/php
19271 start
19272 ==a==
19273 ===aa===
19274 ====aaa====
19275 ==b==
19276 xxx
19277
19278 ===bb===
19279 ====bba====
19280 ===bc===
19281 ==c==
19282 ===ca===
19283 !! end
19284
19285 !! test
19286 Section replacement test (section 6)
19287 !! options
19288 replace=6,"xxx"
19289 !! wikitext
19290 start
19291 ==a==
19292 ===aa===
19293 ====aaa====
19294 ==b==
19295 ===ba===
19296 ===bb===
19297 ====bba====
19298 ===bc===
19299 ==c==
19300 ===ca===
19301 !! html/php
19302 start
19303 ==a==
19304 ===aa===
19305 ====aaa====
19306 ==b==
19307 ===ba===
19308 xxx
19309
19310 ===bc===
19311 ==c==
19312 ===ca===
19313 !! end
19314
19315 !! test
19316 Section replacement test (section 7)
19317 !! options
19318 replace=7,"xxx"
19319 !! wikitext
19320 start
19321 ==a==
19322 ===aa===
19323 ====aaa====
19324 ==b==
19325 ===ba===
19326 ===bb===
19327 ====bba====
19328 ===bc===
19329 ==c==
19330 ===ca===
19331 !! html/php
19332 start
19333 ==a==
19334 ===aa===
19335 ====aaa====
19336 ==b==
19337 ===ba===
19338 ===bb===
19339 xxx
19340
19341 ===bc===
19342 ==c==
19343 ===ca===
19344 !! end
19345
19346 !! test
19347 Section replacement test (section 8)
19348 !! options
19349 replace=8,"xxx"
19350 !! wikitext
19351 start
19352 ==a==
19353 ===aa===
19354 ====aaa====
19355 ==b==
19356 ===ba===
19357 ===bb===
19358 ====bba====
19359 ===bc===
19360 ==c==
19361 ===ca===
19362 !! html/php
19363 start
19364 ==a==
19365 ===aa===
19366 ====aaa====
19367 ==b==
19368 ===ba===
19369 ===bb===
19370 ====bba====
19371 xxx
19372
19373 ==c==
19374 ===ca===
19375 !!end
19376
19377 !! test
19378 Section replacement test (section 9)
19379 !! options
19380 replace=9,"xxx"
19381 !! wikitext
19382 start
19383 ==a==
19384 ===aa===
19385 ====aaa====
19386 ==b==
19387 ===ba===
19388 ===bb===
19389 ====bba====
19390 ===bc===
19391 ==c==
19392 ===ca===
19393 !! html/php
19394 start
19395 ==a==
19396 ===aa===
19397 ====aaa====
19398 ==b==
19399 ===ba===
19400 ===bb===
19401 ====bba====
19402 ===bc===
19403 xxx
19404 !! end
19405
19406 !! test
19407 Section replacement test (section 10)
19408 !! options
19409 replace=10,"xxx"
19410 !! wikitext
19411 start
19412 ==a==
19413 ===aa===
19414 ====aaa====
19415 ==b==
19416 ===ba===
19417 ===bb===
19418 ====bba====
19419 ===bc===
19420 ==c==
19421 ===ca===
19422 !! html/php
19423 start
19424 ==a==
19425 ===aa===
19426 ====aaa====
19427 ==b==
19428 ===ba===
19429 ===bb===
19430 ====bba====
19431 ===bc===
19432 ==c==
19433 xxx
19434 !! end
19435
19436 !! test
19437 Section replacement test with initial whitespace (T15728)
19438 !! options
19439 replace=2,"xxx"
19440 !! wikitext
19441 Preformatted initial line
19442 ==a==
19443 ===a===
19444 !! html/php
19445 Preformatted initial line
19446 ==a==
19447 xxx
19448 !! end
19449
19450
19451 !! test
19452 Section extraction, heading followed by pre with 20 spaces (T8398)
19453 !! options
19454 section=1
19455 !! wikitext
19456 ==a==
19457 a
19458 !! html/php
19459 ==a==
19460 a
19461 !! end
19462
19463 !! test
19464 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
19465 !! options
19466 section=1
19467 !! wikitext
19468 ==a==
19469 a
19470 !! html/php
19471 ==a==
19472 a
19473 !! end
19474
19475
19476 !! test
19477 Section extraction, <pre> around bogus header (T12309)
19478 !! options
19479 section=2
19480 !! wikitext
19481 == Section One ==
19482 <pre>
19483 =======
19484 </pre>
19485
19486 == Section Two ==
19487 stuff
19488 !! html/php
19489 == Section Two ==
19490 stuff
19491 !! end
19492
19493 !! test
19494 Section replacement, <pre> around bogus header (T12309)
19495 !! options
19496 replace=2,"xxx"
19497 !! wikitext
19498 == Section One ==
19499 <pre>
19500 =======
19501 </pre>
19502
19503 == Section Two ==
19504 stuff
19505 !! html/php
19506 == Section One ==
19507 <pre>
19508 =======
19509 </pre>
19510
19511 xxx
19512 !! end
19513
19514 !! test
19515 Handling of &#x0A; in URLs
19516 !! wikitext
19517 ** irc://&#x0A;a
19518 !! html/php
19519 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
19520
19521 !! html/parsoid
19522 <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>
19523 !! end
19524
19525 !! test
19526 Handling of %0A in URLs
19527 !! wikitext
19528 ** irc://%0Aa
19529 !! html/php
19530 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
19531
19532 !! html/parsoid
19533 <ul><li><ul><li> <a rel="mw:ExtLink" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
19534 !! end
19535
19536 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
19537 !! test
19538 5 quotes, code coverage +1 line
19539 !! options
19540 parsoid=wt2html
19541 !! wikitext
19542 '''''
19543 !! html/php
19544 !! html/parsoid
19545 <p><b><i></i></b></p>
19546 !! end
19547
19548 # same html as previous, but wikitext adjusted to match parsoid html2wt
19549 # note that wt2html and html2html will put the <i> before the <b>
19550 !! test
19551 5 quotes, code coverage +1 line w/ nowiki (1)
19552 !! options
19553 parsoid=wt2wt,html2wt
19554 !! wikitext
19555 '''''<nowiki/>'''''
19556 !! html/php
19557 <p><i></i>
19558 </p>
19559 !! html/parsoid
19560 <p><b><i></i></b></p>
19561 !! end
19562
19563 # same as previous, just swapping the <i> and <b>
19564 !! test
19565 5 quotes, code coverage +1 line w/ nowiki (2)
19566 !! wikitext
19567 '''''<nowiki/>'''''
19568 !! html/php
19569 <p><i></i>
19570 </p>
19571 !! html/parsoid
19572 <p><i><b></b></i></p>
19573 !! end
19574
19575 !! test
19576 Special:Search page linking.
19577 !! wikitext
19578 {{Special:search}}
19579 !! html
19580 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
19581 </p>
19582 !! end
19583
19584 !! test
19585 {{!}} is a magic word
19586 !! wikitext
19587 {{!}} is a magic word there and {{!}} is still a magic word here
19588 | is not a magic word here but {{!}} is still a magic word here
19589 !! html/php
19590 <p>| is a magic word there and | is still a magic word here
19591 | is not a magic word here but | is still a magic word here
19592 </p>
19593 !! html/parsoid
19594 <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
19595 | 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>
19596 !! end
19597
19598 !! test
19599 Say the magic word
19600 !! options
19601 title=[[Parser test]]
19602 !! wikitext
19603 * {{PAGENAME}}
19604 * {{PAGENAMEE}}
19605 * {{FULLPAGENAME}}
19606 * {{FULLPAGENAMEE}}
19607 * {{BASEPAGENAME}}
19608 * {{BASEPAGENAMEE}}
19609 * {{SUBPAGENAME}}
19610 * {{SUBPAGENAMEE}}
19611 * {{ROOTPAGENAME}}
19612 * {{ROOTPAGENAMEE}}
19613 * {{TALKPAGENAME}}
19614 * {{TALKPAGENAMEE}}
19615 * {{SUBJECTPAGENAME}}
19616 * {{SUBJECTPAGENAMEE}}
19617 * {{NAMESPACEE}}
19618 * {{NAMESPACE}}
19619 * {{NAMESPACENUMBER}}
19620 * {{TALKSPACE}}
19621 * {{TALKSPACEE}}
19622 * {{SUBJECTSPACE}}
19623 * {{SUBJECTSPACEE}}
19624 * {{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
19625 !! html
19626 <ul><li> Parser test</li>
19627 <li> Parser_test</li>
19628 <li> Parser test</li>
19629 <li> Parser_test</li>
19630 <li> Parser test</li>
19631 <li> Parser_test</li>
19632 <li> Parser test</li>
19633 <li> Parser_test</li>
19634 <li> Parser test</li>
19635 <li> Parser_test</li>
19636 <li> Talk:Parser test</li>
19637 <li> Talk:Parser_test</li>
19638 <li> Parser test</li>
19639 <li> Parser_test</li>
19640 <li> </li>
19641 <li> </li>
19642 <li> 0</li>
19643 <li> Talk</li>
19644 <li> Talk</li>
19645 <li> </li>
19646 <li> </li>
19647 <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>
19648
19649 !! end
19650 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
19651
19652 !! test
19653 Gallery with valid attributes
19654 !! wikitext
19655 <gallery type="123" summary="345">
19656 File:File:Foobar.jpg
19657 </gallery>
19658 !! html/php
19659 <ul class="gallery mw-gallery-traditional" type="123">
19660 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19661 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
19662 <div class="gallerytext">
19663 </div>
19664 </div></li>
19665 </ul>
19666
19667 !! html/parsoid
19668 <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"}}'>
19669 <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>
19670 </ul>
19671 !! end
19672
19673 ## Parsoid thinks the "centre" here is a property, not a caption.
19674 !! test
19675 Gallery
19676 !! options
19677 parsoid={
19678 "modes": ["wt2html"],
19679 "nativeGallery": true
19680 }
19681 !! wikitext
19682 <gallery>
19683 image1.png |
19684 image2.gif|||||
19685
19686 image3|
19687 image4 |300px| centre
19688 image5.svg| http://///////
19689 [[x|xx]]]]
19690 * image6
19691 </gallery>
19692 !! html/php
19693 <ul class="gallery mw-gallery-traditional">
19694 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19695 <div class="thumb" style="height: 150px;">Image1.png</div>
19696 <div class="gallerytext">
19697 </div>
19698 </div></li>
19699 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19700 <div class="thumb" style="height: 150px;">Image2.gif</div>
19701 <div class="gallerytext">
19702 </div>
19703 </div></li>
19704 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19705 <div class="thumb" style="height: 150px;">Image3</div>
19706 <div class="gallerytext">
19707 </div>
19708 </div></li>
19709 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19710 <div class="thumb" style="height: 150px;">Image4</div>
19711 <div class="gallerytext">
19712 <pre>centre
19713 </pre>
19714 </div>
19715 </div></li>
19716 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19717 <div class="thumb" style="height: 150px;">Image5.svg</div>
19718 <div class="gallerytext">
19719 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
19720 </p>
19721 </div>
19722 </div></li>
19723 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19724 <div class="thumb" style="height: 150px;">* image6</div>
19725 <div class="gallerytext">
19726 </div>
19727 </div></li>
19728 </ul>
19729
19730 !! html/parsoid
19731 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19732 <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>
19733 <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>
19734 <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>
19735 <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>
19736 <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>
19737 <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>
19738 </ul>
19739 !! end
19740
19741 !! test
19742 Gallery (with options, html)
19743 !! options
19744 parsoid={
19745 "modes": ["wt2html", "html2html"],
19746 "nativeGallery": true
19747 }
19748 !! wikitext
19749 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
19750 File:Nonexistent.jpg|caption
19751 File:Nonexistent.jpg
19752 image:foobar.jpg|some '''caption''' [[Main Page]]
19753 image:foobar.jpg
19754 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
19755 </gallery>
19756 !! html/php
19757 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
19758 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
19759 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19760 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19761 <div class="gallerytext">
19762 <p>caption
19763 </p>
19764 </div>
19765 </div></li>
19766 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19767 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19768 <div class="gallerytext">
19769 </div>
19770 </div></li>
19771 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19772 <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>
19773 <div class="gallerytext">
19774 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
19775 </p>
19776 </div>
19777 </div></li>
19778 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19779 <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>
19780 <div class="gallerytext">
19781 </div>
19782 </div></li>
19783 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19784 <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>
19785 <div class="gallerytext">
19786 <p>blabla.
19787 </p>
19788 </div>
19789 </div></li>
19790 </ul>
19791
19792 !! html/parsoid
19793 <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":{}}'>
19794 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
19795 <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>
19796 <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>
19797 <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>
19798 <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>
19799 <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>
19800 </ul>
19801 !! end
19802
19803 !! test
19804 Gallery (with options, extsrc)
19805 !! options
19806 parsoid={
19807 "nativeGallery": false
19808 }
19809 !! wikitext
19810 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
19811 File:Nonexistent.jpg|caption
19812 File:Nonexistent.jpg
19813 image:foobar.jpg|some '''caption''' [[Main Page]]
19814 image:foobar.jpg
19815 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
19816 </gallery>
19817 !! html/php
19818 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
19819 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
19820 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19821 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19822 <div class="gallerytext">
19823 <p>caption
19824 </p>
19825 </div>
19826 </div></li>
19827 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19828 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19829 <div class="gallerytext">
19830 </div>
19831 </div></li>
19832 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19833 <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>
19834 <div class="gallerytext">
19835 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
19836 </p>
19837 </div>
19838 </div></li>
19839 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19840 <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>
19841 <div class="gallerytext">
19842 </div>
19843 </div></li>
19844 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19845 <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>
19846 <div class="gallerytext">
19847 <p>blabla.
19848 </p>
19849 </div>
19850 </div></li>
19851 </ul>
19852
19853 !! html/parsoid
19854 <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"}}'>
19855 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
19856 <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>
19857 <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>
19858 <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>
19859 <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>
19860 <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>
19861 </ul>
19862 !! end
19863
19864 !! test
19865 Gallery with link that has fragment
19866 !! options
19867 parsoid={
19868 "modes": ["wt2html", "html2html"],
19869 "nativeGallery": true
19870 }
19871 !! wikitext
19872 <gallery>
19873 image:foobar.jpg|link=Main_Page
19874 image:foobar.jpg|link=Main_Page#section
19875 image:foobar.jpg|link=Main Page#section|caption
19876 </gallery>
19877 !! html/php
19878 <ul class="gallery mw-gallery-traditional">
19879 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19880 <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>
19881 <div class="gallerytext">
19882 </div>
19883 </div></li>
19884 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19885 <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>
19886 <div class="gallerytext">
19887 </div>
19888 </div></li>
19889 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19890 <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>
19891 <div class="gallerytext">
19892 <p>caption
19893 </p>
19894 </div>
19895 </div></li>
19896 </ul>
19897
19898 !! html/parsoid
19899 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19900 <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>
19901 <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>
19902 <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>
19903 </ul>
19904 !! end
19905
19906 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
19907 !! test
19908 Gallery with template inside caption
19909 !! options
19910 parsoid={
19911 "nativeGallery": true
19912 }
19913 !! wikitext
19914 <gallery caption="{{echo|hi}}">
19915 File:Foobar.jpg|{{echo|ho}}
19916 </gallery>
19917 !! html/php
19918 <ul class="gallery mw-gallery-traditional">
19919 <li class='gallerycaption'>{{echo|hi}}</li>
19920 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19921 <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>
19922 <div class="gallerytext">
19923 <p>ho
19924 </p>
19925 </div>
19926 </div></li>
19927 </ul>
19928
19929 !! html/parsoid
19930 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19931 <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>
19932 <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>
19933 </ul>
19934 !! end
19935
19936 !! test
19937 Gallery with wikitext inside caption
19938 !! options
19939 parsoid={
19940 "nativeGallery": true
19941 }
19942 !! wikitext
19943 <gallery>
19944 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
19945 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
19946 </gallery>
19947 !! html/php
19948 <ul class="gallery mw-gallery-traditional">
19949 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19950 <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>
19951 <div class="gallerytext">
19952 <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>
19953 </p>
19954 </div>
19955 </div></li>
19956 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19957 <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>
19958 <div class="gallerytext">
19959 <p>This is a test template
19960 </p>
19961 </div>
19962 </div></li>
19963 </ul>
19964
19965 !! html/parsoid
19966 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19967 <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>
19968 <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>
19969 </ul>
19970 !! end
19971
19972 !! test
19973 Gallery (with showfilename option)
19974 !! options
19975 parsoid={
19976 "nativeGallery": true
19977 }
19978 !! wikitext
19979 <gallery showfilename="">
19980 File:Nonexistent.jpg|caption
19981 File:Nonexistent.jpg
19982 File:Foobar.jpg|some '''caption''' [[Main Page]]
19983 File:Foobar.jpg
19984 </gallery>
19985 !! html/php
19986 <ul class="gallery mw-gallery-traditional">
19987 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19988 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
19989 <div class="gallerytext">
19990 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
19991 caption
19992 </p>
19993 </div>
19994 </div></li>
19995 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19996 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
19997 <div class="gallerytext">
19998 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
19999 </p>
20000 </div>
20001 </div></li>
20002 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20003 <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>
20004 <div class="gallerytext">
20005 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20006 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
20007 </p>
20008 </div>
20009 </div></li>
20010 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20011 <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>
20012 <div class="gallerytext">
20013 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
20014 </p>
20015 </div>
20016 </div></li>
20017 </ul>
20018
20019 !! html/parsoid
20020 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
20021 <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>
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"><a href="./File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">File:Nonexistent.jpg</a></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 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>
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"><a href="./File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">File:Foobar.jpg</a></div></li>
20025 </ul>
20026 !! end
20027
20028 ## Should Parsoid be preserving these variations?
20029 !! test
20030 Gallery (with namespace-less filenames)
20031 !! options
20032 parsoid={
20033 "modes": ["wt2html", "html2html"],
20034 "nativeGallery": true
20035 }
20036 !! wikitext
20037 <gallery>
20038 File:Nonexistent.jpg
20039 Nonexistent.jpg
20040 image:foobar.jpg
20041 foobar.jpg
20042 </gallery>
20043 !! html/php
20044 <ul class="gallery mw-gallery-traditional">
20045 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20046 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20047 <div class="gallerytext">
20048 </div>
20049 </div></li>
20050 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20051 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20052 <div class="gallerytext">
20053 </div>
20054 </div></li>
20055 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20056 <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>
20057 <div class="gallerytext">
20058 </div>
20059 </div></li>
20060 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20061 <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>
20062 <div class="gallerytext">
20063 </div>
20064 </div></li>
20065 </ul>
20066
20067 !! html/parsoid
20068 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20069 <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>
20070 <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>
20071 <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>
20072 <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>
20073 </ul>
20074 !! end
20075
20076 !! test
20077 Gallery override link with WikiLink (T36852)
20078 !! options
20079 parsoid={
20080 "nativeGallery": true
20081 }
20082 !! wikitext
20083 <gallery>
20084 File:Foobar.jpg|alt=galleryalt|link=InterWikiLink
20085 </gallery>
20086 !! html/php
20087 <ul class="gallery mw-gallery-traditional">
20088 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20089 <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>
20090 <div class="gallerytext">
20091 </div>
20092 </div></li>
20093 </ul>
20094
20095 !! html/parsoid
20096 <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":{}}'>
20097 <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>
20098 </ul>
20099 !! end
20100
20101 !! test
20102 Gallery override link with absolute external link (T36852)
20103 !! options
20104 parsoid={
20105 "nativeGallery": true
20106 }
20107 !! wikitext
20108 <gallery>
20109 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
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="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>
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="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>
20123 </ul>
20124 !! end
20125
20126 !! test
20127 Gallery override link with absolute external link with LanguageConverter
20128 !! options
20129 language=zh
20130 !! input
20131 <gallery>
20132 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
20133 </gallery>
20134 !! result
20135 <ul class="gallery mw-gallery-traditional">
20136 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20137 <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>
20138 <div class="gallerytext">
20139 <p>caption
20140 </p>
20141 </div>
20142 </div></li>
20143 </ul>
20144
20145 !! end
20146
20147 !! test
20148 Gallery override link with malicious javascript (T36852)
20149 !! options
20150 parsoid={
20151 "modes": ["wt2html", "html2html"],
20152 "nativeGallery": true
20153 }
20154 !! wikitext
20155 <gallery>
20156 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
20157 </gallery>
20158 !! html/php
20159 <ul class="gallery mw-gallery-traditional">
20160 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20161 <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>
20162 <div class="gallerytext">
20163 </div>
20164 </div></li>
20165 </ul>
20166
20167 !! html/parsoid
20168 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20169 <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>
20170 </ul>
20171 !! end
20172
20173 !! test
20174 Gallery with invalid title as link (T45964)
20175 !! options
20176 parsoid={
20177 "modes": ["wt2html", "html2html"],
20178 "nativeGallery": true
20179 }
20180 !! wikitext
20181 <gallery>
20182 File:Foobar.jpg|link=<
20183 </gallery>
20184 !! html/php
20185 <ul class="gallery mw-gallery-traditional">
20186 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20187 <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>
20188 <div class="gallerytext">
20189 </div>
20190 </div></li>
20191 </ul>
20192
20193 !! html/parsoid
20194 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20195 <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>
20196 </ul>
20197 !! end
20198
20199 !! test
20200 Serialize gallery without attrs in data-mw
20201 !! options
20202 parsoid={
20203 "modes": ["html2wt"],
20204 "nativeGallery": true
20205 }
20206 !! html/parsoid
20207 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
20208 <li class="gallerycaption">123</li>
20209 <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>
20210 </ul>
20211 !! wikitext
20212 <gallery caption="123">
20213 File:Test.png
20214 </gallery>
20215 !! end
20216
20217 !! test
20218 Gallery with class and style attributes
20219 !! options
20220 parsoid={
20221 "nativeGallery": true
20222 }
20223 !! wikitext
20224 <gallery class="center" style="text-align: center;">
20225 File:Foobar.jpg
20226 </gallery>
20227 !! html/php
20228 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
20229 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20230 <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>
20231 <div class="gallerytext">
20232 </div>
20233 </div></li>
20234 </ul>
20235
20236 !! html/parsoid
20237 <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":{}}'>
20238 <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>
20239 </ul>
20240 !! end
20241
20242 !! test
20243 Gallery in slideshow mode
20244 !! options
20245 parsoid={
20246 "nativeGallery": true
20247 }
20248 !! wikitext
20249 <gallery mode="slideshow" showthumbnails="">
20250 File:Foobar.jpg
20251 </gallery>
20252 !! html/php
20253 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
20254 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20255 <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>
20256 <div class="gallerytext">
20257 </div>
20258 </div></li>
20259 </ul>
20260
20261 !! html/parsoid
20262 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
20263 <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>
20264 </ul>
20265 !! end
20266
20267 !! test
20268 HTML Hex character encoding (spells the word "JavaScript")
20269 !! options
20270 parsoid=wt2html,wt2wt,html2html
20271 !! wikitext
20272 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
20273 !! html/php
20274 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
20275 </p>
20276 !! html/php+tidy
20277 <p>JavaScript</p>
20278 !! html/parsoid
20279 <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>
20280 !! end
20281
20282 !! test
20283 HTML Hex character encoding bogus encoding (T28437 regression check)
20284 !! wikitext
20285 &#xsee;&#XSEE;
20286 !! html/php
20287 <p>&amp;#xsee;&amp;#XSEE;
20288 </p>
20289 !! html/parsoid
20290 <p>&amp;#xsee;&amp;#XSEE;</p>
20291 !! end
20292
20293 !! test
20294 HTML Hex character encoding mixed case
20295 !! options
20296 parsoid=wt2html,wt2wt,html2html
20297 !! wikitext
20298 &#xEE;&#Xee;
20299 !! html/php
20300 <p>&#xee;&#xee;
20301 </p>
20302 !! html/php+tidy
20303 <p>îî</p>
20304 !! html/parsoid
20305 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
20306 !! end
20307
20308 # See: https://www.w3.org/TR/html5/syntax.html#character-references
20309 # Note that U+000C (form feed) is not a valid XML character, so
20310 # it is banned even though allowed in HTML5.
20311 !! test
20312 Illegal character references (T106578)
20313 !! wikitext
20314 ; Null: &#00;
20315 ; FF: &#xC;
20316 ; CR: &#xD;
20317 ; Control (low): &#8;
20318 ; Control (high): &#x7F; &#x9F;
20319 ; Surrogate: &#xD83D;&#xDCA9;
20320 ; This is an okay astral character: &#x1F4A9;
20321 !! html+tidy
20322 <dl>
20323 <dt>Null</dt>
20324 <dd>&amp;#00;</dd>
20325 <dt>FF</dt>
20326 <dd>&amp;#xC;</dd>
20327 <dt>CR</dt>
20328 <dd>&amp;#xD;</dd>
20329 <dt>Control (low)</dt>
20330 <dd>&amp;#8;</dd>
20331 <dt>Control (high)</dt>
20332 <dd>&amp;#x7F; &amp;#x9F;</dd>
20333 <dt>Surrogate</dt>
20334 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
20335 <dt>This is an okay astral character</dt>
20336 <dd>💩</dd>
20337 </dl>
20338 !! end
20339
20340 !! test
20341 __FORCETOC__ override
20342 !! wikitext
20343 __NEWSECTIONLINK__
20344 __FORCETOC__
20345 !! html/php
20346 <p><br />
20347 </p>
20348 !! end
20349
20350 !! test
20351 ISBN code coverage
20352 !! wikitext
20353 ISBN 978-0-1234-56&#x20;789
20354 !! html
20355 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
20356 </p>
20357 !! html+tidy
20358 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a> 789</p>
20359 !! html/parsoid
20360 <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>
20361 !! end
20362
20363 !! test
20364 ISBN followed by 5 spaces
20365 !! wikitext
20366 ISBN
20367 !! html
20368 <p>ISBN
20369 </p>
20370 !! end
20371
20372 !! test
20373 Double ISBN
20374 !! wikitext
20375 ISBN ISBN 1234567890
20376 !! html/php
20377 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20378 </p>
20379 !! html/parsoid
20380 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
20381 !! end
20382
20383 # Uppercase X and lowercase x as well
20384 !! test
20385 ISBN with an X
20386 !! wikitext
20387 ISBN 3-462-04561-X
20388 ISBN 3-462-04561-x
20389 ISBN 080442957X
20390 ISBN 080442957x
20391 ISBN 978080442957X
20392 ISBN 978080442957x
20393 !! html/php
20394 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
20395 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
20396 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
20397 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
20398 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
20399 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
20400 </p>
20401 !! html/parsoid
20402 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
20403 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
20404 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
20405 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
20406 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
20407 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
20408 !! end
20409
20410 !! test
20411 ISBN with empty prefix (parsoid test)
20412 !! wikitext
20413 ISBN 1234567890
20414 !! html/php
20415 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20416 </p>
20417 !! html/parsoid
20418 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
20419 !! end
20420
20421 !! test
20422 T24905: <abbr> followed by ISBN followed by </a>
20423 !! wikitext
20424 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
20425 !! html/php
20426 <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>
20427 </p>
20428 !! html/parsoid
20429 <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>
20430 !! end
20431
20432 !! test
20433 Double RFC
20434 !! wikitext
20435 RFC RFC 1234
20436 !! html
20437 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a>
20438 </p>
20439 !! end
20440
20441 !! test
20442 Double RFC with a wiki link
20443 !! wikitext
20444 RFC [[RFC 1234]]
20445 !! html
20446 <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>
20447 </p>
20448 !! end
20449
20450 !! test
20451 RFC code coverage
20452 !! wikitext
20453 RFC 983&#x20;987
20454 !! html
20455 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
20456 </p>
20457 !! html+tidy
20458 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a> 987</p>
20459 !! end
20460
20461 !! test
20462 Centre-aligned image
20463 !! wikitext
20464 [[Image:foobar.jpg|centre]]
20465 !! html
20466 <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>
20467
20468 !!end
20469
20470 !! test
20471 None-aligned image
20472 !! wikitext
20473 [[Image:foobar.jpg|none]]
20474 !! html
20475 <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>
20476
20477 !!end
20478
20479 !! test
20480 Width + Height sized image (using px) (height is ignored)
20481 !! wikitext
20482 [[Image:foobar.jpg|640x480px]]
20483 !! html
20484 <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>
20485 </p>
20486 !!end
20487
20488 !! test
20489 Width-sized image (using px, no following whitespace)
20490 !! wikitext
20491 [[Image:foobar.jpg|640px]]
20492 !! html
20493 <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>
20494 </p>
20495 !!end
20496
20497 !! test
20498 Width-sized image (using px, with following whitespace - test regression from r39467)
20499 !! wikitext
20500 [[Image:foobar.jpg|640px ]]
20501 !! html
20502 <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>
20503 </p>
20504 !!end
20505
20506 !! test
20507 Width-sized image (using px, with preceding whitespace - test regression from r39467)
20508 !! wikitext
20509 [[Image:foobar.jpg| 640px]]
20510 !! html
20511 <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>
20512 </p>
20513 !!end
20514
20515 !! test
20516 Image with page parameter
20517 !! options
20518 djvu
20519 !! wikitext
20520 [[File:LoremIpsum.djvu|page=2]]
20521 !! html/php
20522 <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>
20523 </p>
20524 !! html/parsoid
20525 <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>
20526 !! end
20527
20528 !! test
20529 Another italics / bold test
20530 !! wikitext
20531 ''' ''x'
20532 !! html
20533 <pre>'<i> </i>x'
20534 </pre>
20535 !!end
20536
20537 # FIXME: The php output seems broken. It's interleaving some open/close tags.
20538 !! test
20539 dt/dd/dl test
20540 !! wikitext
20541 :;;;::
20542 !! html/php
20543 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
20544
20545 !! html/parsoid
20546 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
20547
20548 !!end
20549
20550 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
20551 !! test
20552 Images with the "|" character in the comment
20553 !! wikitext
20554 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
20555 !! html/php
20556 <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>
20557
20558 !! html/parsoid
20559 <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>
20560 !! end
20561
20562 !! test
20563 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
20564 !! wikitext
20565 <html><script>alert(1);</script></html>
20566 !! html
20567 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
20568 </p>
20569 !! end
20570
20571 !! test
20572 HTML with raw HTML ($wgRawHtml==true)
20573 !! options
20574 wgRawHtml=1
20575 !! wikitext
20576 <html><script>alert(1);</script></html>
20577 !! html
20578 <p><script>alert(1);</script>
20579 </p>
20580 !! end
20581
20582 !! test
20583 Parents of subpages, one level up
20584 !! options
20585 subpage title=[[Subpage test/L1/L2/L3]]
20586 !! wikitext
20587 [[../|L2]]
20588 !! html
20589 <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>
20590 </p>
20591 !! end
20592
20593
20594 !! test
20595 Parents of subpages, one level up, not named
20596 !! options
20597 subpage title=[[Subpage test/L1/L2/L3]]
20598 !! wikitext
20599 [[../]]
20600 !! html
20601 <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>
20602 </p>
20603 !! end
20604
20605
20606
20607 !! test
20608 Parents of subpages, two levels up
20609 !! options
20610 subpage title=[[Subpage test/L1/L2/L3]]
20611 !! wikitext
20612 [[../../|L1]]2
20613
20614 [[../../|L1]]l
20615 !! html
20616 <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
20617 </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>
20618 </p>
20619 !! end
20620
20621 !! test
20622 Parents of subpages, two levels up, without trailing slash or name.
20623 !! options
20624 subpage title=[[Subpage test/L1/L2/L3]]
20625 !! wikitext
20626 [[../..]]
20627 !! html
20628 <p>[[../..]]
20629 </p>
20630 !! end
20631
20632 !! test
20633 Parents of subpages, two levels up, with lots of extra trailing slashes.
20634 !! options
20635 subpage title=[[Subpage test/L1/L2/L3]]
20636 !! wikitext
20637 [[../../////]]
20638 !! html
20639 <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>
20640 </p>
20641 !! end
20642
20643 !! article
20644 Subpage test/L1/L2/L3Sibling
20645 !! text
20646 Sibling article
20647 !! endarticle
20648
20649 !! test
20650 Transclusion of a sibling page (one level up)
20651 !! options
20652 subpage title=[[Subpage test/L1/L2/L3]]
20653 !! wikitext
20654 {{../L3Sibling}}
20655 !! html
20656 <p>Sibling article
20657 </p>
20658 !! end
20659
20660 !! test
20661 Transclusion of a child page
20662 !! options
20663 subpage title=[[Subpage test/L1/L2]]
20664 !! wikitext
20665 {{/L3Sibling}}
20666 !! html
20667 <p>Sibling article
20668 </p>
20669 !! end
20670
20671 # This is wt2html only in Parsoid because we add <nowiki>
20672 # because of {{..}} and we don't expect to fix that to
20673 # eliminate the nowikis selective for {{..}} markup.
20674 !! test
20675 Non-transclusion because of too many up levels
20676 !! options
20677 subpage title=[[Subpage test/L1/L2/L3]]
20678 parsoid=wt2html
20679 !! wikitext
20680 {{../../../../More than parent}}
20681 !! html/php
20682 <p>{{../../../../More than parent}}
20683 </p>
20684 !! html/parsoid
20685 <p>{{../../../../More than parent}}</p>
20686 !! end
20687
20688 !! test
20689 Definition list code coverage
20690 !! wikitext
20691 ; title : def
20692 ; title : def
20693 ;title: def
20694 !! html/php
20695 <dl><dt> title &#160;</dt>
20696 <dd> def</dd>
20697 <dt> title&#160;</dt>
20698 <dd> def</dd>
20699 <dt>title</dt>
20700 <dd> def</dd></dl>
20701
20702 !! html/parsoid
20703 <dl><dt> title <span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
20704 <dt> title<span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
20705 <dt>title</dt><dd> def</dd></dl>
20706 !! end
20707
20708 !! test
20709 Don't fall for the self-closing div
20710 !! wikitext
20711 <div>hello world</div/>
20712 !! html
20713 <div>hello world</div>
20714
20715 !! end
20716
20717 !! test
20718 MSGNW magic word
20719 !! wikitext
20720 {{MSGNW:msg}}
20721 !! html/php
20722 <p>&#91;&#91;:Template:Msg&#93;&#93;
20723 </p>
20724 !! end
20725
20726 !! test
20727 RAW magic word
20728 !! wikitext
20729 {{RAW:QUERTY}}
20730 !! html
20731 <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>
20732 </p>
20733 !! end
20734
20735 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
20736 !! test
20737 Always escape literal '>' in output, not just after '<'
20738 !! wikitext
20739 ><>
20740 !! html
20741 <p>&gt;&lt;&gt;
20742 </p>
20743 !! end
20744
20745 !! test
20746 Template caching
20747 !! wikitext
20748 {{Test}}
20749 {{Test}}
20750 !! html
20751 <p>This is a test template
20752 This is a test template
20753 </p>
20754 !! end
20755
20756
20757 !! article
20758 MediaWiki:Fake
20759 !! text
20760 ==header==
20761 !! endarticle
20762
20763 !! test
20764 Inclusion of !userCanEdit() content
20765 !! wikitext
20766 {{MediaWiki:Fake}}
20767 !! html
20768 <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>
20769
20770 !! end
20771
20772
20773 !! test
20774 Out-of-order TOC heading levels
20775 !! wikitext
20776 ==2==
20777 ======6======
20778 ===3===
20779 =1=
20780 =====5=====
20781 ==2==
20782 !! html
20783 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
20784 <ul>
20785 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
20786 <ul>
20787 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
20788 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
20789 </ul>
20790 </li>
20791 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
20792 <ul>
20793 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
20794 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
20795 </ul>
20796 </li>
20797 </ul>
20798 </div>
20799
20800 <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>
20801 <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>
20802 <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>
20803 <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>
20804 <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>
20805 <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>
20806
20807 !! end
20808
20809
20810 !! test
20811 ISBN with a dummy number
20812 !! wikitext
20813 ISBN ---
20814 !! html
20815 <p>ISBN ---
20816 </p>
20817 !! end
20818
20819
20820 !! test
20821 ISBN with space-delimited number
20822 !! wikitext
20823 ISBN 92 9017 032 8
20824 !! html/php
20825 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
20826 </p>
20827 !! html/parsoid
20828 <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>
20829 !! end
20830
20831
20832 !! test
20833 ISBN with multiple spaces, no number
20834 !! wikitext
20835 ISBN foo
20836 !! html
20837 <p>ISBN foo
20838 </p>
20839 !! end
20840
20841
20842 !! test
20843 ISBN length
20844 !! wikitext
20845 ISBN 123456789
20846
20847 ISBN 1234567890
20848
20849 ISBN 12345678901
20850 !! html/php
20851 <p>ISBN 123456789
20852 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20853 </p><p>ISBN 12345678901
20854 </p>
20855 !! html/parsoid
20856 <p>ISBN 123456789</p>
20857
20858 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
20859
20860 <p>ISBN 12345678901</p>
20861 !! end
20862
20863
20864 !! test
20865 ISBN with trailing year (T9110)
20866 !! wikitext
20867 ISBN 1-234-56789-0 - 2006
20868
20869 ISBN 1 234 56789 0 - 2006
20870 !! html/php
20871 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
20872 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
20873 </p>
20874 !! html/parsoid
20875 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
20876
20877 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
20878 !! end
20879
20880
20881 !! test
20882 anchorencode
20883 !! wikitext
20884 {{anchorencode:foo bar©#%n}}
20885 !! html
20886 <p>foo_bar.C2.A9.23.25n
20887 </p>
20888 !! end
20889
20890 !! test
20891 anchorencode trims spaces
20892 !! wikitext
20893 {{anchorencode: __pretty__please__}}
20894 !! html
20895 <p>pretty_please
20896 </p>
20897 !! end
20898
20899 !! test
20900 anchorencode deals with links
20901 !! wikitext
20902 {{anchorencode: [[hello|world]] [[hi]]}}
20903 !! html
20904 <p>world_hi
20905 </p>
20906 !! end
20907
20908 !! test
20909 anchorencode deals with templates
20910 !! wikitext
20911 {{anchorencode: {{Foo}} }}
20912 !! html
20913 <p>FOO
20914 </p>
20915 !! end
20916
20917 !! test
20918 anchorencode encodes like the TOC generator: (T20431)
20919 !! wikitext
20920 === _ +:.3A%3A&&amp;]] ===
20921 {{anchorencode: _ +:.3A%3A&&amp;]] }}
20922 __NOEDITSECTION__
20923 !! html
20924 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
20925 <p>.2B:.3A.253A.26.26.5D.5D
20926 </p>
20927 !! end
20928
20929 !! test
20930 T8200: blockquotes and paragraph formatting
20931 !! wikitext
20932 <blockquote>
20933 foo
20934 </blockquote>
20935
20936 bar
20937
20938 baz
20939 !! html
20940 <blockquote>
20941 <p>foo
20942 </p>
20943 </blockquote>
20944 <p>bar
20945 </p>
20946 <pre>baz
20947 </pre>
20948 !! end
20949
20950 !! test
20951 T10293: Use of center tag ruins paragraph formatting
20952 !! wikitext
20953 <center>
20954 foo
20955 </center>
20956
20957 bar
20958
20959 baz
20960 !! html
20961 <center>
20962 <p>foo
20963 </p>
20964 </center>
20965 <p>bar
20966 </p>
20967 <pre>baz
20968 </pre>
20969 !! end
20970
20971 !!test
20972 Parsing of overlapping (improperly nested) inline html tags
20973 !! wikitext
20974 <span><s>x</span></s>
20975 !! html/php
20976 <p><span><s>x&lt;/span&gt;</s></span>
20977 </p>
20978 !! html/parsoid
20979 <p><span><s>x</s></span>
20980 </p>
20981 !!end
20982
20983 ###
20984 ### Language variants related tests
20985 ###
20986 !! test
20987 Self-link in language variants
20988 !! options
20989 title=[[Dunav]] language=sr
20990 !! wikitext
20991 Both [[Dunav]] and [[Дунав]] are names for this river.
20992 !! html
20993 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
20994 </p>
20995 !!end
20996
20997 !! article
20998 Дуна
20999 !! text
21000 content
21001 !! endarticle
21002
21003 !! test
21004 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
21005 !! options
21006 title=[[Duna]] language=sr
21007 !! wikitext
21008 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
21009 !! html
21010 <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.
21011 </p>
21012 !! end
21013
21014 !! test
21015 Link to a section of a variant of this title shouldn't be parsed as self-link
21016 !! options
21017 title=[[Duna]] language=sr
21018 !! wikitext
21019 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
21020 !! html
21021 <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.
21022 </p>
21023 !! end
21024
21025 !! test
21026 Link to pages in language variants
21027 !! options
21028 language=sr
21029 !! wikitext
21030 Main Page can be written as [[Маин Паге]]
21031 !! html
21032 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
21033 </p>
21034 !!end
21035
21036
21037 !! test
21038 Multiple links to pages in language variants
21039 !! options
21040 language=sr
21041 !! wikitext
21042 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
21043 !! html
21044 <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>.
21045 </p>
21046 !!end
21047
21048
21049 !! test
21050 Simple template in language variants
21051 !! options
21052 language=sr
21053 !! wikitext
21054 {{тест}}
21055 !! html
21056 <p>This is a test template
21057 </p>
21058 !! end
21059
21060
21061 !! test
21062 Template with explicit namespace in language variants
21063 !! options
21064 language=sr
21065 !! wikitext
21066 {{Template:тест}}
21067 !! html
21068 <p>This is a test template
21069 </p>
21070 !! end
21071
21072
21073 !! test
21074 Basic test for template parameter in language variants
21075 !! options
21076 language=sr
21077 !! wikitext
21078 {{парамтест|param=foo}}
21079 !! html
21080 <p>This is a test template with parameter foo
21081 </p>
21082 !! end
21083
21084 !! test
21085 Simple category in language variants
21086 !! options
21087 language=sr cat
21088 !! wikitext
21089 [[Category:МедиаWики Усер'с Гуиде]]
21090 !! html/php
21091 cat=МедиаWики_Усер'с_Гуиде sort=
21092 !! html/parsoid
21093 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
21094 !! end
21095
21096 !! article
21097 Category:分类
21098 !! text
21099 blah
21100 !! endarticle
21101
21102 !! article
21103 Category:分類
21104 !! text
21105 blah
21106 !! endarticle
21107
21108 ## We used to, but no longer wt2wt this test since the default serializer
21109 ## will normalize all categories to serialize on their own line.
21110 ## This wikitext usage is going to be fairly uncommon in production and
21111 ## selser will take care of preserving formatting in those scenarios.
21112 !! test
21113 Don't convert blue categorylinks to another variant (T35210)
21114 !! options
21115 cat
21116 language=zh
21117 parsoid=wt2html
21118 !! wikitext
21119 [[A]][[Category:分类]]
21120 !! html/php
21121 cat=分类 sort=
21122 !! html/parsoid
21123 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
21124 <link rel="mw:PageProp/Category" href="./Category:分类"/>
21125 !! end
21126
21127 !! test
21128 Stripping -{}- tags (language variants)
21129 !! options
21130 language=sr
21131 !! wikitext
21132 Latin proverb: -{Ne nuntium necare}-
21133 !! html
21134 <p>Latin proverb: Ne nuntium necare
21135 </p>
21136 !! end
21137
21138
21139 !! test
21140 Prevent conversion with -{}- tags (language variants)
21141 !! options
21142 language=sr variant=sr-ec
21143 !! wikitext
21144 Latinski: -{Ne nuntium necare}-
21145 !! html
21146 <p>Латински: Ne nuntium necare
21147 </p>
21148 !! end
21149
21150
21151 !! test
21152 Prevent conversion of text with -{}- tags (language variants)
21153 !! options
21154 language=sr variant=sr-ec
21155 !! wikitext
21156 Latinski: -{Ne nuntium necare}-
21157 !! html
21158 <p>Латински: Ne nuntium necare
21159 </p>
21160 !! end
21161
21162
21163 !! test
21164 Prevent conversion of links with -{}- tags (language variants)
21165 !! options
21166 language=sr variant=sr-ec
21167 !! wikitext
21168 -{[[Main Page]]}-
21169 !! html
21170 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21171 </p>
21172 !! end
21173
21174
21175 !! test
21176 -{}- tags within headlines (within html for parserConvert())
21177 !! options
21178 language=sr variant=sr-ec
21179 !! wikitext
21180 == -{Naslov}- ==
21181 !! html
21182 <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>
21183
21184 !! end
21185
21186
21187 !! test
21188 Explicit definition of language variant alternatives
21189 !! options
21190 language=zh variant=zh-tw
21191 !! wikitext
21192 -{zh:China;zh-tw:Taiwan}-, not China
21193 !! html
21194 <p>Taiwan, not China
21195 </p>
21196 !! end
21197
21198
21199 !! test
21200 Conversion around HTML tags
21201 !! options
21202 language=sr variant=sr-ec
21203 !! wikitext
21204 -{H|span=>sr-ec:script;title=>sr-ec:src;}-
21205 <span title="La-{sr-el:L;sr-ec:C;}-tin">ski</span>
21206 !! html
21207 <p>
21208 <span title="ЛаCтин">ски</span>
21209 </p>
21210 !! end
21211
21212
21213 !! test
21214 Explicit session-wise language variant mapping (A flag and - flag)
21215 !! options
21216 language=zh variant=zh-tw
21217 !! wikitext
21218 Taiwan is not China.
21219 But -{A|zh:China;zh-tw:Taiwan}- is China,
21220 (This-{-|zh:China;zh-tw:Taiwan}- should be stripped!)
21221 and -{China}- is China.
21222 !! html
21223 <p>Taiwan is not China.
21224 But Taiwan is Taiwan,
21225 (This should be stripped!)
21226 and China is China.
21227 </p>
21228 !! end
21229
21230 !! test
21231 Explicit session-wise language variant mapping (H flag for hide)
21232 !! options
21233 language=zh variant=zh-tw
21234 !! wikitext
21235 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
21236 Taiwan is China.
21237 !! html
21238 <p>(This should be stripped!)
21239 Taiwan is Taiwan.
21240 </p>
21241 !! end
21242
21243 !! test
21244 Adding explicit conversion rule for title (T flag)
21245 !! options
21246 language=zh variant=zh-tw showtitle
21247 !! wikitext
21248 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
21249 !! html
21250 Taiwan
21251 <p>Should be stripped!
21252 </p>
21253 !! end
21254
21255 !! test
21256 Testing that changing the language variant here in the tests actually works
21257 !! options
21258 language=zh variant=zh showtitle
21259 !! wikitext
21260 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
21261 !! html
21262 China
21263 <p>Should be stripped!
21264 </p>
21265 !! end
21266
21267 !! test
21268 Recursive conversion of alt and title attrs shouldn't clear converter state
21269 !! options
21270 language=zh variant=zh-cn showtitle
21271 !! wikitext
21272 -{H|zh-cn:Exclamation;zh-tw:exclamation;}-
21273 Should be stripped-{T|zh-cn:China;zh-tw:Taiwan}-<span title="exclamation">!</span>
21274 !! html
21275 China
21276 <p>
21277 Should be stripped<span title="Exclamation">!</span>
21278 </p>
21279 !! end
21280
21281 !! test
21282 T26072: more test on conversion rule for title
21283 !! options
21284 language=zh variant=zh-tw showtitle
21285 !! wikitext
21286 This should be stripped-{T|zh:China;zh-tw:Taiwan}-!
21287 This won't take interferes with the title rule-{H|zh:Beijing;zh-tw:Taipei}-.
21288 !! html
21289 Taiwan
21290 <p>This should be stripped!
21291 This won't take interferes with the title rule.
21292 </p>
21293 !! end
21294
21295 !! test
21296 Partly disable title conversion if variant == main language code
21297 !! options
21298 language=zh variant=zh title=[[ZH]] showtitle
21299 !! wikitext
21300 -{T|zh-cn:CN;zh-tw:TW}-
21301 !! html
21302 ZH
21303 <p>
21304 </p>
21305 !! end
21306
21307 !! test
21308 Partly disable title conversion if variant == main language code, more
21309 !! options
21310 language=zh variant=zh title=[[ZH]] showtitle
21311 !! wikitext
21312 -{T|TW}-
21313 !! html
21314 ZH
21315 <p>
21316 </p>
21317 !! end
21318
21319 !! test
21320 Raw output of variant escape tags (R flag)
21321 !! options
21322 language=zh variant=zh-tw
21323 !! wikitext
21324 Raw: -{R|zh:China;zh-tw:Taiwan}-
21325 !! html
21326 <p>Raw: zh:China;zh-tw:Taiwan
21327 </p>
21328 !! end
21329
21330 !! test
21331 Nested markup inside raw output of variant escape tags (R flag)
21332 !! options
21333 language=zh variant=zh-tw
21334 !! wikitext
21335 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
21336 !! html
21337 <p>Nested raw: nested Taiwan nested
21338 </p>
21339 !! end
21340
21341 !! test
21342 Templates inside raw output of variant escape tags (R flag)
21343 !! options
21344 language=zh variant=zh-tw
21345 !! wikitext
21346 Nested raw: -{R|nested {{echo|hi}} templates}-
21347 !! html
21348 <p>Nested raw: nested hi templates
21349 </p>
21350 !! end
21351
21352 !! test
21353 Strings evaluating false shouldn't be ignored by Language converter (T51072)
21354 !! options
21355 language=zh variant=zh-cn
21356 !! input
21357 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
21358 !! result
21359 <p>0
21360 </p>
21361 !! end
21362
21363 !! test
21364 Conversion rules from [numeric-only string] to [something else] (T48634)
21365 !! options
21366 language=zh variant=zh-cn
21367 !! input
21368 -{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
21369 !! result
21370 <p>D12345EE12345
21371 </p>
21372 !! end
21373
21374 !! test
21375 Bidirectional converter rule entries with an empty value should be ignored (T53551)
21376 !! options
21377 language=zh variant=zh-cn
21378 !! input
21379 -{H|zh-cn:foo;zh-tw:;}-foobar
21380 !! result
21381 <p>foobar
21382 </p>
21383 !! end
21384
21385 !! test
21386 Unidirectional converter rule entries with an empty "from" string should be ignored (T53551)
21387 !! options
21388 language=zh variant=zh-cn
21389 !! input
21390 -{H|=>zh-cn:foo;}-foobar
21391 !! result
21392 <p>foobar
21393 </p>
21394 !! end
21395
21396 !! test
21397 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
21398 !! options
21399 language=zh variant=zh-cn
21400 !! input
21401 -{H|}-foobar
21402 !! result
21403 <p>foobar
21404 </p>
21405 !! end
21406
21407 !! test
21408 Nested using of manual convert syntax
21409 !! options
21410 language=zh variant=zh-hk
21411 !! wikitext
21412 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
21413 !! html
21414 <p>Nested: Hello Hong Kong!
21415 </p>
21416 !! end
21417
21418 !! test
21419 HTML markups with conversion syntax in attribs, nested in other conversion blocks
21420 !! options
21421 language=zh variant=zh-cn
21422 !! wikitext
21423 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
21424 !! html
21425 <p><span title="X">A</span>
21426 </p>
21427 !! end
21428
21429 !! test
21430 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet)
21431 !! options
21432 language=zh variant=zh-cn disabled
21433 !! wikitext
21434 -{<span title="-{X}-">A</span>}-
21435 !! html
21436 <p><span title="X">A</span>
21437 </p>
21438 !! end
21439
21440 # Since Parsoid is starting to emit canonical wikitext for links,
21441 # [http://example.com http://example.com] will not RT back to that
21442 # form anymore.
21443 !! test
21444 Proper conversion of text in external links
21445 !! options
21446 language=sr variant=sr-ec
21447 parsoid=wt2html
21448 !! wikitext
21449 http://www.google.com
21450 gopher://www.google.com
21451 [http://www.google.com http://www.google.com]
21452 [gopher://www.google.com gopher://www.google.com]
21453 [https://www.google.com irc://www.google.com]
21454 [ftp://www.google.com www.google.com/ftp://dir]
21455 [//www.google.com www.google.com]
21456 !! html/php
21457 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
21458 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
21459 <a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
21460 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
21461 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
21462 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
21463 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
21464 </p>
21465 !! html/parsoid
21466 <p><a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
21467 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
21468 <a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
21469 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
21470 <a rel="mw:ExtLink" href="https://www.google.com">irc://www.google.com</a>
21471 <a rel="mw:ExtLink" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
21472 <a rel="mw:ExtLink" href="//www.google.com">www.гоогле.цом</a></p>
21473 !! end
21474
21475 !! test
21476 Do not convert roman numbers to language variants
21477 !! options
21478 language=sr variant=sr-ec
21479 !! wikitext
21480 Fridrih IV je car.
21481 !! html
21482 <p>Фридрих IV је цар.
21483 </p>
21484 !! end
21485
21486 !! test
21487 Unclosed language converter markup "-{"
21488 !! options
21489 language=sr
21490 !! wikitext
21491 -{T|hello
21492 !! html
21493 <p>-{T|hello
21494 </p>
21495 !! end
21496
21497 !! test
21498 Don't convert raw rule "-{R|=&gt;}-" to "=>"
21499 !! options
21500 language=sr
21501 !! wikitext
21502 -{R|=&gt;}-
21503 !! html
21504 <p>=&gt;
21505 </p>
21506 !!end
21507
21508 !! test
21509 Don't break link parsing if language converter markup is in the caption.
21510 !! options
21511 language=sr variant=sr-ec
21512 !! wikitext
21513 [[Main Page|-{R|main page}-]]
21514 !! html
21515 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
21516 </p>
21517 !! end
21518
21519 !! test
21520 T146304: Don't break template parsing if language converter markup is in the parameter.
21521 !! options
21522 language=sr variant=sr-ec
21523 !! wikitext
21524 {{echo|-{R|foo}-}}
21525 !! html/php
21526 <p>foo
21527 </p>
21528 !! end
21529
21530 !! test
21531 T146305: Don't break image parsing if language converter markup is in the caption.
21532 !! options
21533 language=sr
21534 !! wikitext
21535 [[File:Foobar.jpg|thumb|-{R|caption:}-]]
21536 !! html/php
21537 <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>
21538
21539 !! html/parsoid
21540 <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>
21541 !! end
21542
21543 !! test
21544 T146305: Don't break image parsing if nested language converter markup is in the caption.
21545 !! options
21546 language=zh variant=zh-cn
21547 !! wikitext
21548 [[File:Foobar.jpg|thumb|-{zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
21549 !! html/php
21550 <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>
21551
21552 !! html/parsoid
21553 <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>
21554 !! end
21555
21556 !! test
21557 Don't break gallery if language converter markup is inside.
21558 !! options
21559 language=zh
21560 !! wikitext
21561 <gallery>
21562 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
21563 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
21564 </gallery>
21565 !! html
21566 <ul class="gallery mw-gallery-traditional">
21567 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21568 <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>
21569 <div class="gallerytext">
21570 <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>
21571 </p>
21572 </div>
21573 </div></li>
21574 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21575 <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>
21576 <div class="gallerytext">
21577 <p>This is a test template
21578 </p>
21579 </div>
21580 </div></li>
21581 </ul>
21582
21583 !! end
21584
21585 !! test
21586 T153135: Don't break list handling if language converter markup is in the item.
21587 !! options
21588 language=zh variant=zh-cn
21589 !! wikitext
21590 ;-{zh-cn:AAA;zh-tw:BBB}-
21591 ;-{R|foo:bar}-
21592 !! html/php
21593 <dl><dt>AAA</dt>
21594 <dt>foo:bar</dt></dl>
21595
21596 !! html/parsoid
21597 <dl>
21598 <dt><span typeof="mw:LanguageVariant" data-mw='{"bidir":[{"l":"zh-cn","t":"AAA"},{"l":"zh-tw","t":"BBB"}],"show":true}'></span></dt>
21599 <dt><span typeof="mw:LanguageVariant" data-mw='{"disabled":true,"show":true,"text":"foo:bar"}'></span></dt>
21600 </dl>
21601 !! end
21602
21603 // Note that parsoid does not protect colons unless language converter
21604 // markup is properly nested, because it is a backtracking parser.
21605 !! test
21606 T153135: Unclosed markup in definition list (code coverage)
21607 !! options
21608 language=zh variant=zh-cn
21609 !! wikitext
21610 ;<b>foo:bar
21611 ;-{zh-cn:AAA
21612 !! html/php
21613 <dl><dt><b>foo:bar</dt>
21614 <dt>-{zh-cn:AAA</b></dt></dl>
21615
21616 !! html/parsoid
21617 <dl>
21618 <dt><b>foo:bar</b></dt>
21619 <b>
21620 <dt>-{zh-cn</dt>
21621 <dd>AAA</dd>
21622 </b></dl>
21623 !! end
21624
21625 !! test
21626 T153135: Nested language converter markup in definition list (code coverage)
21627 !! options
21628 language=zh variant=zh-cn
21629 !! wikitext
21630 ;-{zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
21631 !! html/php
21632 <dl><dt>AAA foo:bar bat:baz</dt>
21633 <dd>def</dd></dl>
21634
21635 !! html/parsoid
21636 <dl>
21637 <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>
21638 <dd>def</dd>
21639 </dl>
21640 !! end
21641
21642 !! test
21643 T153140: Don't break table handling if language converter markup is in the cell.
21644 !! options
21645 language=sr variant=sr-ec
21646 !! wikitext
21647 {|
21648 |-
21649 | -{R|B}-
21650 |}
21651 !! html/php
21652 <table>
21653
21654 <tr>
21655 <td> B
21656 </td></tr></table>
21657
21658 !! html/parsoid
21659 <table>
21660
21661 <tr>
21662 <td> B
21663 </td></tr></table>
21664
21665 !! end
21666
21667 !! test
21668 T2529: Uncovered bullet
21669 !! wikitext
21670 * Foo {{bullet}}
21671 !! html
21672 <ul><li> Foo </li>
21673 <li> Bar</li></ul>
21674
21675 !! end
21676
21677 # Plain MediaWiki does not remove empty lists, but tidy actually does.
21678 # Templates in Wikipedia rely on this behavior, as tidy has always been
21679 # enabled there. These tests are normally run *without* tidy, so specify the
21680 # full output here.
21681 # To test realistic parsing behavior, apply a tidy-like transformation to both
21682 # the expected output and your parser's output.
21683 !! test
21684 T2529: Uncovered bullet leaving empty list, normally removed by tidy
21685 !! wikitext
21686 ******* Foo {{bullet}}
21687 !! html
21688 <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>
21689 <li> Bar</li></ul>
21690
21691 !! end
21692
21693 !! test
21694 T2529: Uncovered table already at line-start
21695 !! wikitext
21696 x
21697
21698 {{table}}
21699 y
21700 !! html
21701 <p>x
21702 </p>
21703 <table>
21704 <tr>
21705 <td> 1 </td>
21706 <td> 2
21707 </td></tr>
21708 <tr>
21709 <td> 3 </td>
21710 <td> 4
21711 </td></tr></table>
21712 <p>y
21713 </p>
21714 !! end
21715
21716 !! test
21717 T2529: Uncovered bullet in parser function result
21718 !! wikitext
21719 * Foo {{lc:{{bullet}} }}
21720 !! html
21721 <ul><li> Foo </li>
21722 <li> bar</li></ul>
21723
21724 !! end
21725
21726 !! test
21727 T7678: Double-parsed template argument
21728 !! wikitext
21729 {{lc:{{{1}}}|hello}}
21730 !! html
21731 <p>{{{1}}}
21732 </p>
21733 !! end
21734
21735 !! test
21736 T7678: Double-parsed template invocation
21737 !! wikitext
21738 {{lc:{{paramtest {{!}} param = hello }} }}
21739 !! html
21740 <p>{{paramtest | param = hello }}
21741 </p>
21742 !! end
21743
21744 !! test
21745 Case insensitivity of parser functions for non-ASCII characters (T10143)
21746 !! options
21747 language=cs
21748 title=[[Main Page]]
21749 !! wikitext
21750 {{PRVNÍVELKÉ:ěščř}}
21751 {{prvnívelké:ěščř}}
21752 {{PRVNÍMALÉ:ěščř}}
21753 {{prvnímalé:ěščř}}
21754 {{MALÁ:ěščř}}
21755 {{malá:ěščř}}
21756 {{VELKÁ:ěščř}}
21757 {{velká:ěščř}}
21758 !! html
21759 <p>Ěščř
21760 Ěščř
21761 ěščř
21762 ěščř
21763 ěščř
21764 ěščř
21765 ĚŠČŘ
21766 ĚŠČŘ
21767 </p>
21768 !! end
21769
21770 !! test
21771 Morwen/13: Unclosed link followed by heading
21772 !! wikitext
21773 [[link
21774 ==heading==
21775 !! html
21776 <p>[[link
21777 </p>
21778 <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>
21779
21780 !! end
21781
21782 !! test
21783 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
21784 !! wikitext
21785 {{foo|
21786 =heading=
21787 !! html
21788 <p>{{foo|
21789 </p>
21790 <h1><span class="mw-headline" id="heading">heading</span></h1>
21791
21792 !! end
21793
21794 !! test
21795 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
21796 !! wikitext
21797 {{foo|
21798 ==heading==
21799 !! html
21800 <p>{{foo|
21801 </p>
21802 <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>
21803
21804 !! end
21805
21806 !! test
21807 Tildes in comments
21808 !! options
21809 pst
21810 !! wikitext
21811 <!-- ~~~~ -->
21812 !! html/php
21813 <!-- ~~~~ -->
21814 !! end
21815
21816 !! test
21817 Paragraphs inside divs (no extra line breaks)
21818 !! wikitext
21819 <div>Line one
21820
21821 Line two</div>
21822 !! html
21823 <div>Line one
21824 Line two</div>
21825
21826 !! end
21827
21828 !! test
21829 Paragraphs inside divs (extra line break on open)
21830 !! wikitext
21831 <div>
21832 Line one
21833
21834 Line two</div>
21835 !! html
21836 <div>
21837 <p>Line one
21838 </p>
21839 Line two</div>
21840
21841 !! end
21842
21843 !! test
21844 Paragraphs inside divs (extra line break on close)
21845 !! wikitext
21846 <div>Line one
21847
21848 Line two
21849 </div>
21850 !! html
21851 <div>Line one
21852 <p>Line two
21853 </p>
21854 </div>
21855
21856 !! end
21857
21858 !! test
21859 Paragraphs inside divs (extra line break on open and close)
21860 !! wikitext
21861 <div>
21862 Line one
21863
21864 Line two
21865 </div>
21866 !! html
21867 <div>
21868 <p>Line one
21869 </p><p>Line two
21870 </p>
21871 </div>
21872
21873 !! end
21874
21875 !! test
21876 Nesting tags, paragraphs on lines which begin with <div>
21877 !! wikitext
21878 <div></div><strong>A
21879 B</strong>
21880 !! html/php+tidy
21881 <p><strong>A</strong></p>
21882 <p><strong>B</strong></p>
21883 !! html/parsoid
21884 <div></div>
21885 <p><strong>A
21886 B</strong>
21887 </p>
21888 !! end
21889
21890 # T8200: <blockquote> should behave like <div> with respect to line breaks
21891 !! test
21892 T8200: paragraphs inside blockquotes (no extra line breaks)
21893 !! wikitext
21894 <blockquote>Line one
21895
21896 Line two</blockquote>
21897 !! html
21898 <blockquote>Line one
21899 Line two</blockquote>
21900
21901 !! html+tidy
21902 <blockquote>
21903 <p>Line one Line two</p>
21904 </blockquote>
21905 !! end
21906
21907 !! test
21908 T8200: paragraphs inside blockquotes (extra line break on open)
21909 !! wikitext
21910 <blockquote>
21911 Line one
21912
21913 Line two</blockquote>
21914 !! html
21915 <blockquote>
21916 <p>Line one
21917 </p>
21918 Line two</blockquote>
21919
21920 !! html+tidy
21921 <blockquote>
21922 <p>Line one</p>
21923 Line two</blockquote>
21924 !! end
21925
21926 !! test
21927 T8200: paragraphs inside blockquotes (extra line break on close)
21928 !! wikitext
21929 <blockquote>Line one
21930
21931 Line two
21932 </blockquote>
21933 !! html
21934 <blockquote>Line one
21935 <p>Line two
21936 </p>
21937 </blockquote>
21938
21939 !! html+tidy
21940 <blockquote>
21941 <p>Line one</p>
21942 <p>Line two</p>
21943 </blockquote>
21944 !! end
21945
21946 !! test
21947 T8200: paragraphs inside blockquotes (extra line break on open and close)
21948 !! wikitext
21949 <blockquote>
21950 Line one
21951
21952 Line two
21953 </blockquote>
21954 !! html
21955 <blockquote>
21956 <p>Line one
21957 </p><p>Line two
21958 </p>
21959 </blockquote>
21960
21961 !! html+tidy
21962 <blockquote>
21963 <p>Line one</p>
21964 <p>Line two</p>
21965 </blockquote>
21966 !! end
21967
21968 !! test
21969 Paragraphs inside blockquotes/divs (no extra line breaks)
21970 !! wikitext
21971 <blockquote><div>Line one
21972
21973 Line two</div></blockquote>
21974 !! html
21975 <blockquote><div>Line one
21976 Line two</div></blockquote>
21977
21978 !! end
21979
21980 !! test
21981 Paragraphs inside blockquotes/divs (extra line break on open)
21982 !! wikitext
21983 <blockquote><div>
21984 Line one
21985
21986 Line two</div></blockquote>
21987 !! html
21988 <blockquote><div>
21989 <p>Line one
21990 </p>
21991 Line two</div></blockquote>
21992
21993 !! end
21994
21995 !! test
21996 Paragraphs inside blockquotes/divs (extra line break on close)
21997 !! wikitext
21998 <blockquote><div>Line one
21999
22000 Line two
22001 </div></blockquote>
22002 !! html
22003 <blockquote><div>Line one
22004 <p>Line two
22005 </p>
22006 </div></blockquote>
22007
22008 !! end
22009
22010 !! test
22011 Paragraphs inside blockquotes/divs (extra line break on open and close)
22012 !! wikitext
22013 <blockquote><div>
22014 Line one
22015
22016 Line two
22017 </div></blockquote>
22018 !! html
22019 <blockquote><div>
22020 <p>Line one
22021 </p><p>Line two
22022 </p>
22023 </div></blockquote>
22024
22025 !! end
22026
22027 !! test
22028 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
22029 !! options
22030 wgLinkHolderBatchSize=0
22031 !! wikitext
22032 [[meatball:1]]
22033 [[meatball:2]]
22034 [[meatball:3]]
22035 !! html
22036 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
22037 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
22038 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
22039 </p>
22040 !! end
22041
22042 !! test
22043 Free external link invading image caption
22044 !! wikitext
22045 [[Image:Foobar.jpg|thumb|http://x|hello]]
22046 !! html
22047 <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>
22048
22049 !! end
22050
22051 !! test
22052 T17196: localised external link numbers
22053 !! options
22054 language=fa
22055 !! wikitext
22056 [http://en.wikipedia.org/]
22057 !! html/php
22058 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
22059 </p>
22060 !! html/parsoid
22061 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/"></a></p>
22062 !! end
22063
22064 !! test
22065 Multibyte character in padleft
22066 !! wikitext
22067 {{padleft:-Hello|7|Æ}}
22068 !! html
22069 <p>Æ-Hello
22070 </p>
22071 !! end
22072
22073 !! test
22074 Multibyte character in padright
22075 !! wikitext
22076 {{padright:Hello-|7|Æ}}
22077 !! html
22078 <p>Hello-Æ
22079 </p>
22080 !! end
22081
22082 !!test
22083 formatdate parser function
22084 !! wikitext
22085 {{#formatdate:2009-03-24}}
22086 !! html
22087 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
22088 </p>
22089 !! end
22090
22091 !!test
22092 formatdate parser function, with default format
22093 !! wikitext
22094 {{#formatdate:2009-03-24|mdy}}
22095 !! html
22096 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
22097 </p>
22098 !! end
22099
22100 !! test
22101 Spacing of numbers in formatted dates
22102 !! wikitext
22103 {{#formatdate:January 15}}
22104 !! html
22105 <p><span class="mw-formatted-date" title="01-15">January 15</span>
22106 </p>
22107 !! end
22108
22109 !! test
22110 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
22111 !! options
22112 language=nl title=[[MediaWiki:Common.css]]
22113 !! wikitext
22114 {{#formatdate:2009-03-24|dmy}}
22115 !! html
22116 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
22117 </p>
22118 !! end
22119
22120 #
22121 #
22122 #
22123
22124 #
22125 # Edit comments
22126 #
22127
22128 !! test
22129 Edit comment with link
22130 !! options
22131 comment
22132 !! wikitext
22133 I like the [[Main Page]] a lot
22134 !! html/php
22135 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
22136 !!end
22137
22138 !! test
22139 Edit comment with link and link text
22140 !! options
22141 comment
22142 !! wikitext
22143 I like the [[Main Page|best pages]] a lot
22144 !! html/php
22145 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
22146 !!end
22147
22148 !! test
22149 Edit comment with link and link text with suffix
22150 !! options
22151 comment
22152 !! wikitext
22153 I like the [[Main Page|best page]]s a lot
22154 !! html/php
22155 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
22156 !!end
22157
22158 !! test
22159 Edit comment with section link (non-local, eg in history list)
22160 !! options
22161 comment title=[[Main Page]]
22162 !! wikitext
22163 /* External links */ removed bogus entries
22164 !! html/php
22165 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
22166 !!end
22167
22168 !! test
22169 Edit comment with section link and text before it (non-local, eg in history list)
22170 !! options
22171 comment title=[[Main Page]]
22172 !! wikitext
22173 pre-comment text /* External links */ removed bogus entries
22174 !! html/php
22175 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>
22176 !!end
22177
22178 !! test
22179 Edit comment with section link (local, eg in diff view)
22180 !! options
22181 comment local title=[[Main Page]]
22182 !! wikitext
22183 /* External links */ removed bogus entries
22184 !! html/php
22185 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
22186 !!end
22187
22188 !! test
22189 Edit comment with subpage link (T16080)
22190 !! options
22191 comment
22192 subpage
22193 title=[[Subpage test]]
22194 !! wikitext
22195 Poked at a [[/subpage]] here...
22196 !! html/php
22197 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
22198 !!end
22199
22200 !! test
22201 Edit comment with subpage link and link text (T16080)
22202 !! options
22203 comment
22204 subpage
22205 title=[[Subpage test]]
22206 !! wikitext
22207 Poked at a [[/subpage|neat little page]] here...
22208 !! html/php
22209 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
22210 !!end
22211
22212 !! test
22213 Edit comment with bogus subpage link in non-subpage NS (T16080)
22214 !! options
22215 comment
22216 title=[[Subpage test]]
22217 !! wikitext
22218 Poked at a [[/subpage]] here...
22219 !! html/php
22220 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...
22221 !!end
22222
22223 !! test
22224 Edit comment with bare anchor link (local, as on diff)
22225 !! options
22226 comment
22227 local
22228 title=[[Main Page]]
22229 !! wikitext
22230 [[#section]]
22231 !! html/php
22232 <a href="#section">#section</a>
22233 !! end
22234
22235 !! test
22236 Edit comment with bare anchor link (non-local, as on history)
22237 !! options
22238 comment
22239 title=[[Main Page]]
22240 !! wikitext
22241 [[#section]]
22242 !! html/php
22243 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
22244 !! end
22245
22246 !! test
22247 Anchor starting with underscore
22248 !! options
22249 title=[[Foo]]
22250 !! wikitext
22251 [[#_ref|One]]
22252 !! html/php
22253 <p><a href="#_ref">One</a>
22254 </p>
22255 !! html/parsoid
22256 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
22257 !! end
22258
22259 !! test
22260 Id starting with underscore
22261 !! wikitext
22262 <div id="_ref"></div>
22263 !! html/*
22264 <div id="_ref"></div>
22265
22266 !! end
22267
22268 !! test
22269 Edit comment with link with more than one pipe (T99346)
22270 !! options
22271 comment
22272 !! wikitext
22273 [[Main Page|Many|pipes]]
22274 !! html/php
22275 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
22276 !! end
22277
22278 !! test
22279 Complex edit comment with link with more than one pipe (T99346)
22280 !! options
22281 comment
22282 !! wikitext
22283 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
22284 !! html/php
22285 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;
22286 !! end
22287
22288 !! test
22289 Space normalisation on autocomment (T24784)
22290 !! options
22291 comment
22292 title=[[Main Page]]
22293 !! wikitext
22294 /* __hello__world__ */
22295 !! html/php
22296 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
22297 !! end
22298
22299 !! test
22300 percent-encoding and + signs in comments (T28410)
22301 !! options
22302 comment
22303 !! wikitext
22304 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
22305 !! html/php
22306 <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>
22307 !! end
22308
22309 # Parsoid doesn't support this yet: see T75581
22310 # but it *should* omit the 'src' attribute if the image is bad.
22311 # PHP side of tests was disabled in
22312 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
22313 # because of issues in the PHP parserTests infrastructure
22314 # (but the output below is indeed what the PHP side emits)
22315 !! test
22316 Bad images - basic functionality
22317 !! wikitext
22318 [[File:Bad.jpg]]
22319 !! DISABLED/html/php
22320 !! html/parsoid
22321 <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>
22322 !! end
22323
22324 !! test
22325 Bad images - T18039: text after bad image disappears
22326 !! wikitext
22327 Foo bar
22328 [[File:Bad.jpg]]
22329 Bar foo
22330 !! DISABLED/html/php
22331 <p>Foo bar
22332 </p><p>Bar foo
22333 </p>
22334 !! html/parsoid
22335 <p>Foo bar
22336 <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>
22337 Bar foo</p>
22338 !! end
22339
22340 !! test
22341 Verify that displaytitle works (T24501) no displaytitle
22342 !! options
22343 showtitle
22344 !! config
22345 wgAllowDisplayTitle=true
22346 wgRestrictDisplayTitle=false
22347 !! wikitext
22348 this is not the the title
22349 !! html/php
22350 Parser test
22351 <p>this is not the the title
22352 </p>
22353 !! end
22354
22355 !! test
22356 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
22357 !! options
22358 showtitle
22359 title=[[Screen]]
22360 !! config
22361 wgAllowDisplayTitle=true
22362 wgRestrictDisplayTitle=false
22363 !! wikitext
22364 this is not the the title
22365 {{DISPLAYTITLE:whatever}}
22366 !! html/php
22367 whatever
22368 <p>this is not the the title
22369 </p>
22370 !! end
22371
22372 !! test
22373 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
22374 !! options
22375 showtitle
22376 title=[[Screen]]
22377 !! config
22378 wgAllowDisplayTitle=true
22379 wgRestrictDisplayTitle=true
22380 !! wikitext
22381 this is not the the title
22382 {{DISPLAYTITLE:whatever}}
22383 !! html/php
22384 Screen
22385 <p>this is not the the title
22386 </p>
22387 !! end
22388
22389 !! test
22390 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
22391 !! options
22392 showtitle
22393 title=[[Screen]]
22394 !! config
22395 wgAllowDisplayTitle=true
22396 wgRestrictDisplayTitle=true
22397 !! wikitext
22398 this is not the the title
22399 {{DISPLAYTITLE:screen}}
22400 !! html/php
22401 screen
22402 <p>this is not the the title
22403 </p>
22404 !! end
22405
22406 !! test
22407 Verify that displaytitle works (T24501) AllowDisplayTitle=false
22408 !! options
22409 showtitle
22410 title=[[Screen]]
22411 !! config
22412 wgAllowDisplayTitle=false
22413 !! wikitext
22414 this is not the the title
22415 {{DISPLAYTITLE:screen}}
22416 !! html/php
22417 Screen
22418 <p>this is not the the title
22419 <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>
22420 </p>
22421 !! end
22422
22423 !! test
22424 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
22425 !! options
22426 showtitle
22427 title=[[Screen]]
22428 !! config
22429 wgAllowDisplayTitle=false
22430 !! wikitext
22431 this is not the the title
22432 !! html/php
22433 Screen
22434 <p>this is not the the title
22435 </p>
22436 !! end
22437
22438 !! test
22439 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
22440 !! options
22441 showtitle
22442 title=[[Screen]]
22443 !! config
22444 wgAllowDisplayTitle=true
22445 wgRestrictDisplayTitle=true
22446 !! wikitext
22447 this is not the the title
22448 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
22449 !! html/php
22450 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
22451 <p>this is not the the title
22452 </p>
22453 !! end
22454
22455 !! test
22456 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
22457 !! options
22458 showtitle
22459 title=[[Screen]]
22460 !! config
22461 wgAllowDisplayTitle=true
22462 wgRestrictDisplayTitle=true
22463 !! wikitext
22464 this is not the the title
22465 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
22466 !! html/php
22467 <span style="color: red;">s</span>creen
22468 <p>this is not the the title
22469 </p>
22470 !! end
22471
22472 !! test
22473 Page status indicators: Empty name is invalid
22474 !! options
22475 showindicators
22476 !! wikitext
22477 <indicator name=" "></indicator>
22478 <indicator></indicator>
22479 !! html/php
22480 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
22481 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
22482 </p>
22483 !! end
22484
22485 !! test
22486 Page status indicators: Weird syntaxes that are okay
22487 !! options
22488 showindicators
22489 !! wikitext
22490 <indicator name="empty" />
22491 <indicator name="name"></indicator>
22492 !! html/php
22493 empty=
22494 name=
22495 <p><br />
22496 </p>
22497 !! end
22498
22499 !! test
22500 Page status indicators: Torture test
22501 !! options
22502 showindicators
22503 !! wikitext
22504 <indicator name="01">hello world</indicator>
22505 <indicator name="02">[[Main Page]]</indicator>
22506 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
22507 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
22508 <indicator name="05">* foo
22509 * bar</indicator>
22510 <indicator name="06"><nowiki>foo</nowiki></indicator>
22511 <indicator name="07"> Preformatted</indicator>
22512 <indicator name="08"><div>Broken tag</indicator>
22513 <indicator name="09">{| class=wikitable
22514 | cell
22515 |}</indicator>
22516 <indicator name="10">Two
22517
22518 paragraphs</indicator>
22519 !! html/php
22520 01=hello world
22521 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22522 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" />
22523 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>
22524 05=<ul><li> foo</li>
22525 <li> bar</li></ul>
22526
22527 06=foo
22528 07=<pre>Preformatted
22529 </pre>
22530 08=<div>Broken tag</div>
22531
22532 09=<table class="wikitable">
22533 <tr>
22534 <td> cell
22535 </td></tr></table>
22536
22537 10=<p>Two
22538 </p><p>paragraphs
22539 </p>
22540 <p><br />
22541 </p><p><br />
22542 </p><p><br />
22543 </p><p><br />
22544 </p><p><br />
22545 </p>
22546 !! end
22547
22548 !! test
22549 preload: check <noinclude> and <includeonly>
22550 !! options
22551 preload
22552 !! wikitext
22553 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
22554 !! html/php
22555 Hello kind world.
22556 !! end
22557
22558 !! test
22559 preload: check <onlyinclude>
22560 !! options
22561 preload
22562 !! wikitext
22563 Goodbye <onlyinclude>Hello world</onlyinclude>
22564 !! html/php
22565 Hello world
22566 !! end
22567
22568 !! test
22569 preload: can pass tags through if we want to
22570 !! options
22571 preload
22572 !! wikitext
22573 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
22574 !! html/php
22575 <includeonly>Hello world</includeonly>
22576 !! end
22577
22578 !! test
22579 preload: check that it doesn't try to do tricks
22580 !! options
22581 preload
22582 !! wikitext
22583 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
22584 !! html/php
22585 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
22586 !! end
22587
22588 !! test
22589 Play a bit with r67090 and T5158
22590 !! wikitext
22591 <div style="width:50% !important">&nbsp;</div>
22592 <div style="width:50%&nbsp;!important">&nbsp;</div>
22593 <div style="width:50%&#160;!important">&nbsp;</div>
22594 <div style="border : solid;">&nbsp;</div>
22595 !! html/php
22596 <div style="width:50% !important">&#160;</div>
22597 <div style="width:50% !important">&#160;</div>
22598 <div style="width:50% !important">&#160;</div>
22599 <div style="border&#160;: solid;">&#160;</div>
22600
22601 !! html/parsoid
22602 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
22603 <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>
22604 <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>
22605 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
22606
22607 !! end
22608
22609 !! test
22610 HTML5 data attributes
22611 !! wikitext
22612 <span data-foo="bar">Baz</span>
22613 <p data-abc-def_hij="">Quuz</p>
22614 !! html/php
22615 <p><span data-foo="bar">Baz</span>
22616 </p>
22617 <p data-abc-def_hij="">Quuz</p>
22618
22619 !! html/parsoid
22620 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
22621 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
22622 !! end
22623
22624 !! test
22625 Strip reserved data attributes
22626 !! wikitext
22627 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
22628 !! html/php
22629 <div data-ok="fred">d</div>
22630
22631 !! html/parsoid
22632 <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>
22633 !! end
22634
22635 !! test
22636 percent-encoding and + signs in internal links (T28410)
22637 !! wikitext
22638 [[User:+%]] [[Page+title%]]
22639 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
22640 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
22641 [[%33%45]] [[%33%45+]]
22642 !! html/php
22643 <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>
22644 <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>
22645 <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>
22646 <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>
22647 </p>
22648 !! html/parsoid
22649 <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>
22650 <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>
22651 <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>
22652 <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>
22653 !! end
22654
22655 !! test
22656 Special characters in embedded file links (T29679)
22657 !! wikitext
22658 [[File:Contains & ampersand.jpg]]
22659 [[File:Does not exist.jpg|Title with & ampersand]]
22660 !! html/php
22661 <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>
22662 <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>
22663 </p>
22664 !! html/parsoid
22665 <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>
22666 <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>
22667 !! end
22668
22669 !! test
22670 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
22671 !! wikitext
22672 Text&apos;s been normalized?
22673 !! html
22674 <p>Text&#39;s been normalized?
22675 </p>
22676 !! end
22677
22678 !! test
22679 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
22680 !! wikitext
22681 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
22682 !! html
22683 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
22684 </p>
22685 !! end
22686
22687 !! test
22688 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
22689 !! wikitext
22690 [http://www.example.org/ ideograms]
22691 !! html
22692 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
22693 </p>
22694 !! end
22695
22696 !! test
22697 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
22698 !! wikitext
22699 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
22700 !! html
22701 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
22702 </p>
22703 !! end
22704
22705 !! article
22706 Mediawiki:loop1
22707 !! text
22708 {{Identical|A}}
22709 !! endarticle
22710
22711 !! article
22712 Mediawiki:loop2
22713 !! text
22714 {{Identical|B}}
22715 !! endarticle
22716
22717 !! article
22718 Template:Identical
22719 !! text
22720 {{int:loop1}}
22721 {{int:loop2}}
22722 !! endarticle
22723
22724 !! test
22725 T33098 Template which includes system messages which includes the template
22726 !! wikitext
22727 {{Identical}}
22728 !! html
22729 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
22730 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
22731 </p>
22732 !! end
22733
22734 !! test
22735 T33490 Turkish: ucfirst 'blah'
22736 !! options
22737 language=tr
22738 !! wikitext
22739 {{ucfirst:blah}}
22740 !! html
22741 <p>Blah
22742 </p>
22743 !! end
22744
22745 !! test
22746 T33490 Turkish: ucfirst 'ix'
22747 !! options
22748 language=tr
22749 !! wikitext
22750 {{ucfirst:ix}}
22751 !! html
22752 <p>İx
22753 </p>
22754 !! end
22755
22756 !! test
22757 T33490 Turkish: lcfirst 'BLAH'
22758 !! options
22759 language=tr
22760 !! wikitext
22761 {{lcfirst:BLAH}}
22762 !! html
22763 <p>bLAH
22764 </p>
22765 !! end
22766
22767 !! test
22768 T33490 Turkish: ucfırst (with a dotless i)
22769 !! options
22770 language=tr
22771 !! wikitext
22772 {{ucfırst:blah}}
22773 !! html
22774 <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>
22775 </p>
22776 !! end
22777
22778 !! test
22779 T33490 ucfırst (with a dotless i) with English language
22780 !! options
22781 language=en
22782 !! wikitext
22783 {{ucfırst:blah}}
22784 !! html
22785 <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>
22786 </p>
22787 !! end
22788
22789 # Note that Parsoid doesn't emit an explicit TOC.
22790 # Note also that the html2wt direction tends to emit an extra newline
22791 # between the __TOC__ magicword and the first heading unless *both*
22792 # the <meta> and the <h2> have a data-parsoid attribute set (even if
22793 # it's "{}").
22794
22795 !! test
22796 T28375: TOC with italics
22797 !! options
22798 title=[[Main Page]]
22799 !! wikitext
22800 __TOC__
22801 == ''Lost'' episodes ==
22802 !! html/php
22803 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22804 <ul>
22805 <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>
22806 </ul>
22807 </div>
22808
22809 <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>
22810
22811 !! html/parsoid
22812 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22813 <h2 data-parsoid='{}'> <i>Lost</i> episodes </h2>
22814 !! end
22815
22816 !! test
22817 T28375: TOC with bold
22818 !! options
22819 title=[[Main Page]]
22820 !! wikitext
22821 __TOC__
22822 == '''should be bold''' then normal text ==
22823 !! html/php
22824 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22825 <ul>
22826 <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>
22827 </ul>
22828 </div>
22829
22830 <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>
22831
22832 !! html/parsoid
22833 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22834 <h2 data-parsoid='{}'> <b>should be bold</b> then normal text </h2>
22835 !! end
22836
22837 !! test
22838 T35845: Headings become cursive in TOC when they contain an image
22839 !! options
22840 title=[[Main Page]]
22841 !! wikitext
22842 __TOC__
22843 == Image [[Image:foobar.jpg]] ==
22844 !! html/php
22845 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22846 <ul>
22847 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
22848 </ul>
22849 </div>
22850
22851 <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>
22852
22853 !! html/parsoid
22854 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22855 <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>
22856 !! end
22857
22858 !! test
22859 T35845 (2): Headings become bold in TOC when they contain a blockquote
22860 !! options
22861 title=[[Main Page]]
22862 !! wikitext
22863 __TOC__
22864 == <blockquote>Quote</blockquote> ==
22865 !! html/php
22866 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22867 <ul>
22868 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
22869 </ul>
22870 </div>
22871
22872 <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>
22873
22874 !! html/php+tidy
22875 <p></p>
22876 <div id="toc" class="toc">
22877 <div class="toctitle">
22878 <h2>Contents</h2>
22879 </div>
22880 <ul>
22881 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
22882 </ul>
22883 </div>
22884 <p></p>
22885 <h2><span class="mw-headline" id="Quote"></span></h2>
22886 <blockquote>
22887 <p><span class="mw-headline" id="Quote">Quote</span></p>
22888 </blockquote>
22889 <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>
22890 !! html/parsoid
22891 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22892 <h2 data-parsoid='{}'> <blockquote>Quote</blockquote> </h2>
22893 !! end
22894
22895 !! test
22896 Unclosed tags in TOC
22897 !! options
22898 title=[[Main Page]]
22899 !! wikitext
22900 __TOC__
22901 == Proof: 2 < 3 ==
22902 <small>Hanc marginis exiguitas non caperet.</small>
22903 QED
22904 !! html/php
22905 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22906 <ul>
22907 <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>
22908 </ul>
22909 </div>
22910
22911 <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>
22912 <p><small>Hanc marginis exiguitas non caperet.</small>
22913 QED
22914 </p>
22915 !! html/parsoid
22916 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22917 <h2 data-parsoid='{}'> Proof: 2 &lt; 3 </h2>
22918 <p><small>Hanc marginis exiguitas non caperet.</small>
22919 QED</p>
22920 !! end
22921
22922 !! test
22923 Multiple tags in TOC
22924 !! wikitext
22925 __TOC__
22926 == <i>Foo</i> <b>Bar</b> ==
22927
22928 == <i>Foo</i> <blockquote>Bar</blockquote> ==
22929 !! html/php
22930 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22931 <ul>
22932 <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>
22933 <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>
22934 </ul>
22935 </div>
22936
22937 <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>
22938 <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>
22939
22940 !! html/php+tidy
22941 <p></p>
22942 <div id="toc" class="toc">
22943 <div class="toctitle">
22944 <h2>Contents</h2>
22945 </div>
22946 <ul>
22947 <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>
22948 <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>
22949 </ul>
22950 </div>
22951 <p></p>
22952 <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>
22953 <h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i></span></h2>
22954 <blockquote>
22955 <p><span class="mw-headline" id="Foo_Bar_2">Bar</span></p>
22956 </blockquote>
22957 <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>
22958 !! html/parsoid
22959 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22960 <h2 data-parsoid='{}'> <i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b> </h2>
22961 <h2> <i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote> </h2>
22962 !! end
22963
22964 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
22965 # html5 tag parsing.
22966 !! test
22967 Tags with parameters in TOC
22968 !! options
22969 parsoid=wt2html
22970 !! wikitext
22971 __TOC__
22972 == <sup class="in-h2">Hello</sup> ==
22973
22974 == <sup class="a > b">Evilbye</sup> ==
22975 !! html/php
22976 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22977 <ul>
22978 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
22979 <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>
22980 </ul>
22981 </div>
22982
22983 <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>
22984 <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>
22985
22986 !! html/parsoid
22987 <meta property="mw:PageProp/toc" />
22988 <h2> <sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup> </h2>
22989
22990 <h2> <sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup> </h2>
22991 !! end
22992
22993 !! test
22994 span tags with directionality in TOC
22995 !! wikitext
22996 __TOC__
22997 == <span dir="ltr">C++</span> ==
22998
22999 == <span dir="rtl">זבנג!</span> ==
23000
23001 == <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> ==
23002
23003 == <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> ==
23004
23005 == <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> ==
23006 !! html/php
23007 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23008 <ul>
23009 <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>
23010 <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>
23011 <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>
23012 <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>
23013 <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>
23014 </ul>
23015 </div>
23016
23017 <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>
23018 <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>
23019 <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>
23020 <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>
23021 <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>
23022
23023 !! html/parsoid
23024 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23025 <h2 data-parsoid='{}'> <span dir="ltr">C++</span> </h2>
23026 <h2> <span dir="rtl">זבנג!</span> </h2>
23027 <h2> <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> </h2>
23028 <h2> <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> </h2>
23029 <h2> <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> </h2>
23030 !! end
23031
23032 !! test
23033 T74884: bdi element in ToC
23034 !! wikitext
23035 __TOC__
23036 == <bdi>test</bdi> ==
23037 !! html/php
23038 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23039 <ul>
23040 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
23041 </ul>
23042 </div>
23043
23044 <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>
23045
23046 !! html/parsoid
23047 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23048 <h2 data-parsoid='{}'> <bdi>test</bdi> </h2>
23049 !! end
23050
23051 !! test
23052 T35715: s/strike element in ToC
23053 !! wikitext
23054 __TOC__
23055 == <s>test</s> test <strike>test</strike> ==
23056 !! html/php
23057 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23058 <ul>
23059 <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>
23060 </ul>
23061 </div>
23062
23063 <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>
23064
23065 !! html/parsoid
23066 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23067 <h2 data-parsoid='{}'> <s>test</s> test <strike>test</strike> </h2>
23068 !! end
23069
23070 # Note that the html output does not have the <p></p>, but the
23071 # html+tidy output *does*. This is because the empty <p></p> is
23072 # removed by the sanitizer, but only when tidy is *not* enabled (!).
23073 !! test
23074 Empty <p> tag in TOC, removed by Sanitizer (T92892)
23075 !! wikitext
23076 __TOC__
23077 == x ==
23078 !! html/php
23079 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23080 <ul>
23081 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
23082 </ul>
23083 </div>
23084
23085 <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>
23086
23087 !! html/php+tidy
23088 <p></p>
23089 <div id="toc" class="toc">
23090 <div class="toctitle">
23091 <h2>Contents</h2>
23092 </div>
23093 <ul>
23094 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
23095 </ul>
23096 </div>
23097 <p></p>
23098 <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>
23099 !! html/parsoid
23100 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23101 <h2 data-parsoid='{}'> x </h2>
23102 !! end
23103
23104 !! article
23105 MediaWiki:T34057
23106 !! text
23107 == {{int:headline_sample}} ==
23108 !! endarticle
23109
23110 !! test
23111 T34057: Title needed when expanding <h> nodes.
23112 !! options
23113 title=[[Main Page]]
23114 !! wikitext
23115 {{int:T34057}}
23116 !! html
23117 <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>
23118
23119 !! end
23120
23121 !! test
23122 Strip marker in urlencode
23123 !! wikitext
23124 {{urlencode:x<nowiki/>y}}
23125 {{urlencode:x<nowiki/>y|wiki}}
23126 {{urlencode:x<nowiki/>y|path}}
23127 {{urlencode:x<pre id="one">two</pre>y}}
23128 !! html/php
23129 <p>xy
23130 xy
23131 xy
23132 xy
23133 </p>
23134 !! end
23135
23136 !! test
23137 Strip marker in lc
23138 !! wikitext
23139 {{lc:x<nowiki/>y}}
23140 !! html
23141 <p>xy
23142 </p>
23143 !! end
23144
23145 !! test
23146 Strip marker in uc
23147 !! wikitext
23148 {{uc:x<nowiki/>y}}
23149 !! html
23150 <p>XY
23151 </p>
23152 !! end
23153
23154 !! test
23155 Strip marker in formatNum
23156 !! wikitext
23157 {{formatnum:1<nowiki/>2}}
23158 {{formatnum:1<nowiki/>2|R}}
23159 !! html
23160 <p>12
23161 12
23162 </p>
23163 !! end
23164
23165 !! test
23166 Check noCommafy in formatNum
23167 !! options
23168 language=be-tarask
23169 !! wikitext
23170 {{formatnum:123456.78}}
23171 {{formatnum:123456.78|NOSEP}}
23172 !! html
23173 <p>123 456,78
23174 123456.78
23175 </p>
23176 !! end
23177
23178 !! test
23179 Wrong option for formatNum (T58199)
23180 !! wikitext
23181 {{formatnum:1,234.56|Random}}
23182 {{formatnum:1,234.56|EVERYTHING}}
23183 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
23184 !! html
23185 <p>1,234.56
23186 1,234.56
23187 1,234.56
23188 </p>
23189 !! end
23190
23191 !! test
23192 Strip marker in grammar
23193 !! options
23194 language=fi
23195 !! wikitext
23196 {{grammar:elative|foo<nowiki/>bar}}
23197 !! html
23198 <p>foobarista
23199 </p>
23200 !! end
23201
23202 !! test
23203 Strip marker in padleft
23204 !! wikitext
23205 {{padleft:|2|x<nowiki/>y}}
23206 !! html
23207 <p>xy
23208 </p>
23209 !! end
23210
23211 !! test
23212 Strip marker in padright
23213 !! wikitext
23214 {{padright:|2|x<nowiki/>y}}
23215 !! html
23216 <p>xy
23217 </p>
23218 !! end
23219
23220 !! test
23221 Strip marker in anchorencode
23222 !! wikitext
23223 {{anchorencode:x<nowiki/>y}}
23224 !! html
23225 <p>xy
23226 </p>
23227 !! end
23228
23229 !! test
23230 nowiki inside link inside heading (T20295)
23231 !! wikitext
23232 ==[[foo|x<nowiki>y</nowiki>z]]==
23233 !! html
23234 <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>
23235
23236 !! end
23237
23238 !! test
23239 new support for bdi element (T33817)
23240 !! wikitext
23241 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
23242 !! html
23243 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
23244
23245 !!end
23246
23247 !! test
23248 Ignore pipe between table row attributes
23249 !! wikitext
23250 {|
23251 | quux
23252 |- id=foo | style='color: red'
23253 | bar
23254 |}
23255 !! html
23256 <table>
23257 <tr>
23258 <td> quux
23259 </td></tr>
23260 <tr id="foo" style="color: red">
23261 <td> bar
23262 </td></tr></table>
23263
23264 !! end
23265
23266 !!test
23267 Language parser function
23268 !! wikitext
23269 {{#language:ar}}
23270 !! html
23271 <p>العربية
23272 </p>
23273 !! end
23274
23275 !!test
23276 Padleft and padright as substr
23277 !! wikitext
23278 {{padleft:|3|abcde}}
23279 {{padright:|3|abcde}}
23280 !! html
23281 <p>abc
23282 abc
23283 </p>
23284 !! end
23285
23286 !!test
23287 Special parser function
23288 !! wikitext
23289 {{#special:RandomPage}}
23290 {{#special:BaDtItLe}}
23291 {{#special:Foobar}}
23292 !! html
23293 <p>Special:Random
23294 Special:Badtitle
23295 Special:Foobar
23296 </p>
23297 !! end
23298
23299 !!test
23300 T36939 - Case insensitive link parsing ([HttP://])
23301 !! wikitext
23302 [HttP://MediaWiki.Org/]
23303 !! html/php
23304 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
23305 </p>
23306 !! html/parsoid
23307 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/"></a></p>
23308 !! end
23309
23310 !!test
23311 T36939 - Case insensitive link parsing ([HttP:// title])
23312 !! wikitext
23313 [HttP://MediaWiki.Org/ MediaWiki]
23314 !! html
23315 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
23316 </p>
23317 !! end
23318
23319 !!test
23320 T36939 - Case insensitive link parsing (HttP://)
23321 !! wikitext
23322 HttP://MediaWiki.Org/
23323 !! html/php
23324 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
23325 </p>
23326 !! html/parsoid
23327 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
23328 !! end
23329
23330 !!test
23331 Disable TOC
23332 !! options
23333 notoc
23334 !! wikitext
23335 Lead
23336 == Section 1 ==
23337 == Section 2 ==
23338 == Section 3 ==
23339 == Section 4 ==
23340 == Section 5 ==
23341 !! html
23342 <p>Lead
23343 </p>
23344
23345 <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>
23346 <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>
23347 <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>
23348 <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>
23349 <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>
23350
23351 !! end
23352
23353
23354 ###
23355 ### Parsoid-specific tests
23356 ### Parsoid-PHP parser incompatibilities
23357 ###
23358 !!test
23359 1. SOL-sensitive wikitext tokens as template-args
23360 !!options
23361 parsoid=wt2html,wt2wt
23362 !! wikitext
23363 {{echo|*a}}
23364 {{echo|#a}}
23365 {{echo|:a}}
23366 !! html
23367 <span about="#mwt1" typeof="mw:Transclusion">
23368 </span><ul about="#mwt1"><li>a</li>
23369 </ul>
23370 <span about="#mwt2" typeof="mw:Transclusion">
23371 </span><ol about="#mwt2"><li>a</li>
23372 </ol>
23373 <span about="#mwt3" typeof="mw:Transclusion">
23374 </span><dl about="#mwt3"><dd>a</dd>
23375 </dl>
23376 !!end
23377
23378 #### -----------------------------------------------------------------
23379 #### Parsoid-specific functionality tests
23380 #### -----------------------------------------------------------------
23381
23382 # T65642/T68749: Formatting elt fixup around images is cleaned up.
23383 # We know wt2wt will fail, but we expect selser to pass.
23384 # Due to the nature of our testing, wt2wt and selser tests will enter the
23385 # blacklist and we'll catch selser regressions based on changes to the
23386 # blacklist entries for selser tests.
23387 !! test
23388 1. Bad treebuilder fixup of formatting elt is cleaned up
23389 !! options
23390 parsoid=wt2html,wt2wt
23391 !! wikitext
23392 {|
23393 |
23394 <small>
23395 [[Image:Foobar.jpg|right|Test]]
23396 </small>
23397 |}
23398 !! html/parsoid
23399 <table>
23400 <tbody><tr><td>
23401 <small>
23402 <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>
23403 </small>
23404 </td></tr>
23405 </tbody></table>
23406 !! end
23407
23408 !! test
23409 2. Bad treebuilder fixup of formatting elt is cleaned up
23410 !! options
23411 parsoid=wt2html,wt2wt
23412 !! wikitext
23413 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
23414
23415 <small>[[Image:Foobar.jpg|right|300px]]</small>
23416 !! html/parsoid
23417
23418 <p><b>foo</b></p>
23419 <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>
23420 <p><b>bar</b></p>
23421 <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>
23422 !! end
23423
23424 !! test
23425 3. Bad treebuilder fixup of formatting elt is cleaned up
23426 !! options
23427 parsoid=wt2html,wt2wt
23428 !! wikitext
23429 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
23430 !! html/parsoid
23431 <p><small><b>foo</b></small></p>
23432 <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>
23433 <p><small><b>bar</b></small></p>
23434 !! end
23435
23436 !! test
23437 4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
23438 !! options
23439 parsoid=wt2html,wt2wt
23440 !! wikitext
23441 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
23442 !! html/parsoid
23443 <p><b><small></small></b></p>
23444 <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>
23445 <p></p>
23446 !! end
23447
23448 #### ----------------------------------------------------------------
23449 #### Parsoid-only testing of Parsoid's impl of LST
23450 #### Not implemented yet, see
23451 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
23452 #### ----------------------------------------------------------------
23453
23454 ## We still need to support serializing the older format while content is stored.
23455 !! test
23456 LST Sections: Backwards compatibility
23457 !! options
23458 parsoid={
23459 "suppressErrors": true,
23460 "modes": ["html2wt"]
23461 }
23462 !! wikitext
23463 <section begin="2011-05-16" />
23464 <section end="2014-04-10 (MW 1.23wmf22)" />
23465 !! html/parsoid
23466 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
23467 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
23468 !! end
23469
23470 !! test
23471 LST Sections: Newfangled approach
23472 !! wikitext
23473 <section begin="2011-05-16" />
23474 <section end="2014-04-10 (MW 1.23wmf22)" />
23475 !! html/parsoid
23476 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'>
23477 </span>
23478 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null}'>
23479 </span></p>
23480 !! end
23481
23482 #--------- Test stripping of empty nodes in template content ----------
23483
23484 !! test
23485 Empty LI and TR nodes should be stripped from template content
23486 !! wikitext
23487 {{EmptyLITest}}
23488 {{EmptyTRTest}}
23489 !! html/parsoid
23490 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
23491 <li>a</li>
23492 <li>b</li>
23493 </ul>
23494 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
23495 <tbody>
23496 <tr>
23497 <td>foo</td>
23498 </tr>
23499 <tr>
23500 <td>bar</td>
23501 </tr>
23502 </tbody>
23503 </table>
23504 !! end
23505
23506 !! test
23507 Empty LI and TR nodes should not be stripped from top-level content
23508 !! wikitext
23509 * a
23510 *
23511 * b
23512 {|
23513 |-
23514 |-
23515 |foo
23516 |}
23517 !! html/parsoid
23518 <ul>
23519 <li> a</li>
23520 <li></li>
23521 <li> b</li>
23522 </ul>
23523 <table>
23524 <tbody>
23525 <tr></tr>
23526 <tr>
23527 <td>foo</td>
23528 </tr>
23529 </tbody>
23530 </table>
23531 !! end
23532
23533 !! test
23534 Empty TR nodes should not be stripped if they have any attributes set
23535 !! wikitext
23536 {{EmptyTRWithHTMLAttrTest}}
23537 !! html/parsoid
23538 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
23539 <tr align="center"></tr>
23540 <tr><td>foo</td></tr>
23541 <tr align="center"></tr>
23542 <tr><td>bar</td></tr>
23543 </table>
23544 !! end
23545
23546 #### ----------------------------------------------------------------
23547 #### The following section of tests are primarily to test
23548 #### wikitext escaping capabilities of Parsoid. Given that
23549 #### escaping can be done any number of ways, the wikitext (input)
23550 #### is always adjusted to reflect how Parsoid adds nowiki
23551 #### escape tags.
23552 ####
23553 #### We are marking several tests as parsoid-only since the
23554 #### HTML in the result section is different from what the
23555 #### PHP parser generates for it.
23556 #### ----------------------------------------------------------------
23557
23558
23559 #### --------------- Headings ---------------
23560 #### 0. Unnested
23561 #### 1. Nested inside html <h1>=foo=</h1>
23562 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
23563 #### 3. Nested inside html with wikitext split by html tags
23564 #### 4. No escape needed
23565 #### 5. Empty headings <h1></h1>
23566 #### 6. Heading chars in SOL context
23567 #### ----------------------------------------
23568 !! test
23569 Headings: 0. Unnested
23570 !! options
23571 parsoid=html2wt
23572 !! html/parsoid
23573 <p>=foo=</p>
23574
23575 <p> =foo=
23576 <!--cmt-->
23577 =foo=</p>
23578
23579 <p>=foo<i>a</i>=</p>
23580 !! wikitext
23581 <nowiki>=foo=</nowiki>
23582
23583 <nowiki> </nowiki>=foo=
23584 <!--cmt-->
23585 <nowiki>=foo=</nowiki>
23586
23587 =foo''a''<nowiki>=</nowiki>
23588 !!end
23589
23590 # New headings and existing headings are handled differently
23591 !! test
23592 Headings: 1. Nested inside html
23593 !! options
23594 parsoid=html2wt
23595 !! html/parsoid
23596 <h1>=foo=</h1>
23597 <h2>=foo=</h2>
23598 <h3>=foo=</h3>
23599
23600 <h1 data-parsoid=''>=foo=</h1>
23601 <h2 data-parsoid=''>=foo=</h2>
23602 <h3 data-parsoid=''>=foo=</h3>
23603 <h4 data-parsoid=''>=foo=</h4>
23604 <h5 data-parsoid=''>=foo=</h5>
23605 <h6 data-parsoid=''>=foo=</h6>
23606 !! wikitext
23607 = =foo= =
23608
23609 == =foo= ==
23610
23611 === =foo= ===
23612
23613 =<nowiki>=foo=</nowiki>=
23614 ==<nowiki>=foo=</nowiki>==
23615 ===<nowiki>=foo=</nowiki>===
23616 ====<nowiki>=foo=</nowiki>====
23617 =====<nowiki>=foo=</nowiki>=====
23618 ======<nowiki>=foo=</nowiki>======
23619
23620 !!end
23621
23622 !! test
23623 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
23624 !! options
23625 parsoid=html2wt
23626 !! html/parsoid
23627 <h1>foo</h1>*bar
23628 <h1>foo</h1>=bar
23629 <h1>foo</h1>=bar=
23630 !! wikitext
23631 = foo =
23632 <nowiki>*</nowiki>bar
23633
23634 = foo =
23635 =bar
23636
23637 = foo =
23638 <nowiki>=bar=</nowiki>
23639 !!end
23640
23641 !! test
23642 Headings: 3. Nested inside html with wikitext split by html tags
23643 !! options
23644 parsoid=html2wt
23645 !! html/parsoid
23646 <h1>=<b>bold</b>foo=</h1>
23647 !! wikitext
23648 = ='''bold'''foo= =
23649 !!end
23650
23651 !! test
23652 Headings: 4a. No escaping needed (testing just h1 and h2)
23653 !! options
23654 parsoid=html2wt
23655 !! html/parsoid
23656 <h1>=foo</h1>
23657 <h1>foo=</h1>
23658 <h1> =foo= </h1>
23659 <h1>=foo= bar</h1>
23660 <h2>=foo</h2>
23661 <h2>foo=</h2>
23662 <h1>=</h1>
23663 <h1><i>=</i>foo=</h1>
23664 !! wikitext
23665 = =foo =
23666
23667 = foo= =
23668
23669 = =foo= =
23670
23671 = =foo= bar =
23672
23673 == =foo ==
23674
23675 == foo= ==
23676
23677 = = =
23678
23679 = ''=''foo= =
23680 !!end
23681
23682 !! test
23683 Headings: 4b. No escaping needed (inside p-tags)
23684 !! options
23685 parsoid=html2wt
23686 !! html/parsoid
23687 <p>===
23688 =foo= x
23689 =foo= <s></s>
23690 </p>
23691 !! wikitext
23692 ===
23693 =foo= x
23694 =foo= <s></s>
23695 !!end
23696
23697 !! test
23698 Headings: 5. Empty headings
23699 !! options
23700 parsoid=html2wt
23701 !! html/parsoid
23702 <h1 data-parsoid='{}'></h1>
23703
23704 <h2 data-parsoid='{}'></h2>
23705
23706 <h3 data-parsoid='{}'></h3>
23707
23708 <h4 data-parsoid='{}'></h4>
23709
23710 <h5 data-parsoid='{}'></h5>
23711
23712 <h6 data-parsoid='{}'></h6>
23713 !! wikitext
23714 =<nowiki/>=
23715
23716 ==<nowiki/>==
23717
23718 ===<nowiki/>===
23719
23720 ====<nowiki/>====
23721
23722 =====<nowiki/>=====
23723
23724 ======<nowiki/>======
23725 !!end
23726
23727 !! test
23728 Headings: 6a. Heading chars in SOL context (with trailing spaces)
23729 !! options
23730 parsoid=html2wt
23731 !! html/parsoid
23732 <p>=a=</p>
23733
23734 <p>=a=</p>
23735
23736 <p>=a=</p>
23737 !! wikitext
23738 <nowiki>=a=</nowiki>
23739
23740 <nowiki>=a=</nowiki>
23741
23742 <nowiki>=a=</nowiki>
23743 !!end
23744
23745 !! test
23746 Headings: 6b. Heading chars in SOL context (with trailing newlines)
23747 !! options
23748 parsoid=html2wt
23749 !! html/parsoid
23750 <p>=a=
23751 b</p>
23752
23753 <p>=a=
23754 b</p>
23755
23756 <p>=a=
23757 b</p>
23758 !! wikitext
23759 <nowiki>=a=</nowiki>
23760 b
23761
23762 <nowiki>=a=</nowiki>
23763 b
23764
23765 <nowiki>=a=</nowiki>
23766 b
23767 !!end
23768
23769 !! test
23770 Headings: 6c. Heading chars in SOL context (leading newline break)
23771 !! options
23772 parsoid=html2wt
23773 !! html/parsoid
23774 <p>a
23775 =b=</p>
23776 !! wikitext
23777 a
23778 <nowiki>=b=</nowiki>
23779 !!end
23780
23781 !! test
23782 Headings: 6d. Heading chars in SOL context (with interspersed comments)
23783 !! options
23784 parsoid=html2wt
23785 !! html/parsoid
23786 <!--c0--><p>=a=</p>
23787
23788 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
23789 !! wikitext
23790 <!--c0--><nowiki>=a=</nowiki>
23791
23792 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
23793 !!end
23794
23795 !! test
23796 Headings: 6d. Heading chars in SOL context (No escaping needed)
23797 !! options
23798 parsoid=html2wt
23799 !! html/parsoid
23800 =a=<div>b</div>
23801 !! wikitext
23802 =a=<div>b</div>
23803 !!end
23804
23805 !! test
23806 Headings: 7. Insert a newline between new content and headings
23807 !! options
23808 parsoid=html2wt
23809 !! html/parsoid
23810 <h2>NEW</h2>
23811 <p>new</p>
23812 <h2 data-parsoid='{}'>A</h2>
23813 <p data-parsoid='{}'>a</p>
23814 !! wikitext
23815 == NEW ==
23816 new
23817
23818 ==A==
23819 a
23820
23821 !! end
23822
23823 #### --------------- Lists ---------------
23824 #### 0. Outside nests (*foo, etc.)
23825 #### 1. Nested inside html <ul><li>*foo</li></ul>
23826 #### 2. Inside definition lists
23827 #### 3. Only bullets at start should be escaped
23828 #### 4. No escapes needed
23829 #### 5. No unnecessary escapes
23830 #### 6. Escape bullets in SOL position
23831 #### 7. Escape bullets in a multi-line context
23832 #### ----------------------------------------
23833
23834 !! test
23835 Lists: 0. Outside nests
23836 !! options
23837 parsoid=html2wt
23838 !! html/parsoid
23839 <p>*foo</p>
23840
23841 <p>#foo</p>
23842
23843 <p>;Foo:bar</p>
23844 !! wikitext
23845 <nowiki>*</nowiki>foo
23846
23847 <nowiki>#</nowiki>foo
23848
23849 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
23850 !!end
23851
23852 ## Making these next 3 tests Parsoid-only since they are html2wt tests
23853 ## to test wikitext escaping, and insignificant whitespace diffs
23854 ## cause PHP parser tests to barf
23855 !! test
23856 Lists: 1. Nested inside html (No unnecessary escapes)
23857 !! options
23858 parsoid=html2wt
23859 !! html/parsoid
23860 <ul>
23861 <li>*foo</li>
23862 <li>#foo</li>
23863 <li>:foo</li>
23864 <li>;foo</li>
23865 <li data-parsoid='{}'>*foo</li>
23866 <li data-parsoid='{}'>#foo</li>
23867 <li data-parsoid='{}'>:foo</li>
23868 <li data-parsoid='{}'>;foo</li>
23869 </ul>
23870
23871 <ol>
23872 <li>*foo</li>
23873 <li>#foo</li>
23874 <li>:foo</li>
23875 <li>;foo</li>
23876 <li data-parsoid='{}'>*foo</li>
23877 <li data-parsoid='{}'>#foo</li>
23878 <li data-parsoid='{}'>:foo</li>
23879 <li data-parsoid='{}'>;foo</li>
23880 </ol>
23881 !! wikitext
23882 * *foo
23883 * #foo
23884 * :foo
23885 * ;foo
23886 *<nowiki>*foo</nowiki>
23887 *<nowiki>#foo</nowiki>
23888 *<nowiki>:foo</nowiki>
23889 *<nowiki>;foo</nowiki>
23890
23891 # *foo
23892 # #foo
23893 # :foo
23894 # ;foo
23895 #<nowiki>*foo</nowiki>
23896 #<nowiki>#foo</nowiki>
23897 #<nowiki>:foo</nowiki>
23898 #<nowiki>;foo</nowiki>
23899 !!end
23900
23901 !! test
23902 Lists: 2. Inside definition lists
23903 !! options
23904 parsoid=html2wt
23905 !! html/parsoid
23906 <dl><dt>;foo</dt></dl>
23907 <dl><dt>:foo</dt></dl>
23908 <dl><dt>:foo</dt>
23909 <dd>bar</dd></dl>
23910 <dl><dd>:foo</dd></dl>
23911 !! wikitext
23912 ; ;foo
23913
23914 ; <nowiki>:foo</nowiki>
23915
23916 ; <nowiki>:foo</nowiki>
23917 : bar
23918
23919 : :foo
23920 !!end
23921
23922 !! test
23923 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
23924 !! options
23925 parsoid=html2wt
23926 !! html/parsoid
23927 <ul>
23928 <li>*foo*bar</li>
23929 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
23930 </ul>
23931 !! wikitext
23932 * *foo*bar
23933 *<nowiki>*foo</nowiki>''it''*bar
23934 !!end
23935
23936 !! test
23937 Lists: 4. No escapes needed
23938 !! options
23939 parsoid=html2wt
23940 !! html/parsoid
23941 <ul>
23942 <li>foo*bar
23943 </li>
23944 </ul>
23945 <ul>
23946 <li><i>foo</i>*bar
23947 </li>
23948 </ul>
23949 <ul>
23950 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
23951 </li>
23952 </ul>
23953 <ul>
23954 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
23955 </li>
23956 </ul>
23957 !! wikitext
23958 *foo*bar
23959
23960 *''foo''*bar
23961
23962 *[[Foo]]: bar
23963
23964 *[[Foo]]*bar
23965 !!end
23966
23967 !! test
23968 Lists: 5. No unnecessary escapes
23969 !! options
23970 parsoid=html2wt
23971 !! html/parsoid
23972 <ul><li> bar <span>[[foo]]</span></li></ul>
23973 <ul><li> =bar <span>[[foo]]</span></li></ul>
23974 <ul><li> [[bar <span>[[foo]]</span></li></ul>
23975 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
23976 <ul><li> =bar <span>foo]]</span>=</li></ul>
23977 <ul><li> <s></s>: a</li></ul>
23978 <ul><li> <i>* foo</i></li></ul>
23979
23980 !! wikitext
23981 * bar <span><nowiki>[[foo]]</nowiki></span>
23982
23983 * =bar <span><nowiki>[[foo]]</nowiki></span>
23984
23985 * [[bar <span><nowiki>[[foo]]</nowiki></span>
23986
23987 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
23988
23989 * =bar <span>foo]]</span>=
23990
23991 * <s></s>: a
23992
23993 * ''* foo''
23994 !!end
23995
23996 !! test
23997 Lists: 6. Escape bullets in SOL position
23998 !! options
23999 parsoid=html2wt
24000 !! html/parsoid
24001 <p><!--cmt-->*foo</p>
24002 !! wikitext
24003 <!--cmt--><nowiki>*</nowiki>foo
24004 !!end
24005
24006 !! test
24007 Lists: 7. Escape bullets in a multi-line context
24008 !! options
24009 parsoid=html2wt
24010 !! html/parsoid
24011 <p>a
24012 *b
24013 </p>
24014 !! wikitext
24015 a
24016 <nowiki>*</nowiki>b
24017 !!end
24018
24019 !! test
24020 Lists: 8. Escape colons only if not present in tags
24021 !! options
24022 parsoid=html2wt
24023 !! html/parsoid
24024 <dl><dt>a:b<i>c:d</i></dt></dl>
24025 !! wikitext
24026 ; <nowiki>a:b</nowiki>''c:d''
24027 !! end
24028
24029 #### --------------- HRs ---------------
24030 #### 1. Single line
24031 #### -----------------------------------
24032
24033 !! test
24034 HRs: 1. Single line
24035 !! options
24036 parsoid=html2wt
24037 !! html/parsoid
24038 <hr />----
24039 <hr />=foo=
24040 <hr />*foo
24041 !! wikitext
24042 ----<nowiki>----</nowiki>
24043 ----=foo=
24044 ----*foo
24045 !! end
24046
24047 #### --------------- Tables ---------------
24048 #### 1a. Simple example
24049 #### 1b. No escaping needed (!foo)
24050 #### 1c. No escaping needed (|foo)
24051 #### 1d. No escaping needed (|}foo)
24052 ####
24053 #### 2a. Nested in td (<td>foo|bar</td>)
24054 #### 2b. Nested in td (<td>foo||bar</td>)
24055 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
24056 ####
24057 #### 3a. Nested in th (<th>foo!bar</th>)
24058 #### 3b. Nested in th (<th>foo!!bar</th>)
24059 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
24060 ####
24061 #### 4a. Escape -
24062 #### 4b. Escape +
24063 #### 4c. No escaping needed
24064 #### --------------------------------------
24065
24066 !! test
24067 Tables: 1a. Simple example
24068 !! options
24069 parsoid=html2wt
24070 !! html/parsoid
24071 <p>{|
24072 |}
24073 </p>
24074 !! wikitext
24075 <nowiki>{|</nowiki>
24076 |}
24077 !! end
24078
24079 !! test
24080 Tables: 1b. No escaping needed
24081 !! options
24082 parsoid=html2wt
24083 !! html/parsoid
24084 <p>!foo
24085 </p>
24086 !! wikitext
24087 !foo
24088 !! end
24089
24090 !! test
24091 Tables: 1c. No escaping needed
24092 !! options
24093 parsoid=html2wt
24094 !! html/parsoid
24095 <p>|foo
24096 </p>
24097 !! wikitext
24098 |foo
24099 !! end
24100
24101 !! test
24102 Tables: 1d. No escaping needed
24103 !! options
24104 parsoid=html2wt
24105 !! html/parsoid
24106 <p>|}foo
24107 </p>
24108 !! wikitext
24109 |}foo
24110 !! end
24111
24112 !! test
24113 Tables: 2a. Nested in td
24114 !! options
24115 parsoid=html2wt
24116 !! html/parsoid
24117 <table><tbody><tr>
24118 <td>foo|bar</td></tr>
24119 <tr><td>x<div>a|b</div></td>
24120 </tbody></table>
24121 !! wikitext
24122 {|
24123 |<nowiki>foo|bar</nowiki>
24124 |-
24125 |x<div><nowiki>a|b</nowiki></div>
24126 |}
24127 !! html/php+tidy
24128 <table>
24129 <tr>
24130 <td>foo|bar</td>
24131 </tr>
24132 <tr>
24133 <td>x
24134 <div>a|b</div>
24135 </td>
24136 </tr>
24137 </table>
24138 !! end
24139
24140 !! test
24141 Tables: 2b. Nested in td
24142 !! options
24143 parsoid=html2wt
24144 !! html/parsoid
24145 <table><tbody><tr>
24146 <td>foo||bar</td>
24147 <td>a<i>b||c</i></td>
24148 <td>a<i><div>b||c</div></i></td>
24149 </tr></tbody></table>
24150 !! wikitext
24151 {|
24152 |<nowiki>foo||bar</nowiki>
24153 |a''<nowiki>b||c</nowiki>''
24154 |a''<div><nowiki>b||c</nowiki></div>''
24155 |}
24156 !! html/php
24157 <table>
24158 <tr>
24159 <td>foo||bar
24160 </td>
24161 <td>a<i>b||c</i>
24162 </td>
24163 <td>a<i><div>b||c</div></i>
24164 </td></tr></table>
24165
24166 !! end
24167
24168 !! test
24169 Tables: 2c. Nested in td -- no escaping needed
24170 !! options
24171 parsoid=html2wt
24172 !! html/*
24173 <table>
24174 <tr>
24175 <td>foo!!bar
24176 </td></tr></table>
24177
24178 !! wikitext
24179 {|
24180 |foo!!bar
24181 |}
24182 !! end
24183
24184 !! test
24185 Tables: 3a. Nested in th
24186 !! options
24187 parsoid=html2wt
24188 !! html/*
24189 <table>
24190 <tr>
24191 <th>foo!bar
24192 </th></tr></table>
24193
24194 !! wikitext
24195 {|
24196 !foo!bar
24197 |}
24198 !! end
24199
24200 !! test
24201 Tables: 3b. Nested in th
24202 !! options
24203 parsoid=html2wt
24204 !! html/parsoid
24205 <table><tbody>
24206 <tr><th>foo!!bar</th>
24207 <th><i>foo|bar</i></th>
24208 <th><i>foo!!bar</i></th>
24209 <th><i><span>foo!!bar</span></i></th>
24210 </tr></tbody></table>
24211 !! wikitext
24212 {|
24213 !<nowiki>foo!!bar</nowiki>
24214 !''<nowiki>foo|bar</nowiki>''
24215 !''<nowiki>foo!!bar</nowiki>''
24216 !''<span><nowiki>foo!!bar</nowiki></span>''
24217 |}
24218 !! html/php
24219 <table>
24220 <tr>
24221 <th>foo!!bar
24222 </th>
24223 <th><i>foo|bar</i>
24224 </th>
24225 <th><i>foo!!bar</i>
24226 </th>
24227 <th><i><span>foo!!bar</span></i>
24228 </th></tr></table>
24229
24230 !! end
24231
24232 !! test
24233 Tables: 3c. Nested in th
24234 !! options
24235 parsoid=html2wt
24236 !! html/parsoid
24237 <table><tbody>
24238 <tr><th>foo||bar</th>
24239 <th><span typeof="mw:Nowiki">foo||bar</span></th>
24240 </tr></tbody></table>
24241 !! wikitext
24242 {|
24243 !<nowiki>foo||bar</nowiki>
24244 !<nowiki>foo||bar</nowiki>
24245 |}
24246 !! html/php
24247 <table>
24248 <tr>
24249 <th>foo||bar
24250 </th>
24251 <th>foo||bar
24252 </th></tr></table>
24253
24254 !! end
24255
24256 !! test
24257 Tables: 4a. Escape -
24258 !! options
24259 parsoid=html2wt
24260 !! html/*
24261 <table>
24262 <tr>
24263 <th>-bar
24264 </th></tr>
24265 <tr>
24266 <td>-bar
24267 </td></tr></table>
24268
24269 !! wikitext
24270 {|
24271 !-bar
24272 |-
24273 |<nowiki>-bar</nowiki>
24274 |}
24275 !! end
24276
24277 !! test
24278 Tables: 4b. Escape +
24279 !! options
24280 parsoid=html2wt
24281 !! html/*
24282 <table>
24283 <tr>
24284 <th>+bar
24285 </th></tr>
24286 <tr>
24287 <td>+bar
24288 </td></tr></table>
24289
24290 !! wikitext
24291 {|
24292 !+bar
24293 |-
24294 |<nowiki>+bar</nowiki>
24295 |}
24296 !! end
24297
24298 !! test
24299 Tables: 4c. No escaping needed
24300 !! options
24301 parsoid=html2wt
24302 !! html/parsoid
24303 <table><tbody>
24304 <tr><td>foo-bar</td><td>foo+bar</td></tr>
24305 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
24306 <tr><td>foo
24307 <p>bar|baz
24308 +bar
24309 -bar</p></td></tr>
24310 <tr><td>x
24311 <div>a|b</div></td>
24312 </tbody></table>
24313 !! wikitext
24314 {|
24315 |foo-bar
24316 |foo+bar
24317 |-
24318 |''foo''-bar
24319 |''foo''+bar
24320 |-
24321 |foo
24322 bar|baz
24323 +bar
24324 -bar
24325 |-
24326 |x
24327 <div>a|b</div>
24328 |}
24329 !! html/php
24330 <table>
24331 <tr>
24332 <td>foo-bar
24333 </td>
24334 <td>foo+bar
24335 </td></tr>
24336 <tr>
24337 <td><i>foo</i>-bar
24338 </td>
24339 <td><i>foo</i>+bar
24340 </td></tr>
24341 <tr>
24342 <td>foo
24343 <p>bar|baz
24344 +bar
24345 -bar
24346 </p>
24347 </td></tr>
24348 <tr>
24349 <td>x
24350 <div>a|b</div>
24351 </td></tr></table>
24352
24353 !! end
24354
24355 !! test
24356 Tables: 4d. No escaping needed
24357 !! options
24358 parsoid=html2wt
24359 !! html/parsoid
24360 <table>
24361 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
24362 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
24363 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
24364 </tbody></table>
24365 !! wikitext
24366 {|
24367 |[[Foo]]-bar
24368 ||+1
24369 ||-2
24370 |}
24371 !! html/php
24372 <table>
24373 <tr>
24374 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
24375 </td>
24376 <td>+1
24377 </td>
24378 <td>-2
24379 </td></tr></table>
24380
24381 !! end
24382
24383 !! test
24384 T97430: Don't emit empty nowiki pairs around marker meta tags
24385 !! options
24386 parsoid=html2wt
24387 !! html/parsoid
24388 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
24389 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
24390 !! wikitext
24391 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
24392 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
24393 !! end
24394
24395 !! test
24396 Unclosed xmlish element in table line shouldn't eat end delimiters
24397 !! options
24398 parsoid=html2wt
24399 !! html/parsoid
24400 <table>
24401 <tbody><tr><td> &lt;foo</td>
24402 <td> bar></td></tr>
24403 </tbody></table>
24404 !! wikitext
24405 {|
24406 | <foo
24407 | bar>
24408 |}
24409 !! html/php
24410 <table>
24411 <tr>
24412 <td> &lt;foo
24413 </td>
24414 <td> bar&gt;
24415 </td></tr></table>
24416
24417 !! end
24418
24419 #### --------------- Links ----------------
24420 #### 1. Quote marks in link text
24421 #### 2. Wikilinks: Escapes needed
24422 #### 3. Wikilinks: No escapes needed
24423 #### 4. Extlinks: Escapes needed
24424 #### 5. Extlinks: No escapes needed
24425 #### --------------------------------------
24426 !! test
24427 Links 1. WikiLinks: No escapes needed
24428 !! options
24429 parsoid=html2wt
24430 !! html/parsoid
24431 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
24432 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
24433 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
24434 !! wikitext
24435 [[Foo|Foo''boo'']]
24436 [[Foo|[Foobar]]]
24437 [[Foo|x [Foobar] x]]
24438 !! html/php
24439 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
24440 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
24441 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
24442 </p>
24443 !! end
24444
24445 !! test
24446 Links 2. WikiLinks: Escapes needed
24447 !! options
24448 parsoid=html2wt
24449 !! html/parsoid
24450 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
24451 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
24452 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
24453 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
24454 <a href="Foo" rel="mw:WikiLink">|Bar</a>
24455 <a href="Foo" rel="mw:WikiLink">]]bar</a>
24456 <a href="Foo" rel="mw:WikiLink">[[bar</a>
24457 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
24458 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
24459 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
24460 !! wikitext
24461 [[Foo|<nowiki>Foobar]</nowiki>]]
24462 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
24463 [[Foo|<nowiki>[[Bar]]</nowiki>]]
24464 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
24465 [[Foo|<nowiki>|Bar</nowiki>]]
24466 [[Foo|<nowiki>]]bar</nowiki>]]
24467 [[Foo|<nowiki>[[bar</nowiki>]]
24468 [[Foo|<nowiki>x [[ y</nowiki>]]
24469 [[Foo|<nowiki>x ]] y</nowiki>]]
24470 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
24471 !! html/php
24472 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
24473 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
24474 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
24475 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
24476 <a href="/wiki/Foo" title="Foo">|Bar</a>
24477 <a href="/wiki/Foo" title="Foo">]]bar</a>
24478 <a href="/wiki/Foo" title="Foo">[[bar</a>
24479 <a href="/wiki/Foo" title="Foo">x [[ y</a>
24480 <a href="/wiki/Foo" title="Foo">x ]] y</a>
24481 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
24482 </p>
24483 !! end
24484
24485 !! test
24486 Links 3. WikiLinks: No escapes needed
24487 !! options
24488 parsoid=html2wt
24489 !! html/parsoid
24490 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
24491 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
24492 !! wikitext
24493 [[Foo|[Foobar]]
24494 [[Foo|foo|bar]]
24495 !! html/php
24496 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
24497 <a href="/wiki/Foo" title="Foo">foo|bar</a>
24498 </p>
24499 !! end
24500
24501 !! test
24502 Links 4. ExtLinks: Escapes needed
24503 !! options
24504 parsoid=html2wt
24505 !! html/parsoid
24506 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
24507 <a rel="mw:ExtLink" href="http://google.com">google]</a>
24508 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
24509 <p>[http://google.com]</p>
24510 <p>[http://google.com google]</p>
24511 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
24512 <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>
24513 !! wikitext
24514 [http://google.com <nowiki>[google]</nowiki>]
24515 [http://google.com <nowiki>google]</nowiki>]
24516 [http://google.com <nowiki>goog] le</nowiki>]
24517
24518 <nowiki>[http://google.com]</nowiki>
24519
24520 <nowiki>[http://google.com google]</nowiki>
24521
24522 [http://google.com<nowiki>]</nowiki>
24523
24524 [{{echo|http://google.com}}<nowiki>]</nowiki>
24525 !! html/php
24526 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
24527 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
24528 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
24529 </p><p>[http://google.com]
24530 </p><p>[http://google.com google]
24531 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
24532 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
24533 </p>
24534 !! end
24535
24536 !! test
24537 Links 5. ExtLinks: No escapes needed
24538 !! options
24539 parsoid=html2wt
24540 !! html/parsoid
24541 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
24542 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
24543 !! wikitext
24544 [http://google.com [google]
24545
24546 [[http://google.com]]
24547 !! html/php
24548 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
24549 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
24550 </p>
24551 !! end
24552
24553 !! test
24554 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
24555 !! options
24556 parsoid=html2wt
24557 !! html/parsoid
24558 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
24559 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
24560 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
24561 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
24562 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
24563 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
24564 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
24565 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
24566 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
24567 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
24568 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
24569 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
24570 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
24571 </p>
24572 !! wikitext
24573 x<nowiki/>http://example.com<nowiki/>y
24574 http://example.com<nowiki/>?x
24575 http://example.com<nowiki/>&x
24576 http://example.com<nowiki/>'x
24577 http://example.com<nowiki/>,x
24578 http://example.com<nowiki/>.x
24579 http://example.com<nowiki/>;x
24580 http://example.com<nowiki/>:x
24581 http://example.com<nowiki/>;x
24582 http://example.com<nowiki/>!x
24583 http://example.com<nowiki/>=x
24584 http://example.com<nowiki/>(x)
24585 http://example.com(x<nowiki/>)
24586 !! end
24587
24588 !! test
24589 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
24590 !! options
24591 parsoid=html2wt
24592 !! html/parsoid
24593 <p>x
24594 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
24595 y
24596 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
24597 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
24598 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
24599 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
24600 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
24601 </p>
24602 !! wikitext
24603 x
24604 http://example.com
24605 y
24606 "http://example.com"
24607 (http://example.com)
24608 (http://example.com) foo
24609 http://example.com,
24610 http://example.com, foo
24611 !! html/php
24612 <p>x
24613 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
24614 y
24615 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
24616 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
24617 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
24618 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
24619 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
24620 </p>
24621 !! end
24622
24623 !! test
24624 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
24625 !! options
24626 parsoid=html2wt
24627 !! html/parsoid
24628 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
24629 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
24630 !! wikitext
24631 http://example.com.,;:!?\
24632 -http://example.com:
24633 !! html/php
24634 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
24635 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
24636 </p>
24637 !! end
24638
24639 !! test
24640 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
24641 !! options
24642 parsoid=html2wt
24643 !! html/parsoid
24644 <p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
24645 <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
24646 X<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
24647 !! wikitext
24648 RFC 123<nowiki/>4
24649 RFC 123<nowiki/>y
24650 X<nowiki/>RFC 123<nowiki/>y
24651 !! end
24652
24653 !! test
24654 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
24655 !! options
24656 parsoid=html2wt
24657 !! html/parsoid
24658 <p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
24659 <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
24660 -<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
24661 </p>
24662 !! wikitext
24663 RFC 123?foo
24664 RFC 123&foo
24665 -RFC 123-
24666 !! html/php
24667 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>?foo
24668 <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
24669 -<a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>-
24670 </p>
24671 !! end
24672
24673 !! test
24674 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
24675 !! options
24676 parsoid=html2wt
24677 !! html/parsoid
24678 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
24679 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
24680 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
24681 !! wikitext
24682 PMID 123<nowiki/>4
24683 PMID 123<nowiki/>y
24684 X<nowiki/>PMID 123<nowiki/>y
24685 !! end
24686
24687 !! test
24688 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
24689 !! options
24690 parsoid=html2wt
24691 !! html/parsoid
24692 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
24693 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
24694 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
24695 </p>
24696 !! wikitext
24697 PMID 123?foo
24698 PMID 123&foo
24699 -PMID 123-
24700 !! html/php
24701 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
24702 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
24703 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
24704 </p>
24705 !! end
24706
24707 !! test
24708 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
24709 !! options
24710 parsoid=html2wt
24711 !! html/parsoid
24712 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
24713 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
24714 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
24715 </p>
24716 !! wikitext
24717 ISBN 1234567890<nowiki/>1
24718 ISBN 1234567890<nowiki/>x
24719 a<nowiki/>ISBN 1234567890<nowiki/>b
24720 !! end
24721
24722 !! test
24723 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
24724 !! options
24725 parsoid=html2wt
24726 !! html/parsoid
24727 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
24728 !! wikitext
24729 -ISBN 1234567890's
24730 !! html/php
24731 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
24732 </p>
24733 !! end
24734
24735 !! test
24736 Links 14. Protect link-like plain text. (Parsoid bug T78425)
24737 !! options
24738 parsoid=html2wt
24739 !! html/*
24740 <p>this is not a link: http://example.com
24741 </p>
24742 !! wikitext
24743 this is not a link: <nowiki>http://example.com</nowiki>
24744 !! end
24745
24746 !! test
24747 Links 15. Link trails can't become link prefixes.
24748 !! options
24749 language=is
24750 parsoid=html2wt
24751 !! html/parsoid
24752 <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>
24753 !! wikitext
24754 [[Söfnuður]]-[[00]]
24755 !! html/php
24756 <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>
24757 </p>
24758 !! end
24759
24760 #### --------------- Quotes ---------------
24761 #### 1. Quotes inside <b> and <i>
24762 #### 2. Link fragments separated by <i> and <b> tags
24763 #### 3. Link fragments inside <i> and <b>
24764 #### 4. No escaping needed
24765 #### --------------------------------------
24766 !! test
24767 1a. Quotes inside <b> and <i>
24768 !! options
24769 parsoid=html2wt
24770 !! html/*
24771 <p><i>'foo'</i>
24772 <i>''foo''</i>
24773 <i>'''foo'''</i>
24774 <i>foo</i>'s
24775 <b>'foo'</b>
24776 <b>''foo''</b>
24777 <b>'''foo'''</b>
24778 <b>foo'<i>bar'</i>baz</b>
24779 <b>foo</b>'s
24780 '<i>foo</i>
24781 <i>foo</i>'
24782 <i>foo'</i>'
24783 '<i>foo</i>'
24784 '<b>foo</b>
24785 <b>foo</b>'
24786 '<b>foo</b>'
24787 <i>fools'<span> errand</span></i>
24788 <i><span>fool</span>'s errand</i>
24789 '<i>foo</i> bar '<i>baz</i>
24790 a|!*#-:;+-~[]{}b'<i>x</i>
24791 </p>
24792 !! wikitext
24793 ''<nowiki/>'foo'''
24794 ''<nowiki>''foo''</nowiki>''
24795 ''<nowiki>'''foo'''</nowiki>''
24796 ''foo''<nowiki/>'s
24797 '''<nowiki/>'foo''''
24798 '''<nowiki>''foo''</nowiki>'''
24799 '''<nowiki>'''foo'''</nowiki>'''
24800 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
24801 '''foo'''<nowiki/>'s
24802 '''foo''
24803 ''foo''<nowiki/>'
24804 ''foo'''<nowiki/>'
24805 '''foo''<nowiki/>'
24806 ''''foo'''
24807 '''foo'''<nowiki/>'
24808 ''''foo'''<nowiki/>'
24809 ''fools'<span> errand</span>''
24810 ''<span>fool</span>'s errand''
24811 '<nowiki/>''foo'' bar '''baz''
24812 a|!*#-:;+-~[]{}b'''x''
24813 !! end
24814
24815 !! test
24816 1b. Quotes inside <b> and <i> with other tags on same line
24817 !! options
24818 parsoid=html2wt
24819 !! html/parsoid
24820 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
24821 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
24822 <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>
24823 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
24824 '<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>
24825 '<i>foo</i> <div title="name">test</div>
24826 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
24827 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
24828 <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>
24829 </ol>
24830 !! wikitext
24831 '''a'' foo ''[[bar]]''
24832 ''a''' foo ''[[bar]]''
24833 ''a''' foo '''{{echo|[[bar]]}}'''
24834 [[foo]] x'''[[bar]]''
24835 '''foo'' <ref>test</ref>
24836 '''foo'' <div title="name">test</div>
24837 '''foo'' and <br> bar
24838 <references />
24839 !! end
24840
24841 !! test
24842 2. Link fragments separated by <i> and <b> tags
24843 !! options
24844 parsoid=html2wt
24845 !! html/parsoid
24846 <p>[[<i>foo</i>hello]]</p>
24847 <p>[[<b>foo</b>hello]]</p>
24848 !! wikitext
24849 [[''foo''<nowiki>hello]]</nowiki>
24850
24851 [['''foo'''<nowiki>hello]]</nowiki>
24852 !! end
24853
24854 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
24855 # this is one of the shortcomings of this format
24856 !! test
24857 3. Link fragments inside <i> and <b>
24858 !! options
24859 parsoid=html2wt
24860 !! html/parsoid
24861 <p><i>[[foo</i>]]</p>
24862 <p><b>[[foo</b>]]</p>
24863 !! wikitext
24864 ''[[foo''<nowiki>]]</nowiki>
24865
24866 '''[[foo'''<nowiki>]]</nowiki>
24867 !! end
24868
24869 !! test
24870 4. No escaping needed
24871 !! options
24872 parsoid=html2wt
24873 !! html/parsoid
24874 <p>'<span><i>bar</i></span>'
24875 '<span><b>bar</b></span>'
24876 'a:b'foo
24877 </p>
24878 !! wikitext
24879 '<span>''bar''</span>'
24880 '<span>'''bar'''</span>'
24881 'a:b'foo
24882 !! end
24883
24884 #### ----------- Paragraphs ---------------
24885 #### 1. No unnecessary escapes
24886 #### --------------------------------------
24887
24888 !! test
24889 1. No unnecessary escapes
24890 !! options
24891 parsoid=html2wt
24892 !! html/parsoid
24893 <p>bar <span>[[foo]]</span>
24894 </p><p>=bar <span>[[foo]]</span>
24895 </p><p>[[bar <span>[[foo]]</span>
24896 </p><p>]]bar <span>[[foo]]</span>
24897 </p><p>=bar <span>foo]]</span>=
24898 </p>
24899 !! wikitext
24900 bar <span><nowiki>[[foo]]</nowiki></span>
24901
24902 =bar <span><nowiki>[[foo]]</nowiki></span>
24903
24904 [[bar <span><nowiki>[[foo]]</nowiki></span>
24905
24906 ]]bar <span><nowiki>[[foo]]</nowiki></span>
24907
24908 =bar <span>foo]]</span><nowiki>=</nowiki>
24909 !!end
24910
24911 #### ----------------------- PRE --------------------------
24912 #### 1. Leading whitespace in SOL context should be escaped
24913 #### ------------------------------------------------------
24914 !! test
24915 1. Leading whitespace in SOL context should be escaped
24916 !! options
24917 parsoid=html2wt
24918 !! html/parsoid
24919 <p> a</p>
24920
24921 <p> a</p>
24922
24923 <p> a(tab)</p>
24924
24925 <p> a
24926 <!--cmt-->
24927 a</p>
24928
24929 <p>a
24930 b</p>
24931
24932 <p>a
24933 b</p>
24934
24935 <p>a
24936 b</p>
24937 !! wikitext
24938 <nowiki> </nowiki>a
24939
24940 <nowiki> </nowiki> a
24941
24942 a(tab)
24943
24944 <nowiki> </nowiki> a
24945 <!--cmt-->
24946 <nowiki> </nowiki>a
24947
24948 a
24949 <nowiki> </nowiki>b
24950
24951 a
24952 b
24953
24954 a
24955 b
24956 !! html/php
24957 <p> a
24958 </p><p> a
24959 </p><p> a(tab)
24960 </p><p> a
24961 a
24962 </p><p>a
24963 b
24964 </p><p>a
24965 b
24966 </p><p>a
24967 b
24968 </p>
24969 !! end
24970
24971 !! test
24972 2. Leading whitespace in non-indent-pre contexts should not be escaped
24973 !! options
24974 parsoid=html2wt
24975 !! html/parsoid
24976 <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>
24977 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
24978 <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>
24979 b</span></li>
24980 </ol>
24981 !! wikitext
24982 foo <ref>''a''
24983 b</ref>
24984 <references />
24985 !! end
24986
24987 !! test
24988 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
24989 !! options
24990 parsoid=html2wt
24991 !! html/parsoid
24992 <blockquote>
24993 <p>
24994 a
24995 <span>b</span>
24996 c</p>
24997 </blockquote>
24998 !! wikitext
24999 <blockquote>
25000 a
25001 <span>b</span>
25002 c
25003 </blockquote>
25004 !! end
25005
25006 !! test
25007 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
25008 !! options
25009 parsoid=html2wt
25010 !! html/parsoid
25011 <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>
25012 !! wikitext
25013 [[File:Foobar.jpg|thumb|caption]]
25014 !! end
25015
25016 !! test
25017 5. Nowiki escaping should account for indent-pres
25018 !! options
25019 parsoid=html2wt
25020 !! html/parsoid
25021 <pre>==foo==</pre>
25022 !! wikitext
25023 ==foo==
25024 !! end
25025
25026 !!test
25027 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
25028 !! options
25029 parsoid=html2wt
25030 !! html/parsoid
25031 <pre>
25032 * foo
25033 * bar
25034 </pre>
25035 !! wikitext
25036 * foo
25037 * bar
25038 !! end
25039
25040 #### --------------- Behavior Switches --------------------
25041
25042 !! test
25043 1. Valid behavior switches should be escaped
25044 !! options
25045 parsoid=html2wt
25046 !! html/parsoid
25047 __TOC__
25048 <i>__TOC__</i>
25049 !! wikitext
25050 <nowiki>__TOC__</nowiki>
25051 ''<nowiki>__TOC__</nowiki>''
25052 !! end
25053
25054 !! test
25055 2. Invalid behavior switches should not be escaped
25056 !! options
25057 parsoid=html2wt
25058 !! html/parsoid
25059 __TOO__
25060 __|__
25061 !! wikitext
25062 __TOO__
25063 __|__
25064 !! end
25065
25066 # We use indent-pre as an indirect way to test for sol-transparent behavior.
25067 !! test
25068 Behavior switches should be SOL-transparent
25069 !! options
25070 parsoid=html2wt
25071 !! html/parsoid
25072 <meta property="mw:PageProp/toc" />
25073
25074 <!-- this one's bogus -->
25075 <pre>__TOO__</pre>
25076
25077 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
25078
25079 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
25080 !! wikitext
25081 __TOC__
25082
25083 <!-- this one's bogus -->
25084 __TOO__
25085
25086 __TOC__ foo
25087
25088 __TOC__
25089 bar
25090 !! end
25091
25092 #### --------------- HTML tags ---------------
25093 #### 1. a tags
25094 #### 2. other tags
25095 #### 3. multi-line html tag
25096 #### 4. extension tags
25097 #### -----------------------------------------
25098 !! test
25099 1. a tags
25100 !! options
25101 parsoid=html2wt
25102 !! html/parsoid
25103 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
25104 !! wikitext
25105 <a href="http://google.com">google</a>
25106 !! end
25107
25108 !! test
25109 2. other tags
25110 !! options
25111 parsoid=html2wt
25112 !! html/parsoid
25113 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
25114 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
25115 <li> &lt;td&gt;</li></ul>
25116
25117 !! wikitext
25118 * <nowiki><div>foo</div></nowiki>
25119 * <nowiki><div style="color:red">foo</div></nowiki>
25120 * <nowiki><td></nowiki>
25121 !! end
25122
25123 !! test
25124 3. multi-line html tag
25125 !! options
25126 parsoid=html2wt
25127 !! html/parsoid
25128 <p>&lt;div
25129 &gt;foo&lt;/div
25130 &gt;
25131 </p>
25132 !! wikitext
25133 <nowiki><div
25134 >foo</div
25135 ></nowiki>
25136 !! end
25137
25138 !! test
25139 4. extension tags
25140 !! options
25141 parsoid=html2wt
25142 !! html/parsoid
25143 <p>&lt;ref&gt;foo&lt;/ref&gt;
25144 </p><p>&lt;ref&gt;bar
25145 </p><p>baz&lt;/ref&gt;
25146 </p>
25147 !! wikitext
25148 <nowiki><ref>foo</ref></nowiki>
25149
25150 <nowiki><ref>bar</nowiki>
25151
25152 baz<nowiki></ref></nowiki>
25153 !! end
25154
25155 #### --------------- Others ---------------
25156 !! test
25157 Escaping nowikis
25158 !! options
25159 parsoid=html2wt
25160 !! html/parsoid
25161 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
25162 </p>
25163 !! wikitext
25164 &lt;nowiki&gt;foo&lt;/nowiki&gt;
25165 !! end
25166
25167 ## The quote-char in the input is necessary for triggering the bug
25168 !! test
25169 (T54035) Nowiki-escaping should not get tripped by " :" in text
25170 !! options
25171 parsoid=html2wt
25172 !! html/parsoid
25173 <p>foo's bar :</p>
25174 !! wikitext
25175 foo's bar :
25176 !! end
25177
25178 #----------- End of wikitext escaping tests --------------
25179
25180 !! test
25181
25182 Tag-like HTML structures are passed through as text
25183 !! wikitext
25184 <x y>
25185
25186 <x.y>
25187
25188 <x-y>
25189
25190 1>2
25191
25192 x<y
25193
25194 a>b
25195
25196 1<d e>f
25197 !! html
25198 <p>&lt;x y&gt;
25199 </p><p>&lt;x.y&gt;
25200 </p><p>&lt;x-y&gt;
25201 </p><p>1&gt;2
25202 </p><p>x&lt;y
25203 </p><p>a&gt;b
25204 </p><p>1&lt;d e&gt;f
25205 </p>
25206 !! end
25207
25208 !! test
25209 HTML tag with necessary entities in attributes
25210 !! wikitext
25211 <span title="&amp;amp;">foo</span>
25212 !! html
25213 <p><span title="&amp;amp;">foo</span>
25214 </p>
25215 !! end
25216
25217 !! test
25218 HTML tag with 'unnecessary' entity encoding in attributes
25219 !! wikitext
25220 <span title="&amp;">foo</span>
25221 !! html
25222 <p><span title="&amp;">foo</span>
25223 </p>
25224 !! end
25225
25226 !! test
25227 HTML tag with broken attribute value quoting
25228 !! options
25229 parsoid=wt2html,html2html
25230 !! wikitext
25231 <span title="Hello world>Foo</span>
25232 !! html/php
25233 <p><span title="Hello world">Foo</span>
25234 </p>
25235 !! html/parsoid
25236 <p><span title="Hello world">Foo</span></p>
25237 !! end
25238
25239 !! test
25240 Self-closed tag with broken attribute value quoting
25241 !! options
25242 parsoid=wt2html,html2html
25243 !! wikitext
25244 <div title="Hello world />Foo
25245 !! html/php+tidy
25246 <div title="Hello world"></div>
25247 <p>Foo</p>
25248 !! html/parsoid
25249 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
25250 !! end
25251
25252 !! test
25253 Table with broken attribute value quoting
25254 !! options
25255 parsoid=wt2html,html2html
25256 !! wikitext
25257 {|
25258 | title="Hello world|Foo
25259 |}
25260 !! html/php
25261 <table>
25262 <tr>
25263 <td title="Hello world">Foo
25264 </td></tr></table>
25265
25266 !! html/parsoid
25267 <table>
25268 <tr>
25269 <td title="Hello world">Foo
25270 </td></tr></table>
25271
25272 !! end
25273
25274 !! test
25275 Table with broken attribute value quoting on consecutive lines
25276 !! options
25277 parsoid=wt2html,html2html
25278 !! wikitext
25279 {|
25280 | title="Hello world|Foo
25281 | style="color:red|Bar
25282 |}
25283 !! html/php
25284 <table>
25285 <tr>
25286 <td title="Hello world">Foo
25287 </td>
25288 <td style="color:red">Bar
25289 </td></tr></table>
25290
25291 !! html/parsoid
25292 <table><tbody>
25293 <tr>
25294 <td title="Hello world">Foo
25295 </td><td style="color: red">Bar
25296 </td></tr></tbody></table>
25297
25298 !! end
25299
25300 !!test
25301 Accept empty td cell attribute
25302 !! wikitext
25303 {|
25304 | align="center" | foo || |
25305 |}
25306 !! html
25307 <table>
25308 <tr>
25309 <td align="center"> foo </td>
25310 <td>
25311 </td></tr></table>
25312
25313 !!end
25314
25315 !!test
25316 Non-empty attributes in th-cells
25317 !! wikitext
25318 {|
25319 ! Foo !! style="color: red" | Bar
25320 |}
25321 !! html
25322 <table>
25323 <tr>
25324 <th> Foo </th>
25325 <th style="color: red"> Bar
25326 </th></tr></table>
25327
25328 !!end
25329
25330 !!test
25331 Accept empty attributes in th-cells
25332 !! wikitext
25333 {|
25334 !| foo !!| bar
25335 |}
25336 !! html
25337 <table>
25338 <tr>
25339 <th> foo </th>
25340 <th> bar
25341 </th></tr></table>
25342
25343 !!end
25344
25345 !!test
25346 Empty table rows go away
25347 !! wikitext
25348 {|
25349 | Hello
25350 | there
25351 |- class="foo"
25352 |-
25353 |}
25354 !! html
25355 <table>
25356 <tr>
25357 <td> Hello
25358 </td>
25359 <td> there
25360 </td></tr>
25361
25362 </table>
25363
25364 !! end
25365
25366 ###
25367 ### Parsoid-centric tests for testing RTing of inter-element separators
25368 ### Edge cases not tested by existing parser tests and specific to
25369 ### Parsoid-specific serialization strategies.
25370 ###
25371
25372 !!test
25373 RT-ed inter-element separators should be valid separators
25374 !! wikitext
25375 {|
25376 |- [[foo]]
25377 |}
25378 !! html/php
25379 <table>
25380
25381 </table>
25382
25383 !! html/parsoid
25384 <table>
25385 <tbody><tr data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
25386 </tbody></table>
25387 !!end
25388
25389 # Parsoid-only since PHP parser relies on Tidy for correct output
25390 !!test
25391 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
25392 !!options
25393 parsoid
25394 !! wikitext
25395 {|
25396 |<small>foo
25397 bar
25398 |}
25399
25400 {|
25401 |<small>foo<small>
25402 |}
25403 !! html
25404 <table>
25405 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
25406 <p>bar</p></small></td></tr>
25407 </tbody></table>
25408
25409 <table>
25410 <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>
25411 </tbody></table>
25412 !!end
25413
25414 # Note that the "style" attribute is really a template parameter here.
25415 # The = would have to be {{=}} if you wanted the literal.
25416 !!test
25417 Empty TD followed by TD with tpl-generated attribute
25418 !! wikitext
25419 {|
25420 |-
25421 |
25422 |{{echo|style='color:red'}}|foo
25423 |}
25424 !! html
25425 <table>
25426
25427 <tr>
25428 <td>
25429 </td>
25430 <td>foo
25431 </td></tr></table>
25432
25433 !!end
25434
25435 !!test
25436 Indented table with an empty td
25437 !! wikitext
25438 {|
25439 |-
25440 |
25441 |foo
25442 |}
25443 !! html
25444 <table>
25445
25446 <tr>
25447 <td>
25448 </td>
25449 <td>foo
25450 </td></tr></table>
25451
25452 !!end
25453
25454 ## We have some newline diffs RT-ing this edge case
25455 ## and it is not important enough -- we seem to be emitting
25456 ## at most 2 newlines after a </tr> and this is unrelated to
25457 ## the issue from T85627 that this is testing.
25458 !!test
25459 Indented table with blank lines in between (T85627)
25460 !! options
25461 parsoid=wt2html
25462 !! wikitext
25463 {|
25464 |foo
25465
25466
25467 |}
25468 !! html
25469 <table>
25470
25471 <tr>
25472 <td>foo
25473 </td></tr></table>
25474
25475 !!end
25476
25477 !!test
25478 Indented block & table
25479 !! wikitext
25480 <div>foo</div>
25481 {|
25482 |foo
25483 |}
25484 !! html/php
25485 <div>foo</div>
25486 <table>
25487 <tr>
25488 <td>foo
25489 </td></tr></table>
25490
25491 !! html/parsoid
25492 <div data-parsoid='{"stx":"html"}'>foo</div>
25493 <table><tbody>
25494 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
25495 </tbody></table>
25496 !!end
25497
25498 !! test
25499 Indent and comment before table row
25500 !! wikitext
25501 {|
25502 <!--hi-->|-
25503 | there
25504 |}
25505 !! html/php
25506 <table>
25507
25508 <tr>
25509 <td> there
25510 </td></tr></table>
25511
25512 !! html/parsoid
25513 <table>
25514 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
25515 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
25516 </tbody></table>
25517 !! end
25518
25519 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
25520 !!test
25521 Empty TR followed by a template-generated TR
25522 !!options
25523 parsoid
25524 !! wikitext
25525 {|
25526 |-
25527 {{echo|<tr><td>foo</td></tr>}}
25528 |}
25529 !! html
25530 <table>
25531 <tbody>
25532 <tr></tr>
25533 <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}}]}'>
25534 <td>foo</td></tr>
25535 </tbody></table>
25536 !!end
25537
25538 ## PHP and parsoid output differ for this, and since this is primarily
25539 ## for testing Parsoid's serializer, marking this Parsoid only
25540 !!test
25541 Empty TR followed by mixed-ws-comment line should RT correctly
25542 !!options
25543 parsoid
25544 !! wikitext
25545 {|
25546 |-
25547 <!--c-->
25548 |-
25549 <!--c--> <!--d-->
25550 |}
25551 !! html
25552 <table>
25553 <tbody>
25554 <tr></tr>
25555 <!--c-->
25556 <tr>
25557 <!--c--> </tr><!--d-->
25558 </tbody></table>
25559
25560 !!end
25561
25562 !!test
25563 Multi-line image caption generated by templates with/without trailing newlines
25564 !! wikitext
25565 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
25566 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
25567 !! html/parsoid
25568 <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>
25569 <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>
25570 !!end
25571
25572 !! test
25573 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
25574 !! options
25575 parsoid=html2wt
25576 !! html/parsoid
25577 <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>
25578
25579 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
25580 !! wikitext
25581 <includeonly>foo</includeonly>
25582 new para
25583
25584 [[Category:Foo]]
25585
25586 = new heading =
25587 !! end
25588
25589 ## PHP emits broken html for this, and since this is primarily
25590 ## a Parsoid serializer test, marking this Parsoid only
25591 !!test
25592 Improperly nested inline or quotes tags with whitespace in between
25593 !! wikitext
25594 <span> <s>x</span> </s>
25595 ''' ''x''' ''
25596 !! html/parsoid
25597 <p><span> <s>x</s></span><s> </s>
25598 <b> <i>x</i></b><i> </i>
25599 </p>
25600 !!end
25601
25602 !!test
25603 Encapsulate protected attributes from wt
25604 !! wikitext
25605 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
25606
25607 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
25608 | ok
25609 |}
25610 !! html/parsoid
25611 <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>
25612
25613 <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">
25614 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'> ok</td></tr>
25615 </tbody></table>
25616 !!end
25617
25618 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
25619 ## Having nested or stray pre tags results in the attempt to add duplicates,
25620 ## causing an assertion fail. This test tries to prevent that situation.
25621 !!test
25622 Ensure ParagraphWrapper can deal with stray closing pre tags
25623 !!options
25624 parsoid=wt2html
25625 !! wikitext
25626 plain text</pre>
25627 !! html/parsoid
25628 plain text
25629 !!end
25630
25631 !!test
25632 1. Ensure fostered text content is wrapped in element nodes
25633 !!options
25634 parsoid=wt2html
25635 !! wikitext
25636 <table>hi</table><table>ho</table>
25637 !! html/parsoid
25638 <p>hi</p>
25639 <table></table>
25640 <p>ho</p>
25641 <table></table>
25642 !!end
25643
25644 !!test
25645 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
25646 !!options
25647 parsoid=wt2html,wt2wt
25648 !! wikitext
25649 <table>
25650 <tr> || ||
25651 <td> a
25652 </table>
25653 !! html/parsoid
25654 <p> || ||
25655 </p><table>
25656 <tbody><tr><td> a</td></tr>
25657 </tbody></table>
25658 !!end
25659
25660 !!test
25661 Encapsulation properly handles null DSR information from foster box
25662 !!options
25663 parsoid=wt2html,wt2wt
25664 !! wikitext
25665 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
25666 !! html/parsoid
25667 <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>
25668 !!end
25669
25670 !!test
25671 1. Encapsulate foster-parented transclusion content
25672 !!options
25673 parsoid=wt2wt,wt2html
25674 !! wikitext
25675 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
25676 !! html/parsoid
25677 <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>
25678 <tbody>
25679 <tr>
25680 <td>bar</td>
25681 </tr>
25682 </tbody>
25683 </table>
25684 !!end
25685
25686 !!test
25687 2. Encapsulate foster-parented transclusion content
25688 !!options
25689 parsoid=wt2wt,wt2html
25690 !! wikitext
25691 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
25692 !! html/parsoid
25693 <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>
25694 <table>
25695 <tbody>
25696 <tr>
25697 <td>bar</td>
25698 </tr>
25699 </tbody>
25700 </table>
25701 !!end
25702
25703 !!test
25704 3. Encapsulate foster-parented transclusion content
25705 !!options
25706 parsoid=wt2wt,wt2html
25707 !! wikitext
25708 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
25709 !! html/parsoid
25710 <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;]}">
25711 <p>foo</p>
25712 </div>
25713 <table>
25714 <tbody>
25715 <tr>
25716 <td>bar</td>
25717 </tr>
25718 </tbody>
25719 </table>
25720 !!end
25721
25722 !!test
25723 4. Encapsulate foster-parented transclusion content
25724 !!options
25725 parsoid=wt2wt,wt2html
25726 !! wikitext
25727 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
25728 !! html/parsoid
25729 <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;]}">
25730 <p>foo</p>
25731 </div>
25732 <table>
25733 <tbody>
25734 <tr>
25735 <td>bar</td>
25736 </tr>
25737 </tbody>
25738 </table>
25739 !!end
25740
25741 !!test
25742 5. Encapsulate foster-parented transclusion content
25743 !!options
25744 parsoid=wt2wt,wt2html
25745 !! wikitext
25746 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
25747 !! html/parsoid
25748 <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>
25749 <table>
25750 <tbody>
25751 <tr>
25752 <td>
25753 <div>
25754 <p>foo</p>
25755 </div>
25756 </td>
25757 </tr>
25758 </tbody>
25759 </table>
25760 !!end
25761
25762 !!test
25763 6. Encapsulate foster-parented transclusion content
25764 !!options
25765 parsoid=wt2wt,wt2html
25766 !! wikitext
25767 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
25768 !! html/parsoid
25769 <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>
25770 <table>
25771 <tbody>
25772 <tr>
25773 <td>
25774 <div>
25775 <p>foo</p>
25776 </div>
25777 </td>
25778 </tr>
25779 </tbody>
25780 </table>
25781 <p>ok</p>
25782 !!end
25783
25784 !!test
25785 7. Encapsulate foster-parented transclusion content
25786 !!options
25787 parsoid=wt2wt,wt2html
25788 !! wikitext
25789 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
25790 !! html/parsoid
25791 <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>
25792 <table>
25793 <tbody>
25794 <tr>
25795 <td>bar</td>
25796 </tr>
25797 </tbody>
25798 </table>
25799 !!end
25800
25801 # Note that the wt is broken on purpose: the = should be {{=}} if you
25802 # don't want it to be a template parameter key.
25803 !!test
25804 8. Encapsulate foster-parented transclusion content
25805 !!options
25806 parsoid=wt2wt,wt2html
25807 !! wikitext
25808 {{echo|a
25809 }}{|{{echo|style='color:red'}}
25810 |-
25811 |b
25812 |}
25813 !! html/parsoid
25814 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}'>a</p>
25815 <span> </span>
25816 <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>
25817 <table>
25818 <tbody>
25819 <tr>
25820 <td>b</td>
25821 </tr>
25822 </tbody>
25823 </table>
25824 !!end
25825
25826 !!test
25827 9. Encapsulate foster-parented transclusion content
25828 !!options
25829 parsoid=wt2wt,wt2html
25830 !! wikitext
25831 <table>{{echo|hi</table>hello}}
25832 !! html/parsoid
25833 <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>
25834 !!end
25835
25836 !!test
25837 Table in fosterable position
25838 !!options
25839 parsoid=wt2html
25840 !! wikitext
25841 {{OpenTable}}
25842 <div>
25843 {|
25844 |}
25845 </div>
25846 |}
25847 !! html/parsoid
25848 <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">
25849 </span>
25850 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
25851
25852 <table>
25853 </table>
25854 !!end
25855
25856 # Parsoid only for T66747
25857 !! test
25858 Properly encapsulate empty-content transclusions in fosterable positions
25859 !! wikitext
25860 <table>
25861 {{#if:|
25862 <td>foo</td>
25863 }}
25864 </table>
25865 !! html/parsoid
25866 <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"}]]}'>
25867
25868 </table>
25869 !! end
25870
25871 !! test
25872 Always encapsulate foster box when template range is expanded to table
25873 !! options
25874 parsoid=wt2wt
25875 !! wikitext
25876 {|
25877 hello
25878 {{OpenTable}}
25879 |}
25880 !! html/parsoid
25881
25882 !! end
25883
25884 !! test
25885 T115289: Unclosed table
25886 !! wikitext
25887 {{echo|<table>}}<!--c-->[[Category:Two]]
25888 !! html/parsoid
25889 <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>
25890 !! end
25891
25892 !! test
25893 T115289: Don't migrate newlines out of tables with fostered content
25894 !! wikitext
25895 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
25896 !! html/parsoid
25897 <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>
25898 !! end
25899
25900 !! test
25901 T73074: More fostering fun
25902 !! wikitext
25903 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
25904 !! html/parsoid
25905 <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>
25906 !! end
25907
25908 !!test
25909 Support <object> element with .data attribute
25910 !!options
25911 parsoid=html2wt
25912 !! html/parsoid
25913 <object data="test.swf"></object>
25914 !! wikitext
25915 <object data="test.swf"></object>
25916 !!end
25917
25918 !! test
25919 Don't block XML namespace declaration
25920 !! wikitext
25921 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
25922 !! html/php
25923 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
25924 </p>
25925 !! html/parsoid
25926 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
25927 !! end
25928
25929 # -----------------------------------------------------------------
25930 # The following section of tests are primarily to spec requirements
25931 # around Parsoid's serialization (old, new, edited content)
25932 #
25933 # All these tests are marked Parsoid html2wt and html2html only
25934 # ----------------------------------------------------------------
25935
25936 !! test
25937 Ignore rel attribute in a-tags during serialization to url-links
25938 !! options
25939 parsoid=html2wt
25940 !! html/parsoid
25941 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
25942 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
25943 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
25944 !! wikitext
25945 http://en.wikipedia.org/wiki/Foobar
25946 http://en.wikipedia.org/wiki/Foobar
25947 http://en.wikipedia.org/wiki/Foobar
25948 !! end
25949
25950 # 'mi' is a localinterwiki prefix as well as a language
25951 !! test
25952 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
25953 !! options
25954 parsoid=html2wt
25955 !! html/parsoid
25956 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
25957 !! wikitext
25958 [[Foo]]
25959 !! end
25960
25961 !! test
25962 Parsoid should accept interwiki shortcuts
25963 !! options
25964 parsoid=html2wt
25965 !! html/parsoid
25966 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
25967 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
25968 <a href='./fr:Foo'>Foo</a></p>
25969 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
25970 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
25971 <a href='fr%3AFoo'>Foo</a></p>
25972 !! wikitext
25973 [[:fr:Foo|Foo]]
25974 [[:fr:Foo|Foo]]
25975 [[:fr:Foo|Foo]]
25976
25977 [[:fr:Foo|Foo]]
25978 [[:fr:Foo|Foo]]
25979 [[:fr:Foo|Foo]]
25980 !! end
25981
25982 !! test
25983 Parsoid should not accept invalid interwiki shortcuts
25984 !! options
25985 parsoid=html2wt
25986 !! html/parsoid
25987 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
25988 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
25989 <a href='news:Foo'>Foo</a></p>
25990 !! wikitext
25991 [news:Foo Foo]
25992 [news:Foo Foo]
25993 [news:Foo Foo]
25994 !! end
25995
25996 # See T93839
25997 !! test
25998 New wikilinks should be serialized properly
25999 !! options
26000 parsoid=html2wt
26001 !! html/parsoid
26002 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
26003 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
26004 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
26005 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
26006 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
26007 !! wikitext
26008 [[Foo]]
26009 [[Foo]]
26010 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
26011 http://en.wikipedia.org/wiki/Foo
26012 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
26013 !! end
26014
26015 !! test
26016 New wiki links (href variations)
26017 !! options
26018 parsoid=html2wt
26019 !! html/parsoid
26020 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
26021 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
26022 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
26023 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
26024 !! wikitext
26025 [[Foo_bar]]
26026 [[Foo_bar]]
26027 [[Foo_bar]]
26028 [[Toxine bactérienne]]
26029 !! end
26030
26031 !! test
26032 New wiki links (content string variations)
26033 !! options
26034 parsoid=html2wt
26035 !! html/parsoid
26036 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
26037 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
26038 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
26039 !! wikitext
26040 [[Foo_bar]]
26041 [[Foo bar]]
26042 [[Foo_bar|./Foo_bar]]
26043 !! end
26044
26045 !! test
26046 New category links (href variations)
26047 !! options
26048 parsoid=html2wt
26049 !! html/parsoid
26050 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
26051 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
26052 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
26053 !! wikitext
26054 [[Category:Toxine bactérienne]]
26055 [[Category:Toxine bactérienne]]
26056 [[Category:Toxine bactérienne]]
26057 !! end
26058
26059 !! test
26060 New sol transparent links don't need indent-pre nowiki protection
26061 !! options
26062 parsoid=html2wt
26063 language=de
26064 !! html/parsoid
26065 <link rel="mw:PageProp/redirect" href="./Main_Page">
26066 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
26067 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
26068 !! wikitext
26069 #WEITERLEITUNG [[Main Page]]
26070 <!-- this is good --> [[Category:Good]]
26071 <!-- this is great --> [[Kategorie:Great]]
26072 !! end
26073
26074 !! test
26075 New interlanguage links (href variations)
26076 !! options
26077 parsoid=html2wt
26078 !! html/parsoid
26079 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
26080 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
26081 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
26082 !! wikitext
26083 [[es:Toxine bactérienne]]
26084 [[es:Toxine_bactérienne]]
26085 [[es:Toxine_bactérienne]]
26086 !! end
26087
26088 !! test
26089 Image: Modifying size of an image (1)
26090 !! options
26091 parsoid={
26092 "modes": ["wt2wt"],
26093 "changes": [
26094 ["img[height]", "attr", "height", "22"],
26095 ["img[width]", "attr", "width", "200"]
26096 ]
26097 }
26098 !! wikitext
26099 [[Image:Foobar.jpg|230x230px]]
26100 !! wikitext/edited
26101 [[Image:Foobar.jpg|200x200px]]
26102 !!end
26103
26104 !! test
26105 Image: Modifying size of an image (2)
26106 !! options
26107 parsoid={
26108 "modes": ["wt2wt"],
26109 "changes": [
26110 ["img[height]", "attr", "height", "100"],
26111 ["img[width]", "attr", "width", "500"]
26112 ]
26113 }
26114 !! wikitext
26115 [[Image:Foobar.jpg|230x230px]]
26116 !! wikitext/edited
26117 [[Image:Foobar.jpg|500x500px]]
26118 !!end
26119
26120 # Change in size is ignored so long as class='mw-default-size'
26121 !! test
26122 Image: Modifying size of an image (3)
26123 !! options
26124 parsoid={
26125 "modes": ["wt2wt"],
26126 "changes": [
26127 ["figure[class]", "removeClass", "mw-default-size"],
26128 ["figure img", "attr", "height", "19"],
26129 ["figure img", "attr", "width", "170"]
26130 ]
26131 }
26132 !! wikitext
26133 [[Image:Foobar.jpg|thumb]]
26134 !! wikitext/edited
26135 [[Image:Foobar.jpg|thumb|170x170px]]
26136 !!end
26137
26138 !! test
26139 Image: Modifying alignment of an image (T50665)
26140 !! options
26141 parsoid={
26142 "modes": ["wt2wt"],
26143 "changes": [
26144 ["figure[class]", "removeClass", "mw-halign-right"],
26145 ["figure[class]", "addClass", "mw-halign-left"]
26146 ]
26147 }
26148 !! wikitext
26149 [[Image:Foobar.jpg|thumb|caption|right]]
26150 !! wikitext/edited
26151 [[Image:Foobar.jpg|thumb|caption|left]]
26152 !! end
26153
26154 !! test
26155 Image: Modifying mw-default-size of an frameless image (T64805)
26156 !! options
26157 parsoid={
26158 "modes": ["wt2wt"],
26159 "changes": [
26160 ["figure.mw-default-size", "removeClass", "mw-default-size"]
26161 ]
26162 }
26163 !! wikitext
26164 [[Image:Foobar.jpg|frameless|right]]
26165 !! wikitext/edited
26166 [[Image:Foobar.jpg|frameless|right|220x220px]]
26167 !! end
26168
26169 !! test
26170 Image: Modifying valign of an image (T51221)
26171 !! options
26172 parsoid={
26173 "modes": ["wt2wt"],
26174 "changes": [
26175 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
26176 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
26177 ]
26178 }
26179 !! wikitext
26180 [[File:Foobar.jpg|20px|middle]]
26181 !! wikitext/edited
26182 [[File:Foobar.jpg|20px|text-top]]
26183 !! end
26184
26185 !! test
26186 Image: Modifying alt attribute of an image (T58400)
26187 !! options
26188 parsoid={
26189 "modes": ["wt2wt"],
26190 "changes": [
26191 ["img[alt]", "attr", "alt", "some alternate edited text"]
26192 ]
26193 }
26194 !! wikitext
26195 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
26196 !! wikitext/edited
26197 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
26198 !!end
26199
26200 !! test
26201 Image: Modifying caption of an image
26202 !! options
26203 parsoid={
26204 "modes": ["wt2wt"],
26205 "changes": [
26206 ["figcaption", "text", "new caption"]
26207 ]
26208 }
26209 !! wikitext
26210 [[Image:Foobar.jpg|thumb|original caption]]
26211 !! wikitext/edited
26212 [[Image:Foobar.jpg|thumb|new caption]]
26213 !!end
26214
26215 !! test
26216 Image: empty alt attribute (T50924)
26217 !! options
26218 parsoid
26219 !! wikitext
26220 [[File:Foobar.jpg|thumb|alt=|bar]]
26221 !! html
26222 <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>
26223 !! end
26224
26225 !! test
26226 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
26227 !! options
26228 parsoid=html2wt
26229 language=ar
26230 disabled
26231 !! html/parsoid
26232 <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>
26233 !! wikitext
26234 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
26235 !! end
26236
26237 !! test
26238 Image: Block level image should have \n before and after
26239 !! wikitext
26240 123
26241 [[File:Foobar.jpg|right|thumb|150x150px]]
26242 456
26243 !! html/parsoid
26244 <p>123</p>
26245 <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>
26246 <p>456</p>
26247 !!end
26248
26249 !! test
26250 Image: New block level image should have \n before and after (existing content)
26251 !! wikitext
26252 123
26253 [[File:Foobar.jpg|right|thumb|150x150px]]
26254 456
26255 !! html/parsoid
26256 <p>123</p>
26257 <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>
26258 <p>456</p>
26259 !!end
26260
26261 !! test
26262 Image: upright option (parsoid)
26263 !! wikitext
26264 [[File:Foobar.jpg|thumb|upright|caption]]
26265 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
26266 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
26267 !! html/parsoid
26268 <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>
26269 <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>
26270 <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>
26271 !!end
26272
26273 !! test
26274 Image: upright option is ignored on inline and frame images (parsoid)
26275 !! wikitext
26276 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
26277 !! html/parsoid
26278 <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>
26279 !!end
26280
26281 !! test
26282 Image: from basic HTML (1)
26283 !! options
26284 parsoid=html2wt
26285 !! html/parsoid
26286 <span typeof="mw:Image">
26287 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
26288 </span>
26289 !! wikitext
26290 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
26291 !! end
26292
26293 !! test
26294 Image: from basic HTML (2)
26295 !! options
26296 parsoid=html2wt
26297 !! html/parsoid
26298 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
26299 !! wikitext
26300 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
26301 !! end
26302
26303 !! test
26304 Image: from basic HTML (3)
26305 !! options
26306 parsoid=html2wt
26307 !! html/parsoid
26308 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
26309 !! wikitext
26310 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
26311 !! end
26312
26313 !! test
26314 Image: from basic HTML (4)
26315 !! options
26316 parsoid=html2wt
26317 !! html/parsoid
26318 <img src="./File:Foobar.jpg">
26319 !! wikitext
26320 [[File:Foobar.jpg|link=]]
26321 !! end
26322
26323 !! test
26324 Image: Invalid title as link
26325 !! wikitext
26326 [[File:Foobar.jpg|link=<]]
26327 !! html/php
26328 <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>
26329 </p>
26330 !! html/parsoid
26331 <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>
26332 !! end
26333
26334 !! test
26335 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
26336 !! options
26337 parsoid=html2wt
26338 !! html/parsoid
26339 <ul>
26340 <li><p>foo</p></li>
26341 </ul>
26342 !! wikitext
26343 * foo
26344 !! end
26345
26346 !! test
26347 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
26348 !! options
26349 parsoid=html2wt
26350 !! html/parsoid
26351 <ul> <li>foo</li></ul>
26352 !! wikitext
26353 * foo
26354 !! end
26355
26356 !! test
26357 Don't strip leading whitespace when handling indent-pre suppressing tags
26358 !! options
26359 parsoid=html2wt
26360 !! html/parsoid
26361 <table>
26362 <tr><td> indented row</td></tr>
26363 </table>
26364 <blockquote><p>
26365 <b>This is very bold of you!</b>
26366 </p>
26367 <table><tr><td>
26368 indented cell (no pre-wrapping!)
26369 </td></tr></table>
26370 </blockquote>
26371 <p>foo</p>
26372 <div>bar</div>
26373 !! wikitext
26374 {|
26375 | indented row
26376 |}
26377 <blockquote>
26378 '''This is very bold of you!'''
26379
26380 {|
26381 |
26382 indented cell (no pre-wrapping!)
26383 |}
26384 </blockquote>
26385 foo
26386 <div>bar</div>
26387 !! end
26388
26389 !! test
26390 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
26391 !! options
26392 parsoid=html2wt
26393 !! html/parsoid
26394 <p>foo</p>
26395 <span>bar</span>
26396
26397 <span>foo2
26398 </span>bar2
26399
26400 <div>foo</div>
26401 <span>bar</span>
26402
26403 <div>
26404 <span>foo</span>
26405 </div>
26406 !! wikitext
26407 foo
26408
26409 <span>bar</span>
26410
26411 <span>foo2
26412 <nowiki> </nowiki></span>bar2
26413
26414 <div>foo</div>
26415 <nowiki> </nowiki><span>bar</span>
26416
26417 <div>
26418 <nowiki> </nowiki><span>foo</span>
26419 </div>
26420 !! end
26421
26422 !! test
26423 Lists: Dont insert newlines in a serialized list item.
26424 !! options
26425 parsoid=html2wt
26426 !! html/parsoid
26427 <ul><li>a<br>b</li><li>c</li></ul>
26428 !! wikitext
26429 * a<br>b
26430 * c
26431 !! end
26432
26433 !! test
26434 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
26435 !! options
26436 parsoid={
26437 "modes": ["html2wt"],
26438 "scrubWikitext": false
26439 }
26440 !! html/parsoid
26441 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
26442 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
26443
26444 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
26445 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
26446
26447 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
26448
26449 <h2><meta property="mw:PageProp/toc" /> ok</h2>
26450 !! wikitext
26451 == hello there [[Category:A1]] ==
26452
26453 == [[Category:A2]] hi pal ==
26454
26455 == <!--foo--> [[Category:A3]] how goes it ==
26456
26457 == it goes well [[Category:A4]] <!--bar--> ==
26458
26459 ==howdy [[Category:A5]]==
26460
26461 == __TOC__ ok ==
26462 !! end
26463
26464 !! test
26465 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
26466 !! options
26467 parsoid={
26468 "modes": ["html2wt"],
26469 "scrubWikitext": true
26470 }
26471 !! html/parsoid
26472 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
26473 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
26474
26475 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
26476 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
26477
26478 <h2><meta property="mw:PageProp/toc" /> ok</h2>
26479 !! wikitext
26480 == hello there ==
26481 [[Category:A1]]
26482 [[Category:A2]]
26483
26484 == hi pal ==
26485
26486 <!--foo--> [[Category:A3]]
26487
26488 == how goes it ==
26489
26490 == it goes well ==
26491 [[Category:A4]] <!--bar-->
26492
26493 __TOC__
26494
26495 == ok ==
26496 !! end
26497
26498 !! test
26499 Headings: Don't hoist metas that come from templates
26500 !! options
26501 parsoid={
26502 "modes": ["html2wt"],
26503 "scrubWikitext": true
26504 }
26505 !! html/parsoid
26506 <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>
26507 !! wikitext
26508 == {{echo|foo [[Category:Foo]]}} ==
26509 !! end
26510
26511 !! test
26512 Headings: Category in ref isn't hoisted
26513 !! options
26514 parsoid={
26515 "modes": ["html2wt"],
26516 "scrubWikitext": true
26517 }
26518 !! html/parsoid
26519 <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>
26520
26521 <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>
26522 !! wikitext
26523 == foo <ref>bar
26524 [[Category:Baz]] </ref> ==
26525
26526 <references />
26527 !! end
26528
26529 !! test
26530 Parsoid: Serialize positional parameters with = in them as named parameter
26531 !! options
26532 parsoid=html2wt
26533 !! html/parsoid
26534 <p about="#mwt1" typeof="mw:Transclusion"
26535 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
26536
26537 <p about="#mwt1" typeof="mw:Transclusion"
26538 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
26539
26540 <!--Orig params with data-parsoid has heuristics for handling = chars-->
26541 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
26542 <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>
26543 !! wikitext
26544 {{echo|1=f=oo}}
26545
26546 {{echo|1=f=oo|2=bar}}
26547
26548 <!--Orig params with data-parsoid has heuristics for handling = chars-->
26549 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
26550 {{echo|<nowiki>f=oo</nowiki>|bar}}
26551 !! end
26552
26553 !! test
26554 Parsoid: Serialize positional parameters with = in extlink as named parameter
26555 !! options
26556 parsoid=html2wt
26557 !! html/parsoid
26558 <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>
26559 !! wikitext
26560 {{echo|1=http://stuff?is=ok}}
26561 !! end
26562
26563 !! test
26564 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
26565 !! options
26566 parsoid=html2wt
26567 !! html/parsoid
26568 <div>a<p>b</p></div>
26569 <div>a
26570 <p>b</p></div>
26571 <div>
26572 a
26573 <p>b</p></div>
26574 !! wikitext
26575 <div>a
26576 b
26577 </div>
26578 <div>a
26579 b
26580 </div>
26581 <div>
26582 a
26583
26584 b
26585 </div>
26586 !! end
26587
26588 !! test
26589 Substrings resembling wikitext in hrefs should not get nowiki escapes
26590 !! options
26591 parsoid=html2wt
26592 !! html/parsoid
26593 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
26594 !! wikitext
26595 [[Foo''bar''baz]]
26596 !! end
26597
26598 !! test
26599 Enforce single-line context in the serializer
26600 !! options
26601 parsoid=html2wt
26602 !! html/parsoid
26603 <h2>testing
26604 123</h2>
26605
26606 <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">
26607 </span><span about="#mwt1">you</span> </h2>
26608
26609 <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>
26610
26611 <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
26612 there</span></li></ol>
26613
26614 <ul><li>asd
26615 sdf</li></ul>
26616
26617 <ul><li>foo
26618 bar
26619 baz</li>
26620 <li>foo <b>bar</b>
26621 baz</li></ul>
26622
26623 <dl><dt>hi
26624 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
26625 ho</dd></dl>
26626
26627 <dl><dd> <table>
26628 <tbody><tr><td> ha
26629 ha
26630 ha</td></tr>
26631 </tbody></table></dd></dl>
26632 !! wikitext
26633 == testing 123 ==
26634
26635 == hi {{bogus|there
26636 you}} ==
26637
26638 == foo <ref>hello
26639 there</ref> ==
26640
26641 <references />
26642
26643 * asd sdf
26644
26645 * foo bar baz
26646 * foo '''bar''' baz
26647
26648 ; hi ho : hi ho
26649
26650 : {|
26651 | ha
26652 ha
26653 ha
26654 |}
26655 !! end
26656
26657 !! test
26658 Serialize new placeholder space without spans
26659 !! options
26660 parsoid=html2wt
26661 !! html/parsoid
26662 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
26663
26664 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
26665
26666 <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>
26667 !! wikitext
26668 foo : bar
26669
26670 foo : bar
26671
26672 <ref>foo : bar</ref>ok
26673 !! end
26674
26675
26676 #-----------------------
26677 # Tag minimization tests
26678 #-----------------------
26679
26680 !! test
26681 1. I/B quote minimization: wikitext-only tags should be combined
26682 !! options
26683 parsoid=html2wt
26684 !! html/parsoid
26685 <p><i>A</i><i>B</i></p>
26686 <p><b>A</b><b>B</b></p>
26687 <p><i>A</i><b><i>B</i></b></p>
26688 <p><b>A</b><i><b>B</b></i></p>
26689 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
26690 <p><i><b>A</b></i><i><b>B</b></i></p>
26691 <p><i><b>A</b></i><b><i>B</i></b></p>
26692 <p><b><i>A</i></b><i><b>B</b></i></p>
26693 !! wikitext
26694 ''AB''
26695
26696 '''AB'''
26697
26698 ''A'''B'''''
26699
26700 '''A''B'''''
26701
26702 '''A''BC''D'''
26703
26704 '''''AB'''''
26705
26706 '''''AB'''''
26707
26708 '''''AB'''''
26709 !! end
26710
26711 !! test
26712 2. I/B quote minimization: wikitext and html tags should not be combined
26713 !! options
26714 parsoid=html2wt
26715 !! html/parsoid
26716 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
26717 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
26718 !! wikitext
26719 ''A''<i>B</i>
26720
26721 ''A''<nowiki/>'''<i>B</i>'''
26722 !! end
26723
26724 !! test
26725 3. I/B quote minimization: templated content stops minimization
26726 !! options
26727 parsoid=html2wt
26728 !! html/parsoid
26729 <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>
26730 <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>
26731 !! wikitext
26732 ''A''{{echo|''B''}}
26733
26734 ''A''{{echo|'''''B'''''}}
26735 !! end
26736
26737 !! test
26738 4. I/B quote minimization: new content should be mimimized with adjacent old content
26739 !! options
26740 parsoid=html2wt
26741 !! html/parsoid
26742 <p><i>A</i><i>B</i></p>
26743 <p><b>A</b><b>B</b></p>
26744 <p><i>A</i><b><i>B</i></b></p>
26745 !! wikitext
26746 ''AB''
26747
26748 '''AB'''
26749
26750 ''A'''B'''''
26751 !! end
26752
26753 !! test
26754 5a. Merge adjacent quote nodes if they've been edited
26755 !! options
26756 parsoid={
26757 "modes": ["wt2wt", "selser"],
26758 "changes": [
26759 ["p", "contents", "remove", ":contains('b')"]
26760 ]
26761 }
26762 !! wikitext
26763 ''a''b''c''
26764 !! wikitext/edited
26765 ''ac''
26766 !! end
26767
26768 !! test
26769 5b. Merge adjacent quote nodes if they've been edited
26770 !! options
26771 parsoid={
26772 "modes": ["wt2wt", "selser"],
26773 "changes": [
26774 ["#x", "remove"]
26775 ]
26776 }
26777 !! wikitext
26778 ''a''<span id="x">b</span>''c''
26779 !! wikitext/edited
26780 ''ac''
26781 !! end
26782
26783 !! test
26784 1. Merge adjacent link nodes as long as at least one element is new
26785 !! options
26786 parsoid={
26787 "modes": ["html2wt"],
26788 "scrubWikitext": true
26789 }
26790 !! html/parsoid
26791 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
26792 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
26793 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
26794 !! wikitext
26795 [[Football]]
26796 [[Football]]
26797 [[Football|Foot]][[Football|ball]]
26798 !! end
26799
26800 !! test
26801 2. Merge adjacent link nodes and enable additional normalizations
26802 !! options
26803 parsoid={
26804 "modes": ["html2wt"],
26805 "scrubWikitext": true
26806 }
26807 !! html/parsoid
26808 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
26809 !! wikitext
26810 [[Football|''Football'']]
26811 !! end
26812
26813 !! test
26814 3. Don't merge adjacent link nodes if scrubWikitext is false
26815 !! options
26816 parsoid={
26817 "modes": ["html2wt"],
26818 "scrubWikitext": false
26819 }
26820 !! html/parsoid
26821 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
26822 !! wikitext
26823 [[Football|Foot]][[Football|ball]]
26824 !! end
26825
26826 #------------------------------
26827 # End of tag minimization tests
26828 #------------------------------
26829
26830 !!test
26831 T56262: New entities
26832 !! options
26833 parsoid=html2wt
26834 !! html/parsoid
26835 <span typeof="mw:Entity">&nbsp;</span>
26836 !! wikitext
26837 &nbsp;
26838 !! end
26839
26840 ## Note that there is no wikitext output for 'unknownproperty' ##
26841 ## Unknown magic words are silently dropped ##
26842
26843 !! test
26844 Magic words
26845 !! options
26846 parsoid=html2wt
26847 !! html/parsoid
26848 <meta property='mw:PageProp/toc' />
26849 <meta property='mw:PageProp/notoc' />
26850 <meta property='mw:PageProp/forcetoc' />
26851 <meta property='mw:PageProp/index' />
26852 <meta property='mw:PageProp/noindex' />
26853 <meta property='mw:PageProp/nogallery' />
26854 <meta property='mw:PageProp/noeditsection' />
26855 <meta property='mw:PageProp/notitleconvert' />
26856 <meta property='mw:PageProp/nocontentconvert' />
26857 <meta property='mw:PageProp/unknownproperty' />
26858 !! wikitext
26859 __TOC__
26860 __NOTOC__
26861 __FORCETOC__
26862 __INDEX__
26863 __NOINDEX__
26864 __NOGALLERY__
26865 __NOEDITSECTION__
26866 __NOTITLECONVERT__
26867 __NOCONTENTCONVERT__
26868 !! end
26869
26870 !! test
26871 Consecutive <pre>s should not get merged
26872 !! options
26873 parsoid=html2wt,html2html
26874 !! html/parsoid
26875 <pre>a</pre><pre>b</pre>
26876
26877 <pre>c
26878 </pre><pre>
26879 d</pre>
26880
26881 <pre>e
26882
26883 </pre><pre>
26884
26885 f</pre>
26886 !! wikitext
26887 a
26888
26889 b
26890
26891 c
26892
26893 d
26894
26895 e
26896
26897
26898
26899 f
26900 !! end
26901
26902 !! test
26903 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
26904 !! options
26905 parsoid=html2wt
26906 !! html/parsoid
26907 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
26908 !! wikitext
26909 [[Special:BookSources/1234567890|ISBN 1234567895]]
26910 !! end
26911
26912 !! test
26913 Edited RFC links not serializable as RFC links should serialize as extlinks
26914 !! options
26915 parsoid=html2wt
26916 !! html/parsoid
26917 <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
26918 !! wikitext
26919 [//tools.ietf.org/html/rfc123 New RFC]
26920 !! end
26921
26922 !! test
26923 Edited PMID links not serializable as PMID links should serialize as extlinks
26924 !! options
26925 parsoid=html2wt
26926 !! html/parsoid
26927 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
26928 !! wikitext
26929 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
26930 !! end
26931
26932 !! test
26933 WTS of autolinks with trailing/surrounding context
26934 !! options
26935 parsoid=html2wt
26936 !! html/parsoid
26937 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
26938 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
26939 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
26940 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
26941 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
26942 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
26943 !! wikitext
26944 http://cscott.net'''foo'''
26945
26946 http://cscott.net<b>foo</b>
26947
26948 '''http://cscott.net'''
26949
26950 '''http://cscott.net '''
26951
26952 '''http://cscott.net<nowiki/>x'''
26953
26954 http://cscott.net<nowiki/>x
26955 !! end
26956
26957 !! test
26958 WTS of autolinks with nowikis (round-trip)
26959 !! wikitext
26960 x<nowiki/>http://cscott.net<nowiki/>x
26961 !! html/parsoid
26962 <p>x<a rel="mw:ExtLink" href="http://cscott.net">http://cscott.net</a>x</p>
26963 !! end
26964
26965 # this is the "easy" test because it leaves in place all the
26966 # data-parsoid information indicating this is an autolink
26967 !! test
26968 WTS of autolinks with escapes (editing)
26969 !! options
26970 parsoid={
26971 "modes": ["wt2wt"],
26972 "changes": [
26973 [ "span", "remove" ]
26974 ]
26975 }
26976 !! wikitext
26977 x<nowiki/>http://cscott.net<nowiki/>x
26978 !! wikitext/edited
26979 x<nowiki/>http://cscott.net<nowiki/>x
26980 !! end
26981
26982 !! test
26983 WTS of edited autolink-like text (T103364)
26984 !! options
26985 parsoid={
26986 "modes": ["wt2wt"],
26987 "changes": [
26988 [ "span[typeof]", "removeAttr", "typeof" ]
26989 ]
26990 }
26991 !! wikitext
26992 Not a link: <nowiki>http://example.com</nowiki>.
26993 !! wikitext/edited
26994 Not a link: <span><nowiki>http://example.com</nowiki></span>.
26995 !! end
26996
26997 !! test
26998 WTS of newly-authored autolink-like text (T103364)
26999 !! options
27000 parsoid=html2wt
27001 !! html/parsoid
27002 <p>http://example.com is not a link.</p>
27003 !! wikitext
27004 <nowiki>http://example.com</nowiki> is not a link.
27005 !! end
27006
27007 !! test
27008 WTS of autolink-like text after an autolink (T108563)
27009 !! options
27010 parsoid=html2wt
27011 !! html/parsoid
27012 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
27013 !! wikitext
27014 http://example.com <nowiki>http://example.com</nowiki> is not a link.
27015 !! end
27016
27017 !! test
27018 Magic links inside links (not autolinked)
27019 !! wikitext
27020 [[Foo|http://example.com]]
27021 [[Foo|RFC 1234]]
27022 [[Foo|PMID 1234]]
27023 [[Foo|ISBN 123456789x]]
27024
27025 [http://foo.com http://example.com]
27026 [http://foo.com RFC 1234]
27027 [http://foo.com PMID 1234]
27028 [http://foo.com ISBN 123456789x]
27029 !! html+tidy
27030 <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>
27031 <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>
27032 !! html/parsoid
27033 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
27034 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
27035 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
27036 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
27037
27038 <p><a rel="mw:ExtLink" href="http://foo.com">http://example.com</a>
27039 <a rel="mw:ExtLink" href="http://foo.com">RFC 1234</a>
27040 <a rel="mw:ExtLink" href="http://foo.com">PMID 1234</a>
27041 <a rel="mw:ExtLink" href="http://foo.com">ISBN 123456789x</a></p>
27042 !! end
27043
27044 !! test
27045 Magic links inside image captions (autolinked)
27046 !! wikitext
27047 [[File:Foobar.jpg|thumb|http://example.com]]
27048 [[File:Foobar.jpg|thumb|RFC 1234]]
27049 [[File:Foobar.jpg|thumb|PMID 1234]]
27050 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
27051 !! html+tidy
27052 <div class="thumb tright">
27053 <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>
27054 <div class="thumbcaption">
27055 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
27056 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div>
27057 </div>
27058 </div>
27059 <div class="thumb tright">
27060 <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>
27061 <div class="thumbcaption">
27062 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
27063 <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a></div>
27064 </div>
27065 </div>
27066 <div class="thumb tright">
27067 <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>
27068 <div class="thumbcaption">
27069 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
27070 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a></div>
27071 </div>
27072 </div>
27073 <div class="thumb tright">
27074 <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>
27075 <div class="thumbcaption">
27076 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
27077 <a href="/wiki/Special:BookSources/123456789X" class="internal mw-magiclink-isbn">ISBN 123456789x</a></div>
27078 </div>
27079 </div>
27080 !! html/parsoid
27081 <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>
27082 <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>
27083 <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>
27084 <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>
27085 !! end
27086
27087 !! test
27088 WTS of magic word text (T109371)
27089 !! options
27090 parsoid=html2wt
27091 !! html/parsoid
27092 <p>RFC 1234</p>
27093 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
27094 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
27095 !! wikitext
27096 <nowiki>RFC 1234</nowiki>
27097
27098 [http://foo.com RFC 1234]
27099
27100 [[Foo|RFC 1234]]
27101 !! end
27102
27103 !! test
27104 Edited Redirect link should emit a non-piped wikitext link
27105 !! options
27106 parsoid=html2wt
27107 !! html/parsoid
27108 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
27109 !! wikitext
27110 #REDIRECT [[Bar]]
27111 !! end
27112
27113 !! test
27114 T75121: Infer extension name from typeOf if data-mw is not present
27115 !! options
27116 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
27117 !! html/parsoid
27118 <div typeOf="mw:Extension/foo"></div>
27119 !! wikitext
27120 <foo />
27121 !! end
27122
27123 # Note that the <p> wrapping isn't present in PHP parser output
27124 # The important thing for this test is that P-wrapping doesn't
27125 # interfere with the <nowiki> protection for leading - in <td>
27126 # (which isn't necessary for <th>).
27127 !! test
27128 T88318: p-wrapped dash in table.
27129 !! options
27130 parsoid=html2wt,wt2wt
27131 !! html/parsoid
27132 <table><tbody>
27133 <tr><th><p>-</p></th><th><p>- </p></th></tr>
27134 <tr><td><p>-</p></td><td><p>- </p></td></tr>
27135 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
27136 </tbody></table>
27137 !! wikitext
27138 {|
27139 !-
27140 !-
27141 |-
27142 |<nowiki>-</nowiki>
27143 |<nowiki>- </nowiki>
27144 |-
27145 |<small>-</small>
27146 |<br>
27147 -
27148 |<br>
27149 -
27150 |}
27151 !! html/php+tidy
27152 <table>
27153 <tr>
27154 <th>-</th>
27155 <th>-</th>
27156 </tr>
27157 <tr>
27158 <td>-</td>
27159 <td>-</td>
27160 </tr>
27161 <tr>
27162 <td><small>-</small></td>
27163 <td><br />
27164 <p>-</p>
27165 </td>
27166 <td><br />
27167 <p>-</p>
27168 </td>
27169 </tr>
27170 </table>
27171 !! end
27172
27173 !! test
27174 T149209: WTS: Handle newlines in table cells properly
27175 !! options
27176 parsoid=html2wt
27177 !! html/parsoid
27178 <table>
27179 <tbody>
27180 <tr><td>a
27181 b
27182 </td><td data-parsoid='{"stx_v":"row"}'>c</td></tr>
27183 <tr><td><p>x</p>
27184 </td><td data-parsoid='{"stx_v":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
27185 </tbody></table>
27186 <table>
27187 <tbody>
27188 <tr><th>a
27189 b
27190 </th><th data-parsoid='{"stx_v":"row"}'>c</th></tr>
27191 <tr><th><p>x</h>
27192 </th><th data-parsoid='{"stx_v":"row"}'>y</th></tr>
27193 </tbody></table>
27194 !! wikitext
27195 {|
27196 |a
27197 b
27198 |c
27199 |-
27200 |x
27201 {{!}}y
27202 |}
27203 {|
27204 !a
27205 b
27206 !c
27207 |-
27208 !x
27209 !y
27210 |}
27211 !! end
27212
27213 !! test
27214 T149209: Selser: Handle newlines in table cells properly
27215 !! options
27216 parsoid={
27217 "modes": ["selser"],
27218 "changes": [
27219 [ "#h1", "html", "a\nb\n" ],
27220 [ "#h2", "html", "a\nb\n" ],
27221 [ "#c1", "html", "a\nb\n" ],
27222 [ "#c2", "html", "<p>a</p>" ],
27223 [ "#c3", "html", "<p>a</p>" ],
27224 [ "#c4", "html", "edit-me<p>a</p>" ]
27225 ]
27226 }
27227 !! wikitext
27228 {|
27229 ! id="h1" |edit-me!!1
27230 |-
27231 ! id="h2" |edit-me||2
27232 |-
27233 | id="c1" |edit-me||3
27234 |-
27235 | id="c2" |edit-me||4
27236 |-
27237 | id="c3" |edit-me||p||q||r
27238 |-
27239 | id="c4" |edit-me||p||q||r
27240 |}
27241 !! wikitext/edited
27242 {|
27243 ! id="h1" |a
27244 b
27245 !1
27246 |-
27247 ! id="h2" |a
27248 b
27249 !2
27250 |-
27251 | id="c1" |a
27252 b
27253 |3
27254 |-
27255 | id="c2" |a
27256 |4
27257 |-
27258 | id="c3" |a
27259 |p||q||r
27260 |-
27261 | id="c4" |edit-me
27262 a
27263 |p||q||r
27264 |}
27265 !! end
27266
27267 !! test
27268 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
27269 !! options
27270 parsoid=html2wt
27271 !! html/parsoid
27272 <table id='mwAb'>
27273 <td id='mwAc'>foo</td>
27274 <td id='serialize-this'>bar</td>
27275 </table>
27276 !! wikitext
27277 {|
27278 |foo
27279 | id="serialize-this" |bar
27280 |}
27281 !! end
27282
27283 !! test
27284 Parsoid-like element ids should not be serialized to wikitext unless shadowed
27285 !! options
27286 parsoid=html2wt
27287 !! html/parsoid
27288 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
27289 !! wikitext
27290 <div id="hello">ok</div>
27291 !! end
27292
27293 !! test
27294 WTS change modes
27295 !! options
27296 parsoid={
27297 "modes": ["wt2wt"],
27298 "changes": [
27299 [ "#xyz", "before", "<b>before</b> stuff " ],
27300 [ "#xyz", "after", " stuff <i>after</i>" ],
27301 [ "#xyz", "html", "x <b>y</b> z" ]
27302 ]
27303 }
27304 !! wikitext
27305 <span id="xyz">hello</span>
27306 !! wikitext/edited
27307 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
27308 !! end
27309
27310 !! test
27311 Never serialize a-tag as html, regardless of what data-parsoid has to say
27312 !! options
27313 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
27314 !! html/parsoid
27315 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
27316 !! wikitext
27317 [[Foo]]
27318 !! end
27319
27320 ## SSS FIXME: This is broken output nevertheless.
27321 ## What might be a reasonable non-broken output for this?
27322 ## This is an edge case unlikely to be seen in production
27323 ## that I am not wasting more time on this right now.
27324 !! test
27325 Never serialize a-tag as html, no matter what attributes it has
27326 !! options
27327 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
27328 !! html/parsoid
27329 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
27330 !! wikitext
27331 [http://boo.org http://boohoo.org]
27332 !! end
27333
27334 # Misnested is an indication that selser can reuse the source but these have
27335 # shown to sneak through on occasion. See T101768.
27336 # The original wikitext here is: [http://test.com [[one]] two three]
27337 !! test
27338 Strip span tags added to mark misnested links
27339 !! options
27340 parsoid=html2wt
27341 !! html/parsoid
27342 <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>
27343 !! wikitext
27344 [http://test.com][[one]] two three
27345 !! end
27346
27347 !! test
27348 Catch regression when unpacking misnested links
27349 !! options
27350 parsoid=wt2html
27351 !! wikitext
27352 {{echo|hi}}[http://example.com [[ho]]]
27353 !! html/parsoid
27354 <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>
27355 !! end
27356
27357 !! test
27358 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
27359 !! options
27360 parsoid=html2wt
27361 !! html/parsoid
27362 <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|}"]}'>
27363 <tbody><tr><td>d
27364 </td></tr>
27365 </tbody></table>
27366 !! wikitext
27367 {{echo|a}}
27368 {|{{echo|c
27369 {{!}}d
27370 }}
27371 |}
27372 !! end
27373
27374 ## This test verifies the presence and computation of this attribute indirectly
27375 ## by making an edit and ensuring that the serialization is correct (which it would be
27376 ## only if firstWikitextNode is properly set).
27377 !! test
27378 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
27379 !! options
27380 parsoid= {
27381 "modes": ["wt2wt"],
27382 "changes": [
27383 [ "div#x", "remove" ],
27384 [ "div", "before", "<div>new</div>" ]
27385 ]
27386 }
27387 !! wikitext
27388 <div id="x">foo</div>
27389 {|
27390 {{echo|<div>boo</div>
27391 {{!}}b}}
27392 |c
27393 |}
27394 !! wikitext/edited
27395
27396 <div>new</div>
27397 {|
27398 {{echo|<div>boo</div>
27399 {{!}}b}}
27400 |c
27401 |}
27402 !! end
27403
27404 # --------------------------------------------
27405 # Tests spec'ing wikitext serialization norms |
27406 # --------------------------------------------
27407
27408 !! test
27409 Serialize multi-line indent-pre starting with wikitext syntax
27410 !! options
27411 parsoid=html2wt
27412 !! html/parsoid
27413 <pre>* 1
27414 ** 2
27415 * 3</pre>
27416 !! wikitext
27417 * 1
27418 ** 2
27419 * 3
27420 !! end
27421
27422 !! test
27423 1. Categories should always be serialized on their own line
27424 !! options
27425 parsoid=html2wt
27426 !! html/parsoid
27427 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
27428 !! wikitext
27429 foo
27430 [[Category:Foo]]
27431 bar
27432 !! end
27433
27434 !! test
27435 2. Categories that are part of templates should not introduce a line break
27436 !! wikitext
27437 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
27438 !! html/parsoid
27439 <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>
27440 !! end
27441
27442 # Careful while editing these next 2 tests. There are \u200f characters
27443 # before and after the <link> tags in the HTML and following some
27444 # of the categories in wikitext
27445 # Do not remove these characters in edits.
27446 #
27447 # As part of the serialization, these bidi characters will get stripped.
27448 !! test
27449 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
27450 !! options
27451 parsoid={
27452 "modes": ["html2wt"],
27453 "scrubWikitext": true
27454 }
27455 !! html/parsoid
27456 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
27457 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
27458 !! wikitext
27459 [[קטגוריה:טקסים]]
27460 [[קטגוריה: שיטות משפט]]
27461 !! end
27462
27463 !! test
27464 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
27465 !! options
27466 parsoid={
27467 "modes": ["html2wt"],
27468 "scrubWikitext": true
27469 }
27470 !! html/parsoid
27471 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
27472 !! wikitext
27473 [[קטגוריה:טקסים]]
27474 ‏y
27475 !! end
27476
27477 !! test
27478 Lists: Add space after bullets
27479 !! options
27480 parsoid=html2wt
27481 !! html/parsoid
27482 <ul>
27483 <li>foo</li>
27484 <li> bar</li>
27485 <li><span> baz</span></li>
27486 </ul>
27487 !! wikitext
27488 * foo
27489 * bar
27490 * <span> baz</span>
27491 !! end
27492
27493 !! test
27494 1. Headings: Add space before/after == (T53744)
27495 !! options
27496 parsoid=html2wt
27497 !! html/parsoid
27498 <h2>foo</h2>
27499 <h2> bar</h2>
27500 <h2>baz </h2>
27501 <h2><span> baz</span></h2>
27502 !! wikitext
27503 == foo ==
27504
27505 == bar ==
27506
27507 == baz ==
27508
27509 == <span> baz</span> ==
27510 !! end
27511
27512 !! test
27513 2. Headings: Add space before/after == even after hoisted content
27514 !! options
27515 parsoid={
27516 "modes": ["html2wt"],
27517 "scrubWikitext": true
27518 }
27519 !! html/parsoid
27520 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
27521 !! wikitext
27522 [[Category:A2]]
27523
27524 == ok ==
27525 !! end
27526
27527 !! test
27528 1. Headings: suppress newly created empty headings
27529 !! options
27530 parsoid={
27531 "modes": ["html2wt"],
27532 "scrubWikitext": true
27533 }
27534 !! html/parsoid
27535 <h2></h2>
27536 !! wikitext
27537 !! end
27538
27539 !! test
27540 2. Headings: don't suppress empty headings if scrubWikitext is false
27541 !! options
27542 parsoid=html2wt
27543 !! html/parsoid
27544 <h2></h2>
27545 !! wikitext
27546 ==<nowiki/>==
27547 !! end
27548
27549 !! test
27550 3. Headings: suppress empty headings on edits
27551 !! options
27552 parsoid={
27553 "modes": ["selser"],
27554 "scrubWikitext": true,
27555 "changes": [
27556 [ "#x", "remove"]
27557 ]
27558 }
27559 !! wikitext
27560 ==<span id="x">foo</span>==
27561 !! wikitext/edited
27562 !! end
27563
27564 !! test
27565 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
27566 !! options
27567 parsoid={
27568 "modes": ["html2wt"],
27569 "scrubWikitext": true
27570 }
27571 !! html/parsoid
27572 <h2>foo<br/>bar</h2>
27573 <h2>foo <span><br/>bar</span> baz</h2>
27574 !! wikitext
27575 == foo bar ==
27576
27577 == foo <span> bar</span> baz ==
27578 !! end
27579
27580 !! test
27581 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
27582 !! options
27583 parsoid={
27584 "modes": ["html2wt"],
27585 "scrubWikitext": false
27586 }
27587 !! html/parsoid
27588 <h2>foo<br/>bar</h2>
27589 !! wikitext
27590 == foo<br> bar ==
27591 !! end
27592
27593 !! test
27594 1. WT Quote Tags: suppress newly created empty style tags
27595 !! options
27596 parsoid={
27597 "modes": ["html2wt"],
27598 "scrubWikitext": true
27599 }
27600 !! html/parsoid
27601 <i></i><b></b>
27602 !! wikitext
27603 !! end
27604
27605 !! test
27606 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
27607 !! options
27608 parsoid=html2wt
27609 !! html/parsoid
27610 <i></i><b></b>
27611 !! wikitext
27612 ''<nowiki/>'''''<nowiki/>'''
27613 !! end
27614
27615 !! test
27616 3. WT Quote Tags: suppress empty style tags on edits
27617 !! options
27618 parsoid={
27619 "modes": ["selser"],
27620 "scrubWikitext": true,
27621 "changes": [
27622 [ "#x", "remove"]
27623 ]
27624 }
27625 !! wikitext
27626 '''<span id="x">foo</span>'''
27627 !! wikitext/edited
27628 !! end
27629
27630 !! test
27631 1. Anchors: suppress newly created empty anchors
27632 !! options
27633 parsoid={
27634 "modes": ["html2wt"],
27635 "scrubWikitext": true
27636 }
27637 !! html/parsoid
27638 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
27639 !! wikitext
27640 !! end
27641
27642 !! test
27643 2. Anchors: don't suppress empty anchors if scrubWikitext is false
27644 !! options
27645 parsoid={
27646 "modes": ["html2wt"],
27647 "scrubWikitext": false
27648 }
27649 !! html/parsoid
27650 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
27651 !! wikitext
27652 [[Test|<nowiki/>]]
27653 !! end
27654
27655 !! test
27656 3. Anchors: suppress empty anchors on edits
27657 !! options
27658 parsoid={
27659 "modes": ["selser"],
27660 "scrubWikitext": true,
27661 "changes": [
27662 [ "#x", "remove"]
27663 ]
27664 }
27665 !! wikitext
27666 [[Test|<span id="x">foo</span>]]
27667 !! wikitext/edited
27668 !! end
27669
27670 !! test
27671 3a. Anchors: do not suppress numbered extlinks
27672 !! options
27673 parsoid={
27674 "modes": ["wt2wt"],
27675 "scrubWikitext": true
27676 }
27677 !! wikitext
27678 [http://foo.com]
27679 !! html/parsoid
27680 <a rel="mw:ExtLink" href="http://foo.com"></a>
27681 !! end
27682
27683 !! test
27684 3b. Anchors: do not suppress numbered extlinks
27685 !! options
27686 parsoid={
27687 "modes": ["wt2wt"],
27688 "scrubWikitext": true,
27689 "changes": [
27690 [ "#x", "remove"]
27691 ]
27692 }
27693 !! wikitext
27694 [http://foo.com <span id="x">foo</span>]
27695 !! wikitext/edited
27696 [http://foo.com]
27697 !! end
27698
27699 !!test
27700 Normalizations should be restricted to edited content
27701 !!options
27702 parsoid={
27703 "modes": ["selser"],
27704 "scrubWikitext": true,
27705 "changes": [
27706 [ "h1", "before", "<i></i>"]
27707 ]
27708 }
27709 !!wikitext
27710 a
27711 = =
27712 b
27713 !!wikitext/edited
27714 a
27715 = =
27716 b
27717 !!end
27718
27719 !! test
27720 1. Multiple normalizations (html2wt)
27721 !! options
27722 parsoid={
27723 "modes": ["html2wt"],
27724 "scrubWikitext": true
27725 }
27726 !! html
27727 <h2><i></i></h2>
27728 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
27729 </a><b><i></i></b>x</p>
27730 !! wikitext
27731
27732 [[foo]]
27733 x
27734
27735 !! end
27736
27737 !! test
27738 2. Multiple normalizations (selser)
27739 !! options
27740 parsoid={
27741 "modes": ["selser"],
27742 "scrubWikitext": true,
27743 "changes": [
27744 [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
27745 ]
27746 }
27747 !! wikitext
27748 <span id="x">foo</span>
27749 !! wikitext/edited
27750 <span id="x">foo</span>
27751
27752 x
27753 !! end
27754
27755 !! test
27756 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
27757 !! options
27758 parsoid={
27759 "modes": ["html2wt"],
27760 "scrubWikitext": true
27761 }
27762 !! html/parsoid
27763 <p> hi</p>
27764 <p> hello</p>
27765 !! wikitext
27766 hi
27767
27768 hello
27769 !! end
27770
27771 !! test
27772 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
27773 !! options
27774 parsoid=html2wt
27775 !! html/parsoid
27776 <p> hi</p>
27777 <p> hello</p>
27778 !! wikitext
27779 <nowiki> </nowiki>hi
27780
27781 <nowiki> </nowiki> hello
27782 !! end
27783
27784 !! test
27785 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
27786 !! options
27787 parsoid={
27788 "modes": ["html2wt"],
27789 "scrubWikitext": true
27790 }
27791 !! html/parsoid
27792 <p>Foo
27793 bar
27794 baz</p>
27795
27796 <table><tr><td>Foo
27797 bar
27798 baz bang</td></tr></table>
27799
27800 <p><!--boo--> foo
27801 bar</p>
27802
27803 <p> foo
27804 bar<span>boo</span></p>
27805 !! wikitext
27806 Foo
27807 bar
27808 baz
27809
27810 {|
27811 |Foo
27812 bar
27813 baz bang
27814 |}
27815
27816 <!--boo-->foo
27817 bar
27818
27819 foo
27820 bar<span>boo</span>
27821 !! end
27822
27823 !! test
27824 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
27825 !! options
27826 parsoid={
27827 "modes": ["selser"],
27828 "scrubWikitext": true,
27829 "changes": [
27830 [ "p", "html", " a\n b" ]
27831 ]
27832 }
27833 !! wikitext
27834 xyz
27835 !! wikitext/edited
27836 a
27837 b
27838 !! end
27839
27840 !! test
27841 1. New links that end in spaces
27842 !! options
27843 parsoid={
27844 "modes": ["html2wt"],
27845 "scrubWikitext": false
27846 }
27847 !! html/parsoid
27848 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
27849 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
27850 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
27851 !! wikitext
27852 [[Berlin ]]<nowiki/>is the capital of Germany.
27853
27854 [[Foo ]]'''bar'''
27855
27856 [[Boston ]] is a city.
27857 !! end
27858
27859 !! test
27860 2. New links that end in spaces
27861 !! options
27862 parsoid={
27863 "modes": ["html2wt"],
27864 "scrubWikitext": true
27865 }
27866 !! html/parsoid
27867 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
27868 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
27869 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
27870 !! wikitext
27871 [[Berlin]] is the capital of Germany.
27872
27873 [[Foo]] '''bar'''
27874
27875 [[Boston]] is a city.
27876 !! end
27877
27878 !! test
27879 1. Table cells with escapable prefixes
27880 !! options
27881 parsoid={
27882 "modes": ["html2wt"],
27883 "scrubWikitext": false
27884 }
27885 !! html
27886 <table>
27887 <tr><td>a</td></tr>
27888 <tr><td>-</td></tr>
27889 <tr><td>+</td></tr>
27890 </table>
27891 !! wikitext
27892 {|
27893 |a
27894 |-
27895 |<nowiki>-</nowiki>
27896 |-
27897 |<nowiki>+</nowiki>
27898 |}
27899 !! end
27900
27901 !! test
27902 2. Table cells with escapable prefixes
27903 !! options
27904 parsoid={
27905 "modes": ["html2wt"],
27906 "scrubWikitext": true
27907 }
27908 !! html
27909 <table>
27910 <tr><td>a</td></tr>
27911 <tr><td>-</td></tr>
27912 <tr><td>+</td></tr>
27913 </table>
27914 !! wikitext
27915 {|
27916 |a
27917 |-
27918 | -
27919 |-
27920 | +
27921 |}
27922 !! end
27923
27924 !! test
27925 3a. Table cells with escapable prefixes after edits
27926 !! options
27927 parsoid={
27928 "modes": ["selser"],
27929 "scrubWikitext": true,
27930 "changes": [
27931 [ "table tbody tr:first-child td:first-child", "remove"]
27932 ]
27933 }
27934 !! wikitext
27935 {|
27936 |a||-
27937 |}
27938 !! wikitext/edited
27939 {|
27940 | -
27941 |}
27942 !! end
27943
27944 !! test
27945 3b. Table cells with escapable prefixes after edits
27946 !! options
27947 parsoid={
27948 "modes": ["selser"],
27949 "scrubWikitext": true,
27950 "changes": [
27951 [ "table tbody tr:first-child td:first-child", "html", "-" ],
27952 [ "#x", "remove" ]
27953 ]
27954 }
27955 !! wikitext
27956 {|
27957 |pqr
27958 |<span id="x">foo</span>+
27959 |}
27960 !! wikitext/edited
27961 {|
27962 | -
27963 | +
27964 |}
27965 !! end
27966
27967 # FIXME: This test will fail because
27968 # normalization doesn't realize that the id attribute
27969 # will eliminate the escapable scenario
27970 !! test
27971 4a. Table cells without escapable prefixes after edits
27972 !! options
27973 parsoid={
27974 "modes": ["selser"],
27975 "scrubWikitext": true,
27976 "changes": [
27977 [ "#x", "html", "-" ]
27978 ]
27979 }
27980 !! wikitext
27981 {|
27982 | id="x" |abcd
27983 |}
27984 !! wikitext/edited
27985 {|
27986 | id="x" |-
27987 |}
27988 !! end
27989
27990 ## This tests normalizer's ability to discriminate between
27991 ## cells having identical content.
27992 !! test
27993 4b. Table cells without escapable prefixes after edits
27994 !! options
27995 parsoid={
27996 "modes": ["selser"],
27997 "scrubWikitext": true,
27998 "changes": [
27999 [ "td", "html", "-" ]
28000 ]
28001 }
28002 !! wikitext
28003 {|
28004 |a||b
28005 |}
28006 !! wikitext/edited
28007 {|
28008 | -||-
28009 |}
28010 !! end
28011
28012 ## This tests normalizer's ability to not be tripped by
28013 ## comments (and whitespace)
28014 !! test
28015 4c. Table cells without escapable prefixes after edits
28016 !! options
28017 parsoid={
28018 "modes": ["selser"],
28019 "scrubWikitext": true,
28020 "changes": [
28021 [ "table tbody tr td:first-child", "remove" ]
28022 ]
28023 }
28024 !! wikitext
28025 {|
28026 |-
28027 <!--foo--> |a||-
28028 |}
28029 !! wikitext/edited
28030 {|
28031 |-
28032 <!--foo--> | -
28033 |}
28034 !! end
28035
28036 ## This tests normalizer's ability to handle HTML cells
28037 !! test
28038 4d. Table cells without escapable prefixes after edits
28039 !! options
28040 parsoid={
28041 "modes": ["selser"],
28042 "scrubWikitext": true,
28043 "changes": [
28044 [ "td", "html", "-" ]
28045 ]
28046 }
28047 !! wikitext
28048 <table>
28049 <tr><td>a</td></tr>
28050 </table>
28051 !! wikitext/edited
28052 <table>
28053 <tr><td>-</td></tr>
28054 </table>
28055 !! end
28056
28057 ## T111151 Remove font elements without attributes
28058 !! test
28059 5a. font tags without attributes should be dropped in scrubWikitext mode
28060 !! options
28061 parsoid={
28062 "modes": ["html2wt"],
28063 "scrubWikitext": true
28064 }
28065 !! html
28066 <font>foo</font>
28067 <font><font>bar</font></font>
28068 <font class="x">boo</font>
28069 !! wikitext
28070 foo
28071 bar
28072 <font class="x">boo</font>
28073 !! end
28074
28075 !! test
28076 5b. font tags should not be dropped without scrubWikitext being enabled
28077 !! options
28078 parsoid={
28079 "modes": ["html2wt"],
28080 "scrubWikitext": false
28081 }
28082 !! html
28083 <font>foo</font>
28084 !! wikitext
28085 <font>foo</font>
28086 !! end
28087
28088 !! test
28089 Escape nowiki DOM elements
28090 !! options
28091 parsoid=html2wt
28092 !! html/parsoid
28093 <nowiki><i>foo</i></nowiki>
28094 !! wikitext
28095 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
28096 !! end
28097
28098 # This is meant to be an interim fix while we go about figuring out
28099 # how to not introduce these trailing <nowiki/>s in the first place.
28100 !! test
28101 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
28102 !! options
28103 parsoid=html2wt
28104 !! html/parsoid
28105 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
28106 y</p>
28107 <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>
28108 <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>
28109 !! wikitext
28110 x
28111 y
28112
28113 {{echo|
28114 1 = <nowiki/>}}
28115
28116 {{echo|
28117 1 = <nowiki/>
28118 }}
28119 !! end
28120
28121 # ---------------------------------------------------
28122 # End of tests spec'ing wikitext serialization norms |
28123 # ---------------------------------------------------
28124
28125 # T104032
28126 !! test
28127 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
28128 !! options
28129 parsoid=html2wt
28130 !! html/parsoid
28131 a<p>b</p>
28132 <b>c</b><p>d</p>
28133 <table><tr>
28134 <td>a<p>b</p></td>
28135 <td><b>c</b><p>d</p></td>
28136 </tr></table>
28137 !! wikitext
28138 a
28139
28140 b
28141
28142 '''c'''
28143
28144 d
28145 {|
28146 |a
28147 b
28148 |'''c'''
28149 d
28150 |}
28151 !! end
28152
28153 !! test
28154 Anchor without href scenarios
28155 !! options
28156 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28157 !! html/parsoid
28158 <a class="bc"></a>
28159 <a class="no">dice</a>
28160 <a name="foo"></a>
28161 !! wikitext
28162
28163 dice
28164 <span name="foo"></span>
28165 !! end
28166
28167 !! test
28168 New transclusion added after a list should be serialized after the list
28169 !! options
28170 parsoid=html2wt
28171 !! html/parsoid
28172 <ul><li>a</li></ul><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</span>
28173 !! wikitext
28174 * a
28175 {{echo|foo}}
28176 !! end
28177
28178 # -----------------------------------------------------------------
28179 # End of section for Parsoid-only html2wt tests for serialization
28180 # of new content
28181 # -----------------------------------------------------------------
28182
28183 # -----------------------------------------------------------------
28184 # The following section of tests are primarily to spec behavior of
28185 # the selective serializer. All these tests have manual selser
28186 # changes. The automated selser changes for all tests handle the
28187 # wide variation of changes, but these tests here capture specs
28188 # deterministically.
28189 # ----------------------------------------------------------------
28190
28191 ## T90517
28192 !! test
28193 Selser: New comments should not be lost
28194 !! options
28195 parsoid={
28196 "modes": ["selser"],
28197 "changes": [
28198 [ "#a", "after", "<!--c1-->" ],
28199 [ "#b", "before", "<!--c2-->" ]
28200 ]
28201 }
28202 !! wikitext
28203 <span id="a">a</span>
28204
28205 <span id="b">b</span>
28206 !! wikitext/edited
28207 <span id="a">a</span><!--c1-->
28208
28209 <!--c2--><span id="b">b</span>
28210 !! end
28211
28212 ## T89383
28213 !! test
28214 Selser: Check for validity of DSR before using it
28215 !! options
28216 parsoid={
28217 "modes": ["selser"],
28218 "changes": [
28219 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
28220 ]
28221 }
28222 !! wikitext
28223 <span id="a">a</span>
28224 !! wikitext/edited
28225 {{DISPLAYTITLE:foo}}
28226 <span id="a">a</span>
28227 !! end
28228
28229 !! test
28230 1. DOMDiff: Changes to <ref> content should be looked up using id
28231 !! options
28232 parsoid={
28233 "modes": ["selser"],
28234 "changes": [
28235 ["#X", "after", "bar"],
28236 ["#Y", "after", "baz"]
28237 ]
28238 }
28239 !! wikitext
28240 X <ref><span id="X">foo</span></ref>
28241 Y <ref name="a" />
28242 <references>
28243 <ref name="a"><span id="Y">foo</span></ref>
28244 </references>
28245 !! wikitext/edited
28246 X <ref><span id="X">foo</span>bar</ref>
28247 Y <ref name="a" />
28248 <references>
28249 <ref name="a"><span id="Y">foo</span>baz</ref>
28250 </references>
28251 !! end
28252
28253 !! test
28254 2. DOMDiff: Changes to <ref> content should be looked up using id
28255 !! options
28256 parsoid={
28257 "modes": ["selser"],
28258 "changes": [
28259 ["#Z", "after", "bar"]
28260 ]
28261 }
28262 !! wikitext
28263 A <ref>foo bar for a</ref>
28264 B <ref group="X" name="b" />
28265
28266 <references />
28267
28268 <references group="X">
28269 <ref name="b"><span id="Z">foo</span></ref>
28270 </references>
28271 !! wikitext/edited
28272 A <ref>foo bar for a</ref>
28273 B <ref group="X" name="b" />
28274
28275 <references />
28276
28277 <references group="X">
28278 <ref name="b"><span id="Z">foo</span>bar</ref>
28279 </references>
28280 !! end
28281
28282 !! test
28283 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
28284 !! options
28285 parsoid={
28286 "modes": ["selser"],
28287 "changes": [
28288 [ "div:first-child", "text", "bar" ]
28289 ]
28290 }
28291 !! wikitext
28292 <div style="{{1x|color:red;}}%">foo</div>
28293 !! wikitext/edited
28294 <div style="{{1x|color:red;}}%">bar</div>
28295 !! end
28296
28297 !! test
28298 Empty LI (T49673)
28299 !! wikitext
28300 * a
28301 *
28302 *
28303 * b
28304 !! html/php+tidy
28305 <ul>
28306 <li>a</li>
28307 <li class="mw-empty-elt"></li>
28308 <li class="mw-empty-elt"></li>
28309 <li>b</li>
28310 </ul>
28311 !! end
28312
28313 !! test
28314 Thumbnail output
28315 !! wikitext
28316 [[File:Thumb.png|thumb]]
28317 !! html/php+tidy
28318 <div class="thumb tright">
28319 <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>
28320 <div class="thumbcaption">
28321 <div class="magnify"><a href="/wiki/File:Thumb.png" class="internal" title="Enlarge"></a></div>
28322 </div>
28323 </div>
28324 </div>
28325 !! end
28326
28327 !! test
28328 unclosed internal link XSS (T137264)
28329 !! wikitext
28330 [[#%3Cscript%3Ealert(1)%3C/script%3E|
28331 !! html/php
28332 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
28333 </p>
28334 !! html/parsoid
28335 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
28336 !! end
28337
28338 !! test
28339 Validating that <style> isn't eaten by tidy (T167349)
28340 !! options
28341 # Use $wgRawHtml to inject a <style> tag, since you normally can't in wikitext
28342 wgRawHtml=1
28343 !! wikitext
28344 <div class="foo">
28345 <html><style>.foo::before { content: "<foo>"; }</style></html>
28346 <html><style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style></html>
28347 </div>
28348 !! html+tidy
28349 <div class="foo">
28350 <style>.foo::before { content: "<foo>"; }</style>
28351 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
28352 </div>
28353 !! end