4c48ed53d608b5b461703f29f8bf0b7a71dd8784
[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 !! wikitext
10425 {{REVISIONID}}
10426 !! html/*
10427 <p>1337
10428 </p>
10429 !! end
10430
10431 !! test
10432 Magic Word: {{SCRIPTPATH}}
10433 !! options
10434 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10435 !! wikitext
10436 {{SCRIPTPATH}}
10437 !! html/*
10438
10439 !! end
10440
10441 !! test
10442 Magic Word: {{STYLEPATH}}
10443 !! options
10444 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10445 !! wikitext
10446 {{STYLEPATH}}
10447 !! html/*
10448 <p>/skins
10449 </p>
10450 !! end
10451
10452 !! test
10453 Magic Word: {{SERVER}}
10454 !! options
10455 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10456 !! wikitext
10457 {{SERVER}}
10458 !! html/*
10459 <p><a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10460 </p>
10461 !! end
10462
10463 !! test
10464 Magic Word: {{SERVERNAME}}
10465 !! options
10466 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10467 !! wikitext
10468 {{SERVERNAME}}
10469 !! html/*
10470 <p>example.org
10471 </p>
10472 !! end
10473
10474 !! test
10475 Magic Word: {{SITENAME}}
10476 !! options
10477 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10478 !! wikitext
10479 {{SITENAME}}
10480 !! html/*
10481 <p>MediaWiki
10482 </p>
10483 !! end
10484
10485 !! test
10486 Magic Word: {{PAGELANGUAGE}}
10487 !! options
10488 language=fr
10489 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10490 !! wikitext
10491 {{PAGELANGUAGE}}
10492 !! html/*
10493 <p>fr
10494 </p>
10495 !! end
10496
10497 !! test
10498 Magic Word: {{PAGELANGUAGE}} on a page with no explicitly set language
10499 !! options
10500 parsoid={ "modes": ["wt2html","wt2wt"], "normalizePhp": true }
10501 !! wikitext
10502 {{PAGELANGUAGE}}
10503 !! html/*
10504 <p>en
10505 </p>
10506 !! end
10507
10508 !! test
10509 Case-sensitive magic words, when cased differently, should just be template transclusions
10510 !! wikitext
10511 {{CurrentMonth}}
10512 {{currentday}}
10513 {{cURreNTweEK}}
10514 {{currentHour}}
10515 !! html
10516 <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>
10517 <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>
10518 <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>
10519 <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>
10520 </p>
10521 !! end
10522
10523 !! test
10524 Case-insensitive magic words should still work with weird casing.
10525 !! wikitext
10526 {{sErVeRNaMe}}
10527 {{LCFirst:AOEU}}
10528 {{ucFIRST:aoeu}}
10529 {{SERver}}
10530 !! html
10531 <p>example.org
10532 aOEU
10533 Aoeu
10534 <a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>
10535 </p>
10536 !! end
10537
10538 # From plwiki:PLOS_ONE
10539 !! test
10540 Parsoid: Page property magic word with magic word contents
10541 !! wikitext
10542 {{DISPLAYTITLE:''{{PAGENAME}}''}}
10543 !! html/parsoid
10544 <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>"}]]}'/>
10545 !! end
10546
10547 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
10548 # But, this is a limitation of our representation and is documented in
10549 # TemplateHandler.js in processSpecialMagicWord
10550 !! test
10551 Parsoid: Template-generated DISPLAYTITLE
10552 !! wikitext
10553 {{{{echo|DISPLAYTITLE}}:Foo}}
10554 !! options
10555 showtitle
10556 !! config
10557 wgAllowDisplayTitle=true
10558 wgRestrictDisplayTitle=false
10559 !! html/php
10560 Foo
10561
10562 !! html/parsoid
10563 <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"}]]}'/>
10564 !! end
10565
10566 !! test
10567 Namespace 1 {{ns:1}}
10568 !! wikitext
10569 {{ns:1}}
10570 !! html
10571 <p>Talk
10572 </p>
10573 !! end
10574
10575 !! test
10576 Namespace 1 {{ns:01}}
10577 !! wikitext
10578 {{ns:01}}
10579 !! html
10580 <p>Talk
10581 </p>
10582 !! end
10583
10584 !! test
10585 Namespace 0 {{ns:0}} (T6783)
10586 !! wikitext
10587 {{ns:0}}
10588 !! html
10589
10590 !! end
10591
10592 !! test
10593 Namespace 0 {{ns:00}} (T6783)
10594 !! wikitext
10595 {{ns:00}}
10596 !! html
10597
10598 !! end
10599
10600 !! test
10601 Namespace -1 {{ns:-1}}
10602 !! wikitext
10603 {{ns:-1}}
10604 !! html
10605 <p>Special
10606 </p>
10607 !! end
10608
10609 !! test
10610 Namespace User {{ns:User}}
10611 !! wikitext
10612 {{ns:User}}
10613 !! html
10614 <p>User
10615 </p>
10616 !! end
10617
10618 !! test
10619 Namespace User talk {{ns:User_talk}}
10620 !! wikitext
10621 {{ns:User_talk}}
10622 !! html
10623 <p>User talk
10624 </p>
10625 !! end
10626
10627 !! test
10628 Namespace User talk {{ns:uSeR tAlK}}
10629 !! wikitext
10630 {{ns:uSeR tAlK}}
10631 !! html
10632 <p>User talk
10633 </p>
10634 !! end
10635
10636 !! test
10637 Namespace File {{ns:File}}
10638 !! wikitext
10639 {{ns:File}}
10640 !! html
10641 <p>File
10642 </p>
10643 !! end
10644
10645 !! test
10646 Namespace File {{ns:Image}}
10647 !! wikitext
10648 {{ns:Image}}
10649 !! html
10650 <p>File
10651 </p>
10652 !! end
10653
10654 !! test
10655 Namespace (lang=de) Benutzer {{ns:User}}
10656 !! options
10657 language=de
10658 !! wikitext
10659 {{ns:User}}
10660 !! html
10661 <p>Benutzer
10662 </p>
10663 !! end
10664
10665 !! test
10666 Namespace (lang=de) Benutzer Diskussion {{ns:3}}
10667 !! options
10668 language=de
10669 !! wikitext
10670 {{ns:3}}
10671 !! html
10672 <p>Benutzer Diskussion
10673 </p>
10674 !! end
10675
10676 !! test
10677 Urlencode
10678 !! wikitext
10679 {{urlencode:hi world?!}}
10680 {{urlencode:hi world?!|WIKI}}
10681 {{urlencode:hi world?!|PATH}}
10682 {{urlencode:hi world?!|QUERY}}
10683 !! html/php
10684 <p>hi+world%3F%21
10685 hi_world%3F!
10686 hi%20world%3F%21
10687 hi+world%3F%21
10688 </p>
10689 !! end
10690
10691 !! test
10692 Magic Word: prioritize type info over data-parsoid
10693 !! options
10694 parsoid=html2wt
10695 !! html/parsoid
10696 <meta property="mw:PageProp/forcetoc" data-parsoid='{"magicSrc":"__NOTOC__"}'/>
10697 !! wikitext
10698 __FORCETOC__
10699 !! end
10700
10701 !! test
10702 Magic Word: serialize on separate line (parsoid)
10703 !! options
10704 parsoid=wt2wt,html2wt
10705 !! wikitext
10706 foo
10707 __NOTOC__
10708 bar
10709 !! html/parsoid
10710 foo<meta property="mw:PageProp/notoc"/>bar
10711 !! end
10712
10713 !! test
10714 Magic Word: rt non-english wikis
10715 !! options
10716 parsoid=wt2wt
10717 language=de
10718 !! wikitext
10719 __NOEDITSECTION__
10720 !! html/parsoid
10721 <meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
10722 !! end
10723
10724 !!test
10725 __proto__ is treated as normal wikitext (T105997)
10726 !!wikitext
10727 __proto__
10728 !!html
10729 <p>__proto__
10730 </p>
10731 !!end
10732
10733 ###
10734 ### Magic links
10735 ###
10736 !! test
10737 Magic links: internal link to RFC (T2479)
10738 !! wikitext
10739 [[RFC 123]]
10740 !! html/php
10741 <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>
10742 </p>
10743 !! html/parsoid
10744 <p><a rel="mw:WikiLink" href="./RFC_123" title="RFC 123">RFC 123</a></p>
10745 !! end
10746
10747 !! test
10748 Magic links: RFC (T2479)
10749 !! wikitext
10750 RFC 822
10751 !! html/php
10752 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
10753 </p>
10754 !! html/parsoid
10755 <p><a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a></p>
10756 !! end
10757
10758 !! test
10759 Magic links: RFC (T67278)
10760 !! wikitext
10761 This is RFC 822 but thisRFC 822 is not RFC 822linked.
10762 !! html/php
10763 <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.
10764 </p>
10765 !! html/parsoid
10766 <p>This is <a href="//tools.ietf.org/html/rfc822" rel="mw:ExtLink">RFC 822</a> but thisRFC 822 is not RFC 822linked.</p>
10767 !! end
10768
10769 !! test
10770 Magic links: RFC (w/ non-newline whitespace, T30950/T31025)
10771 !! wikitext
10772 RFC &nbsp;&#160;&#0160;&#xA0;&#Xa0; 822
10773 RFC
10774 822
10775 !! html/php
10776 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc822">RFC 822</a>
10777 RFC
10778 822
10779 </p>
10780 !! html/parsoid
10781 <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>
10782 RFC
10783 822</p>
10784 !! end
10785
10786 !! test
10787 Magic links: ISBN (T3937)
10788 !! wikitext
10789 ISBN 0-306-40615-2
10790 !! html/php
10791 <p><a href="/wiki/Special:BookSources/0306406152" class="internal mw-magiclink-isbn">ISBN 0-306-40615-2</a>
10792 </p>
10793 !! html/parsoid
10794 <p><a href="./Special:BookSources/0306406152" rel="mw:WikiLink">ISBN 0-306-40615-2</a></p>
10795 !! end
10796
10797 !! test
10798 Magic links: ISBN (T67278)
10799 !! wikitext
10800 This is ISBN 978-0-316-09811-3 but thisISBN 978-0-316-09811-3 is not ISBN 978-0-316-09811-3linked.
10801 !! html/php
10802 <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.
10803 </p>
10804 !! html/parsoid
10805 <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>
10806 !! end
10807
10808 !! test
10809 Magic links: ISBN (w/ non-newline whitespace, T30950/T31025)
10810 !! wikitext
10811 ISBN &nbsp;&#160;&#0160;&#xA0;&#Xa0; 978&nbsp;0&#160;316&#0160;09811&#xA0;3
10812 ISBN
10813 9780316098113
10814 ISBN 978
10815 0316098113
10816 !! html/php
10817 <p><a href="/wiki/Special:BookSources/9780316098113" class="internal mw-magiclink-isbn">ISBN 978 0 316 09811 3</a>
10818 ISBN
10819 9780316098113
10820 ISBN 978
10821 0316098113
10822 </p>
10823 !! html/parsoid
10824 <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>
10825 ISBN
10826 9780316098113
10827 ISBN 978
10828 0316098113</p>
10829 !! end
10830
10831 !! test
10832 Magic links: PMID incorrectly converts space to underscore
10833 !! wikitext
10834 PMID 1234
10835 !! html/php
10836 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
10837 </p>
10838 !! html/parsoid
10839 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract" rel="mw:ExtLink">PMID 1234</a></p>
10840 !! end
10841
10842 !! test
10843 Magic links: PMID (T67278)
10844 !! wikitext
10845 This is PMID 1234 but thisPMID 1234 is not PMID 1234linked.
10846 !! html/php
10847 <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.
10848 </p>
10849 !! html/parsoid
10850 <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>
10851 !! end
10852
10853 !! test
10854 Magic links: PMID (w/ non-newline whitespace, T30950/T31025)
10855 !! wikitext
10856 PMID &nbsp;&#160;&#0160;&#xA0;&#Xa0; 1234
10857 PMID
10858 1234
10859 !! html/php
10860 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a>
10861 PMID
10862 1234
10863 </p>
10864 !! html/parsoid
10865 <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>
10866 PMID
10867 1234</p>
10868 !! end
10869
10870 # <nowiki> nodes shouldn't be inserted during html2wt by Parsoid,
10871 # since these are ExtLinkText, not MagicLinkText
10872 !! test
10873 Magic links: use appropriate serialization for "almost" magic links.
10874 !! wikitext
10875 X[[Special:BookSources/0978739256|foo]]
10876
10877 X[//tools.ietf.org/html/rfc1234 foo]
10878 !! html/php
10879 <p>X<a href="/wiki/Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a>
10880 </p><p>X<a rel="nofollow" class="external text" href="//tools.ietf.org/html/rfc1234">foo</a>
10881 </p>
10882 !! html/parsoid
10883 <p>X<a rel="mw:WikiLink" href="./Special:BookSources/0978739256" title="Special:BookSources/0978739256">foo</a></p>
10884 <p>X<a rel="mw:ExtLink" href="//tools.ietf.org/html/rfc1234">foo</a></p>
10885 !! end
10886
10887 !! test
10888 Magic links: All disabled (T47942)
10889 !! options
10890 wgEnableMagicLinks={"ISBN":false, "PMID":false, "RFC":false}
10891 !! wikitext
10892 ISBN 0-306-40615-2
10893 PMID 1234
10894 RFC 4321
10895 !! html/php
10896 <p>ISBN 0-306-40615-2
10897 PMID 1234
10898 RFC 4321
10899 </p>
10900 !! end
10901
10902 ###
10903 ### Templates
10904 ####
10905
10906 !! test
10907 Nonexistent template
10908 !! wikitext
10909 {{thistemplatedoesnotexist}}
10910 !! html
10911 <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>
10912 </p>
10913 !! end
10914
10915 !! test
10916 Template with invalid target containing tags
10917 !! wikitext
10918 {{a<b>b</b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
10919 !! html
10920 <p>{{a<b>b</b>|foo|a=b|a = b}}
10921 </p>
10922 !! end
10923
10924 !! test
10925 Template with invalid target containing unclosed tag
10926 !! wikitext
10927 {{a<b>|{{echo|foo}}|{{echo|a}}={{echo|b}}|a = b}}
10928 !! html
10929 <p>{{a<b>|foo|a=b|a = b}}</b>
10930 </p>
10931 !! end
10932
10933 !! test
10934 Template with invalid target containing wikilink
10935 !! wikitext
10936 {{[[Main Page]]}}
10937 !! html/php
10938 <p>{{<a href="/wiki/Main_Page" title="Main Page">Main Page</a>}}
10939 </p>
10940 !! html/parsoid
10941 <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>
10942 !! end
10943
10944 !! test
10945 Template with just whitespace in it, T70421
10946 !! wikitext
10947 {{echo|{{ }}}}
10948 !! html/parsoid
10949 <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>
10950 !! end
10951
10952 !! article
10953 Template:test
10954 !! text
10955 This is a test template
10956 !! endarticle
10957
10958 !! test
10959 Simple template
10960 !! wikitext
10961 {{test}}
10962 !! html
10963 <p>This is a test template
10964 </p>
10965 !! end
10966
10967 !! test
10968 Template with explicit namespace
10969 !! wikitext
10970 {{Template:test}}
10971 !! html
10972 <p>This is a test template
10973 </p>
10974 !! end
10975
10976
10977 !! article
10978 Template:paramtest
10979 !! text
10980 This is a test template with parameter {{{param}}}
10981 !! endarticle
10982
10983 !! test
10984 Template parameter
10985 !! wikitext
10986 {{paramtest|param=foo}}
10987 !! html
10988 <p>This is a test template with parameter foo
10989 </p>
10990 !! end
10991
10992 !! article
10993 Template:paramtestnum
10994 !! text
10995 [[{{{1}}}|{{{2}}}]]
10996 !! endarticle
10997
10998 !! test
10999 Template unnamed parameter
11000 !! wikitext
11001 {{paramtestnum|Main Page|the main page}}
11002 !! html
11003 <p><a href="/wiki/Main_Page" title="Main Page">the main page</a>
11004 </p>
11005 !! end
11006
11007 !! article
11008 Template:templatesimple
11009 !! text
11010 (test)
11011 !! endarticle
11012
11013 !! article
11014 Template:templateredirect
11015 !! text
11016 #redirect [[Template:templatesimple]]
11017 !! endarticle
11018
11019 !! article
11020 Template:templateasargtestnum
11021 !! text
11022 {{{{{1}}}}}
11023 !! endarticle
11024
11025 !! article
11026 Template:templateasargtest
11027 !! text
11028 {{template{{{templ}}}}}
11029 !! endarticle
11030
11031 !! article
11032 Template:templateasargtest2
11033 !! text
11034 {{{{{templ}}}}}
11035 !! endarticle
11036
11037 !! test
11038 Template with template name as unnamed argument
11039 !! wikitext
11040 {{templateasargtestnum|templatesimple}}
11041 !! html
11042 <p>(test)
11043 </p>
11044 !! end
11045
11046 !! test
11047 Template with template name as argument
11048 !! wikitext
11049 {{templateasargtest|templ=simple}}
11050 !! html
11051 <p>(test)
11052 </p>
11053 !! end
11054
11055 !! test
11056 Template with template name as argument (2)
11057 !! wikitext
11058 {{templateasargtest2|templ=templatesimple}}
11059 !! html
11060 <p>(test)
11061 </p>
11062 !! end
11063
11064 !! article
11065 Template:templateasargtestdefault
11066 !! text
11067 {{{{{templ|templatesimple}}}}}
11068 !! endarticle
11069
11070 !! article
11071 Template:templa
11072 !! text
11073 '''templ'''
11074 !! endarticle
11075
11076 !! test
11077 Template with default value
11078 !! wikitext
11079 {{templateasargtestdefault}}
11080 !! html
11081 <p>(test)
11082 </p>
11083 !! end
11084
11085 !! test
11086 Template with default value (value set)
11087 !! wikitext
11088 {{templateasargtestdefault|templ=templa}}
11089 !! html
11090 <p><b>templ</b>
11091 </p>
11092 !! end
11093
11094 !! test
11095 Template redirect
11096 !! wikitext
11097 {{templateredirect}}
11098 !! html/php
11099 <p>(test)
11100 </p>
11101 !! html/parsoid
11102 <link rel="mw:PageProp/redirect" href="./Template:Templatesimple" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"templateredirect","href":"./Template:Templateredirect"},"params":{},"i":0}}]}'/>
11103 !! end
11104
11105 !! test
11106 Template with argument in separate line
11107 !! wikitext
11108 {{ templateasargtest |
11109 templ = simple }}
11110 !! html
11111 <p>(test)
11112 </p>
11113 !! end
11114
11115 !! test
11116 Template with complex template as argument
11117 !! wikitext
11118 {{paramtest|
11119 param ={{ templateasargtest |
11120 templ = simple }}}}
11121 !! html
11122 <p>This is a test template with parameter (test)
11123 </p>
11124 !! end
11125
11126 !! test
11127 Templates with templated name
11128 !! wikitext
11129 {{{{echo|echo}}|foo}}
11130 {{{{echo|inner list}} }}
11131 !! html
11132 <p>foo
11133 </p>
11134 <ul><li> item 1</li></ul>
11135
11136 !! html/parsoid
11137 <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>
11138 <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>
11139 !! end
11140
11141 # Parsoid markup is deliberate "broken". This is an edge case.
11142 # See long comment in TemplateHandler.js:convertAttribsToString.
11143 !! test
11144 Templates with invalid templated targets
11145 !! wikitext
11146 {{echo
11147 {{echo|foo}}
11148 }}
11149 !! html/php
11150 <p>{{echo
11151 foo
11152 }}
11153 </p>
11154 !! html/parsoid
11155 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo\n{{echo|foo}}\n"},"params":{},"i":0}}]}'>{{echo
11156 foo }}</p>
11157 !! end
11158
11159 !! test
11160 Template with thumb image (with link in description)
11161 !! wikitext
11162 {{paramtest|param=[[Image:noimage.png|thumb|[[no link|link]] [[no link|caption]]]]}}
11163 !! html/php
11164 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>
11165
11166 !! html+tidy
11167 <p>This is a test template with parameter</p>
11168 <div class="thumb tright">
11169 <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>
11170 <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>
11171 </div>
11172 </div>
11173 !! html/parsoid
11174 <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>
11175 !! end
11176
11177 !! article
11178 Template:complextemplate
11179 !! text
11180 {{{1}}} {{paramtest|
11181 param ={{{param}}}}}
11182 !! endarticle
11183
11184 !! test
11185 Template with complex arguments
11186 !! wikitext
11187 {{complextemplate|
11188 param ={{ templateasargtest |
11189 templ = simple }}|[[Template:complextemplate|link]]}}
11190 !! html
11191 <p><a href="/wiki/Template:Complextemplate" title="Template:Complextemplate">link</a> This is a test template with parameter (test)
11192 </p>
11193 !! end
11194
11195 !! test
11196 T2553: link with two variables in a piped link
11197 !! wikitext
11198 {|
11199 |[[{{{1}}}|{{{2}}}]]
11200 |}
11201 !! html/php
11202 <table>
11203 <tr>
11204 <td>[[{{{1}}}|{{{2}}}]]
11205 </td></tr></table>
11206
11207 !! html/parsoid
11208 <table>
11209 <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>
11210 </tbody></table>
11211 !! end
11212
11213 # See: T2553
11214 !! test
11215 Abort table cell attribute parsing on wikilink
11216 !! wikitext
11217 {|
11218 | testing [[one|two]] | three || four
11219 | testing one two | three || four
11220 | testing="[[one|two]]" | three || four
11221 |}
11222 !! html/php
11223 <table>
11224 <tr>
11225 <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>
11226 <td> four
11227 </td>
11228 <td> three </td>
11229 <td> four
11230 </td>
11231 <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>
11232 <td> four
11233 </td></tr></table>
11234
11235 !! html/parsoid
11236 <table>
11237 <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>
11238 <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>
11239 <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>
11240 </tbody></table>
11241 !! end
11242
11243 !! test
11244 Don't abort table cell attribute parsing if wikilink is found in template arg
11245 !! wikitext
11246 {|
11247 | Test {{#tag:ref|One two "[[three]]" four}}
11248 |}
11249 !! html/parsoid
11250 <table>
11251 <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>
11252 </tbody></table>
11253 !! end
11254
11255 !! test
11256 Magic variable as template parameter
11257 !! wikitext
11258 {{paramtest|param={{SITENAME}}}}
11259 !! html
11260 <p>This is a test template with parameter MediaWiki
11261 </p>
11262 !! end
11263
11264 !! article
11265 Template:linktest
11266 !! text
11267 [[{{{param}}}|link]]
11268 !! endarticle
11269
11270 !! test
11271 Template parameter as link source
11272 !! wikitext
11273 {{linktest|param=Main Page}}
11274 !! html
11275 <p><a href="/wiki/Main_Page" title="Main Page">link</a>
11276 </p>
11277 !! end
11278
11279 !!article
11280 Template:paramtest2
11281 !! text
11282 including another template, {{paramtest|param={{{arg}}}}}
11283 !! endarticle
11284
11285 !! test
11286 Template passing argument to another template
11287 !! wikitext
11288 {{paramtest2|arg='hmm'}}
11289 !! html
11290 <p>including another template, This is a test template with parameter 'hmm'
11291 </p>
11292 !! end
11293
11294 !! article
11295 Template:Linktest2
11296 !! text
11297 Main Page
11298 !! endarticle
11299
11300 !! test
11301 Template as link source
11302 !! wikitext
11303 [[{{linktest2}}]]
11304
11305 [[{{linktest2}}|Main Page]]
11306
11307 [[{{linktest2}}]]Page
11308 !! html
11309 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11310 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
11311 </p><p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>Page
11312 </p>
11313 !! end
11314
11315
11316 !! article
11317 Template:loop1
11318 !! text
11319 {{loop2}}
11320 !! endarticle
11321
11322 !! article
11323 Template:loop2
11324 !! text
11325 {{loop1}}
11326 !! endarticle
11327
11328 !! test
11329 Template infinite loop
11330 !! wikitext
11331 {{loop1}}
11332 !! html
11333 <p><span class="error">Template loop detected: <a href="/wiki/Template:Loop1" title="Template:Loop1">Template:Loop1</a></span>
11334 </p>
11335 !! end
11336
11337 !! test
11338 Template from main namespace
11339 !! wikitext
11340 {{:Main Page}}
11341 !! html
11342 <p>blah blah
11343 </p>
11344 !! end
11345
11346 !! article
11347 Template:table
11348 !! text
11349 {|
11350 | 1 || 2
11351 |-
11352 | 3 || 4
11353 |}
11354 !! endarticle
11355
11356 !! test
11357 T2529: Template with table, not included at beginning of line
11358 !! wikitext
11359 foo {{table}}
11360 !! html
11361 <p>foo
11362 </p>
11363 <table>
11364 <tr>
11365 <td> 1 </td>
11366 <td> 2
11367 </td></tr>
11368 <tr>
11369 <td> 3 </td>
11370 <td> 4
11371 </td></tr></table>
11372
11373 !! end
11374
11375 !! test
11376 T2523: Template shouldn't eat newline (or add an extra one before table)
11377 !! wikitext
11378 foo
11379 {{table}}
11380 !! html
11381 <p>foo
11382 </p>
11383 <table>
11384 <tr>
11385 <td> 1 </td>
11386 <td> 2
11387 </td></tr>
11388 <tr>
11389 <td> 3 </td>
11390 <td> 4
11391 </td></tr></table>
11392
11393 !! end
11394
11395 !! test
11396 T2041: Template parameters shown as broken links
11397 !! wikitext
11398 {{{parameter}}}
11399 !! html
11400 <p>{{{parameter}}}
11401 </p>
11402 !! end
11403
11404 !! test
11405 Template with targets containing wikilinks
11406 !! options
11407 parsoid=wt2html
11408 !! wikitext
11409 {{[[foo]]}}
11410
11411 {{[[{{echo|foo}}]]}}
11412
11413 {{{{echo|[[foo}}]]}}
11414 !! html/php
11415 <p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11416 </p><p>{{<a href="/wiki/Foo" title="Foo">foo</a>}}
11417 </p><p>{{[[foo}}]]
11418 </p>
11419 !! html/parsoid
11420 <p>{{<a rel="mw:WikiLink" href="./Foo" title="Foo">foo</a>}}</p>
11421 <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>
11422 <p>{{<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[[foo}}]]"}},"i":0}}]}'>[[foo}}]]</span></p>
11423 !! end
11424
11425 !! article
11426 Template:''
11427 !! text
11428 bar
11429 !! endarticle
11430
11431 !! test
11432 Templates: Double quotes as template target
11433 !! wikitext
11434 foo {{''}} baz
11435 !! html/php
11436 <p>foo bar baz
11437 </p>
11438 !! html/parsoid
11439 <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
11440 </p>
11441 !! end
11442
11443 ## This test is about making sure Parsoid's data-mw is well formed in the
11444 ## face of multiple templates with intersecting and overlapping ranges. The
11445 ## wikitext itself is wretched.
11446 !! test
11447 Templates with intersecting and overlapping ranges
11448 !! wikitext
11449 {|{{echo|
11450 <p>ha</p>}}
11451 {|{{echo|
11452 <p>ho</p>}}
11453 {{echo|{{!}}hi}}
11454 |}
11455 !! html/php+tidy
11456 <p>ha</p>
11457 <p>ho</p>
11458 <table>
11459 <tr>
11460 <td></td>
11461 </tr>
11462 <tr>
11463 <td>hi</td>
11464 </tr>
11465 </table>
11466 <table>
11467 <tr>
11468 <td></td>
11469 </tr>
11470 </table>
11471 !! html/parsoid
11472 <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":""}]]}'>
11473
11474 </table><p about="#mwt1">ho</p><table about="#mwt1" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"","html":""},{"html":""}]]}'>
11475
11476 <tbody><tr><td>hi</td></tr>
11477 </tbody></table>
11478 !! end
11479
11480 !! article
11481 Template:MSGNW test
11482 !! text
11483 ''None'' of '''this''' should be
11484 * interpreted
11485 but rather passed unmodified
11486 {{test}}
11487 <gallery>
11488 File:Foobar.jpg
11489 </gallery>
11490 <!-- comment -->
11491 !! endarticle
11492
11493 # hmm, fix this or just deprecate msgnw and document its behavior?
11494 !! test
11495 msgnw keyword
11496 !! wikitext
11497 {{msgnw:MSGNW test}}
11498 !! html/php
11499 <p>&#39;&#39;None&#39;&#39; of &#39;&#39;&#39;this&#39;&#39;&#39; should be
11500 &#42; interpreted
11501 &#32;but rather passed unmodified
11502 &#123;&#123;test&#125;&#125;
11503 &#60;gallery&#62;
11504 File:Foobar.jpg
11505 &#60;/gallery&#62;
11506 &#60;!-- comment --&#62;
11507 </p>
11508 !! end
11509
11510 !! test
11511 int keyword
11512 !! wikitext
11513 {{int:youhavenewmessages|lots of money|not!}}
11514 !! html
11515 <p>You have lots of money (not!).
11516 </p>
11517 !! end
11518
11519 !! test
11520 int keyword - non-existing message
11521 !! wikitext
11522 {{int:var}}
11523 !! html
11524 <p>⧼var⧽
11525 </p>
11526 !! end
11527
11528 !! article
11529 Template:Includes
11530 !! text
11531 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11532 !! endarticle
11533
11534 !! test
11535 <includeonly> and <noinclude> being included
11536 !! wikitext
11537 {{Includes}}
11538 !! html
11539 <p>Foobar
11540 </p>
11541 !! end
11542
11543 !! article
11544 Template:Includes2
11545 !! text
11546 <onlyinclude>Foo</onlyinclude>bar
11547 !! endarticle
11548
11549 !! test
11550 <onlyinclude> being included
11551 !! wikitext
11552 {{Includes2}}
11553 !! html
11554 <p>Foo
11555 </p>
11556 !! end
11557
11558
11559 !! article
11560 Template:Includes3
11561 !! text
11562 <onlyinclude>Foo</onlyinclude>bar<includeonly>zar</includeonly>
11563 !! endarticle
11564
11565 !! test
11566 <onlyinclude> and <includeonly> being included
11567 !! wikitext
11568 {{Includes3}}
11569 !! html
11570 <p>Foo
11571 </p>
11572 !! end
11573
11574 !! test
11575 <includeonly> and <noinclude> on a page
11576 !! wikitext
11577 Foo<noinclude>zar</noinclude><includeonly>bar</includeonly>
11578 !! html
11579 <p>Foozar
11580 </p>
11581 !! end
11582
11583 !! test
11584 Un-closed <noinclude>
11585 !! wikitext
11586 <noinclude>
11587 !! html
11588 !! end
11589
11590 !! test
11591 <onlyinclude> on a page
11592 !! wikitext
11593 <onlyinclude>Foo</onlyinclude>bar
11594 !! html
11595 <p>Foobar
11596 </p>
11597 !! end
11598
11599 !! test
11600 Un-closed <onlyinclude>
11601 !! wikitext
11602 <onlyinclude>
11603 !! html
11604 !! end
11605
11606 !!test
11607 Self-closed noinclude, includeonly, onlyinclude tags
11608 !! wikitext
11609 <noinclude />
11610 <includeonly />
11611 <onlyinclude />
11612 !! html
11613 <p><br />
11614 </p>
11615 !!end
11616
11617 !!test
11618 Unbalanced includeonly and noinclude tags
11619 !! wikitext
11620 {|
11621 |a</noinclude>
11622 |b</noinclude></noinclude>
11623 |c</noinclude></includeonly>
11624 |d</includeonly></includeonly>
11625 |}
11626 !! html
11627 <table>
11628 <tr>
11629 <td>a
11630 </td>
11631 <td>b
11632 </td>
11633 <td>c&lt;/includeonly&gt;
11634 </td>
11635 <td>d&lt;/includeonly&gt;&lt;/includeonly&gt;
11636 </td></tr></table>
11637
11638 !!end
11639
11640 !! article
11641 Template:Includeonly section
11642 !! text
11643 <includeonly>
11644 ==Includeonly section==
11645 </includeonly>
11646 ==Section T-1==
11647 !!endarticle
11648
11649 !! test
11650 T8563: Edit link generation for section shown by <includeonly>
11651 !! wikitext
11652 {{includeonly section}}
11653 !! html
11654 <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>
11655 <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>
11656
11657 !! end
11658
11659 # Uses same input as the contents of [[Template:Includeonly section]]
11660 !! test
11661 T8563: Section extraction for section shown by <includeonly>
11662 !! options
11663 section=T-2
11664 !! wikitext
11665 <includeonly>
11666 ==Includeonly section==
11667 </includeonly>
11668 ==Section T-2==
11669 !! html
11670 ==Section T-2==
11671 !! end
11672
11673 !! test
11674 T8563: Edit link generation for section suppressed by <includeonly>
11675 !! wikitext
11676 <includeonly>
11677 ==Includeonly section==
11678 </includeonly>
11679 ==Section 1==
11680 !! html
11681 <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>
11682
11683 !! end
11684
11685 !! test
11686 T8563: Section extraction for section suppressed by <includeonly>
11687 !! options
11688 section=1
11689 !! wikitext
11690 <includeonly>
11691 ==Includeonly section==
11692 </includeonly>
11693 ==Section 1==
11694 !! html
11695 ==Section 1==
11696 !! end
11697
11698 !! test
11699 Un-closed <includeonly>
11700 !! wikitext
11701 <includeonly>
11702 !! html/php
11703 !! html/parsoid
11704 <meta typeof="mw:Includes/IncludeOnly" data-parsoid='{"src":"&lt;includeonly>"}'/>
11705 !! end
11706
11707 ## We used to, but no longer wt2wt this test since the default serializer
11708 ## will normalize the include directives to serialize on their own line.
11709 ## Selser will take care of preserving formatting in scenarios where they
11710 ## intermingled with other wikitext.
11711 !! test
11712 Includes and comments at SOL
11713 !! options
11714 parsoid=wt2html,html2html
11715 !! wikitext
11716 <!-- comment --><noinclude><!-- comment --></noinclude><!-- comment -->== hu ==
11717
11718 <noinclude>
11719 some
11720 </noinclude>* stuff
11721 * here
11722
11723 <includeonly>can have stuff</includeonly>=== here ===
11724
11725 !! html/php
11726 <h2><span class="mw-headline" id="hu">hu</span></h2>
11727 <p>some
11728 </p>
11729 <ul><li> stuff</li>
11730 <li> here</li></ul>
11731 <h3><span class="mw-headline" id="here">here</span></h3>
11732
11733 !! html/parsoid
11734 <!-- 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>
11735
11736 <meta typeof="mw:Includes/NoInclude" data-parsoid='{"src":"&lt;noinclude>"}'/>
11737 <p>some</p>
11738 <meta typeof="mw:Includes/NoInclude/End" data-parsoid='{"src":"&lt;/noinclude>"}'/><ul><li> stuff</li>
11739 <li> here</li></ul>
11740
11741 <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>
11742
11743 !! end
11744
11745 # TODO: test with DOM fragment reuse!
11746 !! test
11747 Parsoid: DOM fragment reuse
11748 !! options
11749 parsoid=wt2wt,wt2html
11750 !! wikitext
11751 a{{echo|b<table></table>c}}d
11752
11753 a{{echo|b
11754 <table></table>
11755 c}}d
11756
11757 {{echo|a
11758
11759 <table></table>
11760
11761 b}}
11762 !! html
11763 <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>
11764
11765 <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">
11766 </span><table about="#mwt2" data-parsoid='{"stx":"html"}'></table><span about="#mwt2">
11767 </span><p about="#mwt2">cd</p>
11768
11769 <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">
11770
11771 </span><table about="#mwt3" data-parsoid='{"stx":"html"}'></table><span about="#mwt3">
11772
11773 </span><p about="#mwt3">b</p>
11774 !! end
11775
11776 !! test
11777 Parsoid: Merge double tds (T52603)
11778 !! options
11779 parsoid
11780 !! wikitext
11781 {|
11782 |{{echo|{{!}} foo}}
11783 |}
11784 !! html
11785 <table><tbody>
11786 <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>
11787 </tbody></table>
11788 !! end
11789
11790 !! test
11791 Parsoid: Merge double tds in nested transclusion content (T52603)
11792 !! options
11793 parsoid
11794 !! wikitext
11795 {{echo|<div>}}
11796 {|
11797 |{{echo|{{!}} foo}}
11798 |}
11799 {{echo|</div>}}
11800 !! html
11801 <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}}]}'>
11802 <table><tbody>
11803 <tr><td data-mw='{"parts":["|"]}'> foo</td></tr>
11804 </tbody></table>
11805 </div>
11806 !! end
11807
11808 ###
11809 ### <includeonly> and <noinclude> in attributes
11810 ###
11811 !!test
11812 0. includeonly around the entire attribute
11813 !! wikitext
11814 <span <includeonly>id="v1"</includeonly><noinclude>id="v2"</noinclude>>bar</span>
11815 !! html
11816 <p><span id="v2">bar</span>
11817 </p>
11818 !!end
11819
11820 !!test
11821 1. includeonly in html attr key
11822 !! wikitext
11823 <span <noinclude>id</noinclude><includeonly>about</includeonly>="foo">bar</span>
11824 !! html
11825 <p><span id="foo">bar</span>
11826 </p>
11827 !!end
11828
11829 !!test
11830 2. includeonly in html attr value
11831 !! wikitext
11832 <span id="<noinclude>v1</noinclude><includeonly>v2</includeonly>">bar</span>
11833 <span id=<noinclude>"v1"</noinclude><includeonly>"v2"</includeonly>>bar</span>
11834 !! html
11835 <p><span id="v1">bar</span>
11836 <span id="v1">bar</span>
11837 </p>
11838 !!end
11839
11840 !!test
11841 3. includeonly in part of an attr value
11842 !! wikitext
11843 <span style="color:<noinclude>red</noinclude><includeonly>blue</includeonly>;">bar</span>
11844 !! html
11845 <p><span style="color:red;">bar</span>
11846 </p>
11847 !!end
11848
11849 !!test
11850 4. includeonly in table attributes
11851 !! wikitext
11852 {|
11853 |- <noinclude>
11854 |-
11855 |a
11856 </noinclude>
11857 |- <includeonly>
11858 |-
11859 |b
11860 </includeonly>
11861 |}
11862 !! html
11863 <table>
11864
11865
11866 <tr>
11867 <td>a
11868 </td></tr>
11869 </table>
11870
11871 !!end
11872
11873 ###
11874 ### Preprocessor precedence tests
11875 ### See: https://www.mediawiki.org/wiki/Preprocessor_ABNF
11876 ###
11877 ##{{[[-{{{{{{[[Foo|bar}}]]}-}}}}}]]
11878 !! test
11879 Preprocessor precedence 1: link is rightmost opening
11880 !! wikitext
11881 {{[[Foo|bar}}]]
11882
11883 But close-brace is not a valid character in a link title:
11884 {{[[Foo}}|bar]]
11885
11886 However, we can still tell this was handled as a link in the preprocessor:
11887 {{echo|[[Foo}}|bar]]|bat}}
11888 !! html
11889 <p>{{<a href="/wiki/Foo" title="Foo">bar}}</a>
11890 </p><p>But close-brace is not a valid character in a link title:
11891 {{[[Foo}}|bar]]
11892 </p><p>However, we can still tell this was handled as a link in the preprocessor:
11893 [[Foo}}|bar]]
11894 </p>
11895 !! end
11896
11897 !! test
11898 Preprocessor precedence 2: template is rightmost opening
11899 !! options
11900 language=zh
11901 !! wikitext
11902 -{{echo|foo}-}}-
11903 !! html
11904 <p>-foo}--
11905 </p>
11906 !! end
11907
11908 !! test
11909 Preprocessor precedence 3: language converter is rightmost opening
11910 !! options
11911 language=zh
11912 !! wikitext
11913 {{echo|hi}}
11914
11915 {{-{R|echo|hi}}}-
11916
11917 [[-{R|raw]]}-
11918 !! html
11919 <p>hi
11920 </p><p>{{echo|hi}}
11921 </p><p>[[raw]]
11922 </p>
11923 !! end
11924
11925 !! test
11926 Preprocessor precedence 4: left-most angle bracket
11927 !! options
11928 language=zh
11929 !! wikitext
11930 <!--{raw}-->
11931 !! html
11932 !! end
11933
11934 !! article
11935 Template:Precedence5
11936 !! text
11937 {{{{{1}}}}}
11938 !! endarticle
11939
11940 !! test
11941 Preprocessor precedence 5: tplarg takes precedence over template
11942 !! wikitext
11943 {{Precedence5|Bullet}}
11944 !! html
11945 <ul><li> Bar</li></ul>
11946
11947 !! end
11948
11949 !! test
11950 Preprocessor precedence 6: broken link is rightmost opening
11951 !! wikitext
11952 {{echo|[[Foo}}
11953
11954 {{echo|[[Foo|bar|bat=baz}}
11955 !! html
11956 <p>{{echo|[[Foo}}
11957 </p><p>{{echo|[[Foo|bar|bat=baz}}
11958 </p>
11959 !! end
11960
11961 # This next test exposes a difference between PHP and Parsoid:
11962 # Given [[Foo|{{echo|Bar]]x}}y]]z:
11963 # 1) Both PHP and Parsoid ignore the `]]` inside the `echo` in the
11964 # "preprocessor" stage. The `{{echo` extends until the `x}}`, and the
11965 # outer `[[Foo` extends until the `y]]`
11966 # 2a) But then the PHP preprocessor emits `[[Foo|Bar]]xy]]z` as an
11967 # intermediate result (after template expansion), and link processing
11968 # happens on this intermediate result, which moves the wikilink
11969 # boundary leftward to `[[Foo|Bar]]`
11970 # 2b) Parsoid works in a single step, so it's going to keep the
11971 # wikilink as extending to the `y]]`
11972 # 3a) Then PHP does linktrail processing which slurps up the trailing
11973 # `xy` inside the link.
11974 # 3b) Parsoid will do linktrail processing to slurp up the trailing
11975 # `z` inside the link.
11976 # This is "correct" behavior. Parsoid's basic worldview is that the
11977 # `]]` inside the template shouldn't be allowed to leak out to affect
11978 # the surrounding wikilink. PHP may match Parsoid (in the future)
11979 # if you use {{#balance}} (T114445).
11980
11981 !! test
11982 Preprocessor precedence 7: broken template is rightmost opening
11983 !! wikitext
11984 [[Foo|{{echo|Bar]]
11985
11986 [[Foo|{{echo|Bar]]-x}}-y]]-z
11987
11988 Careful: linktrails can move the end of the wikilink:
11989 [[Foo|{{echo|y']]a}}l]]l
11990 !! html
11991 <p><a href="/wiki/Foo" title="Foo">{{echo|Bar</a>
11992 </p><p><a href="/wiki/Foo" title="Foo">Bar</a>-x-y]]-z
11993 </p><p>Careful: linktrails can move the end of the wikilink:
11994 <a href="/wiki/Foo" title="Foo">y'al</a>]]l
11995 </p>
11996 !! end
11997
11998 !! test
11999 Preprocessor precedence 8: broken language converter is rightmost opening
12000 !! options
12001 language=zh
12002 !! wikitext
12003 [[Foo-{R|raw]]
12004 !! html
12005 <p>[[Foo-{R|raw]]
12006 </p>
12007 !! end
12008
12009 !! article
12010 Template:Preprocessor_precedence_9
12011 !! text
12012 ;4: {{{{1}}}}
12013 ;5: {{{{{2}}}}}
12014 ;6: {{{{{{3}}}}}}
12015 ;7: {{{{{{{4}}}}}}}
12016 !! endarticle
12017
12018 !! test
12019 Preprocessor precedence 9: groups of braces
12020 !! wikitext
12021 {{Preprocessor precedence 9|Four|Bullet|1|2}}
12022 !! html
12023 <dl><dt>4</dt>
12024 <dd> {Four}</dd>
12025 <dt>5</dt>
12026 <dd> </dd></dl>
12027 <ul><li> Bar</li></ul>
12028 <dl><dt>6</dt>
12029 <dd> Four</dd>
12030 <dt>7</dt>
12031 <dd> {Bullet}</dd></dl>
12032
12033 !! end
12034
12035 !! article
12036 Template:Preprocessor_precedence_10
12037 !! text
12038 ;1: -{R|raw}-
12039 ;2: -{{Bullet}}-
12040 ;3: -{{{1}}}-
12041 ;4: -{{{{2}}}}-
12042 ;5: -{{{{{3}}}}}-
12043 ;6: -{{{{{{4}}}}}}-
12044 ;7: -{{{{{{{5}}}}}}}-
12045 !! endarticle
12046
12047 !! test
12048 Preprocessor precedence 10: groups of braces with leading dash
12049 !! options
12050 language=zh
12051 !! wikitext
12052 {{Preprocessor precedence 10|Three|raw2|Bullet|1|2}}
12053 !! html
12054 <dl><dt>1</dt>
12055 <dd> raw</dd>
12056 <dt>2</dt>
12057 <dd> -</dd></dl>
12058 <ul><li> Bar-</li></ul>
12059 <dl><dt>3</dt>
12060 <dd> -Three-</dd>
12061 <dt>4</dt>
12062 <dd> raw2</dd>
12063 <dt>5</dt>
12064 <dd> -</dd></dl>
12065 <ul><li> Bar-</li></ul>
12066 <dl><dt>6</dt>
12067 <dd> -Three-</dd>
12068 <dt>7</dt>
12069 <dd> raw2</dd></dl>
12070
12071 !! end
12072
12073 !! test
12074 Preprocessor precedence 11: found during visual diff testing
12075 !! wikitext
12076 {{#tag:span|-{{#tag:span|-{{echo|x}}}}}}
12077
12078 {{echo|-{{echo|-{{echo|x}}}}}}
12079
12080 {{echo|-{{echo|x}}}}
12081 !! html
12082 <p><span>-<span>-x</span></span>
12083 </p><p>--x
12084 </p><p>-x
12085 </p>
12086 !! end
12087
12088 !! test
12089 Preprocessor precedence 12: broken language converter closed by brace.
12090 !! wikitext
12091 This form breaks the template, which is unfortunate:
12092 * {{echo|foo-{bar}bat}}
12093
12094 But if the broken language converter markup is inside an extension
12095 tag, nothing bad happens:
12096 * <nowiki>foo-{bar}bat</nowiki>
12097 * {{echo|<nowiki>foo-{bar}bat</nowiki>}}
12098 * <pre>foo-{bar}bat</pre>
12099 * {{echo|<pre>foo-{bar}bat</pre>}}
12100
12101 <tag>foo-{bar}bat</tag>
12102 {{echo|<tag>foo-{bar}bat</tag>}}
12103
12104 !! html+tidy
12105 <p>This form breaks the template, which is unfortunate:</p>
12106 <ul>
12107 <li>{{echo|foo-{bar}bat}}</li>
12108 </ul>
12109 <p>But if the broken language converter markup is inside an extension tag, nothing bad happens:</p>
12110 <ul>
12111 <li>foo-{bar}bat</li>
12112 <li>foo-{bar}bat</li>
12113 <li>
12114 <pre>
12115 foo-{bar}bat
12116 </pre></li>
12117 <li>
12118 <pre>
12119 foo-{bar}bat
12120 </pre></li>
12121 </ul>
12122 <pre>
12123 'foo-{bar}bat'
12124 array (
12125 )
12126 </pre>
12127 <pre>
12128 'foo-{bar}bat'
12129 array (
12130 )
12131 </pre>
12132 !! end
12133
12134 !! test
12135 Preprocessor precedence, 13: broken language converter in external link
12136 !! wikitext
12137 * [http://example.com/-{foo Example in URL]
12138 * [http://example.com Example in -{link} description]
12139 * {{echo|[http://example.com/-{foo Breaks template, however]}}
12140 !! html+tidy
12141 <ul>
12142 <li><a rel="nofollow" class="external text" href="http://example.com/-{foo">Example in URL</a></li>
12143 <li><a rel="nofollow" class="external text" href="http://example.com">Example in -{link} description</a></li>
12144 <li>{{echo|<a rel="nofollow" class="external text" href="http://example.com/-{foo">Breaks template, however</a>}}</li>
12145 </ul>
12146 !! end
12147
12148 !! test
12149 Preprocessor precedence, 14: broken language converter in comment
12150 !! wikitext
12151 * <!--{{foo}}--> ...should be ok
12152 * <!---{{foo}}--> ...extra dashes
12153 * {{echo|foo<!-- -{bar} -->bat}} ...should be ok
12154 !! html+tidy
12155 <ul>
12156 <li>...should be ok</li>
12157 <li>...extra dashes</li>
12158 <li>foobat ...should be ok</li>
12159 </ul>
12160 !! end
12161
12162 !! test
12163 Preprocessor precedence, 15: broken brace markup in headings
12164 !! wikitext
12165 __NOTOC__ __NOEDITSECTION__
12166 ===1 foo[bar 1===
12167 1
12168 ===2 foo[[bar 2===
12169 2
12170 ===3 foo{bar 3===
12171 3
12172 ===4 foo{{bar 4===
12173 4
12174 ===5 foo{{{bar 5===
12175 5
12176 ===6 foo-{bar 6===
12177 6
12178 !! html+tidy
12179 <h3><span class="mw-headline" id="1_foo.5Bbar_1">1 foo[bar 1</span></h3>
12180 <p>1</p>
12181 <h3><span class="mw-headline" id="2_foo.5B.5Bbar_2">2 foo[[bar 2</span></h3>
12182 <p>2</p>
12183 <h3><span class="mw-headline" id="3_foo.7Bbar_3">3 foo{bar 3</span></h3>
12184 <p>3</p>
12185 <h3><span class="mw-headline" id="4_foo.7B.7Bbar_4">4 foo{{bar 4</span></h3>
12186 <p>4</p>
12187 <h3><span class="mw-headline" id="5_foo.7B.7B.7Bbar_5">5 foo{{{bar 5</span></h3>
12188 <p>5</p>
12189 <h3><span class="mw-headline" id="6_foo-.7Bbar_6">6 foo-{bar 6</span></h3>
12190 <p>6</p>
12191 !! end
12192
12193 ###
12194 ### Token Stream Patcher tests
12195 ###
12196 ### These tests won't always pass wt2wt and other modes because
12197 ### on serialization, the table will be output on a new line.
12198 ### For now, we are blacklisting them, and using this to test selser.
12199 ###
12200
12201 !!test
12202 1. Table tag in SOL posn. should get reparsed correctly with valid TSR
12203 !!options
12204 parsoid=wt2html,wt2wt
12205 !!wikitext
12206 {{echo|}}{| width = '100%'
12207 |foo
12208 |}
12209 !!html/parsoid
12210 <span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":""}},"i":0}}]}'></span><table width="100%">
12211 <tbody><tr><td>foo</td></tr>
12212 </tbody></table>
12213 !!end
12214
12215 ## We used to, but no longer wt2wt this test since the default serializer
12216 ## will normalize the include directives to serialize on their own line.
12217 ## Selser will take care of preserving formatting in scenarios where they
12218 ## intermingled with other wikitext.
12219 !!test
12220 2. Table tag in SOL posn. should get reparsed correctly with valid TSR
12221 !!options
12222 parsoid=wt2html
12223 !!wikitext
12224 <includeonly>a</includeonly>{| {{{b}}}
12225 |c
12226 |}
12227 !!html/parsoid
12228 <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":""}]]}'>
12229 <tbody><tr><td>c</td></tr>
12230 </tbody></table>
12231 !!end
12232
12233 !! test
12234 Table wikitext syntax outside wiki-tables
12235 !! wikitext
12236 a
12237 |+ not a caption
12238 ! not a table heading
12239 |- not a table row
12240 | not a table cell
12241 | class="foo bar" | baz
12242 b
12243 |}
12244 |-
12245 c
12246 !! html
12247 <p>a
12248 |+ not a caption
12249 ! not a table heading
12250 |- not a table row
12251 | not a table cell
12252 | class="foo bar" | baz
12253 b
12254 |}
12255 |-
12256 c
12257 </p>
12258 !! end
12259
12260 ###
12261 ### Testing parsing of templates where a template arg
12262 ### has the same name as the template itself.
12263 ###
12264
12265 !! article
12266 Template:quote
12267 !! text
12268 {{{quote|{{{1}}}}}}
12269 !! endarticle
12270
12271 !!test
12272 Templates: Template Name/Arg clash: 1. Use of positional param
12273 !! wikitext
12274 {{quote|foo}}
12275 !! html
12276 <p>foo
12277 </p>
12278 !!end
12279
12280 !!test
12281 Templates: Template Name/Arg clash: 2. Use of named param
12282 !! wikitext
12283 {{quote|quote=foo}}
12284 !! html
12285 <p>foo
12286 </p>
12287 !!end
12288
12289 !!test
12290 Templates: Template Name/Arg clash: 3. Use of named param with empty input
12291 !! wikitext
12292 {{quote|quote}}
12293 !! html
12294 <p>quote
12295 </p>
12296 !!end
12297
12298 ###
12299 ### Parsoid-centric tests to stress Parsoid's ability to RT them unchanged
12300 ###
12301
12302 !!test
12303 Templates: 1. Simple use
12304 !! wikitext
12305 {{echo|Foo}}
12306 !! html
12307 <p>Foo
12308 </p>
12309 !!end
12310
12311 !!test
12312 Templates: 2. Inside a block tag
12313 !! wikitext
12314 <div>{{echo|Foo}}</div>
12315 <blockquote>{{echo|Foo}}</blockquote>
12316 !! html
12317 <div>Foo</div>
12318 <blockquote>Foo</blockquote>
12319
12320 !! html+tidy
12321 <div>Foo</div>
12322 <blockquote>
12323 <p>Foo</p>
12324 </blockquote>
12325 !!end
12326
12327 !!test
12328 Templates: P-wrapping: 1a. Templates on consecutive lines
12329 !! wikitext
12330 {{echo|Foo}}
12331 {{echo|bar}}
12332 !! html
12333 <p>Foo
12334 bar
12335 </p>
12336 !!end
12337
12338 !!test
12339 Templates: P-wrapping: 1b. Templates on consecutive lines
12340 !! wikitext
12341 Foo
12342
12343 {{echo|bar}}
12344 {{echo|baz}}
12345 !! html
12346 <p>Foo
12347 </p><p>bar
12348 baz
12349 </p>
12350 !!end
12351
12352 !!test
12353 Templates: P-wrapping: 1c. Templates on consecutive lines
12354 !! wikitext
12355 {{echo|Foo}}
12356 {{echo|bar}} <div>baz</div>
12357 !! html
12358 <p>Foo
12359 </p>
12360 bar <div>baz</div>
12361
12362 !! html+tidy
12363 <p>Foo</p>
12364 <p>bar</p>
12365 <div>baz</div>
12366 !! end
12367
12368 !!test
12369 Templates: P-wrapping: 1d. Template preceded by comment-only line
12370 !!options
12371 parsoid
12372 !! wikitext
12373 <!-- foo -->
12374 {{echo|Bar}}
12375 !! html
12376 <!-- foo -->
12377
12378 <p about="#mwt223" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"Bar"}},"i":0}}]}'>Bar</p>
12379 !!end
12380
12381 !!test
12382 Templates: Inline Text: 1. Multiple template uses
12383 !! wikitext
12384 {{echo|Foo}}bar{{echo|baz}}
12385 !! html
12386 <p>Foobarbaz
12387 </p>
12388 !!end
12389
12390 !!test
12391 Templates: Inline Text: 2. Back-to-back template uses
12392 !! wikitext
12393 {{echo|Foo}}{{echo|bar}}
12394 !! html
12395 <p>Foobar
12396 </p>
12397 !!end
12398
12399 !!test
12400 Templates: Block Tags: 1. Multiple template uses
12401 !! wikitext
12402 {{echo|<div>Foo</div>}}<div>bar</div>{{echo|<div>baz</div>}}
12403 !! html
12404 <div>Foo</div><div>bar</div><div>baz</div>
12405
12406 !!end
12407
12408 !!test
12409 Templates: Block Tags: 2. Back-to-back template uses
12410 !! wikitext
12411 {{echo|<div>Foo</div>}}{{echo|<div>bar</div>}}
12412 !! html
12413 <div>Foo</div><div>bar</div>
12414
12415 !!end
12416
12417 # This is an edge case relating to paragraph wrapping.
12418 !!test
12419 Templates: Correctly encapsulate templates producing </p> tag without a corresponding <p> tag
12420 !! wikitext
12421 {{echo|a
12422 b</p>}}
12423 !! html/parsoid
12424 <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
12425 b</p>
12426 !!end
12427
12428 !!test
12429 Templates: Links: 1. Simple example
12430 !! wikitext
12431 {{echo|[[Foo|bar]]}}
12432 !! html
12433 <p><a href="/wiki/Foo" title="Foo">bar</a>
12434 </p>
12435 !!end
12436
12437 !!test
12438 Templates: Links: 2. Generation of link href
12439 !! wikitext
12440 [[{{echo|Foo}}|bar]]
12441 !! html
12442 <p><a href="/wiki/Foo" title="Foo">bar</a>
12443 </p>
12444 !!end
12445
12446 !!test
12447 Templates: Links: 3. Generation of part of a link href
12448 !! wikitext
12449 [[Fo{{echo|o}}|bar]]
12450
12451 [[Foo{{echo|bar}}]]
12452
12453 [[Foo{{echo|bar}}baz]]
12454
12455 [[Foo{{echo|bar}}|bar]]
12456
12457 [[:Foo{{echo|bar}}]]
12458
12459 [[:Foo{{echo|bar}}|bar]]
12460 !! html
12461 <p><a href="/wiki/Foo" title="Foo">bar</a>
12462 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12463 </p><p><a href="/index.php?title=Foobarbaz&amp;action=edit&amp;redlink=1" class="new" title="Foobarbaz (page does not exist)">Foobarbaz</a>
12464 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">bar</a>
12465 </p><p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</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>
12468 !!end
12469
12470 !!test
12471 Templates: Links: 4. Multiple templates generating link href
12472 !! wikitext
12473 [[{{echo|F}}{{echo|o}}ob{{echo|ar}}]]
12474 !! html
12475 <p><a href="/index.php?title=Foobar&amp;action=edit&amp;redlink=1" class="new" title="Foobar (page does not exist)">Foobar</a>
12476 </p>
12477 !!end
12478
12479 !!test
12480 Templates: Links: 5. Generation of link text
12481 !! wikitext
12482 [[Foo|{{echo|bar}}]]
12483 !! html
12484 <p><a href="/wiki/Foo" title="Foo">bar</a>
12485 </p>
12486 !!end
12487
12488 !!test
12489 Templates: Links: 5. Nested templates (only outermost template should be marked)
12490 !! wikitext
12491 {{echo|[[{{echo|Foo}}|bar]]}}
12492 !! html
12493 <p><a href="/wiki/Foo" title="Foo">bar</a>
12494 </p>
12495 !!end
12496
12497 !!test
12498 Templates: HTML Tag: 1. Generation of HTML attr. key
12499 !! wikitext
12500 <div {{echo|style}}="color:red;">foo</div>
12501 !! html
12502 <div style="color:red;">foo</div>
12503
12504 !!end
12505
12506 !!test
12507 Templates: HTML Tag: 2. Generation of HTML attr. value
12508 !! wikitext
12509 <div style={{echo|'color:red;'}}>foo</div>
12510 !! html
12511 <div style="color:red;">foo</div>
12512
12513 !!end
12514
12515 !!test
12516 Templates: HTML Tag: 3. Generation of HTML attr key and value
12517 !! wikitext
12518 <div {{echo|style}}={{echo|'color:red;'}}>foo</div>
12519 !! html
12520 <div style="color:red;">foo</div>
12521
12522 !!end
12523
12524 !!test
12525 Templates: HTML Tag: 4. Generation of starting piece of HTML attr value
12526 !! wikitext
12527 <div title="{{echo|This is a long title}} with just one piece templated">foo</div>
12528 !! html
12529 <div title="This is a long title with just one piece templated">foo</div>
12530
12531 !!end
12532
12533 !!test
12534 Templates: HTML Tag: 5. Generation of middle piece of HTML attr value
12535 !! wikitext
12536 <div title="This is a long title with just {{echo|one piece}} templated">foo</div>
12537 !! html
12538 <div title="This is a long title with just one piece templated">foo</div>
12539
12540 !!end
12541
12542 !!test
12543 Templates: HTML Tag: 6. Generation of end piece of HTML attr value
12544 !! wikitext
12545 <div title="This is a long title with just one piece {{echo|templated}}">foo</div>
12546 !! html
12547 <div title="This is a long title with just one piece templated">foo</div>
12548
12549 !!end
12550
12551 # SSS FIXME: While it is great we added support for all this,
12552 # do we want to make this part of the spec? Maybe we want to
12553 # deprecate this kind of usage in the future?
12554 !!test
12555 Templates: HTML Tag: 7. Generation of partial attribute key string
12556 !! wikitext
12557 <div st{{echo|yle}}="color:red;">foo</div>
12558 !! html
12559 <div style="color:red;">foo</div>
12560
12561 !!end
12562
12563 !! test
12564 Templates: HTML Tag: 8. Template-generated attribute (k=v)
12565 !! wikitext
12566 <div {{echo|1=id="v1"}}>bar</div>
12567 !! html
12568 <div id="v1">bar</div>
12569
12570 !!end
12571
12572 !! test
12573 Templates: HTML Tag: 9. Multiple template-generated attributes
12574 !! wikitext
12575 <div {{echo|1=id="v1" title="foo"}}>bar</div>
12576 !! html
12577 <div id="v1" title="foo">bar</div>
12578
12579 !!end
12580
12581 !! test
12582 Templates: Support for templates generating attributes and content
12583 !! wikitext
12584 {| {{mixed_attr_content_template}}
12585 |-
12586 |bar
12587 |}
12588 !! html/php
12589 <table style="color:red;" title="T48811">
12590
12591 <tr>
12592 <td>foo
12593 </td></tr>
12594 <tr>
12595 <td>bar
12596 </td></tr></table>
12597
12598 !! html/parsoid
12599 <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|}"]}'>
12600 <tbody><tr>
12601 <td>foo</td></tr>
12602 <tr>
12603 <td>bar</td></tr>
12604 </tbody></table>
12605 !!end
12606
12607 !! test
12608 1. Entities and nowikis inside templated attributes should be handled correctly
12609 !! wikitext
12610 <div {{echo|style{{=}}"background:&#35;f9f9f9;"}}>foo</div>
12611 !! html/php
12612 <div style="background:#f9f9f9;">foo</div>
12613
12614 !! html/parsoid
12615 <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>
12616 !! end
12617
12618 !! test
12619 2. Entities and nowikis inside templated attributes should be handled correctly
12620 !! wikitext
12621 {|
12622 |{{table_attribs_3}}
12623 |}
12624 !! html/php
12625 <table>
12626 <tr>
12627 <td style="background:#f9f9f9;">Foo
12628 </td></tr></table>
12629
12630 !! html/parsoid
12631 <table>
12632 <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>
12633 </tbody></table>
12634 !! end
12635
12636 !! test
12637 3. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
12638 !! wikitext
12639 {{tbl-start}}
12640 |{{table_attribs_3}}
12641 {{tbl-end}}
12642 !! html/php
12643 <table>
12644 <tr>
12645 <td style="background:#f9f9f9;">Foo
12646 </td></tr></table>
12647
12648 !! html/parsoid
12649 <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}}]}'>
12650 <tbody><tr><td style="background:#f9f9f9;">Foo</td></tr>
12651 </tbody></table>
12652 !! end
12653
12654 # T107622
12655 !! test
12656 4. Entities and nowikis inside templated attributes should be handled correctly inside templated tables
12657 !! wikitext
12658 {|
12659 | {{table_attribs_6}} hi
12660 |}
12661 !! html/php
12662 <table>
12663 <tr>
12664 <td style="background: red;"> hi
12665 </td></tr></table>
12666
12667 !! html/parsoid
12668 <table>
12669 <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>
12670 </tbody></table>
12671 !! end
12672
12673 !!test
12674 Templates: HTML Tables: 1. Generating start of a HTML table
12675 !! wikitext
12676 {{echo|<table><tr><td>foo</td>}}</tr></table>
12677 !! html
12678 <table><tr><td>foo</td></tr></table>
12679
12680 !!end
12681
12682 !!test
12683 Templates: HTML Tables: 2a. Generating middle of a HTML table
12684 !! wikitext
12685 <table><tr>{{echo|<td>foo</td>}}</tr></table>
12686 !! html
12687 <table><tr><td>foo</td></tr></table>
12688
12689 !!end
12690
12691 !!test
12692 Templates: HTML Tables: 2b. Generating middle of a HTML table
12693 !! wikitext
12694 <table>{{echo|<tr><td>foo</td></tr>}}</table>
12695 !! html
12696 <table><tr><td>foo</td></tr></table>
12697
12698 !!end
12699
12700 !!test
12701 Templates: HTML Tables: 3. Generating end of a HTML table
12702 !! wikitext
12703 <table><tr>{{echo|<td>foo</td></tr></table>}}
12704 !! html
12705 <table><tr><td>foo</td></tr></table>
12706
12707 !!end
12708
12709 !!test
12710 Templates: HTML Tables: 4a. Generating a single tag of a HTML table
12711 !! wikitext
12712 {{echo|<table>}}<tr><td>foo</td></tr></table>
12713 !! html
12714 <table><tr><td>foo</td></tr></table>
12715
12716 !!end
12717
12718 !!test
12719 Templates: HTML Tables: 4b. Generating a single tag of a HTML table
12720 !! wikitext
12721 <table>{{echo|<tr>}}<td>foo</td></tr></table>
12722 !! html
12723 <table><tr><td>foo</td></tr></table>
12724
12725 !!end
12726
12727 !!test
12728 Templates: HTML Tables: 4c. Generating a single tag of a HTML table
12729 !! wikitext
12730 <table><tr>{{echo|<td>}}foo</td></tr></table>
12731 !! html
12732 <table><tr><td>foo</td></tr></table>
12733
12734 !!end
12735
12736 !!test
12737 Templates: HTML Tables: 4d. Generating a single tag of a HTML table
12738 !! wikitext
12739 <table><tr><td>foo{{echo|</td>}}</tr></table>
12740 !! html
12741 <table><tr><td>foo</td></tr></table>
12742
12743 !!end
12744
12745 !!test
12746 Templates: HTML Tables: 4e. Generating a single tag of a HTML table
12747 !! wikitext
12748 <table><tr><td>foo</td>{{echo|</tr>}}</table>
12749 !! html
12750 <table><tr><td>foo</td></tr></table>
12751
12752 !!end
12753
12754 !!test
12755 Templates: HTML Tables: 4f. Generating a single tag of a HTML table
12756 !! wikitext
12757 <table><tr><td>foo</td></tr>{{echo|</table>}}
12758 !! html
12759 <table><tr><td>foo</td></tr></table>
12760
12761 !!end
12762
12763 !!test
12764 Templates: HTML Tables: 5. Proper fostering of categories from inside
12765 !!options
12766 parsoid=wt2html,wt2wt
12767 !! wikitext
12768 <table>[[Category:foo1]]<tr><td>foo</td></tr></table>
12769 <!--Two categories (T52330)-->
12770 <table>[[Category:bar1]][[Category:bar2]]<tr><td>foo</td></tr></table>
12771 !! html
12772 <link rel="mw:PageProp/Category" href="./Category:Foo1"><table><tbody><tr><td>foo</td></tr></tbody></table>
12773 <!--Two categories (T52330)-->
12774 <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>
12775 !!end
12776
12777 !!test
12778 Templates: Wiki Tables: 1a. Fostering of entire template content
12779 !! wikitext
12780 {|
12781 {{echo|a}}
12782 |}
12783 !! html
12784 <table>
12785 a
12786 <tr><td></td></tr></table>
12787
12788 !! html+tidy
12789 <p>a</p>
12790 <table>
12791 <tr>
12792 <td></td>
12793 </tr>
12794 </table>
12795 !! end
12796
12797 !!test
12798 Templates: Wiki Tables: 1b. Fostering of entire template content
12799 !! wikitext
12800 {|
12801 {{echo|<div>}}
12802 foo
12803 {{echo|</div>}}
12804 |}
12805 !! html
12806 <table>
12807 <div>
12808 <p>foo
12809 </p>
12810 </div>
12811 <tr><td></td></tr></table>
12812
12813 !! html+tidy
12814 <div>
12815 <p>foo</p>
12816 </div>
12817 <table>
12818 <tr>
12819 <td></td>
12820 </tr>
12821 </table>
12822 !! end
12823
12824 !!test
12825 Templates: Wiki Tables: 2. Fostering of partial template content
12826 !! wikitext
12827 {|
12828 {{echo|a
12829 <div>b</div>}}
12830 |}
12831 !! html
12832 <table>
12833 a
12834 <div>b</div>
12835 <tr><td></td></tr></table>
12836
12837 !! html+tidy
12838 <p>a</p>
12839 <div>b</div>
12840 <table>
12841 <tr>
12842 <td></td>
12843 </tr>
12844 </table>
12845 !! end
12846
12847 !!test
12848 Templates: Wiki Tables: 3. td-content via multiple templates
12849 !! wikitext
12850 {|
12851 {{echo|{{pipe}}a}}{{echo|b}}
12852 |}
12853 !! html
12854 <table>
12855 <tr>
12856 <td>ab
12857 </td></tr></table>
12858
12859 !!end
12860
12861 !!test
12862 Templates: Wiki Tables: 4. Templated tags, no content
12863 !! wikitext
12864 {{tbl-start}}
12865 {{tbl-end}}
12866 !! html
12867 <table>
12868 <tr><td></td></tr></table>
12869
12870 !!end
12871
12872 !!test
12873 Templates: Wiki Tables: 5. Templated tags, regular td-tags
12874 !! wikitext
12875 {{tbl-start}}
12876 |foo
12877 {{tbl-end}}
12878 !! html
12879 <table>
12880 <tr>
12881 <td>foo
12882 </td></tr></table>
12883
12884 !!end
12885
12886 !!test
12887 Templates: Wiki Tables: 6. Templated tags, templated td-tags
12888 !! wikitext
12889 {{tbl-start}}
12890 {{!}}foo
12891 {{tbl-end}}
12892 !! html
12893 <table>
12894 <tr>
12895 <td>foo
12896 </td></tr></table>
12897
12898 !!end
12899
12900 ## This test case is very specific to Parsoid's internals
12901 ## and is hence only tested for Parsoid's code. Parsoid uses
12902 ## a <meta> marker tag for <ref> tags and they are expanded
12903 ## much later. We are verifying that this <meta> tag usage
12904 ## doesn't prevent foster parenting.
12905 !!test
12906 Templates: Wiki Tables: 7. Fosterable <ref>s should get fostered
12907 !!wikitext
12908 {{PartialTable}}<ref>foo</ref>
12909 |}
12910
12911 <references />
12912 !!html/parsoid
12913 <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">
12914 <tbody>
12915 </tbody></table>
12916
12917 <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>
12918 !!end
12919
12920 !! test
12921 Templates: Wiki Tables: 8. Fosterable meta-tags should get fostered
12922 !! wikitext
12923 {{echo|
12924 {{{!}}
12925 {{!}}-}}
12926 <onlyinclude>
12927 |foo
12928 </onlyinclude>
12929 {{!}}}
12930 !! html/parsoid
12931 <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{{!}}}"]}'>
12932 </span><meta typeof="mw:Includes/OnlyInclude" about="#mwt1"/><table about="#mwt1">
12933 <tbody><tr>
12934
12935 <td>foo
12936 <meta typeof="mw:Includes/OnlyInclude/End"/></td></tr>
12937 </tbody></table>
12938 !! end
12939
12940 !!test
12941 Templates: Lists: Multi-line list-items via templates
12942 !! wikitext
12943 *{{echo|a {{nonexistent|
12944 unused}}}}
12945 *{{echo|b {{nonexistent|
12946 unused}}}}
12947 !! html
12948 <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>
12949 <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>
12950
12951 !!end
12952
12953 !!test
12954 Templates: Ugly nesting: 1. Quotes opened/closed across templates (echo)
12955 !! wikitext
12956 {{echo|''a}}{{echo|b''c''d}}{{echo|''e}}
12957 !! html
12958 <p><i>ab</i>c<i>d</i>e
12959 </p>
12960 !!end
12961
12962 !!test
12963 Templates: Ugly nesting: 2. Quotes opened/closed across templates (echo_with_span)
12964 (PHP parser generates misnested html)
12965 !! wikitext
12966 {{echo_with_span|''a}}{{echo_with_span|b''c''d}}{{echo_with_span|''e}}
12967 !! html/parsoid
12968 <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>
12969 !!end
12970
12971 !!test
12972 Templates: Ugly nesting: 3. Quotes opened/closed across templates (echo_with_div)
12973 (PHP parser generates misnested html; Parsoid html2wt mode adds newlines between {{echo}}s)
12974 !! options
12975 parsoid=wt2html,wt2wt
12976 !! wikitext
12977 {{echo_with_div|''a}}{{echo_with_div|b''c''d}}{{echo_with_div|''e}}
12978 !! html
12979 <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>
12980 <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>
12981 <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>
12982 !!end
12983
12984 !!test
12985 Templates: Ugly nesting: 4. Divs opened/closed across templates
12986 !! wikitext
12987 a<div>b{{echo|c</div>d}}e
12988 !! html
12989 a<div>bc</div>de
12990
12991 !! html+tidy
12992 <p>a</p>
12993 <div>bc</div>
12994 <p>de</p>
12995 !! end
12996
12997 !!test
12998 Templates: Ugly templates: 1. Navbox template parses badly leading to table misnesting
12999 (Parsoid-centric)
13000 !! options
13001 parsoid
13002 !! wikitext
13003 {|
13004 |{{echo|foo</table>}}
13005 |bar
13006 |}
13007 !! html
13008 <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|}"]}'>
13009
13010 <tbody>
13011 <tr>
13012 <td>foo</td></tr></tbody></table><span about="#mwt1">
13013 </span><span about="#mwt1">|bar</span><span about="#mwt1">
13014 |}</span>
13015 !!end
13016
13017 !!test
13018 Templates: Ugly templates: 2. Navbox template parses badly leading to table misnesting
13019 (Parsoid-centric)
13020 !! options
13021 parsoid
13022 !! wikitext
13023 <table>
13024 <tr>
13025 <td>
13026 <table>
13027 <tr>
13028 <td>1. {{echo|foo </table>}}</td>
13029 <td> bar </td>
13030 <td>2. {{echo|baz </table>}}</td>
13031 </tr>
13032 <tr>
13033 <td>abc</td>
13034 </tr>
13035 </table>
13036 </td>
13037 </tr>
13038 <tr>
13039 <td>xyz</td>
13040 </tr>
13041 </table>
13042 !! html
13043 <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>"]}'>
13044 <tbody><tr>
13045 <td>
13046 <table>
13047 <tbody><tr>
13048 <td>1. foo </td></tr></tbody></table></td>
13049 <td> bar </td>
13050 <td>2. baz </td></tr></tbody></table><span about="#mwt2">
13051 </span><span about="#mwt2">
13052 </span><span about="#mwt2">
13053 </span><span about="#mwt2">abc</span><span about="#mwt2">
13054 </span><span about="#mwt2">
13055 </span><span about="#mwt2">
13056 </span><span about="#mwt2">
13057 </span><span about="#mwt2">
13058 </span><span about="#mwt2">
13059 </span><span about="#mwt2">xyz</span><span about="#mwt2">
13060 </span><span about="#mwt2">
13061 </span>
13062 !!end
13063
13064 !! test
13065 Templates: Ugly templates: 3. newline-only template parameter
13066 !! wikitext
13067 foo {{echo|
13068 }}
13069 !! html
13070 <p>foo
13071 </p>
13072 !! end
13073
13074 # This looks like a bug: a single newline triggers p/br for some reason.
13075 !! test
13076 Templates: Ugly templates: 4. newline-only template parameter inconsistency
13077 !! wikitext
13078 {{echo|
13079 }}
13080 !! html
13081 <p><br />
13082 </p>
13083 !! end
13084
13085 # T66017 -- ugly wikitext with fostered content generates two template ranges that
13086 # have a true overlap (T1-start - T2-start - T1-end - T2-end).
13087 !! test
13088 Templates: Ugly templates: 5. Template encapsulation test: Non-trivial overlap of template ranges is properly handled
13089 !! wikitext
13090 {{echo|<table>}}
13091 {{echo|<div>foo}}
13092 {{echo|</table>}}
13093 !! html/parsoid
13094 <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
13095 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13096 </table>
13097 !! end
13098
13099 # T66017 -- ugly wikitext with fostered content generates two template ranges
13100 # that are "identical" and generate nesting cycles in the algorithm
13101 !! test
13102 Templates: Ugly templates: 6. Template encapsulation test: Cyclical nesting of template ranges is properly handled
13103 !! wikitext
13104 {{echo|<table><tr><td><table>}}
13105 {{echo|<div>}}
13106 {{echo|</div>}}
13107 !! html/parsoid
13108 <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"}'>
13109 </div><table about="#mwt1" data-parsoid='{"stx":"html"}'>
13110 </table></td></tr></tbody></table>
13111 !! end
13112
13113 !! test
13114 Templates: Parameters substituted at the top-level
13115 !! wikitext
13116 {{{foo|''who'' {{echo|me}}? '''never!'''}}}
13117
13118 {{{foo|bar|baz}}}
13119 !! html/php
13120 <p><i>who</i> me? <b>never!</b>
13121 </p><p>bar
13122 </p>
13123 !! html/parsoid
13124 <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>
13125
13126 <p about="#mwt3" typeof="mw:Param" data-mw='{"parts":[{"templatearg":{"target":{"wt":"foo"},"params":{"1":{"wt":"bar"},"2":{"wt":"baz"}},"i":0}}]}'>bar</p>
13127 !! end
13128
13129 !!test
13130 Parser Functions: 1. Simple example
13131 !! wikitext
13132 {{uc:foo}}
13133 !! html
13134 <p>FOO
13135 </p>
13136 !!end
13137
13138 !!test
13139 Parser Functions: 2. Nested use (only outermost should be marked up)
13140 !! wikitext
13141 {{uc:{{lc:FOO}}}}
13142 !! html
13143 <p>FOO
13144 </p>
13145 !!end
13146
13147 ###
13148 ### Pre-save transform tests
13149 ###
13150 !! test
13151 pre-save transform: subst:
13152 !! options
13153 pst
13154 !! wikitext
13155 {{subst:test}}
13156 !! html/php
13157 This is a test template
13158 !! end
13159
13160 !! test
13161 pre-save transform: normal template
13162 !! options
13163 pst
13164 !! wikitext
13165 {{test}}
13166 !! html/php
13167 {{test}}
13168 !! end
13169
13170 !! test
13171 pre-save transform: nonexistent template
13172 !! options
13173 pst
13174 !! wikitext
13175 {{thistemplatedoesnotexist}}
13176 !! html/php
13177 {{thistemplatedoesnotexist}}
13178 !! end
13179
13180 !! test
13181 pre-save transform: subst magic variables
13182 !! options
13183 pst
13184 !! wikitext
13185 {{subst:SITENAME}}
13186 !! html/php
13187 MediaWiki
13188 !! end
13189
13190 # This is T2089, which I fixed. -- wtm
13191 !! test
13192 pre-save transform: subst: templates with parameters
13193 !! options
13194 pst
13195 !! wikitext
13196 {{subst:paramtest|param="something else"}}
13197 !! html/php
13198 This is a test template with parameter "something else"
13199 !! end
13200
13201 !! article
13202 Template:nowikitest
13203 !! text
13204 <nowiki>'''not wiki'''</nowiki>
13205 !! endarticle
13206
13207 !! test
13208 pre-save transform: nowiki in subst (T3188)
13209 !! options
13210 pst
13211 !! wikitext
13212 {{subst:nowikitest}}
13213 !! html/php
13214 <nowiki>'''not wiki'''</nowiki>
13215 !! end
13216
13217 !! article
13218 Template:commenttest
13219 !! text
13220 This template has <!-- a comment --> in it.
13221 !! endarticle
13222
13223 !! test
13224 pre-save transform: comment in subst (T3936)
13225 !! options
13226 pst
13227 !! wikitext
13228 {{subst:commenttest}}
13229 !! html/php
13230 This template has <!-- a comment --> in it.
13231 !! end
13232
13233 !! test
13234 pre-save transform: unclosed tag
13235 !! options
13236 pst
13237 !! wikitext
13238 <nowiki>'''not wiki'''
13239 !! html/php
13240 <nowiki>'''not wiki'''
13241 !! end
13242
13243 !! test
13244 pre-save transform: mixed tag case
13245 !! options
13246 pst
13247 !! wikitext
13248 <NOwiki>'''not wiki'''</noWIKI>
13249 !! html/php
13250 <NOwiki>'''not wiki'''</noWIKI>
13251 !! end
13252
13253 !! test
13254 pre-save transform: unclosed comment in <nowiki>
13255 !! options
13256 pst
13257 !! wikitext
13258 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13259 !! html/php
13260 wiki<nowiki>nowiki<!--nowiki</nowiki>wiki
13261 !!end
13262
13263 # Leading @ in this template definition works around a limitation
13264 # in parsoid's parserTests which otherwise strips the <span> from the
13265 # result (confusing it for a template wrapper)
13266 !! article
13267 Template:dangerous
13268 !!text
13269 @<span onmouseover="alert('crap')">Oh no</span>
13270 !!endarticle
13271
13272 !!test
13273 (confirming safety of fix for subst T3936)
13274 !! wikitext
13275 {{Template:dangerous}}
13276 !! html
13277 <p>@<span>Oh no</span>
13278 </p>
13279 !! end
13280
13281 !! test
13282 pre-save transform: comment containing gallery (T7024)
13283 !! options
13284 pst
13285 !! wikitext
13286 <!-- <gallery>data</gallery> -->
13287 !! html/php
13288 <!-- <gallery>data</gallery> -->
13289 !!end
13290
13291 !! test
13292 pre-save transform: comment containing extension
13293 !! options
13294 pst
13295 !! wikitext
13296 <!-- <tag>data</tag> -->
13297 !! html/php
13298 <!-- <tag>data</tag> -->
13299 !!end
13300
13301 !! test
13302 pre-save transform: comment containing nowiki
13303 !! options
13304 pst
13305 !! wikitext
13306 <!-- <nowiki>data</nowiki> -->
13307 !! html/php
13308 <!-- <nowiki>data</nowiki> -->
13309 !!end
13310
13311 !! test
13312 pre-save transform: <noinclude> in subst (T5298)
13313 !! options
13314 pst
13315 !! wikitext
13316 {{subst:Includes}}
13317 !! html/php
13318 Foobar
13319 !! end
13320
13321 !! test
13322 pre-save transform: <onlyinclude> in subst (T5298)
13323 !! options
13324 pst
13325 !! wikitext
13326 {{subst:Includes2}}
13327 !! html/php
13328 Foo
13329 !! end
13330
13331 !! article
13332 Template:SubstTest
13333 !!text
13334 {{<includeonly>subst:</includeonly>Includes}}
13335 !! endarticle
13336
13337 !! article
13338 Template:SafeSubstTest
13339 !! text
13340 {{<includeonly>safesubst:</includeonly>Includes}}
13341 !! endarticle
13342
13343 !! test
13344 T24297: safesubst: works during PST
13345 !! options
13346 pst
13347 !! wikitext
13348 {{subst:SafeSubstTest}}{{safesubst:SubstTest}}
13349 !! html/php
13350 FoobarFoobar
13351 !! end
13352
13353 !! test
13354 T24297: safesubst: works during normal parse
13355 !! wikitext
13356 {{SafeSubstTest}}
13357 !! html
13358 <p>Foobar
13359 </p>
13360 !! end
13361
13362 !! test
13363 subst: does not work during normal parse
13364 !! wikitext
13365 {{SubstTest}}
13366 !! html
13367 <p>{{subst:Includes}}
13368 </p>
13369 !! end
13370
13371 !! test
13372 pre-save transform: context links ("pipe trick")
13373 !! options
13374 pst
13375 !! wikitext
13376 [[Article (context)|]]
13377 [[Bar:Article|]]
13378 [[:Bar:Article|]]
13379 [[Bar:Article (context)|]]
13380 [[:Bar:Article (context)|]]
13381 [[|Article]]
13382 [[|Article (context)]]
13383 [[Bar:X (Y) Z|]]
13384 [[:Bar:X (Y) Z|]]
13385 !! html/php
13386 [[Article (context)|Article]]
13387 [[Bar:Article|Article]]
13388 [[:Bar:Article|Article]]
13389 [[Bar:Article (context)|Article]]
13390 [[:Bar:Article (context)|Article]]
13391 [[Article]]
13392 [[Article (context)]]
13393 [[Bar:X (Y) Z|X (Y) Z]]
13394 [[:Bar:X (Y) Z|X (Y) Z]]
13395 !! end
13396
13397 !! test
13398 pre-save transform: context links ("pipe trick") with interwiki prefix
13399 !! options
13400 pst
13401 !! wikitext
13402 [[interwiki:Article|]]
13403 [[:interwiki:Article|]]
13404 [[interwiki:Bar:Article|]]
13405 [[:interwiki:Bar:Article|]]
13406 !! html/php
13407 [[interwiki:Article|Article]]
13408 [[:interwiki:Article|Article]]
13409 [[interwiki:Bar:Article|Bar:Article]]
13410 [[:interwiki:Bar:Article|Bar:Article]]
13411 !! end
13412
13413 !! test
13414 pre-save transform: context links ("pipe trick") with parens in title
13415 !! options
13416 pst title=[[Somearticle (context)]]
13417 !! wikitext
13418 [[|Article]]
13419 !! html/php
13420 [[Article (context)|Article]]
13421 !! end
13422
13423 !! test
13424 pre-save transform: context links ("pipe trick") with comma in title
13425 !! options
13426 pst title=[[Someplace, Somewhere]]
13427 !! wikitext
13428 [[|Otherplace]]
13429 [[Otherplace, Elsewhere|]]
13430 [[Otherplace, Elsewhere, Anywhere|]]
13431 !! html/php
13432 [[Otherplace, Somewhere|Otherplace]]
13433 [[Otherplace, Elsewhere|Otherplace]]
13434 [[Otherplace, Elsewhere, Anywhere|Otherplace]]
13435 !! end
13436
13437 !! test
13438 pre-save transform: context links ("pipe trick") with parens and comma
13439 !! options
13440 pst title=[[Someplace (IGNORED), Somewhere]]
13441 !! wikitext
13442 [[|Otherplace]]
13443 [[Otherplace (place), Elsewhere|]]
13444 !! html/php
13445 [[Otherplace, Somewhere|Otherplace]]
13446 [[Otherplace (place), Elsewhere|Otherplace]]
13447 !! end
13448
13449 !! test
13450 pre-save transform: context links ("pipe trick") with comma and parens
13451 !! options
13452 pst title=[[Who, me? (context)]]
13453 !! wikitext
13454 [[|Yes, you.]]
13455 [[Me, Myself, and I (1937 song)|]]
13456 !! html/php
13457 [[Yes, you. (context)|Yes, you.]]
13458 [[Me, Myself, and I (1937 song)|Me, Myself, and I]]
13459 !! end
13460
13461 !! test
13462 pre-save transform: context links ("pipe trick") with namespace
13463 !! options
13464 pst title=[[Ns:Somearticle]]
13465 !! wikitext
13466 [[|Article]]
13467 !! html/php
13468 [[Ns:Article|Article]]
13469 !! end
13470
13471 !! test
13472 pre-save transform: context links ("pipe trick") with namespace and parens
13473 !! options
13474 pst title=[[Ns:Somearticle (context)]]
13475 !! wikitext
13476 [[|Article]]
13477 !! html/php
13478 [[Ns:Article (context)|Article]]
13479 !! end
13480
13481 !! test
13482 pre-save transform: context links ("pipe trick") with namespace and comma
13483 !! options
13484 pst title=[[Ns:Somearticle, Context, Whatever]]
13485 !! wikitext
13486 [[|Article]]
13487 !! html/php
13488 [[Ns:Article, Context, Whatever|Article]]
13489 !! end
13490
13491 !! test
13492 pre-save transform: context links ("pipe trick") with namespace, comma and parens
13493 !! options
13494 pst title=[[Ns:Somearticle, Context (context)]]
13495 !! wikitext
13496 [[|Article]]
13497 !! html/php
13498 [[Ns:Article (context)|Article]]
13499 !! end
13500
13501 !! test
13502 pre-save transform: context links ("pipe trick") with namespace, parens and comma
13503 !! options
13504 pst title=[[Ns:Somearticle (IGNORED), Context]]
13505 !! wikitext
13506 [[|Article]]
13507 !! html/php
13508 [[Ns:Article, Context|Article]]
13509 !! end
13510
13511 !! test
13512 pre-save transform: context links ("pipe trick") with full-width parens and no space (Japanese and Chinese style, T32149)
13513 !! options
13514 pst
13515 !! wikitext
13516 [[Article(context)|]]
13517 [[Bar:Article(context)|]]
13518 [[:Bar:Article(context)|]]
13519 [[|Article(context)]]
13520 [[Bar:X(Y)Z|]]
13521 [[:Bar:X(Y)Z|]]
13522 !! html/php
13523 [[Article(context)|Article]]
13524 [[Bar:Article(context)|Article]]
13525 [[:Bar:Article(context)|Article]]
13526 [[Article(context)]]
13527 [[Bar:X(Y)Z|X(Y)Z]]
13528 [[:Bar:X(Y)Z|X(Y)Z]]
13529 !! end
13530
13531 !! test
13532 pre-save transform: context links ("pipe trick") with full-width parens and space (Japanese and Chinese style, T32149)
13533 !! options
13534 pst
13535 !! wikitext
13536 [[Article (context)|]]
13537 [[Bar:Article (context)|]]
13538 [[:Bar:Article (context)|]]
13539 [[|Article (context)]]
13540 [[Bar:X (Y) Z|]]
13541 [[:Bar:X (Y) Z|]]
13542 !! html/php
13543 [[Article (context)|Article]]
13544 [[Bar:Article (context)|Article]]
13545 [[:Bar:Article (context)|Article]]
13546 [[Article (context)]]
13547 [[Bar:X (Y) Z|X (Y) Z]]
13548 [[:Bar:X (Y) Z|X (Y) Z]]
13549 !! end
13550
13551 !! test
13552 pre-save transform: context links ("pipe trick") with parens and no space (Korean style, T32149)
13553 !! options
13554 pst
13555 !! wikitext
13556 [[Article(context)|]]
13557 [[Bar:Article(context)|]]
13558 [[:Bar:Article(context)|]]
13559 [[|Article(context)]]
13560 [[Bar:X(Y)Z|]]
13561 [[:Bar:X(Y)Z|]]
13562 !! html/php
13563 [[Article(context)|Article]]
13564 [[Bar:Article(context)|Article]]
13565 [[:Bar:Article(context)|Article]]
13566 [[Article(context)]]
13567 [[Bar:X(Y)Z|X(Y)Z]]
13568 [[:Bar:X(Y)Z|X(Y)Z]]
13569 !! end
13570
13571 !! test
13572 pre-save transform: context links ("pipe trick") with commas (T23660)
13573 !! options
13574 pst
13575 !! wikitext
13576 [[Article (context), context|]]
13577 [[Article (context),context|]]
13578 [[Bar:Article (context), context|]]
13579 [[Bar:Article (context),context|]]
13580 [[:Bar:Article (context), context|]]
13581 [[:Bar:Article (context),context|]]
13582 !! html/php
13583 [[Article (context), context|Article]]
13584 [[Article (context),context|Article]]
13585 [[Bar:Article (context), context|Article]]
13586 [[Bar:Article (context),context|Article]]
13587 [[:Bar:Article (context), context|Article]]
13588 [[:Bar:Article (context),context|Article]]
13589 !! end
13590
13591 !! test
13592 Parsoid: backwards pipe trick
13593 !! wikitext
13594 [[|'''bar''']]
13595 !! html/php
13596 <p>[[|<b>bar</b>]]
13597 </p>
13598 !! html/parsoid
13599 <p>[[|<b>bar</b>]]</p>
13600 !! end
13601
13602 !! test
13603 pre-save transform: trim trailing empty lines
13604 !! options
13605 pst
13606 !! wikitext
13607 Empty lines are trimmed
13608
13609
13610
13611
13612 !! html/php
13613 Empty lines are trimmed
13614 !! end
13615
13616 !! test
13617 pre-save transform: Signature expansion
13618 !! options
13619 pst
13620 !! wikitext
13621 * ~~~
13622 * ~~~~
13623 * ~~~~~
13624 * <noinclude>~~~</noinclude>
13625 * <includeonly>~~~</includeonly>
13626 * <onlyinclude>~~~</onlyinclude>
13627 !! html/php
13628 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
13629 * [[Special:Contributions/127.0.0.1|127.0.0.1]] 00:02, 1 January 1970 (UTC)
13630 * 00:02, 1 January 1970 (UTC)
13631 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
13632 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
13633 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
13634 !! end
13635
13636
13637 !! test
13638 pre-save transform: Signature expansion in nowiki tags (T2093)
13639 !! options
13640 pst disabled
13641 !! wikitext
13642 Shall not expand:
13643
13644 <nowiki>~~~~</nowiki>
13645
13646 <includeonly><nowiki>~~~~</nowiki></includeonly>
13647
13648 <noinclude><nowiki>~~~~</nowiki></noinclude>
13649
13650 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13651
13652 {{subst:Foo}} shall be converted to FOO
13653
13654 As well as inside noinclude/onlyinclude
13655 <noinclude>{{subst:Foo}}</noinclude>
13656 <onlyinclude>{{subst:Foo}}</onlyinclude>
13657
13658 But not inside includeonly
13659 <includeonly>{{subst:Foo}}</includeonly>
13660 !! html/php
13661 Shall not expand:
13662
13663 <nowiki>~~~~</nowiki>
13664
13665 <includeonly><nowiki>~~~~</nowiki></includeonly>
13666
13667 <noinclude><nowiki>~~~~</nowiki></noinclude>
13668
13669 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13670
13671 FOO shall be converted to FOO
13672
13673 As well as inside noinclude/onlyinclude
13674 <noinclude>FOO</noinclude>
13675 <onlyinclude>FOO</onlyinclude>
13676
13677 But not inside includeonly
13678 <includeonly>{{subst:Foo}}</includeonly>
13679 !! end
13680
13681 !! test
13682 Parsoid: Recognize nowiki with trailing space in tags
13683 !! options
13684 parsoid=wt2html
13685 !! wikitext
13686 <nowiki ><div>[[foo]]</nowiki >
13687
13688 a<nowiki / >b
13689
13690 c<nowiki />d
13691
13692 e<nowiki/ >f
13693 !! html
13694 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
13695 <p>ab</p>
13696 <p>cd</p>
13697 <p>ef</p>
13698 !! end
13699
13700 !! test
13701 Parsoid: Recognize nowiki with odd capitalization
13702 !! options
13703 parsoid=wt2html
13704 !! wikitext
13705 <noWikI ><div>[[foo]]</Nowiki >
13706 !! html
13707 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
13708 !! end
13709
13710
13711 !! test
13712 Parsoid: Escape nowiki with trailing space in tags
13713 !! options
13714 parsoid=html2wt
13715 !! html/parsoid
13716 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
13717 <p>a&lt;nowiki /&gt;b</p>
13718 <p>c&lt;nowiki/ &gt;d</p>
13719 !! wikitext
13720 &lt;nowiki &gt; foo &lt;/nowiki &gt;
13721
13722 a&lt;nowiki /&gt;b
13723
13724 c&lt;nowiki/ &gt;d
13725 !! end
13726
13727 !! test
13728 Parsoid: Escape weird noWikI capitalizations
13729 !! options
13730 parsoid=html2wt
13731 !! html/parsoid
13732 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
13733 !! wikitext
13734 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
13735 !! end
13736
13737 ###
13738 ### Message transform tests
13739 ###
13740 !! test
13741 message transform: magic variables
13742 !! options
13743 msg
13744 !! wikitext
13745 {{SITENAME}}
13746 !! html
13747 MediaWiki
13748 !! end
13749
13750 !! test
13751 message transform: should not transform wiki markup
13752 !! options
13753 msg
13754 !! wikitext
13755 ''test''
13756 !! html
13757 ''test''
13758 !! end
13759
13760 !! test
13761 message transform: <noinclude> in transcluded template (T6926)
13762 !! options
13763 msg
13764 !! wikitext
13765 {{Includes}}
13766 !! html
13767 Foobar
13768 !! end
13769
13770 !! test
13771 message transform: <onlyinclude> in transcluded template (T6926)
13772 !! options
13773 msg
13774 !! wikitext
13775 {{Includes2}}
13776 !! html
13777 Foo
13778 !! end
13779
13780 !! test
13781 {{#special:}} page name, known
13782 !! options
13783 msg
13784 !! wikitext
13785 {{#special:Recentchanges}}
13786 !! html
13787 Special:RecentChanges
13788 !! end
13789
13790 !! test
13791 {{#special:}} page name with subpage, known
13792 !! options
13793 msg
13794 !! wikitext
13795 {{#special:Recentchanges/param}}
13796 !! html
13797 Special:RecentChanges/param
13798 !! end
13799
13800 !! test
13801 {{#special:}} page name, unknown
13802 !! options
13803 msg
13804 !! wikitext
13805 {{#special:foobar nonexistent}}
13806 !! html
13807 Special:Foobar nonexistent
13808 !! end
13809
13810 !! test
13811 {{#speciale:}} page name, known
13812 !! options
13813 msg
13814 !! wikitext
13815 {{#speciale:Recentchanges}}
13816 !! html
13817 Special:RecentChanges
13818 !! end
13819
13820 !! test
13821 {{#speciale:}} page name with subpage, known
13822 !! options
13823 msg
13824 !! wikitext
13825 {{#speciale:Recentchanges/param}}
13826 !! html
13827 Special:RecentChanges/param
13828 !! end
13829
13830 !! test
13831 {{#speciale:}} page name, unknown
13832 !! options
13833 msg
13834 !! wikitext
13835 {{#speciale:foobar nonexistent}}
13836 !! html
13837 Special:Foobar_nonexistent
13838 !! end
13839
13840 ###
13841 ### Images
13842 ###
13843 ### For Parsoid-specific tests, see
13844 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
13845
13846 !! test
13847 Simple image
13848 !! options
13849 parsoid=wt2html,wt2wt,html2html
13850 !! wikitext
13851 [[Image:foobar.jpg]]
13852 !! html/php
13853 <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>
13854 </p>
13855 !! html/parsoid
13856 <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>
13857 !! end
13858
13859 !! test
13860 Simple image (using File: namespace, now canonical)
13861 !! wikitext
13862 [[File:Foobar.jpg]]
13863 !! html/php
13864 <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>
13865 </p>
13866 !! html/parsoid
13867 <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>
13868 !! end
13869
13870 !! test
13871 Right-aligned image
13872 !! wikitext
13873 [[File:Foobar.jpg|right]]
13874 !! html/php
13875 <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>
13876
13877 !! html/parsoid
13878 <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>
13879 !! end
13880
13881 !! test
13882 Image with caption
13883 !! wikitext
13884 [[File:Foobar.jpg|right|Caption text]]
13885 !! html/php
13886 <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>
13887
13888 !! html/parsoid
13889 <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>
13890 !! end
13891
13892 !! test
13893 Image with caption, T55312 #1
13894 !! wikitext
13895 [[File:Foobar.jpg|right|Caption page stuff]]
13896 !! html/php
13897 <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>
13898
13899 !! html/parsoid
13900 <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>
13901 !! end
13902
13903 !! test
13904 Image with caption, T55312 #2
13905 !! wikitext
13906 [[File:Foobar.jpg|right|Caption page=]]
13907 !! html/php
13908 <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>
13909
13910 !! html/parsoid
13911 <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>
13912 !! end
13913
13914 !! test
13915 Image with caption, T55312 #3
13916 !! wikitext
13917 [[File:Foobar.jpg|right|Caption page=stuff]]
13918 !! html/php
13919 <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>
13920
13921 !! html/parsoid
13922 <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>
13923 !! end
13924
13925 !! test
13926 Allow empty links in image captions (T62753)
13927 !! options
13928 thumbsize=220
13929 !! wikitext
13930 [[File:Foobar.jpg|thumb|Caption [[Link1]]
13931 [[]]
13932 [[Link2]]
13933 ]]
13934 !! html/php
13935 <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>
13936
13937 !! html/parsoid
13938 <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>
13939 [[]]
13940 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
13941 </figcaption></figure>
13942 !! end
13943
13944 !! test
13945 Titles in unlinked images (T23454)
13946 !! wikitext
13947 [[File:Foobar.jpg|link=|stuff]]
13948 !! html/php
13949 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
13950 </p>
13951 !! end
13952
13953 !! test
13954 Link with empty target
13955 !! wikitext
13956 [[]]
13957 !! html
13958 <p>[[]]
13959 </p>
13960 !! end
13961
13962 !! test
13963 Image with link trail
13964 !! wikitext
13965 Linktrails should not work for images: [[File:Foobar.jpg]]s
13966 !! html/php
13967 <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
13968 </p>
13969 !! html/parsoid
13970 <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>
13971 !! end
13972
13973 !! test
13974 Image with empty attribute
13975 !! options
13976 parsoid=wt2html,wt2wt,html2html
13977 !! wikitext
13978 [[File:Foobar.jpg|right||Caption text]]
13979 !! html/php
13980 <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>
13981
13982 !! html/parsoid
13983 <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>
13984 !! end
13985
13986 !! test
13987 1. Block image with individual attributes from templates
13988 !! wikitext
13989 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
13990 !! html/php
13991 <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>
13992
13993 !! html/parsoid
13994 <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>
13995 !! end
13996
13997 !! test
13998 2. Block Image with individual attributes from templates
13999 !! wikitext
14000 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
14001 !! html/php
14002 <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>
14003
14004 !! html/parsoid
14005 <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>
14006 !! end
14007
14008 !! test
14009 3. Inline image with individual attributes from templates
14010 !! wikitext
14011 [[File:Foobar.jpg|{{echo|50px}}]]
14012 !! html/php
14013 <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>
14014 </p>
14015 !! html/parsoid
14016 <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>
14017 !! end
14018
14019 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14020 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14021 !! test
14022 Image with multiple attributes from the same template
14023 !! wikitext
14024 [[File:Foobar.jpg|{{image_attribs}}]]
14025 !! html/php
14026 <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>
14027
14028 !! html/parsoid
14029 <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>
14030 !! end
14031
14032 !! test
14033 Image with link tails
14034 !! options
14035 thumbsize=220
14036 !! wikitext
14037 123[[File:Foobar.jpg]]456
14038 123[[File:Foobar.jpg|right]]456
14039 123[[File:Foobar.jpg|thumb]]456
14040 !! html/php
14041 <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
14042 </p>
14043 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
14044 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
14045
14046 !! html/php+tidy
14047 <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>
14048 <p>123</p>
14049 <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>
14050 <p>456 123</p>
14051 <div class="thumb tright">
14052 <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>
14053 <div class="thumbcaption">
14054 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
14055 </div>
14056 </div>
14057 </div>
14058 <p>456</p>
14059 !! html/parsoid
14060 <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>
14061 <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>
14062 <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>
14063 !! end
14064
14065 !! test
14066 Image with multiple captions -- only last one is accepted
14067 !! wikitext
14068 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14069 !! html/php
14070 <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>
14071
14072 !! html/parsoid
14073 <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>
14074 !! end
14075
14076 !! test
14077 Image with multiple widths -- use last
14078 !! wikitext
14079 [[File:Foobar.jpg|200px|300px|caption]]
14080 !! html/php
14081 <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>
14082 </p>
14083 !! html/parsoid
14084 <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>
14085 !! end
14086
14087 !! test
14088 Image with multiple alignments -- use first (T50664)
14089 !! options
14090 thumbsize=220
14091 !! wikitext
14092 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14093
14094 [[File:Foobar.jpg|middle|text-top|caption]]
14095 !! html/php
14096 <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>
14097 <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>
14098 </p>
14099 !! html/parsoid
14100 <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>
14101 <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>
14102 !! end
14103
14104 !! test
14105 Image with width attribute at different positions
14106 !! wikitext
14107 [[File:Foobar.jpg|200px|right|Caption]]
14108 [[File:Foobar.jpg|right|200px|Caption]]
14109 [[File:Foobar.jpg|right|Caption|200px]]
14110 !! html/php
14111 <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>
14112 <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>
14113 <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>
14114
14115 !! html/parsoid
14116 <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>
14117 <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>
14118 <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>
14119 !! end
14120
14121 # a sad bit of backward-compatibility
14122 !! test
14123 Image with size specified with pxpx (T15500, T53628)
14124 !! options
14125 parsoid=wt2html,wt2wt,html2html
14126 !! wikitext
14127 [[File:Foobar.jpg|20pxpx]]
14128 [[File:Foobar.jpg|200x20pxpx]]
14129 !! html/php
14130 <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>
14131 <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>
14132 </p>
14133 !! html/parsoid
14134 <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>
14135 !! end
14136
14137 !! test
14138 Image with link parameter, wiki target
14139 !! wikitext
14140 [[File:Foobar.jpg|link=Main Page]]
14141 !! html/php
14142 <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>
14143 </p>
14144 !! html/parsoid
14145 <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>
14146 !! end
14147
14148 # parsoid T51293 (part 1)
14149 !! test
14150 Image with link parameter, URL target
14151 !! wikitext
14152 [[File:Foobar.jpg|link=http://example.com/]]
14153 !! html/php
14154 <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>
14155 </p>
14156 !! html/parsoid
14157 <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>
14158 !! end
14159
14160 # parsoid T51293 (part 2)
14161 !! test
14162 Image with link parameter, protocol-less URL target
14163 !! wikitext
14164 [[File:Foobar.jpg|link=//example.com/]]
14165 !! html/php
14166 <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>
14167 </p>
14168 !! html/parsoid
14169 <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>
14170 !! end
14171
14172 !! test
14173 Escaping non-block captions (T107435)
14174 !! options
14175 parsoid={
14176 "modes": ["wt2wt"],
14177 "changes": [
14178 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14179 ]
14180 }
14181 !! wikitext
14182 [[Image:Foobar.jpg|caption]]
14183 !! wikitext/edited
14184 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14185 !! end
14186
14187 # wgExternalLinkTarget not supported by Parsoid
14188 !! test
14189 Image with link parameter, wgExternalLinkTarget
14190 !! wikitext
14191 [[Image:foobar.jpg|link=http://example.com/]]
14192 !! config
14193 wgExternalLinkTarget='foobar'
14194 !! html/php
14195 <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>
14196 </p>
14197 !! end
14198
14199 !! test
14200 Image with link parameter, wgNoFollowLinks set to false
14201 !! wikitext
14202 [[Image:foobar.jpg|link=http://example.com/]]
14203 !! config
14204 wgNoFollowLinks=false
14205 !! html
14206 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14207 </p>
14208 !! end
14209
14210 !! test
14211 Image with link parameter, wgNoFollowDomainExceptions
14212 !! wikitext
14213 [[Image:foobar.jpg|link=http://example.com/]]
14214 !! config
14215 wgNoFollowDomainExceptions='example.com'
14216 !! html
14217 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14218 </p>
14219 !! end
14220
14221 # wgExternalLinkTarget not supported by Parsoid
14222 !! test
14223 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14224 !! wikitext
14225 [[Image:foobar.jpg|link=http://example.com/|Title]]
14226 !! config
14227 wgExternalLinkTarget='foobar'
14228 !! html/php
14229 <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>
14230 </p>
14231 !! end
14232
14233 !! test
14234 Image with empty link parameter
14235 !! wikitext
14236 [[File:Foobar.jpg|link=]]
14237 !! html/php
14238 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14239 </p>
14240 !! html/parsoid
14241 <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>
14242 !! end
14243
14244 !! test
14245 Image with link parameter (wiki target) and unnamed parameter
14246 !! wikitext
14247 [[File:Foobar.jpg|link=Main_Page|Title]]
14248 !! html/php
14249 <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>
14250 </p>
14251 !! html/parsoid
14252 <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>
14253 !! end
14254
14255 !! test
14256 Image with link parameter (URL target) and unnamed parameter
14257 !! wikitext
14258 [[File:Foobar.jpg|link=http://example.com/|Title]]
14259 !! html/php
14260 <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>
14261 </p>
14262 !! html/parsoid
14263 <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>
14264 !! end
14265
14266 !! test
14267 Thumbnail image with link parameter
14268 !! options
14269 thumbsize=220
14270 parsoid=wt2html,wt2wt,html2html
14271 !! wikitext
14272 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14273 !! html/php
14274 <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>
14275
14276 !! html/parsoid
14277 <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>
14278 !! end
14279
14280 !! test
14281 Manually-specified thumbnail image
14282 !! options
14283 thumbsize=220
14284 !! wikitext
14285 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14286 !! html/php
14287 <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>
14288
14289 !! html/parsoid
14290 <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>
14291 !! end
14292
14293 !! test
14294 Manually-specified thumbnail image with explicit link to wiki page
14295 !! options
14296 thumbsize=220
14297 parsoid=wt2html,wt2wt,html2html
14298 !! wikitext
14299 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14300 !! html/php
14301 <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>
14302
14303 !! html/parsoid
14304 <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>
14305 !! end
14306
14307 !! test
14308 Manually-specified thumbnail image with explicit link to url
14309 !! options
14310 thumbsize=220
14311 parsoid=wt2html,wt2wt,html2html
14312 !! wikitext
14313 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14314 !! html/php
14315 <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>
14316
14317 !! html/parsoid
14318 <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>
14319 !! end
14320
14321 !! test
14322 Manually-specified thumbnail image with explicit no link
14323 !! options
14324 thumbsize=220
14325 parsoid=wt2html,wt2wt,html2html
14326 !! wikitext
14327 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14328 !! html/php
14329 <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>
14330
14331 !! html/parsoid
14332 <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>
14333 !! end
14334
14335 !! test
14336 Manually-specified thumbnail image with explicit link and alt text
14337 !! options
14338 thumbsize=220
14339 parsoid=wt2html,wt2wt,html2html
14340 !! wikitext
14341 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14342 !! html/php
14343 <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>
14344
14345 !! html/parsoid
14346 <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>
14347 !! end
14348
14349 !! test
14350 Image with frame and link
14351 !! options
14352 parsoid=wt2html,wt2wt,html2html
14353 !! wikitext
14354 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14355 !! html/php
14356 <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>
14357
14358 !! html/parsoid
14359 <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>
14360 !! end
14361
14362 !! test
14363 Image with frame and link and explicit alt
14364 !! options
14365 parsoid=wt2html,wt2wt,html2html
14366 !! wikitext
14367 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
14368 !! html/php
14369 <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>
14370
14371 !! html/parsoid
14372 <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>
14373 !! end
14374
14375 !! test
14376 Image with wiki markup in implicit alt
14377 !! wikitext
14378 [[Image:Foobar.jpg|testing '''bold''' in alt]]
14379
14380 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
14381 !! html/php
14382 <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>
14383 </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>
14384 </p>
14385 !! html/parsoid
14386 <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>
14387
14388 <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>
14389 !! end
14390
14391 !! test
14392 Alt image option should handle most kinds of wikitext without barfing
14393 !! wikitext
14394 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
14395 !! html/php
14396 <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>
14397
14398 !! html/parsoid
14399 <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>
14400 !! end
14401
14402 ###################
14403 # Conflicting image format options.
14404 # First option specified should 'win'.
14405 # All three cases in each test should be identical.
14406
14407 !! test
14408 Image with 'frameless' first.
14409 !! options
14410 parsoid=wt2html,wt2wt,html2html
14411 !! wikitext
14412 [[File:Foobar.jpg|frameless|caption]]
14413
14414 [[File:Foobar.jpg|frameless|frame|caption]]
14415
14416 [[File:Foobar.jpg|frameless|thumb|caption]]
14417 !! html/php
14418 <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>
14419 </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>
14420 </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>
14421 </p>
14422 !! html/parsoid
14423 <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>
14424 <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>
14425 <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>
14426 !! end
14427
14428 !! test
14429 Image with 'frame' first.
14430 !! options
14431 parsoid=wt2html,wt2wt,html2html
14432 !! wikitext
14433 [[File:Foobar.jpg|frame|caption]]
14434 [[File:Foobar.jpg|frame|frameless|caption]]
14435 [[File:Foobar.jpg|frame|thumb|caption]]
14436 !! html/php
14437 <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>
14438 <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>
14439 <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>
14440
14441 !! html/parsoid
14442 <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>
14443 <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>
14444 <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>
14445 !! end
14446
14447 !! test
14448 Image with 'thumb' first.
14449 !! options
14450 parsoid=wt2html,wt2wt,html2html
14451 !! wikitext
14452 [[File:Foobar.jpg|thumb|caption]]
14453 [[File:Foobar.jpg|thumb|frameless|caption]]
14454 [[File:Foobar.jpg|thumb|frame|caption]]
14455 !! html/php
14456 <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>
14457 <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>
14458 <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>
14459
14460 !! html/parsoid
14461 <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>
14462 <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>
14463 <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>
14464 !! end
14465
14466 ###################
14467 # Image sizing.
14468 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
14469 # and https://phabricator.wikimedia.org/T64258
14470 # Foobar has actual size of 1941x220
14471 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
14472 # a scalable format.
14473 # 2. Framed images always ignore size options; always render at default size.
14474 # 3. "Unspecified format" and border are the only types which can be
14475 # enlarged.
14476
14477 !! test
14478 Image: "unspecified format" and border enlarge
14479 !! options
14480 parsoid=wt2html,wt2wt,html2html
14481 !! wikitext
14482 [[File:Foobar.jpg|2000px]]
14483
14484 [[File:Foobar.jpg|border|2000px]]
14485 !! html/php
14486 <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>
14487 </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>
14488 </p>
14489 !! html/parsoid
14490 <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>
14491 <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>
14492 !! end
14493
14494 !! test
14495 Image: "unspecified format" and border reduce
14496 !! options
14497 parsoid=wt2html,wt2wt,html2html
14498 !! wikitext
14499 [[File:Foobar.jpg|1000px]]
14500
14501 [[File:Foobar.jpg|border|1000px]]
14502 !! html/php
14503 <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>
14504 </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>
14505 </p>
14506 !! html/parsoid
14507 <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>
14508 <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>
14509 !! end
14510
14511 !! test
14512 Image: thumbs reduce
14513 !! options
14514 parsoid=wt2html,wt2wt,html2html
14515 !! wikitext
14516 [[File:Foobar.jpg|thumb|50px]]
14517 !! html/php
14518 <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>
14519
14520 !! html/parsoid
14521 <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>
14522 !! end
14523
14524 !! test
14525 Image: bitmap thumbs can't be enlarged past original size, but vector can.
14526 !! options
14527 parsoid=wt2html,wt2wt,html2html
14528 !! wikitext
14529 [[File:Foobar.jpg|thumb|2000px]]
14530
14531 [[File:Foobar.svg|thumb|2000px]]
14532 !! html/php
14533 <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>
14534 <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>
14535
14536 !! html/parsoid
14537 <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>
14538 <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>
14539 !! end
14540
14541 !! test
14542 Image: frameless can reduce in size
14543 !! options
14544 parsoid=wt2html,wt2wt,html2html
14545 !! wikitext
14546 [[File:Foobar.jpg|frameless|50px]]
14547 !! html/php
14548 <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>
14549 </p>
14550 !! html/parsoid
14551 <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>
14552 !! end
14553
14554 !! test
14555 Image: bitmap frameless can't be enlarged past original size, but vector can
14556 !! options
14557 parsoid=wt2html,wt2wt,html2html
14558 !! wikitext
14559 [[File:Foobar.jpg|frameless|2000px]]
14560
14561 [[File:Foobar.svg|frameless|2000px]]
14562 !! html/php
14563 <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>
14564 </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>
14565 </p>
14566 !! html/parsoid
14567 <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>
14568 <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>
14569 !! end
14570
14571 !! test
14572 Image: framed images are always unscaled.
14573 !! options
14574 parsoid=wt2html,wt2wt,html2html
14575 !! wikitext
14576 [[File:Foobar.jpg|frame]]
14577
14578 [[File:Foobar.jpg|frame|50px]]
14579
14580 [[File:Foobar.jpg|frame|50x50px]]
14581
14582 [[File:Foobar.jpg|frame|2000px]]
14583 !! html/php
14584 <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>
14585 <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>
14586 <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>
14587 <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>
14588
14589 !! html/parsoid
14590 <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>
14591 <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>
14592 <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>
14593 <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>
14594 !! end
14595
14596 ###################
14597
14598 !! test
14599 Link to image page- image page normally doesn't exists, hence edit link
14600 Add test with existing image page
14601 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
14602 !! wikitext
14603 [[:Image:test]]
14604 !! html
14605 <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>
14606 </p>
14607 !! end
14608
14609 !! test
14610 T20784 Link to non-existent image page with caption should use caption as link text
14611 !! wikitext
14612 [[:Image:test|caption]]
14613 !! html
14614 <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>
14615 </p>
14616 !! end
14617
14618 !! test
14619 Frameless image caption with a free URL
14620 !! wikitext
14621 [[File:Foobar.jpg|http://example.com]]
14622 !! html/php
14623 <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>
14624 </p>
14625 !! html/parsoid
14626 <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>
14627 !! end
14628
14629 !! test
14630 Thumbnail image caption with a free URL
14631 !! options
14632 thumbsize=220
14633 !! wikitext
14634 [[File:Foobar.jpg|thumb|http://example.com]]
14635 !! html/php
14636 <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>
14637
14638 !! html/parsoid
14639 <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>
14640 !! end
14641
14642 !! test
14643 Thumbnail image caption with a free URL and explicit alt
14644 !! options
14645 thumbsize=220
14646 parsoid=wt2html,wt2wt,html2html
14647 !! wikitext
14648 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
14649 !! html/php
14650 <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>
14651
14652 !! html/parsoid
14653 <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>
14654 !! end
14655
14656 !! test
14657 SVG thumbnails with no language set
14658 !! options
14659 !! wikitext
14660 [[File:Foobar.svg|thumb|caption]]
14661 !! html/php
14662 <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>
14663
14664 !! html/parsoid
14665 <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>
14666 !! end
14667
14668 !! test
14669 SVG thumbnails with language de
14670 !! options
14671 parsoid=wt2html,wt2wt,html2html
14672 !! wikitext
14673 [[File:Foobar.svg|thumb|caption|lang=de]]
14674 !! html/php
14675 <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>
14676
14677 !! html/parsoid
14678 <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>
14679 !! end
14680
14681 !! test
14682 SVG thumbnails with invalid language code
14683 !! options
14684 parsoid=wt2html,wt2wt,html2html
14685 !! wikitext
14686 [[File:Foobar.svg|thumb|caption|lang=invalid.language.code]]
14687 !! html/php
14688 <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>
14689
14690 !! html/parsoid
14691 <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>
14692 !! end
14693
14694 !! test
14695 T3887: A ISBN with a thumbnail
14696 !! wikitext
14697 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
14698 !! html/php
14699 <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>
14700
14701 !! html/parsoid
14702 <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>
14703 !! end
14704
14705 !! test
14706 T3887: A RFC with a thumbnail
14707 !! wikitext
14708 [[File:Foobar.jpg|thumb|This is RFC 12354]]
14709 !! html/php
14710 <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>
14711
14712 !! html/parsoid
14713 <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>
14714 !! end
14715
14716 !! test
14717 T3887: A mailto link with a thumbnail
14718 !! wikitext
14719 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
14720 !! html/php
14721 <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>
14722
14723 !! html/parsoid
14724 <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>
14725 !! end
14726
14727 # Pending resolution to T2368
14728 !! test
14729 T2648: Frameless image caption with a link
14730 !! wikitext
14731 [[File:Foobar.jpg|text with a [[link]] in it]]
14732 !! html/php
14733 <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>
14734 </p>
14735 !! html/parsoid
14736 <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>
14737 !! end
14738
14739 !! test
14740 T2648: Frameless image caption with a link (suffix)
14741 !! wikitext
14742 [[File:Foobar.jpg|text with a [[link]]foo in it]]
14743 !! html/php
14744 <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>
14745 </p>
14746 !! html/parsoid
14747 <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>
14748 !! end
14749
14750 !! test
14751 T2648: Frameless image caption with an interwiki link
14752 !! wikitext
14753 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
14754 !! html/php
14755 <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>
14756 </p>
14757 !! html/parsoid
14758 <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>
14759 !! end
14760
14761 !! test
14762 T2648: Frameless image caption with a piped interwiki link
14763 !! wikitext
14764 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
14765 !! html/php
14766 <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>
14767 </p>
14768 !! html/parsoid
14769 <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>
14770 !! end
14771
14772 !! test
14773 T107474: Frameless image caption with <nowiki>
14774 !! wikitext
14775 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
14776 !! html/parsoid
14777 <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>
14778 !! end
14779
14780 !! test
14781 Escape HTML special chars in image alt text
14782 !! wikitext
14783 [[File:Foobar.jpg|& < > "]]
14784 !! html/php
14785 <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>
14786 </p>
14787 !! html/parsoid
14788 <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>
14789 !! end
14790
14791 !! test
14792 Escape HTML special chars in image alt text with LanguageConverter
14793 !! options
14794 language=zh
14795 !! wikitext
14796 [[File:Foobar.jpg|& < > "]]
14797 !! html/php
14798 <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>
14799 </p>
14800 !! html/parsoid
14801 <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>
14802 !! end
14803
14804 !! test
14805 Entities in file name and attributes
14806 !! wikitext
14807 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
14808 !! html/php
14809 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
14810 </p>
14811 !! html/parsoid
14812 <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>
14813 !! end
14814
14815 !! test
14816 T2499: Alt text should have &#1234;, not &amp;1234;
14817 !! wikitext
14818 [[File:Foobar.jpg|&#9792;]]
14819 !! html/php
14820 <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>
14821 </p>
14822 !! html/parsoid
14823 <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>
14824 !! end
14825
14826 !! test
14827 Broken image caption with link
14828 !! options
14829 parsoid=wt2html,wt2wt,html2html
14830 !! wikitext
14831 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
14832 !! html/php
14833 <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.
14834 </p>
14835 !! html/parsoid
14836 <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>
14837 !! end
14838
14839 !! test
14840 Image caption containing another image
14841 !! wikitext
14842 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
14843 !! html/php
14844 <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>
14845
14846 !! html/parsoid
14847 <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>
14848 !! end
14849
14850 !! test
14851 Image: caption containing a newline
14852 !! wikitext
14853 [[File:Foobar.jpg|This
14854 *is some text]]
14855 !! html/php
14856 <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>
14857 </p>
14858 !! html/parsoid
14859 <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>
14860 !!end
14861
14862 !!test
14863 Image: caption containing leading space
14864 (The leading space should not trigger nowiki escaping in wt2wt mode)
14865 !! wikitext
14866 [[File:Foobar.jpg|thumb| bar]]
14867 !! html/php
14868 <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>
14869
14870 !! html/parsoid
14871 <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>
14872 !!end
14873
14874 !! test
14875 Image: caption containing a table
14876 !! options
14877 parsoid=wt2html,wt2wt,html2html
14878 !! wikitext
14879 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
14880 {|
14881 ! Foo !! Bar
14882 |-
14883 | Foo1 || Bar1
14884 |}
14885 and some more text.]]
14886 !! html/php
14887 <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>
14888
14889 !! html/parsoid
14890 <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
14891 <table>
14892 <tbody>
14893 <tr><th>Foo </th><th>Bar</th></tr>
14894 <tr>
14895 <td>Foo1 </td>
14896 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
14897 !! end
14898
14899 !! test
14900 T5090: External links other than http: in image captions
14901 !! wikitext
14902 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
14903 !! html/php
14904 <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>
14905
14906 !! html/parsoid
14907 <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>
14908 !! end
14909
14910 !! test
14911 Custom class
14912 !! options
14913 parsoid=wt2html,wt2wt,html2html
14914 !! wikitext
14915 [[Image:foobar.jpg|a|class=b]]
14916 !! html/php
14917 <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>
14918 </p>
14919 !! html/parsoid
14920 <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>
14921 !! end
14922
14923 !! test
14924 Localized image handling (1).
14925 !! options
14926 parsoid=wt2html,wt2wt,html2html
14927 language=es
14928 !! wikitext
14929 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
14930 !! html/php
14931 <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>
14932
14933 !! html/parsoid
14934 <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>
14935 !! end
14936
14937 !! test
14938 Localized image handling (2).
14939 !! options
14940 thumbsize=220
14941 parsoid=wt2html,wt2wt,html2html
14942 language=es
14943 !! wikitext
14944 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
14945 !! html/php
14946 <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>
14947
14948 !! html/parsoid
14949 <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>
14950 !! end
14951
14952 !! test
14953 Localized image handling (3).
14954 !! options
14955 language=fa
14956 parsoid=html2wt
14957 !! html/parsoid
14958 <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>
14959 !! wikitext
14960 [[File:Foobar.jpg|بندانگشتی]]
14961 !! end
14962
14963 !! test
14964 "border", "frameless" and "class" attributes on an image.
14965 !! options
14966 thumbsize=220
14967 parsoid=wt2html,wt2wt,html2html
14968 !! wikitext
14969 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
14970 !! html/php
14971 <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>
14972 </p>
14973 !! html/parsoid
14974 <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>
14975 !! end
14976
14977 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
14978 !! test
14979 Invalid image attributes (T64500)
14980 !! options
14981 thumbsize=220
14982 parsoid=wt2html,wt2wt,html2html
14983 !! wikitext
14984 [[File:Foobar.jpg|thumb|float|left|caption]]
14985
14986 [[File:Foobar.jpg|thumb|righ|caption]]
14987
14988 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
14989 !! html/php
14990 <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>
14991 <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>
14992 <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>
14993
14994 !! html/parsoid
14995 <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>
14996 <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>
14997 <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>
14998 !! end
14999
15000 !! article
15001 File:Barfoo.jpg
15002 !! text
15003 #REDIRECT [[File:Barfoo.jpg]]
15004 !! endarticle
15005
15006 # FIXME: Parsoid should run this test -- but we'd need to teach the
15007 # mockAPI about the redirected Barfoo.jpg image.
15008 !! test
15009 Redirected image
15010 !! wikitext
15011 [[Image:Barfoo.jpg]]
15012 !! html/php
15013 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
15014 </p>
15015 !! end
15016
15017 !! test
15018 Missing image with uploads disabled
15019 !! options
15020 wgEnableUploads=0
15021 !! wikitext
15022 [[File:Foobaz.jpg]]
15023 !! html/php
15024 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
15025 </p>
15026 !! html/parsoid
15027 <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>
15028 !! end
15029
15030 # Parsoid-specific testing for images
15031 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
15032 # Currently imperfect due to a flaw in the Parsoid testrunner
15033 # Work in progress
15034 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
15035 # image tests.
15036
15037 !! test
15038 Parsoid-specific image handling - simple image with size and middle alignment
15039 !! wikitext
15040 [[File:Foobar.jpg|middle|50px]]
15041 !! html/parsoid
15042 <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>
15043 !! end
15044
15045 !! test
15046 Parsoid-specific image handling - simple image with size, middle alignment,
15047 non-standard namespace alias
15048 !! options
15049 parsoid=wt2wt,wt2html,html2html
15050 !! wikitext
15051 [[Image:Foobar.jpg|middle|50px]]
15052 !! html/parsoid
15053 <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>
15054 !! end
15055
15056 !! test
15057 Parsoid-specific image handling - simple image with size and middle alignment
15058 (existing content)
15059 !! wikitext
15060 [[File:Foobar.jpg|50px|middle]]
15061 !! html/parsoid
15062 <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>
15063 !! end
15064
15065 !! test
15066 Parsoid-specific image handling - simple image with size and middle alignment
15067 and non-standard namespace name
15068 !! options
15069 parsoid=wt2html,wt2wt,html2html
15070 !! wikitext
15071 [[Image:Foobar.jpg|50px|middle]]
15072 !! html/parsoid
15073 <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>
15074 !! end
15075
15076 !! test
15077 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
15078 !! wikitext
15079 [[File:Foobar.jpg|500x10px|baseline|caption]]
15080 !! html/parsoid
15081 <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>
15082 !! end
15083
15084 !! test
15085 Parsoid-specific image handling - simple image with border and size spec
15086 !! wikitext
15087 [[File:Foobar.jpg|50px|border|caption]]
15088 !! html/parsoid
15089 <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>
15090 !! end
15091
15092 !! test
15093 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15094 !! wikitext
15095 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
15096 !! html/parsoid
15097 <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>
15098 !! end
15099
15100 !! test
15101 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15102 (existing content)
15103 !! wikitext
15104 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
15105 !! html/parsoid
15106 <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>
15107 !! end
15108
15109 !! test
15110 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
15111 !! wikitext
15112 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
15113 !! html/parsoid
15114 <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>
15115 !! end
15116
15117 !! test
15118 Parsoid-specific image handling - thumbnail with specific size, halign,
15119 valign, and caption (existing content)
15120 !! wikitext
15121 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
15122 !! html/parsoid
15123 <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>
15124 !! end
15125
15126 !! test
15127 Parsoid-specific image handling - framed image with specific size and caption
15128 (size is ignored)
15129 !! options
15130 parsoid=wt2html,wt2wt,html2html
15131 !! wikitext
15132 [[File:Foobar.jpg|frame|500x50px|caption]]
15133 !! html/parsoid
15134 <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>
15135 !! end
15136
15137 !! test
15138 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption
15139 (size is ignored)
15140 !! options
15141 parsoid=wt2html,wt2wt,html2html
15142 !! wikitext
15143 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
15144 !! html/parsoid
15145 <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>
15146 !! end
15147
15148 !! test
15149 Parsoid-specific image handling - frameless image with specific size, border, and caption
15150 !! wikitext
15151 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
15152 !! html/parsoid
15153 <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>
15154 !! end
15155
15156 !! test
15157 Parsoid-specific image handling - simple image with a formatted caption
15158 !! wikitext
15159 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
15160 !! html/parsoid
15161 <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>
15162 !! end
15163
15164 !! test
15165 Parsoid-specific image handling - caption with a template in it
15166 !! wikitext
15167 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
15168 !! html/parsoid
15169 <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>
15170 !! end
15171
15172 !! test
15173 Parsoid-specific image handling - caption with unbalanced tags in it
15174 !! options
15175 parsoid=wt2html,wt2wt,html2html
15176 !! wikitext
15177 foo
15178 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
15179 bar
15180 !! html/parsoid
15181 <p>foo</p>
15182 <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>
15183 <p>bar</p>
15184 !! end
15185
15186 !! test
15187 Parsoid-specific image handling - empty caption (1)
15188 !! options
15189 parsoid=wt2html,wt2wt
15190 !! wikitext
15191 [[File:Foobar.jpg|thumb|]]
15192 !! html/parsoid
15193 <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>
15194 !! end
15195
15196 # empty captions don't get serialized unless we're in the "round trip" case
15197 !! test
15198 Parsoid-specific image handling - empty caption (2)
15199 !! options
15200 parsoid=html2wt
15201 !! html/parsoid
15202 <figure class="mw-default-size" typeof="mw:Image/Thumb">
15203 <a href="./File:Foobar.jpg">
15204 <img resource="./File:Foobar.jpg"
15205 src="//example.com/images/3/3a/Foobar.jpg"
15206 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
15207 height="25" width="220"/>
15208 </a>
15209 <figcaption></figcaption>
15210 </figure>
15211 !! wikitext
15212 [[File:Foobar.jpg|thumb]]
15213 !! end
15214
15215 !! test
15216 Parsoid-specific image handling - whitespace caption
15217 !! wikitext
15218 [[File:Foobar.jpg|thumb| ]]
15219 !! html/parsoid
15220 <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>
15221 !! end
15222
15223 !! test
15224 Parsoid-specific image handling - lang option
15225 !! wikitext
15226 foo
15227 [[File:Foobar.svg|lang=de|caption]]
15228 bar
15229 !! html/parsoid
15230 <p>foo
15231 <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>
15232 bar</p>
15233 !! end
15234
15235 ## Edge case bugs in Parsoid from T93580
15236 !! test
15237 T93580: 1. Templated <ref> inside block images
15238 !! wikitext
15239 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
15240
15241 <references />
15242 !! html/parsoid
15243 <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>
15244
15245 <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>
15246 !! end
15247
15248 !! test
15249 T93580: 2. <ref> inside inline images
15250 !! wikitext
15251 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
15252
15253 <references />
15254 !! html/parsoid
15255 <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>
15256
15257 <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>
15258 !! end
15259
15260 !! test
15261 T93580: 3. Templated <ref> inside inline images
15262 !! wikitext
15263 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
15264
15265 <references />
15266 !! html/parsoid
15267 <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>
15268
15269 <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>
15270 !! end
15271
15272 ###
15273 ### Subpages
15274 ###
15275 !! article
15276 Subpage test/subpage
15277 !! text
15278 foo
15279 !! endarticle
15280
15281 !! test
15282 Subpage link
15283 !! options
15284 subpage title=[[Subpage test]]
15285 !! wikitext
15286 [[/subpage]]
15287 !! html
15288 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
15289 </p>
15290 !! end
15291
15292 !! test
15293 Subpage noslash link
15294 !! options
15295 subpage title=[[Subpage test]]
15296 !! wikitext
15297 [[/subpage/]]
15298 !! html
15299 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
15300 </p>
15301 !! end
15302
15303 !! article
15304 Subpage test/1/2/subpage
15305 !! text
15306 blah
15307 !! endarticle
15308
15309 !! test
15310 Relative subpage noslash link
15311 !! options
15312 parsoid=wt2wt,wt2html,html2html
15313 subpage title=[[Subpage test/1/2/3/4]]
15314 !! wikitext
15315 [[../../subpage/]]
15316
15317 [[../../subpage]]
15318 !! html/php
15319 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
15320 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
15321 </p>
15322 !! html/parsoid
15323 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
15324 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
15325 !! end
15326
15327 !! test
15328 Parsoid: dot-slash prefixed wikilinks
15329 !! wikitext
15330 [[./foo]]
15331
15332 [[././bar]]
15333
15334 [[././baz/]]
15335 !! html/php
15336 <p>[[./foo]]
15337 </p><p>[[././bar]]
15338 </p><p>[[././baz/]]
15339 </p>
15340 !! html/parsoid
15341 <p>[[./foo]]
15342 </p><p>[[././bar]]
15343 </p><p>[[././baz/]]
15344 </p>
15345 !! end
15346
15347 !! test
15348 Render invalid page names as plain text (T53090)
15349 !! wikitext
15350 [[./../foo|bar]]
15351 [[foo�|bar]]
15352 [[foo/.|bar]]
15353 [[foo/..|bar]]
15354 [[foo~~~bar]]
15355 [[foo>bar]]
15356 [[foo[bar]]
15357 [[.]]
15358 [[..]]
15359 [[foo././bar]]
15360 [[foo[http://example.com]xyz]]
15361
15362 [[{{echo|./../foo}}|bar]]
15363 [[{{echo|foo/.}}|bar]]
15364 [[{{echo|foo/..}}|bar]]
15365 [[{{echo|foo~~~~bar}}]]
15366 [[{{echo|foo>bar}}]]
15367 [[{{echo|foo././bar}}]]
15368 [[{{echo|foo{bar}}]]
15369 [[{{echo|foo}bar}}]]
15370 [[{{echo|foo[bar}}]]
15371 [[{{echo|foo]bar}}]]
15372 [[{{echo|foo<bar}}]]
15373 !!html/php
15374 <p>[[./../foo|bar]]
15375 [[foo�|bar]]
15376 [[foo/.|bar]]
15377 [[foo/..|bar]]
15378 [[foo~~~bar]]
15379 [[foo&gt;bar]]
15380 [[foo[bar]]
15381 [[.]]
15382 [[..]]
15383 [[foo././bar]]
15384 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
15385 </p><p>[[./../foo|bar]]
15386 [[foo/.|bar]]
15387 [[foo/..|bar]]
15388 [[foo~~~~bar]]
15389 [[foo&gt;bar]]
15390 [[foo././bar]]
15391 [[foo{bar]]
15392 [[foo}bar]]
15393 [[foo[bar]]
15394 [[foo]bar]]
15395 [[foo&lt;bar]]
15396 </p>
15397 !!html/parsoid
15398 <p>[[./../foo|bar]]
15399 [[foo�|bar]]
15400 [[foo/.|bar]]
15401 [[foo/..|bar]]
15402 [[foo~~~bar]]
15403 [[foo>bar]]
15404 [[foo[bar]]
15405 [[.]]
15406 [[..]]
15407 [[foo././bar]]
15408 [[foo<a rel="mw:ExtLink" href="http://example.com"></a>xyz]]</p>
15409
15410 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
15411 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
15412 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
15413 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
15414 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
15415 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
15416 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
15417 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo}bar"}},"i":0}}]}'>foo}bar</span>]]
15418 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo[bar"}},"i":0}}]}'>foo[bar</span>]]
15419 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo]bar"}},"i":0}}]}'>foo]bar</span>]]
15420 [[<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>
15421 !!end
15422
15423 !! test
15424 Disabled subpages
15425 !! wikitext
15426 [[/subpage]]
15427 !! html
15428 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
15429 </p>
15430 !! end
15431
15432 !! test
15433 T2561: {{/Subpage}}
15434 !! options
15435 subpage title=[[Page]]
15436 !! wikitext
15437 {{/Subpage}}
15438 !! html
15439 <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>
15440 </p>
15441 !! end
15442
15443 ###
15444 ### Categories
15445 ###
15446 !! article
15447 Category:MediaWiki User's Guide
15448 !! text
15449 blah
15450 !! endarticle
15451
15452 !! test
15453 Link to category
15454 !! wikitext
15455 [[:Category:MediaWiki User's Guide]]
15456 !! html
15457 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
15458 </p>
15459 !! end
15460
15461 !! test
15462 Simple category
15463 !! options
15464 cat
15465 !! wikitext
15466 [[Category:MediaWiki User's Guide]]
15467 !! html/php
15468 cat=MediaWiki_User's_Guide sort=
15469 !! html/parsoid
15470 <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"}}'/>
15471 !! end
15472
15473 !! test
15474 PAGESINCATEGORY invalid title fatal (r33546 fix)
15475 !! wikitext
15476 {{PAGESINCATEGORY:<bogus>}}
15477 !! html
15478 <p>0
15479 </p>
15480 !! end
15481
15482 !! test
15483 Category with different sort key
15484 !! options
15485 cat
15486 !! wikitext
15487 [[Category:MediaWiki User's Guide|Foo]]
15488 !! html/php
15489 cat=MediaWiki_User's_Guide sort=Foo
15490 !! html/parsoid
15491 <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"}}'/>
15492 !! end
15493
15494 !! test
15495 Category with identical sort key
15496 !! options
15497 cat
15498 !! wikitext
15499 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15500 !! html/php
15501 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
15502 !! html/parsoid
15503 <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"}}'/>
15504 !! end
15505
15506 !! test
15507 Category with empty sort key
15508 !! options
15509 cat
15510 pst
15511 !! wikitext
15512 [[Category:MediaWiki User's Guide|]]
15513 !! html/php
15514 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15515 !! end
15516
15517 !! test
15518 Category with empty sort key and parentheses
15519 !! options
15520 cat
15521 pst
15522 !! wikitext
15523 [[Category:Foo (bar)|]]
15524 !! html/php
15525 [[Category:Foo (bar)|Foo]]
15526 !! end
15527
15528 !! test
15529 Category with link tail
15530 !! options
15531 cat
15532 pst
15533 !! wikitext
15534 123[[Category:Foo]]456
15535 !! html/php
15536 123[[Category:Foo]]456
15537 !! end
15538
15539 !! test
15540 Category with template
15541 !! options
15542 cat
15543 pst
15544 !! wikitext
15545 [[Category:{{echo|Foo}}]]
15546 !! html/php
15547 [[Category:{{echo|Foo}}]]
15548 !! end
15549
15550 !! test
15551 Category with template in sort key
15552 !! options
15553 cat
15554 pst
15555 !! wikitext
15556 [[Category:Foo|{{echo|Bar}}]]
15557 !! html/php
15558 [[Category:Foo|{{echo|Bar}}]]
15559 !! end
15560
15561 !! test
15562 Category with template in sort key and title
15563 !! options
15564 cat
15565 pst
15566 !! wikitext
15567 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15568 !! html/php
15569 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15570 !! end
15571
15572 ## We used to, but no longer wt2wt this test since the default serializer
15573 ## will normalize all categories to serialize on their own line.
15574 ## This wikitext usage is going to be fairly uncommon in production and
15575 ## selser will take care of preserving formatting in those scenarios.
15576 !! test
15577 Category / paragraph interactions
15578 !! options
15579 parsoid=wt2html
15580 !! wikitext
15581 Foo [[Category:Baz]] Bar
15582
15583 Foo [[Category:Baz]]
15584 Bar
15585
15586 Foo
15587 [[Category:Baz]]
15588 Bar
15589
15590 Foo
15591 [[Category:Baz]] Bar
15592
15593 Foo
15594 [[Category:Baz]]
15595 [[Category:Baz]]
15596 [[Category:Baz]]
15597 Bar
15598
15599 [[Category:Baz]]
15600 [[Category:Baz]]
15601 [[Category:Baz]]
15602
15603 [[Category:Baz]]
15604 {{echo|[[Category:Baz]]}}
15605 [[Category:Baz]]
15606 !! html/php
15607 <p>Foo Bar
15608 </p><p>Foo
15609 Bar
15610 </p><p>Foo
15611 Bar
15612 </p><p>Foo Bar
15613 </p><p>Foo
15614 Bar
15615 </p>
15616 !! html/parsoid
15617 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15618 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15619 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15620 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15621 <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>
15622 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
15623 !! end
15624
15625 ## We used to, but no longer wt2wt this test since the default serializer
15626 ## will normalize all categories to serialize on their own line.
15627 ## This wikitext usage is going to be fairly uncommon in production and
15628 ## selser will take care of preserving formatting in those scenarios.
15629 ##
15630 ## The whitespace on the empty line is part of the test. Please do not delete
15631 !! test
15632 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
15633 !! options
15634 parsoid=wt2html
15635 !! wikitext
15636 This
15637
15638 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
15639
15640 {{echo|[[Category:Foo]] and so should this!}}
15641 !! html/php
15642 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
15643 </p>
15644 !! html/parsoid
15645 <p>This
15646
15647 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
15648
15649 <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>
15650 !! end
15651
15652 ## Parsoid will not try to wt2wt this while preserving newlines because
15653 ## it suppresses excess newlines within list items -- and we don't want to
15654 ## introduce a special case just for categories, which is, in reality somewhat
15655 ## odd behavior -- categories are unlikely to be used in list items like this
15656 ## in top-level pages and are only likely to show up in template-generated
15657 ## list items where this RT-ing is a non-issue.
15658 ##
15659 ## The whitespace on the empty line is part of the test. Please do not delete
15660 !! test
15661 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
15662 !! options
15663 parsoid=wt2html
15664 !! wikitext
15665 * This
15666
15667 [[Category:Foo]] and this should be part of the same list item
15668 * So should this
15669
15670 {{echo|[[Category:Foo]] and this should be part of the same list item}}
15671 !! html
15672 <ul><li>This and this should be part of the same list item</li>
15673 <li>So should this and this should be part of the same list item</li></ul>
15674 !! html/parsoid
15675 <ul>
15676 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
15677 <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>
15678 </ul>
15679 !! end
15680
15681 ## Newlines and categories that follow the last item of a list
15682 ## are treated differently because this (list followed by categories)
15683 ## is an extremely common pattern on wikis.
15684 !! test
15685 3. Categories and newlines: newline suppression for last list item should RT properly
15686 !! wikitext
15687 * a
15688 * b
15689
15690 [[Category:Foo]]
15691
15692 [[Category:Bar]]
15693 [[Category:Baz]]
15694 !! html/parsoid
15695 <ul><li> a</li>
15696 <li> b</li></ul>
15697
15698 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
15699
15700 <link rel="mw:PageProp/Category" href="./Category:Bar" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
15701 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
15702 !! end
15703
15704 !! test
15705 4. Categories and newlines: newline suppression for last list item should RT properly
15706 !! wikitext
15707 * a
15708 **** b
15709
15710 [[Category:Foo]]
15711 !! html/parsoid
15712 <ul><li> a
15713 <ul><li><ul><li><ul><li> b</li></ul></li></ul></li></ul></li></ul>
15714
15715 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
15716 !! end
15717
15718 ## only wt2html for this to make sure the algo only applies to the rightmost path
15719 !! test
15720 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
15721 !! options
15722 parsoid=wt2html
15723 !! wikitext
15724 * a
15725 ** b
15726 [[Category:Foo]]
15727 * c
15728 ** d
15729 [[Category:Foo]]
15730 !! html/parsoid
15731 <ul><li> a
15732 <ul><li> b
15733 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
15734 <li> c
15735 <ul><li> d</li></ul></li></ul>
15736 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
15737 !! end
15738
15739 ## We used to, but no longer wt2wt this test since the default serializer
15740 ## will normalize all categories to serialize on their own line.
15741 ## This wikitext usage is going to be fairly uncommon in production and
15742 ## selser will take care of preserving formatting in those scenarios.
15743 !! test
15744 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
15745 !! options
15746 parsoid=wt2html
15747 !! wikitext
15748 * a [[Category:Foo]]
15749 !! html/parsoid
15750 <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>
15751 !! end
15752
15753 # This test also demonstrates because of newline+category tunneling
15754 # through the list hander, template wrapping doesn't expand to the
15755 # containing list when the list item swallows the category.
15756 !! test
15757 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
15758 !! wikitext
15759 * {{echo|a
15760 [[Category:Foo]]}}
15761 !! html/parsoid
15762 <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
15763 </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>
15764 !! end
15765
15766 !! test
15767 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
15768 !! wikitext
15769 * a
15770
15771 {{echo|[[Category:Foo]]
15772 [[Category:Bar]]}}
15773 [[Category:Baz]]
15774 !! html/parsoid
15775 <ul><li> a</li></ul>
15776
15777 <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">
15778 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
15779 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
15780 !! end
15781
15782 !! test
15783 Category links with multiple namespaces
15784 !! wikitext
15785 [[Category:Project:Foo]]
15786 !! html/parsoid
15787 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
15788 !! end
15789
15790 !! test
15791 Parsoid: Serialize link to category page with colon escape
15792 !! options
15793 parsoid
15794 !! wikitext
15795
15796 [[:Category:Foo]]
15797 [[:Category:Foo|Bar]]
15798 !! html
15799 <p>
15800 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
15801 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
15802 </p>
15803 !! end
15804
15805 # We used to, but no longer wt2wt this test since the default serializer
15806 # will normalize all categories to serialize on their own line.
15807 # This wikitext usage is going to be fairly uncommon in production and
15808 # selser will take care of preventing whitespace insertion if this
15809 # occurs in an article.
15810 #
15811 # html2html disabled for the same reason (whitespace insertion between
15812 # x and y).
15813 #
15814 # html2wt disabled because it localizes the "Category" namespace.
15815 !! test
15816 Link prefix/suffixes aren't applied to category links
15817 !! options
15818 parsoid=wt2html
15819 language=is
15820 !! wikitext
15821 x[[Category:Foo]]y
15822 !! html/php
15823 <p>xy
15824 </p>
15825 !! html/parsoid
15826 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
15827 !! end
15828
15829 !! test
15830 Parsoid: Serialize link to file page with colon escape
15831 !! options
15832 parsoid
15833 !! wikitext
15834
15835 [[:File:Foo.png]]
15836 [[:File:Foo.png|Bar]]
15837 !! html
15838 <p>
15839 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
15840 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
15841 </p>
15842 !! end
15843
15844 !! test
15845 Parsoid: Serialize a genuine category link without colon escape
15846 !! options
15847 parsoid
15848 !! wikitext
15849 [[Category:Foo]]
15850 [[Category:Foo|Bar]]
15851 !! html
15852 <link rel="mw:PageProp/Category" href="./Category:Foo">
15853 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
15854 !! end
15855
15856 !! test
15857 Normalize hrefs properly before testing for invalid link targets (T72894)
15858 !! options
15859 parsoid=html2wt
15860 !! html/parsoid
15861 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
15862 !! wikitext
15863 [[Category:Toxine bactérienne]]
15864 !! end
15865
15866 !! test
15867 Parsoid: Defaultsort
15868 !! wikitext
15869 {{DEFAULTSORT:Foo}}
15870 !! html/parsoid
15871 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
15872 !! end
15873
15874 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
15875 # But, this is a limitation of our representation and is documented in
15876 # TemplateHandler.js in processSpecialMagicWord
15877 !! test
15878 Parsoid: Defaultsort (template-generated)
15879 !! wikitext
15880 {{{{echo|DEFAULTSORT}}:Foo}}
15881 !! html/parsoid
15882 <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"}]]}'/>
15883 !! end
15884
15885 ###
15886 ### Inter-language links
15887 ###
15888 !! test
15889 Interlanguage links
15890 !! options
15891 ill
15892 !! wikitext
15893 [[es:Alimento]]
15894 [[fr:Nourriture]]
15895 [[zh:食品]]
15896 !! html/php
15897 es:Alimento fr:Nourriture zh:食品
15898 !! html/parsoid
15899 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
15900 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
15901 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
15902 !! end
15903
15904 !! test
15905 Duplicate interlanguage links (T26502)
15906 !! options
15907 ill
15908 !! wikitext
15909 [[es:1]]
15910 [[es:2]]
15911 [[fr:1]]
15912 [[fr:2]]
15913 !! html/php
15914 es:1 fr:1
15915 !! html/parsoid
15916 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
15917 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
15918 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
15919 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
15920 !! end
15921
15922 ###
15923 ### Sections
15924 ###
15925 !! test
15926 Basic section headings
15927 !! wikitext
15928 == Headline 1 ==
15929 Some text
15930
15931 ==Headline 2==
15932 More
15933 ===Smaller headline===
15934 Blah blah
15935 !! html
15936 <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>
15937 <p>Some text
15938 </p>
15939 <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>
15940 <p>More
15941 </p>
15942 <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>
15943 <p>Blah blah
15944 </p>
15945 !! end
15946
15947 !! test
15948 Section headings with TOC
15949 !! wikitext
15950 == Headline 1 ==
15951 === Subheadline 1 ===
15952 ===== Skipping a level =====
15953 ====== Skipping a level ======
15954
15955 == Headline 2 ==
15956 Some text
15957 ===Another headline===
15958 !! html
15959 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
15960 <ul>
15961 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
15962 <ul>
15963 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
15964 <ul>
15965 <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>
15966 <ul>
15967 <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>
15968 </ul>
15969 </li>
15970 </ul>
15971 </li>
15972 </ul>
15973 </li>
15974 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
15975 <ul>
15976 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
15977 </ul>
15978 </li>
15979 </ul>
15980 </div>
15981
15982 <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>
15983 <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>
15984 <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>
15985 <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>
15986 <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>
15987 <p>Some text
15988 </p>
15989 <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>
15990
15991 !! end
15992
15993 !! test
15994 TOC anchors don't collide
15995 !! wikitext
15996 __FORCETOC__
15997 == Headline 2 ==
15998 == Headline ==
15999 == Headline 2 ==
16000 == Headline ==
16001 !! html/php
16002 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16003 <ul>
16004 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
16005 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
16006 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
16007 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
16008 </ul>
16009 </div>
16010
16011 <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>
16012 <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>
16013 <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>
16014 <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>
16015
16016 !! end
16017
16018 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
16019 !! test
16020 Handling of sections up to level 6 and beyond
16021 !! wikitext
16022 = Level 1 Heading=
16023 == Level 2 Heading==
16024 === Level 3 Heading===
16025 ==== Level 4 Heading====
16026 ===== Level 5 Heading=====
16027 ====== Level 6 Heading======
16028 ======= Level 7 Heading=======
16029 ======== Level 8 Heading========
16030 ========= Level 9 Heading=========
16031 ========== Level 10 Heading==========
16032 !! html
16033 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16034 <ul>
16035 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
16036 <ul>
16037 <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>
16038 <ul>
16039 <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>
16040 <ul>
16041 <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>
16042 <ul>
16043 <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>
16044 <ul>
16045 <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>
16046 <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>
16047 <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>
16048 <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>
16049 <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>
16050 </ul>
16051 </li>
16052 </ul>
16053 </li>
16054 </ul>
16055 </li>
16056 </ul>
16057 </li>
16058 </ul>
16059 </li>
16060 </ul>
16061 </div>
16062
16063 <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>
16064 <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>
16065 <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>
16066 <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>
16067 <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>
16068 <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>
16069 <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>
16070 <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>
16071 <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>
16072 <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>
16073
16074 !! end
16075
16076 !! test
16077 TOC regression (T11764)
16078 !! wikitext
16079 == title 1 ==
16080 === title 1.1 ===
16081 ==== title 1.1.1 ====
16082 === title 1.2 ===
16083 == title 2 ==
16084 === title 2.1 ===
16085 !! html
16086 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16087 <ul>
16088 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16089 <ul>
16090 <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>
16091 <ul>
16092 <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>
16093 </ul>
16094 </li>
16095 <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>
16096 </ul>
16097 </li>
16098 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16099 <ul>
16100 <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>
16101 </ul>
16102 </li>
16103 </ul>
16104 </div>
16105
16106 <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>
16107 <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>
16108 <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>
16109 <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>
16110 <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>
16111 <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>
16112
16113 !! end
16114
16115 !! test
16116 TOC for heading containing <span id="..."></span> (T96153)
16117 !! wikitext
16118 __FORCETOC__
16119 ==<span id="old-anchor"></span>New title==
16120 !! html/php
16121 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16122 <ul>
16123 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
16124 </ul>
16125 </div>
16126
16127 <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>
16128
16129 !! end
16130
16131 !! test
16132 TOC with wgMaxTocLevel=3 (T8204)
16133 !! options
16134 wgMaxTocLevel=3
16135 !! wikitext
16136 == title 1 ==
16137 === title 1.1 ===
16138 ==== title 1.1.1 ====
16139 === title 1.2 ===
16140 == title 2 ==
16141 === title 2.1 ===
16142 !! html
16143 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16144 <ul>
16145 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16146 <ul>
16147 <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>
16148 <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>
16149 </ul>
16150 </li>
16151 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16152 <ul>
16153 <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>
16154 </ul>
16155 </li>
16156 </ul>
16157 </div>
16158
16159 <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>
16160 <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>
16161 <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>
16162 <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>
16163 <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>
16164 <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>
16165
16166 !! end
16167
16168 !! test
16169 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
16170 !! options
16171 wgMaxTocLevel=3
16172 !! wikitext
16173 ==Section 1==
16174 ===Section 1.1===
16175 ====Section 1.1.1====
16176 ====Section 1.1.1.1====
16177 ==Section 2==
16178 !! html
16179 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16180 <ul>
16181 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
16182 <ul>
16183 <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>
16184 </ul>
16185 </li>
16186 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
16187 </ul>
16188 </div>
16189
16190 <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>
16191 <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>
16192 <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>
16193 <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>
16194 <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>
16195
16196 !! end
16197
16198
16199 !! test
16200 Resolving duplicate section names
16201 !! wikitext
16202 == Foo bar ==
16203 == Foo bar ==
16204 !! html
16205 <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>
16206 <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>
16207
16208 !! end
16209
16210 !! test
16211 Resolving duplicate section names with differing case (T12721)
16212 !! wikitext
16213 == Foo bar ==
16214 == Foo Bar ==
16215 !! html
16216 <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>
16217 <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>
16218
16219 !! end
16220
16221 !! article
16222 Template:sections
16223 !! text
16224 ===Section 1===
16225 ==Section 2==
16226 !! endarticle
16227
16228 !! test
16229 Template with sections, __NOTOC__
16230 !! wikitext
16231 __NOTOC__
16232 ==Section 0==
16233 {{sections}}
16234 ==Section 4==
16235 !! html
16236 <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>
16237 <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>
16238 <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>
16239 <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>
16240
16241 !! end
16242
16243 !! test
16244 __NOEDITSECTION__ keyword
16245 !! wikitext
16246 __NOEDITSECTION__
16247 ==Section 1==
16248 ==Section 2==
16249 !! html
16250 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
16251 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
16252
16253 !! end
16254
16255 !! test
16256 Link inside a section heading
16257 !! wikitext
16258 ==Section with a [[Main Page|link]] in it==
16259 !! html
16260 <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>
16261
16262 !! end
16263
16264 !! test
16265 TOC regression (T14077)
16266 !! wikitext
16267 __TOC__
16268 == title 1 ==
16269 === title 1.1 ===
16270 == title 2 ==
16271 !! html
16272 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16273 <ul>
16274 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16275 <ul>
16276 <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>
16277 </ul>
16278 </li>
16279 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
16280 </ul>
16281 </div>
16282
16283 <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>
16284 <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>
16285 <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>
16286
16287 !! end
16288
16289 !! test
16290 T3219 URL next to image (good)
16291 !! wikitext
16292 http://example.com [[File:Foobar.jpg]]
16293 !! html/php
16294 <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>
16295 </p>
16296 !! html/parsoid
16297 <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>
16298 !!end
16299
16300 !! test
16301 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
16302 !! wikitext
16303 ===
16304 The line above must have a trailing space!
16305 === <!--
16306 --> <!-- -->
16307 But just in case it doesn't...
16308 !! html
16309 <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>
16310 <p>The line above must have a trailing space!
16311 </p>
16312 <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>
16313 <p>But just in case it doesn't...
16314 </p>
16315 !! end
16316
16317 !! test
16318 Header with special characters (T27462)
16319 !! wikitext
16320 The tooltips shall not show entities to the user (ie. be double escaped)
16321
16322 == text > text ==
16323 section 1
16324
16325 == text < text ==
16326 section 2
16327
16328 == text & text ==
16329 section 3
16330
16331 == text ' text ==
16332 section 4
16333
16334 == text " text ==
16335 section 5
16336 !! html
16337 <p>The tooltips shall not show entities to the user (ie. be double escaped)
16338 </p>
16339 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16340 <ul>
16341 <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>
16342 <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>
16343 <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>
16344 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
16345 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
16346 </ul>
16347 </div>
16348
16349 <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>
16350 <p>section 1
16351 </p>
16352 <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>
16353 <p>section 2
16354 </p>
16355 <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>
16356 <p>section 3
16357 </p>
16358 <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>
16359 <p>section 4
16360 </p>
16361 <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>
16362 <p>section 5
16363 </p>
16364 !! end
16365
16366 !! test
16367 Header with space, plus and underscore as entity
16368 !! wikitext
16369 Id should not contain + for spaces
16370
16371 == Space between Text ==
16372 section 1
16373
16374 == Space-Entity&#32;between&#32;Text ==
16375 section 2
16376
16377 == Plus+between+Text ==
16378 section 3
16379
16380 == Plus-Entity&#43;between&#43;Text ==
16381 section 4
16382
16383 == Underscore_between_Text ==
16384 section 5
16385
16386 == Underscore-Entity&#95;between&#95;Text ==
16387 section 6
16388
16389 [[#Space between Text]]
16390 [[#Space-Entity&#32;between&#32;Text]]
16391 [[#Plus+between+Text]]
16392 [[#Plus-Entity&#43;between&#43;Text]]
16393 [[#Underscore_between_Text]]
16394 [[#Underscore-Entity&#95;between&#95;Text]]
16395 !! html
16396 <p>Id should not contain + for spaces
16397 </p>
16398 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16399 <ul>
16400 <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>
16401 <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>
16402 <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>
16403 <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>
16404 <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>
16405 <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>
16406 </ul>
16407 </div>
16408
16409 <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>
16410 <p>section 1
16411 </p>
16412 <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>
16413 <p>section 2
16414 </p>
16415 <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>
16416 <p>section 3
16417 </p>
16418 <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>
16419 <p>section 4
16420 </p>
16421 <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>
16422 <p>section 5
16423 </p>
16424 <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>
16425 <p>section 6
16426 </p><p><a href="#Space_between_Text">#Space between Text</a>
16427 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
16428 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
16429 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
16430 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
16431 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
16432 </p>
16433 !! end
16434
16435 !! test
16436 Headers with excess '=' characters
16437 (Are similar tests necessary beyond the 1st level?)
16438 !! wikitext
16439 =foo==
16440 ==foo=
16441 =''italic'' heading==
16442 ==''italic'' heading=
16443 !! html
16444 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16445 <ul>
16446 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
16447 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
16448 <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>
16449 <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>
16450 </ul>
16451 </div>
16452
16453 <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>
16454 <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>
16455 <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>
16456 <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>
16457
16458 !! end
16459
16460 !! test
16461 HTML headers vs TOC (T25393)
16462 (__NOEDITSECTION__ for clearer output, doesn't matter here)
16463 !! wikitext
16464 <h1>Header 1</h1>
16465 == Header 1.1 ==
16466 == Header 1.2 ==
16467
16468 <h1>Header 2
16469 </h1>
16470 == Header 2.1 ==
16471 == Header 2.2 ==
16472 __NOEDITSECTION__
16473 !! html
16474 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16475 <ul>
16476 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
16477 <ul>
16478 <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>
16479 <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>
16480 </ul>
16481 </li>
16482 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
16483 <ul>
16484 <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>
16485 <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>
16486 </ul>
16487 </li>
16488 </ul>
16489 </div>
16490
16491 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
16492 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
16493 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
16494 <h1><span class="mw-headline" id="Header_2">Header 2</span></h1>
16495 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
16496 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
16497
16498 !! end
16499
16500 !! test
16501 Single-line or multiline-comments can follow headings
16502 !! options
16503 parsoid=wt2html,wt2wt
16504 !! wikitext
16505 ==foo==<!---->
16506 ==bar==<!--c1-->
16507 ==baz==<!--
16508 c2
16509 c3-->
16510 !! html
16511 <h2><span class="mw-headline" id="foo">foo</span></h2>
16512 <h2><span class="mw-headline" id="bar">bar</span></h2>
16513 <h2><span class="mw-headline" id="baz">baz</span></h2>
16514
16515 !! end
16516
16517 !! test
16518 T3219 URL next to image (broken)
16519 !! wikitext
16520 http://example.com[[File:Foobar.jpg]]
16521 !! html/php
16522 <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>
16523 </p>
16524 !! html/parsoid
16525 <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>
16526 !!end
16527
16528 !! test
16529 T3186 news: in the middle of text
16530 !! wikitext
16531 http://en.wikinews.org/wiki/Wikinews:Workplace
16532 !! html
16533 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
16534 </p>
16535 !!end
16536
16537
16538 !! test
16539 Namespaced link must have a title
16540 !! wikitext
16541 [[Project:]]
16542 !! html
16543 <p>[[Project:]]
16544 </p>
16545 !!end
16546
16547 !! test
16548 Namespaced link must have a title (bad fragment version)
16549 !! wikitext
16550 [[Project:#fragment]]
16551 !! html
16552 <p>[[Project:#fragment]]
16553 </p>
16554 !!end
16555
16556
16557 ###
16558 ### HTML tags and HTML attributes
16559 ###
16560
16561 !! test
16562 div with no attributes
16563 !! wikitext
16564 <div>HTML rocks</div>
16565 !! html
16566 <div>HTML rocks</div>
16567
16568 !! end
16569
16570 !! test
16571 div with double-quoted attribute
16572 !! wikitext
16573 <div id="rock">HTML rocks</div>
16574 !! html
16575 <div id="rock">HTML rocks</div>
16576
16577 !! end
16578
16579 !! test
16580 div with single-quoted attribute
16581 !! wikitext
16582 <div id='rock'>HTML rocks</div>
16583 !! html
16584 <div id="rock">HTML rocks</div>
16585
16586 !! end
16587
16588 !! test
16589 div with unquoted attribute
16590 !! wikitext
16591 <div id=rock>HTML rocks</div>
16592 !! html
16593 <div id="rock">HTML rocks</div>
16594
16595 !! end
16596
16597 !! test
16598 div with illegal double attributes
16599 !! wikitext
16600 <div id="a" id="b">HTML rocks</div>
16601 !! html
16602 <div id="b">HTML rocks</div>
16603
16604 !!end
16605
16606 !! test
16607 div with empty attribute value, space before equals
16608 !! options
16609 parsoid=wt2html,html2html
16610 !! wikitext
16611 <div class =>HTML rocks</div>
16612 !! html/php
16613 <div class="">HTML rocks</div>
16614
16615 !! html/parsoid
16616 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
16617 !! end
16618
16619 !! test
16620 div with multiple empty attribute values
16621 !! options
16622 parsoid=wt2html,html2html
16623 !! wikitext
16624 <div id= title=>HTML rocks</div>
16625 !! html/php
16626 <div id="title.3D">HTML rocks</div>
16627
16628 !! html/parsoid
16629 <div id="title.3D" data-parsoid='{"stx":"html"}'>HTML rocks</div>
16630 !! end
16631
16632 !! test
16633 table with multiple empty attribute values
16634 !! options
16635 parsoid=wt2html,html2html
16636 !! wikitext
16637 {| title= id=
16638 | hi
16639 |}
16640 !! html/php
16641 <table title="id=">
16642 <tr>
16643 <td> hi
16644 </td></tr></table>
16645
16646 !! html/parsoid
16647 <table title="id=">
16648 <tbody><tr><td> hi</td></tr>
16649 </tbody></table>
16650 !! end
16651
16652 !! test
16653 div with braces in attribute value
16654 !! wikitext
16655 <div title="{}">Foo</div>
16656 !! html/php
16657 <div title="&#123;&#125;">Foo</div>
16658
16659 !! html/parsoid
16660 <div title="{}">Foo</div>
16661 !! end
16662
16663 !! test
16664 div with empty attribute value, no space before equals
16665 !! options
16666 parsoid=wt2html,html2html
16667 !! wikitext
16668 <div class=>HTML rocks</div>
16669 !! html/php
16670 <div class="">HTML rocks</div>
16671
16672 !! html/parsoid
16673 <div class="">HTML rocks</div>
16674 !! end
16675
16676 !! test
16677 HTML multiple attributes correction
16678 !! wikitext
16679 <p class="error" class="awesome">Awesome!</p>
16680 !! html
16681 <p class="awesome">Awesome!</p>
16682
16683 !!end
16684
16685 !! test
16686 Table multiple attributes correction
16687 !! wikitext
16688 {|
16689 !+ class="error" class="awesome"| status
16690 |}
16691 !! html
16692 <table>
16693 <tr>
16694 <th class="awesome"> status
16695 </th></tr></table>
16696
16697 !!end
16698
16699 !! test
16700 DIV IN UPPERCASE
16701 !! wikitext
16702 <DIV ID="x">HTML ROCKS</DIV>
16703 !! html
16704 <div id="x">HTML ROCKS</div>
16705
16706 !!end
16707
16708 !! test
16709 Non-ASCII pseudo-tags are rendered as text
16710 !! wikitext
16711 <khyô>
16712 !! html
16713 <p>&lt;khyô&gt;
16714 </p>
16715 !! end
16716
16717 !! test
16718 Pseudo-tag with URL 'name' renders as url link
16719 !! wikitext
16720 <http://example.com/>
16721 !! html
16722 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
16723 </p>
16724 !! end
16725
16726 !! test
16727 text with amp in the middle of nowhere
16728 !! wikitext
16729 Remember AT&T?
16730 !! html
16731 <p>Remember AT&amp;T?
16732 </p>
16733 !! end
16734
16735 !! test
16736 text with character entity: eacute
16737 !! wikitext
16738 I always thought &eacute; was a cute letter.
16739 !! html
16740 <p>I always thought &#233; was a cute letter.
16741 </p>
16742 !! html+tidy
16743 <p>I always thought é was a cute letter.</p>
16744 !! end
16745
16746 !! test
16747 text with entity-escaped character entity-like string: eacute
16748 !! wikitext
16749 I always thought &amp;eacute; was a cute letter.
16750 !! html
16751 <p>I always thought &amp;eacute; was a cute letter.
16752 </p>
16753 !! end
16754
16755 !! test
16756 text with undefined character entity: xacute
16757 !! wikitext
16758 I always thought &xacute; was a cute letter.
16759 !! html
16760 <p>I always thought &amp;xacute; was a cute letter.
16761 </p>
16762 !! end
16763
16764 !! test
16765 HTML5 tags
16766 !! wikitext
16767 <data value="5">five</data>
16768 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
16769 <mark>This highlighted text</mark>
16770 !! html
16771 <p><data value="5">five</data>
16772 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
16773 <mark>This highlighted text</mark>
16774 </p>
16775 !! end
16776
16777 !! test
16778 HTML tag with leading space is parsed as text
16779 !! wikitext
16780 < div>foo< /div>
16781 !! html
16782 <p>&lt; div&gt;foo&lt; /div&gt;
16783 </p>
16784 !! end
16785
16786 ###
16787 ### Nesting tests (see T43545, T52604, T53081)
16788 ###
16789
16790 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
16791 # Note that html2wt is considerably more difficult if we use <b> in
16792 # the test case, instead of <small>
16793 !! test
16794 Ensure that HTML adoption agency algorithm is properly implemented.
16795 !! wikitext
16796 <small>X<small>Y</small>Z</small>
16797 !! html
16798 <p><small>X<small>Y</small>Z</small>
16799 </p>
16800 !! end
16801
16802 # This was T43545 in the PHP parser.
16803 # Note that tidy doesn't handle this correctly.
16804 !! test
16805 Nesting of <kbd>
16806 !! wikitext
16807 <kbd>X<kbd>Y</kbd>Z</kbd>
16808 !! html
16809 <p><kbd>X<kbd>Y</kbd>Z</kbd>
16810 </p>
16811 !! end
16812
16813 # The following cases were T53081 in the PHP parser.
16814 # Note that there are some other nestable tags (b, i, etc) which are
16815 # not covered; see T53081 for discussion.
16816
16817 # Note that tidy doesn't handle this correctly.
16818 !! test
16819 Nesting of <em>
16820 !! wikitext
16821 <em>X<em>Y</em>Z</em>
16822 !! html
16823 <p><em>X<em>Y</em>Z</em>
16824 </p>
16825 !! end
16826
16827 # Note that tidy doesn't handle this correctly.
16828 !! test
16829 Nesting of <strong>
16830 !! wikitext
16831 <strong>X<strong>Y</strong>Z</strong>
16832 !! html
16833 <p><strong>X<strong>Y</strong>Z</strong>
16834 </p>
16835 !! end
16836
16837 !! test
16838 Nesting of <q>
16839 !! wikitext
16840 <q>X<q>Y</q>Z</q>
16841 !! html+tidy
16842 <p><q>X<q>Y</q>Z</q></p>
16843 !! end
16844
16845 # Note that tidy doesn't handle this correctly.
16846 !! test
16847 Nesting of <ruby>
16848 !! wikitext
16849 <ruby>X<ruby>Y</ruby>Z</ruby>
16850 !! html
16851 <p><ruby>X<ruby>Y</ruby>Z</ruby>
16852 </p>
16853 !! end
16854
16855 # Note that tidy doesn't handle this correctly.
16856 !! test
16857 Nesting of <bdo>
16858 !! wikitext
16859 <bdo>X<bdo>Y</bdo>Z</bdo>
16860 !! html
16861 <p><bdo>X<bdo>Y</bdo>Z</bdo>
16862 </p>
16863 !! end
16864
16865
16866 ###
16867 ### Media links
16868 ###
16869
16870 !! test
16871 Media link
16872 !! wikitext
16873 [[Media:Foobar.jpg]]
16874 !! html/php
16875 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
16876 </p>
16877 !! html/parsoid
16878 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a></p>
16879 !! end
16880
16881 !! test
16882 Media link with text
16883 !! wikitext
16884 [[Media:Foobar.jpg|A neat file to look at]]
16885 !! html/php
16886 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
16887 </p>
16888 !! html/parsoid
16889 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
16890 !! end
16891
16892 # FIXME: this is still bad HTML tag nesting
16893 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
16894 !! test
16895 Media link with nasty text
16896 !! wikitext
16897 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
16898 !! html/php
16899 <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>
16900
16901 !! html+php/tidy
16902 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link</a></p>
16903 <div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div>
16904 !! html/parsoid
16905 <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>
16906
16907 !! end
16908
16909 !! test
16910 Media link to nonexistent file (T3702)
16911 !! wikitext
16912 [[Media:No such.jpg]]
16913 [[Media:No_such file.jpg]]
16914 !! html/php
16915 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
16916 <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>
16917 </p>
16918 !! html/parsoid
16919 <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>
16920 <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>
16921 !! end
16922
16923 !! test
16924 Image link to nonexistent file (T3850 - good)
16925 !! wikitext
16926 [[File:No_such.jpg]]
16927 !! html/php
16928 <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>
16929 </p>
16930 !! html/parsoid
16931 <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>
16932 !! end
16933
16934 !! test
16935 :Image link to nonexistent file (T3850 - bad)
16936 !! wikitext
16937 [[:Image:No such.jpg]]
16938 !! html/php
16939 <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>
16940 </p>
16941 !! html/parsoid
16942 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
16943 !! end
16944
16945
16946
16947 !! test
16948 Character reference normalization in link text (T3938)
16949 !! wikitext
16950 [[Main Page|this&that]]
16951 !! html
16952 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
16953 </p>
16954 !!end
16955
16956 !! article
16957 אַ
16958 !! text
16959 Test for unicode normalization
16960
16961 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
16962 !! endarticle
16963
16964 !! test
16965 (T21451) Links should refer to the normalized form.
16966 !! wikitext
16967 [[&#xFB2E;]]
16968 [[&#x5d0;&#x5b7;]]
16969 [[&#x5d0;ַ]]
16970 [[א&#x5b7;]]
16971 [[אַ]]
16972 !! html
16973 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
16974 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
16975 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
16976 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
16977 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
16978 </p>
16979 !! end
16980
16981 !! test
16982 Empty attribute crash test (T4067)
16983 !! wikitext
16984 <font color="">foo</font>
16985 !! html
16986 <p><font color="">foo</font>
16987 </p>
16988 !! end
16989
16990 !! test
16991 Empty attribute crash test single-quotes (T4067)
16992 !! wikitext
16993 <font color=''>foo</font>
16994 !! html
16995 <p><font color="">foo</font>
16996 </p>
16997 !! end
16998
16999 !! test
17000 Attribute test: equals, then nothing
17001 !! options
17002 parsoid=wt2html,html2html
17003 !! wikitext
17004 <font color=>foo</font>
17005 !! html/php
17006 <p><font color="">foo</font>
17007 </p>
17008 !! html/parsoid
17009 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
17010 !! end
17011
17012 !! test
17013 Attribute test: unquoted value
17014 !! options
17015 parsoid=wt2html,html2html
17016 !! wikitext
17017 <font color=x>foo</font>
17018 !! html/php
17019 <p><font color="x">foo</font>
17020 </p>
17021 !! html/parsoid
17022 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
17023 !! end
17024
17025 !! test
17026 Attribute test: unquoted but illegal value (hash)
17027 !! wikitext
17028 <font color=#x>foo</font>
17029 !! html
17030 <p><font color="#x">foo</font>
17031 </p>
17032 !! end
17033
17034 # Parsoid does not serialize to empty attribute syntax,
17035 # so wt2wt and html2wt cases are skipped
17036 !! test
17037 Attribute test: no value (T54330)
17038 !! options
17039 parsoid=wt2html,html2html
17040 !! wikitext
17041 <font color>foo</font>
17042 !! html/php
17043 <p><font color="">foo</font>
17044 </p>
17045 !! html/parsoid
17046 <p><font color="">foo</font></p>
17047 !! end
17048
17049 !! test
17050 T4095: link with three closing brackets
17051 !! wikitext
17052 [[Main Page]]]
17053 !! html/php
17054 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
17055 </p>
17056 !! html/parsoid
17057 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
17058 !! end
17059
17060 !! test
17061 T4095: link with pipe and three closing brackets
17062 !! wikitext
17063 [[Main Page|link]]]
17064 !! html/php
17065 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
17066 </p>
17067 !! html/parsoid
17068 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
17069 !! end
17070
17071 !! test
17072 T4095: link with pipe and three closing brackets, version 2
17073 !! wikitext
17074 [[Main Page|[http://example.com/]]]
17075 !! html/php
17076 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
17077 </p>
17078 !! html/parsoid
17079 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
17080 !! end
17081
17082
17083 ###
17084 ### Safety
17085 ###
17086
17087 !! article
17088 Template:Dangerous attribute
17089 !! text
17090 " onmouseover="alert(document.cookie)
17091 !! endarticle
17092
17093 !! article
17094 Template:Dangerous style attribute
17095 !! text
17096 border-size: expression(alert(document.cookie))
17097 !! endarticle
17098
17099 !! article
17100 Template:Div style
17101 !! text
17102 <div style="float: right; {{{1}}}">Magic div</div>
17103 !! endarticle
17104
17105 !! test
17106 T4304: HTML attribute safety (safe template; regression T4309)
17107 !! wikitext
17108 <div title="{{test}}"></div>
17109 !! html/php
17110 <div title="This is a test template"></div>
17111
17112 !! html/parsoid
17113 <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>
17114 !! end
17115
17116 # Parsoid has enough context to handle this case
17117 !! test
17118 T4304: HTML attribute safety (dangerous template; 2309)
17119 !! wikitext
17120 <div title="{{dangerous attribute}}"></div>
17121 !! html/php
17122 <div title=""></div>
17123
17124 !! html/parsoid
17125 <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>
17126 !! end
17127
17128 !! test
17129 T4304: HTML attribute safety (dangerous style template; 2309)
17130 !! wikitext
17131 <div style="{{dangerous style attribute}}"></div>
17132 !! html/php
17133 <div style="/* insecure input */"></div>
17134
17135 !! html/parsoid
17136 <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>
17137 !! end
17138
17139 !! test
17140 T4304: HTML attribute safety (safe parameter; 2309)
17141 !! wikitext
17142 {{div style|width: 200px}}
17143 !! html/php
17144 <div style="float: right; width: 200px">Magic div</div>
17145
17146 !! html/parsoid
17147 <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>
17148 !! end
17149
17150 !! test
17151 T4304: HTML attribute safety (unsafe parameter; 2309)
17152 !! wikitext
17153 {{div style|width: expression(alert(document.cookie))}}
17154 !! html/php
17155 <div style="/* insecure input */">Magic div</div>
17156
17157 !! html/parsoid
17158 <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>
17159 !! end
17160
17161 ## Parsoid output here differs; needs investigation.
17162 !! test
17163 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
17164 !! wikitext
17165 {{div style|"><script>alert(document.cookie)</script>}}
17166 !! html
17167 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17168
17169 !! end
17170
17171 ## Parsoid output here differs; needs investigation.
17172 !! test
17173 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
17174 !! wikitext
17175 {{div style|" ><script>alert(document.cookie)</script>}}
17176 !! html
17177 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17178
17179 !! end
17180
17181 !! test
17182 T4304: HTML attribute safety (link)
17183 !! wikitext
17184 <div title="[[Main Page]]"></div>
17185 !! html
17186 <div title="&#91;&#91;Main Page]]"></div>
17187
17188 !! end
17189
17190 !! test
17191 T4304: HTML attribute safety (italics)
17192 !! wikitext
17193 <div title="''foobar''"></div>
17194 !! html
17195 <div title="&#39;&#39;foobar&#39;&#39;"></div>
17196
17197 !! end
17198
17199 !! test
17200 T4304: HTML attribute safety (bold)
17201 !! wikitext
17202 <div title="'''foobar'''"></div>
17203 !! html
17204 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
17205
17206 !! end
17207
17208 !! test
17209 T4304: HTML attribute safety (ISBN)
17210 !! wikitext
17211 <div title="ISBN 1234567890"></div>
17212 !! html
17213 <div title="&#73;SBN 1234567890"></div>
17214
17215 !! end
17216
17217 !! test
17218 T4304: HTML attribute safety (RFC)
17219 !! wikitext
17220 <div title="RFC 1234"></div>
17221 !! html
17222 <div title="&#82;FC 1234"></div>
17223
17224 !! end
17225
17226 !! test
17227 T4304: HTML attribute safety (PMID)
17228 !! wikitext
17229 <div title="PMID 1234567890"></div>
17230 !! html
17231 <div title="&#80;MID 1234567890"></div>
17232
17233 !! end
17234
17235 !! test
17236 T4304: HTML attribute safety (web link)
17237 !! wikitext
17238 <div title="http://example.com/"></div>
17239 !! html
17240 <div title="http&#58;//example.com/"></div>
17241
17242 !! end
17243
17244 !! test
17245 T4304: HTML attribute safety (named web link)
17246 !! wikitext
17247 <div title="[http://example.com/ link]"></div>
17248 !! html
17249 <div title="&#91;http&#58;//example.com/ link]"></div>
17250
17251 !! end
17252
17253 !! test
17254 T5244: HTML attribute safety (extension; safe)
17255 !! wikitext
17256 <div style="<nowiki>background:blue</nowiki>"></div>
17257 !! html/php
17258 <div style="background:blue"></div>
17259
17260 !! html/parsoid
17261 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
17262 !! end
17263
17264 !! test
17265 T5244: HTML attribute safety (extension; unsafe)
17266 !! wikitext
17267 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
17268 !! html/php
17269 <div style="/* insecure input */"></div>
17270
17271 !! html/parsoid
17272 <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>
17273 !! end
17274
17275 # More MSIE fun discovered by Tom Gilder
17276
17277 !! test
17278 MSIE CSS safety test: spurious slash
17279 !! wikitext
17280 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
17281 !! html/php
17282 <div style="/* insecure input */">evil</div>
17283
17284 !! html/parsoid
17285 <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>
17286 !! end
17287
17288 !! test
17289 MSIE CSS safety test: hex code
17290 !! wikitext
17291 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
17292 !! html/php
17293 <div style="/* insecure input */">evil</div>
17294
17295 !! html/parsoid
17296 <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>
17297 !! end
17298
17299 !! test
17300 MSIE CSS safety test: comment in url
17301 !! wikitext
17302 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
17303 !! html/php
17304 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
17305
17306 !! html/parsoid
17307 <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>
17308 !! end
17309
17310 !! test
17311 MSIE CSS safety test: comment in expression
17312 !! wikitext
17313 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
17314 !! html/php
17315 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
17316
17317 !! html/parsoid
17318 <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>
17319 !! end
17320
17321 !! test
17322 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
17323 !! wikitext
17324 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
17325 !! html/php
17326 <p style="/* invalid control char */">A</p>
17327
17328 !! html/parsoid
17329 <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>
17330 !! end
17331
17332 !! test
17333 MSIE 6 CSS safety test: Fullwidth (T57332)
17334 !! wikitext
17335 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
17336 <div style="top:EXPRESSION(alert())">B</div>
17337 !! html/php
17338 <p style="/* insecure input */">A</p>
17339 <div style="/* insecure input */">B</div>
17340
17341 !! html/parsoid
17342 <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>
17343 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
17344 !! end
17345
17346 !! test
17347 MSIE 6 CSS safety test: IPA extensions (T57332)
17348 !! wikitext
17349 <div style="background-image:uʀʟ(javascript:alert())">A</div>
17350 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
17351 !! html/php
17352 <div style="/* insecure input */">A</div>
17353 <p style="/* insecure input */">B</p>
17354
17355 !! html/parsoid
17356 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
17357 <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>
17358 !! end
17359
17360 !! test
17361 MSIE 6 CSS safety test: sup/sub script (T57332)
17362 !! wikitext
17363 <div style="background-image:url⁽javascript:alert())">A</div>
17364 <div style="background-image:url₍javascript:alert())">B</div>
17365 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
17366 !! html/php
17367 <div style="/* insecure input */">A</div>
17368 <div style="/* insecure input */">B</div>
17369 <p style="/* insecure input */">C</p>
17370
17371 !! html/parsoid
17372 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
17373 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
17374 <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>
17375 !! end
17376
17377 !! test
17378 Opera -o-link CSS
17379 !! options
17380 parsoid=wt2html,html2html
17381 !! wikitext
17382 <div
17383 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;"
17384 style="-o-link:attr(title);-o-link-source:current">X</div>
17385 !! html/php
17386 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
17387
17388 !! html/parsoid
17389 <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>
17390 !! end
17391
17392 !! test
17393 MSIE 6 CSS safety test: Repetition markers (T57332)
17394 !! wikitext
17395 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
17396 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
17397 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
17398 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
17399 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
17400 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
17401 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
17402 !! html/php
17403 <p style="/* insecure input */">A</p>
17404 <p style="/* insecure input */">B</p>
17405 <p style="/* insecure input */">C</p>
17406 <p style="/* insecure input */">D</p>
17407 <p style="/* insecure input */">E</p>
17408 <p style="/* insecure input */">F</p>
17409 <p style="/* insecure input */">G</p>
17410
17411 !! html/parsoid
17412 <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>
17413 <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>
17414 <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>
17415 <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>
17416 <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>
17417 <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>
17418 <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>
17419 !! end
17420
17421 !! test
17422 Table attribute legitimate extension
17423 !! wikitext
17424 {|
17425 !+ style="<nowiki>color:blue</nowiki>"| status
17426 |}
17427 !! html
17428 <table>
17429 <tr>
17430 <th style="color:blue"> status
17431 </th></tr></table>
17432
17433 !!end
17434
17435 !! test
17436 Table attribute safety
17437 !! wikitext
17438 {|
17439 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
17440 |}
17441 !! html
17442 <table>
17443 <tr>
17444 <th style="/* insecure input */"> status
17445 </th></tr></table>
17446
17447 !! end
17448
17449 !! test
17450 CSS line continuation 1
17451 !! wikitext
17452 <div style="background-image: u\&#10;rl(test.jpg);"></div>
17453 !! html
17454 <div style="/* insecure input */"></div>
17455
17456 !! end
17457
17458 !! test
17459 CSS line continuation 2
17460 !! wikitext
17461 <div style="background-image: u\&#13;rl(test.jpg); "></div>
17462 !! html
17463 <div style="/* invalid control char */"></div>
17464
17465 !! end
17466
17467 !! article
17468 Template:Identity
17469 !! text
17470 {{{1}}}
17471 !! endarticle
17472
17473 !! test
17474 Expansion of multi-line templates in attribute values (T8255)
17475 !! wikitext
17476 <div style="background: {{identity|#00FF00}}">-</div>
17477 !! html
17478 <div style="background: #00FF00">-</div>
17479
17480 !! end
17481
17482 !! test
17483 Expansion of multi-line templates in attribute values (T8255 sanity check)
17484 !! wikitext
17485 <div style="background:
17486 #00FF00">-</div>
17487 !! html/php
17488 <div style="background: #00FF00">-</div>
17489
17490 !! html/parsoid
17491 <div style="background:
17492 #00FF00">-</div>
17493 !! end
17494
17495 !! test
17496 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
17497 !! wikitext
17498 <div style="background: &#10;#00FF00">-</div>
17499 !! html
17500 <div style="background: &#10;#00FF00">-</div>
17501
17502 !! end
17503
17504 !! test
17505 Tags which are hidden from Tidy cannot pass through the Sanitizer
17506 !! wikitext
17507 <mw:toc><script>alert();</script></mw:toc>
17508 !! html+tidy
17509 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;</p>
17510 !! end
17511
17512 ###
17513 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
17514 ###
17515
17516 !! test
17517 Parser hook: empty input
17518 !! wikitext
17519 <tag></tag>
17520 !! html/php
17521 <pre>
17522 ''
17523 array (
17524 )
17525 </pre>
17526
17527 !! html/parsoid
17528 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17529 !! end
17530
17531 ## Don't expect parsoid to rt this form.
17532 !! test
17533 Parser hook: empty input using terminated empty elements
17534 !! options
17535 parsoid=wt2html,html2html
17536 !! wikitext
17537 <tag/>
17538 !! html/php
17539 <pre>
17540 NULL
17541 array (
17542 )
17543 </pre>
17544
17545 !! html/parsoid
17546 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
17547 !! end
17548
17549 !! test
17550 Parser hook: empty input using terminated empty elements (space before)
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: basic input
17566 !! wikitext
17567 <tag>input</tag>
17568 !! html/php
17569 <pre>
17570 'input'
17571 array (
17572 )
17573 </pre>
17574
17575 !! html/parsoid
17576 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
17577 !! end
17578
17579 ## Don't expect parsoid to rt this form.
17580 !! test
17581 Parser hook: case insensitive
17582 !! options
17583 parsoid=wt2html,html2html
17584 !! wikitext
17585 <TAG>input</TAG>
17586 !! html/php
17587 <pre>
17588 'input'
17589 array (
17590 )
17591 </pre>
17592
17593 !! html/parsoid
17594 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
17595 !! end
17596
17597 ## Don't expect parsoid to rt this form.
17598 !! test
17599 Parser hook: case insensitive, redux
17600 !! options
17601 parsoid=wt2html,html2html
17602 !! wikitext
17603 <TaG>input</TAg>
17604 !! html/php
17605 <pre>
17606 'input'
17607 array (
17608 )
17609 </pre>
17610
17611 !! html/parsoid
17612 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
17613 !! end
17614
17615 !! test
17616 Parser hook: nested tags
17617 !! wikitext
17618 <tag><tag></tag></tag>
17619 !! html/php
17620 <pre>
17621 '<tag>'
17622 array (
17623 )
17624 </pre>&lt;/tag&gt;
17625
17626 !! html/parsoid
17627 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}' data-parsoid='{}' about="#mwt2"></pre>&lt;/tag>
17628 !! end
17629
17630 !! test
17631 Parser hook: basic arguments
17632 !! wikitext
17633 <tag width="200" height="100" depth="50" square=""></tag>
17634 !! html/php
17635 <pre>
17636 ''
17637 array (
17638 'width' => '200',
17639 'height' => '100',
17640 'depth' => '50',
17641 'square' => '',
17642 )
17643 </pre>
17644
17645 !! html/parsoid
17646 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17647 !! end
17648
17649 ## Don't expect parsoid to rt this form.
17650 !! test
17651 Parser hook: basic arguments, variations
17652 !! options
17653 parsoid=wt2html,html2html
17654 !! wikitext
17655 <tag width=200 height = "100" depth = '50' square></tag>
17656 !! html/php
17657 <pre>
17658 ''
17659 array (
17660 'width' => '200',
17661 'height' => '100',
17662 'depth' => '50',
17663 'square' => '',
17664 )
17665 </pre>
17666
17667 !! html/parsoid
17668 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17669 !! end
17670
17671 !! test
17672 Parser hook: argument containing a forward slash (T7344)
17673 !! wikitext
17674 <tag filename="/tmp/bla"></tag>
17675 !! html/php
17676 <pre>
17677 ''
17678 array (
17679 'filename' => '/tmp/bla',
17680 )
17681 </pre>
17682
17683 !! html/parsoid
17684 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17685 !! end
17686
17687 ## Don't expect parsoid to rt this form.
17688 !! test
17689 Parser hook: empty input using terminated empty elements (T4374)
17690 !! options
17691 parsoid=wt2html,html2html
17692 !! wikitext
17693 <tag foo=bar/>text
17694 !! html/php
17695 <pre>
17696 NULL
17697 array (
17698 'foo' => 'bar',
17699 )
17700 </pre>text
17701
17702 !! html/parsoid
17703 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text
17704 !! end
17705
17706 ## </tag> should be output literally since there is no matching tag that begins it
17707 ## Don't expect parsoid to rt this form.
17708 !! test
17709 Parser hook: basic arguments using terminated empty elements (T4374)
17710 !! options
17711 parsoid=wt2html
17712 !! wikitext
17713 <tag width=200 height = "100" depth = '50' square/>
17714 other stuff
17715 </tag>
17716 !! html/php
17717 <pre>
17718 NULL
17719 array (
17720 'width' => '200',
17721 'height' => '100',
17722 'depth' => '50',
17723 'square' => '',
17724 )
17725 </pre>
17726 <p>other stuff
17727 &lt;/tag&gt;
17728 </p>
17729 !! html/parsoid
17730 <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
17731 &lt;/tag></p>
17732 !! end
17733
17734 ## Don't expect parsoid to rt this form.
17735 !! test
17736 Parser hook: Don't allow unclosed extension tags
17737 !! options
17738 parsoid=wt2html
17739 !! wikitext
17740 test <tag>123
17741
17742 this is a '''test'''
17743 !! html/php
17744 <p>test &lt;tag&gt;123
17745 </p><p>this is a <b>test</b>
17746 </p>
17747 !! html/parsoid
17748 <p>test &lt;tag>123</p>
17749
17750 <p>this is a <b>test</b></p>
17751 !! end
17752
17753 ###
17754 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
17755 ###
17756
17757 !! test
17758 Parser hook: static parser hook not inside a comment
17759 !! wikitext
17760 <statictag>hello, world</statictag>
17761
17762 <statictag action="flush" />
17763 !! html/php
17764 <p><br />
17765 hello, world
17766 </p>
17767 !! html/parsoid
17768 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
17769 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p>
17770 !! end
17771
17772 !! test
17773 Parser hook: static parser hook inside a comment
17774 !! wikitext
17775 <!-- <statictag>hello, world</statictag> -->
17776 <statictag action="flush" />
17777 !! html/php
17778 <p><br />
17779 </p>
17780 !! html/parsoid
17781 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
17782 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt2"></p>
17783 !! end
17784
17785 # Nested template calls; this case was broken by Parser.php rev 1.506,
17786 # since reverted.
17787
17788 !! article
17789 Template:One-parameter
17790 !! text
17791 (My parameter is: {{{1}}})
17792 !! endarticle
17793
17794 !! article
17795 Template:Map-one-parameter
17796 !! text
17797 {{{{{1}}}|{{{2}}}}}
17798 !! endarticle
17799
17800 !! test
17801 Nested template calls
17802 !! wikitext
17803 {{Map-one-parameter|One-parameter|param}}
17804 !! html
17805 <p>(My parameter is: param)
17806 </p>
17807 !! end
17808
17809
17810 ###
17811 ### Sanitizer
17812 ###
17813
17814 # HTML+Tidy effectively strips out the empty tags completely
17815 # But since Parsoid doesn't it wraps the <s></s> tags in p-tags
17816 # which Tidy would have done for the PHP parser had there been content inside it.
17817 !! test
17818 Sanitizer: Closing of open tags
17819 !! wikitext
17820 <s></s><table></table>
17821 !! html
17822 <s></s><table></table>
17823
17824 !! html/parsoid
17825 <p><s></s></p><table></table>
17826 !! end
17827
17828 !! test
17829 Sanitizer: Closing of open but not closed tags
17830 !! wikitext
17831 <s>foo
17832 !! html
17833 <p><s>foo</s>
17834 </p>
17835 !! end
17836
17837 !! test
17838 Sanitizer: Closing of closed but not open tags
17839 !! options
17840 parsoid=wt2html
17841 !! wikitext
17842 </s>
17843 !! html/php+tidy
17844 !! html/parsoid
17845 !! end
17846
17847 !! test
17848 Sanitizer: Closing of closed but not open table tags
17849 !! options
17850 parsoid=wt2html
17851 !! wikitext
17852 Table not started</td></tr></table>
17853 !! html/php+tidy
17854 <p>Table not started</p>
17855 !! html/parsoid
17856 <p>Table not started</p>
17857 !! end
17858
17859 !! test
17860 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
17861 !! wikitext
17862 <span id="æ: v">byte</span>[[#æ: v|backlink]]
17863 !! html/php
17864 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
17865 </p>
17866 !! html/parsoid
17867 <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>
17868 !! end
17869
17870 # In HTML5, the restrictions are that id must contain at least one character,
17871 # and must not contain any space characters.
17872 !! test
17873 Sanitizer: Validating the contents of the id attribute (T6515)
17874 !! options
17875 disabled
17876 !! wikitext
17877 <br id="" /><br id="a space" />
17878 !! html
17879 Something ...
17880 !! end
17881
17882 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
17883 !! test
17884 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
17885 !! options
17886 disabled
17887 !! wikitext
17888 <br id="foo" /><br id="foo" />
17889 !! html
17890 Something need to be done. foo-2 ?
17891 !! end
17892
17893 !! test
17894 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
17895 !! wikitext
17896 <div itemscope>
17897 <meta itemprop="hello" content="world">
17898 <meta http-equiv="refresh" content="5">
17899 <meta itemprop="hello" http-equiv="refresh" content="5">
17900 <link itemprop="hello" href="{{SERVER}}">
17901 <link rel="stylesheet" href="{{SERVER}}">
17902 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
17903 </div>
17904 !! html
17905 <div itemscope="">
17906 <p> <meta itemprop="hello" content="world" />
17907 &lt;meta http-equiv="refresh" content="5"&gt;
17908 <meta itemprop="hello" content="5" />
17909 <link itemprop="hello" href="http&#58;//example.org" />
17910 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
17911 <link itemprop="hello" href="http&#58;//example.org" />
17912 </p>
17913 </div>
17914
17915 !! end
17916
17917 !! test
17918 Sanitizer: Strip comments from CSS attributes
17919 !! options
17920 parsoid=wt2html,wt2wt
17921 !! wikitext
17922 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
17923 !! html/php
17924 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
17925 </p>
17926 !! html/parsoid
17927 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
17928 !! end
17929
17930 !! test
17931 Language converter: output gets cut off unexpectedly (T7757)
17932 !! options
17933 language=zh
17934 !! wikitext
17935 this bit is safe: }-
17936
17937 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
17938
17939 then we get cut off here: }-
17940
17941 all additional text is vanished
17942 !! html
17943 <p>this bit is safe: }-
17944 </p><p>but if we add a conversion instance: xxx
17945 </p><p>then we get cut off here: }-
17946 </p><p>all additional text is vanished
17947 </p>
17948 !! end
17949
17950 !! test
17951 Self closed html pairs (T7487)
17952 !! wikitext
17953 <center><font id="bug" />Centered text</center>
17954 <div><font id="bug2" />In div text</div>
17955 !! html+tidy
17956 <center><font id="bug"></font>Centered text</center>
17957 <div><font id="bug2"></font>In div text</div>
17958 !! end
17959
17960 #
17961 #
17962 #
17963
17964 !! test
17965 Punctuation: nbsp before exclamation
17966 !! wikitext
17967 C'est grave !
17968 !! html
17969 <p>C'est grave&#160;!
17970 </p>
17971 !! end
17972
17973 !! test
17974 Punctuation: CSS !important (T13874)
17975 !! wikitext
17976 <div style="width:50% !important">important</div>
17977 !! html
17978 <div style="width:50% !important">important</div>
17979
17980 !!end
17981
17982 !! test
17983 Punctuation: CSS ! important (T13874; with space after)
17984 !! wikitext
17985 <div style="width:50% ! important">important</div>
17986 !! html
17987 <div style="width:50% ! important">important</div>
17988
17989 !!end
17990
17991 !! test
17992 HTML bullet list, closed tags (T7497)
17993 !! wikitext
17994 <ul>
17995 <li>One</li>
17996 <li>Two</li>
17997 </ul>
17998 !! html/php
17999 <ul>
18000 <li>One</li>
18001 <li>Two</li>
18002 </ul>
18003
18004 !! html/parsoid
18005 <ul data-parsoid='{"stx":"html"}'>
18006 <li data-parsoid='{"stx":"html"}'>One</li>
18007 <li data-parsoid='{"stx":"html"}'>Two</li>
18008 </ul>
18009
18010 !! end
18011
18012 !! test
18013 HTML bullet list, unclosed tags (T7497)
18014 !! wikitext
18015 <ul>
18016 <li>One
18017 <li>Two
18018 </ul>
18019 !! html/php+tidy
18020 <ul>
18021 <li>One</li>
18022 <li>Two</li>
18023 </ul>
18024 !! html/parsoid
18025 <ul data-parsoid='{"stx":"html"}'>
18026 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18027 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18028 </ul>
18029
18030 !! end
18031
18032 !! test
18033 HTML ordered list, closed tags (T7497)
18034 !! wikitext
18035 <ol>
18036 <li>One</li>
18037 <li>Two</li>
18038 </ol>
18039 !! html/php
18040 <ol>
18041 <li>One</li>
18042 <li>Two</li>
18043 </ol>
18044
18045 !! html/parsoid
18046 <ol data-parsoid='{"stx":"html"}'>
18047 <li data-parsoid='{"stx":"html"}'>One</li>
18048 <li data-parsoid='{"stx":"html"}'>Two</li>
18049 </ol>
18050
18051 !! end
18052
18053 !! test
18054 HTML ordered list, unclosed tags (T7497)
18055 !! options
18056 !! wikitext
18057 <ol>
18058 <li>One
18059 <li>Two
18060 </ol>
18061 !! html/php+tidy
18062 <ol>
18063 <li>One</li>
18064 <li>Two</li>
18065 </ol>
18066 !! html/parsoid
18067 <ol data-parsoid='{"stx":"html"}'>
18068 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18069 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18070 </ol>
18071
18072 !! end
18073
18074 !! test
18075 HTML nested bullet list, closed tags (T7497)
18076 !! wikitext
18077 <ul>
18078 <li>One</li>
18079 <li>Two:
18080 <ul>
18081 <li>Sub-one</li>
18082 <li>Sub-two</li>
18083 </ul>
18084 </li>
18085 </ul>
18086 !! html/php
18087 <ul>
18088 <li>One</li>
18089 <li>Two:
18090 <ul>
18091 <li>Sub-one</li>
18092 <li>Sub-two</li>
18093 </ul>
18094 </li>
18095 </ul>
18096
18097 !! html/parsoid
18098 <ul data-parsoid='{"stx":"html"}'>
18099 <li data-parsoid='{"stx":"html"}'>One</li>
18100 <li data-parsoid='{"stx":"html"}'>Two:
18101 <ul data-parsoid='{"stx":"html"}'>
18102 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
18103 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
18104 </ul>
18105 </li>
18106 </ul>
18107 !! end
18108
18109 !! test
18110 HTML nested bullet list, open tags (T7497)
18111 !! wikitext
18112 <ul>
18113 <li>One
18114 <li>Two:
18115 <ul>
18116 <li>Sub-one
18117 <li>Sub-two
18118 </ul>
18119 </ul>
18120 !! html/php+tidy
18121 <ul>
18122 <li>One</li>
18123 <li>Two:
18124 <ul>
18125 <li>Sub-one</li>
18126 <li>Sub-two</li>
18127 </ul>
18128 </li>
18129 </ul>
18130 !! html/parsoid
18131 <ul>
18132 <li>One
18133 </li>
18134 <li>Two:
18135 <ul>
18136 <li>Sub-one
18137 </li>
18138 <li>Sub-two
18139 </li>
18140 </ul>
18141 </li>
18142 </ul>
18143
18144 !! end
18145
18146 !! test
18147 HTML nested ordered list, closed tags (T7497)
18148 !! wikitext
18149 <ol>
18150 <li>One</li>
18151 <li>Two:
18152 <ol>
18153 <li>Sub-one</li>
18154 <li>Sub-two</li>
18155 </ol>
18156 </li>
18157 </ol>
18158 !! html
18159 <ol>
18160 <li>One</li>
18161 <li>Two:
18162 <ol>
18163 <li>Sub-one</li>
18164 <li>Sub-two</li>
18165 </ol>
18166 </li>
18167 </ol>
18168
18169 !! end
18170
18171 !! test
18172 HTML nested ordered list, open tags (T7497)
18173 !! wikitext
18174 <ol>
18175 <li>One
18176 <li>Two:
18177 <ol>
18178 <li>Sub-one
18179 <li>Sub-two
18180 </ol>
18181 </ol>
18182 !! html/php
18183 <ol>
18184 <li>One
18185 <li>Two:
18186 <ol>
18187 <li>Sub-one
18188 <li>Sub-two
18189 </ol>
18190 </ol>
18191
18192 !! html/parsoid
18193 <ol>
18194 <li>One
18195 </li>
18196 <li>Two:
18197 <ol>
18198 <li>Sub-one
18199 </li>
18200 <li>Sub-two
18201 </li>
18202 </ol>
18203 </li>
18204 </ol>
18205
18206 !! end
18207
18208 !! test
18209 HTML ordered list item with parameters oddity
18210 !! wikitext
18211 <ol><li id="fragment">One</li>
18212 </ol>
18213 !! html
18214 <ol><li id="fragment">One</li>
18215 </ol>
18216
18217 !! end
18218
18219 # parsoid doesn't explicitly mark autonumbered links, see T55505
18220 !!test
18221 T7918: autonumbering
18222 !! wikitext
18223 [http://first/] [http://second] [ftp://ftp]
18224
18225 ftp://inlineftp
18226
18227 [mailto:enclosed@mail.tld With target]
18228
18229 [mailto:enclosed@mail.tld]
18230
18231 mailto:inline@mail.tld
18232 !! html/php
18233 <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>
18234 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
18235 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
18236 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
18237 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
18238 </p>
18239 !! html/parsoid
18240 <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>
18241 <p><a rel="mw:ExtLink" href="ftp://inlineftp">ftp://inlineftp</a></p>
18242 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld">With target</a></p>
18243 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld"></a></p>
18244 <p><a rel="mw:ExtLink" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
18245 !! end
18246
18247
18248 #
18249 # Security and HTML correctness
18250 # From Nick Jenkins' fuzz testing
18251 #
18252
18253 !! test
18254 Fuzz testing: Parser13
18255 !! wikitext
18256 {|
18257 | http://a|
18258 !! html
18259 <table>
18260 <tr>
18261 <td>
18262 </td>
18263 </tr>
18264 </table>
18265
18266 !! end
18267
18268 !! test
18269 Fuzz testing: Parser14
18270 !! wikitext
18271 == onmouseover= ==
18272 http://__TOC__
18273 !! html
18274 <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>
18275 http://<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
18276 <ul>
18277 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18278 </ul>
18279 </div>
18280
18281
18282 !! html+tidy
18283 <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>
18284 <p>http://</p>
18285 <div id="toc" class="toc">
18286 <div class="toctitle">
18287 <h2>Contents</h2>
18288 </div>
18289 <ul>
18290 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18291 </ul>
18292 </div>
18293 <p></p>
18294 !! end
18295
18296 !! test
18297 Fuzz testing: Parser14-table
18298 !! options
18299 parsoid=wt2html,html2html
18300 !! wikitext
18301 ==a==
18302 {| STYLE=__TOC__
18303 !! html
18304 <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>
18305 <table style="&#95;_TOC&#95;_">
18306 <tr><td></td></tr>
18307 </table>
18308
18309 !! html+tidy
18310 <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>
18311 <table style="__TOC__">
18312 <tr>
18313 <td></td>
18314 </tr>
18315 </table>
18316 !! html/parsoid
18317 <h2>a</h2>
18318 <table style="__TOC__"></table>
18319 !! end
18320
18321 # Known to produce bogus xml (extra </td>)
18322 !! test
18323 Fuzz testing: Parser16
18324 !! wikitext
18325 {|
18326 !https://||||||
18327 !! html
18328 <table>
18329 <tr>
18330 <th>https://</th>
18331 <th></th>
18332 <th></th>
18333 <th>
18334 </td>
18335 </tr>
18336 </table>
18337
18338 !! html+tidy
18339 <table>
18340 <tr>
18341 <th>https://</th>
18342 <th></th>
18343 <th></th>
18344 <th></th>
18345 </tr>
18346 </table>
18347 !! end
18348
18349 !! test
18350 Fuzz testing: Parser21
18351 !! wikitext
18352 {|
18353 ! irc://{{ftp://a" onmouseover="alert('hello world');"
18354 |
18355 !! html
18356 <table>
18357 <tr>
18358 <th> <a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
18359 </th>
18360 <td>
18361 </td>
18362 </tr>
18363 </table>
18364
18365 !! end
18366
18367 !! test
18368 Fuzz testing: Parser22
18369 !! wikitext
18370 http://===r:::https://b
18371
18372 {|
18373 !! html
18374 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
18375 </p>
18376 <table>
18377 <tr><td></td></tr>
18378 </table>
18379
18380 !! end
18381
18382 # Known to produce bad XML for now
18383 !! test
18384 Fuzz testing: Parser24
18385 !! options
18386 parsoid=wt2html
18387 !! wikitext
18388 {|
18389 {{{|
18390 <u CLASS=
18391 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
18392 <br style="onmouseover='alert(document.cookie);' " />
18393
18394 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
18395 |
18396 !! html/php
18397 <table>
18398 {{{|
18399 <u class="&#124;">}}}} &gt;
18400 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
18401
18402 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
18403 <tr>
18404 <td></u>
18405 </td>
18406 </tr>
18407 </table>
18408
18409 !! html/parsoid
18410 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
18411 <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>"}'/>}}}} >
18412 <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}'>
18413
18414
18415
18416 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table>
18417 !! end
18418
18419 # Note: the current result listed for this is not what the original one was,
18420 # but the original bug was JavaScript injection, which is fixed in any case.
18421 # It's not clear that the original result listed was any more correct than the
18422 # current one. Original result:
18423 # <p>{{{|
18424 # </p>
18425 # <li class="&#124;&#124;">
18426 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
18427 !!test
18428 Fuzz testing: Parser25 (T8055)
18429 !! wikitext
18430 {{{
18431 |
18432 <LI CLASS=||
18433 >
18434 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
18435 !! html/php
18436 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
18437 </p>
18438 !! html/parsoid
18439 <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"]}'>
18440 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
18441 !! end
18442
18443 !!test
18444 Fuzz testing: URL adjacent extension (with space, clean)
18445 !! wikitext
18446 http://example.com <nowiki>junk</nowiki>
18447 !! html/php
18448 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
18449 </p>
18450 !! html/parsoid
18451 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a> <span typeof="mw:Nowiki">junk</span></p>
18452 !! end
18453
18454 !!test
18455 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
18456 !! wikitext
18457 http://example.com<nowiki>junk</nowiki>
18458 !! html/php
18459 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
18460 </p>
18461 !! html/parsoid
18462 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a><span typeof="mw:Nowiki">junk</span></p>
18463 !! end
18464
18465 !! test
18466 Fuzz testing: URL adjacent extension (no space, dirty; pre)
18467 !! wikitext
18468 http://example.com<pre>junk</pre>
18469 !! html/php
18470 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
18471
18472 !! html/php+tidy
18473 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p>
18474 <pre>
18475 junk
18476 </pre>
18477 !! html/parsoid
18478 <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>
18479 !! end
18480
18481 !! test
18482 Fuzz testing: image with bogus manual thumbnail
18483 !! wikitext
18484 [[Image:foobar.jpg|thumbnail= ]]
18485 !! html/php
18486 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
18487
18488 !! html/parsoid
18489 <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>
18490 !! end
18491
18492 !! test
18493 Fuzz testing: encoded newline in generated HTML replacements (T8577)
18494 !! wikitext
18495 <pre dir="&#10;"></pre>
18496 !! html/php
18497 <pre dir="&#10;"></pre>
18498
18499 !! html/parsoid
18500 <pre typeof="mw:Extension/pre" about="#mwt2" dir="&amp;#10;" data-mw='{"name":"pre","attrs":{"dir":"&amp;#10;"},"body":{"extsrc":""}}'></pre>
18501 !! end
18502
18503 !! test
18504 Parsing optional HTML elements (T8171)
18505 !! options
18506 !! wikitext
18507 <table>
18508 <tr>
18509 <td> Some tabular data</td>
18510 <td> More tabular data ...
18511 <td> And yet som tabular data</td>
18512 </tr>
18513 </table>
18514 !! html
18515 <table>
18516 <tr>
18517 <td> Some tabular data</td>
18518 <td> More tabular data ...
18519 </td><td> And yet som tabular data</td>
18520 </tr>
18521 </table>
18522
18523 !! end
18524
18525 !! test
18526 Correct handling of <td>, <tr> (T8171)
18527 !! options
18528 !! wikitext
18529 <table>
18530 <tr>
18531 <td> Some tabular data</td>
18532 <td> More tabular data ...</td>
18533 <td> And yet som tabular data</td>
18534 </tr>
18535 </table>
18536 !! html
18537 <table>
18538 <tr>
18539 <td> Some tabular data</td>
18540 <td> More tabular data ...</td>
18541 <td> And yet som tabular data</td>
18542 </tr>
18543 </table>
18544
18545 !! end
18546
18547
18548 !! test
18549 Parsing crashing regression (fr:JavaScript)
18550 !! wikitext
18551 </body></x>
18552 !! html
18553 <p>&lt;/body&gt;&lt;/x&gt;
18554 </p>
18555 !! end
18556
18557 !! test
18558 Inline wiki vs wiki block nesting
18559 !! wikitext
18560 '''Bold paragraph
18561
18562 New wiki paragraph
18563 !! html
18564 <p><b>Bold paragraph</b>
18565 </p><p>New wiki paragraph
18566 </p>
18567 !! end
18568
18569 # FIXME: The current php output is documented
18570 # and desired output is the parsoid target.
18571 !! test
18572 Inline HTML vs wiki block nesting
18573 !! wikitext
18574 <b>Bold paragraph
18575
18576 New wiki paragraph
18577 !! html/php
18578 <p><b>Bold paragraph
18579 </p><p>New wiki paragraph</b>
18580 </p>
18581 !! html/parsoid
18582 <p><b>Bold paragraph</b>
18583 </p><p>New wiki paragraph
18584 </p>
18585 !! end
18586
18587 # Original result was this:
18588 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
18589 # </p>
18590 # While that might be marginally more intuitive, maybe, the six-apostrophe
18591 # construct is clearly pathological and the result stated here (which is what
18592 # the parser actually does) is about as reasonable as anything.
18593 !!test
18594 Mixing markup for italics and bold
18595 !! options
18596 !! wikitext
18597 '''bold''''''bold''bolditalics'''''
18598 !! html
18599 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
18600 </p>
18601 !! end
18602
18603
18604 !! article
18605 Xyzzyx
18606 !! text
18607 Article for special page transclusion test
18608 !! endarticle
18609
18610 !! test
18611 Special page transclusion
18612 !! options
18613 !! wikitext
18614 {{Special:Prefixindex/Xyzzyx}}
18615 !! html
18616 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
18617 </ul>
18618
18619 !! end
18620
18621 !! test
18622 Special page transclusion twice (T7021)
18623 !! options
18624 !! wikitext
18625 {{Special:Prefixindex/Xyzzyx}}
18626 {{Special:Prefixindex/Xyzzyx}}
18627 !! html
18628 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
18629 </ul>
18630 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
18631 </ul>
18632
18633 !! end
18634
18635 !! test
18636 Transclusion of default MediaWiki message
18637 !! wikitext
18638 {{MediaWiki:Mainpage}}
18639 !! html
18640 <p>Main Page
18641 </p>
18642 !! end
18643
18644 !! test
18645 Transclusion of nonexistent MediaWiki message
18646 !! wikitext
18647 {{MediaWiki:Mainpagexxx}}
18648 !! html
18649 <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>
18650 </p>
18651 !! end
18652
18653 !! test
18654 Transclusion of MediaWiki message with underscore
18655 !! wikitext
18656 {{MediaWiki:history_short}}
18657 !! html
18658 <p>History
18659 </p>
18660 !! end
18661
18662 !! test
18663 Transclusion of MediaWiki message with space
18664 !! wikitext
18665 {{MediaWiki:history short}}
18666 !! html
18667 <p>History
18668 </p>
18669 !! end
18670
18671 !! test
18672 Invalid header with following text
18673 !! wikitext
18674 = x = y
18675 !! html
18676 <p>= x = y
18677 </p>
18678 !! end
18679
18680
18681 !! test
18682 Section extraction test (section 0)
18683 !! options
18684 section=0
18685 !! wikitext
18686 start
18687 ==a==
18688 ===aa===
18689 ====aaa====
18690 ==b==
18691 ===ba===
18692 ===bb===
18693 ====bba====
18694 ===bc===
18695 ==c==
18696 ===ca===
18697 !! html/php
18698 start
18699 !! end
18700
18701 !! test
18702 Section extraction test (section 1)
18703 !! options
18704 section=1
18705 !! wikitext
18706 start
18707 ==a==
18708 ===aa===
18709 ====aaa====
18710 ==b==
18711 ===ba===
18712 ===bb===
18713 ====bba====
18714 ===bc===
18715 ==c==
18716 ===ca===
18717 !! html/php
18718 ==a==
18719 ===aa===
18720 ====aaa====
18721 !! end
18722
18723 !! test
18724 Section extraction test (section 2)
18725 !! options
18726 section=2
18727 !! wikitext
18728 start
18729 ==a==
18730 ===aa===
18731 ====aaa====
18732 ==b==
18733 ===ba===
18734 ===bb===
18735 ====bba====
18736 ===bc===
18737 ==c==
18738 ===ca===
18739 !! html/php
18740 ===aa===
18741 ====aaa====
18742 !! end
18743
18744 !! test
18745 Section extraction test (section 3)
18746 !! options
18747 section=3
18748 !! wikitext
18749 start
18750 ==a==
18751 ===aa===
18752 ====aaa====
18753 ==b==
18754 ===ba===
18755 ===bb===
18756 ====bba====
18757 ===bc===
18758 ==c==
18759 ===ca===
18760 !! html/php
18761 ====aaa====
18762 !! end
18763
18764 !! test
18765 Section extraction test (section 4)
18766 !! options
18767 section=4
18768 !! wikitext
18769 start
18770 ==a==
18771 ===aa===
18772 ====aaa====
18773 ==b==
18774 ===ba===
18775 ===bb===
18776 ====bba====
18777 ===bc===
18778 ==c==
18779 ===ca===
18780 !! html/php
18781 ==b==
18782 ===ba===
18783 ===bb===
18784 ====bba====
18785 ===bc===
18786 !! end
18787
18788 !! test
18789 Section extraction test (section 5)
18790 !! options
18791 section=5
18792 !! wikitext
18793 start
18794 ==a==
18795 ===aa===
18796 ====aaa====
18797 ==b==
18798 ===ba===
18799 ===bb===
18800 ====bba====
18801 ===bc===
18802 ==c==
18803 ===ca===
18804 !! html/php
18805 ===ba===
18806 !! end
18807
18808 !! test
18809 Section extraction test (section 6)
18810 !! options
18811 section=6
18812 !! wikitext
18813 start
18814 ==a==
18815 ===aa===
18816 ====aaa====
18817 ==b==
18818 ===ba===
18819 ===bb===
18820 ====bba====
18821 ===bc===
18822 ==c==
18823 ===ca===
18824 !! html/php
18825 ===bb===
18826 ====bba====
18827 !! end
18828
18829 !! test
18830 Section extraction test (section 7)
18831 !! options
18832 section=7
18833 !! wikitext
18834 start
18835 ==a==
18836 ===aa===
18837 ====aaa====
18838 ==b==
18839 ===ba===
18840 ===bb===
18841 ====bba====
18842 ===bc===
18843 ==c==
18844 ===ca===
18845 !! html/php
18846 ====bba====
18847 !! end
18848
18849 !! test
18850 Section extraction test (section 8)
18851 !! options
18852 section=8
18853 !! wikitext
18854 start
18855 ==a==
18856 ===aa===
18857 ====aaa====
18858 ==b==
18859 ===ba===
18860 ===bb===
18861 ====bba====
18862 ===bc===
18863 ==c==
18864 ===ca===
18865 !! html/php
18866 ===bc===
18867 !! end
18868
18869 !! test
18870 Section extraction test (section 9)
18871 !! options
18872 section=9
18873 !! wikitext
18874 start
18875 ==a==
18876 ===aa===
18877 ====aaa====
18878 ==b==
18879 ===ba===
18880 ===bb===
18881 ====bba====
18882 ===bc===
18883 ==c==
18884 ===ca===
18885 !! html/php
18886 ==c==
18887 ===ca===
18888 !! end
18889
18890 !! test
18891 Section extraction test (section 10)
18892 !! options
18893 section=10
18894 !! wikitext
18895 start
18896 ==a==
18897 ===aa===
18898 ====aaa====
18899 ==b==
18900 ===ba===
18901 ===bb===
18902 ====bba====
18903 ===bc===
18904 ==c==
18905 ===ca===
18906 !! html/php
18907 ===ca===
18908 !! end
18909
18910 !! test
18911 Section extraction test (nonexistent section 11)
18912 !! options
18913 section=11
18914 !! wikitext
18915 start
18916 ==a==
18917 ===aa===
18918 ====aaa====
18919 ==b==
18920 ===ba===
18921 ===bb===
18922 ====bba====
18923 ===bc===
18924 ==c==
18925 ===ca===
18926 !! html/php
18927 !! end
18928
18929 !! test
18930 Section extraction test with bogus heading (section 1)
18931 !! options
18932 section=1
18933 !! wikitext
18934 ==a==
18935 ==bogus== not a legal section
18936 ==b==
18937 !! html/php
18938 ==a==
18939 ==bogus== not a legal section
18940 !! end
18941
18942 !! test
18943 Section extraction test with bogus heading (section 2)
18944 !! options
18945 section=2
18946 !! wikitext
18947 ==a==
18948 ==bogus== not a legal section
18949 ==b==
18950 !! html/php
18951 ==b==
18952 !! end
18953
18954 !! test
18955 Section extraction test with comment after heading (section 1)
18956 !! options
18957 section=1
18958 !! wikitext
18959 ==a==
18960 ==b== <!-- -->
18961 ==c==
18962 !! html/php
18963 ==a==
18964 !! end
18965
18966 !! test
18967 Section extraction test with comment after heading (section 2)
18968 !! options
18969 section=2
18970 !! wikitext
18971 ==a==
18972 ==b== <!-- -->
18973 ==c==
18974 !! html/php
18975 ==b== <!-- -->
18976 !! end
18977
18978 !! test
18979 Section extraction test with bogus <nowiki> heading (section 1)
18980 !! options
18981 section=1
18982 !! wikitext
18983 ==a==
18984 ==bogus== <nowiki>not a legal section</nowiki>
18985 ==b==
18986 !! html/php
18987 ==a==
18988 ==bogus== <nowiki>not a legal section</nowiki>
18989 !! end
18990
18991 !! test
18992 Section extraction test with bogus <nowiki> heading (section 2)
18993 !! options
18994 section=2
18995 !! wikitext
18996 ==a==
18997 ==bogus== <nowiki>not a legal section</nowiki>
18998 ==b==
18999 !! html/php
19000 ==b==
19001 !! end
19002
19003 # Formerly testing for T4587, now resolved by the use of unmarked sections
19004 # instead of respecting commented sections
19005 !! test
19006 Section extraction prefixed by comment (section 1)
19007 !! options
19008 section=1
19009 !! wikitext
19010 <!-- -->==sec1==
19011 ==sec2==
19012 !! html/php
19013 ==sec2==
19014 !!end
19015
19016 !! test
19017 Section extraction prefixed by comment (section 2)
19018 !! options
19019 section=2
19020 !! wikitext
19021 <!-- -->==sec1==
19022 ==sec2==
19023 !! html/php
19024
19025 !!end
19026
19027 # Formerly testing for T4607, now resolved by the use of unmarked sections
19028 # instead of respecting HTML-style headings
19029 !! test
19030 Section extraction, mixed wiki and html (section 1)
19031 !! options
19032 section=1
19033 !! wikitext
19034 <h2>unmarked</h2>
19035 unmarked
19036 ==1==
19037 one
19038 ==2==
19039 two
19040 !! html/php
19041 ==1==
19042 one
19043 !! end
19044
19045 !! test
19046 Section extraction, mixed wiki and html (section 2)
19047 !! options
19048 section=2
19049 !! wikitext
19050 <h2>unmarked</h2>
19051 unmarked
19052 ==1==
19053 one
19054 ==2==
19055 two
19056 !! html/php
19057 ==2==
19058 two
19059 !! end
19060
19061
19062 # Formerly testing for T5342
19063 !! test
19064 Section extraction, heading surrounded by <noinclude>
19065 !! options
19066 section=1
19067 !! wikitext
19068 <noinclude>==unmarked==</noinclude>
19069 ==marked==
19070 !! html/php
19071 ==marked==
19072 !!end
19073
19074 # Test behavior of T21910
19075 !! test
19076 Sectiion with all-equals
19077 !! options
19078 section=2
19079 !! wikitext
19080 ===
19081 The line above must have a trailing space
19082 === <!--
19083 --> <!-- -->
19084 But just in case it doesn't...
19085 !! html/php
19086 === <!--
19087 --> <!-- -->
19088 But just in case it doesn't...
19089 !! end
19090
19091 !! test
19092 Section replacement test (section 0)
19093 !! options
19094 replace=0,"xxx"
19095 !! wikitext
19096 start
19097 ==a==
19098 ===aa===
19099 ====aaa====
19100 ==b==
19101 ===ba===
19102 ===bb===
19103 ====bba====
19104 ===bc===
19105 ==c==
19106 ===ca===
19107 !! html/php
19108 xxx
19109
19110 ==a==
19111 ===aa===
19112 ====aaa====
19113 ==b==
19114 ===ba===
19115 ===bb===
19116 ====bba====
19117 ===bc===
19118 ==c==
19119 ===ca===
19120 !! end
19121
19122 !! test
19123 Section replacement test (section 1)
19124 !! options
19125 replace=1,"xxx"
19126 !! wikitext
19127 start
19128 ==a==
19129 ===aa===
19130 ====aaa====
19131 ==b==
19132 ===ba===
19133 ===bb===
19134 ====bba====
19135 ===bc===
19136 ==c==
19137 ===ca===
19138 !! html/php
19139 start
19140 xxx
19141
19142 ==b==
19143 ===ba===
19144 ===bb===
19145 ====bba====
19146 ===bc===
19147 ==c==
19148 ===ca===
19149 !! end
19150
19151 !! test
19152 Section replacement test (section 2)
19153 !! options
19154 replace=2,"xxx"
19155 !! wikitext
19156 start
19157 ==a==
19158 ===aa===
19159 ====aaa====
19160 ==b==
19161 ===ba===
19162 ===bb===
19163 ====bba====
19164 ===bc===
19165 ==c==
19166 ===ca===
19167 !! html/php
19168 start
19169 ==a==
19170 xxx
19171
19172 ==b==
19173 ===ba===
19174 ===bb===
19175 ====bba====
19176 ===bc===
19177 ==c==
19178 ===ca===
19179 !! end
19180
19181 !! test
19182 Section replacement test (section 3)
19183 !! options
19184 replace=3,"xxx"
19185 !! wikitext
19186 start
19187 ==a==
19188 ===aa===
19189 ====aaa====
19190 ==b==
19191 ===ba===
19192 ===bb===
19193 ====bba====
19194 ===bc===
19195 ==c==
19196 ===ca===
19197 !! html/php
19198 start
19199 ==a==
19200 ===aa===
19201 xxx
19202
19203 ==b==
19204 ===ba===
19205 ===bb===
19206 ====bba====
19207 ===bc===
19208 ==c==
19209 ===ca===
19210 !! end
19211
19212 !! test
19213 Section replacement test (section 4)
19214 !! options
19215 replace=4,"xxx"
19216 !! wikitext
19217 start
19218 ==a==
19219 ===aa===
19220 ====aaa====
19221 ==b==
19222 ===ba===
19223 ===bb===
19224 ====bba====
19225 ===bc===
19226 ==c==
19227 ===ca===
19228 !! html/php
19229 start
19230 ==a==
19231 ===aa===
19232 ====aaa====
19233 xxx
19234
19235 ==c==
19236 ===ca===
19237 !! end
19238
19239 !! test
19240 Section replacement test (section 5)
19241 !! options
19242 replace=5,"xxx"
19243 !! wikitext
19244 start
19245 ==a==
19246 ===aa===
19247 ====aaa====
19248 ==b==
19249 ===ba===
19250 ===bb===
19251 ====bba====
19252 ===bc===
19253 ==c==
19254 ===ca===
19255 !! html/php
19256 start
19257 ==a==
19258 ===aa===
19259 ====aaa====
19260 ==b==
19261 xxx
19262
19263 ===bb===
19264 ====bba====
19265 ===bc===
19266 ==c==
19267 ===ca===
19268 !! end
19269
19270 !! test
19271 Section replacement test (section 6)
19272 !! options
19273 replace=6,"xxx"
19274 !! wikitext
19275 start
19276 ==a==
19277 ===aa===
19278 ====aaa====
19279 ==b==
19280 ===ba===
19281 ===bb===
19282 ====bba====
19283 ===bc===
19284 ==c==
19285 ===ca===
19286 !! html/php
19287 start
19288 ==a==
19289 ===aa===
19290 ====aaa====
19291 ==b==
19292 ===ba===
19293 xxx
19294
19295 ===bc===
19296 ==c==
19297 ===ca===
19298 !! end
19299
19300 !! test
19301 Section replacement test (section 7)
19302 !! options
19303 replace=7,"xxx"
19304 !! wikitext
19305 start
19306 ==a==
19307 ===aa===
19308 ====aaa====
19309 ==b==
19310 ===ba===
19311 ===bb===
19312 ====bba====
19313 ===bc===
19314 ==c==
19315 ===ca===
19316 !! html/php
19317 start
19318 ==a==
19319 ===aa===
19320 ====aaa====
19321 ==b==
19322 ===ba===
19323 ===bb===
19324 xxx
19325
19326 ===bc===
19327 ==c==
19328 ===ca===
19329 !! end
19330
19331 !! test
19332 Section replacement test (section 8)
19333 !! options
19334 replace=8,"xxx"
19335 !! wikitext
19336 start
19337 ==a==
19338 ===aa===
19339 ====aaa====
19340 ==b==
19341 ===ba===
19342 ===bb===
19343 ====bba====
19344 ===bc===
19345 ==c==
19346 ===ca===
19347 !! html/php
19348 start
19349 ==a==
19350 ===aa===
19351 ====aaa====
19352 ==b==
19353 ===ba===
19354 ===bb===
19355 ====bba====
19356 xxx
19357
19358 ==c==
19359 ===ca===
19360 !!end
19361
19362 !! test
19363 Section replacement test (section 9)
19364 !! options
19365 replace=9,"xxx"
19366 !! wikitext
19367 start
19368 ==a==
19369 ===aa===
19370 ====aaa====
19371 ==b==
19372 ===ba===
19373 ===bb===
19374 ====bba====
19375 ===bc===
19376 ==c==
19377 ===ca===
19378 !! html/php
19379 start
19380 ==a==
19381 ===aa===
19382 ====aaa====
19383 ==b==
19384 ===ba===
19385 ===bb===
19386 ====bba====
19387 ===bc===
19388 xxx
19389 !! end
19390
19391 !! test
19392 Section replacement test (section 10)
19393 !! options
19394 replace=10,"xxx"
19395 !! wikitext
19396 start
19397 ==a==
19398 ===aa===
19399 ====aaa====
19400 ==b==
19401 ===ba===
19402 ===bb===
19403 ====bba====
19404 ===bc===
19405 ==c==
19406 ===ca===
19407 !! html/php
19408 start
19409 ==a==
19410 ===aa===
19411 ====aaa====
19412 ==b==
19413 ===ba===
19414 ===bb===
19415 ====bba====
19416 ===bc===
19417 ==c==
19418 xxx
19419 !! end
19420
19421 !! test
19422 Section replacement test with initial whitespace (T15728)
19423 !! options
19424 replace=2,"xxx"
19425 !! wikitext
19426 Preformatted initial line
19427 ==a==
19428 ===a===
19429 !! html/php
19430 Preformatted initial line
19431 ==a==
19432 xxx
19433 !! end
19434
19435
19436 !! test
19437 Section extraction, heading followed by pre with 20 spaces (T8398)
19438 !! options
19439 section=1
19440 !! wikitext
19441 ==a==
19442 a
19443 !! html/php
19444 ==a==
19445 a
19446 !! end
19447
19448 !! test
19449 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
19450 !! options
19451 section=1
19452 !! wikitext
19453 ==a==
19454 a
19455 !! html/php
19456 ==a==
19457 a
19458 !! end
19459
19460
19461 !! test
19462 Section extraction, <pre> around bogus header (T12309)
19463 !! options
19464 section=2
19465 !! wikitext
19466 == Section One ==
19467 <pre>
19468 =======
19469 </pre>
19470
19471 == Section Two ==
19472 stuff
19473 !! html/php
19474 == Section Two ==
19475 stuff
19476 !! end
19477
19478 !! test
19479 Section replacement, <pre> around bogus header (T12309)
19480 !! options
19481 replace=2,"xxx"
19482 !! wikitext
19483 == Section One ==
19484 <pre>
19485 =======
19486 </pre>
19487
19488 == Section Two ==
19489 stuff
19490 !! html/php
19491 == Section One ==
19492 <pre>
19493 =======
19494 </pre>
19495
19496 xxx
19497 !! end
19498
19499 !! test
19500 Handling of &#x0A; in URLs
19501 !! wikitext
19502 ** irc://&#x0A;a
19503 !! html/php
19504 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
19505
19506 !! html/parsoid
19507 <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>
19508 !! end
19509
19510 !! test
19511 Handling of %0A in URLs
19512 !! wikitext
19513 ** irc://%0Aa
19514 !! html/php
19515 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
19516
19517 !! html/parsoid
19518 <ul><li><ul><li> <a rel="mw:ExtLink" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
19519 !! end
19520
19521 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
19522 !! test
19523 5 quotes, code coverage +1 line
19524 !! options
19525 parsoid=wt2html
19526 !! wikitext
19527 '''''
19528 !! html/php
19529 !! html/parsoid
19530 <p><b><i></i></b></p>
19531 !! end
19532
19533 # same html as previous, but wikitext adjusted to match parsoid html2wt
19534 # note that wt2html and html2html will put the <i> before the <b>
19535 !! test
19536 5 quotes, code coverage +1 line w/ nowiki (1)
19537 !! options
19538 parsoid=wt2wt,html2wt
19539 !! wikitext
19540 '''''<nowiki/>'''''
19541 !! html/php
19542 <p><i></i>
19543 </p>
19544 !! html/parsoid
19545 <p><b><i></i></b></p>
19546 !! end
19547
19548 # same as previous, just swapping the <i> and <b>
19549 !! test
19550 5 quotes, code coverage +1 line w/ nowiki (2)
19551 !! wikitext
19552 '''''<nowiki/>'''''
19553 !! html/php
19554 <p><i></i>
19555 </p>
19556 !! html/parsoid
19557 <p><i><b></b></i></p>
19558 !! end
19559
19560 !! test
19561 Special:Search page linking.
19562 !! wikitext
19563 {{Special:search}}
19564 !! html
19565 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
19566 </p>
19567 !! end
19568
19569 !! test
19570 {{!}} is a magic word
19571 !! wikitext
19572 {{!}} is a magic word there and {{!}} is still a magic word here
19573 | is not a magic word here but {{!}} is still a magic word here
19574 !! html/php
19575 <p>| is a magic word there and | is still a magic word here
19576 | is not a magic word here but | is still a magic word here
19577 </p>
19578 !! html/parsoid
19579 <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
19580 | 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>
19581 !! end
19582
19583 !! test
19584 Say the magic word
19585 !! options
19586 title=[[Parser test]]
19587 !! wikitext
19588 * {{PAGENAME}}
19589 * {{PAGENAMEE}}
19590 * {{FULLPAGENAME}}
19591 * {{FULLPAGENAMEE}}
19592 * {{BASEPAGENAME}}
19593 * {{BASEPAGENAMEE}}
19594 * {{SUBPAGENAME}}
19595 * {{SUBPAGENAMEE}}
19596 * {{ROOTPAGENAME}}
19597 * {{ROOTPAGENAMEE}}
19598 * {{TALKPAGENAME}}
19599 * {{TALKPAGENAMEE}}
19600 * {{SUBJECTPAGENAME}}
19601 * {{SUBJECTPAGENAMEE}}
19602 * {{NAMESPACEE}}
19603 * {{NAMESPACE}}
19604 * {{NAMESPACENUMBER}}
19605 * {{TALKSPACE}}
19606 * {{TALKSPACEE}}
19607 * {{SUBJECTSPACE}}
19608 * {{SUBJECTSPACEE}}
19609 * {{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
19610 !! html
19611 <ul><li> Parser test</li>
19612 <li> Parser_test</li>
19613 <li> Parser test</li>
19614 <li> Parser_test</li>
19615 <li> Parser test</li>
19616 <li> Parser_test</li>
19617 <li> Parser test</li>
19618 <li> Parser_test</li>
19619 <li> Parser test</li>
19620 <li> Parser_test</li>
19621 <li> Talk:Parser test</li>
19622 <li> Talk:Parser_test</li>
19623 <li> Parser test</li>
19624 <li> Parser_test</li>
19625 <li> </li>
19626 <li> </li>
19627 <li> 0</li>
19628 <li> Talk</li>
19629 <li> Talk</li>
19630 <li> </li>
19631 <li> </li>
19632 <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>
19633
19634 !! end
19635 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
19636
19637 !! test
19638 Gallery with valid attributes
19639 !! wikitext
19640 <gallery type="123" summary="345">
19641 File:File:Foobar.jpg
19642 </gallery>
19643 !! html/php
19644 <ul class="gallery mw-gallery-traditional" type="123">
19645 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19646 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
19647 <div class="gallerytext">
19648 </div>
19649 </div></li>
19650 </ul>
19651
19652 !! html/parsoid
19653 <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"}}'>
19654 <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>
19655 </ul>
19656 !! end
19657
19658 ## Parsoid thinks the "centre" here is a property, not a caption.
19659 !! test
19660 Gallery
19661 !! options
19662 parsoid={
19663 "modes": ["wt2html"],
19664 "nativeGallery": true
19665 }
19666 !! wikitext
19667 <gallery>
19668 image1.png |
19669 image2.gif|||||
19670
19671 image3|
19672 image4 |300px| centre
19673 image5.svg| http://///////
19674 [[x|xx]]]]
19675 * image6
19676 </gallery>
19677 !! html/php
19678 <ul class="gallery mw-gallery-traditional">
19679 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19680 <div class="thumb" style="height: 150px;">Image1.png</div>
19681 <div class="gallerytext">
19682 </div>
19683 </div></li>
19684 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19685 <div class="thumb" style="height: 150px;">Image2.gif</div>
19686 <div class="gallerytext">
19687 </div>
19688 </div></li>
19689 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19690 <div class="thumb" style="height: 150px;">Image3</div>
19691 <div class="gallerytext">
19692 </div>
19693 </div></li>
19694 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19695 <div class="thumb" style="height: 150px;">Image4</div>
19696 <div class="gallerytext">
19697 <pre>centre
19698 </pre>
19699 </div>
19700 </div></li>
19701 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19702 <div class="thumb" style="height: 150px;">Image5.svg</div>
19703 <div class="gallerytext">
19704 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
19705 </p>
19706 </div>
19707 </div></li>
19708 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19709 <div class="thumb" style="height: 150px;">* image6</div>
19710 <div class="gallerytext">
19711 </div>
19712 </div></li>
19713 </ul>
19714
19715 !! html/parsoid
19716 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19717 <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>
19718 <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>
19719 <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>
19720 <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>
19721 <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>
19722 <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>
19723 </ul>
19724 !! end
19725
19726 !! test
19727 Gallery (with options, html)
19728 !! options
19729 parsoid={
19730 "modes": ["wt2html", "html2html"],
19731 "nativeGallery": true
19732 }
19733 !! wikitext
19734 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
19735 File:Nonexistent.jpg|caption
19736 File:Nonexistent.jpg
19737 image:foobar.jpg|some '''caption''' [[Main Page]]
19738 image:foobar.jpg
19739 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
19740 </gallery>
19741 !! html/php
19742 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
19743 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
19744 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19745 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19746 <div class="gallerytext">
19747 <p>caption
19748 </p>
19749 </div>
19750 </div></li>
19751 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19752 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19753 <div class="gallerytext">
19754 </div>
19755 </div></li>
19756 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19757 <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>
19758 <div class="gallerytext">
19759 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
19760 </p>
19761 </div>
19762 </div></li>
19763 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19764 <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>
19765 <div class="gallerytext">
19766 </div>
19767 </div></li>
19768 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19769 <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>
19770 <div class="gallerytext">
19771 <p>blabla.
19772 </p>
19773 </div>
19774 </div></li>
19775 </ul>
19776
19777 !! html/parsoid
19778 <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":{}}'>
19779 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
19780 <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>
19781 <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>
19782 <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>
19783 <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>
19784 <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>
19785 </ul>
19786 !! end
19787
19788 !! test
19789 Gallery (with options, extsrc)
19790 !! options
19791 parsoid={
19792 "nativeGallery": false
19793 }
19794 !! wikitext
19795 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
19796 File:Nonexistent.jpg|caption
19797 File:Nonexistent.jpg
19798 image:foobar.jpg|some '''caption''' [[Main Page]]
19799 image:foobar.jpg
19800 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
19801 </gallery>
19802 !! html/php
19803 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
19804 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
19805 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19806 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19807 <div class="gallerytext">
19808 <p>caption
19809 </p>
19810 </div>
19811 </div></li>
19812 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19813 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19814 <div class="gallerytext">
19815 </div>
19816 </div></li>
19817 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19818 <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>
19819 <div class="gallerytext">
19820 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
19821 </p>
19822 </div>
19823 </div></li>
19824 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19825 <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>
19826 <div class="gallerytext">
19827 </div>
19828 </div></li>
19829 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19830 <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>
19831 <div class="gallerytext">
19832 <p>blabla.
19833 </p>
19834 </div>
19835 </div></li>
19836 </ul>
19837
19838 !! html/parsoid
19839 <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"}}'>
19840 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
19841 <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>
19842 <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>
19843 <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>
19844 <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>
19845 <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>
19846 </ul>
19847 !! end
19848
19849 !! test
19850 Gallery with link that has fragment
19851 !! options
19852 parsoid={
19853 "modes": ["wt2html", "html2html"],
19854 "nativeGallery": true
19855 }
19856 !! wikitext
19857 <gallery>
19858 image:foobar.jpg|link=Main_Page
19859 image:foobar.jpg|link=Main_Page#section
19860 image:foobar.jpg|link=Main Page#section|caption
19861 </gallery>
19862 !! html/php
19863 <ul class="gallery mw-gallery-traditional">
19864 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19865 <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>
19866 <div class="gallerytext">
19867 </div>
19868 </div></li>
19869 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19870 <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>
19871 <div class="gallerytext">
19872 </div>
19873 </div></li>
19874 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19875 <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>
19876 <div class="gallerytext">
19877 <p>caption
19878 </p>
19879 </div>
19880 </div></li>
19881 </ul>
19882
19883 !! html/parsoid
19884 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19885 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span typeof="mw:Image" style="vertical-align: middle; display: inline-block;"><a href="./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>
19886 <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>
19887 <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>
19888 </ul>
19889 !! end
19890
19891 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
19892 !! test
19893 Gallery with template inside caption
19894 !! options
19895 parsoid={
19896 "nativeGallery": true
19897 }
19898 !! wikitext
19899 <gallery caption="{{echo|hi}}">
19900 File:Foobar.jpg|{{echo|ho}}
19901 </gallery>
19902 !! html/php
19903 <ul class="gallery mw-gallery-traditional">
19904 <li class='gallerycaption'>{{echo|hi}}</li>
19905 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19906 <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>
19907 <div class="gallerytext">
19908 <p>ho
19909 </p>
19910 </div>
19911 </div></li>
19912 </ul>
19913
19914 !! html/parsoid
19915 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19916 <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>
19917 <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>
19918 </ul>
19919 !! end
19920
19921 !! test
19922 Gallery with wikitext inside caption
19923 !! options
19924 parsoid={
19925 "nativeGallery": true
19926 }
19927 !! wikitext
19928 <gallery>
19929 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
19930 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
19931 </gallery>
19932 !! html/php
19933 <ul class="gallery mw-gallery-traditional">
19934 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19935 <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>
19936 <div class="gallerytext">
19937 <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>
19938 </p>
19939 </div>
19940 </div></li>
19941 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19942 <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>
19943 <div class="gallerytext">
19944 <p>This is a test template
19945 </p>
19946 </div>
19947 </div></li>
19948 </ul>
19949
19950 !! html/parsoid
19951 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19952 <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>
19953 <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>
19954 </ul>
19955 !! end
19956
19957 !! test
19958 Gallery (with showfilename option)
19959 !! options
19960 parsoid={
19961 "nativeGallery": true
19962 }
19963 !! wikitext
19964 <gallery showfilename="">
19965 File:Nonexistent.jpg|caption
19966 File:Nonexistent.jpg
19967 File:Foobar.jpg|some '''caption''' [[Main Page]]
19968 File:Foobar.jpg
19969 </gallery>
19970 !! html/php
19971 <ul class="gallery mw-gallery-traditional">
19972 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19973 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
19974 <div class="gallerytext">
19975 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
19976 caption
19977 </p>
19978 </div>
19979 </div></li>
19980 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19981 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
19982 <div class="gallerytext">
19983 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
19984 </p>
19985 </div>
19986 </div></li>
19987 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19988 <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>
19989 <div class="gallerytext">
19990 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
19991 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
19992 </p>
19993 </div>
19994 </div></li>
19995 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19996 <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>
19997 <div class="gallerytext">
19998 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
19999 </p>
20000 </div>
20001 </div></li>
20002 </ul>
20003
20004 !! html/parsoid
20005 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
20006 <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>
20007 <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>
20008 <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>
20009 <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>
20010 </ul>
20011 !! end
20012
20013 ## Should Parsoid be preserving these variations?
20014 !! test
20015 Gallery (with namespace-less filenames)
20016 !! options
20017 parsoid={
20018 "modes": ["wt2html", "html2html"],
20019 "nativeGallery": true
20020 }
20021 !! wikitext
20022 <gallery>
20023 File:Nonexistent.jpg
20024 Nonexistent.jpg
20025 image:foobar.jpg
20026 foobar.jpg
20027 </gallery>
20028 !! html/php
20029 <ul class="gallery mw-gallery-traditional">
20030 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20031 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20032 <div class="gallerytext">
20033 </div>
20034 </div></li>
20035 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20036 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20037 <div class="gallerytext">
20038 </div>
20039 </div></li>
20040 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20041 <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>
20042 <div class="gallerytext">
20043 </div>
20044 </div></li>
20045 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20046 <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>
20047 <div class="gallerytext">
20048 </div>
20049 </div></li>
20050 </ul>
20051
20052 !! html/parsoid
20053 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20054 <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>
20055 <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>
20056 <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>
20057 <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>
20058 </ul>
20059 !! end
20060
20061 !! test
20062 Gallery override link with WikiLink (T36852)
20063 !! options
20064 parsoid={
20065 "nativeGallery": true
20066 }
20067 !! wikitext
20068 <gallery>
20069 File:Foobar.jpg|alt=galleryalt|link=InterWikiLink
20070 </gallery>
20071 !! html/php
20072 <ul class="gallery mw-gallery-traditional">
20073 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20074 <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>
20075 <div class="gallerytext">
20076 </div>
20077 </div></li>
20078 </ul>
20079
20080 !! html/parsoid
20081 <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":{}}'>
20082 <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>
20083 </ul>
20084 !! end
20085
20086 !! test
20087 Gallery override link with absolute external link (T36852)
20088 !! options
20089 parsoid={
20090 "nativeGallery": true
20091 }
20092 !! wikitext
20093 <gallery>
20094 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
20095 </gallery>
20096 !! html/php
20097 <ul class="gallery mw-gallery-traditional">
20098 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20099 <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>
20100 <div class="gallerytext">
20101 </div>
20102 </div></li>
20103 </ul>
20104
20105 !! html/parsoid
20106 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20107 <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>
20108 </ul>
20109 !! end
20110
20111 !! test
20112 Gallery override link with absolute external link with LanguageConverter
20113 !! options
20114 language=zh
20115 !! input
20116 <gallery>
20117 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
20118 </gallery>
20119 !! result
20120 <ul class="gallery mw-gallery-traditional">
20121 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20122 <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>
20123 <div class="gallerytext">
20124 <p>caption
20125 </p>
20126 </div>
20127 </div></li>
20128 </ul>
20129
20130 !! end
20131
20132 !! test
20133 Gallery override link with malicious javascript (T36852)
20134 !! options
20135 parsoid={
20136 "modes": ["wt2html", "html2html"],
20137 "nativeGallery": true
20138 }
20139 !! wikitext
20140 <gallery>
20141 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
20142 </gallery>
20143 !! html/php
20144 <ul class="gallery mw-gallery-traditional">
20145 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20146 <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>
20147 <div class="gallerytext">
20148 </div>
20149 </div></li>
20150 </ul>
20151
20152 !! html/parsoid
20153 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20154 <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>
20155 </ul>
20156 !! end
20157
20158 !! test
20159 Gallery with invalid title as link (T45964)
20160 !! options
20161 parsoid={
20162 "modes": ["wt2html", "html2html"],
20163 "nativeGallery": true
20164 }
20165 !! wikitext
20166 <gallery>
20167 File:Foobar.jpg|link=<
20168 </gallery>
20169 !! html/php
20170 <ul class="gallery mw-gallery-traditional">
20171 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20172 <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>
20173 <div class="gallerytext">
20174 </div>
20175 </div></li>
20176 </ul>
20177
20178 !! html/parsoid
20179 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20180 <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>
20181 </ul>
20182 !! end
20183
20184 !! test
20185 Serialize gallery without attrs in data-mw
20186 !! options
20187 parsoid={
20188 "modes": ["html2wt"],
20189 "nativeGallery": true
20190 }
20191 !! html/parsoid
20192 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
20193 <li class="gallerycaption">123</li>
20194 <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>
20195 </ul>
20196 !! wikitext
20197 <gallery caption="123">
20198 File:Test.png
20199 </gallery>
20200 !! end
20201
20202 !! test
20203 Gallery with class and style attributes
20204 !! options
20205 parsoid={
20206 "nativeGallery": true
20207 }
20208 !! wikitext
20209 <gallery class="center" style="text-align: center;">
20210 File:Foobar.jpg
20211 </gallery>
20212 !! html/php
20213 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
20214 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20215 <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>
20216 <div class="gallerytext">
20217 </div>
20218 </div></li>
20219 </ul>
20220
20221 !! html/parsoid
20222 <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":{}}'>
20223 <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>
20224 </ul>
20225 !! end
20226
20227 !! test
20228 Gallery in slideshow mode
20229 !! options
20230 parsoid={
20231 "nativeGallery": true
20232 }
20233 !! wikitext
20234 <gallery mode="slideshow" showthumbnails="">
20235 File:Foobar.jpg
20236 </gallery>
20237 !! html/php
20238 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
20239 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20240 <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>
20241 <div class="gallerytext">
20242 </div>
20243 </div></li>
20244 </ul>
20245
20246 !! html/parsoid
20247 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
20248 <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>
20249 </ul>
20250 !! end
20251
20252 !! test
20253 HTML Hex character encoding (spells the word "JavaScript")
20254 !! options
20255 parsoid=wt2html,wt2wt,html2html
20256 !! wikitext
20257 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
20258 !! html/php
20259 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
20260 </p>
20261 !! html/php+tidy
20262 <p>JavaScript</p>
20263 !! html/parsoid
20264 <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>
20265 !! end
20266
20267 !! test
20268 HTML Hex character encoding bogus encoding (T28437 regression check)
20269 !! wikitext
20270 &#xsee;&#XSEE;
20271 !! html/php
20272 <p>&amp;#xsee;&amp;#XSEE;
20273 </p>
20274 !! html/parsoid
20275 <p>&amp;#xsee;&amp;#XSEE;</p>
20276 !! end
20277
20278 !! test
20279 HTML Hex character encoding mixed case
20280 !! options
20281 parsoid=wt2html,wt2wt,html2html
20282 !! wikitext
20283 &#xEE;&#Xee;
20284 !! html/php
20285 <p>&#xee;&#xee;
20286 </p>
20287 !! html/php+tidy
20288 <p>îî</p>
20289 !! html/parsoid
20290 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
20291 !! end
20292
20293 # See: https://www.w3.org/TR/html5/syntax.html#character-references
20294 # Note that U+000C (form feed) is not a valid XML character, so
20295 # it is banned even though allowed in HTML5.
20296 !! test
20297 Illegal character references (T106578)
20298 !! wikitext
20299 ; Null: &#00;
20300 ; FF: &#xC;
20301 ; CR: &#xD;
20302 ; Control (low): &#8;
20303 ; Control (high): &#x7F; &#x9F;
20304 ; Surrogate: &#xD83D;&#xDCA9;
20305 ; This is an okay astral character: &#x1F4A9;
20306 !! html+tidy
20307 <dl>
20308 <dt>Null</dt>
20309 <dd>&amp;#00;</dd>
20310 <dt>FF</dt>
20311 <dd>&amp;#xC;</dd>
20312 <dt>CR</dt>
20313 <dd>&amp;#xD;</dd>
20314 <dt>Control (low)</dt>
20315 <dd>&amp;#8;</dd>
20316 <dt>Control (high)</dt>
20317 <dd>&amp;#x7F; &amp;#x9F;</dd>
20318 <dt>Surrogate</dt>
20319 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
20320 <dt>This is an okay astral character</dt>
20321 <dd>💩</dd>
20322 </dl>
20323 !! end
20324
20325 !! test
20326 __FORCETOC__ override
20327 !! wikitext
20328 __NEWSECTIONLINK__
20329 __FORCETOC__
20330 !! html/php
20331 <p><br />
20332 </p>
20333 !! end
20334
20335 !! test
20336 ISBN code coverage
20337 !! wikitext
20338 ISBN 978-0-1234-56&#x20;789
20339 !! html
20340 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
20341 </p>
20342 !! html+tidy
20343 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a> 789</p>
20344 !! html/parsoid
20345 <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>
20346 !! end
20347
20348 !! test
20349 ISBN followed by 5 spaces
20350 !! wikitext
20351 ISBN
20352 !! html
20353 <p>ISBN
20354 </p>
20355 !! end
20356
20357 !! test
20358 Double ISBN
20359 !! wikitext
20360 ISBN ISBN 1234567890
20361 !! html/php
20362 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20363 </p>
20364 !! html/parsoid
20365 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
20366 !! end
20367
20368 # Uppercase X and lowercase x as well
20369 !! test
20370 ISBN with an X
20371 !! wikitext
20372 ISBN 3-462-04561-X
20373 ISBN 3-462-04561-x
20374 ISBN 080442957X
20375 ISBN 080442957x
20376 ISBN 978080442957X
20377 ISBN 978080442957x
20378 !! html/php
20379 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
20380 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
20381 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
20382 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
20383 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
20384 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
20385 </p>
20386 !! html/parsoid
20387 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
20388 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
20389 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
20390 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
20391 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
20392 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
20393 !! end
20394
20395 !! test
20396 ISBN with empty prefix (parsoid test)
20397 !! wikitext
20398 ISBN 1234567890
20399 !! html/php
20400 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20401 </p>
20402 !! html/parsoid
20403 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
20404 !! end
20405
20406 !! test
20407 T24905: <abbr> followed by ISBN followed by </a>
20408 !! wikitext
20409 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
20410 !! html/php
20411 <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>
20412 </p>
20413 !! html/parsoid
20414 <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>
20415 !! end
20416
20417 !! test
20418 Double RFC
20419 !! wikitext
20420 RFC RFC 1234
20421 !! html
20422 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a>
20423 </p>
20424 !! end
20425
20426 !! test
20427 Double RFC with a wiki link
20428 !! wikitext
20429 RFC [[RFC 1234]]
20430 !! html
20431 <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>
20432 </p>
20433 !! end
20434
20435 !! test
20436 RFC code coverage
20437 !! wikitext
20438 RFC 983&#x20;987
20439 !! html
20440 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
20441 </p>
20442 !! html+tidy
20443 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a> 987</p>
20444 !! end
20445
20446 !! test
20447 Centre-aligned image
20448 !! wikitext
20449 [[Image:foobar.jpg|centre]]
20450 !! html
20451 <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>
20452
20453 !!end
20454
20455 !! test
20456 None-aligned image
20457 !! wikitext
20458 [[Image:foobar.jpg|none]]
20459 !! html
20460 <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>
20461
20462 !!end
20463
20464 !! test
20465 Width + Height sized image (using px) (height is ignored)
20466 !! wikitext
20467 [[Image:foobar.jpg|640x480px]]
20468 !! html
20469 <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>
20470 </p>
20471 !!end
20472
20473 !! test
20474 Width-sized image (using px, no following whitespace)
20475 !! wikitext
20476 [[Image:foobar.jpg|640px]]
20477 !! html
20478 <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>
20479 </p>
20480 !!end
20481
20482 !! test
20483 Width-sized image (using px, with following whitespace - test regression from r39467)
20484 !! wikitext
20485 [[Image:foobar.jpg|640px ]]
20486 !! html
20487 <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>
20488 </p>
20489 !!end
20490
20491 !! test
20492 Width-sized image (using px, with preceding whitespace - test regression from r39467)
20493 !! wikitext
20494 [[Image:foobar.jpg| 640px]]
20495 !! html
20496 <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>
20497 </p>
20498 !!end
20499
20500 !! test
20501 Image with page parameter
20502 !! options
20503 djvu
20504 !! wikitext
20505 [[File:LoremIpsum.djvu|page=2]]
20506 !! html/php
20507 <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>
20508 </p>
20509 !! html/parsoid
20510 <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>
20511 !! end
20512
20513 !! test
20514 Another italics / bold test
20515 !! wikitext
20516 ''' ''x'
20517 !! html
20518 <pre>'<i> </i>x'
20519 </pre>
20520 !!end
20521
20522 # FIXME: The php output seems broken. It's interleaving some open/close tags.
20523 !! test
20524 dt/dd/dl test
20525 !! wikitext
20526 :;;;::
20527 !! html/php
20528 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
20529
20530 !! html/parsoid
20531 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
20532
20533 !!end
20534
20535 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
20536 !! test
20537 Images with the "|" character in the comment
20538 !! wikitext
20539 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
20540 !! html/php
20541 <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>
20542
20543 !! html/parsoid
20544 <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>
20545 !! end
20546
20547 !! test
20548 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
20549 !! wikitext
20550 <html><script>alert(1);</script></html>
20551 !! html
20552 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
20553 </p>
20554 !! end
20555
20556 !! test
20557 HTML with raw HTML ($wgRawHtml==true)
20558 !! options
20559 wgRawHtml=1
20560 !! wikitext
20561 <html><script>alert(1);</script></html>
20562 !! html
20563 <p><script>alert(1);</script>
20564 </p>
20565 !! end
20566
20567 !! test
20568 Parents of subpages, one level up
20569 !! options
20570 subpage title=[[Subpage test/L1/L2/L3]]
20571 !! wikitext
20572 [[../|L2]]
20573 !! html
20574 <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>
20575 </p>
20576 !! end
20577
20578
20579 !! test
20580 Parents of subpages, one level up, not named
20581 !! options
20582 subpage title=[[Subpage test/L1/L2/L3]]
20583 !! wikitext
20584 [[../]]
20585 !! html
20586 <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>
20587 </p>
20588 !! end
20589
20590
20591
20592 !! test
20593 Parents of subpages, two levels up
20594 !! options
20595 subpage title=[[Subpage test/L1/L2/L3]]
20596 !! wikitext
20597 [[../../|L1]]2
20598
20599 [[../../|L1]]l
20600 !! html
20601 <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
20602 </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>
20603 </p>
20604 !! end
20605
20606 !! test
20607 Parents of subpages, two levels up, without trailing slash or name.
20608 !! options
20609 subpage title=[[Subpage test/L1/L2/L3]]
20610 !! wikitext
20611 [[../..]]
20612 !! html
20613 <p>[[../..]]
20614 </p>
20615 !! end
20616
20617 !! test
20618 Parents of subpages, two levels up, with lots of extra trailing slashes.
20619 !! options
20620 subpage title=[[Subpage test/L1/L2/L3]]
20621 !! wikitext
20622 [[../../////]]
20623 !! html
20624 <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>
20625 </p>
20626 !! end
20627
20628 !! article
20629 Subpage test/L1/L2/L3Sibling
20630 !! text
20631 Sibling article
20632 !! endarticle
20633
20634 !! test
20635 Transclusion of a sibling page (one level up)
20636 !! options
20637 subpage title=[[Subpage test/L1/L2/L3]]
20638 !! wikitext
20639 {{../L3Sibling}}
20640 !! html
20641 <p>Sibling article
20642 </p>
20643 !! end
20644
20645 !! test
20646 Transclusion of a child page
20647 !! options
20648 subpage title=[[Subpage test/L1/L2]]
20649 !! wikitext
20650 {{/L3Sibling}}
20651 !! html
20652 <p>Sibling article
20653 </p>
20654 !! end
20655
20656 # This is wt2html only in Parsoid because we add <nowiki>
20657 # because of {{..}} and we don't expect to fix that to
20658 # eliminate the nowikis selective for {{..}} markup.
20659 !! test
20660 Non-transclusion because of too many up levels
20661 !! options
20662 subpage title=[[Subpage test/L1/L2/L3]]
20663 parsoid=wt2html
20664 !! wikitext
20665 {{../../../../More than parent}}
20666 !! html/php
20667 <p>{{../../../../More than parent}}
20668 </p>
20669 !! html/parsoid
20670 <p>{{../../../../More than parent}}</p>
20671 !! end
20672
20673 !! test
20674 Definition list code coverage
20675 !! wikitext
20676 ; title : def
20677 ; title : def
20678 ;title: def
20679 !! html/php
20680 <dl><dt> title &#160;</dt>
20681 <dd> def</dd>
20682 <dt> title&#160;</dt>
20683 <dd> def</dd>
20684 <dt>title</dt>
20685 <dd> def</dd></dl>
20686
20687 !! html/parsoid
20688 <dl><dt> title <span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
20689 <dt> title<span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
20690 <dt>title</dt><dd> def</dd></dl>
20691 !! end
20692
20693 !! test
20694 Don't fall for the self-closing div
20695 !! wikitext
20696 <div>hello world</div/>
20697 !! html
20698 <div>hello world</div>
20699
20700 !! end
20701
20702 !! test
20703 MSGNW magic word
20704 !! wikitext
20705 {{MSGNW:msg}}
20706 !! html/php
20707 <p>&#91;&#91;:Template:Msg&#93;&#93;
20708 </p>
20709 !! end
20710
20711 !! test
20712 RAW magic word
20713 !! wikitext
20714 {{RAW:QUERTY}}
20715 !! html
20716 <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>
20717 </p>
20718 !! end
20719
20720 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
20721 !! test
20722 Always escape literal '>' in output, not just after '<'
20723 !! wikitext
20724 ><>
20725 !! html
20726 <p>&gt;&lt;&gt;
20727 </p>
20728 !! end
20729
20730 !! test
20731 Template caching
20732 !! wikitext
20733 {{Test}}
20734 {{Test}}
20735 !! html
20736 <p>This is a test template
20737 This is a test template
20738 </p>
20739 !! end
20740
20741
20742 !! article
20743 MediaWiki:Fake
20744 !! text
20745 ==header==
20746 !! endarticle
20747
20748 !! test
20749 Inclusion of !userCanEdit() content
20750 !! wikitext
20751 {{MediaWiki:Fake}}
20752 !! html
20753 <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>
20754
20755 !! end
20756
20757
20758 !! test
20759 Out-of-order TOC heading levels
20760 !! wikitext
20761 ==2==
20762 ======6======
20763 ===3===
20764 =1=
20765 =====5=====
20766 ==2==
20767 !! html
20768 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
20769 <ul>
20770 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
20771 <ul>
20772 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
20773 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
20774 </ul>
20775 </li>
20776 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
20777 <ul>
20778 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
20779 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
20780 </ul>
20781 </li>
20782 </ul>
20783 </div>
20784
20785 <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>
20786 <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>
20787 <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>
20788 <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>
20789 <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>
20790 <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>
20791
20792 !! end
20793
20794
20795 !! test
20796 ISBN with a dummy number
20797 !! wikitext
20798 ISBN ---
20799 !! html
20800 <p>ISBN ---
20801 </p>
20802 !! end
20803
20804
20805 !! test
20806 ISBN with space-delimited number
20807 !! wikitext
20808 ISBN 92 9017 032 8
20809 !! html/php
20810 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
20811 </p>
20812 !! html/parsoid
20813 <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>
20814 !! end
20815
20816
20817 !! test
20818 ISBN with multiple spaces, no number
20819 !! wikitext
20820 ISBN foo
20821 !! html
20822 <p>ISBN foo
20823 </p>
20824 !! end
20825
20826
20827 !! test
20828 ISBN length
20829 !! wikitext
20830 ISBN 123456789
20831
20832 ISBN 1234567890
20833
20834 ISBN 12345678901
20835 !! html/php
20836 <p>ISBN 123456789
20837 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20838 </p><p>ISBN 12345678901
20839 </p>
20840 !! html/parsoid
20841 <p>ISBN 123456789</p>
20842
20843 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
20844
20845 <p>ISBN 12345678901</p>
20846 !! end
20847
20848
20849 !! test
20850 ISBN with trailing year (T9110)
20851 !! wikitext
20852 ISBN 1-234-56789-0 - 2006
20853
20854 ISBN 1 234 56789 0 - 2006
20855 !! html/php
20856 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
20857 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
20858 </p>
20859 !! html/parsoid
20860 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
20861
20862 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
20863 !! end
20864
20865
20866 !! test
20867 anchorencode
20868 !! wikitext
20869 {{anchorencode:foo bar©#%n}}
20870 !! html
20871 <p>foo_bar.C2.A9.23.25n
20872 </p>
20873 !! end
20874
20875 !! test
20876 anchorencode trims spaces
20877 !! wikitext
20878 {{anchorencode: __pretty__please__}}
20879 !! html
20880 <p>pretty_please
20881 </p>
20882 !! end
20883
20884 !! test
20885 anchorencode deals with links
20886 !! wikitext
20887 {{anchorencode: [[hello|world]] [[hi]]}}
20888 !! html
20889 <p>world_hi
20890 </p>
20891 !! end
20892
20893 !! test
20894 anchorencode deals with templates
20895 !! wikitext
20896 {{anchorencode: {{Foo}} }}
20897 !! html
20898 <p>FOO
20899 </p>
20900 !! end
20901
20902 !! test
20903 anchorencode encodes like the TOC generator: (T20431)
20904 !! wikitext
20905 === _ +:.3A%3A&&amp;]] ===
20906 {{anchorencode: _ +:.3A%3A&&amp;]] }}
20907 __NOEDITSECTION__
20908 !! html
20909 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
20910 <p>.2B:.3A.253A.26.26.5D.5D
20911 </p>
20912 !! end
20913
20914 !! test
20915 T8200: blockquotes and paragraph formatting
20916 !! wikitext
20917 <blockquote>
20918 foo
20919 </blockquote>
20920
20921 bar
20922
20923 baz
20924 !! html
20925 <blockquote>
20926 <p>foo
20927 </p>
20928 </blockquote>
20929 <p>bar
20930 </p>
20931 <pre>baz
20932 </pre>
20933 !! end
20934
20935 !! test
20936 T10293: Use of center tag ruins paragraph formatting
20937 !! wikitext
20938 <center>
20939 foo
20940 </center>
20941
20942 bar
20943
20944 baz
20945 !! html
20946 <center>
20947 <p>foo
20948 </p>
20949 </center>
20950 <p>bar
20951 </p>
20952 <pre>baz
20953 </pre>
20954 !! end
20955
20956 !!test
20957 Parsing of overlapping (improperly nested) inline html tags
20958 !! wikitext
20959 <span><s>x</span></s>
20960 !! html/php
20961 <p><span><s>x&lt;/span&gt;</s></span>
20962 </p>
20963 !! html/parsoid
20964 <p><span><s>x</s></span>
20965 </p>
20966 !!end
20967
20968 ###
20969 ### Language variants related tests
20970 ###
20971 !! test
20972 Self-link in language variants
20973 !! options
20974 title=[[Dunav]] language=sr
20975 !! wikitext
20976 Both [[Dunav]] and [[Дунав]] are names for this river.
20977 !! html
20978 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
20979 </p>
20980 !!end
20981
20982 !! article
20983 Дуна
20984 !! text
20985 content
20986 !! endarticle
20987
20988 !! test
20989 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
20990 !! options
20991 title=[[Duna]] language=sr
20992 !! wikitext
20993 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
20994 !! html
20995 <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.
20996 </p>
20997 !! end
20998
20999 !! test
21000 Link to a section of a variant of this title shouldn't be parsed as self-link
21001 !! options
21002 title=[[Duna]] language=sr
21003 !! wikitext
21004 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
21005 !! html
21006 <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.
21007 </p>
21008 !! end
21009
21010 !! test
21011 Link to pages in language variants
21012 !! options
21013 language=sr
21014 !! wikitext
21015 Main Page can be written as [[Маин Паге]]
21016 !! html
21017 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
21018 </p>
21019 !!end
21020
21021
21022 !! test
21023 Multiple links to pages in language variants
21024 !! options
21025 language=sr
21026 !! wikitext
21027 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
21028 !! html
21029 <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>.
21030 </p>
21031 !!end
21032
21033
21034 !! test
21035 Simple template in language variants
21036 !! options
21037 language=sr
21038 !! wikitext
21039 {{тест}}
21040 !! html
21041 <p>This is a test template
21042 </p>
21043 !! end
21044
21045
21046 !! test
21047 Template with explicit namespace in language variants
21048 !! options
21049 language=sr
21050 !! wikitext
21051 {{Template:тест}}
21052 !! html
21053 <p>This is a test template
21054 </p>
21055 !! end
21056
21057
21058 !! test
21059 Basic test for template parameter in language variants
21060 !! options
21061 language=sr
21062 !! wikitext
21063 {{парамтест|param=foo}}
21064 !! html
21065 <p>This is a test template with parameter foo
21066 </p>
21067 !! end
21068
21069 !! test
21070 Simple category in language variants
21071 !! options
21072 language=sr cat
21073 !! wikitext
21074 [[Category:МедиаWики Усер'с Гуиде]]
21075 !! html/php
21076 cat=МедиаWики_Усер'с_Гуиде sort=
21077 !! html/parsoid
21078 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
21079 !! end
21080
21081 !! article
21082 Category:分类
21083 !! text
21084 blah
21085 !! endarticle
21086
21087 !! article
21088 Category:分類
21089 !! text
21090 blah
21091 !! endarticle
21092
21093 ## We used to, but no longer wt2wt this test since the default serializer
21094 ## will normalize all categories to serialize on their own line.
21095 ## This wikitext usage is going to be fairly uncommon in production and
21096 ## selser will take care of preserving formatting in those scenarios.
21097 !! test
21098 Don't convert blue categorylinks to another variant (T35210)
21099 !! options
21100 cat
21101 language=zh
21102 parsoid=wt2html
21103 !! wikitext
21104 [[A]][[Category:分类]]
21105 !! html/php
21106 cat=分类 sort=
21107 !! html/parsoid
21108 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
21109 <link rel="mw:PageProp/Category" href="./Category:分类"/>
21110 !! end
21111
21112 !! test
21113 Stripping -{}- tags (language variants)
21114 !! options
21115 language=sr
21116 !! wikitext
21117 Latin proverb: -{Ne nuntium necare}-
21118 !! html
21119 <p>Latin proverb: Ne nuntium necare
21120 </p>
21121 !! end
21122
21123
21124 !! test
21125 Prevent conversion with -{}- tags (language variants)
21126 !! options
21127 language=sr variant=sr-ec
21128 !! wikitext
21129 Latinski: -{Ne nuntium necare}-
21130 !! html
21131 <p>Латински: Ne nuntium necare
21132 </p>
21133 !! end
21134
21135
21136 !! test
21137 Prevent conversion of text with -{}- tags (language variants)
21138 !! options
21139 language=sr variant=sr-ec
21140 !! wikitext
21141 Latinski: -{Ne nuntium necare}-
21142 !! html
21143 <p>Латински: Ne nuntium necare
21144 </p>
21145 !! end
21146
21147
21148 !! test
21149 Prevent conversion of links with -{}- tags (language variants)
21150 !! options
21151 language=sr variant=sr-ec
21152 !! wikitext
21153 -{[[Main Page]]}-
21154 !! html
21155 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21156 </p>
21157 !! end
21158
21159
21160 !! test
21161 -{}- tags within headlines (within html for parserConvert())
21162 !! options
21163 language=sr variant=sr-ec
21164 !! wikitext
21165 == -{Naslov}- ==
21166 !! html
21167 <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>
21168
21169 !! end
21170
21171
21172 !! test
21173 Explicit definition of language variant alternatives
21174 !! options
21175 language=zh variant=zh-tw
21176 !! wikitext
21177 -{zh:China;zh-tw:Taiwan}-, not China
21178 !! html
21179 <p>Taiwan, not China
21180 </p>
21181 !! end
21182
21183
21184 !! test
21185 Conversion around HTML tags
21186 !! options
21187 language=sr variant=sr-ec
21188 !! wikitext
21189 -{H|span=>sr-ec:script;title=>sr-ec:src;}-
21190 <span title="La-{sr-el:L;sr-ec:C;}-tin">ski</span>
21191 !! html
21192 <p>
21193 <span title="ЛаCтин">ски</span>
21194 </p>
21195 !! end
21196
21197
21198 !! test
21199 Explicit session-wise language variant mapping (A flag and - flag)
21200 !! options
21201 language=zh variant=zh-tw
21202 !! wikitext
21203 Taiwan is not China.
21204 But -{A|zh:China;zh-tw:Taiwan}- is China,
21205 (This-{-|zh:China;zh-tw:Taiwan}- should be stripped!)
21206 and -{China}- is China.
21207 !! html
21208 <p>Taiwan is not China.
21209 But Taiwan is Taiwan,
21210 (This should be stripped!)
21211 and China is China.
21212 </p>
21213 !! end
21214
21215 !! test
21216 Explicit session-wise language variant mapping (H flag for hide)
21217 !! options
21218 language=zh variant=zh-tw
21219 !! wikitext
21220 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
21221 Taiwan is China.
21222 !! html
21223 <p>(This should be stripped!)
21224 Taiwan is Taiwan.
21225 </p>
21226 !! end
21227
21228 !! test
21229 Adding explicit conversion rule for title (T flag)
21230 !! options
21231 language=zh variant=zh-tw showtitle
21232 !! wikitext
21233 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
21234 !! html
21235 Taiwan
21236 <p>Should be stripped!
21237 </p>
21238 !! end
21239
21240 !! test
21241 Testing that changing the language variant here in the tests actually works
21242 !! options
21243 language=zh variant=zh showtitle
21244 !! wikitext
21245 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
21246 !! html
21247 China
21248 <p>Should be stripped!
21249 </p>
21250 !! end
21251
21252 !! test
21253 Recursive conversion of alt and title attrs shouldn't clear converter state
21254 !! options
21255 language=zh variant=zh-cn showtitle
21256 !! wikitext
21257 -{H|zh-cn:Exclamation;zh-tw:exclamation;}-
21258 Should be stripped-{T|zh-cn:China;zh-tw:Taiwan}-<span title="exclamation">!</span>
21259 !! html
21260 China
21261 <p>
21262 Should be stripped<span title="Exclamation">!</span>
21263 </p>
21264 !! end
21265
21266 !! test
21267 T26072: more test on conversion rule for title
21268 !! options
21269 language=zh variant=zh-tw showtitle
21270 !! wikitext
21271 This should be stripped-{T|zh:China;zh-tw:Taiwan}-!
21272 This won't take interferes with the title rule-{H|zh:Beijing;zh-tw:Taipei}-.
21273 !! html
21274 Taiwan
21275 <p>This should be stripped!
21276 This won't take interferes with the title rule.
21277 </p>
21278 !! end
21279
21280 !! test
21281 Partly disable title conversion if variant == main language code
21282 !! options
21283 language=zh variant=zh title=[[ZH]] showtitle
21284 !! wikitext
21285 -{T|zh-cn:CN;zh-tw:TW}-
21286 !! html
21287 ZH
21288 <p>
21289 </p>
21290 !! end
21291
21292 !! test
21293 Partly disable title conversion if variant == main language code, more
21294 !! options
21295 language=zh variant=zh title=[[ZH]] showtitle
21296 !! wikitext
21297 -{T|TW}-
21298 !! html
21299 ZH
21300 <p>
21301 </p>
21302 !! end
21303
21304 !! test
21305 Raw output of variant escape tags (R flag)
21306 !! options
21307 language=zh variant=zh-tw
21308 !! wikitext
21309 Raw: -{R|zh:China;zh-tw:Taiwan}-
21310 !! html
21311 <p>Raw: zh:China;zh-tw:Taiwan
21312 </p>
21313 !! end
21314
21315 !! test
21316 Nested markup inside raw output of variant escape tags (R flag)
21317 !! options
21318 language=zh variant=zh-tw
21319 !! wikitext
21320 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
21321 !! html
21322 <p>Nested raw: nested Taiwan nested
21323 </p>
21324 !! end
21325
21326 !! test
21327 Templates inside raw output of variant escape tags (R flag)
21328 !! options
21329 language=zh variant=zh-tw
21330 !! wikitext
21331 Nested raw: -{R|nested {{echo|hi}} templates}-
21332 !! html
21333 <p>Nested raw: nested hi templates
21334 </p>
21335 !! end
21336
21337 !! test
21338 Strings evaluating false shouldn't be ignored by Language converter (T51072)
21339 !! options
21340 language=zh variant=zh-cn
21341 !! input
21342 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
21343 !! result
21344 <p>0
21345 </p>
21346 !! end
21347
21348 !! test
21349 Conversion rules from [numeric-only string] to [something else] (T48634)
21350 !! options
21351 language=zh variant=zh-cn
21352 !! input
21353 -{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
21354 !! result
21355 <p>D12345EE12345
21356 </p>
21357 !! end
21358
21359 !! test
21360 Bidirectional converter rule entries with an empty value should be ignored (T53551)
21361 !! options
21362 language=zh variant=zh-cn
21363 !! input
21364 -{H|zh-cn:foo;zh-tw:;}-foobar
21365 !! result
21366 <p>foobar
21367 </p>
21368 !! end
21369
21370 !! test
21371 Unidirectional converter rule entries with an empty "from" string should be ignored (T53551)
21372 !! options
21373 language=zh variant=zh-cn
21374 !! input
21375 -{H|=>zh-cn:foo;}-foobar
21376 !! result
21377 <p>foobar
21378 </p>
21379 !! end
21380
21381 !! test
21382 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
21383 !! options
21384 language=zh variant=zh-cn
21385 !! input
21386 -{H|}-foobar
21387 !! result
21388 <p>foobar
21389 </p>
21390 !! end
21391
21392 !! test
21393 Nested using of manual convert syntax
21394 !! options
21395 language=zh variant=zh-hk
21396 !! wikitext
21397 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
21398 !! html
21399 <p>Nested: Hello Hong Kong!
21400 </p>
21401 !! end
21402
21403 !! test
21404 HTML markups with conversion syntax in attribs, nested in other conversion blocks
21405 !! options
21406 language=zh variant=zh-cn
21407 !! wikitext
21408 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
21409 !! html
21410 <p><span title="X">A</span>
21411 </p>
21412 !! end
21413
21414 !! test
21415 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet)
21416 !! options
21417 language=zh variant=zh-cn disabled
21418 !! wikitext
21419 -{<span title="-{X}-">A</span>}-
21420 !! html
21421 <p><span title="X">A</span>
21422 </p>
21423 !! end
21424
21425 # Since Parsoid is starting to emit canonical wikitext for links,
21426 # [http://example.com http://example.com] will not RT back to that
21427 # form anymore.
21428 !! test
21429 Proper conversion of text in external links
21430 !! options
21431 language=sr variant=sr-ec
21432 parsoid=wt2html
21433 !! wikitext
21434 http://www.google.com
21435 gopher://www.google.com
21436 [http://www.google.com http://www.google.com]
21437 [gopher://www.google.com gopher://www.google.com]
21438 [https://www.google.com irc://www.google.com]
21439 [ftp://www.google.com www.google.com/ftp://dir]
21440 [//www.google.com www.google.com]
21441 !! html/php
21442 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
21443 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
21444 <a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
21445 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
21446 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
21447 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
21448 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
21449 </p>
21450 !! html/parsoid
21451 <p><a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
21452 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
21453 <a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
21454 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
21455 <a rel="mw:ExtLink" href="https://www.google.com">irc://www.google.com</a>
21456 <a rel="mw:ExtLink" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
21457 <a rel="mw:ExtLink" href="//www.google.com">www.гоогле.цом</a></p>
21458 !! end
21459
21460 !! test
21461 Do not convert roman numbers to language variants
21462 !! options
21463 language=sr variant=sr-ec
21464 !! wikitext
21465 Fridrih IV je car.
21466 !! html
21467 <p>Фридрих IV је цар.
21468 </p>
21469 !! end
21470
21471 !! test
21472 Unclosed language converter markup "-{"
21473 !! options
21474 language=sr
21475 !! wikitext
21476 -{T|hello
21477 !! html
21478 <p>-{T|hello
21479 </p>
21480 !! end
21481
21482 !! test
21483 Don't convert raw rule "-{R|=&gt;}-" to "=>"
21484 !! options
21485 language=sr
21486 !! wikitext
21487 -{R|=&gt;}-
21488 !! html
21489 <p>=&gt;
21490 </p>
21491 !!end
21492
21493 !! test
21494 Don't break link parsing if language converter markup is in the caption.
21495 !! options
21496 language=sr variant=sr-ec
21497 !! wikitext
21498 [[Main Page|-{R|main page}-]]
21499 !! html
21500 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
21501 </p>
21502 !! end
21503
21504 !! test
21505 T146304: Don't break template parsing if language converter markup is in the parameter.
21506 !! options
21507 language=sr variant=sr-ec
21508 !! wikitext
21509 {{echo|-{R|foo}-}}
21510 !! html/php
21511 <p>foo
21512 </p>
21513 !! end
21514
21515 !! test
21516 T146305: Don't break image parsing if language converter markup is in the caption.
21517 !! options
21518 language=sr
21519 !! wikitext
21520 [[File:Foobar.jpg|thumb|-{R|caption:}-]]
21521 !! html/php
21522 <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>
21523
21524 !! html/parsoid
21525 <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>
21526 !! end
21527
21528 !! test
21529 T146305: Don't break image parsing if nested language converter markup is in the caption.
21530 !! options
21531 language=zh variant=zh-cn
21532 !! wikitext
21533 [[File:Foobar.jpg|thumb|-{zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
21534 !! html/php
21535 <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>
21536
21537 !! html/parsoid
21538 <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>
21539 !! end
21540
21541 !! test
21542 Don't break gallery if language converter markup is inside.
21543 !! options
21544 language=zh
21545 !! wikitext
21546 <gallery>
21547 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
21548 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
21549 </gallery>
21550 !! html
21551 <ul class="gallery mw-gallery-traditional">
21552 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21553 <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>
21554 <div class="gallerytext">
21555 <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>
21556 </p>
21557 </div>
21558 </div></li>
21559 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21560 <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>
21561 <div class="gallerytext">
21562 <p>This is a test template
21563 </p>
21564 </div>
21565 </div></li>
21566 </ul>
21567
21568 !! end
21569
21570 !! test
21571 T153135: Don't break list handling if language converter markup is in the item.
21572 !! options
21573 language=zh variant=zh-cn
21574 !! wikitext
21575 ;-{zh-cn:AAA;zh-tw:BBB}-
21576 ;-{R|foo:bar}-
21577 !! html/php
21578 <dl><dt>AAA</dt>
21579 <dt>foo:bar</dt></dl>
21580
21581 !! html/parsoid
21582 <dl>
21583 <dt><span typeof="mw:LanguageVariant" data-mw='{"bidir":[{"l":"zh-cn","t":"AAA"},{"l":"zh-tw","t":"BBB"}],"show":true}'></span></dt>
21584 <dt><span typeof="mw:LanguageVariant" data-mw='{"disabled":true,"show":true,"text":"foo:bar"}'></span></dt>
21585 </dl>
21586 !! end
21587
21588 // Note that parsoid does not protect colons unless language converter
21589 // markup is properly nested, because it is a backtracking parser.
21590 !! test
21591 T153135: Unclosed markup in definition list (code coverage)
21592 !! options
21593 language=zh variant=zh-cn
21594 !! wikitext
21595 ;<b>foo:bar
21596 ;-{zh-cn:AAA
21597 !! html/php
21598 <dl><dt><b>foo:bar</dt>
21599 <dt>-{zh-cn:AAA</b></dt></dl>
21600
21601 !! html/parsoid
21602 <dl>
21603 <dt><b>foo:bar</b></dt>
21604 <b>
21605 <dt>-{zh-cn</dt>
21606 <dd>AAA</dd>
21607 </b></dl>
21608 !! end
21609
21610 !! test
21611 T153135: Nested language converter markup in definition list (code coverage)
21612 !! options
21613 language=zh variant=zh-cn
21614 !! wikitext
21615 ;-{zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
21616 !! html/php
21617 <dl><dt>AAA foo:bar bat:baz</dt>
21618 <dd>def</dd></dl>
21619
21620 !! html/parsoid
21621 <dl>
21622 <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>
21623 <dd>def</dd>
21624 </dl>
21625 !! end
21626
21627 !! test
21628 T153140: Don't break table handling if language converter markup is in the cell.
21629 !! options
21630 language=sr variant=sr-ec
21631 !! wikitext
21632 {|
21633 |-
21634 | -{R|B}-
21635 |}
21636 !! html/php
21637 <table>
21638
21639 <tr>
21640 <td> B
21641 </td></tr></table>
21642
21643 !! html/parsoid
21644 <table>
21645
21646 <tr>
21647 <td> B
21648 </td></tr></table>
21649
21650 !! end
21651
21652 !! test
21653 T2529: Uncovered bullet
21654 !! wikitext
21655 * Foo {{bullet}}
21656 !! html
21657 <ul><li> Foo </li>
21658 <li> Bar</li></ul>
21659
21660 !! end
21661
21662 # Plain MediaWiki does not remove empty lists, but tidy actually does.
21663 # Templates in Wikipedia rely on this behavior, as tidy has always been
21664 # enabled there. These tests are normally run *without* tidy, so specify the
21665 # full output here.
21666 # To test realistic parsing behavior, apply a tidy-like transformation to both
21667 # the expected output and your parser's output.
21668 !! test
21669 T2529: Uncovered bullet leaving empty list, normally removed by tidy
21670 !! wikitext
21671 ******* Foo {{bullet}}
21672 !! html
21673 <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>
21674 <li> Bar</li></ul>
21675
21676 !! end
21677
21678 !! test
21679 T2529: Uncovered table already at line-start
21680 !! wikitext
21681 x
21682
21683 {{table}}
21684 y
21685 !! html
21686 <p>x
21687 </p>
21688 <table>
21689 <tr>
21690 <td> 1 </td>
21691 <td> 2
21692 </td></tr>
21693 <tr>
21694 <td> 3 </td>
21695 <td> 4
21696 </td></tr></table>
21697 <p>y
21698 </p>
21699 !! end
21700
21701 !! test
21702 T2529: Uncovered bullet in parser function result
21703 !! wikitext
21704 * Foo {{lc:{{bullet}} }}
21705 !! html
21706 <ul><li> Foo </li>
21707 <li> bar</li></ul>
21708
21709 !! end
21710
21711 !! test
21712 T7678: Double-parsed template argument
21713 !! wikitext
21714 {{lc:{{{1}}}|hello}}
21715 !! html
21716 <p>{{{1}}}
21717 </p>
21718 !! end
21719
21720 !! test
21721 T7678: Double-parsed template invocation
21722 !! wikitext
21723 {{lc:{{paramtest {{!}} param = hello }} }}
21724 !! html
21725 <p>{{paramtest | param = hello }}
21726 </p>
21727 !! end
21728
21729 !! test
21730 Case insensitivity of parser functions for non-ASCII characters (T10143)
21731 !! options
21732 language=cs
21733 title=[[Main Page]]
21734 !! wikitext
21735 {{PRVNÍVELKÉ:ěščř}}
21736 {{prvnívelké:ěščř}}
21737 {{PRVNÍMALÉ:ěščř}}
21738 {{prvnímalé:ěščř}}
21739 {{MALÁ:ěščř}}
21740 {{malá:ěščř}}
21741 {{VELKÁ:ěščř}}
21742 {{velká:ěščř}}
21743 !! html
21744 <p>Ěščř
21745 Ěščř
21746 ěščř
21747 ěščř
21748 ěščř
21749 ěščř
21750 ĚŠČŘ
21751 ĚŠČŘ
21752 </p>
21753 !! end
21754
21755 !! test
21756 Morwen/13: Unclosed link followed by heading
21757 !! wikitext
21758 [[link
21759 ==heading==
21760 !! html
21761 <p>[[link
21762 </p>
21763 <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>
21764
21765 !! end
21766
21767 !! test
21768 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
21769 !! wikitext
21770 {{foo|
21771 =heading=
21772 !! html
21773 <p>{{foo|
21774 </p>
21775 <h1><span class="mw-headline" id="heading">heading</span></h1>
21776
21777 !! end
21778
21779 !! test
21780 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
21781 !! wikitext
21782 {{foo|
21783 ==heading==
21784 !! html
21785 <p>{{foo|
21786 </p>
21787 <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>
21788
21789 !! end
21790
21791 !! test
21792 Tildes in comments
21793 !! options
21794 pst
21795 !! wikitext
21796 <!-- ~~~~ -->
21797 !! html/php
21798 <!-- ~~~~ -->
21799 !! end
21800
21801 !! test
21802 Paragraphs inside divs (no extra line breaks)
21803 !! wikitext
21804 <div>Line one
21805
21806 Line two</div>
21807 !! html
21808 <div>Line one
21809 Line two</div>
21810
21811 !! end
21812
21813 !! test
21814 Paragraphs inside divs (extra line break on open)
21815 !! wikitext
21816 <div>
21817 Line one
21818
21819 Line two</div>
21820 !! html
21821 <div>
21822 <p>Line one
21823 </p>
21824 Line two</div>
21825
21826 !! end
21827
21828 !! test
21829 Paragraphs inside divs (extra line break on close)
21830 !! wikitext
21831 <div>Line one
21832
21833 Line two
21834 </div>
21835 !! html
21836 <div>Line one
21837 <p>Line two
21838 </p>
21839 </div>
21840
21841 !! end
21842
21843 !! test
21844 Paragraphs inside divs (extra line break on open and close)
21845 !! wikitext
21846 <div>
21847 Line one
21848
21849 Line two
21850 </div>
21851 !! html
21852 <div>
21853 <p>Line one
21854 </p><p>Line two
21855 </p>
21856 </div>
21857
21858 !! end
21859
21860 !! test
21861 Nesting tags, paragraphs on lines which begin with <div>
21862 !! wikitext
21863 <div></div><strong>A
21864 B</strong>
21865 !! html/php+tidy
21866 <p><strong>A</strong></p>
21867 <p><strong>B</strong></p>
21868 !! html/parsoid
21869 <div></div>
21870 <p><strong>A
21871 B</strong>
21872 </p>
21873 !! end
21874
21875 # T8200: <blockquote> should behave like <div> with respect to line breaks
21876 !! test
21877 T8200: paragraphs inside blockquotes (no extra line breaks)
21878 !! wikitext
21879 <blockquote>Line one
21880
21881 Line two</blockquote>
21882 !! html
21883 <blockquote>Line one
21884 Line two</blockquote>
21885
21886 !! html+tidy
21887 <blockquote>
21888 <p>Line one Line two</p>
21889 </blockquote>
21890 !! end
21891
21892 !! test
21893 T8200: paragraphs inside blockquotes (extra line break on open)
21894 !! wikitext
21895 <blockquote>
21896 Line one
21897
21898 Line two</blockquote>
21899 !! html
21900 <blockquote>
21901 <p>Line one
21902 </p>
21903 Line two</blockquote>
21904
21905 !! html+tidy
21906 <blockquote>
21907 <p>Line one</p>
21908 Line two</blockquote>
21909 !! end
21910
21911 !! test
21912 T8200: paragraphs inside blockquotes (extra line break on close)
21913 !! wikitext
21914 <blockquote>Line one
21915
21916 Line two
21917 </blockquote>
21918 !! html
21919 <blockquote>Line one
21920 <p>Line two
21921 </p>
21922 </blockquote>
21923
21924 !! html+tidy
21925 <blockquote>
21926 <p>Line one</p>
21927 <p>Line two</p>
21928 </blockquote>
21929 !! end
21930
21931 !! test
21932 T8200: paragraphs inside blockquotes (extra line break on open and close)
21933 !! wikitext
21934 <blockquote>
21935 Line one
21936
21937 Line two
21938 </blockquote>
21939 !! html
21940 <blockquote>
21941 <p>Line one
21942 </p><p>Line two
21943 </p>
21944 </blockquote>
21945
21946 !! html+tidy
21947 <blockquote>
21948 <p>Line one</p>
21949 <p>Line two</p>
21950 </blockquote>
21951 !! end
21952
21953 !! test
21954 Paragraphs inside blockquotes/divs (no extra line breaks)
21955 !! wikitext
21956 <blockquote><div>Line one
21957
21958 Line two</div></blockquote>
21959 !! html
21960 <blockquote><div>Line one
21961 Line two</div></blockquote>
21962
21963 !! end
21964
21965 !! test
21966 Paragraphs inside blockquotes/divs (extra line break on open)
21967 !! wikitext
21968 <blockquote><div>
21969 Line one
21970
21971 Line two</div></blockquote>
21972 !! html
21973 <blockquote><div>
21974 <p>Line one
21975 </p>
21976 Line two</div></blockquote>
21977
21978 !! end
21979
21980 !! test
21981 Paragraphs inside blockquotes/divs (extra line break on close)
21982 !! wikitext
21983 <blockquote><div>Line one
21984
21985 Line two
21986 </div></blockquote>
21987 !! html
21988 <blockquote><div>Line one
21989 <p>Line two
21990 </p>
21991 </div></blockquote>
21992
21993 !! end
21994
21995 !! test
21996 Paragraphs inside blockquotes/divs (extra line break on open and close)
21997 !! wikitext
21998 <blockquote><div>
21999 Line one
22000
22001 Line two
22002 </div></blockquote>
22003 !! html
22004 <blockquote><div>
22005 <p>Line one
22006 </p><p>Line two
22007 </p>
22008 </div></blockquote>
22009
22010 !! end
22011
22012 !! test
22013 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
22014 !! options
22015 wgLinkHolderBatchSize=0
22016 !! wikitext
22017 [[meatball:1]]
22018 [[meatball:2]]
22019 [[meatball:3]]
22020 !! html
22021 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
22022 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
22023 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
22024 </p>
22025 !! end
22026
22027 !! test
22028 Free external link invading image caption
22029 !! wikitext
22030 [[Image:Foobar.jpg|thumb|http://x|hello]]
22031 !! html
22032 <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>
22033
22034 !! end
22035
22036 !! test
22037 T17196: localised external link numbers
22038 !! options
22039 language=fa
22040 !! wikitext
22041 [http://en.wikipedia.org/]
22042 !! html/php
22043 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
22044 </p>
22045 !! html/parsoid
22046 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/"></a></p>
22047 !! end
22048
22049 !! test
22050 Multibyte character in padleft
22051 !! wikitext
22052 {{padleft:-Hello|7|Æ}}
22053 !! html
22054 <p>Æ-Hello
22055 </p>
22056 !! end
22057
22058 !! test
22059 Multibyte character in padright
22060 !! wikitext
22061 {{padright:Hello-|7|Æ}}
22062 !! html
22063 <p>Hello-Æ
22064 </p>
22065 !! end
22066
22067 !!test
22068 formatdate parser function
22069 !! wikitext
22070 {{#formatdate:2009-03-24}}
22071 !! html
22072 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
22073 </p>
22074 !! end
22075
22076 !!test
22077 formatdate parser function, with default format
22078 !! wikitext
22079 {{#formatdate:2009-03-24|mdy}}
22080 !! html
22081 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
22082 </p>
22083 !! end
22084
22085 !! test
22086 Spacing of numbers in formatted dates
22087 !! wikitext
22088 {{#formatdate:January 15}}
22089 !! html
22090 <p><span class="mw-formatted-date" title="01-15">January 15</span>
22091 </p>
22092 !! end
22093
22094 !! test
22095 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
22096 !! options
22097 language=nl title=[[MediaWiki:Common.css]]
22098 !! wikitext
22099 {{#formatdate:2009-03-24|dmy}}
22100 !! html
22101 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
22102 </p>
22103 !! end
22104
22105 #
22106 #
22107 #
22108
22109 #
22110 # Edit comments
22111 #
22112
22113 !! test
22114 Edit comment with link
22115 !! options
22116 comment
22117 !! wikitext
22118 I like the [[Main Page]] a lot
22119 !! html/php
22120 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
22121 !!end
22122
22123 !! test
22124 Edit comment with link and link text
22125 !! options
22126 comment
22127 !! wikitext
22128 I like the [[Main Page|best pages]] a lot
22129 !! html/php
22130 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
22131 !!end
22132
22133 !! test
22134 Edit comment with link and link text with suffix
22135 !! options
22136 comment
22137 !! wikitext
22138 I like the [[Main Page|best page]]s a lot
22139 !! html/php
22140 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
22141 !!end
22142
22143 !! test
22144 Edit comment with section link (non-local, eg in history list)
22145 !! options
22146 comment title=[[Main Page]]
22147 !! wikitext
22148 /* External links */ removed bogus entries
22149 !! html/php
22150 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
22151 !!end
22152
22153 !! test
22154 Edit comment with section link and text before it (non-local, eg in history list)
22155 !! options
22156 comment title=[[Main Page]]
22157 !! wikitext
22158 pre-comment text /* External links */ removed bogus entries
22159 !! html/php
22160 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>
22161 !!end
22162
22163 !! test
22164 Edit comment with section link (local, eg in diff view)
22165 !! options
22166 comment local title=[[Main Page]]
22167 !! wikitext
22168 /* External links */ removed bogus entries
22169 !! html/php
22170 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
22171 !!end
22172
22173 !! test
22174 Edit comment with subpage link (T16080)
22175 !! options
22176 comment
22177 subpage
22178 title=[[Subpage test]]
22179 !! wikitext
22180 Poked at a [[/subpage]] here...
22181 !! html/php
22182 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
22183 !!end
22184
22185 !! test
22186 Edit comment with subpage link and link text (T16080)
22187 !! options
22188 comment
22189 subpage
22190 title=[[Subpage test]]
22191 !! wikitext
22192 Poked at a [[/subpage|neat little page]] here...
22193 !! html/php
22194 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
22195 !!end
22196
22197 !! test
22198 Edit comment with bogus subpage link in non-subpage NS (T16080)
22199 !! options
22200 comment
22201 title=[[Subpage test]]
22202 !! wikitext
22203 Poked at a [[/subpage]] here...
22204 !! html/php
22205 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...
22206 !!end
22207
22208 !! test
22209 Edit comment with bare anchor link (local, as on diff)
22210 !! options
22211 comment
22212 local
22213 title=[[Main Page]]
22214 !! wikitext
22215 [[#section]]
22216 !! html/php
22217 <a href="#section">#section</a>
22218 !! end
22219
22220 !! test
22221 Edit comment with bare anchor link (non-local, as on history)
22222 !! options
22223 comment
22224 title=[[Main Page]]
22225 !! wikitext
22226 [[#section]]
22227 !! html/php
22228 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
22229 !! end
22230
22231 !! test
22232 Anchor starting with underscore
22233 !! options
22234 title=[[Foo]]
22235 !! wikitext
22236 [[#_ref|One]]
22237 !! html/php
22238 <p><a href="#_ref">One</a>
22239 </p>
22240 !! html/parsoid
22241 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
22242 !! end
22243
22244 !! test
22245 Id starting with underscore
22246 !! wikitext
22247 <div id="_ref"></div>
22248 !! html/*
22249 <div id="_ref"></div>
22250
22251 !! end
22252
22253 !! test
22254 Edit comment with link with more than one pipe (T99346)
22255 !! options
22256 comment
22257 !! wikitext
22258 [[Main Page|Many|pipes]]
22259 !! html/php
22260 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
22261 !! end
22262
22263 !! test
22264 Complex edit comment with link with more than one pipe (T99346)
22265 !! options
22266 comment
22267 !! wikitext
22268 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
22269 !! html/php
22270 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;
22271 !! end
22272
22273 !! test
22274 Space normalisation on autocomment (T24784)
22275 !! options
22276 comment
22277 title=[[Main Page]]
22278 !! wikitext
22279 /* __hello__world__ */
22280 !! html/php
22281 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
22282 !! end
22283
22284 !! test
22285 percent-encoding and + signs in comments (T28410)
22286 !! options
22287 comment
22288 !! wikitext
22289 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
22290 !! html/php
22291 <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>
22292 !! end
22293
22294 # Parsoid doesn't support this yet: see T75581
22295 # but it *should* omit the 'src' attribute if the image is bad.
22296 # PHP side of tests was disabled in
22297 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
22298 # because of issues in the PHP parserTests infrastructure
22299 # (but the output below is indeed what the PHP side emits)
22300 !! test
22301 Bad images - basic functionality
22302 !! wikitext
22303 [[File:Bad.jpg]]
22304 !! DISABLED/html/php
22305 !! html/parsoid
22306 <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>
22307 !! end
22308
22309 !! test
22310 Bad images - T18039: text after bad image disappears
22311 !! wikitext
22312 Foo bar
22313 [[File:Bad.jpg]]
22314 Bar foo
22315 !! DISABLED/html/php
22316 <p>Foo bar
22317 </p><p>Bar foo
22318 </p>
22319 !! html/parsoid
22320 <p>Foo bar
22321 <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>
22322 Bar foo</p>
22323 !! end
22324
22325 !! test
22326 Verify that displaytitle works (T24501) no displaytitle
22327 !! options
22328 showtitle
22329 !! config
22330 wgAllowDisplayTitle=true
22331 wgRestrictDisplayTitle=false
22332 !! wikitext
22333 this is not the the title
22334 !! html/php
22335 Parser test
22336 <p>this is not the the title
22337 </p>
22338 !! end
22339
22340 !! test
22341 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
22342 !! options
22343 showtitle
22344 title=[[Screen]]
22345 !! config
22346 wgAllowDisplayTitle=true
22347 wgRestrictDisplayTitle=false
22348 !! wikitext
22349 this is not the the title
22350 {{DISPLAYTITLE:whatever}}
22351 !! html/php
22352 whatever
22353 <p>this is not the the title
22354 </p>
22355 !! end
22356
22357 !! test
22358 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
22359 !! options
22360 showtitle
22361 title=[[Screen]]
22362 !! config
22363 wgAllowDisplayTitle=true
22364 wgRestrictDisplayTitle=true
22365 !! wikitext
22366 this is not the the title
22367 {{DISPLAYTITLE:whatever}}
22368 !! html/php
22369 Screen
22370 <p>this is not the the title
22371 </p>
22372 !! end
22373
22374 !! test
22375 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
22376 !! options
22377 showtitle
22378 title=[[Screen]]
22379 !! config
22380 wgAllowDisplayTitle=true
22381 wgRestrictDisplayTitle=true
22382 !! wikitext
22383 this is not the the title
22384 {{DISPLAYTITLE:screen}}
22385 !! html/php
22386 screen
22387 <p>this is not the the title
22388 </p>
22389 !! end
22390
22391 !! test
22392 Verify that displaytitle works (T24501) AllowDisplayTitle=false
22393 !! options
22394 showtitle
22395 title=[[Screen]]
22396 !! config
22397 wgAllowDisplayTitle=false
22398 !! wikitext
22399 this is not the the title
22400 {{DISPLAYTITLE:screen}}
22401 !! html/php
22402 Screen
22403 <p>this is not the the title
22404 <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>
22405 </p>
22406 !! end
22407
22408 !! test
22409 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
22410 !! options
22411 showtitle
22412 title=[[Screen]]
22413 !! config
22414 wgAllowDisplayTitle=false
22415 !! wikitext
22416 this is not the the title
22417 !! html/php
22418 Screen
22419 <p>this is not the the title
22420 </p>
22421 !! end
22422
22423 !! test
22424 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
22425 !! options
22426 showtitle
22427 title=[[Screen]]
22428 !! config
22429 wgAllowDisplayTitle=true
22430 wgRestrictDisplayTitle=true
22431 !! wikitext
22432 this is not the the title
22433 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
22434 !! html/php
22435 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
22436 <p>this is not the the title
22437 </p>
22438 !! end
22439
22440 !! test
22441 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
22442 !! options
22443 showtitle
22444 title=[[Screen]]
22445 !! config
22446 wgAllowDisplayTitle=true
22447 wgRestrictDisplayTitle=true
22448 !! wikitext
22449 this is not the the title
22450 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
22451 !! html/php
22452 <span style="color: red;">s</span>creen
22453 <p>this is not the the title
22454 </p>
22455 !! end
22456
22457 !! test
22458 Page status indicators: Empty name is invalid
22459 !! options
22460 showindicators
22461 !! wikitext
22462 <indicator name=" "></indicator>
22463 <indicator></indicator>
22464 !! html/php
22465 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
22466 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
22467 </p>
22468 !! end
22469
22470 !! test
22471 Page status indicators: Weird syntaxes that are okay
22472 !! options
22473 showindicators
22474 !! wikitext
22475 <indicator name="empty" />
22476 <indicator name="name"></indicator>
22477 !! html/php
22478 empty=
22479 name=
22480 <p><br />
22481 </p>
22482 !! end
22483
22484 !! test
22485 Page status indicators: Torture test
22486 !! options
22487 showindicators
22488 !! wikitext
22489 <indicator name="01">hello world</indicator>
22490 <indicator name="02">[[Main Page]]</indicator>
22491 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
22492 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
22493 <indicator name="05">* foo
22494 * bar</indicator>
22495 <indicator name="06"><nowiki>foo</nowiki></indicator>
22496 <indicator name="07"> Preformatted</indicator>
22497 <indicator name="08"><div>Broken tag</indicator>
22498 <indicator name="09">{| class=wikitable
22499 | cell
22500 |}</indicator>
22501 <indicator name="10">Two
22502
22503 paragraphs</indicator>
22504 !! html/php
22505 01=hello world
22506 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22507 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" />
22508 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>
22509 05=<ul><li> foo</li>
22510 <li> bar</li></ul>
22511
22512 06=foo
22513 07=<pre>Preformatted
22514 </pre>
22515 08=<div>Broken tag</div>
22516
22517 09=<table class="wikitable">
22518 <tr>
22519 <td> cell
22520 </td></tr></table>
22521
22522 10=<p>Two
22523 </p><p>paragraphs
22524 </p>
22525 <p><br />
22526 </p><p><br />
22527 </p><p><br />
22528 </p><p><br />
22529 </p><p><br />
22530 </p>
22531 !! end
22532
22533 !! test
22534 preload: check <noinclude> and <includeonly>
22535 !! options
22536 preload
22537 !! wikitext
22538 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
22539 !! html/php
22540 Hello kind world.
22541 !! end
22542
22543 !! test
22544 preload: check <onlyinclude>
22545 !! options
22546 preload
22547 !! wikitext
22548 Goodbye <onlyinclude>Hello world</onlyinclude>
22549 !! html/php
22550 Hello world
22551 !! end
22552
22553 !! test
22554 preload: can pass tags through if we want to
22555 !! options
22556 preload
22557 !! wikitext
22558 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
22559 !! html/php
22560 <includeonly>Hello world</includeonly>
22561 !! end
22562
22563 !! test
22564 preload: check that it doesn't try to do tricks
22565 !! options
22566 preload
22567 !! wikitext
22568 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
22569 !! html/php
22570 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
22571 !! end
22572
22573 !! test
22574 Play a bit with r67090 and T5158
22575 !! wikitext
22576 <div style="width:50% !important">&nbsp;</div>
22577 <div style="width:50%&nbsp;!important">&nbsp;</div>
22578 <div style="width:50%&#160;!important">&nbsp;</div>
22579 <div style="border : solid;">&nbsp;</div>
22580 !! html/php
22581 <div style="width:50% !important">&#160;</div>
22582 <div style="width:50% !important">&#160;</div>
22583 <div style="width:50% !important">&#160;</div>
22584 <div style="border&#160;: solid;">&#160;</div>
22585
22586 !! html/parsoid
22587 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
22588 <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>
22589 <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>
22590 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
22591
22592 !! end
22593
22594 !! test
22595 HTML5 data attributes
22596 !! wikitext
22597 <span data-foo="bar">Baz</span>
22598 <p data-abc-def_hij="">Quuz</p>
22599 !! html/php
22600 <p><span data-foo="bar">Baz</span>
22601 </p>
22602 <p data-abc-def_hij="">Quuz</p>
22603
22604 !! html/parsoid
22605 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
22606 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
22607 !! end
22608
22609 !! test
22610 Strip reserved data attributes
22611 !! wikitext
22612 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
22613 !! html/php
22614 <div data-ok="fred">d</div>
22615
22616 !! html/parsoid
22617 <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>
22618 !! end
22619
22620 !! test
22621 percent-encoding and + signs in internal links (T28410)
22622 !! wikitext
22623 [[User:+%]] [[Page+title%]]
22624 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
22625 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
22626 [[%33%45]] [[%33%45+]]
22627 !! html/php
22628 <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>
22629 <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>
22630 <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>
22631 <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>
22632 </p>
22633 !! html/parsoid
22634 <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>
22635 <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>
22636 <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>
22637 <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>
22638 !! end
22639
22640 !! test
22641 Special characters in embedded file links (T29679)
22642 !! wikitext
22643 [[File:Contains & ampersand.jpg]]
22644 [[File:Does not exist.jpg|Title with & ampersand]]
22645 !! html/php
22646 <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>
22647 <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>
22648 </p>
22649 !! html/parsoid
22650 <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>
22651 <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>
22652 !! end
22653
22654 !! test
22655 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
22656 !! wikitext
22657 Text&apos;s been normalized?
22658 !! html
22659 <p>Text&#39;s been normalized?
22660 </p>
22661 !! end
22662
22663 !! test
22664 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
22665 !! wikitext
22666 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
22667 !! html
22668 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
22669 </p>
22670 !! end
22671
22672 !! test
22673 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
22674 !! wikitext
22675 [http://www.example.org/ ideograms]
22676 !! html
22677 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
22678 </p>
22679 !! end
22680
22681 !! test
22682 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
22683 !! wikitext
22684 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
22685 !! html
22686 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
22687 </p>
22688 !! end
22689
22690 !! article
22691 Mediawiki:loop1
22692 !! text
22693 {{Identical|A}}
22694 !! endarticle
22695
22696 !! article
22697 Mediawiki:loop2
22698 !! text
22699 {{Identical|B}}
22700 !! endarticle
22701
22702 !! article
22703 Template:Identical
22704 !! text
22705 {{int:loop1}}
22706 {{int:loop2}}
22707 !! endarticle
22708
22709 !! test
22710 T33098 Template which includes system messages which includes the template
22711 !! wikitext
22712 {{Identical}}
22713 !! html
22714 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
22715 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
22716 </p>
22717 !! end
22718
22719 !! test
22720 T33490 Turkish: ucfirst 'blah'
22721 !! options
22722 language=tr
22723 !! wikitext
22724 {{ucfirst:blah}}
22725 !! html
22726 <p>Blah
22727 </p>
22728 !! end
22729
22730 !! test
22731 T33490 Turkish: ucfirst 'ix'
22732 !! options
22733 language=tr
22734 !! wikitext
22735 {{ucfirst:ix}}
22736 !! html
22737 <p>İx
22738 </p>
22739 !! end
22740
22741 !! test
22742 T33490 Turkish: lcfirst 'BLAH'
22743 !! options
22744 language=tr
22745 !! wikitext
22746 {{lcfirst:BLAH}}
22747 !! html
22748 <p>bLAH
22749 </p>
22750 !! end
22751
22752 !! test
22753 T33490 Turkish: ucfırst (with a dotless i)
22754 !! options
22755 language=tr
22756 !! wikitext
22757 {{ucfırst:blah}}
22758 !! html
22759 <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>
22760 </p>
22761 !! end
22762
22763 !! test
22764 T33490 ucfırst (with a dotless i) with English language
22765 !! options
22766 language=en
22767 !! wikitext
22768 {{ucfırst:blah}}
22769 !! html
22770 <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>
22771 </p>
22772 !! end
22773
22774 # Note that Parsoid doesn't emit an explicit TOC.
22775 # Note also that the html2wt direction tends to emit an extra newline
22776 # between the __TOC__ magicword and the first heading unless *both*
22777 # the <meta> and the <h2> have a data-parsoid attribute set (even if
22778 # it's "{}").
22779
22780 !! test
22781 T28375: TOC with italics
22782 !! options
22783 title=[[Main Page]]
22784 !! wikitext
22785 __TOC__
22786 == ''Lost'' episodes ==
22787 !! html/php
22788 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22789 <ul>
22790 <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>
22791 </ul>
22792 </div>
22793
22794 <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>
22795
22796 !! html/parsoid
22797 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22798 <h2 data-parsoid='{}'> <i>Lost</i> episodes </h2>
22799 !! end
22800
22801 !! test
22802 T28375: TOC with bold
22803 !! options
22804 title=[[Main Page]]
22805 !! wikitext
22806 __TOC__
22807 == '''should be bold''' then normal text ==
22808 !! html/php
22809 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22810 <ul>
22811 <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>
22812 </ul>
22813 </div>
22814
22815 <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>
22816
22817 !! html/parsoid
22818 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22819 <h2 data-parsoid='{}'> <b>should be bold</b> then normal text </h2>
22820 !! end
22821
22822 !! test
22823 T35845: Headings become cursive in TOC when they contain an image
22824 !! options
22825 title=[[Main Page]]
22826 !! wikitext
22827 __TOC__
22828 == Image [[Image:foobar.jpg]] ==
22829 !! html/php
22830 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22831 <ul>
22832 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
22833 </ul>
22834 </div>
22835
22836 <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>
22837
22838 !! html/parsoid
22839 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22840 <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>
22841 !! end
22842
22843 !! test
22844 T35845 (2): Headings become bold in TOC when they contain a blockquote
22845 !! options
22846 title=[[Main Page]]
22847 !! wikitext
22848 __TOC__
22849 == <blockquote>Quote</blockquote> ==
22850 !! html/php
22851 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22852 <ul>
22853 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
22854 </ul>
22855 </div>
22856
22857 <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>
22858
22859 !! html/php+tidy
22860 <p></p>
22861 <div id="toc" class="toc">
22862 <div class="toctitle">
22863 <h2>Contents</h2>
22864 </div>
22865 <ul>
22866 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
22867 </ul>
22868 </div>
22869 <p></p>
22870 <h2><span class="mw-headline" id="Quote"></span></h2>
22871 <blockquote>
22872 <p><span class="mw-headline" id="Quote">Quote</span></p>
22873 </blockquote>
22874 <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>
22875 !! html/parsoid
22876 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22877 <h2 data-parsoid='{}'> <blockquote>Quote</blockquote> </h2>
22878 !! end
22879
22880 !! test
22881 Unclosed tags in TOC
22882 !! options
22883 title=[[Main Page]]
22884 !! wikitext
22885 __TOC__
22886 == Proof: 2 < 3 ==
22887 <small>Hanc marginis exiguitas non caperet.</small>
22888 QED
22889 !! html/php
22890 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22891 <ul>
22892 <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>
22893 </ul>
22894 </div>
22895
22896 <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>
22897 <p><small>Hanc marginis exiguitas non caperet.</small>
22898 QED
22899 </p>
22900 !! html/parsoid
22901 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22902 <h2 data-parsoid='{}'> Proof: 2 &lt; 3 </h2>
22903 <p><small>Hanc marginis exiguitas non caperet.</small>
22904 QED</p>
22905 !! end
22906
22907 !! test
22908 Multiple tags in TOC
22909 !! wikitext
22910 __TOC__
22911 == <i>Foo</i> <b>Bar</b> ==
22912
22913 == <i>Foo</i> <blockquote>Bar</blockquote> ==
22914 !! html/php
22915 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22916 <ul>
22917 <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>
22918 <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>
22919 </ul>
22920 </div>
22921
22922 <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>
22923 <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>
22924
22925 !! html/php+tidy
22926 <p></p>
22927 <div id="toc" class="toc">
22928 <div class="toctitle">
22929 <h2>Contents</h2>
22930 </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 <p></p>
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></span></h2>
22939 <blockquote>
22940 <p><span class="mw-headline" id="Foo_Bar_2">Bar</span></p>
22941 </blockquote>
22942 <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>
22943 !! html/parsoid
22944 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22945 <h2 data-parsoid='{}'> <i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b> </h2>
22946 <h2> <i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote> </h2>
22947 !! end
22948
22949 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
22950 # html5 tag parsing.
22951 !! test
22952 Tags with parameters in TOC
22953 !! options
22954 parsoid=wt2html
22955 !! wikitext
22956 __TOC__
22957 == <sup class="in-h2">Hello</sup> ==
22958
22959 == <sup class="a > b">Evilbye</sup> ==
22960 !! html/php
22961 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22962 <ul>
22963 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
22964 <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>
22965 </ul>
22966 </div>
22967
22968 <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>
22969 <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>
22970
22971 !! html/parsoid
22972 <meta property="mw:PageProp/toc" />
22973 <h2> <sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup> </h2>
22974
22975 <h2> <sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup> </h2>
22976 !! end
22977
22978 !! test
22979 span tags with directionality in TOC
22980 !! wikitext
22981 __TOC__
22982 == <span dir="ltr">C++</span> ==
22983
22984 == <span dir="rtl">זבנג!</span> ==
22985
22986 == <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> ==
22987
22988 == <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> ==
22989
22990 == <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> ==
22991 !! html/php
22992 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22993 <ul>
22994 <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>
22995 <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>
22996 <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>
22997 <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>
22998 <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>
22999 </ul>
23000 </div>
23001
23002 <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>
23003 <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>
23004 <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>
23005 <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>
23006 <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>
23007
23008 !! html/parsoid
23009 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23010 <h2 data-parsoid='{}'> <span dir="ltr">C++</span> </h2>
23011 <h2> <span dir="rtl">זבנג!</span> </h2>
23012 <h2> <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> </h2>
23013 <h2> <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> </h2>
23014 <h2> <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> </h2>
23015 !! end
23016
23017 !! test
23018 T74884: bdi element in ToC
23019 !! wikitext
23020 __TOC__
23021 == <bdi>test</bdi> ==
23022 !! html/php
23023 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23024 <ul>
23025 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
23026 </ul>
23027 </div>
23028
23029 <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>
23030
23031 !! html/parsoid
23032 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23033 <h2 data-parsoid='{}'> <bdi>test</bdi> </h2>
23034 !! end
23035
23036 !! test
23037 T35715: s/strike element in ToC
23038 !! wikitext
23039 __TOC__
23040 == <s>test</s> test <strike>test</strike> ==
23041 !! html/php
23042 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23043 <ul>
23044 <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>
23045 </ul>
23046 </div>
23047
23048 <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>
23049
23050 !! html/parsoid
23051 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23052 <h2 data-parsoid='{}'> <s>test</s> test <strike>test</strike> </h2>
23053 !! end
23054
23055 # Note that the html output does not have the <p></p>, but the
23056 # html+tidy output *does*. This is because the empty <p></p> is
23057 # removed by the sanitizer, but only when tidy is *not* enabled (!).
23058 !! test
23059 Empty <p> tag in TOC, removed by Sanitizer (T92892)
23060 !! wikitext
23061 __TOC__
23062 == x ==
23063 !! html/php
23064 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23065 <ul>
23066 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
23067 </ul>
23068 </div>
23069
23070 <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>
23071
23072 !! html/php+tidy
23073 <p></p>
23074 <div id="toc" class="toc">
23075 <div class="toctitle">
23076 <h2>Contents</h2>
23077 </div>
23078 <ul>
23079 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
23080 </ul>
23081 </div>
23082 <p></p>
23083 <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>
23084 !! html/parsoid
23085 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23086 <h2 data-parsoid='{}'> x </h2>
23087 !! end
23088
23089 !! article
23090 MediaWiki:T34057
23091 !! text
23092 == {{int:headline_sample}} ==
23093 !! endarticle
23094
23095 !! test
23096 T34057: Title needed when expanding <h> nodes.
23097 !! options
23098 title=[[Main Page]]
23099 !! wikitext
23100 {{int:T34057}}
23101 !! html
23102 <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>
23103
23104 !! end
23105
23106 !! test
23107 Strip marker in urlencode
23108 !! wikitext
23109 {{urlencode:x<nowiki/>y}}
23110 {{urlencode:x<nowiki/>y|wiki}}
23111 {{urlencode:x<nowiki/>y|path}}
23112 {{urlencode:x<pre id="one">two</pre>y}}
23113 !! html/php
23114 <p>xy
23115 xy
23116 xy
23117 xy
23118 </p>
23119 !! end
23120
23121 !! test
23122 Strip marker in lc
23123 !! wikitext
23124 {{lc:x<nowiki/>y}}
23125 !! html
23126 <p>xy
23127 </p>
23128 !! end
23129
23130 !! test
23131 Strip marker in uc
23132 !! wikitext
23133 {{uc:x<nowiki/>y}}
23134 !! html
23135 <p>XY
23136 </p>
23137 !! end
23138
23139 !! test
23140 Strip marker in formatNum
23141 !! wikitext
23142 {{formatnum:1<nowiki/>2}}
23143 {{formatnum:1<nowiki/>2|R}}
23144 !! html
23145 <p>12
23146 12
23147 </p>
23148 !! end
23149
23150 !! test
23151 Check noCommafy in formatNum
23152 !! options
23153 language=be-tarask
23154 !! wikitext
23155 {{formatnum:123456.78}}
23156 {{formatnum:123456.78|NOSEP}}
23157 !! html
23158 <p>123 456,78
23159 123456.78
23160 </p>
23161 !! end
23162
23163 !! test
23164 Wrong option for formatNum (T58199)
23165 !! wikitext
23166 {{formatnum:1,234.56|Random}}
23167 {{formatnum:1,234.56|EVERYTHING}}
23168 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
23169 !! html
23170 <p>1,234.56
23171 1,234.56
23172 1,234.56
23173 </p>
23174 !! end
23175
23176 !! test
23177 Strip marker in grammar
23178 !! options
23179 language=fi
23180 !! wikitext
23181 {{grammar:elative|foo<nowiki/>bar}}
23182 !! html
23183 <p>foobarista
23184 </p>
23185 !! end
23186
23187 !! test
23188 Strip marker in padleft
23189 !! wikitext
23190 {{padleft:|2|x<nowiki/>y}}
23191 !! html
23192 <p>xy
23193 </p>
23194 !! end
23195
23196 !! test
23197 Strip marker in padright
23198 !! wikitext
23199 {{padright:|2|x<nowiki/>y}}
23200 !! html
23201 <p>xy
23202 </p>
23203 !! end
23204
23205 !! test
23206 Strip marker in anchorencode
23207 !! wikitext
23208 {{anchorencode:x<nowiki/>y}}
23209 !! html
23210 <p>xy
23211 </p>
23212 !! end
23213
23214 !! test
23215 nowiki inside link inside heading (T20295)
23216 !! wikitext
23217 ==[[foo|x<nowiki>y</nowiki>z]]==
23218 !! html
23219 <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>
23220
23221 !! end
23222
23223 !! test
23224 new support for bdi element (T33817)
23225 !! wikitext
23226 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
23227 !! html
23228 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
23229
23230 !!end
23231
23232 !! test
23233 Ignore pipe between table row attributes
23234 !! wikitext
23235 {|
23236 | quux
23237 |- id=foo | style='color: red'
23238 | bar
23239 |}
23240 !! html
23241 <table>
23242 <tr>
23243 <td> quux
23244 </td></tr>
23245 <tr id="foo" style="color: red">
23246 <td> bar
23247 </td></tr></table>
23248
23249 !! end
23250
23251 !!test
23252 Language parser function
23253 !! wikitext
23254 {{#language:ar}}
23255 !! html
23256 <p>العربية
23257 </p>
23258 !! end
23259
23260 !!test
23261 Padleft and padright as substr
23262 !! wikitext
23263 {{padleft:|3|abcde}}
23264 {{padright:|3|abcde}}
23265 !! html
23266 <p>abc
23267 abc
23268 </p>
23269 !! end
23270
23271 !!test
23272 Special parser function
23273 !! wikitext
23274 {{#special:RandomPage}}
23275 {{#special:BaDtItLe}}
23276 {{#special:Foobar}}
23277 !! html
23278 <p>Special:Random
23279 Special:Badtitle
23280 Special:Foobar
23281 </p>
23282 !! end
23283
23284 !!test
23285 T36939 - Case insensitive link parsing ([HttP://])
23286 !! wikitext
23287 [HttP://MediaWiki.Org/]
23288 !! html/php
23289 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
23290 </p>
23291 !! html/parsoid
23292 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/"></a></p>
23293 !! end
23294
23295 !!test
23296 T36939 - Case insensitive link parsing ([HttP:// title])
23297 !! wikitext
23298 [HttP://MediaWiki.Org/ MediaWiki]
23299 !! html
23300 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
23301 </p>
23302 !! end
23303
23304 !!test
23305 T36939 - Case insensitive link parsing (HttP://)
23306 !! wikitext
23307 HttP://MediaWiki.Org/
23308 !! html/php
23309 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
23310 </p>
23311 !! html/parsoid
23312 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
23313 !! end
23314
23315 !!test
23316 Disable TOC
23317 !! options
23318 notoc
23319 !! wikitext
23320 Lead
23321 == Section 1 ==
23322 == Section 2 ==
23323 == Section 3 ==
23324 == Section 4 ==
23325 == Section 5 ==
23326 !! html
23327 <p>Lead
23328 </p>
23329
23330 <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>
23331 <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>
23332 <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>
23333 <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>
23334 <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>
23335
23336 !! end
23337
23338
23339 ###
23340 ### Parsoid-specific tests
23341 ### Parsoid-PHP parser incompatibilities
23342 ###
23343 !!test
23344 1. SOL-sensitive wikitext tokens as template-args
23345 !!options
23346 parsoid=wt2html,wt2wt
23347 !! wikitext
23348 {{echo|*a}}
23349 {{echo|#a}}
23350 {{echo|:a}}
23351 !! html
23352 <span about="#mwt1" typeof="mw:Transclusion">
23353 </span><ul about="#mwt1"><li>a</li>
23354 </ul>
23355 <span about="#mwt2" typeof="mw:Transclusion">
23356 </span><ol about="#mwt2"><li>a</li>
23357 </ol>
23358 <span about="#mwt3" typeof="mw:Transclusion">
23359 </span><dl about="#mwt3"><dd>a</dd>
23360 </dl>
23361 !!end
23362
23363 #### -----------------------------------------------------------------
23364 #### Parsoid-specific functionality tests
23365 #### -----------------------------------------------------------------
23366
23367 # T65642/T68749: Formatting elt fixup around images is cleaned up.
23368 # We know wt2wt will fail, but we expect selser to pass.
23369 # Due to the nature of our testing, wt2wt and selser tests will enter the
23370 # blacklist and we'll catch selser regressions based on changes to the
23371 # blacklist entries for selser tests.
23372 !! test
23373 1. Bad treebuilder fixup of formatting elt is cleaned up
23374 !! options
23375 parsoid=wt2html,wt2wt
23376 !! wikitext
23377 {|
23378 |
23379 <small>
23380 [[Image:Foobar.jpg|right|Test]]
23381 </small>
23382 |}
23383 !! html/parsoid
23384 <table>
23385 <tbody><tr><td>
23386 <small>
23387 <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>
23388 </small>
23389 </td></tr>
23390 </tbody></table>
23391 !! end
23392
23393 !! test
23394 2. Bad treebuilder fixup of formatting elt is cleaned up
23395 !! options
23396 parsoid=wt2html,wt2wt
23397 !! wikitext
23398 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
23399
23400 <small>[[Image:Foobar.jpg|right|300px]]</small>
23401 !! html/parsoid
23402
23403 <p><b>foo</b></p>
23404 <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>
23405 <p><b>bar</b></p>
23406 <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>
23407 !! end
23408
23409 !! test
23410 3. Bad treebuilder fixup of formatting elt is cleaned up
23411 !! options
23412 parsoid=wt2html,wt2wt
23413 !! wikitext
23414 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
23415 !! html/parsoid
23416 <p><small><b>foo</b></small></p>
23417 <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>
23418 <p><small><b>bar</b></small></p>
23419 !! end
23420
23421 !! test
23422 4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
23423 !! options
23424 parsoid=wt2html,wt2wt
23425 !! wikitext
23426 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
23427 !! html/parsoid
23428 <p><b><small></small></b></p>
23429 <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>
23430 <p></p>
23431 !! end
23432
23433 #### ----------------------------------------------------------------
23434 #### Parsoid-only testing of Parsoid's impl of LST
23435 #### Not implemented yet, see
23436 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
23437 #### ----------------------------------------------------------------
23438
23439 ## We still need to support serializing the older format while content is stored.
23440 !! test
23441 LST Sections: Backwards compatibility
23442 !! options
23443 parsoid={
23444 "suppressErrors": true,
23445 "modes": ["html2wt"]
23446 }
23447 !! wikitext
23448 <section begin="2011-05-16" />
23449 <section end="2014-04-10 (MW 1.23wmf22)" />
23450 !! html/parsoid
23451 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
23452 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
23453 !! end
23454
23455 !! test
23456 LST Sections: Newfangled approach
23457 !! wikitext
23458 <section begin="2011-05-16" />
23459 <section end="2014-04-10 (MW 1.23wmf22)" />
23460 !! html/parsoid
23461 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'>
23462 </span>
23463 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null}'>
23464 </span></p>
23465 !! end
23466
23467 #--------- Test stripping of empty nodes in template content ----------
23468
23469 !! test
23470 Empty LI and TR nodes should be stripped from template content
23471 !! wikitext
23472 {{EmptyLITest}}
23473 {{EmptyTRTest}}
23474 !! html/parsoid
23475 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
23476 <li>a</li>
23477 <li>b</li>
23478 </ul>
23479 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
23480 <tbody>
23481 <tr>
23482 <td>foo</td>
23483 </tr>
23484 <tr>
23485 <td>bar</td>
23486 </tr>
23487 </tbody>
23488 </table>
23489 !! end
23490
23491 !! test
23492 Empty LI and TR nodes should not be stripped from top-level content
23493 !! wikitext
23494 * a
23495 *
23496 * b
23497 {|
23498 |-
23499 |-
23500 |foo
23501 |}
23502 !! html/parsoid
23503 <ul>
23504 <li> a</li>
23505 <li></li>
23506 <li> b</li>
23507 </ul>
23508 <table>
23509 <tbody>
23510 <tr></tr>
23511 <tr>
23512 <td>foo</td>
23513 </tr>
23514 </tbody>
23515 </table>
23516 !! end
23517
23518 !! test
23519 Empty TR nodes should not be stripped if they have any attributes set
23520 !! wikitext
23521 {{EmptyTRWithHTMLAttrTest}}
23522 !! html/parsoid
23523 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
23524 <tr align="center"></tr>
23525 <tr><td>foo</td></tr>
23526 <tr align="center"></tr>
23527 <tr><td>bar</td></tr>
23528 </table>
23529 !! end
23530
23531 #### ----------------------------------------------------------------
23532 #### The following section of tests are primarily to test
23533 #### wikitext escaping capabilities of Parsoid. Given that
23534 #### escaping can be done any number of ways, the wikitext (input)
23535 #### is always adjusted to reflect how Parsoid adds nowiki
23536 #### escape tags.
23537 ####
23538 #### We are marking several tests as parsoid-only since the
23539 #### HTML in the result section is different from what the
23540 #### PHP parser generates for it.
23541 #### ----------------------------------------------------------------
23542
23543
23544 #### --------------- Headings ---------------
23545 #### 0. Unnested
23546 #### 1. Nested inside html <h1>=foo=</h1>
23547 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
23548 #### 3. Nested inside html with wikitext split by html tags
23549 #### 4. No escape needed
23550 #### 5. Empty headings <h1></h1>
23551 #### 6. Heading chars in SOL context
23552 #### ----------------------------------------
23553 !! test
23554 Headings: 0. Unnested
23555 !! options
23556 parsoid=html2wt
23557 !! html/parsoid
23558 <p>=foo=</p>
23559
23560 <p> =foo=
23561 <!--cmt-->
23562 =foo=</p>
23563
23564 <p>=foo<i>a</i>=</p>
23565 !! wikitext
23566 <nowiki>=foo=</nowiki>
23567
23568 <nowiki> </nowiki>=foo=
23569 <!--cmt-->
23570 <nowiki>=foo=</nowiki>
23571
23572 =foo''a''<nowiki>=</nowiki>
23573 !!end
23574
23575 # New headings and existing headings are handled differently
23576 !! test
23577 Headings: 1. Nested inside html
23578 !! options
23579 parsoid=html2wt
23580 !! html/parsoid
23581 <h1>=foo=</h1>
23582 <h2>=foo=</h2>
23583 <h3>=foo=</h3>
23584
23585 <h1 data-parsoid=''>=foo=</h1>
23586 <h2 data-parsoid=''>=foo=</h2>
23587 <h3 data-parsoid=''>=foo=</h3>
23588 <h4 data-parsoid=''>=foo=</h4>
23589 <h5 data-parsoid=''>=foo=</h5>
23590 <h6 data-parsoid=''>=foo=</h6>
23591 !! wikitext
23592 = =foo= =
23593
23594 == =foo= ==
23595
23596 === =foo= ===
23597
23598 =<nowiki>=foo=</nowiki>=
23599 ==<nowiki>=foo=</nowiki>==
23600 ===<nowiki>=foo=</nowiki>===
23601 ====<nowiki>=foo=</nowiki>====
23602 =====<nowiki>=foo=</nowiki>=====
23603 ======<nowiki>=foo=</nowiki>======
23604
23605 !!end
23606
23607 !! test
23608 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
23609 !! options
23610 parsoid=html2wt
23611 !! html/parsoid
23612 <h1>foo</h1>*bar
23613 <h1>foo</h1>=bar
23614 <h1>foo</h1>=bar=
23615 !! wikitext
23616 = foo =
23617 <nowiki>*</nowiki>bar
23618
23619 = foo =
23620 =bar
23621
23622 = foo =
23623 <nowiki>=bar=</nowiki>
23624 !!end
23625
23626 !! test
23627 Headings: 3. Nested inside html with wikitext split by html tags
23628 !! options
23629 parsoid=html2wt
23630 !! html/parsoid
23631 <h1>=<b>bold</b>foo=</h1>
23632 !! wikitext
23633 = ='''bold'''foo= =
23634 !!end
23635
23636 !! test
23637 Headings: 4a. No escaping needed (testing just h1 and h2)
23638 !! options
23639 parsoid=html2wt
23640 !! html/parsoid
23641 <h1>=foo</h1>
23642 <h1>foo=</h1>
23643 <h1> =foo= </h1>
23644 <h1>=foo= bar</h1>
23645 <h2>=foo</h2>
23646 <h2>foo=</h2>
23647 <h1>=</h1>
23648 <h1><i>=</i>foo=</h1>
23649 !! wikitext
23650 = =foo =
23651
23652 = foo= =
23653
23654 = =foo= =
23655
23656 = =foo= bar =
23657
23658 == =foo ==
23659
23660 == foo= ==
23661
23662 = = =
23663
23664 = ''=''foo= =
23665 !!end
23666
23667 !! test
23668 Headings: 4b. No escaping needed (inside p-tags)
23669 !! options
23670 parsoid=html2wt
23671 !! html/parsoid
23672 <p>===
23673 =foo= x
23674 =foo= <s></s>
23675 </p>
23676 !! wikitext
23677 ===
23678 =foo= x
23679 =foo= <s></s>
23680 !!end
23681
23682 !! test
23683 Headings: 5. Empty headings
23684 !! options
23685 parsoid=html2wt
23686 !! html/parsoid
23687 <h1 data-parsoid='{}'></h1>
23688
23689 <h2 data-parsoid='{}'></h2>
23690
23691 <h3 data-parsoid='{}'></h3>
23692
23693 <h4 data-parsoid='{}'></h4>
23694
23695 <h5 data-parsoid='{}'></h5>
23696
23697 <h6 data-parsoid='{}'></h6>
23698 !! wikitext
23699 =<nowiki/>=
23700
23701 ==<nowiki/>==
23702
23703 ===<nowiki/>===
23704
23705 ====<nowiki/>====
23706
23707 =====<nowiki/>=====
23708
23709 ======<nowiki/>======
23710 !!end
23711
23712 !! test
23713 Headings: 6a. Heading chars in SOL context (with trailing spaces)
23714 !! options
23715 parsoid=html2wt
23716 !! html/parsoid
23717 <p>=a=</p>
23718
23719 <p>=a=</p>
23720
23721 <p>=a=</p>
23722 !! wikitext
23723 <nowiki>=a=</nowiki>
23724
23725 <nowiki>=a=</nowiki>
23726
23727 <nowiki>=a=</nowiki>
23728 !!end
23729
23730 !! test
23731 Headings: 6b. Heading chars in SOL context (with trailing newlines)
23732 !! options
23733 parsoid=html2wt
23734 !! html/parsoid
23735 <p>=a=
23736 b</p>
23737
23738 <p>=a=
23739 b</p>
23740
23741 <p>=a=
23742 b</p>
23743 !! wikitext
23744 <nowiki>=a=</nowiki>
23745 b
23746
23747 <nowiki>=a=</nowiki>
23748 b
23749
23750 <nowiki>=a=</nowiki>
23751 b
23752 !!end
23753
23754 !! test
23755 Headings: 6c. Heading chars in SOL context (leading newline break)
23756 !! options
23757 parsoid=html2wt
23758 !! html/parsoid
23759 <p>a
23760 =b=</p>
23761 !! wikitext
23762 a
23763 <nowiki>=b=</nowiki>
23764 !!end
23765
23766 !! test
23767 Headings: 6d. Heading chars in SOL context (with interspersed comments)
23768 !! options
23769 parsoid=html2wt
23770 !! html/parsoid
23771 <!--c0--><p>=a=</p>
23772
23773 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
23774 !! wikitext
23775 <!--c0--><nowiki>=a=</nowiki>
23776
23777 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
23778 !!end
23779
23780 !! test
23781 Headings: 6d. Heading chars in SOL context (No escaping needed)
23782 !! options
23783 parsoid=html2wt
23784 !! html/parsoid
23785 =a=<div>b</div>
23786 !! wikitext
23787 =a=<div>b</div>
23788 !!end
23789
23790 !! test
23791 Headings: 7. Insert a newline between new content and headings
23792 !! options
23793 parsoid=html2wt
23794 !! html/parsoid
23795 <h2>NEW</h2>
23796 <p>new</p>
23797 <h2 data-parsoid='{}'>A</h2>
23798 <p data-parsoid='{}'>a</p>
23799 !! wikitext
23800 == NEW ==
23801 new
23802
23803 ==A==
23804 a
23805
23806 !! end
23807
23808 #### --------------- Lists ---------------
23809 #### 0. Outside nests (*foo, etc.)
23810 #### 1. Nested inside html <ul><li>*foo</li></ul>
23811 #### 2. Inside definition lists
23812 #### 3. Only bullets at start should be escaped
23813 #### 4. No escapes needed
23814 #### 5. No unnecessary escapes
23815 #### 6. Escape bullets in SOL position
23816 #### 7. Escape bullets in a multi-line context
23817 #### ----------------------------------------
23818
23819 !! test
23820 Lists: 0. Outside nests
23821 !! options
23822 parsoid=html2wt
23823 !! html/parsoid
23824 <p>*foo</p>
23825
23826 <p>#foo</p>
23827
23828 <p>;Foo:bar</p>
23829 !! wikitext
23830 <nowiki>*</nowiki>foo
23831
23832 <nowiki>#</nowiki>foo
23833
23834 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
23835 !!end
23836
23837 ## Making these next 3 tests Parsoid-only since they are html2wt tests
23838 ## to test wikitext escaping, and insignificant whitespace diffs
23839 ## cause PHP parser tests to barf
23840 !! test
23841 Lists: 1. Nested inside html (No unnecessary escapes)
23842 !! options
23843 parsoid=html2wt
23844 !! html/parsoid
23845 <ul>
23846 <li>*foo</li>
23847 <li>#foo</li>
23848 <li>:foo</li>
23849 <li>;foo</li>
23850 <li data-parsoid='{}'>*foo</li>
23851 <li data-parsoid='{}'>#foo</li>
23852 <li data-parsoid='{}'>:foo</li>
23853 <li data-parsoid='{}'>;foo</li>
23854 </ul>
23855
23856 <ol>
23857 <li>*foo</li>
23858 <li>#foo</li>
23859 <li>:foo</li>
23860 <li>;foo</li>
23861 <li data-parsoid='{}'>*foo</li>
23862 <li data-parsoid='{}'>#foo</li>
23863 <li data-parsoid='{}'>:foo</li>
23864 <li data-parsoid='{}'>;foo</li>
23865 </ol>
23866 !! wikitext
23867 * *foo
23868 * #foo
23869 * :foo
23870 * ;foo
23871 *<nowiki>*foo</nowiki>
23872 *<nowiki>#foo</nowiki>
23873 *<nowiki>:foo</nowiki>
23874 *<nowiki>;foo</nowiki>
23875
23876 # *foo
23877 # #foo
23878 # :foo
23879 # ;foo
23880 #<nowiki>*foo</nowiki>
23881 #<nowiki>#foo</nowiki>
23882 #<nowiki>:foo</nowiki>
23883 #<nowiki>;foo</nowiki>
23884 !!end
23885
23886 !! test
23887 Lists: 2. Inside definition lists
23888 !! options
23889 parsoid=html2wt
23890 !! html/parsoid
23891 <dl><dt>;foo</dt></dl>
23892 <dl><dt>:foo</dt></dl>
23893 <dl><dt>:foo</dt>
23894 <dd>bar</dd></dl>
23895 <dl><dd>:foo</dd></dl>
23896 !! wikitext
23897 ; ;foo
23898
23899 ; <nowiki>:foo</nowiki>
23900
23901 ; <nowiki>:foo</nowiki>
23902 : bar
23903
23904 : :foo
23905 !!end
23906
23907 !! test
23908 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
23909 !! options
23910 parsoid=html2wt
23911 !! html/parsoid
23912 <ul>
23913 <li>*foo*bar</li>
23914 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
23915 </ul>
23916 !! wikitext
23917 * *foo*bar
23918 *<nowiki>*foo</nowiki>''it''*bar
23919 !!end
23920
23921 !! test
23922 Lists: 4. No escapes needed
23923 !! options
23924 parsoid=html2wt
23925 !! html/parsoid
23926 <ul>
23927 <li>foo*bar
23928 </li>
23929 </ul>
23930 <ul>
23931 <li><i>foo</i>*bar
23932 </li>
23933 </ul>
23934 <ul>
23935 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: bar
23936 </li>
23937 </ul>
23938 <ul>
23939 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>*bar
23940 </li>
23941 </ul>
23942 !! wikitext
23943 *foo*bar
23944
23945 *''foo''*bar
23946
23947 *[[Foo]]: bar
23948
23949 *[[Foo]]*bar
23950 !!end
23951
23952 !! test
23953 Lists: 5. No unnecessary escapes
23954 !! options
23955 parsoid=html2wt
23956 !! html/parsoid
23957 <ul><li> bar <span>[[foo]]</span></li></ul>
23958 <ul><li> =bar <span>[[foo]]</span></li></ul>
23959 <ul><li> [[bar <span>[[foo]]</span></li></ul>
23960 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
23961 <ul><li> =bar <span>foo]]</span>=</li></ul>
23962 <ul><li> <s></s>: a</li></ul>
23963 <ul><li> <i>* foo</i></li></ul>
23964
23965 !! wikitext
23966 * bar <span><nowiki>[[foo]]</nowiki></span>
23967
23968 * =bar <span><nowiki>[[foo]]</nowiki></span>
23969
23970 * [[bar <span><nowiki>[[foo]]</nowiki></span>
23971
23972 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
23973
23974 * =bar <span>foo]]</span>=
23975
23976 * <s></s>: a
23977
23978 * ''* foo''
23979 !!end
23980
23981 !! test
23982 Lists: 6. Escape bullets in SOL position
23983 !! options
23984 parsoid=html2wt
23985 !! html/parsoid
23986 <p><!--cmt-->*foo</p>
23987 !! wikitext
23988 <!--cmt--><nowiki>*</nowiki>foo
23989 !!end
23990
23991 !! test
23992 Lists: 7. Escape bullets in a multi-line context
23993 !! options
23994 parsoid=html2wt
23995 !! html/parsoid
23996 <p>a
23997 *b
23998 </p>
23999 !! wikitext
24000 a
24001 <nowiki>*</nowiki>b
24002 !!end
24003
24004 !! test
24005 Lists: 8. Escape colons only if not present in tags
24006 !! options
24007 parsoid=html2wt
24008 !! html/parsoid
24009 <dl><dt>a:b<i>c:d</i></dt></dl>
24010 !! wikitext
24011 ; <nowiki>a:b</nowiki>''c:d''
24012 !! end
24013
24014 #### --------------- HRs ---------------
24015 #### 1. Single line
24016 #### -----------------------------------
24017
24018 !! test
24019 HRs: 1. Single line
24020 !! options
24021 parsoid=html2wt
24022 !! html/parsoid
24023 <hr />----
24024 <hr />=foo=
24025 <hr />*foo
24026 !! wikitext
24027 ----<nowiki>----</nowiki>
24028 ----=foo=
24029 ----*foo
24030 !! end
24031
24032 #### --------------- Tables ---------------
24033 #### 1a. Simple example
24034 #### 1b. No escaping needed (!foo)
24035 #### 1c. No escaping needed (|foo)
24036 #### 1d. No escaping needed (|}foo)
24037 ####
24038 #### 2a. Nested in td (<td>foo|bar</td>)
24039 #### 2b. Nested in td (<td>foo||bar</td>)
24040 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
24041 ####
24042 #### 3a. Nested in th (<th>foo!bar</th>)
24043 #### 3b. Nested in th (<th>foo!!bar</th>)
24044 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
24045 ####
24046 #### 4a. Escape -
24047 #### 4b. Escape +
24048 #### 4c. No escaping needed
24049 #### --------------------------------------
24050
24051 !! test
24052 Tables: 1a. Simple example
24053 !! options
24054 parsoid=html2wt
24055 !! html/parsoid
24056 <p>{|
24057 |}
24058 </p>
24059 !! wikitext
24060 <nowiki>{|</nowiki>
24061 |}
24062 !! end
24063
24064 !! test
24065 Tables: 1b. No escaping needed
24066 !! options
24067 parsoid=html2wt
24068 !! html/parsoid
24069 <p>!foo
24070 </p>
24071 !! wikitext
24072 !foo
24073 !! end
24074
24075 !! test
24076 Tables: 1c. No escaping needed
24077 !! options
24078 parsoid=html2wt
24079 !! html/parsoid
24080 <p>|foo
24081 </p>
24082 !! wikitext
24083 |foo
24084 !! end
24085
24086 !! test
24087 Tables: 1d. No escaping needed
24088 !! options
24089 parsoid=html2wt
24090 !! html/parsoid
24091 <p>|}foo
24092 </p>
24093 !! wikitext
24094 |}foo
24095 !! end
24096
24097 !! test
24098 Tables: 2a. Nested in td
24099 !! options
24100 parsoid=html2wt
24101 !! html/parsoid
24102 <table><tbody><tr>
24103 <td>foo|bar</td></tr>
24104 <tr><td>x<div>a|b</div></td>
24105 </tbody></table>
24106 !! wikitext
24107 {|
24108 |<nowiki>foo|bar</nowiki>
24109 |-
24110 |x<div><nowiki>a|b</nowiki></div>
24111 |}
24112 !! html/php+tidy
24113 <table>
24114 <tr>
24115 <td>foo|bar</td>
24116 </tr>
24117 <tr>
24118 <td>x
24119 <div>a|b</div>
24120 </td>
24121 </tr>
24122 </table>
24123 !! end
24124
24125 !! test
24126 Tables: 2b. Nested in td
24127 !! options
24128 parsoid=html2wt
24129 !! html/parsoid
24130 <table><tbody><tr>
24131 <td>foo||bar</td>
24132 <td>a<i>b||c</i></td>
24133 <td>a<i><div>b||c</div></i></td>
24134 </tr></tbody></table>
24135 !! wikitext
24136 {|
24137 |<nowiki>foo||bar</nowiki>
24138 |a''<nowiki>b||c</nowiki>''
24139 |a''<div><nowiki>b||c</nowiki></div>''
24140 |}
24141 !! html/php
24142 <table>
24143 <tr>
24144 <td>foo||bar
24145 </td>
24146 <td>a<i>b||c</i>
24147 </td>
24148 <td>a<i><div>b||c</div></i>
24149 </td></tr></table>
24150
24151 !! end
24152
24153 !! test
24154 Tables: 2c. Nested in td -- no escaping needed
24155 !! options
24156 parsoid=html2wt
24157 !! html/*
24158 <table>
24159 <tr>
24160 <td>foo!!bar
24161 </td></tr></table>
24162
24163 !! wikitext
24164 {|
24165 |foo!!bar
24166 |}
24167 !! end
24168
24169 !! test
24170 Tables: 3a. Nested in th
24171 !! options
24172 parsoid=html2wt
24173 !! html/*
24174 <table>
24175 <tr>
24176 <th>foo!bar
24177 </th></tr></table>
24178
24179 !! wikitext
24180 {|
24181 !foo!bar
24182 |}
24183 !! end
24184
24185 !! test
24186 Tables: 3b. Nested in th
24187 !! options
24188 parsoid=html2wt
24189 !! html/parsoid
24190 <table><tbody>
24191 <tr><th>foo!!bar</th>
24192 <th><i>foo|bar</i></th>
24193 <th><i>foo!!bar</i></th>
24194 <th><i><span>foo!!bar</span></i></th>
24195 </tr></tbody></table>
24196 !! wikitext
24197 {|
24198 !<nowiki>foo!!bar</nowiki>
24199 !''<nowiki>foo|bar</nowiki>''
24200 !''<nowiki>foo!!bar</nowiki>''
24201 !''<span><nowiki>foo!!bar</nowiki></span>''
24202 |}
24203 !! html/php
24204 <table>
24205 <tr>
24206 <th>foo!!bar
24207 </th>
24208 <th><i>foo|bar</i>
24209 </th>
24210 <th><i>foo!!bar</i>
24211 </th>
24212 <th><i><span>foo!!bar</span></i>
24213 </th></tr></table>
24214
24215 !! end
24216
24217 !! test
24218 Tables: 3c. Nested in th
24219 !! options
24220 parsoid=html2wt
24221 !! html/parsoid
24222 <table><tbody>
24223 <tr><th>foo||bar</th>
24224 <th><span typeof="mw:Nowiki">foo||bar</span></th>
24225 </tr></tbody></table>
24226 !! wikitext
24227 {|
24228 !<nowiki>foo||bar</nowiki>
24229 !<nowiki>foo||bar</nowiki>
24230 |}
24231 !! html/php
24232 <table>
24233 <tr>
24234 <th>foo||bar
24235 </th>
24236 <th>foo||bar
24237 </th></tr></table>
24238
24239 !! end
24240
24241 !! test
24242 Tables: 4a. Escape -
24243 !! options
24244 parsoid=html2wt
24245 !! html/*
24246 <table>
24247 <tr>
24248 <th>-bar
24249 </th></tr>
24250 <tr>
24251 <td>-bar
24252 </td></tr></table>
24253
24254 !! wikitext
24255 {|
24256 !-bar
24257 |-
24258 |<nowiki>-bar</nowiki>
24259 |}
24260 !! end
24261
24262 !! test
24263 Tables: 4b. Escape +
24264 !! options
24265 parsoid=html2wt
24266 !! html/*
24267 <table>
24268 <tr>
24269 <th>+bar
24270 </th></tr>
24271 <tr>
24272 <td>+bar
24273 </td></tr></table>
24274
24275 !! wikitext
24276 {|
24277 !+bar
24278 |-
24279 |<nowiki>+bar</nowiki>
24280 |}
24281 !! end
24282
24283 !! test
24284 Tables: 4c. No escaping needed
24285 !! options
24286 parsoid=html2wt
24287 !! html/parsoid
24288 <table><tbody>
24289 <tr><td>foo-bar</td><td>foo+bar</td></tr>
24290 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
24291 <tr><td>foo
24292 <p>bar|baz
24293 +bar
24294 -bar</p></td></tr>
24295 <tr><td>x
24296 <div>a|b</div></td>
24297 </tbody></table>
24298 !! wikitext
24299 {|
24300 |foo-bar
24301 |foo+bar
24302 |-
24303 |''foo''-bar
24304 |''foo''+bar
24305 |-
24306 |foo
24307 bar|baz
24308 +bar
24309 -bar
24310 |-
24311 |x
24312 <div>a|b</div>
24313 |}
24314 !! html/php
24315 <table>
24316 <tr>
24317 <td>foo-bar
24318 </td>
24319 <td>foo+bar
24320 </td></tr>
24321 <tr>
24322 <td><i>foo</i>-bar
24323 </td>
24324 <td><i>foo</i>+bar
24325 </td></tr>
24326 <tr>
24327 <td>foo
24328 <p>bar|baz
24329 +bar
24330 -bar
24331 </p>
24332 </td></tr>
24333 <tr>
24334 <td>x
24335 <div>a|b</div>
24336 </td></tr></table>
24337
24338 !! end
24339
24340 !! test
24341 Tables: 4d. No escaping needed
24342 !! options
24343 parsoid=html2wt
24344 !! html/parsoid
24345 <table>
24346 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
24347 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
24348 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
24349 </tbody></table>
24350 !! wikitext
24351 {|
24352 |[[Foo]]-bar
24353 ||+1
24354 ||-2
24355 |}
24356 !! html/php
24357 <table>
24358 <tr>
24359 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
24360 </td>
24361 <td>+1
24362 </td>
24363 <td>-2
24364 </td></tr></table>
24365
24366 !! end
24367
24368 !! test
24369 T97430: Don't emit empty nowiki pairs around marker meta tags
24370 !! options
24371 parsoid=html2wt
24372 !! html/parsoid
24373 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
24374 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
24375 !! wikitext
24376 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
24377 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
24378 !! end
24379
24380 !! test
24381 Unclosed xmlish element in table line shouldn't eat end delimiters
24382 !! options
24383 parsoid=html2wt
24384 !! html/parsoid
24385 <table>
24386 <tbody><tr><td> &lt;foo</td>
24387 <td> bar></td></tr>
24388 </tbody></table>
24389 !! wikitext
24390 {|
24391 | <foo
24392 | bar>
24393 |}
24394 !! html/php
24395 <table>
24396 <tr>
24397 <td> &lt;foo
24398 </td>
24399 <td> bar&gt;
24400 </td></tr></table>
24401
24402 !! end
24403
24404 #### --------------- Links ----------------
24405 #### 1. Quote marks in link text
24406 #### 2. Wikilinks: Escapes needed
24407 #### 3. Wikilinks: No escapes needed
24408 #### 4. Extlinks: Escapes needed
24409 #### 5. Extlinks: No escapes needed
24410 #### --------------------------------------
24411 !! test
24412 Links 1. WikiLinks: No escapes needed
24413 !! options
24414 parsoid=html2wt
24415 !! html/parsoid
24416 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
24417 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
24418 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
24419 !! wikitext
24420 [[Foo|Foo''boo'']]
24421 [[Foo|[Foobar]]]
24422 [[Foo|x [Foobar] x]]
24423 !! html/php
24424 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
24425 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
24426 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
24427 </p>
24428 !! end
24429
24430 !! test
24431 Links 2. WikiLinks: Escapes needed
24432 !! options
24433 parsoid=html2wt
24434 !! html/parsoid
24435 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
24436 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
24437 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
24438 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
24439 <a href="Foo" rel="mw:WikiLink">|Bar</a>
24440 <a href="Foo" rel="mw:WikiLink">]]bar</a>
24441 <a href="Foo" rel="mw:WikiLink">[[bar</a>
24442 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
24443 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
24444 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
24445 !! wikitext
24446 [[Foo|<nowiki>Foobar]</nowiki>]]
24447 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
24448 [[Foo|<nowiki>[[Bar]]</nowiki>]]
24449 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
24450 [[Foo|<nowiki>|Bar</nowiki>]]
24451 [[Foo|<nowiki>]]bar</nowiki>]]
24452 [[Foo|<nowiki>[[bar</nowiki>]]
24453 [[Foo|<nowiki>x [[ y</nowiki>]]
24454 [[Foo|<nowiki>x ]] y</nowiki>]]
24455 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
24456 !! html/php
24457 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
24458 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
24459 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
24460 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
24461 <a href="/wiki/Foo" title="Foo">|Bar</a>
24462 <a href="/wiki/Foo" title="Foo">]]bar</a>
24463 <a href="/wiki/Foo" title="Foo">[[bar</a>
24464 <a href="/wiki/Foo" title="Foo">x [[ y</a>
24465 <a href="/wiki/Foo" title="Foo">x ]] y</a>
24466 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
24467 </p>
24468 !! end
24469
24470 !! test
24471 Links 3. WikiLinks: No escapes needed
24472 !! options
24473 parsoid=html2wt
24474 !! html/parsoid
24475 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
24476 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
24477 !! wikitext
24478 [[Foo|[Foobar]]
24479 [[Foo|foo|bar]]
24480 !! html/php
24481 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
24482 <a href="/wiki/Foo" title="Foo">foo|bar</a>
24483 </p>
24484 !! end
24485
24486 !! test
24487 Links 4. ExtLinks: Escapes needed
24488 !! options
24489 parsoid=html2wt
24490 !! html/parsoid
24491 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
24492 <a rel="mw:ExtLink" href="http://google.com">google]</a>
24493 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
24494 <p>[http://google.com]</p>
24495 <p>[http://google.com google]</p>
24496 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
24497 <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>
24498 !! wikitext
24499 [http://google.com <nowiki>[google]</nowiki>]
24500 [http://google.com <nowiki>google]</nowiki>]
24501 [http://google.com <nowiki>goog] le</nowiki>]
24502
24503 <nowiki>[http://google.com]</nowiki>
24504
24505 <nowiki>[http://google.com google]</nowiki>
24506
24507 [http://google.com<nowiki>]</nowiki>
24508
24509 [{{echo|http://google.com}}<nowiki>]</nowiki>
24510 !! html/php
24511 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
24512 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
24513 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
24514 </p><p>[http://google.com]
24515 </p><p>[http://google.com google]
24516 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
24517 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
24518 </p>
24519 !! end
24520
24521 !! test
24522 Links 5. ExtLinks: No escapes needed
24523 !! options
24524 parsoid=html2wt
24525 !! html/parsoid
24526 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
24527 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
24528 !! wikitext
24529 [http://google.com [google]
24530
24531 [[http://google.com]]
24532 !! html/php
24533 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
24534 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
24535 </p>
24536 !! end
24537
24538 !! test
24539 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
24540 !! options
24541 parsoid=html2wt
24542 !! html/parsoid
24543 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
24544 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
24545 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
24546 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
24547 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
24548 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.x
24549 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
24550 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>:x
24551 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>;x
24552 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>!x
24553 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>=x
24554 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>(x)
24555 <a rel="mw:ExtLink" href="http://example.com(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
24556 </p>
24557 !! wikitext
24558 x<nowiki/>http://example.com<nowiki/>y
24559 http://example.com<nowiki/>?x
24560 http://example.com<nowiki/>&x
24561 http://example.com<nowiki/>'x
24562 http://example.com<nowiki/>,x
24563 http://example.com<nowiki/>.x
24564 http://example.com<nowiki/>;x
24565 http://example.com<nowiki/>:x
24566 http://example.com<nowiki/>;x
24567 http://example.com<nowiki/>!x
24568 http://example.com<nowiki/>=x
24569 http://example.com<nowiki/>(x)
24570 http://example.com(x<nowiki/>)
24571 !! end
24572
24573 !! test
24574 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
24575 !! options
24576 parsoid=html2wt
24577 !! html/parsoid
24578 <p>x
24579 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
24580 y
24581 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
24582 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
24583 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
24584 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
24585 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
24586 </p>
24587 !! wikitext
24588 x
24589 http://example.com
24590 y
24591 "http://example.com"
24592 (http://example.com)
24593 (http://example.com) foo
24594 http://example.com,
24595 http://example.com, foo
24596 !! html/php
24597 <p>x
24598 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
24599 y
24600 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
24601 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
24602 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
24603 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
24604 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
24605 </p>
24606 !! end
24607
24608 !! test
24609 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
24610 !! options
24611 parsoid=html2wt
24612 !! html/parsoid
24613 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
24614 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
24615 !! wikitext
24616 http://example.com.,;:!?\
24617 -http://example.com:
24618 !! html/php
24619 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
24620 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
24621 </p>
24622 !! end
24623
24624 !! test
24625 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
24626 !! options
24627 parsoid=html2wt
24628 !! html/parsoid
24629 <p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
24630 <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
24631 X<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
24632 !! wikitext
24633 RFC 123<nowiki/>4
24634 RFC 123<nowiki/>y
24635 X<nowiki/>RFC 123<nowiki/>y
24636 !! end
24637
24638 !! test
24639 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
24640 !! options
24641 parsoid=html2wt
24642 !! html/parsoid
24643 <p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
24644 <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
24645 -<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
24646 </p>
24647 !! wikitext
24648 RFC 123?foo
24649 RFC 123&foo
24650 -RFC 123-
24651 !! html/php
24652 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>?foo
24653 <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
24654 -<a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>-
24655 </p>
24656 !! end
24657
24658 !! test
24659 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
24660 !! options
24661 parsoid=html2wt
24662 !! html/parsoid
24663 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
24664 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
24665 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
24666 !! wikitext
24667 PMID 123<nowiki/>4
24668 PMID 123<nowiki/>y
24669 X<nowiki/>PMID 123<nowiki/>y
24670 !! end
24671
24672 !! test
24673 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
24674 !! options
24675 parsoid=html2wt
24676 !! html/parsoid
24677 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
24678 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
24679 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
24680 </p>
24681 !! wikitext
24682 PMID 123?foo
24683 PMID 123&foo
24684 -PMID 123-
24685 !! html/php
24686 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
24687 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
24688 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
24689 </p>
24690 !! end
24691
24692 !! test
24693 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
24694 !! options
24695 parsoid=html2wt
24696 !! html/parsoid
24697 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
24698 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
24699 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
24700 </p>
24701 !! wikitext
24702 ISBN 1234567890<nowiki/>1
24703 ISBN 1234567890<nowiki/>x
24704 a<nowiki/>ISBN 1234567890<nowiki/>b
24705 !! end
24706
24707 !! test
24708 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (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>'s
24713 !! wikitext
24714 -ISBN 1234567890's
24715 !! html/php
24716 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
24717 </p>
24718 !! end
24719
24720 !! test
24721 Links 14. Protect link-like plain text. (Parsoid bug T78425)
24722 !! options
24723 parsoid=html2wt
24724 !! html/*
24725 <p>this is not a link: http://example.com
24726 </p>
24727 !! wikitext
24728 this is not a link: <nowiki>http://example.com</nowiki>
24729 !! end
24730
24731 !! test
24732 Links 15. Link trails can't become link prefixes.
24733 !! options
24734 language=is
24735 parsoid=html2wt
24736 !! html/parsoid
24737 <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>
24738 !! wikitext
24739 [[Söfnuður]]-[[00]]
24740 !! html/php
24741 <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>
24742 </p>
24743 !! end
24744
24745 #### --------------- Quotes ---------------
24746 #### 1. Quotes inside <b> and <i>
24747 #### 2. Link fragments separated by <i> and <b> tags
24748 #### 3. Link fragments inside <i> and <b>
24749 #### 4. No escaping needed
24750 #### --------------------------------------
24751 !! test
24752 1a. Quotes inside <b> and <i>
24753 !! options
24754 parsoid=html2wt
24755 !! html/*
24756 <p><i>'foo'</i>
24757 <i>''foo''</i>
24758 <i>'''foo'''</i>
24759 <i>foo</i>'s
24760 <b>'foo'</b>
24761 <b>''foo''</b>
24762 <b>'''foo'''</b>
24763 <b>foo'<i>bar'</i>baz</b>
24764 <b>foo</b>'s
24765 '<i>foo</i>
24766 <i>foo</i>'
24767 <i>foo'</i>'
24768 '<i>foo</i>'
24769 '<b>foo</b>
24770 <b>foo</b>'
24771 '<b>foo</b>'
24772 <i>fools'<span> errand</span></i>
24773 <i><span>fool</span>'s errand</i>
24774 '<i>foo</i> bar '<i>baz</i>
24775 a|!*#-:;+-~[]{}b'<i>x</i>
24776 </p>
24777 !! wikitext
24778 ''<nowiki/>'foo'''
24779 ''<nowiki>''foo''</nowiki>''
24780 ''<nowiki>'''foo'''</nowiki>''
24781 ''foo''<nowiki/>'s
24782 '''<nowiki/>'foo''''
24783 '''<nowiki>''foo''</nowiki>'''
24784 '''<nowiki>'''foo'''</nowiki>'''
24785 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
24786 '''foo'''<nowiki/>'s
24787 '''foo''
24788 ''foo''<nowiki/>'
24789 ''foo'''<nowiki/>'
24790 '''foo''<nowiki/>'
24791 ''''foo'''
24792 '''foo'''<nowiki/>'
24793 ''''foo'''<nowiki/>'
24794 ''fools'<span> errand</span>''
24795 ''<span>fool</span>'s errand''
24796 '<nowiki/>''foo'' bar '''baz''
24797 a|!*#-:;+-~[]{}b'''x''
24798 !! end
24799
24800 !! test
24801 1b. Quotes inside <b> and <i> with other tags on same line
24802 !! options
24803 parsoid=html2wt
24804 !! html/parsoid
24805 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
24806 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
24807 <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>
24808 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
24809 '<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>
24810 '<i>foo</i> <div title="name">test</div>
24811 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
24812 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
24813 <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>
24814 </ol>
24815 !! wikitext
24816 '''a'' foo ''[[bar]]''
24817 ''a''' foo ''[[bar]]''
24818 ''a''' foo '''{{echo|[[bar]]}}'''
24819 [[foo]] x'''[[bar]]''
24820 '''foo'' <ref>test</ref>
24821 '''foo'' <div title="name">test</div>
24822 '''foo'' and <br> bar
24823 <references />
24824 !! end
24825
24826 !! test
24827 2. Link fragments separated by <i> and <b> tags
24828 !! options
24829 parsoid=html2wt
24830 !! html/parsoid
24831 <p>[[<i>foo</i>hello]]</p>
24832 <p>[[<b>foo</b>hello]]</p>
24833 !! wikitext
24834 [[''foo''<nowiki>hello]]</nowiki>
24835
24836 [['''foo'''<nowiki>hello]]</nowiki>
24837 !! end
24838
24839 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
24840 # this is one of the shortcomings of this format
24841 !! test
24842 3. Link fragments inside <i> and <b>
24843 !! options
24844 parsoid=html2wt
24845 !! html/parsoid
24846 <p><i>[[foo</i>]]</p>
24847 <p><b>[[foo</b>]]</p>
24848 !! wikitext
24849 ''[[foo''<nowiki>]]</nowiki>
24850
24851 '''[[foo'''<nowiki>]]</nowiki>
24852 !! end
24853
24854 !! test
24855 4. No escaping needed
24856 !! options
24857 parsoid=html2wt
24858 !! html/parsoid
24859 <p>'<span><i>bar</i></span>'
24860 '<span><b>bar</b></span>'
24861 'a:b'foo
24862 </p>
24863 !! wikitext
24864 '<span>''bar''</span>'
24865 '<span>'''bar'''</span>'
24866 'a:b'foo
24867 !! end
24868
24869 #### ----------- Paragraphs ---------------
24870 #### 1. No unnecessary escapes
24871 #### --------------------------------------
24872
24873 !! test
24874 1. No unnecessary escapes
24875 !! options
24876 parsoid=html2wt
24877 !! html/parsoid
24878 <p>bar <span>[[foo]]</span>
24879 </p><p>=bar <span>[[foo]]</span>
24880 </p><p>[[bar <span>[[foo]]</span>
24881 </p><p>]]bar <span>[[foo]]</span>
24882 </p><p>=bar <span>foo]]</span>=
24883 </p>
24884 !! wikitext
24885 bar <span><nowiki>[[foo]]</nowiki></span>
24886
24887 =bar <span><nowiki>[[foo]]</nowiki></span>
24888
24889 [[bar <span><nowiki>[[foo]]</nowiki></span>
24890
24891 ]]bar <span><nowiki>[[foo]]</nowiki></span>
24892
24893 =bar <span>foo]]</span><nowiki>=</nowiki>
24894 !!end
24895
24896 #### ----------------------- PRE --------------------------
24897 #### 1. Leading whitespace in SOL context should be escaped
24898 #### ------------------------------------------------------
24899 !! test
24900 1. Leading whitespace in SOL context should be escaped
24901 !! options
24902 parsoid=html2wt
24903 !! html/parsoid
24904 <p> a</p>
24905
24906 <p> a</p>
24907
24908 <p> a(tab)</p>
24909
24910 <p> a
24911 <!--cmt-->
24912 a</p>
24913
24914 <p>a
24915 b</p>
24916
24917 <p>a
24918 b</p>
24919
24920 <p>a
24921 b</p>
24922 !! wikitext
24923 <nowiki> </nowiki>a
24924
24925 <nowiki> </nowiki> a
24926
24927 a(tab)
24928
24929 <nowiki> </nowiki> a
24930 <!--cmt-->
24931 <nowiki> </nowiki>a
24932
24933 a
24934 <nowiki> </nowiki>b
24935
24936 a
24937 b
24938
24939 a
24940 b
24941 !! html/php
24942 <p> a
24943 </p><p> a
24944 </p><p> a(tab)
24945 </p><p> a
24946 a
24947 </p><p>a
24948 b
24949 </p><p>a
24950 b
24951 </p><p>a
24952 b
24953 </p>
24954 !! end
24955
24956 !! test
24957 2. Leading whitespace in non-indent-pre contexts should not be escaped
24958 !! options
24959 parsoid=html2wt
24960 !! html/parsoid
24961 <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>
24962 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
24963 <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>
24964 b</span></li>
24965 </ol>
24966 !! wikitext
24967 foo <ref>''a''
24968 b</ref>
24969 <references />
24970 !! end
24971
24972 !! test
24973 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
24974 !! options
24975 parsoid=html2wt
24976 !! html/parsoid
24977 <blockquote>
24978 <p>
24979 a
24980 <span>b</span>
24981 c</p>
24982 </blockquote>
24983 !! wikitext
24984 <blockquote>
24985 a
24986 <span>b</span>
24987 c
24988 </blockquote>
24989 !! end
24990
24991 !! test
24992 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
24993 !! options
24994 parsoid=html2wt
24995 !! html/parsoid
24996 <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>
24997 !! wikitext
24998 [[File:Foobar.jpg|thumb|caption]]
24999 !! end
25000
25001 !! test
25002 5. Nowiki escaping should account for indent-pres
25003 !! options
25004 parsoid=html2wt
25005 !! html/parsoid
25006 <pre>==foo==</pre>
25007 !! wikitext
25008 ==foo==
25009 !! end
25010
25011 !!test
25012 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
25013 !! options
25014 parsoid=html2wt
25015 !! html/parsoid
25016 <pre>
25017 * foo
25018 * bar
25019 </pre>
25020 !! wikitext
25021 * foo
25022 * bar
25023 !! end
25024
25025 #### --------------- Behavior Switches --------------------
25026
25027 !! test
25028 1. Valid behavior switches should be escaped
25029 !! options
25030 parsoid=html2wt
25031 !! html/parsoid
25032 __TOC__
25033 <i>__TOC__</i>
25034 !! wikitext
25035 <nowiki>__TOC__</nowiki>
25036 ''<nowiki>__TOC__</nowiki>''
25037 !! end
25038
25039 !! test
25040 2. Invalid behavior switches should not be escaped
25041 !! options
25042 parsoid=html2wt
25043 !! html/parsoid
25044 __TOO__
25045 __|__
25046 !! wikitext
25047 __TOO__
25048 __|__
25049 !! end
25050
25051 # We use indent-pre as an indirect way to test for sol-transparent behavior.
25052 !! test
25053 Behavior switches should be SOL-transparent
25054 !! options
25055 parsoid=html2wt
25056 !! html/parsoid
25057 <meta property="mw:PageProp/toc" />
25058
25059 <!-- this one's bogus -->
25060 <pre>__TOO__</pre>
25061
25062 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
25063
25064 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
25065 !! wikitext
25066 __TOC__
25067
25068 <!-- this one's bogus -->
25069 __TOO__
25070
25071 __TOC__ foo
25072
25073 __TOC__
25074 bar
25075 !! end
25076
25077 #### --------------- HTML tags ---------------
25078 #### 1. a tags
25079 #### 2. other tags
25080 #### 3. multi-line html tag
25081 #### 4. extension tags
25082 #### -----------------------------------------
25083 !! test
25084 1. a tags
25085 !! options
25086 parsoid=html2wt
25087 !! html/parsoid
25088 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
25089 !! wikitext
25090 <a href="http://google.com">google</a>
25091 !! end
25092
25093 !! test
25094 2. other tags
25095 !! options
25096 parsoid=html2wt
25097 !! html/parsoid
25098 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
25099 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
25100 <li> &lt;td&gt;</li></ul>
25101
25102 !! wikitext
25103 * <nowiki><div>foo</div></nowiki>
25104 * <nowiki><div style="color:red">foo</div></nowiki>
25105 * <nowiki><td></nowiki>
25106 !! end
25107
25108 !! test
25109 3. multi-line html tag
25110 !! options
25111 parsoid=html2wt
25112 !! html/parsoid
25113 <p>&lt;div
25114 &gt;foo&lt;/div
25115 &gt;
25116 </p>
25117 !! wikitext
25118 <nowiki><div
25119 >foo</div
25120 ></nowiki>
25121 !! end
25122
25123 !! test
25124 4. extension tags
25125 !! options
25126 parsoid=html2wt
25127 !! html/parsoid
25128 <p>&lt;ref&gt;foo&lt;/ref&gt;
25129 </p><p>&lt;ref&gt;bar
25130 </p><p>baz&lt;/ref&gt;
25131 </p>
25132 !! wikitext
25133 <nowiki><ref>foo</ref></nowiki>
25134
25135 <nowiki><ref>bar</nowiki>
25136
25137 baz<nowiki></ref></nowiki>
25138 !! end
25139
25140 #### --------------- Others ---------------
25141 !! test
25142 Escaping nowikis
25143 !! options
25144 parsoid=html2wt
25145 !! html/parsoid
25146 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
25147 </p>
25148 !! wikitext
25149 &lt;nowiki&gt;foo&lt;/nowiki&gt;
25150 !! end
25151
25152 ## The quote-char in the input is necessary for triggering the bug
25153 !! test
25154 (T54035) Nowiki-escaping should not get tripped by " :" in text
25155 !! options
25156 parsoid=html2wt
25157 !! html/parsoid
25158 <p>foo's bar :</p>
25159 !! wikitext
25160 foo's bar :
25161 !! end
25162
25163 #----------- End of wikitext escaping tests --------------
25164
25165 !! test
25166
25167 Tag-like HTML structures are passed through as text
25168 !! wikitext
25169 <x y>
25170
25171 <x.y>
25172
25173 <x-y>
25174
25175 1>2
25176
25177 x<y
25178
25179 a>b
25180
25181 1<d e>f
25182 !! html
25183 <p>&lt;x y&gt;
25184 </p><p>&lt;x.y&gt;
25185 </p><p>&lt;x-y&gt;
25186 </p><p>1&gt;2
25187 </p><p>x&lt;y
25188 </p><p>a&gt;b
25189 </p><p>1&lt;d e&gt;f
25190 </p>
25191 !! end
25192
25193 !! test
25194 HTML tag with necessary entities in attributes
25195 !! wikitext
25196 <span title="&amp;amp;">foo</span>
25197 !! html
25198 <p><span title="&amp;amp;">foo</span>
25199 </p>
25200 !! end
25201
25202 !! test
25203 HTML tag with 'unnecessary' entity encoding in attributes
25204 !! wikitext
25205 <span title="&amp;">foo</span>
25206 !! html
25207 <p><span title="&amp;">foo</span>
25208 </p>
25209 !! end
25210
25211 !! test
25212 HTML tag with broken attribute value quoting
25213 !! options
25214 parsoid=wt2html,html2html
25215 !! wikitext
25216 <span title="Hello world>Foo</span>
25217 !! html/php
25218 <p><span title="Hello world">Foo</span>
25219 </p>
25220 !! html/parsoid
25221 <p><span title="Hello world">Foo</span></p>
25222 !! end
25223
25224 !! test
25225 Self-closed tag with broken attribute value quoting
25226 !! options
25227 parsoid=wt2html,html2html
25228 !! wikitext
25229 <div title="Hello world />Foo
25230 !! html/php+tidy
25231 <div title="Hello world"></div>
25232 <p>Foo</p>
25233 !! html/parsoid
25234 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
25235 !! end
25236
25237 !! test
25238 Table with broken attribute value quoting
25239 !! options
25240 parsoid=wt2html,html2html
25241 !! wikitext
25242 {|
25243 | title="Hello world|Foo
25244 |}
25245 !! html/php
25246 <table>
25247 <tr>
25248 <td title="Hello world">Foo
25249 </td></tr></table>
25250
25251 !! html/parsoid
25252 <table>
25253 <tr>
25254 <td title="Hello world">Foo
25255 </td></tr></table>
25256
25257 !! end
25258
25259 !! test
25260 Table with broken attribute value quoting on consecutive lines
25261 !! options
25262 parsoid=wt2html,html2html
25263 !! wikitext
25264 {|
25265 | title="Hello world|Foo
25266 | style="color:red|Bar
25267 |}
25268 !! html/php
25269 <table>
25270 <tr>
25271 <td title="Hello world">Foo
25272 </td>
25273 <td style="color:red">Bar
25274 </td></tr></table>
25275
25276 !! html/parsoid
25277 <table><tbody>
25278 <tr>
25279 <td title="Hello world">Foo
25280 </td><td style="color: red">Bar
25281 </td></tr></tbody></table>
25282
25283 !! end
25284
25285 !!test
25286 Accept empty td cell attribute
25287 !! wikitext
25288 {|
25289 | align="center" | foo || |
25290 |}
25291 !! html
25292 <table>
25293 <tr>
25294 <td align="center"> foo </td>
25295 <td>
25296 </td></tr></table>
25297
25298 !!end
25299
25300 !!test
25301 Non-empty attributes in th-cells
25302 !! wikitext
25303 {|
25304 ! Foo !! style="color: red" | Bar
25305 |}
25306 !! html
25307 <table>
25308 <tr>
25309 <th> Foo </th>
25310 <th style="color: red"> Bar
25311 </th></tr></table>
25312
25313 !!end
25314
25315 !!test
25316 Accept empty attributes in th-cells
25317 !! wikitext
25318 {|
25319 !| foo !!| bar
25320 |}
25321 !! html
25322 <table>
25323 <tr>
25324 <th> foo </th>
25325 <th> bar
25326 </th></tr></table>
25327
25328 !!end
25329
25330 !!test
25331 Empty table rows go away
25332 !! wikitext
25333 {|
25334 | Hello
25335 | there
25336 |- class="foo"
25337 |-
25338 |}
25339 !! html
25340 <table>
25341 <tr>
25342 <td> Hello
25343 </td>
25344 <td> there
25345 </td></tr>
25346
25347 </table>
25348
25349 !! end
25350
25351 ###
25352 ### Parsoid-centric tests for testing RTing of inter-element separators
25353 ### Edge cases not tested by existing parser tests and specific to
25354 ### Parsoid-specific serialization strategies.
25355 ###
25356
25357 !!test
25358 RT-ed inter-element separators should be valid separators
25359 !! wikitext
25360 {|
25361 |- [[foo]]
25362 |}
25363 !! html/php
25364 <table>
25365
25366 </table>
25367
25368 !! html/parsoid
25369 <table>
25370 <tbody><tr data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
25371 </tbody></table>
25372 !!end
25373
25374 # Parsoid-only since PHP parser relies on Tidy for correct output
25375 !!test
25376 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
25377 !!options
25378 parsoid
25379 !! wikitext
25380 {|
25381 |<small>foo
25382 bar
25383 |}
25384
25385 {|
25386 |<small>foo<small>
25387 |}
25388 !! html
25389 <table>
25390 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
25391 <p>bar</p></small></td></tr>
25392 </tbody></table>
25393
25394 <table>
25395 <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>
25396 </tbody></table>
25397 !!end
25398
25399 # Note that the "style" attribute is really a template parameter here.
25400 # The = would have to be {{=}} if you wanted the literal.
25401 !!test
25402 Empty TD followed by TD with tpl-generated attribute
25403 !! wikitext
25404 {|
25405 |-
25406 |
25407 |{{echo|style='color:red'}}|foo
25408 |}
25409 !! html
25410 <table>
25411
25412 <tr>
25413 <td>
25414 </td>
25415 <td>foo
25416 </td></tr></table>
25417
25418 !!end
25419
25420 !!test
25421 Indented table with an empty td
25422 !! wikitext
25423 {|
25424 |-
25425 |
25426 |foo
25427 |}
25428 !! html
25429 <table>
25430
25431 <tr>
25432 <td>
25433 </td>
25434 <td>foo
25435 </td></tr></table>
25436
25437 !!end
25438
25439 ## We have some newline diffs RT-ing this edge case
25440 ## and it is not important enough -- we seem to be emitting
25441 ## at most 2 newlines after a </tr> and this is unrelated to
25442 ## the issue from T85627 that this is testing.
25443 !!test
25444 Indented table with blank lines in between (T85627)
25445 !! options
25446 parsoid=wt2html
25447 !! wikitext
25448 {|
25449 |foo
25450
25451
25452 |}
25453 !! html
25454 <table>
25455
25456 <tr>
25457 <td>foo
25458 </td></tr></table>
25459
25460 !!end
25461
25462 !!test
25463 Indented block & table
25464 !! wikitext
25465 <div>foo</div>
25466 {|
25467 |foo
25468 |}
25469 !! html/php
25470 <div>foo</div>
25471 <table>
25472 <tr>
25473 <td>foo
25474 </td></tr></table>
25475
25476 !! html/parsoid
25477 <div data-parsoid='{"stx":"html"}'>foo</div>
25478 <table><tbody>
25479 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
25480 </tbody></table>
25481 !!end
25482
25483 !! test
25484 Indent and comment before table row
25485 !! wikitext
25486 {|
25487 <!--hi-->|-
25488 | there
25489 |}
25490 !! html/php
25491 <table>
25492
25493 <tr>
25494 <td> there
25495 </td></tr></table>
25496
25497 !! html/parsoid
25498 <table>
25499 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
25500 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
25501 </tbody></table>
25502 !! end
25503
25504 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
25505 !!test
25506 Empty TR followed by a template-generated TR
25507 !!options
25508 parsoid
25509 !! wikitext
25510 {|
25511 |-
25512 {{echo|<tr><td>foo</td></tr>}}
25513 |}
25514 !! html
25515 <table>
25516 <tbody>
25517 <tr></tr>
25518 <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}}]}'>
25519 <td>foo</td></tr>
25520 </tbody></table>
25521 !!end
25522
25523 ## PHP and parsoid output differ for this, and since this is primarily
25524 ## for testing Parsoid's serializer, marking this Parsoid only
25525 !!test
25526 Empty TR followed by mixed-ws-comment line should RT correctly
25527 !!options
25528 parsoid
25529 !! wikitext
25530 {|
25531 |-
25532 <!--c-->
25533 |-
25534 <!--c--> <!--d-->
25535 |}
25536 !! html
25537 <table>
25538 <tbody>
25539 <tr></tr>
25540 <!--c-->
25541 <tr>
25542 <!--c--> </tr><!--d-->
25543 </tbody></table>
25544
25545 !!end
25546
25547 !!test
25548 Multi-line image caption generated by templates with/without trailing newlines
25549 !! wikitext
25550 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
25551 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
25552 !! html/parsoid
25553 <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>
25554 <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>
25555 !!end
25556
25557 !! test
25558 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
25559 !! options
25560 parsoid=html2wt
25561 !! html/parsoid
25562 <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>
25563
25564 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
25565 !! wikitext
25566 <includeonly>foo</includeonly>
25567 new para
25568
25569 [[Category:Foo]]
25570
25571 = new heading =
25572 !! end
25573
25574 ## PHP emits broken html for this, and since this is primarily
25575 ## a Parsoid serializer test, marking this Parsoid only
25576 !!test
25577 Improperly nested inline or quotes tags with whitespace in between
25578 !! wikitext
25579 <span> <s>x</span> </s>
25580 ''' ''x''' ''
25581 !! html/parsoid
25582 <p><span> <s>x</s></span><s> </s>
25583 <b> <i>x</i></b><i> </i>
25584 </p>
25585 !!end
25586
25587 !!test
25588 Encapsulate protected attributes from wt
25589 !! wikitext
25590 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
25591
25592 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
25593 | ok
25594 |}
25595 !! html/parsoid
25596 <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>
25597
25598 <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">
25599 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'> ok</td></tr>
25600 </tbody></table>
25601 !!end
25602
25603 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
25604 ## Having nested or stray pre tags results in the attempt to add duplicates,
25605 ## causing an assertion fail. This test tries to prevent that situation.
25606 !!test
25607 Ensure ParagraphWrapper can deal with stray closing pre tags
25608 !!options
25609 parsoid=wt2html
25610 !! wikitext
25611 plain text</pre>
25612 !! html/parsoid
25613 plain text
25614 !!end
25615
25616 !!test
25617 1. Ensure fostered text content is wrapped in element nodes
25618 !!options
25619 parsoid=wt2html
25620 !! wikitext
25621 <table>hi</table><table>ho</table>
25622 !! html/parsoid
25623 <p>hi</p>
25624 <table></table>
25625 <p>ho</p>
25626 <table></table>
25627 !!end
25628
25629 !!test
25630 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
25631 !!options
25632 parsoid=wt2html,wt2wt
25633 !! wikitext
25634 <table>
25635 <tr> || ||
25636 <td> a
25637 </table>
25638 !! html/parsoid
25639 <p> || ||
25640 </p><table>
25641 <tbody><tr><td> a</td></tr>
25642 </tbody></table>
25643 !!end
25644
25645 !!test
25646 Encapsulation properly handles null DSR information from foster box
25647 !!options
25648 parsoid=wt2html,wt2wt
25649 !! wikitext
25650 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
25651 !! html/parsoid
25652 <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>
25653 !!end
25654
25655 !!test
25656 1. Encapsulate foster-parented transclusion content
25657 !!options
25658 parsoid=wt2wt,wt2html
25659 !! wikitext
25660 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
25661 !! html/parsoid
25662 <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>
25663 <tbody>
25664 <tr>
25665 <td>bar</td>
25666 </tr>
25667 </tbody>
25668 </table>
25669 !!end
25670
25671 !!test
25672 2. Encapsulate foster-parented transclusion content
25673 !!options
25674 parsoid=wt2wt,wt2html
25675 !! wikitext
25676 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
25677 !! html/parsoid
25678 <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>
25679 <table>
25680 <tbody>
25681 <tr>
25682 <td>bar</td>
25683 </tr>
25684 </tbody>
25685 </table>
25686 !!end
25687
25688 !!test
25689 3. Encapsulate foster-parented transclusion content
25690 !!options
25691 parsoid=wt2wt,wt2html
25692 !! wikitext
25693 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
25694 !! html/parsoid
25695 <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;]}">
25696 <p>foo</p>
25697 </div>
25698 <table>
25699 <tbody>
25700 <tr>
25701 <td>bar</td>
25702 </tr>
25703 </tbody>
25704 </table>
25705 !!end
25706
25707 !!test
25708 4. Encapsulate foster-parented transclusion content
25709 !!options
25710 parsoid=wt2wt,wt2html
25711 !! wikitext
25712 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
25713 !! html/parsoid
25714 <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;]}">
25715 <p>foo</p>
25716 </div>
25717 <table>
25718 <tbody>
25719 <tr>
25720 <td>bar</td>
25721 </tr>
25722 </tbody>
25723 </table>
25724 !!end
25725
25726 !!test
25727 5. Encapsulate foster-parented transclusion content
25728 !!options
25729 parsoid=wt2wt,wt2html
25730 !! wikitext
25731 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
25732 !! html/parsoid
25733 <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>
25734 <table>
25735 <tbody>
25736 <tr>
25737 <td>
25738 <div>
25739 <p>foo</p>
25740 </div>
25741 </td>
25742 </tr>
25743 </tbody>
25744 </table>
25745 !!end
25746
25747 !!test
25748 6. Encapsulate foster-parented transclusion content
25749 !!options
25750 parsoid=wt2wt,wt2html
25751 !! wikitext
25752 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
25753 !! html/parsoid
25754 <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>
25755 <table>
25756 <tbody>
25757 <tr>
25758 <td>
25759 <div>
25760 <p>foo</p>
25761 </div>
25762 </td>
25763 </tr>
25764 </tbody>
25765 </table>
25766 <p>ok</p>
25767 !!end
25768
25769 !!test
25770 7. Encapsulate foster-parented transclusion content
25771 !!options
25772 parsoid=wt2wt,wt2html
25773 !! wikitext
25774 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
25775 !! html/parsoid
25776 <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>
25777 <table>
25778 <tbody>
25779 <tr>
25780 <td>bar</td>
25781 </tr>
25782 </tbody>
25783 </table>
25784 !!end
25785
25786 # Note that the wt is broken on purpose: the = should be {{=}} if you
25787 # don't want it to be a template parameter key.
25788 !!test
25789 8. Encapsulate foster-parented transclusion content
25790 !!options
25791 parsoid=wt2wt,wt2html
25792 !! wikitext
25793 {{echo|a
25794 }}{|{{echo|style='color:red'}}
25795 |-
25796 |b
25797 |}
25798 !! html/parsoid
25799 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}'>a</p>
25800 <span> </span>
25801 <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>
25802 <table>
25803 <tbody>
25804 <tr>
25805 <td>b</td>
25806 </tr>
25807 </tbody>
25808 </table>
25809 !!end
25810
25811 !!test
25812 9. Encapsulate foster-parented transclusion content
25813 !!options
25814 parsoid=wt2wt,wt2html
25815 !! wikitext
25816 <table>{{echo|hi</table>hello}}
25817 !! html/parsoid
25818 <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>
25819 !!end
25820
25821 !!test
25822 Table in fosterable position
25823 !!options
25824 parsoid=wt2html
25825 !! wikitext
25826 {{OpenTable}}
25827 <div>
25828 {|
25829 |}
25830 </div>
25831 |}
25832 !! html/parsoid
25833 <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">
25834 </span>
25835 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
25836
25837 <table>
25838 </table>
25839 !!end
25840
25841 # Parsoid only for T66747
25842 !! test
25843 Properly encapsulate empty-content transclusions in fosterable positions
25844 !! wikitext
25845 <table>
25846 {{#if:|
25847 <td>foo</td>
25848 }}
25849 </table>
25850 !! html/parsoid
25851 <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"}]]}'>
25852
25853 </table>
25854 !! end
25855
25856 !! test
25857 Always encapsulate foster box when template range is expanded to table
25858 !! options
25859 parsoid=wt2wt
25860 !! wikitext
25861 {|
25862 hello
25863 {{OpenTable}}
25864 |}
25865 !! html/parsoid
25866
25867 !! end
25868
25869 !! test
25870 T115289: Unclosed table
25871 !! wikitext
25872 {{echo|<table>}}<!--c-->[[Category:Two]]
25873 !! html/parsoid
25874 <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>
25875 !! end
25876
25877 !! test
25878 T115289: Don't migrate newlines out of tables with fostered content
25879 !! wikitext
25880 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
25881 !! html/parsoid
25882 <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>
25883 !! end
25884
25885 !! test
25886 T73074: More fostering fun
25887 !! wikitext
25888 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
25889 !! html/parsoid
25890 <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>
25891 !! end
25892
25893 !!test
25894 Support <object> element with .data attribute
25895 !!options
25896 parsoid=html2wt
25897 !! html/parsoid
25898 <object data="test.swf"></object>
25899 !! wikitext
25900 <object data="test.swf"></object>
25901 !!end
25902
25903 !! test
25904 Don't block XML namespace declaration
25905 !! wikitext
25906 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
25907 !! html/php
25908 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
25909 </p>
25910 !! html/parsoid
25911 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
25912 !! end
25913
25914 # -----------------------------------------------------------------
25915 # The following section of tests are primarily to spec requirements
25916 # around Parsoid's serialization (old, new, edited content)
25917 #
25918 # All these tests are marked Parsoid html2wt and html2html only
25919 # ----------------------------------------------------------------
25920
25921 !! test
25922 Ignore rel attribute in a-tags during serialization to url-links
25923 !! options
25924 parsoid=html2wt
25925 !! html/parsoid
25926 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
25927 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
25928 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
25929 !! wikitext
25930 http://en.wikipedia.org/wiki/Foobar
25931 http://en.wikipedia.org/wiki/Foobar
25932 http://en.wikipedia.org/wiki/Foobar
25933 !! end
25934
25935 # 'mi' is a localinterwiki prefix as well as a language
25936 !! test
25937 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
25938 !! options
25939 parsoid=html2wt
25940 !! html/parsoid
25941 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
25942 !! wikitext
25943 [[Foo]]
25944 !! end
25945
25946 !! test
25947 Parsoid should accept interwiki shortcuts
25948 !! options
25949 parsoid=html2wt
25950 !! html/parsoid
25951 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
25952 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
25953 <a href='./fr:Foo'>Foo</a></p>
25954 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
25955 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
25956 <a href='fr%3AFoo'>Foo</a></p>
25957 !! wikitext
25958 [[:fr:Foo|Foo]]
25959 [[:fr:Foo|Foo]]
25960 [[:fr:Foo|Foo]]
25961
25962 [[:fr:Foo|Foo]]
25963 [[:fr:Foo|Foo]]
25964 [[:fr:Foo|Foo]]
25965 !! end
25966
25967 !! test
25968 Parsoid should not accept invalid interwiki shortcuts
25969 !! options
25970 parsoid=html2wt
25971 !! html/parsoid
25972 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
25973 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
25974 <a href='news:Foo'>Foo</a></p>
25975 !! wikitext
25976 [news:Foo Foo]
25977 [news:Foo Foo]
25978 [news:Foo Foo]
25979 !! end
25980
25981 # See T93839
25982 !! test
25983 New wikilinks should be serialized properly
25984 !! options
25985 parsoid=html2wt
25986 !! html/parsoid
25987 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
25988 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
25989 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
25990 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
25991 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
25992 !! wikitext
25993 [[Foo]]
25994 [[Foo]]
25995 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
25996 http://en.wikipedia.org/wiki/Foo
25997 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
25998 !! end
25999
26000 !! test
26001 New wiki links (href variations)
26002 !! options
26003 parsoid=html2wt
26004 !! html/parsoid
26005 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
26006 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
26007 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
26008 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
26009 !! wikitext
26010 [[Foo_bar]]
26011 [[Foo_bar]]
26012 [[Foo_bar]]
26013 [[Toxine bactérienne]]
26014 !! end
26015
26016 !! test
26017 New wiki links (content string variations)
26018 !! options
26019 parsoid=html2wt
26020 !! html/parsoid
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="./Foo_bar">./Foo_bar</a>
26024 !! wikitext
26025 [[Foo_bar]]
26026 [[Foo bar]]
26027 [[Foo_bar|./Foo_bar]]
26028 !! end
26029
26030 !! test
26031 New category links (href variations)
26032 !! options
26033 parsoid=html2wt
26034 !! html/parsoid
26035 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
26036 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
26037 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
26038 !! wikitext
26039 [[Category:Toxine bactérienne]]
26040 [[Category:Toxine bactérienne]]
26041 [[Category:Toxine bactérienne]]
26042 !! end
26043
26044 !! test
26045 New sol transparent links don't need indent-pre nowiki protection
26046 !! options
26047 parsoid=html2wt
26048 language=de
26049 !! html/parsoid
26050 <link rel="mw:PageProp/redirect" href="./Main_Page">
26051 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
26052 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
26053 !! wikitext
26054 #WEITERLEITUNG [[Main Page]]
26055 <!-- this is good --> [[Category:Good]]
26056 <!-- this is great --> [[Kategorie:Great]]
26057 !! end
26058
26059 !! test
26060 New interlanguage links (href variations)
26061 !! options
26062 parsoid=html2wt
26063 !! html/parsoid
26064 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
26065 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
26066 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
26067 !! wikitext
26068 [[es:Toxine bactérienne]]
26069 [[es:Toxine_bactérienne]]
26070 [[es:Toxine_bactérienne]]
26071 !! end
26072
26073 !! test
26074 Image: Modifying size of an image (1)
26075 !! options
26076 parsoid={
26077 "modes": ["wt2wt"],
26078 "changes": [
26079 ["img[height]", "attr", "height", "22"],
26080 ["img[width]", "attr", "width", "200"]
26081 ]
26082 }
26083 !! wikitext
26084 [[Image:Foobar.jpg|230x230px]]
26085 !! wikitext/edited
26086 [[Image:Foobar.jpg|200x200px]]
26087 !!end
26088
26089 !! test
26090 Image: Modifying size of an image (2)
26091 !! options
26092 parsoid={
26093 "modes": ["wt2wt"],
26094 "changes": [
26095 ["img[height]", "attr", "height", "100"],
26096 ["img[width]", "attr", "width", "500"]
26097 ]
26098 }
26099 !! wikitext
26100 [[Image:Foobar.jpg|230x230px]]
26101 !! wikitext/edited
26102 [[Image:Foobar.jpg|500x500px]]
26103 !!end
26104
26105 # Change in size is ignored so long as class='mw-default-size'
26106 !! test
26107 Image: Modifying size of an image (3)
26108 !! options
26109 parsoid={
26110 "modes": ["wt2wt"],
26111 "changes": [
26112 ["figure[class]", "removeClass", "mw-default-size"],
26113 ["figure img", "attr", "height", "19"],
26114 ["figure img", "attr", "width", "170"]
26115 ]
26116 }
26117 !! wikitext
26118 [[Image:Foobar.jpg|thumb]]
26119 !! wikitext/edited
26120 [[Image:Foobar.jpg|thumb|170x170px]]
26121 !!end
26122
26123 !! test
26124 Image: Modifying alignment of an image (T50665)
26125 !! options
26126 parsoid={
26127 "modes": ["wt2wt"],
26128 "changes": [
26129 ["figure[class]", "removeClass", "mw-halign-right"],
26130 ["figure[class]", "addClass", "mw-halign-left"]
26131 ]
26132 }
26133 !! wikitext
26134 [[Image:Foobar.jpg|thumb|caption|right]]
26135 !! wikitext/edited
26136 [[Image:Foobar.jpg|thumb|caption|left]]
26137 !! end
26138
26139 !! test
26140 Image: Modifying mw-default-size of an frameless image (T64805)
26141 !! options
26142 parsoid={
26143 "modes": ["wt2wt"],
26144 "changes": [
26145 ["figure.mw-default-size", "removeClass", "mw-default-size"]
26146 ]
26147 }
26148 !! wikitext
26149 [[Image:Foobar.jpg|frameless|right]]
26150 !! wikitext/edited
26151 [[Image:Foobar.jpg|frameless|right|220x220px]]
26152 !! end
26153
26154 !! test
26155 Image: Modifying valign of an image (T51221)
26156 !! options
26157 parsoid={
26158 "modes": ["wt2wt"],
26159 "changes": [
26160 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
26161 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
26162 ]
26163 }
26164 !! wikitext
26165 [[File:Foobar.jpg|20px|middle]]
26166 !! wikitext/edited
26167 [[File:Foobar.jpg|20px|text-top]]
26168 !! end
26169
26170 !! test
26171 Image: Modifying alt attribute of an image (T58400)
26172 !! options
26173 parsoid={
26174 "modes": ["wt2wt"],
26175 "changes": [
26176 ["img[alt]", "attr", "alt", "some alternate edited text"]
26177 ]
26178 }
26179 !! wikitext
26180 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
26181 !! wikitext/edited
26182 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
26183 !!end
26184
26185 !! test
26186 Image: Modifying caption of an image
26187 !! options
26188 parsoid={
26189 "modes": ["wt2wt"],
26190 "changes": [
26191 ["figcaption", "text", "new caption"]
26192 ]
26193 }
26194 !! wikitext
26195 [[Image:Foobar.jpg|thumb|original caption]]
26196 !! wikitext/edited
26197 [[Image:Foobar.jpg|thumb|new caption]]
26198 !!end
26199
26200 !! test
26201 Image: empty alt attribute (T50924)
26202 !! options
26203 parsoid
26204 !! wikitext
26205 [[File:Foobar.jpg|thumb|alt=|bar]]
26206 !! html
26207 <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>
26208 !! end
26209
26210 !! test
26211 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
26212 !! options
26213 parsoid=html2wt
26214 language=ar
26215 disabled
26216 !! html/parsoid
26217 <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>
26218 !! wikitext
26219 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
26220 !! end
26221
26222 !! test
26223 Image: Block level image should have \n before and after
26224 !! wikitext
26225 123
26226 [[File:Foobar.jpg|right|thumb|150x150px]]
26227 456
26228 !! html/parsoid
26229 <p>123</p>
26230 <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>
26231 <p>456</p>
26232 !!end
26233
26234 !! test
26235 Image: New block level image should have \n before and after (existing content)
26236 !! wikitext
26237 123
26238 [[File:Foobar.jpg|right|thumb|150x150px]]
26239 456
26240 !! html/parsoid
26241 <p>123</p>
26242 <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>
26243 <p>456</p>
26244 !!end
26245
26246 !! test
26247 Image: upright option (parsoid)
26248 !! wikitext
26249 [[File:Foobar.jpg|thumb|upright|caption]]
26250 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
26251 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
26252 !! html/parsoid
26253 <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>
26254 <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>
26255 <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>
26256 !!end
26257
26258 !! test
26259 Image: upright option is ignored on inline and frame images (parsoid)
26260 !! wikitext
26261 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
26262 !! html/parsoid
26263 <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>
26264 !!end
26265
26266 !! test
26267 Image: from basic HTML (1)
26268 !! options
26269 parsoid=html2wt
26270 !! html/parsoid
26271 <span typeof="mw:Image">
26272 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
26273 </span>
26274 !! wikitext
26275 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
26276 !! end
26277
26278 !! test
26279 Image: from basic HTML (2)
26280 !! options
26281 parsoid=html2wt
26282 !! html/parsoid
26283 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
26284 !! wikitext
26285 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
26286 !! end
26287
26288 !! test
26289 Image: from basic HTML (3)
26290 !! options
26291 parsoid=html2wt
26292 !! html/parsoid
26293 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
26294 !! wikitext
26295 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
26296 !! end
26297
26298 !! test
26299 Image: from basic HTML (4)
26300 !! options
26301 parsoid=html2wt
26302 !! html/parsoid
26303 <img src="./File:Foobar.jpg">
26304 !! wikitext
26305 [[File:Foobar.jpg|link=]]
26306 !! end
26307
26308 !! test
26309 Image: Invalid title as link
26310 !! wikitext
26311 [[File:Foobar.jpg|link=<]]
26312 !! html/php
26313 <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>
26314 </p>
26315 !! html/parsoid
26316 <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>
26317 !! end
26318
26319 !! test
26320 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
26321 !! options
26322 parsoid=html2wt
26323 !! html/parsoid
26324 <ul>
26325 <li><p>foo</p></li>
26326 </ul>
26327 !! wikitext
26328 * foo
26329 !! end
26330
26331 !! test
26332 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
26333 !! options
26334 parsoid=html2wt
26335 !! html/parsoid
26336 <ul> <li>foo</li></ul>
26337 !! wikitext
26338 * foo
26339 !! end
26340
26341 !! test
26342 Don't strip leading whitespace when handling indent-pre suppressing tags
26343 !! options
26344 parsoid=html2wt
26345 !! html/parsoid
26346 <table>
26347 <tr><td> indented row</td></tr>
26348 </table>
26349 <blockquote><p>
26350 <b>This is very bold of you!</b>
26351 </p>
26352 <table><tr><td>
26353 indented cell (no pre-wrapping!)
26354 </td></tr></table>
26355 </blockquote>
26356 <p>foo</p>
26357 <div>bar</div>
26358 !! wikitext
26359 {|
26360 | indented row
26361 |}
26362 <blockquote>
26363 '''This is very bold of you!'''
26364
26365 {|
26366 |
26367 indented cell (no pre-wrapping!)
26368 |}
26369 </blockquote>
26370 foo
26371 <div>bar</div>
26372 !! end
26373
26374 !! test
26375 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
26376 !! options
26377 parsoid=html2wt
26378 !! html/parsoid
26379 <p>foo</p>
26380 <span>bar</span>
26381
26382 <span>foo2
26383 </span>bar2
26384
26385 <div>foo</div>
26386 <span>bar</span>
26387
26388 <div>
26389 <span>foo</span>
26390 </div>
26391 !! wikitext
26392 foo
26393
26394 <span>bar</span>
26395
26396 <span>foo2
26397 <nowiki> </nowiki></span>bar2
26398
26399 <div>foo</div>
26400 <nowiki> </nowiki><span>bar</span>
26401
26402 <div>
26403 <nowiki> </nowiki><span>foo</span>
26404 </div>
26405 !! end
26406
26407 !! test
26408 Lists: Dont insert newlines in a serialized list item.
26409 !! options
26410 parsoid=html2wt
26411 !! html/parsoid
26412 <ul><li>a<br>b</li><li>c</li></ul>
26413 !! wikitext
26414 * a<br>b
26415 * c
26416 !! end
26417
26418 !! test
26419 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
26420 !! options
26421 parsoid={
26422 "modes": ["html2wt"],
26423 "scrubWikitext": false
26424 }
26425 !! html/parsoid
26426 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
26427 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
26428
26429 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
26430 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
26431
26432 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
26433
26434 <h2><meta property="mw:PageProp/toc" /> ok</h2>
26435 !! wikitext
26436 == hello there [[Category:A1]] ==
26437
26438 == [[Category:A2]] hi pal ==
26439
26440 == <!--foo--> [[Category:A3]] how goes it ==
26441
26442 == it goes well [[Category:A4]] <!--bar--> ==
26443
26444 ==howdy [[Category:A5]]==
26445
26446 == __TOC__ ok ==
26447 !! end
26448
26449 !! test
26450 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
26451 !! options
26452 parsoid={
26453 "modes": ["html2wt"],
26454 "scrubWikitext": true
26455 }
26456 !! html/parsoid
26457 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
26458 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
26459
26460 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
26461 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
26462
26463 <h2><meta property="mw:PageProp/toc" /> ok</h2>
26464 !! wikitext
26465 == hello there ==
26466 [[Category:A1]]
26467 [[Category:A2]]
26468
26469 == hi pal ==
26470
26471 <!--foo--> [[Category:A3]]
26472
26473 == how goes it ==
26474
26475 == it goes well ==
26476 [[Category:A4]] <!--bar-->
26477
26478 __TOC__
26479
26480 == ok ==
26481 !! end
26482
26483 !! test
26484 Headings: Don't hoist metas that come from templates
26485 !! options
26486 parsoid={
26487 "modes": ["html2wt"],
26488 "scrubWikitext": true
26489 }
26490 !! html/parsoid
26491 <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>
26492 !! wikitext
26493 == {{echo|foo [[Category:Foo]]}} ==
26494 !! end
26495
26496 !! test
26497 Headings: Category in ref isn't hoisted
26498 !! options
26499 parsoid={
26500 "modes": ["html2wt"],
26501 "scrubWikitext": true
26502 }
26503 !! html/parsoid
26504 <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>
26505
26506 <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>
26507 !! wikitext
26508 == foo <ref>bar
26509 [[Category:Baz]] </ref> ==
26510
26511 <references />
26512 !! end
26513
26514 !! test
26515 Parsoid: Serialize positional parameters with = in them as named parameter
26516 !! options
26517 parsoid=html2wt
26518 !! html/parsoid
26519 <p about="#mwt1" typeof="mw:Transclusion"
26520 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
26521
26522 <p about="#mwt1" typeof="mw:Transclusion"
26523 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
26524
26525 <!--Orig params with data-parsoid has heuristics for handling = chars-->
26526 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
26527 <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>
26528 !! wikitext
26529 {{echo|1=f=oo}}
26530
26531 {{echo|1=f=oo|2=bar}}
26532
26533 <!--Orig params with data-parsoid has heuristics for handling = chars-->
26534 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
26535 {{echo|<nowiki>f=oo</nowiki>|bar}}
26536 !! end
26537
26538 !! test
26539 Parsoid: Serialize positional parameters with = in extlink as named parameter
26540 !! options
26541 parsoid=html2wt
26542 !! html/parsoid
26543 <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>
26544 !! wikitext
26545 {{echo|1=http://stuff?is=ok}}
26546 !! end
26547
26548 !! test
26549 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
26550 !! options
26551 parsoid=html2wt
26552 !! html/parsoid
26553 <div>a<p>b</p></div>
26554 <div>a
26555 <p>b</p></div>
26556 <div>
26557 a
26558 <p>b</p></div>
26559 !! wikitext
26560 <div>a
26561 b
26562 </div>
26563 <div>a
26564 b
26565 </div>
26566 <div>
26567 a
26568
26569 b
26570 </div>
26571 !! end
26572
26573 !! test
26574 Substrings resembling wikitext in hrefs should not get nowiki escapes
26575 !! options
26576 parsoid=html2wt
26577 !! html/parsoid
26578 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
26579 !! wikitext
26580 [[Foo''bar''baz]]
26581 !! end
26582
26583 !! test
26584 Enforce single-line context in the serializer
26585 !! options
26586 parsoid=html2wt
26587 !! html/parsoid
26588 <h2>testing
26589 123</h2>
26590
26591 <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">
26592 </span><span about="#mwt1">you</span> </h2>
26593
26594 <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>
26595
26596 <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
26597 there</span></li></ol>
26598
26599 <ul><li>asd
26600 sdf</li></ul>
26601
26602 <ul><li>foo
26603 bar
26604 baz</li>
26605 <li>foo <b>bar</b>
26606 baz</li></ul>
26607
26608 <dl><dt>hi
26609 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
26610 ho</dd></dl>
26611
26612 <dl><dd> <table>
26613 <tbody><tr><td> ha
26614 ha
26615 ha</td></tr>
26616 </tbody></table></dd></dl>
26617 !! wikitext
26618 == testing 123 ==
26619
26620 == hi {{bogus|there
26621 you}} ==
26622
26623 == foo <ref>hello
26624 there</ref> ==
26625
26626 <references />
26627
26628 * asd sdf
26629
26630 * foo bar baz
26631 * foo '''bar''' baz
26632
26633 ; hi ho : hi ho
26634
26635 : {|
26636 | ha
26637 ha
26638 ha
26639 |}
26640 !! end
26641
26642 !! test
26643 Serialize new placeholder space without spans
26644 !! options
26645 parsoid=html2wt
26646 !! html/parsoid
26647 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
26648
26649 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
26650
26651 <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>
26652 !! wikitext
26653 foo : bar
26654
26655 foo : bar
26656
26657 <ref>foo : bar</ref>ok
26658 !! end
26659
26660
26661 #-----------------------
26662 # Tag minimization tests
26663 #-----------------------
26664
26665 !! test
26666 1. I/B quote minimization: wikitext-only tags should be combined
26667 !! options
26668 parsoid=html2wt
26669 !! html/parsoid
26670 <p><i>A</i><i>B</i></p>
26671 <p><b>A</b><b>B</b></p>
26672 <p><i>A</i><b><i>B</i></b></p>
26673 <p><b>A</b><i><b>B</b></i></p>
26674 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
26675 <p><i><b>A</b></i><i><b>B</b></i></p>
26676 <p><i><b>A</b></i><b><i>B</i></b></p>
26677 <p><b><i>A</i></b><i><b>B</b></i></p>
26678 !! wikitext
26679 ''AB''
26680
26681 '''AB'''
26682
26683 ''A'''B'''''
26684
26685 '''A''B'''''
26686
26687 '''A''BC''D'''
26688
26689 '''''AB'''''
26690
26691 '''''AB'''''
26692
26693 '''''AB'''''
26694 !! end
26695
26696 !! test
26697 2. I/B quote minimization: wikitext and html tags should not be combined
26698 !! options
26699 parsoid=html2wt
26700 !! html/parsoid
26701 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
26702 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
26703 !! wikitext
26704 ''A''<i>B</i>
26705
26706 ''A''<nowiki/>'''<i>B</i>'''
26707 !! end
26708
26709 !! test
26710 3. I/B quote minimization: templated content stops minimization
26711 !! options
26712 parsoid=html2wt
26713 !! html/parsoid
26714 <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>
26715 <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>
26716 !! wikitext
26717 ''A''{{echo|''B''}}
26718
26719 ''A''{{echo|'''''B'''''}}
26720 !! end
26721
26722 !! test
26723 4. I/B quote minimization: new content should be mimimized with adjacent old content
26724 !! options
26725 parsoid=html2wt
26726 !! html/parsoid
26727 <p><i>A</i><i>B</i></p>
26728 <p><b>A</b><b>B</b></p>
26729 <p><i>A</i><b><i>B</i></b></p>
26730 !! wikitext
26731 ''AB''
26732
26733 '''AB'''
26734
26735 ''A'''B'''''
26736 !! end
26737
26738 !! test
26739 5a. Merge adjacent quote nodes if they've been edited
26740 !! options
26741 parsoid={
26742 "modes": ["wt2wt", "selser"],
26743 "changes": [
26744 ["p", "contents", "remove", ":contains('b')"]
26745 ]
26746 }
26747 !! wikitext
26748 ''a''b''c''
26749 !! wikitext/edited
26750 ''ac''
26751 !! end
26752
26753 !! test
26754 5b. Merge adjacent quote nodes if they've been edited
26755 !! options
26756 parsoid={
26757 "modes": ["wt2wt", "selser"],
26758 "changes": [
26759 ["#x", "remove"]
26760 ]
26761 }
26762 !! wikitext
26763 ''a''<span id="x">b</span>''c''
26764 !! wikitext/edited
26765 ''ac''
26766 !! end
26767
26768 !! test
26769 1. Merge adjacent link nodes as long as at least one element is new
26770 !! options
26771 parsoid={
26772 "modes": ["html2wt"],
26773 "scrubWikitext": true
26774 }
26775 !! html/parsoid
26776 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
26777 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
26778 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
26779 !! wikitext
26780 [[Football]]
26781 [[Football]]
26782 [[Football|Foot]][[Football|ball]]
26783 !! end
26784
26785 !! test
26786 2. Merge adjacent link nodes and enable additional normalizations
26787 !! options
26788 parsoid={
26789 "modes": ["html2wt"],
26790 "scrubWikitext": true
26791 }
26792 !! html/parsoid
26793 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
26794 !! wikitext
26795 [[Football|''Football'']]
26796 !! end
26797
26798 !! test
26799 3. Don't merge adjacent link nodes if scrubWikitext is false
26800 !! options
26801 parsoid={
26802 "modes": ["html2wt"],
26803 "scrubWikitext": false
26804 }
26805 !! html/parsoid
26806 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
26807 !! wikitext
26808 [[Football|Foot]][[Football|ball]]
26809 !! end
26810
26811 #------------------------------
26812 # End of tag minimization tests
26813 #------------------------------
26814
26815 !!test
26816 T56262: New entities
26817 !! options
26818 parsoid=html2wt
26819 !! html/parsoid
26820 <span typeof="mw:Entity">&nbsp;</span>
26821 !! wikitext
26822 &nbsp;
26823 !! end
26824
26825 ## Note that there is no wikitext output for 'unknownproperty' ##
26826 ## Unknown magic words are silently dropped ##
26827
26828 !! test
26829 Magic words
26830 !! options
26831 parsoid=html2wt
26832 !! html/parsoid
26833 <meta property='mw:PageProp/toc' />
26834 <meta property='mw:PageProp/notoc' />
26835 <meta property='mw:PageProp/forcetoc' />
26836 <meta property='mw:PageProp/index' />
26837 <meta property='mw:PageProp/noindex' />
26838 <meta property='mw:PageProp/nogallery' />
26839 <meta property='mw:PageProp/noeditsection' />
26840 <meta property='mw:PageProp/notitleconvert' />
26841 <meta property='mw:PageProp/nocontentconvert' />
26842 <meta property='mw:PageProp/unknownproperty' />
26843 !! wikitext
26844 __TOC__
26845 __NOTOC__
26846 __FORCETOC__
26847 __INDEX__
26848 __NOINDEX__
26849 __NOGALLERY__
26850 __NOEDITSECTION__
26851 __NOTITLECONVERT__
26852 __NOCONTENTCONVERT__
26853 !! end
26854
26855 !! test
26856 Consecutive <pre>s should not get merged
26857 !! options
26858 parsoid=html2wt,html2html
26859 !! html/parsoid
26860 <pre>a</pre><pre>b</pre>
26861
26862 <pre>c
26863 </pre><pre>
26864 d</pre>
26865
26866 <pre>e
26867
26868 </pre><pre>
26869
26870 f</pre>
26871 !! wikitext
26872 a
26873
26874 b
26875
26876 c
26877
26878 d
26879
26880 e
26881
26882
26883
26884 f
26885 !! end
26886
26887 !! test
26888 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
26889 !! options
26890 parsoid=html2wt
26891 !! html/parsoid
26892 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
26893 !! wikitext
26894 [[Special:BookSources/1234567890|ISBN 1234567895]]
26895 !! end
26896
26897 !! test
26898 Edited RFC links not serializable as RFC links should serialize as extlinks
26899 !! options
26900 parsoid=html2wt
26901 !! html/parsoid
26902 <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
26903 !! wikitext
26904 [//tools.ietf.org/html/rfc123 New RFC]
26905 !! end
26906
26907 !! test
26908 Edited PMID links not serializable as PMID links should serialize as extlinks
26909 !! options
26910 parsoid=html2wt
26911 !! html/parsoid
26912 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
26913 !! wikitext
26914 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
26915 !! end
26916
26917 !! test
26918 WTS of autolinks with trailing/surrounding context
26919 !! options
26920 parsoid=html2wt
26921 !! html/parsoid
26922 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
26923 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
26924 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
26925 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
26926 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
26927 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
26928 !! wikitext
26929 http://cscott.net'''foo'''
26930
26931 http://cscott.net<b>foo</b>
26932
26933 '''http://cscott.net'''
26934
26935 '''http://cscott.net '''
26936
26937 '''http://cscott.net<nowiki/>x'''
26938
26939 http://cscott.net<nowiki/>x
26940 !! end
26941
26942 !! test
26943 WTS of autolinks with nowikis (round-trip)
26944 !! wikitext
26945 x<nowiki/>http://cscott.net<nowiki/>x
26946 !! html/parsoid
26947 <p>x<a rel="mw:ExtLink" href="http://cscott.net">http://cscott.net</a>x</p>
26948 !! end
26949
26950 # this is the "easy" test because it leaves in place all the
26951 # data-parsoid information indicating this is an autolink
26952 !! test
26953 WTS of autolinks with escapes (editing)
26954 !! options
26955 parsoid={
26956 "modes": ["wt2wt"],
26957 "changes": [
26958 [ "span", "remove" ]
26959 ]
26960 }
26961 !! wikitext
26962 x<nowiki/>http://cscott.net<nowiki/>x
26963 !! wikitext/edited
26964 x<nowiki/>http://cscott.net<nowiki/>x
26965 !! end
26966
26967 !! test
26968 WTS of edited autolink-like text (T103364)
26969 !! options
26970 parsoid={
26971 "modes": ["wt2wt"],
26972 "changes": [
26973 [ "span[typeof]", "removeAttr", "typeof" ]
26974 ]
26975 }
26976 !! wikitext
26977 Not a link: <nowiki>http://example.com</nowiki>.
26978 !! wikitext/edited
26979 Not a link: <span><nowiki>http://example.com</nowiki></span>.
26980 !! end
26981
26982 !! test
26983 WTS of newly-authored autolink-like text (T103364)
26984 !! options
26985 parsoid=html2wt
26986 !! html/parsoid
26987 <p>http://example.com is not a link.</p>
26988 !! wikitext
26989 <nowiki>http://example.com</nowiki> is not a link.
26990 !! end
26991
26992 !! test
26993 WTS of autolink-like text after an autolink (T108563)
26994 !! options
26995 parsoid=html2wt
26996 !! html/parsoid
26997 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
26998 !! wikitext
26999 http://example.com <nowiki>http://example.com</nowiki> is not a link.
27000 !! end
27001
27002 !! test
27003 Magic links inside links (not autolinked)
27004 !! wikitext
27005 [[Foo|http://example.com]]
27006 [[Foo|RFC 1234]]
27007 [[Foo|PMID 1234]]
27008 [[Foo|ISBN 123456789x]]
27009
27010 [http://foo.com http://example.com]
27011 [http://foo.com RFC 1234]
27012 [http://foo.com PMID 1234]
27013 [http://foo.com ISBN 123456789x]
27014 !! html+tidy
27015 <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>
27016 <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>
27017 !! html/parsoid
27018 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
27019 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
27020 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
27021 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
27022
27023 <p><a rel="mw:ExtLink" href="http://foo.com">http://example.com</a>
27024 <a rel="mw:ExtLink" href="http://foo.com">RFC 1234</a>
27025 <a rel="mw:ExtLink" href="http://foo.com">PMID 1234</a>
27026 <a rel="mw:ExtLink" href="http://foo.com">ISBN 123456789x</a></p>
27027 !! end
27028
27029 !! test
27030 Magic links inside image captions (autolinked)
27031 !! wikitext
27032 [[File:Foobar.jpg|thumb|http://example.com]]
27033 [[File:Foobar.jpg|thumb|RFC 1234]]
27034 [[File:Foobar.jpg|thumb|PMID 1234]]
27035 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
27036 !! html+tidy
27037 <div class="thumb tright">
27038 <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>
27039 <div class="thumbcaption">
27040 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
27041 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div>
27042 </div>
27043 </div>
27044 <div class="thumb tright">
27045 <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>
27046 <div class="thumbcaption">
27047 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
27048 <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a></div>
27049 </div>
27050 </div>
27051 <div class="thumb tright">
27052 <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>
27053 <div class="thumbcaption">
27054 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
27055 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a></div>
27056 </div>
27057 </div>
27058 <div class="thumb tright">
27059 <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>
27060 <div class="thumbcaption">
27061 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
27062 <a href="/wiki/Special:BookSources/123456789X" class="internal mw-magiclink-isbn">ISBN 123456789x</a></div>
27063 </div>
27064 </div>
27065 !! html/parsoid
27066 <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>
27067 <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>
27068 <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>
27069 <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>
27070 !! end
27071
27072 !! test
27073 WTS of magic word text (T109371)
27074 !! options
27075 parsoid=html2wt
27076 !! html/parsoid
27077 <p>RFC 1234</p>
27078 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
27079 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
27080 !! wikitext
27081 <nowiki>RFC 1234</nowiki>
27082
27083 [http://foo.com RFC 1234]
27084
27085 [[Foo|RFC 1234]]
27086 !! end
27087
27088 !! test
27089 Edited Redirect link should emit a non-piped wikitext link
27090 !! options
27091 parsoid=html2wt
27092 !! html/parsoid
27093 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
27094 !! wikitext
27095 #REDIRECT [[Bar]]
27096 !! end
27097
27098 !! test
27099 T75121: Infer extension name from typeOf if data-mw is not present
27100 !! options
27101 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
27102 !! html/parsoid
27103 <div typeOf="mw:Extension/foo"></div>
27104 !! wikitext
27105 <foo />
27106 !! end
27107
27108 # Note that the <p> wrapping isn't present in PHP parser output
27109 # The important thing for this test is that P-wrapping doesn't
27110 # interfere with the <nowiki> protection for leading - in <td>
27111 # (which isn't necessary for <th>).
27112 !! test
27113 T88318: p-wrapped dash in table.
27114 !! options
27115 parsoid=html2wt,wt2wt
27116 !! html/parsoid
27117 <table><tbody>
27118 <tr><th><p>-</p></th><th><p>- </p></th></tr>
27119 <tr><td><p>-</p></td><td><p>- </p></td></tr>
27120 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
27121 </tbody></table>
27122 !! wikitext
27123 {|
27124 !-
27125 !-
27126 |-
27127 |<nowiki>-</nowiki>
27128 |<nowiki>- </nowiki>
27129 |-
27130 |<small>-</small>
27131 |<br>
27132 -
27133 |<br>
27134 -
27135 |}
27136 !! html/php+tidy
27137 <table>
27138 <tr>
27139 <th>-</th>
27140 <th>-</th>
27141 </tr>
27142 <tr>
27143 <td>-</td>
27144 <td>-</td>
27145 </tr>
27146 <tr>
27147 <td><small>-</small></td>
27148 <td><br />
27149 <p>-</p>
27150 </td>
27151 <td><br />
27152 <p>-</p>
27153 </td>
27154 </tr>
27155 </table>
27156 !! end
27157
27158 !! test
27159 T149209: WTS: Handle newlines in table cells properly
27160 !! options
27161 parsoid=html2wt
27162 !! html/parsoid
27163 <table>
27164 <tbody>
27165 <tr><td>a
27166 b
27167 </td><td data-parsoid='{"stx_v":"row"}'>c</td></tr>
27168 <tr><td><p>x</p>
27169 </td><td data-parsoid='{"stx_v":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
27170 </tbody></table>
27171 <table>
27172 <tbody>
27173 <tr><th>a
27174 b
27175 </th><th data-parsoid='{"stx_v":"row"}'>c</th></tr>
27176 <tr><th><p>x</h>
27177 </th><th data-parsoid='{"stx_v":"row"}'>y</th></tr>
27178 </tbody></table>
27179 !! wikitext
27180 {|
27181 |a
27182 b
27183 |c
27184 |-
27185 |x
27186 {{!}}y
27187 |}
27188 {|
27189 !a
27190 b
27191 !c
27192 |-
27193 !x
27194 !y
27195 |}
27196 !! end
27197
27198 !! test
27199 T149209: Selser: Handle newlines in table cells properly
27200 !! options
27201 parsoid={
27202 "modes": ["selser"],
27203 "changes": [
27204 [ "#h1", "html", "a\nb\n" ],
27205 [ "#h2", "html", "a\nb\n" ],
27206 [ "#c1", "html", "a\nb\n" ],
27207 [ "#c2", "html", "<p>a</p>" ],
27208 [ "#c3", "html", "<p>a</p>" ],
27209 [ "#c4", "html", "edit-me<p>a</p>" ]
27210 ]
27211 }
27212 !! wikitext
27213 {|
27214 ! id="h1" |edit-me!!1
27215 |-
27216 ! id="h2" |edit-me||2
27217 |-
27218 | id="c1" |edit-me||3
27219 |-
27220 | id="c2" |edit-me||4
27221 |-
27222 | id="c3" |edit-me||p||q||r
27223 |-
27224 | id="c4" |edit-me||p||q||r
27225 |}
27226 !! wikitext/edited
27227 {|
27228 ! id="h1" |a
27229 b
27230 !1
27231 |-
27232 ! id="h2" |a
27233 b
27234 !2
27235 |-
27236 | id="c1" |a
27237 b
27238 |3
27239 |-
27240 | id="c2" |a
27241 |4
27242 |-
27243 | id="c3" |a
27244 |p||q||r
27245 |-
27246 | id="c4" |edit-me
27247 a
27248 |p||q||r
27249 |}
27250 !! end
27251
27252 !! test
27253 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
27254 !! options
27255 parsoid=html2wt
27256 !! html/parsoid
27257 <table id='mwAb'>
27258 <td id='mwAc'>foo</td>
27259 <td id='serialize-this'>bar</td>
27260 </table>
27261 !! wikitext
27262 {|
27263 |foo
27264 | id="serialize-this" |bar
27265 |}
27266 !! end
27267
27268 !! test
27269 Parsoid-like element ids should not be serialized to wikitext unless shadowed
27270 !! options
27271 parsoid=html2wt
27272 !! html/parsoid
27273 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
27274 !! wikitext
27275 <div id="hello">ok</div>
27276 !! end
27277
27278 !! test
27279 WTS change modes
27280 !! options
27281 parsoid={
27282 "modes": ["wt2wt"],
27283 "changes": [
27284 [ "#xyz", "before", "<b>before</b> stuff " ],
27285 [ "#xyz", "after", " stuff <i>after</i>" ],
27286 [ "#xyz", "html", "x <b>y</b> z" ]
27287 ]
27288 }
27289 !! wikitext
27290 <span id="xyz">hello</span>
27291 !! wikitext/edited
27292 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
27293 !! end
27294
27295 !! test
27296 Never serialize a-tag as html, regardless of what data-parsoid has to say
27297 !! options
27298 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
27299 !! html/parsoid
27300 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
27301 !! wikitext
27302 [[Foo]]
27303 !! end
27304
27305 ## SSS FIXME: This is broken output nevertheless.
27306 ## What might be a reasonable non-broken output for this?
27307 ## This is an edge case unlikely to be seen in production
27308 ## that I am not wasting more time on this right now.
27309 !! test
27310 Never serialize a-tag as html, no matter what attributes it has
27311 !! options
27312 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
27313 !! html/parsoid
27314 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
27315 !! wikitext
27316 [http://boo.org http://boohoo.org]
27317 !! end
27318
27319 # Misnested is an indication that selser can reuse the source but these have
27320 # shown to sneak through on occasion. See T101768.
27321 # The original wikitext here is: [http://test.com [[one]] two three]
27322 !! test
27323 Strip span tags added to mark misnested links
27324 !! options
27325 parsoid=html2wt
27326 !! html/parsoid
27327 <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>
27328 !! wikitext
27329 [http://test.com][[one]] two three
27330 !! end
27331
27332 !! test
27333 Catch regression when unpacking misnested links
27334 !! options
27335 parsoid=wt2html
27336 !! wikitext
27337 {{echo|hi}}[http://example.com [[ho]]]
27338 !! html/parsoid
27339 <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>
27340 !! end
27341
27342 !! test
27343 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
27344 !! options
27345 parsoid=html2wt
27346 !! html/parsoid
27347 <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|}"]}'>
27348 <tbody><tr><td>d
27349 </td></tr>
27350 </tbody></table>
27351 !! wikitext
27352 {{echo|a}}
27353 {|{{echo|c
27354 {{!}}d
27355 }}
27356 |}
27357 !! end
27358
27359 ## This test verifies the presence and computation of this attribute indirectly
27360 ## by making an edit and ensuring that the serialization is correct (which it would be
27361 ## only if firstWikitextNode is properly set).
27362 !! test
27363 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
27364 !! options
27365 parsoid= {
27366 "modes": ["wt2wt"],
27367 "changes": [
27368 [ "div#x", "remove" ],
27369 [ "div", "before", "<div>new</div>" ]
27370 ]
27371 }
27372 !! wikitext
27373 <div id="x">foo</div>
27374 {|
27375 {{echo|<div>boo</div>
27376 {{!}}b}}
27377 |c
27378 |}
27379 !! wikitext/edited
27380
27381 <div>new</div>
27382 {|
27383 {{echo|<div>boo</div>
27384 {{!}}b}}
27385 |c
27386 |}
27387 !! end
27388
27389 # --------------------------------------------
27390 # Tests spec'ing wikitext serialization norms |
27391 # --------------------------------------------
27392
27393 !! test
27394 Serialize multi-line indent-pre starting with wikitext syntax
27395 !! options
27396 parsoid=html2wt
27397 !! html/parsoid
27398 <pre>* 1
27399 ** 2
27400 * 3</pre>
27401 !! wikitext
27402 * 1
27403 ** 2
27404 * 3
27405 !! end
27406
27407 !! test
27408 1. Categories should always be serialized on their own line
27409 !! options
27410 parsoid=html2wt
27411 !! html/parsoid
27412 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
27413 !! wikitext
27414 foo
27415 [[Category:Foo]]
27416 bar
27417 !! end
27418
27419 !! test
27420 2. Categories that are part of templates should not introduce a line break
27421 !! wikitext
27422 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
27423 !! html/parsoid
27424 <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>
27425 !! end
27426
27427 # Careful while editing these next 2 tests. There are \u200f characters
27428 # before and after the <link> tags in the HTML and following some
27429 # of the categories in wikitext
27430 # Do not remove these characters in edits.
27431 #
27432 # As part of the serialization, these bidi characters will get stripped.
27433 !! test
27434 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
27435 !! options
27436 parsoid={
27437 "modes": ["html2wt"],
27438 "scrubWikitext": true
27439 }
27440 !! html/parsoid
27441 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
27442 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
27443 !! wikitext
27444 [[קטגוריה:טקסים]]
27445 [[קטגוריה: שיטות משפט]]
27446 !! end
27447
27448 !! test
27449 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
27450 !! options
27451 parsoid={
27452 "modes": ["html2wt"],
27453 "scrubWikitext": true
27454 }
27455 !! html/parsoid
27456 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
27457 !! wikitext
27458 [[קטגוריה:טקסים]]
27459 ‏y
27460 !! end
27461
27462 !! test
27463 Lists: Add space after bullets
27464 !! options
27465 parsoid=html2wt
27466 !! html/parsoid
27467 <ul>
27468 <li>foo</li>
27469 <li> bar</li>
27470 <li><span> baz</span></li>
27471 </ul>
27472 !! wikitext
27473 * foo
27474 * bar
27475 * <span> baz</span>
27476 !! end
27477
27478 !! test
27479 1. Headings: Add space before/after == (T53744)
27480 !! options
27481 parsoid=html2wt
27482 !! html/parsoid
27483 <h2>foo</h2>
27484 <h2> bar</h2>
27485 <h2>baz </h2>
27486 <h2><span> baz</span></h2>
27487 !! wikitext
27488 == foo ==
27489
27490 == bar ==
27491
27492 == baz ==
27493
27494 == <span> baz</span> ==
27495 !! end
27496
27497 !! test
27498 2. Headings: Add space before/after == even after hoisted content
27499 !! options
27500 parsoid={
27501 "modes": ["html2wt"],
27502 "scrubWikitext": true
27503 }
27504 !! html/parsoid
27505 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
27506 !! wikitext
27507 [[Category:A2]]
27508
27509 == ok ==
27510 !! end
27511
27512 !! test
27513 1. Headings: suppress newly created empty headings
27514 !! options
27515 parsoid={
27516 "modes": ["html2wt"],
27517 "scrubWikitext": true
27518 }
27519 !! html/parsoid
27520 <h2></h2>
27521 !! wikitext
27522 !! end
27523
27524 !! test
27525 2. Headings: don't suppress empty headings if scrubWikitext is false
27526 !! options
27527 parsoid=html2wt
27528 !! html/parsoid
27529 <h2></h2>
27530 !! wikitext
27531 ==<nowiki/>==
27532 !! end
27533
27534 !! test
27535 3. Headings: suppress empty headings on edits
27536 !! options
27537 parsoid={
27538 "modes": ["selser"],
27539 "scrubWikitext": true,
27540 "changes": [
27541 [ "#x", "remove"]
27542 ]
27543 }
27544 !! wikitext
27545 ==<span id="x">foo</span>==
27546 !! wikitext/edited
27547 !! end
27548
27549 !! test
27550 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
27551 !! options
27552 parsoid={
27553 "modes": ["html2wt"],
27554 "scrubWikitext": true
27555 }
27556 !! html/parsoid
27557 <h2>foo<br/>bar</h2>
27558 <h2>foo <span><br/>bar</span> baz</h2>
27559 !! wikitext
27560 == foo bar ==
27561
27562 == foo <span> bar</span> baz ==
27563 !! end
27564
27565 !! test
27566 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
27567 !! options
27568 parsoid={
27569 "modes": ["html2wt"],
27570 "scrubWikitext": false
27571 }
27572 !! html/parsoid
27573 <h2>foo<br/>bar</h2>
27574 !! wikitext
27575 == foo<br> bar ==
27576 !! end
27577
27578 !! test
27579 1. WT Quote Tags: suppress newly created empty style tags
27580 !! options
27581 parsoid={
27582 "modes": ["html2wt"],
27583 "scrubWikitext": true
27584 }
27585 !! html/parsoid
27586 <i></i><b></b>
27587 !! wikitext
27588 !! end
27589
27590 !! test
27591 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
27592 !! options
27593 parsoid=html2wt
27594 !! html/parsoid
27595 <i></i><b></b>
27596 !! wikitext
27597 ''<nowiki/>'''''<nowiki/>'''
27598 !! end
27599
27600 !! test
27601 3. WT Quote Tags: suppress empty style tags on edits
27602 !! options
27603 parsoid={
27604 "modes": ["selser"],
27605 "scrubWikitext": true,
27606 "changes": [
27607 [ "#x", "remove"]
27608 ]
27609 }
27610 !! wikitext
27611 '''<span id="x">foo</span>'''
27612 !! wikitext/edited
27613 !! end
27614
27615 !! test
27616 1. Anchors: suppress newly created empty anchors
27617 !! options
27618 parsoid={
27619 "modes": ["html2wt"],
27620 "scrubWikitext": true
27621 }
27622 !! html/parsoid
27623 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
27624 !! wikitext
27625 !! end
27626
27627 !! test
27628 2. Anchors: don't suppress empty anchors if scrubWikitext is false
27629 !! options
27630 parsoid={
27631 "modes": ["html2wt"],
27632 "scrubWikitext": false
27633 }
27634 !! html/parsoid
27635 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
27636 !! wikitext
27637 [[Test|<nowiki/>]]
27638 !! end
27639
27640 !! test
27641 3. Anchors: suppress empty anchors on edits
27642 !! options
27643 parsoid={
27644 "modes": ["selser"],
27645 "scrubWikitext": true,
27646 "changes": [
27647 [ "#x", "remove"]
27648 ]
27649 }
27650 !! wikitext
27651 [[Test|<span id="x">foo</span>]]
27652 !! wikitext/edited
27653 !! end
27654
27655 !! test
27656 3a. Anchors: do not suppress numbered extlinks
27657 !! options
27658 parsoid={
27659 "modes": ["wt2wt"],
27660 "scrubWikitext": true
27661 }
27662 !! wikitext
27663 [http://foo.com]
27664 !! html/parsoid
27665 <a rel="mw:ExtLink" href="http://foo.com"></a>
27666 !! end
27667
27668 !! test
27669 3b. Anchors: do not suppress numbered extlinks
27670 !! options
27671 parsoid={
27672 "modes": ["wt2wt"],
27673 "scrubWikitext": true,
27674 "changes": [
27675 [ "#x", "remove"]
27676 ]
27677 }
27678 !! wikitext
27679 [http://foo.com <span id="x">foo</span>]
27680 !! wikitext/edited
27681 [http://foo.com]
27682 !! end
27683
27684 !!test
27685 Normalizations should be restricted to edited content
27686 !!options
27687 parsoid={
27688 "modes": ["selser"],
27689 "scrubWikitext": true,
27690 "changes": [
27691 [ "h1", "before", "<i></i>"]
27692 ]
27693 }
27694 !!wikitext
27695 a
27696 = =
27697 b
27698 !!wikitext/edited
27699 a
27700 = =
27701 b
27702 !!end
27703
27704 !! test
27705 1. Multiple normalizations (html2wt)
27706 !! options
27707 parsoid={
27708 "modes": ["html2wt"],
27709 "scrubWikitext": true
27710 }
27711 !! html
27712 <h2><i></i></h2>
27713 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
27714 </a><b><i></i></b>x</p>
27715 !! wikitext
27716
27717 [[foo]]
27718 x
27719
27720 !! end
27721
27722 !! test
27723 2. Multiple normalizations (selser)
27724 !! options
27725 parsoid={
27726 "modes": ["selser"],
27727 "scrubWikitext": true,
27728 "changes": [
27729 [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
27730 ]
27731 }
27732 !! wikitext
27733 <span id="x">foo</span>
27734 !! wikitext/edited
27735 <span id="x">foo</span>
27736
27737 x
27738 !! end
27739
27740 !! test
27741 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
27742 !! options
27743 parsoid={
27744 "modes": ["html2wt"],
27745 "scrubWikitext": true
27746 }
27747 !! html/parsoid
27748 <p> hi</p>
27749 <p> hello</p>
27750 !! wikitext
27751 hi
27752
27753 hello
27754 !! end
27755
27756 !! test
27757 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
27758 !! options
27759 parsoid=html2wt
27760 !! html/parsoid
27761 <p> hi</p>
27762 <p> hello</p>
27763 !! wikitext
27764 <nowiki> </nowiki>hi
27765
27766 <nowiki> </nowiki> hello
27767 !! end
27768
27769 !! test
27770 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
27771 !! options
27772 parsoid={
27773 "modes": ["html2wt"],
27774 "scrubWikitext": true
27775 }
27776 !! html/parsoid
27777 <p>Foo
27778 bar
27779 baz</p>
27780
27781 <table><tr><td>Foo
27782 bar
27783 baz bang</td></tr></table>
27784
27785 <p><!--boo--> foo
27786 bar</p>
27787
27788 <p> foo
27789 bar<span>boo</span></p>
27790 !! wikitext
27791 Foo
27792 bar
27793 baz
27794
27795 {|
27796 |Foo
27797 bar
27798 baz bang
27799 |}
27800
27801 <!--boo-->foo
27802 bar
27803
27804 foo
27805 bar<span>boo</span>
27806 !! end
27807
27808 !! test
27809 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
27810 !! options
27811 parsoid={
27812 "modes": ["selser"],
27813 "scrubWikitext": true,
27814 "changes": [
27815 [ "p", "html", " a\n b" ]
27816 ]
27817 }
27818 !! wikitext
27819 xyz
27820 !! wikitext/edited
27821 a
27822 b
27823 !! end
27824
27825 !! test
27826 1. New links that end in spaces
27827 !! options
27828 parsoid={
27829 "modes": ["html2wt"],
27830 "scrubWikitext": false
27831 }
27832 !! html/parsoid
27833 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
27834 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
27835 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
27836 !! wikitext
27837 [[Berlin ]]<nowiki/>is the capital of Germany.
27838
27839 [[Foo ]]'''bar'''
27840
27841 [[Boston ]] is a city.
27842 !! end
27843
27844 !! test
27845 2. New links that end in spaces
27846 !! options
27847 parsoid={
27848 "modes": ["html2wt"],
27849 "scrubWikitext": true
27850 }
27851 !! html/parsoid
27852 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
27853 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
27854 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
27855 !! wikitext
27856 [[Berlin]] is the capital of Germany.
27857
27858 [[Foo]] '''bar'''
27859
27860 [[Boston]] is a city.
27861 !! end
27862
27863 !! test
27864 1. Table cells with escapable prefixes
27865 !! options
27866 parsoid={
27867 "modes": ["html2wt"],
27868 "scrubWikitext": false
27869 }
27870 !! html
27871 <table>
27872 <tr><td>a</td></tr>
27873 <tr><td>-</td></tr>
27874 <tr><td>+</td></tr>
27875 </table>
27876 !! wikitext
27877 {|
27878 |a
27879 |-
27880 |<nowiki>-</nowiki>
27881 |-
27882 |<nowiki>+</nowiki>
27883 |}
27884 !! end
27885
27886 !! test
27887 2. Table cells with escapable prefixes
27888 !! options
27889 parsoid={
27890 "modes": ["html2wt"],
27891 "scrubWikitext": true
27892 }
27893 !! html
27894 <table>
27895 <tr><td>a</td></tr>
27896 <tr><td>-</td></tr>
27897 <tr><td>+</td></tr>
27898 </table>
27899 !! wikitext
27900 {|
27901 |a
27902 |-
27903 | -
27904 |-
27905 | +
27906 |}
27907 !! end
27908
27909 !! test
27910 3a. Table cells with escapable prefixes after edits
27911 !! options
27912 parsoid={
27913 "modes": ["selser"],
27914 "scrubWikitext": true,
27915 "changes": [
27916 [ "table tbody tr:first-child td:first-child", "remove"]
27917 ]
27918 }
27919 !! wikitext
27920 {|
27921 |a||-
27922 |}
27923 !! wikitext/edited
27924 {|
27925 | -
27926 |}
27927 !! end
27928
27929 !! test
27930 3b. Table cells with escapable prefixes after edits
27931 !! options
27932 parsoid={
27933 "modes": ["selser"],
27934 "scrubWikitext": true,
27935 "changes": [
27936 [ "table tbody tr:first-child td:first-child", "html", "-" ],
27937 [ "#x", "remove" ]
27938 ]
27939 }
27940 !! wikitext
27941 {|
27942 |pqr
27943 |<span id="x">foo</span>+
27944 |}
27945 !! wikitext/edited
27946 {|
27947 | -
27948 | +
27949 |}
27950 !! end
27951
27952 # FIXME: This test will fail because
27953 # normalization doesn't realize that the id attribute
27954 # will eliminate the escapable scenario
27955 !! test
27956 4a. Table cells without escapable prefixes after edits
27957 !! options
27958 parsoid={
27959 "modes": ["selser"],
27960 "scrubWikitext": true,
27961 "changes": [
27962 [ "#x", "html", "-" ]
27963 ]
27964 }
27965 !! wikitext
27966 {|
27967 | id="x" |abcd
27968 |}
27969 !! wikitext/edited
27970 {|
27971 | id="x" |-
27972 |}
27973 !! end
27974
27975 ## This tests normalizer's ability to discriminate between
27976 ## cells having identical content.
27977 !! test
27978 4b. Table cells without escapable prefixes after edits
27979 !! options
27980 parsoid={
27981 "modes": ["selser"],
27982 "scrubWikitext": true,
27983 "changes": [
27984 [ "td", "html", "-" ]
27985 ]
27986 }
27987 !! wikitext
27988 {|
27989 |a||b
27990 |}
27991 !! wikitext/edited
27992 {|
27993 | -||-
27994 |}
27995 !! end
27996
27997 ## This tests normalizer's ability to not be tripped by
27998 ## comments (and whitespace)
27999 !! test
28000 4c. Table cells without escapable prefixes after edits
28001 !! options
28002 parsoid={
28003 "modes": ["selser"],
28004 "scrubWikitext": true,
28005 "changes": [
28006 [ "table tbody tr td:first-child", "remove" ]
28007 ]
28008 }
28009 !! wikitext
28010 {|
28011 |-
28012 <!--foo--> |a||-
28013 |}
28014 !! wikitext/edited
28015 {|
28016 |-
28017 <!--foo--> | -
28018 |}
28019 !! end
28020
28021 ## This tests normalizer's ability to handle HTML cells
28022 !! test
28023 4d. Table cells without escapable prefixes after edits
28024 !! options
28025 parsoid={
28026 "modes": ["selser"],
28027 "scrubWikitext": true,
28028 "changes": [
28029 [ "td", "html", "-" ]
28030 ]
28031 }
28032 !! wikitext
28033 <table>
28034 <tr><td>a</td></tr>
28035 </table>
28036 !! wikitext/edited
28037 <table>
28038 <tr><td>-</td></tr>
28039 </table>
28040 !! end
28041
28042 ## T111151 Remove font elements without attributes
28043 !! test
28044 5a. font tags without attributes should be dropped in scrubWikitext mode
28045 !! options
28046 parsoid={
28047 "modes": ["html2wt"],
28048 "scrubWikitext": true
28049 }
28050 !! html
28051 <font>foo</font>
28052 <font><font>bar</font></font>
28053 <font class="x">boo</font>
28054 !! wikitext
28055 foo
28056 bar
28057 <font class="x">boo</font>
28058 !! end
28059
28060 !! test
28061 5b. font tags should not be dropped without scrubWikitext being enabled
28062 !! options
28063 parsoid={
28064 "modes": ["html2wt"],
28065 "scrubWikitext": false
28066 }
28067 !! html
28068 <font>foo</font>
28069 !! wikitext
28070 <font>foo</font>
28071 !! end
28072
28073 !! test
28074 Escape nowiki DOM elements
28075 !! options
28076 parsoid=html2wt
28077 !! html/parsoid
28078 <nowiki><i>foo</i></nowiki>
28079 !! wikitext
28080 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
28081 !! end
28082
28083 # This is meant to be an interim fix while we go about figuring out
28084 # how to not introduce these trailing <nowiki/>s in the first place.
28085 !! test
28086 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
28087 !! options
28088 parsoid=html2wt
28089 !! html/parsoid
28090 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
28091 y</p>
28092 <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>
28093 <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>
28094 !! wikitext
28095 x
28096 y
28097
28098 {{echo|
28099 1 = <nowiki/>}}
28100
28101 {{echo|
28102 1 = <nowiki/>
28103 }}
28104 !! end
28105
28106 # ---------------------------------------------------
28107 # End of tests spec'ing wikitext serialization norms |
28108 # ---------------------------------------------------
28109
28110 # T104032
28111 !! test
28112 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
28113 !! options
28114 parsoid=html2wt
28115 !! html/parsoid
28116 a<p>b</p>
28117 <b>c</b><p>d</p>
28118 <table><tr>
28119 <td>a<p>b</p></td>
28120 <td><b>c</b><p>d</p></td>
28121 </tr></table>
28122 !! wikitext
28123 a
28124
28125 b
28126
28127 '''c'''
28128
28129 d
28130 {|
28131 |a
28132 b
28133 |'''c'''
28134 d
28135 |}
28136 !! end
28137
28138 !! test
28139 Anchor without href scenarios
28140 !! options
28141 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28142 !! html/parsoid
28143 <a class="bc"></a>
28144 <a class="no">dice</a>
28145 <a name="foo"></a>
28146 !! wikitext
28147
28148 dice
28149 <span name="foo"></span>
28150 !! end
28151
28152 !! test
28153 New transclusion added after a list should be serialized after the list
28154 !! options
28155 parsoid=html2wt
28156 !! html/parsoid
28157 <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>
28158 !! wikitext
28159 * a
28160 {{echo|foo}}
28161 !! end
28162
28163 # -----------------------------------------------------------------
28164 # End of section for Parsoid-only html2wt tests for serialization
28165 # of new content
28166 # -----------------------------------------------------------------
28167
28168 # -----------------------------------------------------------------
28169 # The following section of tests are primarily to spec behavior of
28170 # the selective serializer. All these tests have manual selser
28171 # changes. The automated selser changes for all tests handle the
28172 # wide variation of changes, but these tests here capture specs
28173 # deterministically.
28174 # ----------------------------------------------------------------
28175
28176 ## T90517
28177 !! test
28178 Selser: New comments should not be lost
28179 !! options
28180 parsoid={
28181 "modes": ["selser"],
28182 "changes": [
28183 [ "#a", "after", "<!--c1-->" ],
28184 [ "#b", "before", "<!--c2-->" ]
28185 ]
28186 }
28187 !! wikitext
28188 <span id="a">a</span>
28189
28190 <span id="b">b</span>
28191 !! wikitext/edited
28192 <span id="a">a</span><!--c1-->
28193
28194 <!--c2--><span id="b">b</span>
28195 !! end
28196
28197 ## T89383
28198 !! test
28199 Selser: Check for validity of DSR before using it
28200 !! options
28201 parsoid={
28202 "modes": ["selser"],
28203 "changes": [
28204 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
28205 ]
28206 }
28207 !! wikitext
28208 <span id="a">a</span>
28209 !! wikitext/edited
28210 {{DISPLAYTITLE:foo}}
28211 <span id="a">a</span>
28212 !! end
28213
28214 !! test
28215 1. DOMDiff: Changes to <ref> content should be looked up using id
28216 !! options
28217 parsoid={
28218 "modes": ["selser"],
28219 "changes": [
28220 ["#X", "after", "bar"],
28221 ["#Y", "after", "baz"]
28222 ]
28223 }
28224 !! wikitext
28225 X <ref><span id="X">foo</span></ref>
28226 Y <ref name="a" />
28227 <references>
28228 <ref name="a"><span id="Y">foo</span></ref>
28229 </references>
28230 !! wikitext/edited
28231 X <ref><span id="X">foo</span>bar</ref>
28232 Y <ref name="a" />
28233 <references>
28234 <ref name="a"><span id="Y">foo</span>baz</ref>
28235 </references>
28236 !! end
28237
28238 !! test
28239 2. DOMDiff: Changes to <ref> content should be looked up using id
28240 !! options
28241 parsoid={
28242 "modes": ["selser"],
28243 "changes": [
28244 ["#Z", "after", "bar"]
28245 ]
28246 }
28247 !! wikitext
28248 A <ref>foo bar for a</ref>
28249 B <ref group="X" name="b" />
28250
28251 <references />
28252
28253 <references group="X">
28254 <ref name="b"><span id="Z">foo</span></ref>
28255 </references>
28256 !! wikitext/edited
28257 A <ref>foo bar for a</ref>
28258 B <ref group="X" name="b" />
28259
28260 <references />
28261
28262 <references group="X">
28263 <ref name="b"><span id="Z">foo</span>bar</ref>
28264 </references>
28265 !! end
28266
28267 !! test
28268 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
28269 !! options
28270 parsoid={
28271 "modes": ["selser"],
28272 "changes": [
28273 [ "div:first-child", "text", "bar" ]
28274 ]
28275 }
28276 !! wikitext
28277 <div style="{{1x|color:red;}}%">foo</div>
28278 !! wikitext/edited
28279 <div style="{{1x|color:red;}}%">bar</div>
28280 !! end
28281
28282 !! test
28283 Empty LI (T49673)
28284 !! wikitext
28285 * a
28286 *
28287 *
28288 * b
28289 !! html/php+tidy
28290 <ul>
28291 <li>a</li>
28292 <li class="mw-empty-elt"></li>
28293 <li class="mw-empty-elt"></li>
28294 <li>b</li>
28295 </ul>
28296 !! end
28297
28298 !! test
28299 Thumbnail output
28300 !! wikitext
28301 [[File:Thumb.png|thumb]]
28302 !! html/php+tidy
28303 <div class="thumb tright">
28304 <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>
28305 <div class="thumbcaption">
28306 <div class="magnify"><a href="/wiki/File:Thumb.png" class="internal" title="Enlarge"></a></div>
28307 </div>
28308 </div>
28309 </div>
28310 !! end
28311
28312 !! test
28313 unclosed internal link XSS (T137264)
28314 !! wikitext
28315 [[#%3Cscript%3Ealert(1)%3C/script%3E|
28316 !! html/php
28317 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
28318 </p>
28319 !! html/parsoid
28320 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
28321 !! end
28322
28323 !! test
28324 Validating that <style> isn't eaten by tidy (T167349)
28325 !! options
28326 # Use $wgRawHtml to inject a <style> tag, since you normally can't in wikitext
28327 wgRawHtml=1
28328 !! wikitext
28329 <div class="foo">
28330 <html><style>.foo::before { content: "<foo>"; }</style></html>
28331 <html><style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style></html>
28332 </div>
28333 !! html+tidy
28334 <div class="foo">
28335 <style>.foo::before { content: "<foo>"; }</style>
28336 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
28337 </div>
28338 !! end