Hide <style> tags from Tidy
[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 * <noinclude>~~~</noinclude>
13623 * <includeonly>~~~</includeonly>
13624 * <onlyinclude>~~~</onlyinclude>
13625 !! html/php
13626 * [[Special:Contributions/127.0.0.1|127.0.0.1]]
13627 * <noinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</noinclude>
13628 * <includeonly>[[Special:Contributions/127.0.0.1|127.0.0.1]]</includeonly>
13629 * <onlyinclude>[[Special:Contributions/127.0.0.1|127.0.0.1]]</onlyinclude>
13630 !! end
13631
13632
13633 !! test
13634 pre-save transform: Signature expansion in nowiki tags (T2093)
13635 !! options
13636 pst disabled
13637 !! wikitext
13638 Shall not expand:
13639
13640 <nowiki>~~~~</nowiki>
13641
13642 <includeonly><nowiki>~~~~</nowiki></includeonly>
13643
13644 <noinclude><nowiki>~~~~</nowiki></noinclude>
13645
13646 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13647
13648 {{subst:Foo}} shall be converted to FOO
13649
13650 As well as inside noinclude/onlyinclude
13651 <noinclude>{{subst:Foo}}</noinclude>
13652 <onlyinclude>{{subst:Foo}}</onlyinclude>
13653
13654 But not inside includeonly
13655 <includeonly>{{subst:Foo}}</includeonly>
13656 !! html/php
13657 Shall not expand:
13658
13659 <nowiki>~~~~</nowiki>
13660
13661 <includeonly><nowiki>~~~~</nowiki></includeonly>
13662
13663 <noinclude><nowiki>~~~~</nowiki></noinclude>
13664
13665 <onlyinclude><nowiki>~~~~</nowiki></onlyinclude>
13666
13667 FOO shall be converted to FOO
13668
13669 As well as inside noinclude/onlyinclude
13670 <noinclude>FOO</noinclude>
13671 <onlyinclude>FOO</onlyinclude>
13672
13673 But not inside includeonly
13674 <includeonly>{{subst:Foo}}</includeonly>
13675 !! end
13676
13677 !! test
13678 Parsoid: Recognize nowiki with trailing space in tags
13679 !! options
13680 parsoid=wt2html
13681 !! wikitext
13682 <nowiki ><div>[[foo]]</nowiki >
13683
13684 a<nowiki / >b
13685
13686 c<nowiki />d
13687
13688 e<nowiki/ >f
13689 !! html
13690 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
13691 <p>ab</p>
13692 <p>cd</p>
13693 <p>ef</p>
13694 !! end
13695
13696 !! test
13697 Parsoid: Recognize nowiki with odd capitalization
13698 !! options
13699 parsoid=wt2html
13700 !! wikitext
13701 <noWikI ><div>[[foo]]</Nowiki >
13702 !! html
13703 <p><span typeof="mw:Nowiki">&lt;div&gt;[[foo]]</span></p>
13704 !! end
13705
13706
13707 !! test
13708 Parsoid: Escape nowiki with trailing space in tags
13709 !! options
13710 parsoid=html2wt
13711 !! html/parsoid
13712 <p>&lt;nowiki &gt; foo &lt/nowiki ></p>
13713 <p>a&lt;nowiki /&gt;b</p>
13714 <p>c&lt;nowiki/ &gt;d</p>
13715 !! wikitext
13716 &lt;nowiki &gt; foo &lt;/nowiki &gt;
13717
13718 a&lt;nowiki /&gt;b
13719
13720 c&lt;nowiki/ &gt;d
13721 !! end
13722
13723 !! test
13724 Parsoid: Escape weird noWikI capitalizations
13725 !! options
13726 parsoid=html2wt
13727 !! html/parsoid
13728 <p>&lt;noWikI &gt; foo &lt/NoWikI ></p>
13729 !! wikitext
13730 &lt;noWikI &gt; foo &lt;/NoWikI &gt;
13731 !! end
13732
13733 ###
13734 ### Message transform tests
13735 ###
13736 !! test
13737 message transform: magic variables
13738 !! options
13739 msg
13740 !! wikitext
13741 {{SITENAME}}
13742 !! html
13743 MediaWiki
13744 !! end
13745
13746 !! test
13747 message transform: should not transform wiki markup
13748 !! options
13749 msg
13750 !! wikitext
13751 ''test''
13752 !! html
13753 ''test''
13754 !! end
13755
13756 !! test
13757 message transform: <noinclude> in transcluded template (T6926)
13758 !! options
13759 msg
13760 !! wikitext
13761 {{Includes}}
13762 !! html
13763 Foobar
13764 !! end
13765
13766 !! test
13767 message transform: <onlyinclude> in transcluded template (T6926)
13768 !! options
13769 msg
13770 !! wikitext
13771 {{Includes2}}
13772 !! html
13773 Foo
13774 !! end
13775
13776 !! test
13777 {{#special:}} page name, known
13778 !! options
13779 msg
13780 !! wikitext
13781 {{#special:Recentchanges}}
13782 !! html
13783 Special:RecentChanges
13784 !! end
13785
13786 !! test
13787 {{#special:}} page name with subpage, known
13788 !! options
13789 msg
13790 !! wikitext
13791 {{#special:Recentchanges/param}}
13792 !! html
13793 Special:RecentChanges/param
13794 !! end
13795
13796 !! test
13797 {{#special:}} page name, unknown
13798 !! options
13799 msg
13800 !! wikitext
13801 {{#special:foobar nonexistent}}
13802 !! html
13803 Special:Foobar nonexistent
13804 !! end
13805
13806 !! test
13807 {{#speciale:}} page name, known
13808 !! options
13809 msg
13810 !! wikitext
13811 {{#speciale:Recentchanges}}
13812 !! html
13813 Special:RecentChanges
13814 !! end
13815
13816 !! test
13817 {{#speciale:}} page name with subpage, known
13818 !! options
13819 msg
13820 !! wikitext
13821 {{#speciale:Recentchanges/param}}
13822 !! html
13823 Special:RecentChanges/param
13824 !! end
13825
13826 !! test
13827 {{#speciale:}} page name, unknown
13828 !! options
13829 msg
13830 !! wikitext
13831 {{#speciale:foobar nonexistent}}
13832 !! html
13833 Special:Foobar_nonexistent
13834 !! end
13835
13836 ###
13837 ### Images
13838 ###
13839 ### For Parsoid-specific tests, see
13840 #### https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
13841
13842 !! test
13843 Simple image
13844 !! options
13845 parsoid=wt2html,wt2wt,html2html
13846 !! wikitext
13847 [[Image:foobar.jpg]]
13848 !! html/php
13849 <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>
13850 </p>
13851 !! html/parsoid
13852 <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>
13853 !! end
13854
13855 !! test
13856 Simple image (using File: namespace, now canonical)
13857 !! wikitext
13858 [[File:Foobar.jpg]]
13859 !! html/php
13860 <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>
13861 </p>
13862 !! html/parsoid
13863 <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>
13864 !! end
13865
13866 !! test
13867 Right-aligned image
13868 !! wikitext
13869 [[File:Foobar.jpg|right]]
13870 !! html/php
13871 <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>
13872
13873 !! html/parsoid
13874 <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>
13875 !! end
13876
13877 !! test
13878 Image with caption
13879 !! wikitext
13880 [[File:Foobar.jpg|right|Caption text]]
13881 !! html/php
13882 <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>
13883
13884 !! html/parsoid
13885 <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>
13886 !! end
13887
13888 !! test
13889 Image with caption, T55312 #1
13890 !! wikitext
13891 [[File:Foobar.jpg|right|Caption page stuff]]
13892 !! html/php
13893 <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>
13894
13895 !! html/parsoid
13896 <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>
13897 !! end
13898
13899 !! test
13900 Image with caption, T55312 #2
13901 !! wikitext
13902 [[File:Foobar.jpg|right|Caption page=]]
13903 !! html/php
13904 <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>
13905
13906 !! html/parsoid
13907 <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>
13908 !! end
13909
13910 !! test
13911 Image with caption, T55312 #3
13912 !! wikitext
13913 [[File:Foobar.jpg|right|Caption page=stuff]]
13914 !! html/php
13915 <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>
13916
13917 !! html/parsoid
13918 <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>
13919 !! end
13920
13921 !! test
13922 Allow empty links in image captions (T62753)
13923 !! options
13924 thumbsize=220
13925 !! wikitext
13926 [[File:Foobar.jpg|thumb|Caption [[Link1]]
13927 [[]]
13928 [[Link2]]
13929 ]]
13930 !! html/php
13931 <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>
13932
13933 !! html/parsoid
13934 <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>
13935 [[]]
13936 <a rel="mw:WikiLink" href="./Link2" title="Link2" data-parsoid='{"stx":"simple","a":{"href":"./Link2"},"sa":{"href":"Link2"}}'>Link2</a>
13937 </figcaption></figure>
13938 !! end
13939
13940 !! test
13941 Titles in unlinked images (T23454)
13942 !! wikitext
13943 [[File:Foobar.jpg|link=|stuff]]
13944 !! html/php
13945 <p><img alt="stuff" src="http://example.com/images/3/3a/Foobar.jpg" title="stuff" width="1941" height="220" />
13946 </p>
13947 !! end
13948
13949 !! test
13950 Link with empty target
13951 !! wikitext
13952 [[]]
13953 !! html
13954 <p>[[]]
13955 </p>
13956 !! end
13957
13958 !! test
13959 Image with link trail
13960 !! wikitext
13961 Linktrails should not work for images: [[File:Foobar.jpg]]s
13962 !! html/php
13963 <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
13964 </p>
13965 !! html/parsoid
13966 <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>
13967 !! end
13968
13969 !! test
13970 Image with empty attribute
13971 !! options
13972 parsoid=wt2html,wt2wt,html2html
13973 !! wikitext
13974 [[File:Foobar.jpg|right||Caption text]]
13975 !! html/php
13976 <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>
13977
13978 !! html/parsoid
13979 <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>
13980 !! end
13981
13982 !! test
13983 1. Block image with individual attributes from templates
13984 !! wikitext
13985 [[File:Foobar.jpg|thumb|{{echo|137px}}|This is a caption]]
13986 !! html/php
13987 <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>
13988
13989 !! html/parsoid
13990 <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>
13991 !! end
13992
13993 !! test
13994 2. Block Image with individual attributes from templates
13995 !! wikitext
13996 [[File:Foobar.jpg|{{echo|thumb}}|{{echo|137px}}|This is a caption]]
13997 !! html/php
13998 <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>
13999
14000 !! html/parsoid
14001 <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>
14002 !! end
14003
14004 !! test
14005 3. Inline image with individual attributes from templates
14006 !! wikitext
14007 [[File:Foobar.jpg|{{echo|50px}}]]
14008 !! html/php
14009 <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>
14010 </p>
14011 !! html/parsoid
14012 <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>
14013 !! end
14014
14015 ## Parsoid does not provide editing support for images where templates produce multiple image attributes.
14016 ## To signal this, we add a 'mw:Placeholder' type to such images. This could change in the future.
14017 !! test
14018 Image with multiple attributes from the same template
14019 !! wikitext
14020 [[File:Foobar.jpg|{{image_attribs}}]]
14021 !! html/php
14022 <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>
14023
14024 !! html/parsoid
14025 <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>
14026 !! end
14027
14028 !! test
14029 Image with link tails
14030 !! options
14031 thumbsize=220
14032 !! wikitext
14033 123[[File:Foobar.jpg]]456
14034 123[[File:Foobar.jpg|right]]456
14035 123[[File:Foobar.jpg|thumb]]456
14036 !! html/php
14037 <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
14038 </p>
14039 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
14040 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
14041
14042 !! html/php+tidy
14043 <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>
14044 <p>123</p>
14045 <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>
14046 <p>456 123</p>
14047 <div class="thumb tright">
14048 <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>
14049 <div class="thumbcaption">
14050 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
14051 </div>
14052 </div>
14053 </div>
14054 <p>456</p>
14055 !! html/parsoid
14056 <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>
14057 <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>
14058 <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>
14059 !! end
14060
14061 !! test
14062 Image with multiple captions -- only last one is accepted
14063 !! wikitext
14064 [[File:Foobar.jpg|right|Caption1 - ignored|[[Caption2]] - ignored|Caption3 - accepted]]
14065 !! html/php
14066 <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>
14067
14068 !! html/parsoid
14069 <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>
14070 !! end
14071
14072 !! test
14073 Image with multiple widths -- use last
14074 !! wikitext
14075 [[File:Foobar.jpg|200px|300px|caption]]
14076 !! html/php
14077 <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>
14078 </p>
14079 !! html/parsoid
14080 <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>
14081 !! end
14082
14083 !! test
14084 Image with multiple alignments -- use first (T50664)
14085 !! options
14086 thumbsize=220
14087 !! wikitext
14088 [[File:Foobar.jpg|thumb|left|right|center|caption]]
14089
14090 [[File:Foobar.jpg|middle|text-top|caption]]
14091 !! html/php
14092 <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>
14093 <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>
14094 </p>
14095 !! html/parsoid
14096 <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>
14097 <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>
14098 !! end
14099
14100 !! test
14101 Image with width attribute at different positions
14102 !! wikitext
14103 [[File:Foobar.jpg|200px|right|Caption]]
14104 [[File:Foobar.jpg|right|200px|Caption]]
14105 [[File:Foobar.jpg|right|Caption|200px]]
14106 !! html/php
14107 <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>
14108 <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>
14109 <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>
14110
14111 !! html/parsoid
14112 <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>
14113 <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>
14114 <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>
14115 !! end
14116
14117 # a sad bit of backward-compatibility
14118 !! test
14119 Image with size specified with pxpx (T15500, T53628)
14120 !! options
14121 parsoid=wt2html,wt2wt,html2html
14122 !! wikitext
14123 [[File:Foobar.jpg|20pxpx]]
14124 [[File:Foobar.jpg|200x20pxpx]]
14125 !! html/php
14126 <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>
14127 <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>
14128 </p>
14129 !! html/parsoid
14130 <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>
14131 !! end
14132
14133 !! test
14134 Image with link parameter, wiki target
14135 !! wikitext
14136 [[File:Foobar.jpg|link=Main Page]]
14137 !! html/php
14138 <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>
14139 </p>
14140 !! html/parsoid
14141 <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>
14142 !! end
14143
14144 # parsoid T51293 (part 1)
14145 !! test
14146 Image with link parameter, URL target
14147 !! wikitext
14148 [[File:Foobar.jpg|link=http://example.com/]]
14149 !! html/php
14150 <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>
14151 </p>
14152 !! html/parsoid
14153 <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>
14154 !! end
14155
14156 # parsoid T51293 (part 2)
14157 !! test
14158 Image with link parameter, protocol-less URL target
14159 !! wikitext
14160 [[File:Foobar.jpg|link=//example.com/]]
14161 !! html/php
14162 <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>
14163 </p>
14164 !! html/parsoid
14165 <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>
14166 !! end
14167
14168 !! test
14169 Escaping non-block captions (T107435)
14170 !! options
14171 parsoid={
14172 "modes": ["wt2wt"],
14173 "changes": [
14174 ["[typeof~='mw:Image']", "attr", "data-mw", "{\"caption\": \"|\"}"]
14175 ]
14176 }
14177 !! wikitext
14178 [[Image:Foobar.jpg|caption]]
14179 !! wikitext/edited
14180 [[Image:Foobar.jpg|<nowiki>|</nowiki>]]
14181 !! end
14182
14183 # wgExternalLinkTarget not supported by Parsoid
14184 !! test
14185 Image with link parameter, wgExternalLinkTarget
14186 !! wikitext
14187 [[Image:foobar.jpg|link=http://example.com/]]
14188 !! config
14189 wgExternalLinkTarget='foobar'
14190 !! html/php
14191 <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>
14192 </p>
14193 !! end
14194
14195 !! test
14196 Image with link parameter, wgNoFollowLinks set to false
14197 !! wikitext
14198 [[Image:foobar.jpg|link=http://example.com/]]
14199 !! config
14200 wgNoFollowLinks=false
14201 !! html
14202 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14203 </p>
14204 !! end
14205
14206 !! test
14207 Image with link parameter, wgNoFollowDomainExceptions
14208 !! wikitext
14209 [[Image:foobar.jpg|link=http://example.com/]]
14210 !! config
14211 wgNoFollowDomainExceptions='example.com'
14212 !! html
14213 <p><a href="http://example.com/"><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" /></a>
14214 </p>
14215 !! end
14216
14217 # wgExternalLinkTarget not supported by Parsoid
14218 !! test
14219 Image with link parameter, wgExternalLinkTarget, unnamed parameter
14220 !! wikitext
14221 [[Image:foobar.jpg|link=http://example.com/|Title]]
14222 !! config
14223 wgExternalLinkTarget='foobar'
14224 !! html/php
14225 <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>
14226 </p>
14227 !! end
14228
14229 !! test
14230 Image with empty link parameter
14231 !! wikitext
14232 [[File:Foobar.jpg|link=]]
14233 !! html/php
14234 <p><img alt="Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" width="1941" height="220" />
14235 </p>
14236 !! html/parsoid
14237 <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>
14238 !! end
14239
14240 !! test
14241 Image with link parameter (wiki target) and unnamed parameter
14242 !! wikitext
14243 [[File:Foobar.jpg|link=Main_Page|Title]]
14244 !! html/php
14245 <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>
14246 </p>
14247 !! html/parsoid
14248 <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>
14249 !! end
14250
14251 !! test
14252 Image with link parameter (URL target) and unnamed parameter
14253 !! wikitext
14254 [[File:Foobar.jpg|link=http://example.com/|Title]]
14255 !! html/php
14256 <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>
14257 </p>
14258 !! html/parsoid
14259 <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>
14260 !! end
14261
14262 !! test
14263 Thumbnail image with link parameter
14264 !! options
14265 thumbsize=220
14266 parsoid=wt2html,wt2wt,html2html
14267 !! wikitext
14268 [[File:Foobar.jpg|thumb|link=http://example.com/|Title]]
14269 !! html/php
14270 <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>
14271
14272 !! html/parsoid
14273 <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>
14274 !! end
14275
14276 !! test
14277 Manually-specified thumbnail image
14278 !! options
14279 thumbsize=220
14280 !! wikitext
14281 [[File:Foobar.jpg|thumbnail=Thumb.png|Title]]
14282 !! html/php
14283 <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>
14284
14285 !! html/parsoid
14286 <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>
14287 !! end
14288
14289 !! test
14290 Manually-specified thumbnail image with explicit link to wiki page
14291 !! options
14292 thumbsize=220
14293 parsoid=wt2html,wt2wt,html2html
14294 !! wikitext
14295 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|Title]]
14296 !! html/php
14297 <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>
14298
14299 !! html/parsoid
14300 <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>
14301 !! end
14302
14303 !! test
14304 Manually-specified thumbnail image with explicit link to url
14305 !! options
14306 thumbsize=220
14307 parsoid=wt2html,wt2wt,html2html
14308 !! wikitext
14309 [[File:Foobar.jpg|thumb=Thumb.png|link=http://example.com|Title]]
14310 !! html/php
14311 <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>
14312
14313 !! html/parsoid
14314 <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>
14315 !! end
14316
14317 !! test
14318 Manually-specified thumbnail image with explicit no link
14319 !! options
14320 thumbsize=220
14321 parsoid=wt2html,wt2wt,html2html
14322 !! wikitext
14323 [[File:Foobar.jpg|thumb=Thumb.png|link=|Title]]
14324 !! html/php
14325 <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>
14326
14327 !! html/parsoid
14328 <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>
14329 !! end
14330
14331 !! test
14332 Manually-specified thumbnail image with explicit link and alt text
14333 !! options
14334 thumbsize=220
14335 parsoid=wt2html,wt2wt,html2html
14336 !! wikitext
14337 [[File:Foobar.jpg|thumb=Thumb.png|link=Main_Page|alt=alttext|Title]]
14338 !! html/php
14339 <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>
14340
14341 !! html/parsoid
14342 <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>
14343 !! end
14344
14345 !! test
14346 Image with frame and link
14347 !! options
14348 parsoid=wt2html,wt2wt,html2html
14349 !! wikitext
14350 [[File:Foobar.jpg|frame|left|This is a test image [[Main Page]]]]
14351 !! html/php
14352 <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>
14353
14354 !! html/parsoid
14355 <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>
14356 !! end
14357
14358 !! test
14359 Image with frame and link and explicit alt
14360 !! options
14361 parsoid=wt2html,wt2wt,html2html
14362 !! wikitext
14363 [[Image:Foobar.jpg|frame|left|This is a test image [[Main Page]]|alt=Altitude]]
14364 !! html/php
14365 <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>
14366
14367 !! html/parsoid
14368 <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>
14369 !! end
14370
14371 !! test
14372 Image with wiki markup in implicit alt
14373 !! wikitext
14374 [[Image:Foobar.jpg|testing '''bold''' in alt]]
14375
14376 [[Image:Foobar.jpg|alt=testing '''bold''' in alt]]
14377 !! html/php
14378 <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>
14379 </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>
14380 </p>
14381 !! html/parsoid
14382 <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>
14383
14384 <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>
14385 !! end
14386
14387 !! test
14388 Alt image option should handle most kinds of wikitext without barfing
14389 !! wikitext
14390 [[Image:Foobar.jpg|thumb|This is the image caption|alt=This is a [[link]] and a {{echo|''bold template''}}.]]
14391 !! html/php
14392 <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>
14393
14394 !! html/parsoid
14395 <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>
14396 !! end
14397
14398 ###################
14399 # Conflicting image format options.
14400 # First option specified should 'win'.
14401 # All three cases in each test should be identical.
14402
14403 !! test
14404 Image with 'frameless' first.
14405 !! options
14406 parsoid=wt2html,wt2wt,html2html
14407 !! wikitext
14408 [[File:Foobar.jpg|frameless|caption]]
14409
14410 [[File:Foobar.jpg|frameless|frame|caption]]
14411
14412 [[File:Foobar.jpg|frameless|thumb|caption]]
14413 !! html/php
14414 <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>
14415 </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>
14416 </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>
14417 </p>
14418 !! html/parsoid
14419 <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>
14420 <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>
14421 <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>
14422 !! end
14423
14424 !! test
14425 Image with 'frame' first.
14426 !! options
14427 parsoid=wt2html,wt2wt,html2html
14428 !! wikitext
14429 [[File:Foobar.jpg|frame|caption]]
14430 [[File:Foobar.jpg|frame|frameless|caption]]
14431 [[File:Foobar.jpg|frame|thumb|caption]]
14432 !! html/php
14433 <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>
14434 <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>
14435 <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>
14436
14437 !! html/parsoid
14438 <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>
14439 <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>
14440 <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>
14441 !! end
14442
14443 !! test
14444 Image with 'thumb' first.
14445 !! options
14446 parsoid=wt2html,wt2wt,html2html
14447 !! wikitext
14448 [[File:Foobar.jpg|thumb|caption]]
14449 [[File:Foobar.jpg|thumb|frameless|caption]]
14450 [[File:Foobar.jpg|thumb|frame|caption]]
14451 !! html/php
14452 <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>
14453 <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>
14454 <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>
14455
14456 !! html/parsoid
14457 <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>
14458 <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>
14459 <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>
14460 !! end
14461
14462 ###################
14463 # Image sizing.
14464 # See https://www.mediawiki.org/wiki/Help:Images#Size_and_frame
14465 # and https://phabricator.wikimedia.org/T64258
14466 # Foobar has actual size of 1941x220
14467 # 1. Thumbs & frameless always reduce, can't be enlarged unless it's
14468 # a scalable format.
14469 # 2. Framed images always ignore size options; always render at default size.
14470 # 3. "Unspecified format" and border are the only types which can be
14471 # enlarged.
14472
14473 !! test
14474 Image: "unspecified format" and border enlarge
14475 !! options
14476 parsoid=wt2html,wt2wt,html2html
14477 !! wikitext
14478 [[File:Foobar.jpg|2000px]]
14479
14480 [[File:Foobar.jpg|border|2000px]]
14481 !! html/php
14482 <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>
14483 </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>
14484 </p>
14485 !! html/parsoid
14486 <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>
14487 <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>
14488 !! end
14489
14490 !! test
14491 Image: "unspecified format" and border reduce
14492 !! options
14493 parsoid=wt2html,wt2wt,html2html
14494 !! wikitext
14495 [[File:Foobar.jpg|1000px]]
14496
14497 [[File:Foobar.jpg|border|1000px]]
14498 !! html/php
14499 <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>
14500 </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>
14501 </p>
14502 !! html/parsoid
14503 <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>
14504 <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>
14505 !! end
14506
14507 !! test
14508 Image: thumbs reduce
14509 !! options
14510 parsoid=wt2html,wt2wt,html2html
14511 !! wikitext
14512 [[File:Foobar.jpg|thumb|50px]]
14513 !! html/php
14514 <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>
14515
14516 !! html/parsoid
14517 <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>
14518 !! end
14519
14520 !! test
14521 Image: bitmap thumbs can't be enlarged past original size, but vector can.
14522 !! options
14523 parsoid=wt2html,wt2wt,html2html
14524 !! wikitext
14525 [[File:Foobar.jpg|thumb|2000px]]
14526
14527 [[File:Foobar.svg|thumb|2000px]]
14528 !! html/php
14529 <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>
14530 <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>
14531
14532 !! html/parsoid
14533 <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>
14534 <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>
14535 !! end
14536
14537 !! test
14538 Image: frameless can reduce in size
14539 !! options
14540 parsoid=wt2html,wt2wt,html2html
14541 !! wikitext
14542 [[File:Foobar.jpg|frameless|50px]]
14543 !! html/php
14544 <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>
14545 </p>
14546 !! html/parsoid
14547 <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>
14548 !! end
14549
14550 !! test
14551 Image: bitmap frameless can't be enlarged past original size, but vector can
14552 !! options
14553 parsoid=wt2html,wt2wt,html2html
14554 !! wikitext
14555 [[File:Foobar.jpg|frameless|2000px]]
14556
14557 [[File:Foobar.svg|frameless|2000px]]
14558 !! html/php
14559 <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>
14560 </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>
14561 </p>
14562 !! html/parsoid
14563 <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>
14564 <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>
14565 !! end
14566
14567 !! test
14568 Image: framed images are always unscaled.
14569 !! options
14570 parsoid=wt2html,wt2wt,html2html
14571 !! wikitext
14572 [[File:Foobar.jpg|frame]]
14573
14574 [[File:Foobar.jpg|frame|50px]]
14575
14576 [[File:Foobar.jpg|frame|50x50px]]
14577
14578 [[File:Foobar.jpg|frame|2000px]]
14579 !! html/php
14580 <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>
14581 <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>
14582 <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>
14583 <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>
14584
14585 !! html/parsoid
14586 <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>
14587 <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>
14588 <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>
14589 <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>
14590 !! end
14591
14592 ###################
14593
14594 !! test
14595 Link to image page- image page normally doesn't exists, hence edit link
14596 Add test with existing image page
14597 #<p><a href="/wiki/File:Test" title="Image:Test">Image:test</a>
14598 !! wikitext
14599 [[:Image:test]]
14600 !! html
14601 <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>
14602 </p>
14603 !! end
14604
14605 !! test
14606 T20784 Link to non-existent image page with caption should use caption as link text
14607 !! wikitext
14608 [[:Image:test|caption]]
14609 !! html
14610 <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>
14611 </p>
14612 !! end
14613
14614 !! test
14615 Frameless image caption with a free URL
14616 !! wikitext
14617 [[File:Foobar.jpg|http://example.com]]
14618 !! html/php
14619 <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>
14620 </p>
14621 !! html/parsoid
14622 <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>
14623 !! end
14624
14625 !! test
14626 Thumbnail image caption with a free URL
14627 !! options
14628 thumbsize=220
14629 !! wikitext
14630 [[File:Foobar.jpg|thumb|http://example.com]]
14631 !! html/php
14632 <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>
14633
14634 !! html/parsoid
14635 <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>
14636 !! end
14637
14638 !! test
14639 Thumbnail image caption with a free URL and explicit alt
14640 !! options
14641 thumbsize=220
14642 parsoid=wt2html,wt2wt,html2html
14643 !! wikitext
14644 [[File:Foobar.jpg|thumb|http://example.com|alt=Alteration]]
14645 !! html/php
14646 <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>
14647
14648 !! html/parsoid
14649 <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>
14650 !! end
14651
14652 !! test
14653 SVG thumbnails with no language set
14654 !! options
14655 !! wikitext
14656 [[File:Foobar.svg|thumb|caption]]
14657 !! html/php
14658 <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>
14659
14660 !! html/parsoid
14661 <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>
14662 !! end
14663
14664 !! test
14665 SVG thumbnails with language de
14666 !! options
14667 parsoid=wt2html,wt2wt,html2html
14668 !! wikitext
14669 [[File:Foobar.svg|thumb|caption|lang=de]]
14670 !! html/php
14671 <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>
14672
14673 !! html/parsoid
14674 <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>
14675 !! end
14676
14677 !! test
14678 SVG thumbnails with invalid language code
14679 !! options
14680 parsoid=wt2html,wt2wt,html2html
14681 !! wikitext
14682 [[File:Foobar.svg|thumb|caption|lang=invalid.language.code]]
14683 !! html/php
14684 <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>
14685
14686 !! html/parsoid
14687 <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>
14688 !! end
14689
14690 !! test
14691 T3887: A ISBN with a thumbnail
14692 !! wikitext
14693 [[File:Foobar.jpg|thumb|ISBN 1235467890]]
14694 !! html/php
14695 <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>
14696
14697 !! html/parsoid
14698 <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>
14699 !! end
14700
14701 !! test
14702 T3887: A RFC with a thumbnail
14703 !! wikitext
14704 [[File:Foobar.jpg|thumb|This is RFC 12354]]
14705 !! html/php
14706 <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>
14707
14708 !! html/parsoid
14709 <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>
14710 !! end
14711
14712 !! test
14713 T3887: A mailto link with a thumbnail
14714 !! wikitext
14715 [[File:Foobar.jpg|thumb|Please mailto:nobody@example.com]]
14716 !! html/php
14717 <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>
14718
14719 !! html/parsoid
14720 <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>
14721 !! end
14722
14723 # Pending resolution to T2368
14724 !! test
14725 T2648: Frameless image caption with a link
14726 !! wikitext
14727 [[File:Foobar.jpg|text with a [[link]] in it]]
14728 !! html/php
14729 <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>
14730 </p>
14731 !! html/parsoid
14732 <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>
14733 !! end
14734
14735 !! test
14736 T2648: Frameless image caption with a link (suffix)
14737 !! wikitext
14738 [[File:Foobar.jpg|text with a [[link]]foo in it]]
14739 !! html/php
14740 <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>
14741 </p>
14742 !! html/parsoid
14743 <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>
14744 !! end
14745
14746 !! test
14747 T2648: Frameless image caption with an interwiki link
14748 !! wikitext
14749 [[File:Foobar.jpg|text with a [[MeatBall:Link]] in it]]
14750 !! html/php
14751 <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>
14752 </p>
14753 !! html/parsoid
14754 <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>
14755 !! end
14756
14757 !! test
14758 T2648: Frameless image caption with a piped interwiki link
14759 !! wikitext
14760 [[File:Foobar.jpg|text with a [[MeatBall:Link|link]] in it]]
14761 !! html/php
14762 <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>
14763 </p>
14764 !! html/parsoid
14765 <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>
14766 !! end
14767
14768 !! test
14769 T107474: Frameless image caption with <nowiki>
14770 !! wikitext
14771 [[File:Foobar.jpg|<nowiki>text with a [[MeatBall:Link|link]] in it</nowiki>]]
14772 !! html/parsoid
14773 <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>
14774 !! end
14775
14776 !! test
14777 Escape HTML special chars in image alt text
14778 !! wikitext
14779 [[File:Foobar.jpg|& < > "]]
14780 !! html/php
14781 <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>
14782 </p>
14783 !! html/parsoid
14784 <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>
14785 !! end
14786
14787 !! test
14788 Escape HTML special chars in image alt text with LanguageConverter
14789 !! options
14790 language=zh
14791 !! wikitext
14792 [[File:Foobar.jpg|& < > "]]
14793 !! html/php
14794 <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>
14795 </p>
14796 !! html/parsoid
14797 <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>
14798 !! end
14799
14800 !! test
14801 Entities in file name and attributes
14802 !! wikitext
14803 [[File:7%25 solution.gif|manualthumb=7%25 solution.gif|link=7%25 solution|[[7%25 solution]]]]
14804 !! html/php
14805 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=7%25_solution.gif" class="new" title="File:7% solution.gif">7% solution</a>
14806 </p>
14807 !! html/parsoid
14808 <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>
14809 !! end
14810
14811 !! test
14812 T2499: Alt text should have &#1234;, not &amp;1234;
14813 !! wikitext
14814 [[File:Foobar.jpg|&#9792;]]
14815 !! html/php
14816 <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>
14817 </p>
14818 !! html/parsoid
14819 <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>
14820 !! end
14821
14822 !! test
14823 Broken image caption with link
14824 !! options
14825 parsoid=wt2html,wt2wt,html2html
14826 !! wikitext
14827 [[Image:Foobar.jpg|thumb|This is a broken caption. But [[Main Page|this]] is just an ordinary link.
14828 !! html/php
14829 <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.
14830 </p>
14831 !! html/parsoid
14832 <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>
14833 !! end
14834
14835 !! test
14836 Image caption containing another image
14837 !! wikitext
14838 [[File:Foobar.jpg|thumb|This is a caption with another [[File:Thumb.png|image]] inside it!]]
14839 !! html/php
14840 <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>
14841
14842 !! html/parsoid
14843 <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>
14844 !! end
14845
14846 !! test
14847 Image: caption containing a newline
14848 !! wikitext
14849 [[File:Foobar.jpg|This
14850 *is some text]]
14851 !! html/php
14852 <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>
14853 </p>
14854 !! html/parsoid
14855 <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>
14856 !!end
14857
14858 !!test
14859 Image: caption containing leading space
14860 (The leading space should not trigger nowiki escaping in wt2wt mode)
14861 !! wikitext
14862 [[File:Foobar.jpg|thumb| bar]]
14863 !! html/php
14864 <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>
14865
14866 !! html/parsoid
14867 <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>
14868 !!end
14869
14870 !! test
14871 Image: caption containing a table
14872 !! options
14873 parsoid=wt2html,wt2wt,html2html
14874 !! wikitext
14875 [[Image:Foobar.jpg|thumb|200px|This is an example image thumbnail caption with a table
14876 {|
14877 ! Foo !! Bar
14878 |-
14879 | Foo1 || Bar1
14880 |}
14881 and some more text.]]
14882 !! html/php
14883 <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>
14884
14885 !! html/parsoid
14886 <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
14887 <table>
14888 <tbody>
14889 <tr><th>Foo </th><th>Bar</th></tr>
14890 <tr>
14891 <td>Foo1 </td>
14892 <td>Bar1</td></tr></tbody></table>and some more text.</figcaption></figure>
14893 !! end
14894
14895 !! test
14896 T5090: External links other than http: in image captions
14897 !! wikitext
14898 [[File:Foobar.jpg|thumb|200x200px|This caption has [irc://example.net irc] and [https://example.com Secure] ext links in it.]]
14899 !! html/php
14900 <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>
14901
14902 !! html/parsoid
14903 <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>
14904 !! end
14905
14906 !! test
14907 Custom class
14908 !! options
14909 parsoid=wt2html,wt2wt,html2html
14910 !! wikitext
14911 [[Image:foobar.jpg|a|class=b]]
14912 !! html/php
14913 <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>
14914 </p>
14915 !! html/parsoid
14916 <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>
14917 !! end
14918
14919 !! test
14920 Localized image handling (1).
14921 !! options
14922 parsoid=wt2html,wt2wt,html2html
14923 language=es
14924 !! wikitext
14925 [[Archivo:Foobar.jpg|izquierda|enlace=foo|caption]]
14926 !! html/php
14927 <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>
14928
14929 !! html/parsoid
14930 <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>
14931 !! end
14932
14933 !! test
14934 Localized image handling (2).
14935 !! options
14936 thumbsize=220
14937 parsoid=wt2html,wt2wt,html2html
14938 language=es
14939 !! wikitext
14940 [[Archivo:Foobar.jpg|miniatura|izquierda|enlace=foo|caption]]
14941 !! html/php
14942 <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>
14943
14944 !! html/parsoid
14945 <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>
14946 !! end
14947
14948 !! test
14949 Localized image handling (3).
14950 !! options
14951 language=fa
14952 parsoid=html2wt
14953 !! html/parsoid
14954 <figure class="mw-default-size" typeof="mw:Image/Thumb"><a href="./File:Foobar.jpg"><img resource="./File:Foobar.jpg" src="//example.com/images/thumb/3/3a/Foobar.jpg/220px-Foobar.jpg" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="25" width="220"/></a></figure>
14955 !! wikitext
14956 [[File:Foobar.jpg|بندانگشتی]]
14957 !! end
14958
14959 !! test
14960 "border", "frameless" and "class" attributes on an image.
14961 !! options
14962 thumbsize=220
14963 parsoid=wt2html,wt2wt,html2html
14964 !! wikitext
14965 [[File:Foobar.jpg|frameless|border|class=extra|caption]]
14966 !! html/php
14967 <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>
14968 </p>
14969 !! html/parsoid
14970 <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>
14971 !! end
14972
14973 # Note that 'right' is the default alignment, despite the misspelled 'righ' below
14974 !! test
14975 Invalid image attributes (T64500)
14976 !! options
14977 thumbsize=220
14978 parsoid=wt2html,wt2wt,html2html
14979 !! wikitext
14980 [[File:Foobar.jpg|thumb|float|left|caption]]
14981
14982 [[File:Foobar.jpg|thumb|righ|caption]]
14983
14984 [[File:Foobar.jpg|bogus1|thumb|bogus2|left|bogus3|caption]]
14985 !! html/php
14986 <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>
14987 <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>
14988 <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>
14989
14990 !! html/parsoid
14991 <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>
14992 <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>
14993 <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>
14994 !! end
14995
14996 !! article
14997 File:Barfoo.jpg
14998 !! text
14999 #REDIRECT [[File:Barfoo.jpg]]
15000 !! endarticle
15001
15002 # FIXME: Parsoid should run this test -- but we'd need to teach the
15003 # mockAPI about the redirected Barfoo.jpg image.
15004 !! test
15005 Redirected image
15006 !! wikitext
15007 [[Image:Barfoo.jpg]]
15008 !! html/php
15009 <p><a href="/wiki/File:Barfoo.jpg" class="mw-redirect" title="File:Barfoo.jpg">File:Barfoo.jpg</a>
15010 </p>
15011 !! end
15012
15013 !! test
15014 Missing image with uploads disabled
15015 !! options
15016 wgEnableUploads=0
15017 !! wikitext
15018 [[File:Foobaz.jpg]]
15019 !! html/php
15020 <p><a href="/wiki/File:Foobaz.jpg" title="File:Foobaz.jpg">File:Foobaz.jpg</a>
15021 </p>
15022 !! html/parsoid
15023 <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>
15024 !! end
15025
15026 # Parsoid-specific testing for images
15027 # https://www.mediawiki.org/wiki/Parsoid/MediaWiki_DOM_spec#Images
15028 # Currently imperfect due to a flaw in the Parsoid testrunner
15029 # Work in progress
15030 # THESE TESTS SHOULD BE MOVED UP and merged with the php-specific
15031 # image tests.
15032
15033 !! test
15034 Parsoid-specific image handling - simple image with size and middle alignment
15035 !! wikitext
15036 [[File:Foobar.jpg|middle|50px]]
15037 !! html/parsoid
15038 <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>
15039 !! end
15040
15041 !! test
15042 Parsoid-specific image handling - simple image with size, middle alignment,
15043 non-standard namespace alias
15044 !! options
15045 parsoid=wt2wt,wt2html,html2html
15046 !! wikitext
15047 [[Image:Foobar.jpg|middle|50px]]
15048 !! html/parsoid
15049 <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>
15050 !! end
15051
15052 !! test
15053 Parsoid-specific image handling - simple image with size and middle alignment
15054 (existing content)
15055 !! wikitext
15056 [[File:Foobar.jpg|50px|middle]]
15057 !! html/parsoid
15058 <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>
15059 !! end
15060
15061 !! test
15062 Parsoid-specific image handling - simple image with size and middle alignment
15063 and non-standard namespace name
15064 !! options
15065 parsoid=wt2html,wt2wt,html2html
15066 !! wikitext
15067 [[Image:Foobar.jpg|50px|middle]]
15068 !! html/parsoid
15069 <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>
15070 !! end
15071
15072 !! test
15073 Parsoid-specific image handling - simple image with both sizes, a baseline alignment, and a caption
15074 !! wikitext
15075 [[File:Foobar.jpg|500x10px|baseline|caption]]
15076 !! html/parsoid
15077 <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>
15078 !! end
15079
15080 !! test
15081 Parsoid-specific image handling - simple image with border and size spec
15082 !! wikitext
15083 [[File:Foobar.jpg|50px|border|caption]]
15084 !! html/parsoid
15085 <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>
15086 !! end
15087
15088 !! test
15089 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15090 !! wikitext
15091 [[File:Foobar.jpg|left|baseline|thumb|caption content]]
15092 !! html/parsoid
15093 <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>
15094 !! end
15095
15096 !! test
15097 Parsoid-specific image handling - thumbnail with halign, valign, and caption
15098 (existing content)
15099 !! wikitext
15100 [[File:Foobar.jpg|thumb|left|baseline|caption content]]
15101 !! html/parsoid
15102 <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>
15103 !! end
15104
15105 !! test
15106 Parsoid-specific image handling - thumbnail with specific size, halign, valign, and caption
15107 !! wikitext
15108 [[Image:Foobar.jpg|right|middle|thumb|50x50px|caption]]
15109 !! html/parsoid
15110 <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>
15111 !! end
15112
15113 !! test
15114 Parsoid-specific image handling - thumbnail with specific size, halign,
15115 valign, and caption (existing content)
15116 !! wikitext
15117 [[File:Foobar.jpg|thumb|50x50px|right|middle|caption]]
15118 !! html/parsoid
15119 <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>
15120 !! end
15121
15122 !! test
15123 Parsoid-specific image handling - framed image with specific size and caption
15124 (size is ignored)
15125 !! options
15126 parsoid=wt2html,wt2wt,html2html
15127 !! wikitext
15128 [[File:Foobar.jpg|frame|500x50px|caption]]
15129 !! html/parsoid
15130 <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>
15131 !! end
15132
15133 !! test
15134 Parsoid-specific image handling - framed image with specific size, halign, valign, and caption
15135 (size is ignored)
15136 !! options
15137 parsoid=wt2html,wt2wt,html2html
15138 !! wikitext
15139 [[File:Foobar.jpg|left|baseline|frame|500x50px|caption]]
15140 !! html/parsoid
15141 <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>
15142 !! end
15143
15144 !! test
15145 Parsoid-specific image handling - frameless image with specific size, border, and caption
15146 !! wikitext
15147 [[File:Foobar.jpg|frameless|442x50px|border|caption]]
15148 !! html/parsoid
15149 <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>
15150 !! end
15151
15152 !! test
15153 Parsoid-specific image handling - simple image with a formatted caption
15154 !! wikitext
15155 [[File:Foobar.jpg|<table><tr><td>a</td><td>b</td></tr><tr><td>c</td></tr></table>]]
15156 !! html/parsoid
15157 <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>
15158 !! end
15159
15160 !! test
15161 Parsoid-specific image handling - caption with a template in it
15162 !! wikitext
15163 [[File:Foobar.jpg|thumb|200x23px|This caption has a {{echo|transclusion}} in it.]]
15164 !! html/parsoid
15165 <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>
15166 !! end
15167
15168 !! test
15169 Parsoid-specific image handling - caption with unbalanced tags in it
15170 !! options
15171 parsoid=wt2html,wt2wt,html2html
15172 !! wikitext
15173 foo
15174 [[File:Foobar.jpg|thumb|200x200px|This caption has a <center>unbalanced tag in it.]]
15175 bar
15176 !! html/parsoid
15177 <p>foo</p>
15178 <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>
15179 <p>bar</p>
15180 !! end
15181
15182 !! test
15183 Parsoid-specific image handling - empty caption (1)
15184 !! options
15185 parsoid=wt2html,wt2wt
15186 !! wikitext
15187 [[File:Foobar.jpg|thumb|]]
15188 !! html/parsoid
15189 <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>
15190 !! end
15191
15192 # empty captions don't get serialized unless we're in the "round trip" case
15193 !! test
15194 Parsoid-specific image handling - empty caption (2)
15195 !! options
15196 parsoid=html2wt
15197 !! html/parsoid
15198 <figure class="mw-default-size" typeof="mw:Image/Thumb">
15199 <a href="./File:Foobar.jpg">
15200 <img resource="./File:Foobar.jpg"
15201 src="//example.com/images/3/3a/Foobar.jpg"
15202 data-file-width="1941" data-file-height="220" data-file-type="bitmap"
15203 height="25" width="220"/>
15204 </a>
15205 <figcaption></figcaption>
15206 </figure>
15207 !! wikitext
15208 [[File:Foobar.jpg|thumb]]
15209 !! end
15210
15211 !! test
15212 Parsoid-specific image handling - whitespace caption
15213 !! wikitext
15214 [[File:Foobar.jpg|thumb| ]]
15215 !! html/parsoid
15216 <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>
15217 !! end
15218
15219 !! test
15220 Parsoid-specific image handling - lang option
15221 !! wikitext
15222 foo
15223 [[File:Foobar.svg|lang=de|caption]]
15224 bar
15225 !! html/parsoid
15226 <p>foo
15227 <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>
15228 bar</p>
15229 !! end
15230
15231 ## Edge case bugs in Parsoid from T93580
15232 !! test
15233 T93580: 1. Templated <ref> inside block images
15234 !! wikitext
15235 [[File:Foobar.jpg|thumb|Caption with templated ref: {{echo|<ref>foo</ref>}}]]
15236
15237 <references />
15238 !! html/parsoid
15239 <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>
15240
15241 <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>
15242 !! end
15243
15244 !! test
15245 T93580: 2. <ref> inside inline images
15246 !! wikitext
15247 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: <ref>foo</ref>]]
15248
15249 <references />
15250 !! html/parsoid
15251 <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>
15252
15253 <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>
15254 !! end
15255
15256 !! test
15257 T93580: 3. Templated <ref> inside inline images
15258 !! wikitext
15259 [[File:Foobar.jpg|Undisplayed caption in inline image with ref: {{echo|<ref>{{echo|foo}}</ref>}}]]
15260
15261 <references />
15262 !! html/parsoid
15263 <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>
15264
15265 <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>
15266 !! end
15267
15268 ###
15269 ### Subpages
15270 ###
15271 !! article
15272 Subpage test/subpage
15273 !! text
15274 foo
15275 !! endarticle
15276
15277 !! test
15278 Subpage link
15279 !! options
15280 subpage title=[[Subpage test]]
15281 !! wikitext
15282 [[/subpage]]
15283 !! html
15284 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a>
15285 </p>
15286 !! end
15287
15288 !! test
15289 Subpage noslash link
15290 !! options
15291 subpage title=[[Subpage test]]
15292 !! wikitext
15293 [[/subpage/]]
15294 !! html
15295 <p><a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">subpage</a>
15296 </p>
15297 !! end
15298
15299 !! article
15300 Subpage test/1/2/subpage
15301 !! text
15302 blah
15303 !! endarticle
15304
15305 !! test
15306 Relative subpage noslash link
15307 !! options
15308 parsoid=wt2wt,wt2html,html2html
15309 subpage title=[[Subpage test/1/2/3/4]]
15310 !! wikitext
15311 [[../../subpage/]]
15312
15313 [[../../subpage]]
15314 !! html/php
15315 <p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a>
15316 </p><p><a href="/wiki/Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage test/1/2/subpage</a>
15317 </p>
15318 !! html/parsoid
15319 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">subpage</a></p>
15320 <p><a rel="mw:WikiLink" href="./Subpage_test/1/2/subpage" title="Subpage test/1/2/subpage">Subpage_test/1/2/subpage</a></p>
15321 !! end
15322
15323 !! test
15324 Parsoid: dot-slash prefixed wikilinks
15325 !! wikitext
15326 [[./foo]]
15327
15328 [[././bar]]
15329
15330 [[././baz/]]
15331 !! html/php
15332 <p>[[./foo]]
15333 </p><p>[[././bar]]
15334 </p><p>[[././baz/]]
15335 </p>
15336 !! html/parsoid
15337 <p>[[./foo]]
15338 </p><p>[[././bar]]
15339 </p><p>[[././baz/]]
15340 </p>
15341 !! end
15342
15343 !! test
15344 Render invalid page names as plain text (T53090)
15345 !! wikitext
15346 [[./../foo|bar]]
15347 [[foo�|bar]]
15348 [[foo/.|bar]]
15349 [[foo/..|bar]]
15350 [[foo~~~bar]]
15351 [[foo>bar]]
15352 [[foo[bar]]
15353 [[.]]
15354 [[..]]
15355 [[foo././bar]]
15356 [[foo[http://example.com]xyz]]
15357
15358 [[{{echo|./../foo}}|bar]]
15359 [[{{echo|foo/.}}|bar]]
15360 [[{{echo|foo/..}}|bar]]
15361 [[{{echo|foo~~~~bar}}]]
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 !!html/php
15370 <p>[[./../foo|bar]]
15371 [[foo�|bar]]
15372 [[foo/.|bar]]
15373 [[foo/..|bar]]
15374 [[foo~~~bar]]
15375 [[foo&gt;bar]]
15376 [[foo[bar]]
15377 [[.]]
15378 [[..]]
15379 [[foo././bar]]
15380 [[foo<a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>xyz]]
15381 </p><p>[[./../foo|bar]]
15382 [[foo/.|bar]]
15383 [[foo/..|bar]]
15384 [[foo~~~~bar]]
15385 [[foo&gt;bar]]
15386 [[foo././bar]]
15387 [[foo{bar]]
15388 [[foo}bar]]
15389 [[foo[bar]]
15390 [[foo]bar]]
15391 [[foo&lt;bar]]
15392 </p>
15393 !!html/parsoid
15394 <p>[[./../foo|bar]]
15395 [[foo�|bar]]
15396 [[foo/.|bar]]
15397 [[foo/..|bar]]
15398 [[foo~~~bar]]
15399 [[foo>bar]]
15400 [[foo[bar]]
15401 [[.]]
15402 [[..]]
15403 [[foo././bar]]
15404 [[foo<a rel="mw:ExtLink" href="http://example.com"></a>xyz]]</p>
15405
15406 <p>[[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"./../foo"}},"i":0}}]}'>./../foo</span>|bar]]
15407 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/."}},"i":0}}]}'>foo/.</span>|bar]]
15408 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo/.."}},"i":0}}]}'>foo/..</span>|bar]]
15409 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo~~~~bar"}},"i":0}}]}'>foo~~~~bar</span>]]
15410 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo>bar"}},"i":0}}]}'>foo>bar</span>]]
15411 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo././bar"}},"i":0}}]}'>foo././bar</span>]]
15412 [[<span typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo{bar"}},"i":0}}]}'>foo{bar</span>]]
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&lt;bar"}},"i":0}}]}'>foo&lt;bar</span>]]</p>
15417 !!end
15418
15419 !! test
15420 Disabled subpages
15421 !! wikitext
15422 [[/subpage]]
15423 !! html
15424 <p><a href="/index.php?title=/subpage&amp;action=edit&amp;redlink=1" class="new" title="/subpage (page does not exist)">/subpage</a>
15425 </p>
15426 !! end
15427
15428 !! test
15429 T2561: {{/Subpage}}
15430 !! options
15431 subpage title=[[Page]]
15432 !! wikitext
15433 {{/Subpage}}
15434 !! html
15435 <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>
15436 </p>
15437 !! end
15438
15439 ###
15440 ### Categories
15441 ###
15442 !! article
15443 Category:MediaWiki User's Guide
15444 !! text
15445 blah
15446 !! endarticle
15447
15448 !! test
15449 Link to category
15450 !! wikitext
15451 [[:Category:MediaWiki User's Guide]]
15452 !! html
15453 <p><a href="/wiki/Category:MediaWiki_User%27s_Guide" title="Category:MediaWiki User's Guide">Category:MediaWiki User's Guide</a>
15454 </p>
15455 !! end
15456
15457 !! test
15458 Simple category
15459 !! options
15460 cat
15461 !! wikitext
15462 [[Category:MediaWiki User's Guide]]
15463 !! html/php
15464 cat=MediaWiki_User's_Guide sort=
15465 !! html/parsoid
15466 <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"}}'/>
15467 !! end
15468
15469 !! test
15470 PAGESINCATEGORY invalid title fatal (r33546 fix)
15471 !! wikitext
15472 {{PAGESINCATEGORY:<bogus>}}
15473 !! html
15474 <p>0
15475 </p>
15476 !! end
15477
15478 !! test
15479 Category with different sort key
15480 !! options
15481 cat
15482 !! wikitext
15483 [[Category:MediaWiki User's Guide|Foo]]
15484 !! html/php
15485 cat=MediaWiki_User's_Guide sort=Foo
15486 !! html/parsoid
15487 <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"}}'/>
15488 !! end
15489
15490 !! test
15491 Category with identical sort key
15492 !! options
15493 cat
15494 !! wikitext
15495 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15496 !! html/php
15497 cat=MediaWiki_User's_Guide sort=MediaWiki User's Guide
15498 !! html/parsoid
15499 <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"}}'/>
15500 !! end
15501
15502 !! test
15503 Category with empty sort key
15504 !! options
15505 cat
15506 pst
15507 !! wikitext
15508 [[Category:MediaWiki User's Guide|]]
15509 !! html/php
15510 [[Category:MediaWiki User's Guide|MediaWiki User's Guide]]
15511 !! end
15512
15513 !! test
15514 Category with empty sort key and parentheses
15515 !! options
15516 cat
15517 pst
15518 !! wikitext
15519 [[Category:Foo (bar)|]]
15520 !! html/php
15521 [[Category:Foo (bar)|Foo]]
15522 !! end
15523
15524 !! test
15525 Category with link tail
15526 !! options
15527 cat
15528 pst
15529 !! wikitext
15530 123[[Category:Foo]]456
15531 !! html/php
15532 123[[Category:Foo]]456
15533 !! end
15534
15535 !! test
15536 Category with template
15537 !! options
15538 cat
15539 pst
15540 !! wikitext
15541 [[Category:{{echo|Foo}}]]
15542 !! html/php
15543 [[Category:{{echo|Foo}}]]
15544 !! end
15545
15546 !! test
15547 Category with template in sort key
15548 !! options
15549 cat
15550 pst
15551 !! wikitext
15552 [[Category:Foo|{{echo|Bar}}]]
15553 !! html/php
15554 [[Category:Foo|{{echo|Bar}}]]
15555 !! end
15556
15557 !! test
15558 Category with template in sort key and title
15559 !! options
15560 cat
15561 pst
15562 !! wikitext
15563 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15564 !! html/php
15565 [[Category:{{echo|Foo}}|{{echo|Bar}}]]
15566 !! end
15567
15568 ## We used to, but no longer wt2wt this test since the default serializer
15569 ## will normalize all categories to serialize on their own line.
15570 ## This wikitext usage is going to be fairly uncommon in production and
15571 ## selser will take care of preserving formatting in those scenarios.
15572 !! test
15573 Category / paragraph interactions
15574 !! options
15575 parsoid=wt2html
15576 !! wikitext
15577 Foo [[Category:Baz]] Bar
15578
15579 Foo [[Category:Baz]]
15580 Bar
15581
15582 Foo
15583 [[Category:Baz]]
15584 Bar
15585
15586 Foo
15587 [[Category:Baz]] Bar
15588
15589 Foo
15590 [[Category:Baz]]
15591 [[Category:Baz]]
15592 [[Category:Baz]]
15593 Bar
15594
15595 [[Category:Baz]]
15596 [[Category:Baz]]
15597 [[Category:Baz]]
15598
15599 [[Category:Baz]]
15600 {{echo|[[Category:Baz]]}}
15601 [[Category:Baz]]
15602 !! html/php
15603 <p>Foo Bar
15604 </p><p>Foo
15605 Bar
15606 </p><p>Foo
15607 Bar
15608 </p><p>Foo Bar
15609 </p><p>Foo
15610 Bar
15611 </p>
15612 !! html/parsoid
15613 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15614 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15615 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15616 <p>Foo <link rel="mw:PageProp/Category" href="./Category:Baz"/> Bar</p>
15617 <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>
15618 <link rel="mw:PageProp/Category" href="./Category:Baz"/>
15619 !! end
15620
15621 ## We used to, but no longer wt2wt this test since the default serializer
15622 ## will normalize all categories to serialize on their own line.
15623 ## This wikitext usage is going to be fairly uncommon in production and
15624 ## selser will take care of preserving formatting in those scenarios.
15625 ##
15626 ## The whitespace on the empty line is part of the test. Please do not delete
15627 !! test
15628 1. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
15629 !! options
15630 parsoid=wt2html
15631 !! wikitext
15632 This
15633
15634 [[Category:Foo]] and this should be part of same paragraph (not an indent-pre)
15635
15636 {{echo|[[Category:Foo]] and so should this!}}
15637 !! html/php
15638 <p>This and this should be part of same paragraph (not an indent-pre) and so should this!
15639 </p>
15640 !! html/parsoid
15641 <p>This
15642
15643 <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of same paragraph (not an indent-pre)
15644
15645 <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>
15646 !! end
15647
15648 ## Parsoid will not try to wt2wt this while preserving newlines because
15649 ## it suppresses excess newlines within list items -- and we don't want to
15650 ## introduce a special case just for categories, which is, in reality somewhat
15651 ## odd behavior -- categories are unlikely to be used in list items like this
15652 ## in top-level pages and are only likely to show up in template-generated
15653 ## list items where this RT-ing is a non-issue.
15654 ##
15655 ## The whitespace on the empty line is part of the test. Please do not delete
15656 !! test
15657 2. Categories and newlines: All preceding newlines should be suppressed (courtesy T2087)
15658 !! options
15659 parsoid=wt2html
15660 !! wikitext
15661 * This
15662
15663 [[Category:Foo]] and this should be part of the same list item
15664 * So should this
15665
15666 {{echo|[[Category:Foo]] and this should be part of the same list item}}
15667 !! html
15668 <ul><li>This and this should be part of the same list item</li>
15669 <li>So should this and this should be part of the same list item</li></ul>
15670 !! html/parsoid
15671 <ul>
15672 <li>This <link rel="mw:PageProp/Category" href="./Category:Foo"/> and this should be part of the same list item</li>
15673 <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>
15674 </ul>
15675 !! end
15676
15677 ## Newlines and categories that follow the last item of a list
15678 ## are treated differently because this (list followed by categories)
15679 ## is an extremely common pattern on wikis.
15680 !! test
15681 3. Categories and newlines: newline suppression for last list item should RT properly
15682 !! wikitext
15683 * a
15684 * b
15685
15686 [[Category:Foo]]
15687
15688 [[Category:Bar]]
15689 [[Category:Baz]]
15690 !! html/parsoid
15691 <ul><li> a</li>
15692 <li> b</li></ul>
15693
15694 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
15695
15696 <link rel="mw:PageProp/Category" href="./Category:Bar" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
15697 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
15698 !! end
15699
15700 !! test
15701 4. Categories and newlines: newline suppression for last list item should RT properly
15702 !! wikitext
15703 * a
15704 **** b
15705
15706 [[Category:Foo]]
15707 !! html/parsoid
15708 <ul><li> a
15709 <ul><li><ul><li><ul><li> b</li></ul></li></ul></li></ul></li></ul>
15710
15711 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
15712 !! end
15713
15714 ## only wt2html for this to make sure the algo only applies to the rightmost path
15715 !! test
15716 5. Categories and newlines: migrateTrailingCategories dom pass should only run on the rightmost path of nested lists
15717 !! options
15718 parsoid=wt2html
15719 !! wikitext
15720 * a
15721 ** b
15722 [[Category:Foo]]
15723 * c
15724 ** d
15725 [[Category:Foo]]
15726 !! html/parsoid
15727 <ul><li> a
15728 <ul><li> b
15729 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/></li></ul></li>
15730 <li> c
15731 <ul><li> d</li></ul></li></ul>
15732 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
15733 !! end
15734
15735 ## We used to, but no longer wt2wt this test since the default serializer
15736 ## will normalize all categories to serialize on their own line.
15737 ## This wikitext usage is going to be fairly uncommon in production and
15738 ## selser will take care of preserving formatting in those scenarios.
15739 !! test
15740 6. Categories and newlines: migrateTrailingCategories dom pass should not migrate categories not preceded by newlines
15741 !! options
15742 parsoid=wt2html
15743 !! wikitext
15744 * a [[Category:Foo]]
15745 !! html/parsoid
15746 <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>
15747 !! end
15748
15749 # This test also demonstrates because of newline+category tunneling
15750 # through the list hander, template wrapping doesn't expand to the
15751 # containing list when the list item swallows the category.
15752 !! test
15753 7. Categories and newlines: migrateTrailingCategories dom pass should leave template content alone
15754 !! wikitext
15755 * {{echo|a
15756 [[Category:Foo]]}}
15757 !! html/parsoid
15758 <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
15759 </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>
15760 !! end
15761
15762 !! test
15763 8. Categories and newlines: migrateTrailingCategories dom pass should not get tripped by intervening templates
15764 !! wikitext
15765 * a
15766
15767 {{echo|[[Category:Foo]]
15768 [[Category:Bar]]}}
15769 [[Category:Baz]]
15770 !! html/parsoid
15771 <ul><li> a</li></ul>
15772
15773 <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">
15774 </span><link rel="mw:PageProp/Category" href="./Category:Bar" about="#mwt1" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
15775 <link rel="mw:PageProp/Category" href="./Category:Baz" data-parsoid='{"stx":"simple","a":{"href":"./Category:Baz"},"sa":{"href":"Category:Baz"}}'/>
15776 !! end
15777
15778 !! test
15779 Category links with multiple namespaces
15780 !! wikitext
15781 [[Category:Project:Foo]]
15782 !! html/parsoid
15783 <link rel="mw:PageProp/Category" href="./Category:Project:Foo" />
15784 !! end
15785
15786 !! test
15787 Parsoid: Serialize link to category page with colon escape
15788 !! options
15789 parsoid
15790 !! wikitext
15791
15792 [[:Category:Foo]]
15793 [[:Category:Foo|Bar]]
15794 !! html
15795 <p>
15796 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Category:Foo</a>
15797 <a rel="mw:WikiLink" href="./Category:Foo" title="Category:Foo">Bar</a>
15798 </p>
15799 !! end
15800
15801 # We used to, but no longer wt2wt this test since the default serializer
15802 # will normalize all categories to serialize on their own line.
15803 # This wikitext usage is going to be fairly uncommon in production and
15804 # selser will take care of preventing whitespace insertion if this
15805 # occurs in an article.
15806 #
15807 # html2html disabled for the same reason (whitespace insertion between
15808 # x and y).
15809 #
15810 # html2wt disabled because it localizes the "Category" namespace.
15811 !! test
15812 Link prefix/suffixes aren't applied to category links
15813 !! options
15814 parsoid=wt2html
15815 language=is
15816 !! wikitext
15817 x[[Category:Foo]]y
15818 !! html/php
15819 <p>xy
15820 </p>
15821 !! html/parsoid
15822 <p>x<link rel="mw:PageProp/Category" href="./Flokkur:Foo" data-parsoid=""/>y</p>
15823 !! end
15824
15825 !! test
15826 Parsoid: Serialize link to file page with colon escape
15827 !! options
15828 parsoid
15829 !! wikitext
15830
15831 [[:File:Foo.png]]
15832 [[:File:Foo.png|Bar]]
15833 !! html
15834 <p>
15835 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">File:Foo.png</a>
15836 <a rel="mw:WikiLink" href="./File:Foo.png" title="File:Foo.png">Bar</a>
15837 </p>
15838 !! end
15839
15840 !! test
15841 Parsoid: Serialize a genuine category link without colon escape
15842 !! options
15843 parsoid
15844 !! wikitext
15845 [[Category:Foo]]
15846 [[Category:Foo|Bar]]
15847 !! html
15848 <link rel="mw:PageProp/Category" href="./Category:Foo">
15849 <link rel="mw:PageProp/Category" href="./Category:Foo#Bar">
15850 !! end
15851
15852 !! test
15853 Normalize hrefs properly before testing for invalid link targets (T72894)
15854 !! options
15855 parsoid=html2wt
15856 !! html/parsoid
15857 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne"/>
15858 !! wikitext
15859 [[Category:Toxine bactérienne]]
15860 !! end
15861
15862 !! test
15863 Parsoid: Defaultsort
15864 !! wikitext
15865 {{DEFAULTSORT:Foo}}
15866 !! html/parsoid
15867 <meta property="mw:PageProp/categorydefaultsort" content="Foo"/>
15868 !! end
15869
15870 # NOTE: mw:ExpandedAttrs is not the best typeof here. mw:Transclusion is better.
15871 # But, this is a limitation of our representation and is documented in
15872 # TemplateHandler.js in processSpecialMagicWord
15873 !! test
15874 Parsoid: Defaultsort (template-generated)
15875 !! wikitext
15876 {{{{echo|DEFAULTSORT}}:Foo}}
15877 !! html/parsoid
15878 <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"}]]}'/>
15879 !! end
15880
15881 ###
15882 ### Inter-language links
15883 ###
15884 !! test
15885 Interlanguage links
15886 !! options
15887 ill
15888 !! wikitext
15889 [[es:Alimento]]
15890 [[fr:Nourriture]]
15891 [[zh:食品]]
15892 !! html/php
15893 es:Alimento fr:Nourriture zh:食品
15894 !! html/parsoid
15895 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Alimento"/>
15896 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/Nourriture"/>
15897 <link rel="mw:PageProp/Language" href="http://zh.wikipedia.org/wiki/食品"/>
15898 !! end
15899
15900 !! test
15901 Duplicate interlanguage links (T26502)
15902 !! options
15903 ill
15904 !! wikitext
15905 [[es:1]]
15906 [[es:2]]
15907 [[fr:1]]
15908 [[fr:2]]
15909 !! html/php
15910 es:1 fr:1
15911 !! html/parsoid
15912 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/1"/>
15913 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/2"/>
15914 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/1"/>
15915 <link rel="mw:PageProp/Language" href="http://fr.wikipedia.org/wiki/2"/>
15916 !! end
15917
15918 ###
15919 ### Sections
15920 ###
15921 !! test
15922 Basic section headings
15923 !! wikitext
15924 == Headline 1 ==
15925 Some text
15926
15927 ==Headline 2==
15928 More
15929 ===Smaller headline===
15930 Blah blah
15931 !! html
15932 <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>
15933 <p>Some text
15934 </p>
15935 <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>
15936 <p>More
15937 </p>
15938 <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>
15939 <p>Blah blah
15940 </p>
15941 !! end
15942
15943 !! test
15944 Section headings with TOC
15945 !! wikitext
15946 == Headline 1 ==
15947 === Subheadline 1 ===
15948 ===== Skipping a level =====
15949 ====== Skipping a level ======
15950
15951 == Headline 2 ==
15952 Some text
15953 ===Another headline===
15954 !! html
15955 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
15956 <ul>
15957 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
15958 <ul>
15959 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
15960 <ul>
15961 <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>
15962 <ul>
15963 <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>
15964 </ul>
15965 </li>
15966 </ul>
15967 </li>
15968 </ul>
15969 </li>
15970 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
15971 <ul>
15972 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
15973 </ul>
15974 </li>
15975 </ul>
15976 </div>
15977
15978 <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>
15979 <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>
15980 <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>
15981 <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>
15982 <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>
15983 <p>Some text
15984 </p>
15985 <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>
15986
15987 !! end
15988
15989 !! test
15990 TOC anchors don't collide
15991 !! wikitext
15992 __FORCETOC__
15993 == Headline 2 ==
15994 == Headline ==
15995 == Headline 2 ==
15996 == Headline ==
15997 !! html/php
15998 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
15999 <ul>
16000 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
16001 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
16002 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
16003 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
16004 </ul>
16005 </div>
16006
16007 <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>
16008 <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>
16009 <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>
16010 <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>
16011
16012 !! end
16013
16014 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
16015 !! test
16016 Handling of sections up to level 6 and beyond
16017 !! wikitext
16018 = Level 1 Heading=
16019 == Level 2 Heading==
16020 === Level 3 Heading===
16021 ==== Level 4 Heading====
16022 ===== Level 5 Heading=====
16023 ====== Level 6 Heading======
16024 ======= Level 7 Heading=======
16025 ======== Level 8 Heading========
16026 ========= Level 9 Heading=========
16027 ========== Level 10 Heading==========
16028 !! html
16029 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16030 <ul>
16031 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
16032 <ul>
16033 <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>
16034 <ul>
16035 <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>
16036 <ul>
16037 <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>
16038 <ul>
16039 <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>
16040 <ul>
16041 <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>
16042 <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>
16043 <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>
16044 <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>
16045 <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>
16046 </ul>
16047 </li>
16048 </ul>
16049 </li>
16050 </ul>
16051 </li>
16052 </ul>
16053 </li>
16054 </ul>
16055 </li>
16056 </ul>
16057 </div>
16058
16059 <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>
16060 <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>
16061 <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>
16062 <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>
16063 <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>
16064 <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>
16065 <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>
16066 <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>
16067 <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>
16068 <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>
16069
16070 !! end
16071
16072 !! test
16073 TOC regression (T11764)
16074 !! wikitext
16075 == title 1 ==
16076 === title 1.1 ===
16077 ==== title 1.1.1 ====
16078 === title 1.2 ===
16079 == title 2 ==
16080 === title 2.1 ===
16081 !! html
16082 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16083 <ul>
16084 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16085 <ul>
16086 <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>
16087 <ul>
16088 <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>
16089 </ul>
16090 </li>
16091 <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>
16092 </ul>
16093 </li>
16094 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16095 <ul>
16096 <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>
16097 </ul>
16098 </li>
16099 </ul>
16100 </div>
16101
16102 <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>
16103 <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>
16104 <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>
16105 <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>
16106 <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>
16107 <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>
16108
16109 !! end
16110
16111 !! test
16112 TOC for heading containing <span id="..."></span> (T96153)
16113 !! wikitext
16114 __FORCETOC__
16115 ==<span id="old-anchor"></span>New title==
16116 !! html/php
16117 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16118 <ul>
16119 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
16120 </ul>
16121 </div>
16122
16123 <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>
16124
16125 !! end
16126
16127 !! test
16128 TOC with wgMaxTocLevel=3 (T8204)
16129 !! options
16130 wgMaxTocLevel=3
16131 !! wikitext
16132 == title 1 ==
16133 === title 1.1 ===
16134 ==== title 1.1.1 ====
16135 === title 1.2 ===
16136 == title 2 ==
16137 === title 2.1 ===
16138 !! html
16139 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16140 <ul>
16141 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16142 <ul>
16143 <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>
16144 <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>
16145 </ul>
16146 </li>
16147 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
16148 <ul>
16149 <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>
16150 </ul>
16151 </li>
16152 </ul>
16153 </div>
16154
16155 <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>
16156 <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>
16157 <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>
16158 <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>
16159 <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>
16160 <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>
16161
16162 !! end
16163
16164 !! test
16165 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
16166 !! options
16167 wgMaxTocLevel=3
16168 !! wikitext
16169 ==Section 1==
16170 ===Section 1.1===
16171 ====Section 1.1.1====
16172 ====Section 1.1.1.1====
16173 ==Section 2==
16174 !! html
16175 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16176 <ul>
16177 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
16178 <ul>
16179 <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>
16180 </ul>
16181 </li>
16182 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
16183 </ul>
16184 </div>
16185
16186 <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>
16187 <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>
16188 <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>
16189 <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>
16190 <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>
16191
16192 !! end
16193
16194
16195 !! test
16196 Resolving duplicate section names
16197 !! wikitext
16198 == Foo bar ==
16199 == Foo bar ==
16200 !! html
16201 <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>
16202 <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>
16203
16204 !! end
16205
16206 !! test
16207 Resolving duplicate section names with differing case (T12721)
16208 !! wikitext
16209 == Foo bar ==
16210 == Foo Bar ==
16211 !! html
16212 <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>
16213 <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>
16214
16215 !! end
16216
16217 !! article
16218 Template:sections
16219 !! text
16220 ===Section 1===
16221 ==Section 2==
16222 !! endarticle
16223
16224 !! test
16225 Template with sections, __NOTOC__
16226 !! wikitext
16227 __NOTOC__
16228 ==Section 0==
16229 {{sections}}
16230 ==Section 4==
16231 !! html
16232 <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>
16233 <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>
16234 <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>
16235 <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>
16236
16237 !! end
16238
16239 !! test
16240 __NOEDITSECTION__ keyword
16241 !! wikitext
16242 __NOEDITSECTION__
16243 ==Section 1==
16244 ==Section 2==
16245 !! html
16246 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
16247 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
16248
16249 !! end
16250
16251 !! test
16252 Link inside a section heading
16253 !! wikitext
16254 ==Section with a [[Main Page|link]] in it==
16255 !! html
16256 <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>
16257
16258 !! end
16259
16260 !! test
16261 TOC regression (T14077)
16262 !! wikitext
16263 __TOC__
16264 == title 1 ==
16265 === title 1.1 ===
16266 == title 2 ==
16267 !! html
16268 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16269 <ul>
16270 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
16271 <ul>
16272 <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>
16273 </ul>
16274 </li>
16275 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
16276 </ul>
16277 </div>
16278
16279 <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>
16280 <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>
16281 <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>
16282
16283 !! end
16284
16285 !! test
16286 T3219 URL next to image (good)
16287 !! wikitext
16288 http://example.com [[File:Foobar.jpg]]
16289 !! html/php
16290 <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>
16291 </p>
16292 !! html/parsoid
16293 <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>
16294 !!end
16295
16296 !! test
16297 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
16298 !! wikitext
16299 ===
16300 The line above must have a trailing space!
16301 === <!--
16302 --> <!-- -->
16303 But just in case it doesn't...
16304 !! html
16305 <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>
16306 <p>The line above must have a trailing space!
16307 </p>
16308 <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>
16309 <p>But just in case it doesn't...
16310 </p>
16311 !! end
16312
16313 !! test
16314 Header with special characters (T27462)
16315 !! wikitext
16316 The tooltips shall not show entities to the user (ie. be double escaped)
16317
16318 == text > text ==
16319 section 1
16320
16321 == text < text ==
16322 section 2
16323
16324 == text & text ==
16325 section 3
16326
16327 == text ' text ==
16328 section 4
16329
16330 == text " text ==
16331 section 5
16332 !! html
16333 <p>The tooltips shall not show entities to the user (ie. be double escaped)
16334 </p>
16335 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16336 <ul>
16337 <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>
16338 <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>
16339 <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>
16340 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
16341 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
16342 </ul>
16343 </div>
16344
16345 <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>
16346 <p>section 1
16347 </p>
16348 <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>
16349 <p>section 2
16350 </p>
16351 <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>
16352 <p>section 3
16353 </p>
16354 <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>
16355 <p>section 4
16356 </p>
16357 <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>
16358 <p>section 5
16359 </p>
16360 !! end
16361
16362 !! test
16363 Header with space, plus and underscore as entity
16364 !! wikitext
16365 Id should not contain + for spaces
16366
16367 == Space between Text ==
16368 section 1
16369
16370 == Space-Entity&#32;between&#32;Text ==
16371 section 2
16372
16373 == Plus+between+Text ==
16374 section 3
16375
16376 == Plus-Entity&#43;between&#43;Text ==
16377 section 4
16378
16379 == Underscore_between_Text ==
16380 section 5
16381
16382 == Underscore-Entity&#95;between&#95;Text ==
16383 section 6
16384
16385 [[#Space between Text]]
16386 [[#Space-Entity&#32;between&#32;Text]]
16387 [[#Plus+between+Text]]
16388 [[#Plus-Entity&#43;between&#43;Text]]
16389 [[#Underscore_between_Text]]
16390 [[#Underscore-Entity&#95;between&#95;Text]]
16391 !! html
16392 <p>Id should not contain + for spaces
16393 </p>
16394 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16395 <ul>
16396 <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>
16397 <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>
16398 <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>
16399 <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>
16400 <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>
16401 <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>
16402 </ul>
16403 </div>
16404
16405 <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>
16406 <p>section 1
16407 </p>
16408 <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>
16409 <p>section 2
16410 </p>
16411 <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>
16412 <p>section 3
16413 </p>
16414 <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>
16415 <p>section 4
16416 </p>
16417 <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>
16418 <p>section 5
16419 </p>
16420 <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>
16421 <p>section 6
16422 </p><p><a href="#Space_between_Text">#Space between Text</a>
16423 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
16424 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
16425 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
16426 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
16427 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
16428 </p>
16429 !! end
16430
16431 !! test
16432 Headers with excess '=' characters
16433 (Are similar tests necessary beyond the 1st level?)
16434 !! wikitext
16435 =foo==
16436 ==foo=
16437 =''italic'' heading==
16438 ==''italic'' heading=
16439 !! html
16440 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16441 <ul>
16442 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
16443 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
16444 <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>
16445 <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>
16446 </ul>
16447 </div>
16448
16449 <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>
16450 <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>
16451 <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>
16452 <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>
16453
16454 !! end
16455
16456 !! test
16457 HTML headers vs TOC (T25393)
16458 (__NOEDITSECTION__ for clearer output, doesn't matter here)
16459 !! wikitext
16460 <h1>Header 1</h1>
16461 == Header 1.1 ==
16462 == Header 1.2 ==
16463
16464 <h1>Header 2
16465 </h1>
16466 == Header 2.1 ==
16467 == Header 2.2 ==
16468 __NOEDITSECTION__
16469 !! html
16470 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
16471 <ul>
16472 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
16473 <ul>
16474 <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>
16475 <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>
16476 </ul>
16477 </li>
16478 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
16479 <ul>
16480 <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>
16481 <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>
16482 </ul>
16483 </li>
16484 </ul>
16485 </div>
16486
16487 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
16488 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
16489 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
16490 <h1><span class="mw-headline" id="Header_2">Header 2</span></h1>
16491 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
16492 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
16493
16494 !! end
16495
16496 !! test
16497 Single-line or multiline-comments can follow headings
16498 !! options
16499 parsoid=wt2html,wt2wt
16500 !! wikitext
16501 ==foo==<!---->
16502 ==bar==<!--c1-->
16503 ==baz==<!--
16504 c2
16505 c3-->
16506 !! html
16507 <h2><span class="mw-headline" id="foo">foo</span></h2>
16508 <h2><span class="mw-headline" id="bar">bar</span></h2>
16509 <h2><span class="mw-headline" id="baz">baz</span></h2>
16510
16511 !! end
16512
16513 !! test
16514 T3219 URL next to image (broken)
16515 !! wikitext
16516 http://example.com[[File:Foobar.jpg]]
16517 !! html/php
16518 <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>
16519 </p>
16520 !! html/parsoid
16521 <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>
16522 !!end
16523
16524 !! test
16525 T3186 news: in the middle of text
16526 !! wikitext
16527 http://en.wikinews.org/wiki/Wikinews:Workplace
16528 !! html
16529 <p><a rel="nofollow" class="external free" href="http://en.wikinews.org/wiki/Wikinews:Workplace">http://en.wikinews.org/wiki/Wikinews:Workplace</a>
16530 </p>
16531 !!end
16532
16533
16534 !! test
16535 Namespaced link must have a title
16536 !! wikitext
16537 [[Project:]]
16538 !! html
16539 <p>[[Project:]]
16540 </p>
16541 !!end
16542
16543 !! test
16544 Namespaced link must have a title (bad fragment version)
16545 !! wikitext
16546 [[Project:#fragment]]
16547 !! html
16548 <p>[[Project:#fragment]]
16549 </p>
16550 !!end
16551
16552
16553 ###
16554 ### HTML tags and HTML attributes
16555 ###
16556
16557 !! test
16558 div with no attributes
16559 !! wikitext
16560 <div>HTML rocks</div>
16561 !! html
16562 <div>HTML rocks</div>
16563
16564 !! end
16565
16566 !! test
16567 div with double-quoted attribute
16568 !! wikitext
16569 <div id="rock">HTML rocks</div>
16570 !! html
16571 <div id="rock">HTML rocks</div>
16572
16573 !! end
16574
16575 !! test
16576 div with single-quoted attribute
16577 !! wikitext
16578 <div id='rock'>HTML rocks</div>
16579 !! html
16580 <div id="rock">HTML rocks</div>
16581
16582 !! end
16583
16584 !! test
16585 div with unquoted attribute
16586 !! wikitext
16587 <div id=rock>HTML rocks</div>
16588 !! html
16589 <div id="rock">HTML rocks</div>
16590
16591 !! end
16592
16593 !! test
16594 div with illegal double attributes
16595 !! wikitext
16596 <div id="a" id="b">HTML rocks</div>
16597 !! html
16598 <div id="b">HTML rocks</div>
16599
16600 !!end
16601
16602 !! test
16603 div with empty attribute value, space before equals
16604 !! options
16605 parsoid=wt2html,html2html
16606 !! wikitext
16607 <div class =>HTML rocks</div>
16608 !! html/php
16609 <div class="">HTML rocks</div>
16610
16611 !! html/parsoid
16612 <div class="" data-parsoid='{"stx":"html"}'>HTML rocks</div>
16613 !! end
16614
16615 !! test
16616 div with multiple empty attribute values
16617 !! options
16618 parsoid=wt2html,html2html
16619 !! wikitext
16620 <div id= title=>HTML rocks</div>
16621 !! html/php
16622 <div id="title.3D">HTML rocks</div>
16623
16624 !! html/parsoid
16625 <div id="title.3D" data-parsoid='{"stx":"html"}'>HTML rocks</div>
16626 !! end
16627
16628 !! test
16629 table with multiple empty attribute values
16630 !! options
16631 parsoid=wt2html,html2html
16632 !! wikitext
16633 {| title= id=
16634 | hi
16635 |}
16636 !! html/php
16637 <table title="id=">
16638 <tr>
16639 <td> hi
16640 </td></tr></table>
16641
16642 !! html/parsoid
16643 <table title="id=">
16644 <tbody><tr><td> hi</td></tr>
16645 </tbody></table>
16646 !! end
16647
16648 !! test
16649 div with braces in attribute value
16650 !! wikitext
16651 <div title="{}">Foo</div>
16652 !! html/php
16653 <div title="&#123;&#125;">Foo</div>
16654
16655 !! html/parsoid
16656 <div title="{}">Foo</div>
16657 !! end
16658
16659 !! test
16660 div with empty attribute value, no space before equals
16661 !! options
16662 parsoid=wt2html,html2html
16663 !! wikitext
16664 <div class=>HTML rocks</div>
16665 !! html/php
16666 <div class="">HTML rocks</div>
16667
16668 !! html/parsoid
16669 <div class="">HTML rocks</div>
16670 !! end
16671
16672 !! test
16673 HTML multiple attributes correction
16674 !! wikitext
16675 <p class="error" class="awesome">Awesome!</p>
16676 !! html
16677 <p class="awesome">Awesome!</p>
16678
16679 !!end
16680
16681 !! test
16682 Table multiple attributes correction
16683 !! wikitext
16684 {|
16685 !+ class="error" class="awesome"| status
16686 |}
16687 !! html
16688 <table>
16689 <tr>
16690 <th class="awesome"> status
16691 </th></tr></table>
16692
16693 !!end
16694
16695 !! test
16696 DIV IN UPPERCASE
16697 !! wikitext
16698 <DIV ID="x">HTML ROCKS</DIV>
16699 !! html
16700 <div id="x">HTML ROCKS</div>
16701
16702 !!end
16703
16704 !! test
16705 Non-ASCII pseudo-tags are rendered as text
16706 !! wikitext
16707 <khyô>
16708 !! html
16709 <p>&lt;khyô&gt;
16710 </p>
16711 !! end
16712
16713 !! test
16714 Pseudo-tag with URL 'name' renders as url link
16715 !! wikitext
16716 <http://example.com/>
16717 !! html
16718 <p>&lt;<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&gt;
16719 </p>
16720 !! end
16721
16722 !! test
16723 text with amp in the middle of nowhere
16724 !! wikitext
16725 Remember AT&T?
16726 !! html
16727 <p>Remember AT&amp;T?
16728 </p>
16729 !! end
16730
16731 !! test
16732 text with character entity: eacute
16733 !! wikitext
16734 I always thought &eacute; was a cute letter.
16735 !! html
16736 <p>I always thought &#233; was a cute letter.
16737 </p>
16738 !! html+tidy
16739 <p>I always thought é was a cute letter.</p>
16740 !! end
16741
16742 !! test
16743 text with entity-escaped character entity-like string: eacute
16744 !! wikitext
16745 I always thought &amp;eacute; was a cute letter.
16746 !! html
16747 <p>I always thought &amp;eacute; was a cute letter.
16748 </p>
16749 !! end
16750
16751 !! test
16752 text with undefined character entity: xacute
16753 !! wikitext
16754 I always thought &xacute; was a cute letter.
16755 !! html
16756 <p>I always thought &amp;xacute; was a cute letter.
16757 </p>
16758 !! end
16759
16760 !! test
16761 HTML5 tags
16762 !! wikitext
16763 <data value="5">five</data>
16764 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
16765 <mark>This highlighted text</mark>
16766 !! html
16767 <p><data value="5">five</data>
16768 <time datetime="2000-01-01T00:00Z">The new millenium started</time>
16769 <mark>This highlighted text</mark>
16770 </p>
16771 !! end
16772
16773 !! test
16774 HTML tag with leading space is parsed as text
16775 !! wikitext
16776 < div>foo< /div>
16777 !! html
16778 <p>&lt; div&gt;foo&lt; /div&gt;
16779 </p>
16780 !! end
16781
16782 ###
16783 ### Nesting tests (see T43545, T52604, T53081)
16784 ###
16785
16786 # This test case is fixed in Parsoid by domino 1.0.12. (T52604)
16787 # Note that html2wt is considerably more difficult if we use <b> in
16788 # the test case, instead of <small>
16789 !! test
16790 Ensure that HTML adoption agency algorithm is properly implemented.
16791 !! wikitext
16792 <small>X<small>Y</small>Z</small>
16793 !! html
16794 <p><small>X<small>Y</small>Z</small>
16795 </p>
16796 !! end
16797
16798 # This was T43545 in the PHP parser.
16799 # Note that tidy doesn't handle this correctly.
16800 !! test
16801 Nesting of <kbd>
16802 !! wikitext
16803 <kbd>X<kbd>Y</kbd>Z</kbd>
16804 !! html
16805 <p><kbd>X<kbd>Y</kbd>Z</kbd>
16806 </p>
16807 !! end
16808
16809 # The following cases were T53081 in the PHP parser.
16810 # Note that there are some other nestable tags (b, i, etc) which are
16811 # not covered; see T53081 for discussion.
16812
16813 # Note that tidy doesn't handle this correctly.
16814 !! test
16815 Nesting of <em>
16816 !! wikitext
16817 <em>X<em>Y</em>Z</em>
16818 !! html
16819 <p><em>X<em>Y</em>Z</em>
16820 </p>
16821 !! end
16822
16823 # Note that tidy doesn't handle this correctly.
16824 !! test
16825 Nesting of <strong>
16826 !! wikitext
16827 <strong>X<strong>Y</strong>Z</strong>
16828 !! html
16829 <p><strong>X<strong>Y</strong>Z</strong>
16830 </p>
16831 !! end
16832
16833 !! test
16834 Nesting of <q>
16835 !! wikitext
16836 <q>X<q>Y</q>Z</q>
16837 !! html+tidy
16838 <p><q>X<q>Y</q>Z</q></p>
16839 !! end
16840
16841 # Note that tidy doesn't handle this correctly.
16842 !! test
16843 Nesting of <ruby>
16844 !! wikitext
16845 <ruby>X<ruby>Y</ruby>Z</ruby>
16846 !! html
16847 <p><ruby>X<ruby>Y</ruby>Z</ruby>
16848 </p>
16849 !! end
16850
16851 # Note that tidy doesn't handle this correctly.
16852 !! test
16853 Nesting of <bdo>
16854 !! wikitext
16855 <bdo>X<bdo>Y</bdo>Z</bdo>
16856 !! html
16857 <p><bdo>X<bdo>Y</bdo>Z</bdo>
16858 </p>
16859 !! end
16860
16861
16862 ###
16863 ### Media links
16864 ###
16865
16866 !! test
16867 Media link
16868 !! wikitext
16869 [[Media:Foobar.jpg]]
16870 !! html/php
16871 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Media:Foobar.jpg</a>
16872 </p>
16873 !! html/parsoid
16874 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">Media:Foobar.jpg</a></p>
16875 !! end
16876
16877 !! test
16878 Media link with text
16879 !! wikitext
16880 [[Media:Foobar.jpg|A neat file to look at]]
16881 !! html/php
16882 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">A neat file to look at</a>
16883 </p>
16884 !! html/parsoid
16885 <p><a rel="mw:MediaLink" href="//example.com/images/3/3a/Foobar.jpg" title="Foobar.jpg">A neat file to look at</a></p>
16886 !! end
16887
16888 # FIXME: this is still bad HTML tag nesting
16889 # FIXME: doBlockLevels won't wrap this in a paragraph because it contains a div
16890 !! test
16891 Media link with nasty text
16892 !! wikitext
16893 [[Media:Foobar.jpg|Safe Link<div style=display:none>" onmouseover="alert(document.cookie)" onfoo="</div>]]
16894 !! html/php
16895 <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>
16896
16897 !! html+php/tidy
16898 <p><a href="http://example.com/images/3/3a/Foobar.jpg" class="internal" title="Foobar.jpg">Safe Link</a></p>
16899 <div style="display:none">" onmouseover="alert(document.cookie)" onfoo="</div>
16900 !! html/parsoid
16901 <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>
16902
16903 !! end
16904
16905 !! test
16906 Media link to nonexistent file (T3702)
16907 !! wikitext
16908 [[Media:No such.jpg]]
16909 [[Media:No_such file.jpg]]
16910 !! html/php
16911 <p><a href="/index.php?title=Special:Upload&amp;wpDestFile=No_such.jpg" class="new" title="No such.jpg">Media:No such.jpg</a>
16912 <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>
16913 </p>
16914 !! html/parsoid
16915 <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>
16916 <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>
16917 !! end
16918
16919 !! test
16920 Image link to nonexistent file (T3850 - good)
16921 !! wikitext
16922 [[File:No_such.jpg]]
16923 !! html/php
16924 <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>
16925 </p>
16926 !! html/parsoid
16927 <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>
16928 !! end
16929
16930 !! test
16931 :Image link to nonexistent file (T3850 - bad)
16932 !! wikitext
16933 [[:Image:No such.jpg]]
16934 !! html/php
16935 <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>
16936 </p>
16937 !! html/parsoid
16938 <p><a rel="mw:WikiLink" href="./File:No_such.jpg" title="File:No such.jpg">Image:No such.jpg</a></p>
16939 !! end
16940
16941
16942
16943 !! test
16944 Character reference normalization in link text (T3938)
16945 !! wikitext
16946 [[Main Page|this&that]]
16947 !! html
16948 <p><a href="/wiki/Main_Page" title="Main Page">this&amp;that</a>
16949 </p>
16950 !!end
16951
16952 !! article
16953 אַ
16954 !! text
16955 Test for unicode normalization
16956
16957 The page's name is U+05d0 U+05b7, with non-canonical form U+FB2E
16958 !! endarticle
16959
16960 !! test
16961 (T21451) Links should refer to the normalized form.
16962 !! wikitext
16963 [[&#xFB2E;]]
16964 [[&#x5d0;&#x5b7;]]
16965 [[&#x5d0;ַ]]
16966 [[א&#x5b7;]]
16967 [[אַ]]
16968 !! html
16969 <p><a href="/wiki/%D7%90%D6%B7" title="אַ">&#xfb2e;</a>
16970 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;&#x5b7;</a>
16971 <a href="/wiki/%D7%90%D6%B7" title="אַ">&#x5d0;ַ</a>
16972 <a href="/wiki/%D7%90%D6%B7" title="אַ">א&#x5b7;</a>
16973 <a href="/wiki/%D7%90%D6%B7" title="אַ">אַ</a>
16974 </p>
16975 !! end
16976
16977 !! test
16978 Empty attribute crash test (T4067)
16979 !! wikitext
16980 <font color="">foo</font>
16981 !! html
16982 <p><font color="">foo</font>
16983 </p>
16984 !! end
16985
16986 !! test
16987 Empty attribute crash test single-quotes (T4067)
16988 !! wikitext
16989 <font color=''>foo</font>
16990 !! html
16991 <p><font color="">foo</font>
16992 </p>
16993 !! end
16994
16995 !! test
16996 Attribute test: equals, then nothing
16997 !! options
16998 parsoid=wt2html,html2html
16999 !! wikitext
17000 <font color=>foo</font>
17001 !! html/php
17002 <p><font color="">foo</font>
17003 </p>
17004 !! html/parsoid
17005 <p><font color="" data-parsoid='{"stx":"html"}'>foo</font></p>
17006 !! end
17007
17008 !! test
17009 Attribute test: unquoted value
17010 !! options
17011 parsoid=wt2html,html2html
17012 !! wikitext
17013 <font color=x>foo</font>
17014 !! html/php
17015 <p><font color="x">foo</font>
17016 </p>
17017 !! html/parsoid
17018 <p><font color="x" data-parsoid='{"stx":"html"}'>foo</font></p>
17019 !! end
17020
17021 !! test
17022 Attribute test: unquoted but illegal value (hash)
17023 !! wikitext
17024 <font color=#x>foo</font>
17025 !! html
17026 <p><font color="#x">foo</font>
17027 </p>
17028 !! end
17029
17030 # Parsoid does not serialize to empty attribute syntax,
17031 # so wt2wt and html2wt cases are skipped
17032 !! test
17033 Attribute test: no value (T54330)
17034 !! options
17035 parsoid=wt2html,html2html
17036 !! wikitext
17037 <font color>foo</font>
17038 !! html/php
17039 <p><font color="">foo</font>
17040 </p>
17041 !! html/parsoid
17042 <p><font color="">foo</font></p>
17043 !! end
17044
17045 !! test
17046 T4095: link with three closing brackets
17047 !! wikitext
17048 [[Main Page]]]
17049 !! html/php
17050 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>]
17051 </p>
17052 !! html/parsoid
17053 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>]</p>
17054 !! end
17055
17056 !! test
17057 T4095: link with pipe and three closing brackets
17058 !! wikitext
17059 [[Main Page|link]]]
17060 !! html/php
17061 <p><a href="/wiki/Main_Page" title="Main Page">link</a>]
17062 </p>
17063 !! html/parsoid
17064 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">link</a>]</p>
17065 !! end
17066
17067 !! test
17068 T4095: link with pipe and three closing brackets, version 2
17069 !! wikitext
17070 [[Main Page|[http://example.com/]]]
17071 !! html/php
17072 <p><a href="/wiki/Main_Page" title="Main Page">[http://example.com/]</a>
17073 </p>
17074 !! html/parsoid
17075 <p><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">[http://example.com/]</a></p>
17076 !! end
17077
17078
17079 ###
17080 ### Safety
17081 ###
17082
17083 !! article
17084 Template:Dangerous attribute
17085 !! text
17086 " onmouseover="alert(document.cookie)
17087 !! endarticle
17088
17089 !! article
17090 Template:Dangerous style attribute
17091 !! text
17092 border-size: expression(alert(document.cookie))
17093 !! endarticle
17094
17095 !! article
17096 Template:Div style
17097 !! text
17098 <div style="float: right; {{{1}}}">Magic div</div>
17099 !! endarticle
17100
17101 !! test
17102 T4304: HTML attribute safety (safe template; regression T4309)
17103 !! wikitext
17104 <div title="{{test}}"></div>
17105 !! html/php
17106 <div title="This is a test template"></div>
17107
17108 !! html/parsoid
17109 <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>
17110 !! end
17111
17112 # Parsoid has enough context to handle this case
17113 !! test
17114 T4304: HTML attribute safety (dangerous template; 2309)
17115 !! wikitext
17116 <div title="{{dangerous attribute}}"></div>
17117 !! html/php
17118 <div title=""></div>
17119
17120 !! html/parsoid
17121 <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>
17122 !! end
17123
17124 !! test
17125 T4304: HTML attribute safety (dangerous style template; 2309)
17126 !! wikitext
17127 <div style="{{dangerous style attribute}}"></div>
17128 !! html/php
17129 <div style="/* insecure input */"></div>
17130
17131 !! html/parsoid
17132 <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>
17133 !! end
17134
17135 !! test
17136 T4304: HTML attribute safety (safe parameter; 2309)
17137 !! wikitext
17138 {{div style|width: 200px}}
17139 !! html/php
17140 <div style="float: right; width: 200px">Magic div</div>
17141
17142 !! html/parsoid
17143 <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>
17144 !! end
17145
17146 !! test
17147 T4304: HTML attribute safety (unsafe parameter; 2309)
17148 !! wikitext
17149 {{div style|width: expression(alert(document.cookie))}}
17150 !! html/php
17151 <div style="/* insecure input */">Magic div</div>
17152
17153 !! html/parsoid
17154 <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>
17155 !! end
17156
17157 ## Parsoid output here differs; needs investigation.
17158 !! test
17159 T4304: HTML attribute safety (unsafe breakout parameter; 2309)
17160 !! wikitext
17161 {{div style|"><script>alert(document.cookie)</script>}}
17162 !! html
17163 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17164
17165 !! end
17166
17167 ## Parsoid output here differs; needs investigation.
17168 !! test
17169 T4304: HTML attribute safety (unsafe breakout parameter 2; 2309)
17170 !! wikitext
17171 {{div style|" ><script>alert(document.cookie)</script>}}
17172 !! html
17173 <div style="float: right;">&lt;script&gt;alert(document.cookie)&lt;/script&gt;"&gt;Magic div</div>
17174
17175 !! end
17176
17177 !! test
17178 T4304: HTML attribute safety (link)
17179 !! wikitext
17180 <div title="[[Main Page]]"></div>
17181 !! html
17182 <div title="&#91;&#91;Main Page]]"></div>
17183
17184 !! end
17185
17186 !! test
17187 T4304: HTML attribute safety (italics)
17188 !! wikitext
17189 <div title="''foobar''"></div>
17190 !! html
17191 <div title="&#39;&#39;foobar&#39;&#39;"></div>
17192
17193 !! end
17194
17195 !! test
17196 T4304: HTML attribute safety (bold)
17197 !! wikitext
17198 <div title="'''foobar'''"></div>
17199 !! html
17200 <div title="&#39;&#39;&#39;foobar&#39;&#39;&#39;"></div>
17201
17202 !! end
17203
17204 !! test
17205 T4304: HTML attribute safety (ISBN)
17206 !! wikitext
17207 <div title="ISBN 1234567890"></div>
17208 !! html
17209 <div title="&#73;SBN 1234567890"></div>
17210
17211 !! end
17212
17213 !! test
17214 T4304: HTML attribute safety (RFC)
17215 !! wikitext
17216 <div title="RFC 1234"></div>
17217 !! html
17218 <div title="&#82;FC 1234"></div>
17219
17220 !! end
17221
17222 !! test
17223 T4304: HTML attribute safety (PMID)
17224 !! wikitext
17225 <div title="PMID 1234567890"></div>
17226 !! html
17227 <div title="&#80;MID 1234567890"></div>
17228
17229 !! end
17230
17231 !! test
17232 T4304: HTML attribute safety (web link)
17233 !! wikitext
17234 <div title="http://example.com/"></div>
17235 !! html
17236 <div title="http&#58;//example.com/"></div>
17237
17238 !! end
17239
17240 !! test
17241 T4304: HTML attribute safety (named web link)
17242 !! wikitext
17243 <div title="[http://example.com/ link]"></div>
17244 !! html
17245 <div title="&#91;http&#58;//example.com/ link]"></div>
17246
17247 !! end
17248
17249 !! test
17250 T5244: HTML attribute safety (extension; safe)
17251 !! wikitext
17252 <div style="<nowiki>background:blue</nowiki>"></div>
17253 !! html/php
17254 <div style="background:blue"></div>
17255
17256 !! html/parsoid
17257 <div style="background:blue" data-parsoid='{"stx":"html","a":{"style":"background:blue"},"sa":{"style":"&lt;nowiki>background:blue&lt;/nowiki>"}}'></div>
17258 !! end
17259
17260 !! test
17261 T5244: HTML attribute safety (extension; unsafe)
17262 !! wikitext
17263 <div style="<nowiki>border-left:expression(alert(document.cookie))</nowiki>"></div>
17264 !! html/php
17265 <div style="/* insecure input */"></div>
17266
17267 !! html/parsoid
17268 <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>
17269 !! end
17270
17271 # More MSIE fun discovered by Tom Gilder
17272
17273 !! test
17274 MSIE CSS safety test: spurious slash
17275 !! wikitext
17276 <div style="background-image:u\rl(javascript:alert('boo'))">evil</div>
17277 !! html/php
17278 <div style="/* insecure input */">evil</div>
17279
17280 !! html/parsoid
17281 <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>
17282 !! end
17283
17284 !! test
17285 MSIE CSS safety test: hex code
17286 !! wikitext
17287 <div style="background-image:u\72l(javascript:alert('boo'))">evil</div>
17288 !! html/php
17289 <div style="/* insecure input */">evil</div>
17290
17291 !! html/parsoid
17292 <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>
17293 !! end
17294
17295 !! test
17296 MSIE CSS safety test: comment in url
17297 !! wikitext
17298 <div style="background-image:u/**/rl(javascript:alert('boo'))">evil</div>
17299 !! html/php
17300 <div style="background-image:u rl(javascript:alert(&#39;boo&#39;))">evil</div>
17301
17302 !! html/parsoid
17303 <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>
17304 !! end
17305
17306 !! test
17307 MSIE CSS safety test: comment in expression
17308 !! wikitext
17309 <div style="background-image:expres/**/sion(alert('boo4'))">evil4</div>
17310 !! html/php
17311 <div style="background-image:expres sion(alert(&#39;boo4&#39;))">evil4</div>
17312
17313 !! html/parsoid
17314 <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>
17315 !! end
17316
17317 !! test
17318 CSS safety test (all browsers): vertical tab (T57332 / CVE-2013-4567)
17319 !! wikitext
17320 <p style="font-size: 100px; background-image:url\b(https://www.google.com/images/srpr/logo6w.png)">A</p>
17321 !! html/php
17322 <p style="/* invalid control char */">A</p>
17323
17324 !! html/parsoid
17325 <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>
17326 !! end
17327
17328 !! test
17329 MSIE 6 CSS safety test: Fullwidth (T57332)
17330 !! wikitext
17331 <p style="font-size: 100px; color: expression((title='XSSed'),'red')">A</p>
17332 <div style="top:EXPRESSION(alert())">B</div>
17333 !! html/php
17334 <p style="/* insecure input */">A</p>
17335 <div style="/* insecure input */">B</div>
17336
17337 !! html/parsoid
17338 <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>
17339 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"top:EXPRESSION(alert())"}}'>B</div>
17340 !! end
17341
17342 !! test
17343 MSIE 6 CSS safety test: IPA extensions (T57332)
17344 !! wikitext
17345 <div style="background-image:uʀʟ(javascript:alert())">A</div>
17346 <p style="font-size: 100px; color: expʀessɪoɴ((title='XSSed'),'red')">B</p>
17347 !! html/php
17348 <div style="/* insecure input */">A</div>
17349 <p style="/* insecure input */">B</p>
17350
17351 !! html/parsoid
17352 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:uʀʟ(javascript:alert())"}}'>A</div>
17353 <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>
17354 !! end
17355
17356 !! test
17357 MSIE 6 CSS safety test: sup/sub script (T57332)
17358 !! wikitext
17359 <div style="background-image:url⁽javascript:alert())">A</div>
17360 <div style="background-image:url₍javascript:alert())">B</div>
17361 <p style="font-size: 100px; color: expressioⁿ((title='XSSed'),'red')">C</p>
17362 !! html/php
17363 <div style="/* insecure input */">A</div>
17364 <div style="/* insecure input */">B</div>
17365 <p style="/* insecure input */">C</p>
17366
17367 !! html/parsoid
17368 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url⁽javascript:alert())"}}'>A</div>
17369 <div style="/* insecure input */" data-parsoid='{"stx":"html","a":{"style":"/* insecure input */"},"sa":{"style":"background-image:url₍javascript:alert())"}}'>B</div>
17370 <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>
17371 !! end
17372
17373 !! test
17374 Opera -o-link CSS
17375 !! options
17376 parsoid=wt2html,html2html
17377 !! wikitext
17378 <div
17379 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;"
17380 style="-o-link:attr(title);-o-link-source:current">X</div>
17381 !! html/php
17382 <div title="data:text/html,&lt;img src=1 onerror=alert(1)&gt;" style="/* insecure input */">X</div>
17383
17384 !! html/parsoid
17385 <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>
17386 !! end
17387
17388 !! test
17389 MSIE 6 CSS safety test: Repetition markers (T57332)
17390 !! wikitext
17391 <p style="font-size: 100px; color: expres〱ion((title='XSSed'),'red')">A</p>
17392 <p style="font-size: 100px; color: expresゝion((title='XSSed'),'red')">B</p>
17393 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">C</p>
17394 <p style="font-size: 100px; color: expresヽion((title='XSSed'),'red')">D</p>
17395 <p style="font-size: 100px; color: expresﹽion((title='XSSed'),'red')">E</p>
17396 <p style="font-size: 100px; color: expresﹼion((title='XSSed'),'red')">F</p>
17397 <p style="font-size: 100px; color: expresーion((title='XSSed'),'red')">G</p>
17398 !! html/php
17399 <p style="/* insecure input */">A</p>
17400 <p style="/* insecure input */">B</p>
17401 <p style="/* insecure input */">C</p>
17402 <p style="/* insecure input */">D</p>
17403 <p style="/* insecure input */">E</p>
17404 <p style="/* insecure input */">F</p>
17405 <p style="/* insecure input */">G</p>
17406
17407 !! html/parsoid
17408 <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>
17409 <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>
17410 <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>
17411 <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>
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;)"}}'>E</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;)"}}'>F</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;)"}}'>G</p>
17415 !! end
17416
17417 !! test
17418 Table attribute legitimate extension
17419 !! wikitext
17420 {|
17421 !+ style="<nowiki>color:blue</nowiki>"| status
17422 |}
17423 !! html
17424 <table>
17425 <tr>
17426 <th style="color:blue"> status
17427 </th></tr></table>
17428
17429 !!end
17430
17431 !! test
17432 Table attribute safety
17433 !! wikitext
17434 {|
17435 !+ style="<nowiki>border-width:expression(0+alert(document.cookie))</nowiki>"| status
17436 |}
17437 !! html
17438 <table>
17439 <tr>
17440 <th style="/* insecure input */"> status
17441 </th></tr></table>
17442
17443 !! end
17444
17445 !! test
17446 CSS line continuation 1
17447 !! wikitext
17448 <div style="background-image: u\&#10;rl(test.jpg);"></div>
17449 !! html
17450 <div style="/* insecure input */"></div>
17451
17452 !! end
17453
17454 !! test
17455 CSS line continuation 2
17456 !! wikitext
17457 <div style="background-image: u\&#13;rl(test.jpg); "></div>
17458 !! html
17459 <div style="/* invalid control char */"></div>
17460
17461 !! end
17462
17463 !! article
17464 Template:Identity
17465 !! text
17466 {{{1}}}
17467 !! endarticle
17468
17469 !! test
17470 Expansion of multi-line templates in attribute values (T8255)
17471 !! wikitext
17472 <div style="background: {{identity|#00FF00}}">-</div>
17473 !! html
17474 <div style="background: #00FF00">-</div>
17475
17476 !! end
17477
17478 !! test
17479 Expansion of multi-line templates in attribute values (T8255 sanity check)
17480 !! wikitext
17481 <div style="background:
17482 #00FF00">-</div>
17483 !! html/php
17484 <div style="background: #00FF00">-</div>
17485
17486 !! html/parsoid
17487 <div style="background:
17488 #00FF00">-</div>
17489 !! end
17490
17491 !! test
17492 Expansion of multi-line templates in attribute values (T8255 sanity check 2)
17493 !! wikitext
17494 <div style="background: &#10;#00FF00">-</div>
17495 !! html
17496 <div style="background: &#10;#00FF00">-</div>
17497
17498 !! end
17499
17500 !! test
17501 Tags which are hidden from Tidy cannot pass through the Sanitizer
17502 !! wikitext
17503 <mw:toc><script>alert();</script></mw:toc>
17504 !! html+tidy
17505 <p>&lt;mw:toc&gt;&lt;script&gt;alert();&lt;/script&gt;&lt;/mw:toc&gt;</p>
17506 !! end
17507
17508 ###
17509 ### Parser hooks (see tests/parser/parserTestsParserHook.php for the <tag> extension)
17510 ###
17511
17512 !! test
17513 Parser hook: empty input
17514 !! wikitext
17515 <tag></tag>
17516 !! html/php
17517 <pre>
17518 ''
17519 array (
17520 )
17521 </pre>
17522
17523 !! html/parsoid
17524 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17525 !! end
17526
17527 ## Don't expect parsoid to rt this form.
17528 !! test
17529 Parser hook: empty input using terminated empty elements
17530 !! options
17531 parsoid=wt2html,html2html
17532 !! wikitext
17533 <tag/>
17534 !! html/php
17535 <pre>
17536 NULL
17537 array (
17538 )
17539 </pre>
17540
17541 !! html/parsoid
17542 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
17543 !! end
17544
17545 !! test
17546 Parser hook: empty input using terminated empty elements (space before)
17547 !! wikitext
17548 <tag />
17549 !! html/php
17550 <pre>
17551 NULL
17552 array (
17553 )
17554 </pre>
17555
17556 !! html/parsoid
17557 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":null}' data-parsoid='{}' about="#mwt2"></pre>
17558 !! end
17559
17560 !! test
17561 Parser hook: basic input
17562 !! wikitext
17563 <tag>input</tag>
17564 !! html/php
17565 <pre>
17566 'input'
17567 array (
17568 )
17569 </pre>
17570
17571 !! html/parsoid
17572 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
17573 !! end
17574
17575 ## Don't expect parsoid to rt this form.
17576 !! test
17577 Parser hook: case insensitive
17578 !! options
17579 parsoid=wt2html,html2html
17580 !! wikitext
17581 <TAG>input</TAG>
17582 !! html/php
17583 <pre>
17584 'input'
17585 array (
17586 )
17587 </pre>
17588
17589 !! html/parsoid
17590 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
17591 !! end
17592
17593 ## Don't expect parsoid to rt this form.
17594 !! test
17595 Parser hook: case insensitive, redux
17596 !! options
17597 parsoid=wt2html,html2html
17598 !! wikitext
17599 <TaG>input</TAg>
17600 !! html/php
17601 <pre>
17602 'input'
17603 array (
17604 )
17605 </pre>
17606
17607 !! html/parsoid
17608 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"input"}}' data-parsoid='{}' about="#mwt2"></pre>
17609 !! end
17610
17611 !! test
17612 Parser hook: nested tags
17613 !! wikitext
17614 <tag><tag></tag></tag>
17615 !! html/php
17616 <pre>
17617 '<tag>'
17618 array (
17619 )
17620 </pre>&lt;/tag&gt;
17621
17622 !! html/parsoid
17623 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{},"body":{"extsrc":"&lt;tag>"}}' data-parsoid='{}' about="#mwt2"></pre>&lt;/tag>
17624 !! end
17625
17626 !! test
17627 Parser hook: basic arguments
17628 !! wikitext
17629 <tag width="200" height="100" depth="50" square=""></tag>
17630 !! html/php
17631 <pre>
17632 ''
17633 array (
17634 'width' => '200',
17635 'height' => '100',
17636 'depth' => '50',
17637 'square' => '',
17638 )
17639 </pre>
17640
17641 !! html/parsoid
17642 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17643 !! end
17644
17645 ## Don't expect parsoid to rt this form.
17646 !! test
17647 Parser hook: basic arguments, variations
17648 !! options
17649 parsoid=wt2html,html2html
17650 !! wikitext
17651 <tag width=200 height = "100" depth = '50' square></tag>
17652 !! html/php
17653 <pre>
17654 ''
17655 array (
17656 'width' => '200',
17657 'height' => '100',
17658 'depth' => '50',
17659 'square' => '',
17660 )
17661 </pre>
17662
17663 !! html/parsoid
17664 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"width":"200","height":"100","depth":"50","square":""},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17665 !! end
17666
17667 !! test
17668 Parser hook: argument containing a forward slash (T7344)
17669 !! wikitext
17670 <tag filename="/tmp/bla"></tag>
17671 !! html/php
17672 <pre>
17673 ''
17674 array (
17675 'filename' => '/tmp/bla',
17676 )
17677 </pre>
17678
17679 !! html/parsoid
17680 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"filename":"/tmp/bla"},"body":{"extsrc":""}}' data-parsoid='{}' about="#mwt2"></pre>
17681 !! end
17682
17683 ## Don't expect parsoid to rt this form.
17684 !! test
17685 Parser hook: empty input using terminated empty elements (T4374)
17686 !! options
17687 parsoid=wt2html,html2html
17688 !! wikitext
17689 <tag foo=bar/>text
17690 !! html/php
17691 <pre>
17692 NULL
17693 array (
17694 'foo' => 'bar',
17695 )
17696 </pre>text
17697
17698 !! html/parsoid
17699 <pre typeof="mw:Extension/tag" data-mw='{"name":"tag","attrs":{"foo":"bar"},"body":null}' data-parsoid='{}' about="#mwt2"></pre>text
17700 !! end
17701
17702 ## </tag> should be output literally since there is no matching tag that begins it
17703 ## Don't expect parsoid to rt this form.
17704 !! test
17705 Parser hook: basic arguments using terminated empty elements (T4374)
17706 !! options
17707 parsoid=wt2html
17708 !! wikitext
17709 <tag width=200 height = "100" depth = '50' square/>
17710 other stuff
17711 </tag>
17712 !! html/php
17713 <pre>
17714 NULL
17715 array (
17716 'width' => '200',
17717 'height' => '100',
17718 'depth' => '50',
17719 'square' => '',
17720 )
17721 </pre>
17722 <p>other stuff
17723 &lt;/tag&gt;
17724 </p>
17725 !! html/parsoid
17726 <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
17727 &lt;/tag></p>
17728 !! end
17729
17730 ## Don't expect parsoid to rt this form.
17731 !! test
17732 Parser hook: Don't allow unclosed extension tags
17733 !! options
17734 parsoid=wt2html
17735 !! wikitext
17736 test <tag>123
17737
17738 this is a '''test'''
17739 !! html/php
17740 <p>test &lt;tag&gt;123
17741 </p><p>this is a <b>test</b>
17742 </p>
17743 !! html/parsoid
17744 <p>test &lt;tag>123</p>
17745
17746 <p>this is a <b>test</b></p>
17747 !! end
17748
17749 ###
17750 ### (see tests/parser/parserTestsParserHook.php for the <statictag> extension)
17751 ###
17752
17753 !! test
17754 Parser hook: static parser hook not inside a comment
17755 !! wikitext
17756 <statictag>hello, world</statictag>
17757
17758 <statictag action="flush" />
17759 !! html/php
17760 <p><br />
17761 hello, world
17762 </p>
17763 !! html/parsoid
17764 <p><span typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{},"body":{"extsrc":"hello, world"}}' data-parsoid='{}' about="#mwt2"></span></p>
17765 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt4">hello, world</p>
17766 !! end
17767
17768 !! test
17769 Parser hook: static parser hook inside a comment
17770 !! wikitext
17771 <!-- <statictag>hello, world</statictag> -->
17772 <statictag action="flush" />
17773 !! html/php
17774 <p><br />
17775 </p>
17776 !! html/parsoid
17777 <!-- <statictag&#x3E;hello, world</statictag&#x3E; -->
17778 <p typeof="mw:Extension/statictag" data-mw='{"name":"statictag","attrs":{"action":"flush"},"body":null}' data-parsoid='{}' about="#mwt2"></p>
17779 !! end
17780
17781 # Nested template calls; this case was broken by Parser.php rev 1.506,
17782 # since reverted.
17783
17784 !! article
17785 Template:One-parameter
17786 !! text
17787 (My parameter is: {{{1}}})
17788 !! endarticle
17789
17790 !! article
17791 Template:Map-one-parameter
17792 !! text
17793 {{{{{1}}}|{{{2}}}}}
17794 !! endarticle
17795
17796 !! test
17797 Nested template calls
17798 !! wikitext
17799 {{Map-one-parameter|One-parameter|param}}
17800 !! html
17801 <p>(My parameter is: param)
17802 </p>
17803 !! end
17804
17805
17806 ###
17807 ### Sanitizer
17808 ###
17809
17810 # HTML+Tidy effectively strips out the empty tags completely
17811 # But since Parsoid doesn't it wraps the <s></s> tags in p-tags
17812 # which Tidy would have done for the PHP parser had there been content inside it.
17813 !! test
17814 Sanitizer: Closing of open tags
17815 !! wikitext
17816 <s></s><table></table>
17817 !! html
17818 <s></s><table></table>
17819
17820 !! html/parsoid
17821 <p><s></s></p><table></table>
17822 !! end
17823
17824 !! test
17825 Sanitizer: Closing of open but not closed tags
17826 !! wikitext
17827 <s>foo
17828 !! html
17829 <p><s>foo</s>
17830 </p>
17831 !! end
17832
17833 !! test
17834 Sanitizer: Closing of closed but not open tags
17835 !! options
17836 parsoid=wt2html
17837 !! wikitext
17838 </s>
17839 !! html/php+tidy
17840 !! html/parsoid
17841 !! end
17842
17843 !! test
17844 Sanitizer: Closing of closed but not open table tags
17845 !! options
17846 parsoid=wt2html
17847 !! wikitext
17848 Table not started</td></tr></table>
17849 !! html/php+tidy
17850 <p>Table not started</p>
17851 !! html/parsoid
17852 <p>Table not started</p>
17853 !! end
17854
17855 !! test
17856 Sanitizer: Escaping of spaces, multibyte characters, colons & other stuff in id=""
17857 !! wikitext
17858 <span id="æ: v">byte</span>[[#æ: v|backlink]]
17859 !! html/php
17860 <p><span id=".C3.A6:_v">byte</span><a href="#.C3.A6:_v">backlink</a>
17861 </p>
17862 !! html/parsoid
17863 <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>
17864 !! end
17865
17866 # In HTML5, the restrictions are that id must contain at least one character,
17867 # and must not contain any space characters.
17868 !! test
17869 Sanitizer: Validating the contents of the id attribute (T6515)
17870 !! options
17871 disabled
17872 !! wikitext
17873 <br id="" /><br id="a space" />
17874 !! html
17875 Something ...
17876 !! end
17877
17878 # In HTML5, id must be unique amongst all the ids in the element's home subtree.
17879 !! test
17880 Sanitizer: Validating id attribute uniqueness (T6515, T8301)
17881 !! options
17882 disabled
17883 !! wikitext
17884 <br id="foo" /><br id="foo" />
17885 !! html
17886 Something need to be done. foo-2 ?
17887 !! end
17888
17889 !! test
17890 Sanitizer: Validating that <meta> and <link> work, but only for Microdata
17891 !! wikitext
17892 <div itemscope>
17893 <meta itemprop="hello" content="world">
17894 <meta http-equiv="refresh" content="5">
17895 <meta itemprop="hello" http-equiv="refresh" content="5">
17896 <link itemprop="hello" href="{{SERVER}}">
17897 <link rel="stylesheet" href="{{SERVER}}">
17898 <link rel="stylesheet" itemprop="hello" href="{{SERVER}}">
17899 </div>
17900 !! html
17901 <div itemscope="">
17902 <p> <meta itemprop="hello" content="world" />
17903 &lt;meta http-equiv="refresh" content="5"&gt;
17904 <meta itemprop="hello" content="5" />
17905 <link itemprop="hello" href="http&#58;//example.org" />
17906 &lt;link rel="stylesheet" href="<a rel="nofollow" class="external free" href="http://example.org">http://example.org</a>"&gt;
17907 <link itemprop="hello" href="http&#58;//example.org" />
17908 </p>
17909 </div>
17910
17911 !! end
17912
17913 !! test
17914 Sanitizer: Strip comments from CSS attributes
17915 !! options
17916 parsoid=wt2html,wt2wt
17917 !! wikitext
17918 <span style="margin:/*negate mbox-text padding */-0.125em -0.45em; /*rainbow*/rgba(255, 0, 0, 0.3)">2013</span>
17919 !! html/php
17920 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span>
17921 </p>
17922 !! html/parsoid
17923 <p><span style="margin: -0.125em -0.45em; rgba(255, 0, 0, 0.3)">2013</span></p>
17924 !! end
17925
17926 !! test
17927 Language converter: output gets cut off unexpectedly (T7757)
17928 !! options
17929 language=zh
17930 !! wikitext
17931 this bit is safe: }-
17932
17933 but if we add a conversion instance: -{zh-cn:xxx;zh-tw:yyy}-
17934
17935 then we get cut off here: }-
17936
17937 all additional text is vanished
17938 !! html
17939 <p>this bit is safe: }-
17940 </p><p>but if we add a conversion instance: xxx
17941 </p><p>then we get cut off here: }-
17942 </p><p>all additional text is vanished
17943 </p>
17944 !! end
17945
17946 !! test
17947 Self closed html pairs (T7487)
17948 !! wikitext
17949 <center><font id="bug" />Centered text</center>
17950 <div><font id="bug2" />In div text</div>
17951 !! html+tidy
17952 <center><font id="bug"></font>Centered text</center>
17953 <div><font id="bug2"></font>In div text</div>
17954 !! end
17955
17956 #
17957 #
17958 #
17959
17960 !! test
17961 Punctuation: nbsp before exclamation
17962 !! wikitext
17963 C'est grave !
17964 !! html
17965 <p>C'est grave&#160;!
17966 </p>
17967 !! end
17968
17969 !! test
17970 Punctuation: CSS !important (T13874)
17971 !! wikitext
17972 <div style="width:50% !important">important</div>
17973 !! html
17974 <div style="width:50% !important">important</div>
17975
17976 !!end
17977
17978 !! test
17979 Punctuation: CSS ! important (T13874; with space after)
17980 !! wikitext
17981 <div style="width:50% ! important">important</div>
17982 !! html
17983 <div style="width:50% ! important">important</div>
17984
17985 !!end
17986
17987 !! test
17988 HTML bullet list, closed tags (T7497)
17989 !! wikitext
17990 <ul>
17991 <li>One</li>
17992 <li>Two</li>
17993 </ul>
17994 !! html/php
17995 <ul>
17996 <li>One</li>
17997 <li>Two</li>
17998 </ul>
17999
18000 !! html/parsoid
18001 <ul data-parsoid='{"stx":"html"}'>
18002 <li data-parsoid='{"stx":"html"}'>One</li>
18003 <li data-parsoid='{"stx":"html"}'>Two</li>
18004 </ul>
18005
18006 !! end
18007
18008 !! test
18009 HTML bullet list, unclosed tags (T7497)
18010 !! wikitext
18011 <ul>
18012 <li>One
18013 <li>Two
18014 </ul>
18015 !! html/php+tidy
18016 <ul>
18017 <li>One</li>
18018 <li>Two</li>
18019 </ul>
18020 !! html/parsoid
18021 <ul data-parsoid='{"stx":"html"}'>
18022 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18023 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18024 </ul>
18025
18026 !! end
18027
18028 !! test
18029 HTML ordered list, closed tags (T7497)
18030 !! wikitext
18031 <ol>
18032 <li>One</li>
18033 <li>Two</li>
18034 </ol>
18035 !! html/php
18036 <ol>
18037 <li>One</li>
18038 <li>Two</li>
18039 </ol>
18040
18041 !! html/parsoid
18042 <ol data-parsoid='{"stx":"html"}'>
18043 <li data-parsoid='{"stx":"html"}'>One</li>
18044 <li data-parsoid='{"stx":"html"}'>Two</li>
18045 </ol>
18046
18047 !! end
18048
18049 !! test
18050 HTML ordered list, unclosed tags (T7497)
18051 !! options
18052 !! wikitext
18053 <ol>
18054 <li>One
18055 <li>Two
18056 </ol>
18057 !! html/php+tidy
18058 <ol>
18059 <li>One</li>
18060 <li>Two</li>
18061 </ol>
18062 !! html/parsoid
18063 <ol data-parsoid='{"stx":"html"}'>
18064 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>One</li>
18065 <li data-parsoid='{"stx":"html","autoInsertedEnd":true}'>Two</li>
18066 </ol>
18067
18068 !! end
18069
18070 !! test
18071 HTML nested bullet list, closed tags (T7497)
18072 !! wikitext
18073 <ul>
18074 <li>One</li>
18075 <li>Two:
18076 <ul>
18077 <li>Sub-one</li>
18078 <li>Sub-two</li>
18079 </ul>
18080 </li>
18081 </ul>
18082 !! html/php
18083 <ul>
18084 <li>One</li>
18085 <li>Two:
18086 <ul>
18087 <li>Sub-one</li>
18088 <li>Sub-two</li>
18089 </ul>
18090 </li>
18091 </ul>
18092
18093 !! html/parsoid
18094 <ul data-parsoid='{"stx":"html"}'>
18095 <li data-parsoid='{"stx":"html"}'>One</li>
18096 <li data-parsoid='{"stx":"html"}'>Two:
18097 <ul data-parsoid='{"stx":"html"}'>
18098 <li data-parsoid='{"stx":"html"}'>Sub-one</li>
18099 <li data-parsoid='{"stx":"html"}'>Sub-two</li>
18100 </ul>
18101 </li>
18102 </ul>
18103 !! end
18104
18105 !! test
18106 HTML nested bullet list, open tags (T7497)
18107 !! wikitext
18108 <ul>
18109 <li>One
18110 <li>Two:
18111 <ul>
18112 <li>Sub-one
18113 <li>Sub-two
18114 </ul>
18115 </ul>
18116 !! html/php+tidy
18117 <ul>
18118 <li>One</li>
18119 <li>Two:
18120 <ul>
18121 <li>Sub-one</li>
18122 <li>Sub-two</li>
18123 </ul>
18124 </li>
18125 </ul>
18126 !! html/parsoid
18127 <ul>
18128 <li>One
18129 </li>
18130 <li>Two:
18131 <ul>
18132 <li>Sub-one
18133 </li>
18134 <li>Sub-two
18135 </li>
18136 </ul>
18137 </li>
18138 </ul>
18139
18140 !! end
18141
18142 !! test
18143 HTML nested ordered list, closed tags (T7497)
18144 !! wikitext
18145 <ol>
18146 <li>One</li>
18147 <li>Two:
18148 <ol>
18149 <li>Sub-one</li>
18150 <li>Sub-two</li>
18151 </ol>
18152 </li>
18153 </ol>
18154 !! html
18155 <ol>
18156 <li>One</li>
18157 <li>Two:
18158 <ol>
18159 <li>Sub-one</li>
18160 <li>Sub-two</li>
18161 </ol>
18162 </li>
18163 </ol>
18164
18165 !! end
18166
18167 !! test
18168 HTML nested ordered list, open tags (T7497)
18169 !! wikitext
18170 <ol>
18171 <li>One
18172 <li>Two:
18173 <ol>
18174 <li>Sub-one
18175 <li>Sub-two
18176 </ol>
18177 </ol>
18178 !! html/php
18179 <ol>
18180 <li>One
18181 <li>Two:
18182 <ol>
18183 <li>Sub-one
18184 <li>Sub-two
18185 </ol>
18186 </ol>
18187
18188 !! html/parsoid
18189 <ol>
18190 <li>One
18191 </li>
18192 <li>Two:
18193 <ol>
18194 <li>Sub-one
18195 </li>
18196 <li>Sub-two
18197 </li>
18198 </ol>
18199 </li>
18200 </ol>
18201
18202 !! end
18203
18204 !! test
18205 HTML ordered list item with parameters oddity
18206 !! wikitext
18207 <ol><li id="fragment">One</li>
18208 </ol>
18209 !! html
18210 <ol><li id="fragment">One</li>
18211 </ol>
18212
18213 !! end
18214
18215 # parsoid doesn't explicitly mark autonumbered links, see T55505
18216 !!test
18217 T7918: autonumbering
18218 !! wikitext
18219 [http://first/] [http://second] [ftp://ftp]
18220
18221 ftp://inlineftp
18222
18223 [mailto:enclosed@mail.tld With target]
18224
18225 [mailto:enclosed@mail.tld]
18226
18227 mailto:inline@mail.tld
18228 !! html/php
18229 <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>
18230 </p><p><a rel="nofollow" class="external free" href="ftp://inlineftp">ftp://inlineftp</a>
18231 </p><p><a rel="nofollow" class="external text" href="mailto:enclosed@mail.tld">With target</a>
18232 </p><p><a rel="nofollow" class="external autonumber" href="mailto:enclosed@mail.tld">[4]</a>
18233 </p><p><a rel="nofollow" class="external free" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a>
18234 </p>
18235 !! html/parsoid
18236 <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>
18237 <p><a rel="mw:ExtLink" href="ftp://inlineftp">ftp://inlineftp</a></p>
18238 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld">With target</a></p>
18239 <p><a rel="mw:ExtLink" href="mailto:enclosed@mail.tld"></a></p>
18240 <p><a rel="mw:ExtLink" href="mailto:inline@mail.tld">mailto:inline@mail.tld</a></p>
18241 !! end
18242
18243
18244 #
18245 # Security and HTML correctness
18246 # From Nick Jenkins' fuzz testing
18247 #
18248
18249 !! test
18250 Fuzz testing: Parser13
18251 !! wikitext
18252 {|
18253 | http://a|
18254 !! html
18255 <table>
18256 <tr>
18257 <td>
18258 </td>
18259 </tr>
18260 </table>
18261
18262 !! end
18263
18264 !! test
18265 Fuzz testing: Parser14
18266 !! wikitext
18267 == onmouseover= ==
18268 http://__TOC__
18269 !! html
18270 <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>
18271 http://<div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
18272 <ul>
18273 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18274 </ul>
18275 </div>
18276
18277
18278 !! html+tidy
18279 <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>
18280 <p>http://</p>
18281 <div id="toc" class="toc">
18282 <div class="toctitle">
18283 <h2>Contents</h2>
18284 </div>
18285 <ul>
18286 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
18287 </ul>
18288 </div>
18289 <p></p>
18290 !! end
18291
18292 !! test
18293 Fuzz testing: Parser14-table
18294 !! options
18295 parsoid=wt2html,html2html
18296 !! wikitext
18297 ==a==
18298 {| STYLE=__TOC__
18299 !! html
18300 <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>
18301 <table style="&#95;_TOC&#95;_">
18302 <tr><td></td></tr>
18303 </table>
18304
18305 !! html+tidy
18306 <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>
18307 <table style="__TOC__">
18308 <tr>
18309 <td></td>
18310 </tr>
18311 </table>
18312 !! html/parsoid
18313 <h2>a</h2>
18314 <table style="__TOC__"></table>
18315 !! end
18316
18317 # Known to produce bogus xml (extra </td>)
18318 !! test
18319 Fuzz testing: Parser16
18320 !! wikitext
18321 {|
18322 !https://||||||
18323 !! html
18324 <table>
18325 <tr>
18326 <th>https://</th>
18327 <th></th>
18328 <th></th>
18329 <th>
18330 </td>
18331 </tr>
18332 </table>
18333
18334 !! html+tidy
18335 <table>
18336 <tr>
18337 <th>https://</th>
18338 <th></th>
18339 <th></th>
18340 <th></th>
18341 </tr>
18342 </table>
18343 !! end
18344
18345 !! test
18346 Fuzz testing: Parser21
18347 !! wikitext
18348 {|
18349 ! irc://{{ftp://a" onmouseover="alert('hello world');"
18350 |
18351 !! html
18352 <table>
18353 <tr>
18354 <th> <a rel="nofollow" class="external free" href="irc://{{ftp://a">irc://{{ftp://a</a>" onmouseover="alert('hello world');"
18355 </th>
18356 <td>
18357 </td>
18358 </tr>
18359 </table>
18360
18361 !! end
18362
18363 !! test
18364 Fuzz testing: Parser22
18365 !! wikitext
18366 http://===r:::https://b
18367
18368 {|
18369 !! html
18370 <p><a rel="nofollow" class="external free" href="http://===r:::https://b">http://===r:::https://b</a>
18371 </p>
18372 <table>
18373 <tr><td></td></tr>
18374 </table>
18375
18376 !! end
18377
18378 # Known to produce bad XML for now
18379 !! test
18380 Fuzz testing: Parser24
18381 !! options
18382 parsoid=wt2html
18383 !! wikitext
18384 {|
18385 {{{|
18386 <u CLASS=
18387 | {{{{SSSll!!!!!!!VVVV)]]][[Special:*xxxxxxx--><noinclude>}}}} >
18388 <br style="onmouseover='alert(document.cookie);' " />
18389
18390 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
18391 |
18392 !! html/php
18393 <table>
18394 {{{|
18395 <u class="&#124;">}}}} &gt;
18396 <br style="onmouseover=&#39;alert(document.cookie);&#39;" />
18397
18398 MOVE YOUR MOUSE CURSOR OVER THIS TEXT
18399 <tr>
18400 <td></u>
18401 </td>
18402 </tr>
18403 </table>
18404
18405 !! html/parsoid
18406 <p data-parsoid='{"fostered":true,"autoInsertedEnd":true}'>{{{|
18407 <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>"}'/>}}}} >
18408 <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}'>
18409
18410
18411
18412 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'></td></tr></tbody></table>
18413 !! end
18414
18415 # Note: the current result listed for this is not what the original one was,
18416 # but the original bug was JavaScript injection, which is fixed in any case.
18417 # It's not clear that the original result listed was any more correct than the
18418 # current one. Original result:
18419 # <p>{{{|
18420 # </p>
18421 # <li class="&#124;&#124;">
18422 # }}}blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
18423 !!test
18424 Fuzz testing: Parser25 (T8055)
18425 !! wikitext
18426 {{{
18427 |
18428 <LI CLASS=||
18429 >
18430 }}}blah" onmouseover="alert('hello world');" align="left"'''MOVE MOUSE CURSOR OVER HERE
18431 !! html/php
18432 <p>&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b>
18433 </p>
18434 !! html/parsoid
18435 <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"]}'>
18436 </span><p about="#mwt1">&lt;LI CLASS=blah" onmouseover="alert('hello world');" align="left"<b>MOVE MOUSE CURSOR OVER HERE</b></p>
18437 !! end
18438
18439 !!test
18440 Fuzz testing: URL adjacent extension (with space, clean)
18441 !! wikitext
18442 http://example.com <nowiki>junk</nowiki>
18443 !! html/php
18444 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a> junk
18445 </p>
18446 !! html/parsoid
18447 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a> <span typeof="mw:Nowiki">junk</span></p>
18448 !! end
18449
18450 !!test
18451 Fuzz testing: URL adjacent extension (no space, dirty; nowiki)
18452 !! wikitext
18453 http://example.com<nowiki>junk</nowiki>
18454 !! html/php
18455 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>junk
18456 </p>
18457 !! html/parsoid
18458 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a><span typeof="mw:Nowiki">junk</span></p>
18459 !! end
18460
18461 !! test
18462 Fuzz testing: URL adjacent extension (no space, dirty; pre)
18463 !! wikitext
18464 http://example.com<pre>junk</pre>
18465 !! html/php
18466 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a><pre>junk</pre>
18467
18468 !! html/php+tidy
18469 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></p>
18470 <pre>
18471 junk
18472 </pre>
18473 !! html/parsoid
18474 <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>
18475 !! end
18476
18477 !! test
18478 Fuzz testing: image with bogus manual thumbnail
18479 !! wikitext
18480 [[Image:foobar.jpg|thumbnail= ]]
18481 !! html/php
18482 <div class="thumb tright"><div class="thumbinner" style="width:182px;">Error creating thumbnail: <div class="thumbcaption"></div></div></div>
18483
18484 !! html/parsoid
18485 <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>
18486 !! end
18487
18488 !! test
18489 Fuzz testing: encoded newline in generated HTML replacements (T8577)
18490 !! wikitext
18491 <pre dir="&#10;"></pre>
18492 !! html/php
18493 <pre dir="&#10;"></pre>
18494
18495 !! html/parsoid
18496 <pre typeof="mw:Extension/pre" about="#mwt2" dir="&amp;#10;" data-mw='{"name":"pre","attrs":{"dir":"&amp;#10;"},"body":{"extsrc":""}}'></pre>
18497 !! end
18498
18499 !! test
18500 Parsing optional HTML elements (T8171)
18501 !! options
18502 !! wikitext
18503 <table>
18504 <tr>
18505 <td> Some tabular data</td>
18506 <td> More tabular data ...
18507 <td> And yet som tabular data</td>
18508 </tr>
18509 </table>
18510 !! html
18511 <table>
18512 <tr>
18513 <td> Some tabular data</td>
18514 <td> More tabular data ...
18515 </td><td> And yet som tabular data</td>
18516 </tr>
18517 </table>
18518
18519 !! end
18520
18521 !! test
18522 Correct handling of <td>, <tr> (T8171)
18523 !! options
18524 !! wikitext
18525 <table>
18526 <tr>
18527 <td> Some tabular data</td>
18528 <td> More tabular data ...</td>
18529 <td> And yet som tabular data</td>
18530 </tr>
18531 </table>
18532 !! html
18533 <table>
18534 <tr>
18535 <td> Some tabular data</td>
18536 <td> More tabular data ...</td>
18537 <td> And yet som tabular data</td>
18538 </tr>
18539 </table>
18540
18541 !! end
18542
18543
18544 !! test
18545 Parsing crashing regression (fr:JavaScript)
18546 !! wikitext
18547 </body></x>
18548 !! html
18549 <p>&lt;/body&gt;&lt;/x&gt;
18550 </p>
18551 !! end
18552
18553 !! test
18554 Inline wiki vs wiki block nesting
18555 !! wikitext
18556 '''Bold paragraph
18557
18558 New wiki paragraph
18559 !! html
18560 <p><b>Bold paragraph</b>
18561 </p><p>New wiki paragraph
18562 </p>
18563 !! end
18564
18565 # FIXME: The current php output is documented
18566 # and desired output is the parsoid target.
18567 !! test
18568 Inline HTML vs wiki block nesting
18569 !! wikitext
18570 <b>Bold paragraph
18571
18572 New wiki paragraph
18573 !! html/php
18574 <p><b>Bold paragraph
18575 </p><p>New wiki paragraph</b>
18576 </p>
18577 !! html/parsoid
18578 <p><b>Bold paragraph</b>
18579 </p><p>New wiki paragraph
18580 </p>
18581 !! end
18582
18583 # Original result was this:
18584 # <p><b>bold</b><b>bold<i>bolditalics</i></b>
18585 # </p>
18586 # While that might be marginally more intuitive, maybe, the six-apostrophe
18587 # construct is clearly pathological and the result stated here (which is what
18588 # the parser actually does) is about as reasonable as anything.
18589 !!test
18590 Mixing markup for italics and bold
18591 !! options
18592 !! wikitext
18593 '''bold''''''bold''bolditalics'''''
18594 !! html
18595 <p>'<i>bold'</i><b>bold<i>bolditalics</i></b>
18596 </p>
18597 !! end
18598
18599
18600 !! article
18601 Xyzzyx
18602 !! text
18603 Article for special page transclusion test
18604 !! endarticle
18605
18606 !! test
18607 Special page transclusion
18608 !! options
18609 !! wikitext
18610 {{Special:Prefixindex/Xyzzyx}}
18611 !! html
18612 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
18613 </ul>
18614
18615 !! end
18616
18617 !! test
18618 Special page transclusion twice (T7021)
18619 !! options
18620 !! wikitext
18621 {{Special:Prefixindex/Xyzzyx}}
18622 {{Special:Prefixindex/Xyzzyx}}
18623 !! html
18624 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
18625 </ul>
18626 <ul class="mw-prefixindex-list"><li><a href="/wiki/Xyzzyx" title="Xyzzyx">Xyzzyx</a></li>
18627 </ul>
18628
18629 !! end
18630
18631 !! test
18632 Transclusion of default MediaWiki message
18633 !! wikitext
18634 {{MediaWiki:Mainpage}}
18635 !! html
18636 <p>Main Page
18637 </p>
18638 !! end
18639
18640 !! test
18641 Transclusion of nonexistent MediaWiki message
18642 !! wikitext
18643 {{MediaWiki:Mainpagexxx}}
18644 !! html
18645 <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>
18646 </p>
18647 !! end
18648
18649 !! test
18650 Transclusion of MediaWiki message with underscore
18651 !! wikitext
18652 {{MediaWiki:history_short}}
18653 !! html
18654 <p>History
18655 </p>
18656 !! end
18657
18658 !! test
18659 Transclusion of MediaWiki message with space
18660 !! wikitext
18661 {{MediaWiki:history short}}
18662 !! html
18663 <p>History
18664 </p>
18665 !! end
18666
18667 !! test
18668 Invalid header with following text
18669 !! wikitext
18670 = x = y
18671 !! html
18672 <p>= x = y
18673 </p>
18674 !! end
18675
18676
18677 !! test
18678 Section extraction test (section 0)
18679 !! options
18680 section=0
18681 !! wikitext
18682 start
18683 ==a==
18684 ===aa===
18685 ====aaa====
18686 ==b==
18687 ===ba===
18688 ===bb===
18689 ====bba====
18690 ===bc===
18691 ==c==
18692 ===ca===
18693 !! html/php
18694 start
18695 !! end
18696
18697 !! test
18698 Section extraction test (section 1)
18699 !! options
18700 section=1
18701 !! wikitext
18702 start
18703 ==a==
18704 ===aa===
18705 ====aaa====
18706 ==b==
18707 ===ba===
18708 ===bb===
18709 ====bba====
18710 ===bc===
18711 ==c==
18712 ===ca===
18713 !! html/php
18714 ==a==
18715 ===aa===
18716 ====aaa====
18717 !! end
18718
18719 !! test
18720 Section extraction test (section 2)
18721 !! options
18722 section=2
18723 !! wikitext
18724 start
18725 ==a==
18726 ===aa===
18727 ====aaa====
18728 ==b==
18729 ===ba===
18730 ===bb===
18731 ====bba====
18732 ===bc===
18733 ==c==
18734 ===ca===
18735 !! html/php
18736 ===aa===
18737 ====aaa====
18738 !! end
18739
18740 !! test
18741 Section extraction test (section 3)
18742 !! options
18743 section=3
18744 !! wikitext
18745 start
18746 ==a==
18747 ===aa===
18748 ====aaa====
18749 ==b==
18750 ===ba===
18751 ===bb===
18752 ====bba====
18753 ===bc===
18754 ==c==
18755 ===ca===
18756 !! html/php
18757 ====aaa====
18758 !! end
18759
18760 !! test
18761 Section extraction test (section 4)
18762 !! options
18763 section=4
18764 !! wikitext
18765 start
18766 ==a==
18767 ===aa===
18768 ====aaa====
18769 ==b==
18770 ===ba===
18771 ===bb===
18772 ====bba====
18773 ===bc===
18774 ==c==
18775 ===ca===
18776 !! html/php
18777 ==b==
18778 ===ba===
18779 ===bb===
18780 ====bba====
18781 ===bc===
18782 !! end
18783
18784 !! test
18785 Section extraction test (section 5)
18786 !! options
18787 section=5
18788 !! wikitext
18789 start
18790 ==a==
18791 ===aa===
18792 ====aaa====
18793 ==b==
18794 ===ba===
18795 ===bb===
18796 ====bba====
18797 ===bc===
18798 ==c==
18799 ===ca===
18800 !! html/php
18801 ===ba===
18802 !! end
18803
18804 !! test
18805 Section extraction test (section 6)
18806 !! options
18807 section=6
18808 !! wikitext
18809 start
18810 ==a==
18811 ===aa===
18812 ====aaa====
18813 ==b==
18814 ===ba===
18815 ===bb===
18816 ====bba====
18817 ===bc===
18818 ==c==
18819 ===ca===
18820 !! html/php
18821 ===bb===
18822 ====bba====
18823 !! end
18824
18825 !! test
18826 Section extraction test (section 7)
18827 !! options
18828 section=7
18829 !! wikitext
18830 start
18831 ==a==
18832 ===aa===
18833 ====aaa====
18834 ==b==
18835 ===ba===
18836 ===bb===
18837 ====bba====
18838 ===bc===
18839 ==c==
18840 ===ca===
18841 !! html/php
18842 ====bba====
18843 !! end
18844
18845 !! test
18846 Section extraction test (section 8)
18847 !! options
18848 section=8
18849 !! wikitext
18850 start
18851 ==a==
18852 ===aa===
18853 ====aaa====
18854 ==b==
18855 ===ba===
18856 ===bb===
18857 ====bba====
18858 ===bc===
18859 ==c==
18860 ===ca===
18861 !! html/php
18862 ===bc===
18863 !! end
18864
18865 !! test
18866 Section extraction test (section 9)
18867 !! options
18868 section=9
18869 !! wikitext
18870 start
18871 ==a==
18872 ===aa===
18873 ====aaa====
18874 ==b==
18875 ===ba===
18876 ===bb===
18877 ====bba====
18878 ===bc===
18879 ==c==
18880 ===ca===
18881 !! html/php
18882 ==c==
18883 ===ca===
18884 !! end
18885
18886 !! test
18887 Section extraction test (section 10)
18888 !! options
18889 section=10
18890 !! wikitext
18891 start
18892 ==a==
18893 ===aa===
18894 ====aaa====
18895 ==b==
18896 ===ba===
18897 ===bb===
18898 ====bba====
18899 ===bc===
18900 ==c==
18901 ===ca===
18902 !! html/php
18903 ===ca===
18904 !! end
18905
18906 !! test
18907 Section extraction test (nonexistent section 11)
18908 !! options
18909 section=11
18910 !! wikitext
18911 start
18912 ==a==
18913 ===aa===
18914 ====aaa====
18915 ==b==
18916 ===ba===
18917 ===bb===
18918 ====bba====
18919 ===bc===
18920 ==c==
18921 ===ca===
18922 !! html/php
18923 !! end
18924
18925 !! test
18926 Section extraction test with bogus heading (section 1)
18927 !! options
18928 section=1
18929 !! wikitext
18930 ==a==
18931 ==bogus== not a legal section
18932 ==b==
18933 !! html/php
18934 ==a==
18935 ==bogus== not a legal section
18936 !! end
18937
18938 !! test
18939 Section extraction test with bogus heading (section 2)
18940 !! options
18941 section=2
18942 !! wikitext
18943 ==a==
18944 ==bogus== not a legal section
18945 ==b==
18946 !! html/php
18947 ==b==
18948 !! end
18949
18950 !! test
18951 Section extraction test with comment after heading (section 1)
18952 !! options
18953 section=1
18954 !! wikitext
18955 ==a==
18956 ==b== <!-- -->
18957 ==c==
18958 !! html/php
18959 ==a==
18960 !! end
18961
18962 !! test
18963 Section extraction test with comment after heading (section 2)
18964 !! options
18965 section=2
18966 !! wikitext
18967 ==a==
18968 ==b== <!-- -->
18969 ==c==
18970 !! html/php
18971 ==b== <!-- -->
18972 !! end
18973
18974 !! test
18975 Section extraction test with bogus <nowiki> heading (section 1)
18976 !! options
18977 section=1
18978 !! wikitext
18979 ==a==
18980 ==bogus== <nowiki>not a legal section</nowiki>
18981 ==b==
18982 !! html/php
18983 ==a==
18984 ==bogus== <nowiki>not a legal section</nowiki>
18985 !! end
18986
18987 !! test
18988 Section extraction test with bogus <nowiki> heading (section 2)
18989 !! options
18990 section=2
18991 !! wikitext
18992 ==a==
18993 ==bogus== <nowiki>not a legal section</nowiki>
18994 ==b==
18995 !! html/php
18996 ==b==
18997 !! end
18998
18999 # Formerly testing for T4587, now resolved by the use of unmarked sections
19000 # instead of respecting commented sections
19001 !! test
19002 Section extraction prefixed by comment (section 1)
19003 !! options
19004 section=1
19005 !! wikitext
19006 <!-- -->==sec1==
19007 ==sec2==
19008 !! html/php
19009 ==sec2==
19010 !!end
19011
19012 !! test
19013 Section extraction prefixed by comment (section 2)
19014 !! options
19015 section=2
19016 !! wikitext
19017 <!-- -->==sec1==
19018 ==sec2==
19019 !! html/php
19020
19021 !!end
19022
19023 # Formerly testing for T4607, now resolved by the use of unmarked sections
19024 # instead of respecting HTML-style headings
19025 !! test
19026 Section extraction, mixed wiki and html (section 1)
19027 !! options
19028 section=1
19029 !! wikitext
19030 <h2>unmarked</h2>
19031 unmarked
19032 ==1==
19033 one
19034 ==2==
19035 two
19036 !! html/php
19037 ==1==
19038 one
19039 !! end
19040
19041 !! test
19042 Section extraction, mixed wiki and html (section 2)
19043 !! options
19044 section=2
19045 !! wikitext
19046 <h2>unmarked</h2>
19047 unmarked
19048 ==1==
19049 one
19050 ==2==
19051 two
19052 !! html/php
19053 ==2==
19054 two
19055 !! end
19056
19057
19058 # Formerly testing for T5342
19059 !! test
19060 Section extraction, heading surrounded by <noinclude>
19061 !! options
19062 section=1
19063 !! wikitext
19064 <noinclude>==unmarked==</noinclude>
19065 ==marked==
19066 !! html/php
19067 ==marked==
19068 !!end
19069
19070 # Test behavior of T21910
19071 !! test
19072 Sectiion with all-equals
19073 !! options
19074 section=2
19075 !! wikitext
19076 ===
19077 The line above must have a trailing space
19078 === <!--
19079 --> <!-- -->
19080 But just in case it doesn't...
19081 !! html/php
19082 === <!--
19083 --> <!-- -->
19084 But just in case it doesn't...
19085 !! end
19086
19087 !! test
19088 Section replacement test (section 0)
19089 !! options
19090 replace=0,"xxx"
19091 !! wikitext
19092 start
19093 ==a==
19094 ===aa===
19095 ====aaa====
19096 ==b==
19097 ===ba===
19098 ===bb===
19099 ====bba====
19100 ===bc===
19101 ==c==
19102 ===ca===
19103 !! html/php
19104 xxx
19105
19106 ==a==
19107 ===aa===
19108 ====aaa====
19109 ==b==
19110 ===ba===
19111 ===bb===
19112 ====bba====
19113 ===bc===
19114 ==c==
19115 ===ca===
19116 !! end
19117
19118 !! test
19119 Section replacement test (section 1)
19120 !! options
19121 replace=1,"xxx"
19122 !! wikitext
19123 start
19124 ==a==
19125 ===aa===
19126 ====aaa====
19127 ==b==
19128 ===ba===
19129 ===bb===
19130 ====bba====
19131 ===bc===
19132 ==c==
19133 ===ca===
19134 !! html/php
19135 start
19136 xxx
19137
19138 ==b==
19139 ===ba===
19140 ===bb===
19141 ====bba====
19142 ===bc===
19143 ==c==
19144 ===ca===
19145 !! end
19146
19147 !! test
19148 Section replacement test (section 2)
19149 !! options
19150 replace=2,"xxx"
19151 !! wikitext
19152 start
19153 ==a==
19154 ===aa===
19155 ====aaa====
19156 ==b==
19157 ===ba===
19158 ===bb===
19159 ====bba====
19160 ===bc===
19161 ==c==
19162 ===ca===
19163 !! html/php
19164 start
19165 ==a==
19166 xxx
19167
19168 ==b==
19169 ===ba===
19170 ===bb===
19171 ====bba====
19172 ===bc===
19173 ==c==
19174 ===ca===
19175 !! end
19176
19177 !! test
19178 Section replacement test (section 3)
19179 !! options
19180 replace=3,"xxx"
19181 !! wikitext
19182 start
19183 ==a==
19184 ===aa===
19185 ====aaa====
19186 ==b==
19187 ===ba===
19188 ===bb===
19189 ====bba====
19190 ===bc===
19191 ==c==
19192 ===ca===
19193 !! html/php
19194 start
19195 ==a==
19196 ===aa===
19197 xxx
19198
19199 ==b==
19200 ===ba===
19201 ===bb===
19202 ====bba====
19203 ===bc===
19204 ==c==
19205 ===ca===
19206 !! end
19207
19208 !! test
19209 Section replacement test (section 4)
19210 !! options
19211 replace=4,"xxx"
19212 !! wikitext
19213 start
19214 ==a==
19215 ===aa===
19216 ====aaa====
19217 ==b==
19218 ===ba===
19219 ===bb===
19220 ====bba====
19221 ===bc===
19222 ==c==
19223 ===ca===
19224 !! html/php
19225 start
19226 ==a==
19227 ===aa===
19228 ====aaa====
19229 xxx
19230
19231 ==c==
19232 ===ca===
19233 !! end
19234
19235 !! test
19236 Section replacement test (section 5)
19237 !! options
19238 replace=5,"xxx"
19239 !! wikitext
19240 start
19241 ==a==
19242 ===aa===
19243 ====aaa====
19244 ==b==
19245 ===ba===
19246 ===bb===
19247 ====bba====
19248 ===bc===
19249 ==c==
19250 ===ca===
19251 !! html/php
19252 start
19253 ==a==
19254 ===aa===
19255 ====aaa====
19256 ==b==
19257 xxx
19258
19259 ===bb===
19260 ====bba====
19261 ===bc===
19262 ==c==
19263 ===ca===
19264 !! end
19265
19266 !! test
19267 Section replacement test (section 6)
19268 !! options
19269 replace=6,"xxx"
19270 !! wikitext
19271 start
19272 ==a==
19273 ===aa===
19274 ====aaa====
19275 ==b==
19276 ===ba===
19277 ===bb===
19278 ====bba====
19279 ===bc===
19280 ==c==
19281 ===ca===
19282 !! html/php
19283 start
19284 ==a==
19285 ===aa===
19286 ====aaa====
19287 ==b==
19288 ===ba===
19289 xxx
19290
19291 ===bc===
19292 ==c==
19293 ===ca===
19294 !! end
19295
19296 !! test
19297 Section replacement test (section 7)
19298 !! options
19299 replace=7,"xxx"
19300 !! wikitext
19301 start
19302 ==a==
19303 ===aa===
19304 ====aaa====
19305 ==b==
19306 ===ba===
19307 ===bb===
19308 ====bba====
19309 ===bc===
19310 ==c==
19311 ===ca===
19312 !! html/php
19313 start
19314 ==a==
19315 ===aa===
19316 ====aaa====
19317 ==b==
19318 ===ba===
19319 ===bb===
19320 xxx
19321
19322 ===bc===
19323 ==c==
19324 ===ca===
19325 !! end
19326
19327 !! test
19328 Section replacement test (section 8)
19329 !! options
19330 replace=8,"xxx"
19331 !! wikitext
19332 start
19333 ==a==
19334 ===aa===
19335 ====aaa====
19336 ==b==
19337 ===ba===
19338 ===bb===
19339 ====bba====
19340 ===bc===
19341 ==c==
19342 ===ca===
19343 !! html/php
19344 start
19345 ==a==
19346 ===aa===
19347 ====aaa====
19348 ==b==
19349 ===ba===
19350 ===bb===
19351 ====bba====
19352 xxx
19353
19354 ==c==
19355 ===ca===
19356 !!end
19357
19358 !! test
19359 Section replacement test (section 9)
19360 !! options
19361 replace=9,"xxx"
19362 !! wikitext
19363 start
19364 ==a==
19365 ===aa===
19366 ====aaa====
19367 ==b==
19368 ===ba===
19369 ===bb===
19370 ====bba====
19371 ===bc===
19372 ==c==
19373 ===ca===
19374 !! html/php
19375 start
19376 ==a==
19377 ===aa===
19378 ====aaa====
19379 ==b==
19380 ===ba===
19381 ===bb===
19382 ====bba====
19383 ===bc===
19384 xxx
19385 !! end
19386
19387 !! test
19388 Section replacement test (section 10)
19389 !! options
19390 replace=10,"xxx"
19391 !! wikitext
19392 start
19393 ==a==
19394 ===aa===
19395 ====aaa====
19396 ==b==
19397 ===ba===
19398 ===bb===
19399 ====bba====
19400 ===bc===
19401 ==c==
19402 ===ca===
19403 !! html/php
19404 start
19405 ==a==
19406 ===aa===
19407 ====aaa====
19408 ==b==
19409 ===ba===
19410 ===bb===
19411 ====bba====
19412 ===bc===
19413 ==c==
19414 xxx
19415 !! end
19416
19417 !! test
19418 Section replacement test with initial whitespace (T15728)
19419 !! options
19420 replace=2,"xxx"
19421 !! wikitext
19422 Preformatted initial line
19423 ==a==
19424 ===a===
19425 !! html/php
19426 Preformatted initial line
19427 ==a==
19428 xxx
19429 !! end
19430
19431
19432 !! test
19433 Section extraction, heading followed by pre with 20 spaces (T8398)
19434 !! options
19435 section=1
19436 !! wikitext
19437 ==a==
19438 a
19439 !! html/php
19440 ==a==
19441 a
19442 !! end
19443
19444 !! test
19445 Section extraction, heading followed by pre with 19 spaces (T8398 sanity check)
19446 !! options
19447 section=1
19448 !! wikitext
19449 ==a==
19450 a
19451 !! html/php
19452 ==a==
19453 a
19454 !! end
19455
19456
19457 !! test
19458 Section extraction, <pre> around bogus header (T12309)
19459 !! options
19460 section=2
19461 !! wikitext
19462 == Section One ==
19463 <pre>
19464 =======
19465 </pre>
19466
19467 == Section Two ==
19468 stuff
19469 !! html/php
19470 == Section Two ==
19471 stuff
19472 !! end
19473
19474 !! test
19475 Section replacement, <pre> around bogus header (T12309)
19476 !! options
19477 replace=2,"xxx"
19478 !! wikitext
19479 == Section One ==
19480 <pre>
19481 =======
19482 </pre>
19483
19484 == Section Two ==
19485 stuff
19486 !! html/php
19487 == Section One ==
19488 <pre>
19489 =======
19490 </pre>
19491
19492 xxx
19493 !! end
19494
19495 !! test
19496 Handling of &#x0A; in URLs
19497 !! wikitext
19498 ** irc://&#x0A;a
19499 !! html/php
19500 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
19501
19502 !! html/parsoid
19503 <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>
19504 !! end
19505
19506 !! test
19507 Handling of %0A in URLs
19508 !! wikitext
19509 ** irc://%0Aa
19510 !! html/php
19511 <ul><li><ul><li> <a rel="nofollow" class="external free" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
19512
19513 !! html/parsoid
19514 <ul><li><ul><li> <a rel="mw:ExtLink" href="irc://%0Aa">irc://%0Aa</a></li></ul></li></ul>
19515 !! end
19516
19517 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
19518 !! test
19519 5 quotes, code coverage +1 line
19520 !! options
19521 parsoid=wt2html
19522 !! wikitext
19523 '''''
19524 !! html/php
19525 !! html/parsoid
19526 <p><b><i></i></b></p>
19527 !! end
19528
19529 # same html as previous, but wikitext adjusted to match parsoid html2wt
19530 # note that wt2html and html2html will put the <i> before the <b>
19531 !! test
19532 5 quotes, code coverage +1 line w/ nowiki (1)
19533 !! options
19534 parsoid=wt2wt,html2wt
19535 !! wikitext
19536 '''''<nowiki/>'''''
19537 !! html/php
19538 <p><i></i>
19539 </p>
19540 !! html/parsoid
19541 <p><b><i></i></b></p>
19542 !! end
19543
19544 # same as previous, just swapping the <i> and <b>
19545 !! test
19546 5 quotes, code coverage +1 line w/ nowiki (2)
19547 !! wikitext
19548 '''''<nowiki/>'''''
19549 !! html/php
19550 <p><i></i>
19551 </p>
19552 !! html/parsoid
19553 <p><i><b></b></i></p>
19554 !! end
19555
19556 !! test
19557 Special:Search page linking.
19558 !! wikitext
19559 {{Special:search}}
19560 !! html
19561 <p><a href="/wiki/Special:Search" title="Special:Search">Special:Search</a>
19562 </p>
19563 !! end
19564
19565 !! test
19566 {{!}} is a magic word
19567 !! wikitext
19568 {{!}} is a magic word there and {{!}} is still a magic word here
19569 | is not a magic word here but {{!}} is still a magic word here
19570 !! html/php
19571 <p>| is a magic word there and | is still a magic word here
19572 | is not a magic word here but | is still a magic word here
19573 </p>
19574 !! html/parsoid
19575 <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
19576 | 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>
19577 !! end
19578
19579 !! test
19580 Say the magic word
19581 !! options
19582 title=[[Parser test]]
19583 !! wikitext
19584 * {{PAGENAME}}
19585 * {{PAGENAMEE}}
19586 * {{FULLPAGENAME}}
19587 * {{FULLPAGENAMEE}}
19588 * {{BASEPAGENAME}}
19589 * {{BASEPAGENAMEE}}
19590 * {{SUBPAGENAME}}
19591 * {{SUBPAGENAMEE}}
19592 * {{ROOTPAGENAME}}
19593 * {{ROOTPAGENAMEE}}
19594 * {{TALKPAGENAME}}
19595 * {{TALKPAGENAMEE}}
19596 * {{SUBJECTPAGENAME}}
19597 * {{SUBJECTPAGENAMEE}}
19598 * {{NAMESPACEE}}
19599 * {{NAMESPACE}}
19600 * {{NAMESPACENUMBER}}
19601 * {{TALKSPACE}}
19602 * {{TALKSPACEE}}
19603 * {{SUBJECTSPACE}}
19604 * {{SUBJECTSPACEE}}
19605 * {{Dynamic|{{NUMBEROFUSERS}}|{{NUMBEROFPAGES}}|{{CURRENTVERSION}}|{{CONTENTLANGUAGE}}|{{DIRECTIONMARK}}|{{CURRENTTIMESTAMP}}|{{NUMBEROFARTICLES}}}}
19606 !! html
19607 <ul><li> Parser test</li>
19608 <li> Parser_test</li>
19609 <li> Parser test</li>
19610 <li> Parser_test</li>
19611 <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> Talk:Parser test</li>
19618 <li> Talk:Parser_test</li>
19619 <li> Parser test</li>
19620 <li> Parser_test</li>
19621 <li> </li>
19622 <li> </li>
19623 <li> 0</li>
19624 <li> Talk</li>
19625 <li> Talk</li>
19626 <li> </li>
19627 <li> </li>
19628 <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>
19629
19630 !! end
19631 ### Note: Above tests excludes the "{{NUMBEROFADMINS}}" magic word because it generates a MySQL error when included.
19632
19633 !! test
19634 Gallery with valid attributes
19635 !! wikitext
19636 <gallery type="123" summary="345">
19637 File:File:Foobar.jpg
19638 </gallery>
19639 !! html/php
19640 <ul class="gallery mw-gallery-traditional" type="123">
19641 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19642 <div class="thumb" style="height: 150px;">File:Foobar.jpg</div>
19643 <div class="gallerytext">
19644 </div>
19645 </div></li>
19646 </ul>
19647
19648 !! html/parsoid
19649 <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"}}'>
19650 <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>
19651 </ul>
19652 !! end
19653
19654 ## Parsoid thinks the "centre" here is a property, not a caption.
19655 !! test
19656 Gallery
19657 !! options
19658 parsoid={
19659 "modes": ["wt2html"],
19660 "nativeGallery": true
19661 }
19662 !! wikitext
19663 <gallery>
19664 image1.png |
19665 image2.gif|||||
19666
19667 image3|
19668 image4 |300px| centre
19669 image5.svg| http://///////
19670 [[x|xx]]]]
19671 * image6
19672 </gallery>
19673 !! html/php
19674 <ul class="gallery mw-gallery-traditional">
19675 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19676 <div class="thumb" style="height: 150px;">Image1.png</div>
19677 <div class="gallerytext">
19678 </div>
19679 </div></li>
19680 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19681 <div class="thumb" style="height: 150px;">Image2.gif</div>
19682 <div class="gallerytext">
19683 </div>
19684 </div></li>
19685 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19686 <div class="thumb" style="height: 150px;">Image3</div>
19687 <div class="gallerytext">
19688 </div>
19689 </div></li>
19690 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19691 <div class="thumb" style="height: 150px;">Image4</div>
19692 <div class="gallerytext">
19693 <pre>centre
19694 </pre>
19695 </div>
19696 </div></li>
19697 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19698 <div class="thumb" style="height: 150px;">Image5.svg</div>
19699 <div class="gallerytext">
19700 <p><a rel="nofollow" class="external free" href="http://///////">http://///////</a>
19701 </p>
19702 </div>
19703 </div></li>
19704 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19705 <div class="thumb" style="height: 150px;">* image6</div>
19706 <div class="gallerytext">
19707 </div>
19708 </div></li>
19709 </ul>
19710
19711 !! html/parsoid
19712 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19713 <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>
19714 <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>
19715 <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>
19716 <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>
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;"> image5.svg</span></div><div class="gallerytext"> <a rel="mw:ExtLink" href="http://///////">http://///////</a></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;">* image6</span></div><div class="gallerytext"></div></li>
19719 </ul>
19720 !! end
19721
19722 !! test
19723 Gallery (with options, html)
19724 !! options
19725 parsoid={
19726 "modes": ["wt2html", "html2html"],
19727 "nativeGallery": true
19728 }
19729 !! wikitext
19730 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
19731 File:Nonexistent.jpg|caption
19732 File:Nonexistent.jpg
19733 image:foobar.jpg|some '''caption''' [[Main Page]]
19734 image:foobar.jpg
19735 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
19736 </gallery>
19737 !! html/php
19738 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
19739 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
19740 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19741 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19742 <div class="gallerytext">
19743 <p>caption
19744 </p>
19745 </div>
19746 </div></li>
19747 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19748 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19749 <div class="gallerytext">
19750 </div>
19751 </div></li>
19752 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19753 <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>
19754 <div class="gallerytext">
19755 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
19756 </p>
19757 </div>
19758 </div></li>
19759 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19760 <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>
19761 <div class="gallerytext">
19762 </div>
19763 </div></li>
19764 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19765 <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>
19766 <div class="gallerytext">
19767 <p>blabla.
19768 </p>
19769 </div>
19770 </div></li>
19771 </ul>
19772
19773 !! html/parsoid
19774 <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":{}}'>
19775 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
19776 <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>
19777 <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>
19778 <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>
19779 <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>
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 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>
19781 </ul>
19782 !! end
19783
19784 !! test
19785 Gallery (with options, extsrc)
19786 !! options
19787 parsoid={
19788 "nativeGallery": false
19789 }
19790 !! wikitext
19791 <gallery widths="70px" heights="40px" perrow="2" caption="Foo [[Main Page]]">
19792 File:Nonexistent.jpg|caption
19793 File:Nonexistent.jpg
19794 image:foobar.jpg|some '''caption''' [[Main Page]]
19795 image:foobar.jpg
19796 image:foobar.jpg|Blabla|alt=This is a foo-bar.|blabla.
19797 </gallery>
19798 !! html/php
19799 <ul class="gallery mw-gallery-traditional" style="max-width: 226px;_width: 226px;">
19800 <li class='gallerycaption'>Foo <a href="/wiki/Main_Page" title="Main Page">Main Page</a></li>
19801 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19802 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19803 <div class="gallerytext">
19804 <p>caption
19805 </p>
19806 </div>
19807 </div></li>
19808 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19809 <div class="thumb" style="height: 70px;">Nonexistent.jpg</div>
19810 <div class="gallerytext">
19811 </div>
19812 </div></li>
19813 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19814 <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>
19815 <div class="gallerytext">
19816 <p>some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
19817 </p>
19818 </div>
19819 </div></li>
19820 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19821 <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>
19822 <div class="gallerytext">
19823 </div>
19824 </div></li>
19825 <li class="gallerybox" style="width: 105px"><div style="width: 105px">
19826 <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>
19827 <div class="gallerytext">
19828 <p>blabla.
19829 </p>
19830 </div>
19831 </div></li>
19832 </ul>
19833
19834 !! html/parsoid
19835 <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"}}'>
19836 <li class="gallerycaption">Foo <a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a></li>
19837 <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>
19838 <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>
19839 <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>
19840 <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>
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 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>
19842 </ul>
19843 !! end
19844
19845 !! test
19846 Gallery with link that has fragment
19847 !! options
19848 parsoid={
19849 "modes": ["wt2html", "html2html"],
19850 "nativeGallery": true
19851 }
19852 !! wikitext
19853 <gallery>
19854 image:foobar.jpg|link=Main_Page
19855 image:foobar.jpg|link=Main_Page#section
19856 image:foobar.jpg|link=Main Page#section|caption
19857 </gallery>
19858 !! html/php
19859 <ul class="gallery mw-gallery-traditional">
19860 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19861 <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>
19862 <div class="gallerytext">
19863 </div>
19864 </div></li>
19865 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19866 <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>
19867 <div class="gallerytext">
19868 </div>
19869 </div></li>
19870 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19871 <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>
19872 <div class="gallerytext">
19873 <p>caption
19874 </p>
19875 </div>
19876 </div></li>
19877 </ul>
19878
19879 !! html/parsoid
19880 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19881 <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>
19882 <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>
19883 <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>
19884 </ul>
19885 !! end
19886
19887 ## Whoops, Parsoid shouldn't be parsing templates in the attribute caption!
19888 !! test
19889 Gallery with template inside caption
19890 !! options
19891 parsoid={
19892 "nativeGallery": true
19893 }
19894 !! wikitext
19895 <gallery caption="{{echo|hi}}">
19896 File:Foobar.jpg|{{echo|ho}}
19897 </gallery>
19898 !! html/php
19899 <ul class="gallery mw-gallery-traditional">
19900 <li class='gallerycaption'>{{echo|hi}}</li>
19901 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19902 <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>
19903 <div class="gallerytext">
19904 <p>ho
19905 </p>
19906 </div>
19907 </div></li>
19908 </ul>
19909
19910 !! html/parsoid
19911 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19912 <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>
19913 <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>
19914 </ul>
19915 !! end
19916
19917 !! test
19918 Gallery with wikitext inside caption
19919 !! options
19920 parsoid={
19921 "nativeGallery": true
19922 }
19923 !! wikitext
19924 <gallery>
19925 File:Foobar.jpg|alt=galleryalt|[[File:Foobar.jpg|alt=inneralt|20x20px|desc]]
19926 File:Foobar.jpg|alt=galleryalt|{{Test|unamedParam|alt=param}}
19927 </gallery>
19928 !! html/php
19929 <ul class="gallery mw-gallery-traditional">
19930 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19931 <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>
19932 <div class="gallerytext">
19933 <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>
19934 </p>
19935 </div>
19936 </div></li>
19937 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19938 <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>
19939 <div class="gallerytext">
19940 <p>This is a test template
19941 </p>
19942 </div>
19943 </div></li>
19944 </ul>
19945
19946 !! html/parsoid
19947 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt6" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
19948 <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>
19949 <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>
19950 </ul>
19951 !! end
19952
19953 !! test
19954 Gallery (with showfilename option)
19955 !! options
19956 parsoid={
19957 "nativeGallery": true
19958 }
19959 !! wikitext
19960 <gallery showfilename="">
19961 File:Nonexistent.jpg|caption
19962 File:Nonexistent.jpg
19963 File:Foobar.jpg|some '''caption''' [[Main Page]]
19964 File:Foobar.jpg
19965 </gallery>
19966 !! html/php
19967 <ul class="gallery mw-gallery-traditional">
19968 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19969 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
19970 <div class="gallerytext">
19971 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
19972 caption
19973 </p>
19974 </div>
19975 </div></li>
19976 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19977 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
19978 <div class="gallerytext">
19979 <p><a href="/wiki/File:Nonexistent.jpg" class="galleryfilename galleryfilename-truncate" title="File:Nonexistent.jpg">Nonexistent.jpg</a>
19980 </p>
19981 </div>
19982 </div></li>
19983 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19984 <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>
19985 <div class="gallerytext">
19986 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
19987 some <b>caption</b> <a href="/wiki/Main_Page" title="Main Page">Main Page</a>
19988 </p>
19989 </div>
19990 </div></li>
19991 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
19992 <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>
19993 <div class="gallerytext">
19994 <p><a href="/wiki/File:Foobar.jpg" class="galleryfilename galleryfilename-truncate" title="File:Foobar.jpg">Foobar.jpg</a>
19995 </p>
19996 </div>
19997 </div></li>
19998 </ul>
19999
20000 !! html/parsoid
20001 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt3" data-mw='{"name":"gallery","attrs":{"showfilename":""},"body":{}}'>
20002 <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>
20003 <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>
20004 <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>
20005 <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>
20006 </ul>
20007 !! end
20008
20009 ## Should Parsoid be preserving these variations?
20010 !! test
20011 Gallery (with namespace-less filenames)
20012 !! options
20013 parsoid={
20014 "modes": ["wt2html", "html2html"],
20015 "nativeGallery": true
20016 }
20017 !! wikitext
20018 <gallery>
20019 File:Nonexistent.jpg
20020 Nonexistent.jpg
20021 image:foobar.jpg
20022 foobar.jpg
20023 </gallery>
20024 !! html/php
20025 <ul class="gallery mw-gallery-traditional">
20026 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20027 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20028 <div class="gallerytext">
20029 </div>
20030 </div></li>
20031 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20032 <div class="thumb" style="height: 150px;">Nonexistent.jpg</div>
20033 <div class="gallerytext">
20034 </div>
20035 </div></li>
20036 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20037 <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>
20038 <div class="gallerytext">
20039 </div>
20040 </div></li>
20041 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20042 <div class="thumb" style="width: 150px;"><div style="margin:68px auto;"><a href="/wiki/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>
20043 <div class="gallerytext">
20044 </div>
20045 </div></li>
20046 </ul>
20047
20048 !! html/parsoid
20049 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20050 <li class="gallerybox" style="width: 155px;"><div class="thumb" style="width: 150px; height: 150px;"><span style="display: inline-block; height: 100%; vertical-align: middle;"></span><span style="vertical-align: middle; display: inline-block;">File:Nonexistent.jpg</span></div><div class="gallerytext"></div></li>
20051 <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>
20052 <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>
20053 <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>
20054 </ul>
20055 !! end
20056
20057 !! test
20058 Gallery override link with WikiLink (T36852)
20059 !! options
20060 parsoid={
20061 "nativeGallery": true
20062 }
20063 !! wikitext
20064 <gallery>
20065 File:Foobar.jpg|alt=galleryalt|link=InterWikiLink
20066 </gallery>
20067 !! html/php
20068 <ul class="gallery mw-gallery-traditional">
20069 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20070 <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>
20071 <div class="gallerytext">
20072 </div>
20073 </div></li>
20074 </ul>
20075
20076 !! html/parsoid
20077 <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":{}}'>
20078 <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>
20079 </ul>
20080 !! end
20081
20082 !! test
20083 Gallery override link with absolute external link (T36852)
20084 !! options
20085 parsoid={
20086 "nativeGallery": true
20087 }
20088 !! wikitext
20089 <gallery>
20090 File:Foobar.jpg|alt=galleryalt|link=http://www.example.org
20091 </gallery>
20092 !! html/php
20093 <ul class="gallery mw-gallery-traditional">
20094 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20095 <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>
20096 <div class="gallerytext">
20097 </div>
20098 </div></li>
20099 </ul>
20100
20101 !! html/parsoid
20102 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20103 <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>
20104 </ul>
20105 !! end
20106
20107 !! test
20108 Gallery override link with absolute external link with LanguageConverter
20109 !! options
20110 language=zh
20111 !! input
20112 <gallery>
20113 File:foobar.jpg|caption|alt=galleryalt|link=http://www.example.org
20114 </gallery>
20115 !! result
20116 <ul class="gallery mw-gallery-traditional">
20117 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20118 <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>
20119 <div class="gallerytext">
20120 <p>caption
20121 </p>
20122 </div>
20123 </div></li>
20124 </ul>
20125
20126 !! end
20127
20128 !! test
20129 Gallery override link with malicious javascript (T36852)
20130 !! options
20131 parsoid={
20132 "modes": ["wt2html", "html2html"],
20133 "nativeGallery": true
20134 }
20135 !! wikitext
20136 <gallery>
20137 File:Foobar.jpg|alt=galleryalt|link=" onclick="alert('malicious javascript code!');
20138 </gallery>
20139 !! html/php
20140 <ul class="gallery mw-gallery-traditional">
20141 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20142 <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>
20143 <div class="gallerytext">
20144 </div>
20145 </div></li>
20146 </ul>
20147
20148 !! html/parsoid
20149 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20150 <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>
20151 </ul>
20152 !! end
20153
20154 !! test
20155 Gallery with invalid title as link (T45964)
20156 !! options
20157 parsoid={
20158 "modes": ["wt2html", "html2html"],
20159 "nativeGallery": true
20160 }
20161 !! wikitext
20162 <gallery>
20163 File:Foobar.jpg|link=<
20164 </gallery>
20165 !! html/php
20166 <ul class="gallery mw-gallery-traditional">
20167 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20168 <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>
20169 <div class="gallerytext">
20170 </div>
20171 </div></li>
20172 </ul>
20173
20174 !! html/parsoid
20175 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{},"body":{}}'>
20176 <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>
20177 </ul>
20178 !! end
20179
20180 !! test
20181 Serialize gallery without attrs in data-mw
20182 !! options
20183 parsoid={
20184 "modes": ["html2wt"],
20185 "nativeGallery": true
20186 }
20187 !! html/parsoid
20188 <ul class="gallery mw-gallery-traditional" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","body":{}}'>
20189 <li class="gallerycaption">123</li>
20190 <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>
20191 </ul>
20192 !! wikitext
20193 <gallery caption="123">
20194 File:Test.png
20195 </gallery>
20196 !! end
20197
20198 !! test
20199 Gallery with class and style attributes
20200 !! options
20201 parsoid={
20202 "nativeGallery": true
20203 }
20204 !! wikitext
20205 <gallery class="center" style="text-align: center;">
20206 File:Foobar.jpg
20207 </gallery>
20208 !! html/php
20209 <ul class="gallery mw-gallery-traditional center" style="text-align: center;">
20210 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20211 <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>
20212 <div class="gallerytext">
20213 </div>
20214 </div></li>
20215 </ul>
20216
20217 !! html/parsoid
20218 <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":{}}'>
20219 <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>
20220 </ul>
20221 !! end
20222
20223 !! test
20224 Gallery in slideshow mode
20225 !! options
20226 parsoid={
20227 "nativeGallery": true
20228 }
20229 !! wikitext
20230 <gallery mode="slideshow" showthumbnails="">
20231 File:Foobar.jpg
20232 </gallery>
20233 !! html/php
20234 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1">
20235 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
20236 <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>
20237 <div class="gallerytext">
20238 </div>
20239 </div></li>
20240 </ul>
20241
20242 !! html/parsoid
20243 <ul class="gallery mw-gallery-slideshow" data-showthumbnails="1" typeof="mw:Extension/gallery" about="#mwt2" data-mw='{"name":"gallery","attrs":{"mode":"slideshow","showthumbnails":""},"body":{}}'>
20244 <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>
20245 </ul>
20246 !! end
20247
20248 !! test
20249 HTML Hex character encoding (spells the word "JavaScript")
20250 !! options
20251 parsoid=wt2html,wt2wt,html2html
20252 !! wikitext
20253 &#x4A;&#x061;&#x0076;&#x00061;&#x000053;&#x0000063;&#114;&#x0000069;&#00000112;&#x0000000074;
20254 !! html/php
20255 <p>&#x4a;&#x61;&#x76;&#x61;&#x53;&#x63;&#114;&#x69;&#112;&#x74;
20256 </p>
20257 !! html/php+tidy
20258 <p>JavaScript</p>
20259 !! html/parsoid
20260 <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>
20261 !! end
20262
20263 !! test
20264 HTML Hex character encoding bogus encoding (T28437 regression check)
20265 !! wikitext
20266 &#xsee;&#XSEE;
20267 !! html/php
20268 <p>&amp;#xsee;&amp;#XSEE;
20269 </p>
20270 !! html/parsoid
20271 <p>&amp;#xsee;&amp;#XSEE;</p>
20272 !! end
20273
20274 !! test
20275 HTML Hex character encoding mixed case
20276 !! options
20277 parsoid=wt2html,wt2wt,html2html
20278 !! wikitext
20279 &#xEE;&#Xee;
20280 !! html/php
20281 <p>&#xee;&#xee;
20282 </p>
20283 !! html/php+tidy
20284 <p>îî</p>
20285 !! html/parsoid
20286 <p><span typeof="mw:Entity">î</span><span typeof="mw:Entity">î</span></p>
20287 !! end
20288
20289 # See: https://www.w3.org/TR/html5/syntax.html#character-references
20290 # Note that U+000C (form feed) is not a valid XML character, so
20291 # it is banned even though allowed in HTML5.
20292 !! test
20293 Illegal character references (T106578)
20294 !! wikitext
20295 ; Null: &#00;
20296 ; FF: &#xC;
20297 ; CR: &#xD;
20298 ; Control (low): &#8;
20299 ; Control (high): &#x7F; &#x9F;
20300 ; Surrogate: &#xD83D;&#xDCA9;
20301 ; This is an okay astral character: &#x1F4A9;
20302 !! html+tidy
20303 <dl>
20304 <dt>Null</dt>
20305 <dd>&amp;#00;</dd>
20306 <dt>FF</dt>
20307 <dd>&amp;#xC;</dd>
20308 <dt>CR</dt>
20309 <dd>&amp;#xD;</dd>
20310 <dt>Control (low)</dt>
20311 <dd>&amp;#8;</dd>
20312 <dt>Control (high)</dt>
20313 <dd>&amp;#x7F; &amp;#x9F;</dd>
20314 <dt>Surrogate</dt>
20315 <dd>&amp;#xD83D;&amp;#xDCA9;</dd>
20316 <dt>This is an okay astral character</dt>
20317 <dd>💩</dd>
20318 </dl>
20319 !! end
20320
20321 !! test
20322 __FORCETOC__ override
20323 !! wikitext
20324 __NEWSECTIONLINK__
20325 __FORCETOC__
20326 !! html/php
20327 <p><br />
20328 </p>
20329 !! end
20330
20331 !! test
20332 ISBN code coverage
20333 !! wikitext
20334 ISBN 978-0-1234-56&#x20;789
20335 !! html
20336 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a>&#x20;789
20337 </p>
20338 !! html+tidy
20339 <p><a href="/wiki/Special:BookSources/9780123456" class="internal mw-magiclink-isbn">ISBN 978-0-1234-56</a> 789</p>
20340 !! html/parsoid
20341 <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>
20342 !! end
20343
20344 !! test
20345 ISBN followed by 5 spaces
20346 !! wikitext
20347 ISBN
20348 !! html
20349 <p>ISBN
20350 </p>
20351 !! end
20352
20353 !! test
20354 Double ISBN
20355 !! wikitext
20356 ISBN ISBN 1234567890
20357 !! html/php
20358 <p>ISBN <a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20359 </p>
20360 !! html/parsoid
20361 <p>ISBN <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
20362 !! end
20363
20364 # Uppercase X and lowercase x as well
20365 !! test
20366 ISBN with an X
20367 !! wikitext
20368 ISBN 3-462-04561-X
20369 ISBN 3-462-04561-x
20370 ISBN 080442957X
20371 ISBN 080442957x
20372 ISBN 978080442957X
20373 ISBN 978080442957x
20374 !! html/php
20375 <p><a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-X</a>
20376 <a href="/wiki/Special:BookSources/346204561X" class="internal mw-magiclink-isbn">ISBN 3-462-04561-x</a>
20377 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957X</a>
20378 <a href="/wiki/Special:BookSources/080442957X" class="internal mw-magiclink-isbn">ISBN 080442957x</a>
20379 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957X</a>
20380 <a href="/wiki/Special:BookSources/978080442957X" class="internal mw-magiclink-isbn">ISBN 978080442957x</a>
20381 </p>
20382 !! html/parsoid
20383 <p><a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-X</a>
20384 <a href="./Special:BookSources/346204561X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 3-462-04561-x</a>
20385 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957X</a>
20386 <a href="./Special:BookSources/080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 080442957x</a>
20387 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957X</a>
20388 <a href="./Special:BookSources/978080442957X" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 978080442957x</a></p>
20389 !! end
20390
20391 !! test
20392 ISBN with empty prefix (parsoid test)
20393 !! wikitext
20394 ISBN 1234567890
20395 !! html/php
20396 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20397 </p>
20398 !! html/parsoid
20399 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink">ISBN 1234567890</a></p>
20400 !! end
20401
20402 !! test
20403 T24905: <abbr> followed by ISBN followed by </a>
20404 !! wikitext
20405 <abbr>(fr)</abbr> ISBN 2753300917 [http://www.example.com example.com]
20406 !! html/php
20407 <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>
20408 </p>
20409 !! html/parsoid
20410 <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>
20411 !! end
20412
20413 !! test
20414 Double RFC
20415 !! wikitext
20416 RFC RFC 1234
20417 !! html
20418 <p>RFC <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a>
20419 </p>
20420 !! end
20421
20422 !! test
20423 Double RFC with a wiki link
20424 !! wikitext
20425 RFC [[RFC 1234]]
20426 !! html
20427 <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>
20428 </p>
20429 !! end
20430
20431 !! test
20432 RFC code coverage
20433 !! wikitext
20434 RFC 983&#x20;987
20435 !! html
20436 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a>&#x20;987
20437 </p>
20438 !! html+tidy
20439 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc983">RFC 983</a> 987</p>
20440 !! end
20441
20442 !! test
20443 Centre-aligned image
20444 !! wikitext
20445 [[Image:foobar.jpg|centre]]
20446 !! html
20447 <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>
20448
20449 !!end
20450
20451 !! test
20452 None-aligned image
20453 !! wikitext
20454 [[Image:foobar.jpg|none]]
20455 !! html
20456 <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>
20457
20458 !!end
20459
20460 !! test
20461 Width + Height sized image (using px) (height is ignored)
20462 !! wikitext
20463 [[Image:foobar.jpg|640x480px]]
20464 !! html
20465 <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>
20466 </p>
20467 !!end
20468
20469 !! test
20470 Width-sized image (using px, no following whitespace)
20471 !! wikitext
20472 [[Image:foobar.jpg|640px]]
20473 !! html
20474 <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>
20475 </p>
20476 !!end
20477
20478 !! test
20479 Width-sized image (using px, with following whitespace - test regression from r39467)
20480 !! wikitext
20481 [[Image:foobar.jpg|640px ]]
20482 !! html
20483 <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>
20484 </p>
20485 !!end
20486
20487 !! test
20488 Width-sized image (using px, with preceding whitespace - test regression from r39467)
20489 !! wikitext
20490 [[Image:foobar.jpg| 640px]]
20491 !! html
20492 <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>
20493 </p>
20494 !!end
20495
20496 !! test
20497 Image with page parameter
20498 !! options
20499 djvu
20500 !! wikitext
20501 [[File:LoremIpsum.djvu|page=2]]
20502 !! html/php
20503 <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>
20504 </p>
20505 !! html/parsoid
20506 <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>
20507 !! end
20508
20509 !! test
20510 Another italics / bold test
20511 !! wikitext
20512 ''' ''x'
20513 !! html
20514 <pre>'<i> </i>x'
20515 </pre>
20516 !!end
20517
20518 # FIXME: The php output seems broken. It's interleaving some open/close tags.
20519 !! test
20520 dt/dd/dl test
20521 !! wikitext
20522 :;;;::
20523 !! html/php
20524 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dt></dl></dd></dl></dd></dl></dd></dl></dd></dl></dd></dl>
20525
20526 !! html/parsoid
20527 <dl><dd><dl><dt><dl><dt><dl><dt><dl><dd><dl><dd></dd></dl></dd></dl></dt></dl></dt></dl></dt></dl></dd></dl>
20528
20529 !!end
20530
20531 # Images with the "|" character in external URLs in comment tags; Eats half the comment, leaves unmatched "</a>" tag.
20532 !! test
20533 Images with the "|" character in the comment
20534 !! wikitext
20535 [[File:Foobar.jpg|thumb|An [http://test/?param1=|left|&param2=|x external] URL]]
20536 !! html/php
20537 <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>
20538
20539 !! html/parsoid
20540 <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>
20541 !! end
20542
20543 !! test
20544 [Before] HTML without raw HTML enabled ($wgRawHtml==false)
20545 !! wikitext
20546 <html><script>alert(1);</script></html>
20547 !! html
20548 <p>&lt;html&gt;&lt;script&gt;alert(1);&lt;/script&gt;&lt;/html&gt;
20549 </p>
20550 !! end
20551
20552 !! test
20553 HTML with raw HTML ($wgRawHtml==true)
20554 !! options
20555 wgRawHtml=1
20556 !! wikitext
20557 <html><script>alert(1);</script></html>
20558 !! html
20559 <p><script>alert(1);</script>
20560 </p>
20561 !! end
20562
20563 !! test
20564 Parents of subpages, one level up
20565 !! options
20566 subpage title=[[Subpage test/L1/L2/L3]]
20567 !! wikitext
20568 [[../|L2]]
20569 !! html
20570 <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>
20571 </p>
20572 !! end
20573
20574
20575 !! test
20576 Parents of subpages, one level up, not named
20577 !! options
20578 subpage title=[[Subpage test/L1/L2/L3]]
20579 !! wikitext
20580 [[../]]
20581 !! html
20582 <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>
20583 </p>
20584 !! end
20585
20586
20587
20588 !! test
20589 Parents of subpages, two levels up
20590 !! options
20591 subpage title=[[Subpage test/L1/L2/L3]]
20592 !! wikitext
20593 [[../../|L1]]2
20594
20595 [[../../|L1]]l
20596 !! html
20597 <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
20598 </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>
20599 </p>
20600 !! end
20601
20602 !! test
20603 Parents of subpages, two levels up, without trailing slash or name.
20604 !! options
20605 subpage title=[[Subpage test/L1/L2/L3]]
20606 !! wikitext
20607 [[../..]]
20608 !! html
20609 <p>[[../..]]
20610 </p>
20611 !! end
20612
20613 !! test
20614 Parents of subpages, two levels up, with lots of extra trailing slashes.
20615 !! options
20616 subpage title=[[Subpage test/L1/L2/L3]]
20617 !! wikitext
20618 [[../../////]]
20619 !! html
20620 <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>
20621 </p>
20622 !! end
20623
20624 !! article
20625 Subpage test/L1/L2/L3Sibling
20626 !! text
20627 Sibling article
20628 !! endarticle
20629
20630 !! test
20631 Transclusion of a sibling page (one level up)
20632 !! options
20633 subpage title=[[Subpage test/L1/L2/L3]]
20634 !! wikitext
20635 {{../L3Sibling}}
20636 !! html
20637 <p>Sibling article
20638 </p>
20639 !! end
20640
20641 !! test
20642 Transclusion of a child page
20643 !! options
20644 subpage title=[[Subpage test/L1/L2]]
20645 !! wikitext
20646 {{/L3Sibling}}
20647 !! html
20648 <p>Sibling article
20649 </p>
20650 !! end
20651
20652 # This is wt2html only in Parsoid because we add <nowiki>
20653 # because of {{..}} and we don't expect to fix that to
20654 # eliminate the nowikis selective for {{..}} markup.
20655 !! test
20656 Non-transclusion because of too many up levels
20657 !! options
20658 subpage title=[[Subpage test/L1/L2/L3]]
20659 parsoid=wt2html
20660 !! wikitext
20661 {{../../../../More than parent}}
20662 !! html/php
20663 <p>{{../../../../More than parent}}
20664 </p>
20665 !! html/parsoid
20666 <p>{{../../../../More than parent}}</p>
20667 !! end
20668
20669 !! test
20670 Definition list code coverage
20671 !! wikitext
20672 ; title : def
20673 ; title : def
20674 ;title: def
20675 !! html/php
20676 <dl><dt> title &#160;</dt>
20677 <dd> def</dd>
20678 <dt> title&#160;</dt>
20679 <dd> def</dd>
20680 <dt>title</dt>
20681 <dd> def</dd></dl>
20682
20683 !! html/parsoid
20684 <dl><dt> title <span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
20685 <dt> title<span typeof="mw:Placeholder"> </span></dt><dd> def</dd>
20686 <dt>title</dt><dd> def</dd></dl>
20687 !! end
20688
20689 !! test
20690 Don't fall for the self-closing div
20691 !! wikitext
20692 <div>hello world</div/>
20693 !! html
20694 <div>hello world</div>
20695
20696 !! end
20697
20698 !! test
20699 MSGNW magic word
20700 !! wikitext
20701 {{MSGNW:msg}}
20702 !! html/php
20703 <p>&#91;&#91;:Template:Msg&#93;&#93;
20704 </p>
20705 !! end
20706
20707 !! test
20708 RAW magic word
20709 !! wikitext
20710 {{RAW:QUERTY}}
20711 !! html
20712 <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>
20713 </p>
20714 !! end
20715
20716 # This isn't needed for XHTML conformance, but would be handy as a fallback security measure
20717 !! test
20718 Always escape literal '>' in output, not just after '<'
20719 !! wikitext
20720 ><>
20721 !! html
20722 <p>&gt;&lt;&gt;
20723 </p>
20724 !! end
20725
20726 !! test
20727 Template caching
20728 !! wikitext
20729 {{Test}}
20730 {{Test}}
20731 !! html
20732 <p>This is a test template
20733 This is a test template
20734 </p>
20735 !! end
20736
20737
20738 !! article
20739 MediaWiki:Fake
20740 !! text
20741 ==header==
20742 !! endarticle
20743
20744 !! test
20745 Inclusion of !userCanEdit() content
20746 !! wikitext
20747 {{MediaWiki:Fake}}
20748 !! html
20749 <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>
20750
20751 !! end
20752
20753
20754 !! test
20755 Out-of-order TOC heading levels
20756 !! wikitext
20757 ==2==
20758 ======6======
20759 ===3===
20760 =1=
20761 =====5=====
20762 ==2==
20763 !! html
20764 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
20765 <ul>
20766 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
20767 <ul>
20768 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
20769 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
20770 </ul>
20771 </li>
20772 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
20773 <ul>
20774 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
20775 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
20776 </ul>
20777 </li>
20778 </ul>
20779 </div>
20780
20781 <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>
20782 <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>
20783 <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>
20784 <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>
20785 <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>
20786 <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>
20787
20788 !! end
20789
20790
20791 !! test
20792 ISBN with a dummy number
20793 !! wikitext
20794 ISBN ---
20795 !! html
20796 <p>ISBN ---
20797 </p>
20798 !! end
20799
20800
20801 !! test
20802 ISBN with space-delimited number
20803 !! wikitext
20804 ISBN 92 9017 032 8
20805 !! html/php
20806 <p><a href="/wiki/Special:BookSources/9290170328" class="internal mw-magiclink-isbn">ISBN 92 9017 032 8</a>
20807 </p>
20808 !! html/parsoid
20809 <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>
20810 !! end
20811
20812
20813 !! test
20814 ISBN with multiple spaces, no number
20815 !! wikitext
20816 ISBN foo
20817 !! html
20818 <p>ISBN foo
20819 </p>
20820 !! end
20821
20822
20823 !! test
20824 ISBN length
20825 !! wikitext
20826 ISBN 123456789
20827
20828 ISBN 1234567890
20829
20830 ISBN 12345678901
20831 !! html/php
20832 <p>ISBN 123456789
20833 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>
20834 </p><p>ISBN 12345678901
20835 </p>
20836 !! html/parsoid
20837 <p>ISBN 123456789</p>
20838
20839 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a></p>
20840
20841 <p>ISBN 12345678901</p>
20842 !! end
20843
20844
20845 !! test
20846 ISBN with trailing year (T9110)
20847 !! wikitext
20848 ISBN 1-234-56789-0 - 2006
20849
20850 ISBN 1 234 56789 0 - 2006
20851 !! html/php
20852 <p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1-234-56789-0</a> - 2006
20853 </p><p><a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1 234 56789 0</a> - 2006
20854 </p>
20855 !! html/parsoid
20856 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1-234-56789-0</a> - 2006</p>
20857
20858 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1 234 56789 0</a> - 2006</p>
20859 !! end
20860
20861
20862 !! test
20863 anchorencode
20864 !! wikitext
20865 {{anchorencode:foo bar©#%n}}
20866 !! html
20867 <p>foo_bar.C2.A9.23.25n
20868 </p>
20869 !! end
20870
20871 !! test
20872 anchorencode trims spaces
20873 !! wikitext
20874 {{anchorencode: __pretty__please__}}
20875 !! html
20876 <p>pretty_please
20877 </p>
20878 !! end
20879
20880 !! test
20881 anchorencode deals with links
20882 !! wikitext
20883 {{anchorencode: [[hello|world]] [[hi]]}}
20884 !! html
20885 <p>world_hi
20886 </p>
20887 !! end
20888
20889 !! test
20890 anchorencode deals with templates
20891 !! wikitext
20892 {{anchorencode: {{Foo}} }}
20893 !! html
20894 <p>FOO
20895 </p>
20896 !! end
20897
20898 !! test
20899 anchorencode encodes like the TOC generator: (T20431)
20900 !! wikitext
20901 === _ +:.3A%3A&&amp;]] ===
20902 {{anchorencode: _ +:.3A%3A&&amp;]] }}
20903 __NOEDITSECTION__
20904 !! html
20905 <h3><span class="mw-headline" id=".2B:.3A.253A.26.26.5D.5D">_ +:.3A%3A&amp;&amp;]]</span></h3>
20906 <p>.2B:.3A.253A.26.26.5D.5D
20907 </p>
20908 !! end
20909
20910 !! test
20911 T8200: blockquotes and paragraph formatting
20912 !! wikitext
20913 <blockquote>
20914 foo
20915 </blockquote>
20916
20917 bar
20918
20919 baz
20920 !! html
20921 <blockquote>
20922 <p>foo
20923 </p>
20924 </blockquote>
20925 <p>bar
20926 </p>
20927 <pre>baz
20928 </pre>
20929 !! end
20930
20931 !! test
20932 T10293: Use of center tag ruins paragraph formatting
20933 !! wikitext
20934 <center>
20935 foo
20936 </center>
20937
20938 bar
20939
20940 baz
20941 !! html
20942 <center>
20943 <p>foo
20944 </p>
20945 </center>
20946 <p>bar
20947 </p>
20948 <pre>baz
20949 </pre>
20950 !! end
20951
20952 !!test
20953 Parsing of overlapping (improperly nested) inline html tags
20954 !! wikitext
20955 <span><s>x</span></s>
20956 !! html/php
20957 <p><span><s>x&lt;/span&gt;</s></span>
20958 </p>
20959 !! html/parsoid
20960 <p><span><s>x</s></span>
20961 </p>
20962 !!end
20963
20964 ###
20965 ### Language variants related tests
20966 ###
20967 !! test
20968 Self-link in language variants
20969 !! options
20970 title=[[Dunav]] language=sr
20971 !! wikitext
20972 Both [[Dunav]] and [[Дунав]] are names for this river.
20973 !! html
20974 <p>Both <a class="mw-selflink selflink">Dunav</a> and <a class="mw-selflink selflink">Дунав</a> are names for this river.
20975 </p>
20976 !!end
20977
20978 !! article
20979 Дуна
20980 !! text
20981 content
20982 !! endarticle
20983
20984 !! test
20985 Link to another existing title shouldn't be parsed as self-link even if it's a variant of this title
20986 !! options
20987 title=[[Duna]] language=sr
20988 !! wikitext
20989 [[Дуна]] is not a self-link while [[Duna]] and [[Dуна]] are still self-links.
20990 !! html
20991 <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.
20992 </p>
20993 !! end
20994
20995 !! test
20996 Link to a section of a variant of this title shouldn't be parsed as self-link
20997 !! options
20998 title=[[Duna]] language=sr
20999 !! wikitext
21000 [[Dуна]] is a self-link while [[Dunа#Foo]] and [[Dуна#Foo]] are not self-links.
21001 !! html
21002 <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.
21003 </p>
21004 !! end
21005
21006 !! test
21007 Link to pages in language variants
21008 !! options
21009 language=sr
21010 !! wikitext
21011 Main Page can be written as [[Маин Паге]]
21012 !! html
21013 <p>Main Page can be written as <a href="/wiki/Main_Page" title="Main Page">Маин Паге</a>
21014 </p>
21015 !!end
21016
21017
21018 !! test
21019 Multiple links to pages in language variants
21020 !! options
21021 language=sr
21022 !! wikitext
21023 [[Main Page]] can be written as [[Маин Паге]] same as [[Маин Паге]].
21024 !! html
21025 <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>.
21026 </p>
21027 !!end
21028
21029
21030 !! test
21031 Simple template in language variants
21032 !! options
21033 language=sr
21034 !! wikitext
21035 {{тест}}
21036 !! html
21037 <p>This is a test template
21038 </p>
21039 !! end
21040
21041
21042 !! test
21043 Template with explicit namespace in language variants
21044 !! options
21045 language=sr
21046 !! wikitext
21047 {{Template:тест}}
21048 !! html
21049 <p>This is a test template
21050 </p>
21051 !! end
21052
21053
21054 !! test
21055 Basic test for template parameter in language variants
21056 !! options
21057 language=sr
21058 !! wikitext
21059 {{парамтест|param=foo}}
21060 !! html
21061 <p>This is a test template with parameter foo
21062 </p>
21063 !! end
21064
21065 !! test
21066 Simple category in language variants
21067 !! options
21068 language=sr cat
21069 !! wikitext
21070 [[Category:МедиаWики Усер'с Гуиде]]
21071 !! html/php
21072 cat=МедиаWики_Усер'с_Гуиде sort=
21073 !! html/parsoid
21074 <link rel="mw:PageProp/Category" href="./Категорија:МедиаWики_Усер'с_Гуиде" data-parsoid='{"stx":"simple","a":{"href":"./Категорија:МедиаWики_Усер&#39;с_Гуиде"},"sa":{"href":"Category:МедиаWики Усер&#39;с Гуиде"}}'/>
21075 !! end
21076
21077 !! article
21078 Category:分类
21079 !! text
21080 blah
21081 !! endarticle
21082
21083 !! article
21084 Category:分類
21085 !! text
21086 blah
21087 !! endarticle
21088
21089 ## We used to, but no longer wt2wt this test since the default serializer
21090 ## will normalize all categories to serialize on their own line.
21091 ## This wikitext usage is going to be fairly uncommon in production and
21092 ## selser will take care of preserving formatting in those scenarios.
21093 !! test
21094 Don't convert blue categorylinks to another variant (T35210)
21095 !! options
21096 cat
21097 language=zh
21098 parsoid=wt2html
21099 !! wikitext
21100 [[A]][[Category:分类]]
21101 !! html/php
21102 cat=分类 sort=
21103 !! html/parsoid
21104 <p><a rel="mw:WikiLink" href="./A" title="A">A</a></p>
21105 <link rel="mw:PageProp/Category" href="./Category:分类"/>
21106 !! end
21107
21108 !! test
21109 Stripping -{}- tags (language variants)
21110 !! options
21111 language=sr
21112 !! wikitext
21113 Latin proverb: -{Ne nuntium necare}-
21114 !! html
21115 <p>Latin proverb: Ne nuntium necare
21116 </p>
21117 !! end
21118
21119
21120 !! test
21121 Prevent conversion with -{}- tags (language variants)
21122 !! options
21123 language=sr variant=sr-ec
21124 !! wikitext
21125 Latinski: -{Ne nuntium necare}-
21126 !! html
21127 <p>Латински: Ne nuntium necare
21128 </p>
21129 !! end
21130
21131
21132 !! test
21133 Prevent conversion of text with -{}- tags (language variants)
21134 !! options
21135 language=sr variant=sr-ec
21136 !! wikitext
21137 Latinski: -{Ne nuntium necare}-
21138 !! html
21139 <p>Латински: Ne nuntium necare
21140 </p>
21141 !! end
21142
21143
21144 !! test
21145 Prevent conversion of links with -{}- tags (language variants)
21146 !! options
21147 language=sr variant=sr-ec
21148 !! wikitext
21149 -{[[Main Page]]}-
21150 !! html
21151 <p><a href="/wiki/Main_Page" title="Main Page">Main Page</a>
21152 </p>
21153 !! end
21154
21155
21156 !! test
21157 -{}- tags within headlines (within html for parserConvert())
21158 !! options
21159 language=sr variant=sr-ec
21160 !! wikitext
21161 == -{Naslov}- ==
21162 !! html
21163 <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>
21164
21165 !! end
21166
21167
21168 !! test
21169 Explicit definition of language variant alternatives
21170 !! options
21171 language=zh variant=zh-tw
21172 !! wikitext
21173 -{zh:China;zh-tw:Taiwan}-, not China
21174 !! html
21175 <p>Taiwan, not China
21176 </p>
21177 !! end
21178
21179
21180 !! test
21181 Conversion around HTML tags
21182 !! options
21183 language=sr variant=sr-ec
21184 !! wikitext
21185 -{H|span=>sr-ec:script;title=>sr-ec:src;}-
21186 <span title="La-{sr-el:L;sr-ec:C;}-tin">ski</span>
21187 !! html
21188 <p>
21189 <span title="ЛаCтин">ски</span>
21190 </p>
21191 !! end
21192
21193
21194 !! test
21195 Explicit session-wise language variant mapping (A flag and - flag)
21196 !! options
21197 language=zh variant=zh-tw
21198 !! wikitext
21199 Taiwan is not China.
21200 But -{A|zh:China;zh-tw:Taiwan}- is China,
21201 (This-{-|zh:China;zh-tw:Taiwan}- should be stripped!)
21202 and -{China}- is China.
21203 !! html
21204 <p>Taiwan is not China.
21205 But Taiwan is Taiwan,
21206 (This should be stripped!)
21207 and China is China.
21208 </p>
21209 !! end
21210
21211 !! test
21212 Explicit session-wise language variant mapping (H flag for hide)
21213 !! options
21214 language=zh variant=zh-tw
21215 !! wikitext
21216 (This-{H|zh:China;zh-tw:Taiwan}- should be stripped!)
21217 Taiwan is China.
21218 !! html
21219 <p>(This should be stripped!)
21220 Taiwan is Taiwan.
21221 </p>
21222 !! end
21223
21224 !! test
21225 Adding explicit conversion rule for title (T flag)
21226 !! options
21227 language=zh variant=zh-tw showtitle
21228 !! wikitext
21229 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
21230 !! html
21231 Taiwan
21232 <p>Should be stripped!
21233 </p>
21234 !! end
21235
21236 !! test
21237 Testing that changing the language variant here in the tests actually works
21238 !! options
21239 language=zh variant=zh showtitle
21240 !! wikitext
21241 Should be stripped-{T|zh:China;zh-tw:Taiwan}-!
21242 !! html
21243 China
21244 <p>Should be stripped!
21245 </p>
21246 !! end
21247
21248 !! test
21249 Recursive conversion of alt and title attrs shouldn't clear converter state
21250 !! options
21251 language=zh variant=zh-cn showtitle
21252 !! wikitext
21253 -{H|zh-cn:Exclamation;zh-tw:exclamation;}-
21254 Should be stripped-{T|zh-cn:China;zh-tw:Taiwan}-<span title="exclamation">!</span>
21255 !! html
21256 China
21257 <p>
21258 Should be stripped<span title="Exclamation">!</span>
21259 </p>
21260 !! end
21261
21262 !! test
21263 T26072: more test on conversion rule for title
21264 !! options
21265 language=zh variant=zh-tw showtitle
21266 !! wikitext
21267 This should be stripped-{T|zh:China;zh-tw:Taiwan}-!
21268 This won't take interferes with the title rule-{H|zh:Beijing;zh-tw:Taipei}-.
21269 !! html
21270 Taiwan
21271 <p>This should be stripped!
21272 This won't take interferes with the title rule.
21273 </p>
21274 !! end
21275
21276 !! test
21277 Partly disable title conversion if variant == main language code
21278 !! options
21279 language=zh variant=zh title=[[ZH]] showtitle
21280 !! wikitext
21281 -{T|zh-cn:CN;zh-tw:TW}-
21282 !! html
21283 ZH
21284 <p>
21285 </p>
21286 !! end
21287
21288 !! test
21289 Partly disable title conversion if variant == main language code, more
21290 !! options
21291 language=zh variant=zh title=[[ZH]] showtitle
21292 !! wikitext
21293 -{T|TW}-
21294 !! html
21295 ZH
21296 <p>
21297 </p>
21298 !! end
21299
21300 !! test
21301 Raw output of variant escape tags (R flag)
21302 !! options
21303 language=zh variant=zh-tw
21304 !! wikitext
21305 Raw: -{R|zh:China;zh-tw:Taiwan}-
21306 !! html
21307 <p>Raw: zh:China;zh-tw:Taiwan
21308 </p>
21309 !! end
21310
21311 !! test
21312 Nested markup inside raw output of variant escape tags (R flag)
21313 !! options
21314 language=zh variant=zh-tw
21315 !! wikitext
21316 Nested raw: -{R|nested -{zh:China;zh-tw:Taiwan}- nested}-
21317 !! html
21318 <p>Nested raw: nested Taiwan nested
21319 </p>
21320 !! end
21321
21322 !! test
21323 Templates inside raw output of variant escape tags (R flag)
21324 !! options
21325 language=zh variant=zh-tw
21326 !! wikitext
21327 Nested raw: -{R|nested {{echo|hi}} templates}-
21328 !! html
21329 <p>Nested raw: nested hi templates
21330 </p>
21331 !! end
21332
21333 !! test
21334 Strings evaluating false shouldn't be ignored by Language converter (T51072)
21335 !! options
21336 language=zh variant=zh-cn
21337 !! input
21338 -{zh-cn:0;zh-sg:1;zh-tw:2;zh-hk:3}-
21339 !! result
21340 <p>0
21341 </p>
21342 !! end
21343
21344 !! test
21345 Conversion rules from [numeric-only string] to [something else] (T48634)
21346 !! options
21347 language=zh variant=zh-cn
21348 !! input
21349 -{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
21350 !! result
21351 <p>D12345EE12345
21352 </p>
21353 !! end
21354
21355 !! test
21356 Bidirectional converter rule entries with an empty value should be ignored (T53551)
21357 !! options
21358 language=zh variant=zh-cn
21359 !! input
21360 -{H|zh-cn:foo;zh-tw:;}-foobar
21361 !! result
21362 <p>foobar
21363 </p>
21364 !! end
21365
21366 !! test
21367 Unidirectional converter rule entries with an empty "from" string should be ignored (T53551)
21368 !! options
21369 language=zh variant=zh-cn
21370 !! input
21371 -{H|=>zh-cn:foo;}-foobar
21372 !! result
21373 <p>foobar
21374 </p>
21375 !! end
21376
21377 !! test
21378 Empty converter rule entries shouldn't be inserted into the conversion table (T53551)
21379 !! options
21380 language=zh variant=zh-cn
21381 !! input
21382 -{H|}-foobar
21383 !! result
21384 <p>foobar
21385 </p>
21386 !! end
21387
21388 !! test
21389 Nested using of manual convert syntax
21390 !! options
21391 language=zh variant=zh-hk
21392 !! wikitext
21393 Nested: -{zh-hans:Hi -{zh-cn:China;zh-sg:Singapore;}-;zh-hant:Hello -{zh-tw:Taiwan;zh-hk:H-{ong}- K-{}-ong;}-;}-!
21394 !! html
21395 <p>Nested: Hello Hong Kong!
21396 </p>
21397 !! end
21398
21399 !! test
21400 HTML markups with conversion syntax in attribs, nested in other conversion blocks
21401 !! options
21402 language=zh variant=zh-cn
21403 !! wikitext
21404 -{zh;zh-hans;zh-hant|<span title="-{X}-">A</span>}-
21405 !! html
21406 <p><span title="X">A</span>
21407 </p>
21408 !! end
21409
21410 !! test
21411 HTML markups with conversion syntax in attribs, nested in other conversion blocks (not working yet)
21412 !! options
21413 language=zh variant=zh-cn disabled
21414 !! wikitext
21415 -{<span title="-{X}-">A</span>}-
21416 !! html
21417 <p><span title="X">A</span>
21418 </p>
21419 !! end
21420
21421 # Since Parsoid is starting to emit canonical wikitext for links,
21422 # [http://example.com http://example.com] will not RT back to that
21423 # form anymore.
21424 !! test
21425 Proper conversion of text in external links
21426 !! options
21427 language=sr variant=sr-ec
21428 parsoid=wt2html
21429 !! wikitext
21430 http://www.google.com
21431 gopher://www.google.com
21432 [http://www.google.com http://www.google.com]
21433 [gopher://www.google.com gopher://www.google.com]
21434 [https://www.google.com irc://www.google.com]
21435 [ftp://www.google.com www.google.com/ftp://dir]
21436 [//www.google.com www.google.com]
21437 !! html/php
21438 <p><a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
21439 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
21440 <a rel="nofollow" class="external free" href="http://www.google.com">http://www.google.com</a>
21441 <a rel="nofollow" class="external free" href="gopher://www.google.com">gopher://www.google.com</a>
21442 <a rel="nofollow" class="external text" href="https://www.google.com">irc://www.google.com</a>
21443 <a rel="nofollow" class="external text" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
21444 <a rel="nofollow" class="external text" href="//www.google.com">www.гоогле.цом</a>
21445 </p>
21446 !! html/parsoid
21447 <p><a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
21448 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
21449 <a rel="mw:ExtLink" href="http://www.google.com">http://www.google.com</a>
21450 <a rel="mw:ExtLink" href="gopher://www.google.com">gopher://www.google.com</a>
21451 <a rel="mw:ExtLink" href="https://www.google.com">irc://www.google.com</a>
21452 <a rel="mw:ExtLink" href="ftp://www.google.com">www.гоогле.цом/фтп://дир</a>
21453 <a rel="mw:ExtLink" href="//www.google.com">www.гоогле.цом</a></p>
21454 !! end
21455
21456 !! test
21457 Do not convert roman numbers to language variants
21458 !! options
21459 language=sr variant=sr-ec
21460 !! wikitext
21461 Fridrih IV je car.
21462 !! html
21463 <p>Фридрих IV је цар.
21464 </p>
21465 !! end
21466
21467 !! test
21468 Unclosed language converter markup "-{"
21469 !! options
21470 language=sr
21471 !! wikitext
21472 -{T|hello
21473 !! html
21474 <p>-{T|hello
21475 </p>
21476 !! end
21477
21478 !! test
21479 Don't convert raw rule "-{R|=&gt;}-" to "=>"
21480 !! options
21481 language=sr
21482 !! wikitext
21483 -{R|=&gt;}-
21484 !! html
21485 <p>=&gt;
21486 </p>
21487 !!end
21488
21489 !! test
21490 Don't break link parsing if language converter markup is in the caption.
21491 !! options
21492 language=sr variant=sr-ec
21493 !! wikitext
21494 [[Main Page|-{R|main page}-]]
21495 !! html
21496 <p><a href="/wiki/Main_Page" title="Маин Паге">main page</a>
21497 </p>
21498 !! end
21499
21500 !! test
21501 T146304: Don't break template parsing if language converter markup is in the parameter.
21502 !! options
21503 language=sr variant=sr-ec
21504 !! wikitext
21505 {{echo|-{R|foo}-}}
21506 !! html/php
21507 <p>foo
21508 </p>
21509 !! end
21510
21511 !! test
21512 T146305: Don't break image parsing if language converter markup is in the caption.
21513 !! options
21514 language=sr
21515 !! wikitext
21516 [[File:Foobar.jpg|thumb|-{R|caption:}-]]
21517 !! html/php
21518 <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>
21519
21520 !! html/parsoid
21521 <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>
21522 !! end
21523
21524 !! test
21525 T146305: Don't break image parsing if nested language converter markup is in the caption.
21526 !! options
21527 language=zh variant=zh-cn
21528 !! wikitext
21529 [[File:Foobar.jpg|thumb|-{zh-cn:blog (hk: -{zh-hans|WEBJOURNAL}-, tw: -{zh-hans|WEBLOG}-)}-]]
21530 !! html/php
21531 <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>
21532
21533 !! html/parsoid
21534 <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>
21535 !! end
21536
21537 !! test
21538 Don't break gallery if language converter markup is inside.
21539 !! options
21540 language=zh
21541 !! wikitext
21542 <gallery>
21543 File:foobar.jpg|[[File:foobar.jpg|20px|desc|alt=-{R|foo}-|-{R|bar}-]]|alt=-{R|bat}-
21544 File:foobar.jpg|{{Test|unamedParam|alt=-{R|param}-}}|alt=galleryalt
21545 </gallery>
21546 !! html
21547 <ul class="gallery mw-gallery-traditional">
21548 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21549 <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>
21550 <div class="gallerytext">
21551 <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>
21552 </p>
21553 </div>
21554 </div></li>
21555 <li class="gallerybox" style="width: 155px"><div style="width: 155px">
21556 <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>
21557 <div class="gallerytext">
21558 <p>This is a test template
21559 </p>
21560 </div>
21561 </div></li>
21562 </ul>
21563
21564 !! end
21565
21566 !! test
21567 T153135: Don't break list handling if language converter markup is in the item.
21568 !! options
21569 language=zh variant=zh-cn
21570 !! wikitext
21571 ;-{zh-cn:AAA;zh-tw:BBB}-
21572 ;-{R|foo:bar}-
21573 !! html/php
21574 <dl><dt>AAA</dt>
21575 <dt>foo:bar</dt></dl>
21576
21577 !! html/parsoid
21578 <dl>
21579 <dt><span typeof="mw:LanguageVariant" data-mw='{"bidir":[{"l":"zh-cn","t":"AAA"},{"l":"zh-tw","t":"BBB"}],"show":true}'></span></dt>
21580 <dt><span typeof="mw:LanguageVariant" data-mw='{"disabled":true,"show":true,"text":"foo:bar"}'></span></dt>
21581 </dl>
21582 !! end
21583
21584 // Note that parsoid does not protect colons unless language converter
21585 // markup is properly nested, because it is a backtracking parser.
21586 !! test
21587 T153135: Unclosed markup in definition list (code coverage)
21588 !! options
21589 language=zh variant=zh-cn
21590 !! wikitext
21591 ;<b>foo:bar
21592 ;-{zh-cn:AAA
21593 !! html/php
21594 <dl><dt><b>foo:bar</dt>
21595 <dt>-{zh-cn:AAA</b></dt></dl>
21596
21597 !! html/parsoid
21598 <dl>
21599 <dt><b>foo:bar</b></dt>
21600 <b>
21601 <dt>-{zh-cn</dt>
21602 <dd>AAA</dd>
21603 </b></dl>
21604 !! end
21605
21606 !! test
21607 T153135: Nested language converter markup in definition list (code coverage)
21608 !! options
21609 language=zh variant=zh-cn
21610 !! wikitext
21611 ;-{zh-cn:AAA -{zh-hans|foo:bar}- -{R|bat:baz}-}-:def
21612 !! html/php
21613 <dl><dt>AAA foo:bar bat:baz</dt>
21614 <dd>def</dd></dl>
21615
21616 !! html/parsoid
21617 <dl>
21618 <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>
21619 <dd>def</dd>
21620 </dl>
21621 !! end
21622
21623 !! test
21624 T153140: Don't break table handling if language converter markup is in the cell.
21625 !! options
21626 language=sr variant=sr-ec
21627 !! wikitext
21628 {|
21629 |-
21630 | -{R|B}-
21631 |}
21632 !! html/php
21633 <table>
21634
21635 <tr>
21636 <td> B
21637 </td></tr></table>
21638
21639 !! html/parsoid
21640 <table>
21641
21642 <tr>
21643 <td> B
21644 </td></tr></table>
21645
21646 !! end
21647
21648 !! test
21649 T2529: Uncovered bullet
21650 !! wikitext
21651 * Foo {{bullet}}
21652 !! html
21653 <ul><li> Foo </li>
21654 <li> Bar</li></ul>
21655
21656 !! end
21657
21658 # Plain MediaWiki does not remove empty lists, but tidy actually does.
21659 # Templates in Wikipedia rely on this behavior, as tidy has always been
21660 # enabled there. These tests are normally run *without* tidy, so specify the
21661 # full output here.
21662 # To test realistic parsing behavior, apply a tidy-like transformation to both
21663 # the expected output and your parser's output.
21664 !! test
21665 T2529: Uncovered bullet leaving empty list, normally removed by tidy
21666 !! wikitext
21667 ******* Foo {{bullet}}
21668 !! html
21669 <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>
21670 <li> Bar</li></ul>
21671
21672 !! end
21673
21674 !! test
21675 T2529: Uncovered table already at line-start
21676 !! wikitext
21677 x
21678
21679 {{table}}
21680 y
21681 !! html
21682 <p>x
21683 </p>
21684 <table>
21685 <tr>
21686 <td> 1 </td>
21687 <td> 2
21688 </td></tr>
21689 <tr>
21690 <td> 3 </td>
21691 <td> 4
21692 </td></tr></table>
21693 <p>y
21694 </p>
21695 !! end
21696
21697 !! test
21698 T2529: Uncovered bullet in parser function result
21699 !! wikitext
21700 * Foo {{lc:{{bullet}} }}
21701 !! html
21702 <ul><li> Foo </li>
21703 <li> bar</li></ul>
21704
21705 !! end
21706
21707 !! test
21708 T7678: Double-parsed template argument
21709 !! wikitext
21710 {{lc:{{{1}}}|hello}}
21711 !! html
21712 <p>{{{1}}}
21713 </p>
21714 !! end
21715
21716 !! test
21717 T7678: Double-parsed template invocation
21718 !! wikitext
21719 {{lc:{{paramtest {{!}} param = hello }} }}
21720 !! html
21721 <p>{{paramtest | param = hello }}
21722 </p>
21723 !! end
21724
21725 !! test
21726 Case insensitivity of parser functions for non-ASCII characters (T10143)
21727 !! options
21728 language=cs
21729 title=[[Main Page]]
21730 !! wikitext
21731 {{PRVNÍVELKÉ:ěščř}}
21732 {{prvnívelké:ěščř}}
21733 {{PRVNÍMALÉ:ěščř}}
21734 {{prvnímalé:ěščř}}
21735 {{MALÁ:ěščř}}
21736 {{malá:ěščř}}
21737 {{VELKÁ:ěščř}}
21738 {{velká:ěščř}}
21739 !! html
21740 <p>Ěščř
21741 Ěščř
21742 ěščř
21743 ěščř
21744 ěščř
21745 ěščř
21746 ĚŠČŘ
21747 ĚŠČŘ
21748 </p>
21749 !! end
21750
21751 !! test
21752 Morwen/13: Unclosed link followed by heading
21753 !! wikitext
21754 [[link
21755 ==heading==
21756 !! html
21757 <p>[[link
21758 </p>
21759 <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>
21760
21761 !! end
21762
21763 !! test
21764 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
21765 !! wikitext
21766 {{foo|
21767 =heading=
21768 !! html
21769 <p>{{foo|
21770 </p>
21771 <h1><span class="mw-headline" id="heading">heading</span></h1>
21772
21773 !! end
21774
21775 !! test
21776 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
21777 !! wikitext
21778 {{foo|
21779 ==heading==
21780 !! html
21781 <p>{{foo|
21782 </p>
21783 <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>
21784
21785 !! end
21786
21787 !! test
21788 Tildes in comments
21789 !! options
21790 pst
21791 !! wikitext
21792 <!-- ~~~~ -->
21793 !! html/php
21794 <!-- ~~~~ -->
21795 !! end
21796
21797 !! test
21798 Paragraphs inside divs (no extra line breaks)
21799 !! wikitext
21800 <div>Line one
21801
21802 Line two</div>
21803 !! html
21804 <div>Line one
21805 Line two</div>
21806
21807 !! end
21808
21809 !! test
21810 Paragraphs inside divs (extra line break on open)
21811 !! wikitext
21812 <div>
21813 Line one
21814
21815 Line two</div>
21816 !! html
21817 <div>
21818 <p>Line one
21819 </p>
21820 Line two</div>
21821
21822 !! end
21823
21824 !! test
21825 Paragraphs inside divs (extra line break on close)
21826 !! wikitext
21827 <div>Line one
21828
21829 Line two
21830 </div>
21831 !! html
21832 <div>Line one
21833 <p>Line two
21834 </p>
21835 </div>
21836
21837 !! end
21838
21839 !! test
21840 Paragraphs inside divs (extra line break on open and close)
21841 !! wikitext
21842 <div>
21843 Line one
21844
21845 Line two
21846 </div>
21847 !! html
21848 <div>
21849 <p>Line one
21850 </p><p>Line two
21851 </p>
21852 </div>
21853
21854 !! end
21855
21856 !! test
21857 Nesting tags, paragraphs on lines which begin with <div>
21858 !! wikitext
21859 <div></div><strong>A
21860 B</strong>
21861 !! html/php+tidy
21862 <p><strong>A</strong></p>
21863 <p><strong>B</strong></p>
21864 !! html/parsoid
21865 <div></div>
21866 <p><strong>A
21867 B</strong>
21868 </p>
21869 !! end
21870
21871 # T8200: <blockquote> should behave like <div> with respect to line breaks
21872 !! test
21873 T8200: paragraphs inside blockquotes (no extra line breaks)
21874 !! wikitext
21875 <blockquote>Line one
21876
21877 Line two</blockquote>
21878 !! html
21879 <blockquote>Line one
21880 Line two</blockquote>
21881
21882 !! html+tidy
21883 <blockquote>
21884 <p>Line one Line two</p>
21885 </blockquote>
21886 !! end
21887
21888 !! test
21889 T8200: paragraphs inside blockquotes (extra line break on open)
21890 !! wikitext
21891 <blockquote>
21892 Line one
21893
21894 Line two</blockquote>
21895 !! html
21896 <blockquote>
21897 <p>Line one
21898 </p>
21899 Line two</blockquote>
21900
21901 !! html+tidy
21902 <blockquote>
21903 <p>Line one</p>
21904 Line two</blockquote>
21905 !! end
21906
21907 !! test
21908 T8200: paragraphs inside blockquotes (extra line break on close)
21909 !! wikitext
21910 <blockquote>Line one
21911
21912 Line two
21913 </blockquote>
21914 !! html
21915 <blockquote>Line one
21916 <p>Line two
21917 </p>
21918 </blockquote>
21919
21920 !! html+tidy
21921 <blockquote>
21922 <p>Line one</p>
21923 <p>Line two</p>
21924 </blockquote>
21925 !! end
21926
21927 !! test
21928 T8200: paragraphs inside blockquotes (extra line break on open and close)
21929 !! wikitext
21930 <blockquote>
21931 Line one
21932
21933 Line two
21934 </blockquote>
21935 !! html
21936 <blockquote>
21937 <p>Line one
21938 </p><p>Line two
21939 </p>
21940 </blockquote>
21941
21942 !! html+tidy
21943 <blockquote>
21944 <p>Line one</p>
21945 <p>Line two</p>
21946 </blockquote>
21947 !! end
21948
21949 !! test
21950 Paragraphs inside blockquotes/divs (no extra line breaks)
21951 !! wikitext
21952 <blockquote><div>Line one
21953
21954 Line two</div></blockquote>
21955 !! html
21956 <blockquote><div>Line one
21957 Line two</div></blockquote>
21958
21959 !! end
21960
21961 !! test
21962 Paragraphs inside blockquotes/divs (extra line break on open)
21963 !! wikitext
21964 <blockquote><div>
21965 Line one
21966
21967 Line two</div></blockquote>
21968 !! html
21969 <blockquote><div>
21970 <p>Line one
21971 </p>
21972 Line two</div></blockquote>
21973
21974 !! end
21975
21976 !! test
21977 Paragraphs inside blockquotes/divs (extra line break on close)
21978 !! wikitext
21979 <blockquote><div>Line one
21980
21981 Line two
21982 </div></blockquote>
21983 !! html
21984 <blockquote><div>Line one
21985 <p>Line two
21986 </p>
21987 </div></blockquote>
21988
21989 !! end
21990
21991 !! test
21992 Paragraphs inside blockquotes/divs (extra line break on open and close)
21993 !! wikitext
21994 <blockquote><div>
21995 Line one
21996
21997 Line two
21998 </div></blockquote>
21999 !! html
22000 <blockquote><div>
22001 <p>Line one
22002 </p><p>Line two
22003 </p>
22004 </div></blockquote>
22005
22006 !! end
22007
22008 !! test
22009 Interwiki links trounced by replaceExternalLinks after early LinkHolderArray expansion
22010 !! options
22011 wgLinkHolderBatchSize=0
22012 !! wikitext
22013 [[meatball:1]]
22014 [[meatball:2]]
22015 [[meatball:3]]
22016 !! html
22017 <p><a href="http://www.usemod.com/cgi-bin/mb.pl?1" class="extiw" title="meatball:1">meatball:1</a>
22018 <a href="http://www.usemod.com/cgi-bin/mb.pl?2" class="extiw" title="meatball:2">meatball:2</a>
22019 <a href="http://www.usemod.com/cgi-bin/mb.pl?3" class="extiw" title="meatball:3">meatball:3</a>
22020 </p>
22021 !! end
22022
22023 !! test
22024 Free external link invading image caption
22025 !! wikitext
22026 [[Image:Foobar.jpg|thumb|http://x|hello]]
22027 !! html
22028 <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>
22029
22030 !! end
22031
22032 !! test
22033 T17196: localised external link numbers
22034 !! options
22035 language=fa
22036 !! wikitext
22037 [http://en.wikipedia.org/]
22038 !! html/php
22039 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/">[۱]</a>
22040 </p>
22041 !! html/parsoid
22042 <p><a rel="mw:ExtLink" href="http://en.wikipedia.org/"></a></p>
22043 !! end
22044
22045 !! test
22046 Multibyte character in padleft
22047 !! wikitext
22048 {{padleft:-Hello|7|Æ}}
22049 !! html
22050 <p>Æ-Hello
22051 </p>
22052 !! end
22053
22054 !! test
22055 Multibyte character in padright
22056 !! wikitext
22057 {{padright:Hello-|7|Æ}}
22058 !! html
22059 <p>Hello-Æ
22060 </p>
22061 !! end
22062
22063 !!test
22064 formatdate parser function
22065 !! wikitext
22066 {{#formatdate:2009-03-24}}
22067 !! html
22068 <p><span class="mw-formatted-date" title="2009-03-24">2009-03-24</span>
22069 </p>
22070 !! end
22071
22072 !!test
22073 formatdate parser function, with default format
22074 !! wikitext
22075 {{#formatdate:2009-03-24|mdy}}
22076 !! html
22077 <p><span class="mw-formatted-date" title="2009-03-24">March 24, 2009</span>
22078 </p>
22079 !! end
22080
22081 !! test
22082 Spacing of numbers in formatted dates
22083 !! wikitext
22084 {{#formatdate:January 15}}
22085 !! html
22086 <p><span class="mw-formatted-date" title="01-15">January 15</span>
22087 </p>
22088 !! end
22089
22090 !! test
22091 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
22092 !! options
22093 language=nl title=[[MediaWiki:Common.css]]
22094 !! wikitext
22095 {{#formatdate:2009-03-24|dmy}}
22096 !! html
22097 <p><span class="mw-formatted-date" title="2009-03-24">24 March 2009</span>
22098 </p>
22099 !! end
22100
22101 #
22102 #
22103 #
22104
22105 #
22106 # Edit comments
22107 #
22108
22109 !! test
22110 Edit comment with link
22111 !! options
22112 comment
22113 !! wikitext
22114 I like the [[Main Page]] a lot
22115 !! html/php
22116 I like the <a href="/wiki/Main_Page" title="Main Page">Main Page</a> a lot
22117 !!end
22118
22119 !! test
22120 Edit comment with link and link text
22121 !! options
22122 comment
22123 !! wikitext
22124 I like the [[Main Page|best pages]] a lot
22125 !! html/php
22126 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
22127 !!end
22128
22129 !! test
22130 Edit comment with link and link text with suffix
22131 !! options
22132 comment
22133 !! wikitext
22134 I like the [[Main Page|best page]]s a lot
22135 !! html/php
22136 I like the <a href="/wiki/Main_Page" title="Main Page">best pages</a> a lot
22137 !!end
22138
22139 !! test
22140 Edit comment with section link (non-local, eg in history list)
22141 !! options
22142 comment title=[[Main Page]]
22143 !! wikitext
22144 /* External links */ removed bogus entries
22145 !! html/php
22146 <a href="/wiki/Main_Page#External_links" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
22147 !!end
22148
22149 !! test
22150 Edit comment with section link and text before it (non-local, eg in history list)
22151 !! options
22152 comment title=[[Main Page]]
22153 !! wikitext
22154 pre-comment text /* External links */ removed bogus entries
22155 !! html/php
22156 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>
22157 !!end
22158
22159 !! test
22160 Edit comment with section link (local, eg in diff view)
22161 !! options
22162 comment local title=[[Main Page]]
22163 !! wikitext
22164 /* External links */ removed bogus entries
22165 !! html/php
22166 <a href="#External_links">→</a>‎<span dir="auto"><span class="autocomment">External links: </span> removed bogus entries</span>
22167 !!end
22168
22169 !! test
22170 Edit comment with subpage link (T16080)
22171 !! options
22172 comment
22173 subpage
22174 title=[[Subpage test]]
22175 !! wikitext
22176 Poked at a [[/subpage]] here...
22177 !! html/php
22178 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">/subpage</a> here...
22179 !!end
22180
22181 !! test
22182 Edit comment with subpage link and link text (T16080)
22183 !! options
22184 comment
22185 subpage
22186 title=[[Subpage test]]
22187 !! wikitext
22188 Poked at a [[/subpage|neat little page]] here...
22189 !! html/php
22190 Poked at a <a href="/wiki/Subpage_test/subpage" title="Subpage test/subpage">neat little page</a> here...
22191 !!end
22192
22193 !! test
22194 Edit comment with bogus subpage link in non-subpage NS (T16080)
22195 !! options
22196 comment
22197 title=[[Subpage test]]
22198 !! wikitext
22199 Poked at a [[/subpage]] here...
22200 !! html/php
22201 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...
22202 !!end
22203
22204 !! test
22205 Edit comment with bare anchor link (local, as on diff)
22206 !! options
22207 comment
22208 local
22209 title=[[Main Page]]
22210 !! wikitext
22211 [[#section]]
22212 !! html/php
22213 <a href="#section">#section</a>
22214 !! end
22215
22216 !! test
22217 Edit comment with bare anchor link (non-local, as on history)
22218 !! options
22219 comment
22220 title=[[Main Page]]
22221 !! wikitext
22222 [[#section]]
22223 !! html/php
22224 <a href="/wiki/Main_Page#section" title="Main Page">#section</a>
22225 !! end
22226
22227 !! test
22228 Anchor starting with underscore
22229 !! options
22230 title=[[Foo]]
22231 !! wikitext
22232 [[#_ref|One]]
22233 !! html/php
22234 <p><a href="#_ref">One</a>
22235 </p>
22236 !! html/parsoid
22237 <p><a rel="mw:WikiLink" href="./Foo#_ref" data-parsoid='{"stx":"piped","a":{"href":"./Foo#_ref"},"sa":{"href":"#_ref"}}'>One</a></p>
22238 !! end
22239
22240 !! test
22241 Id starting with underscore
22242 !! wikitext
22243 <div id="_ref"></div>
22244 !! html/*
22245 <div id="_ref"></div>
22246
22247 !! end
22248
22249 !! test
22250 Edit comment with link with more than one pipe (T99346)
22251 !! options
22252 comment
22253 !! wikitext
22254 [[Main Page|Many|pipes]]
22255 !! html/php
22256 <a href="/wiki/Main_Page" title="Main Page">Many|pipes</a>
22257 !! end
22258
22259 !! test
22260 Complex edit comment with link with more than one pipe (T99346)
22261 !! options
22262 comment
22263 !! wikitext
22264 Created page with "<noinclude>[[Category:Requests for permissions/Bot|{{subst:#titleparts:{{subst:PAGENAME}}|1|3}}]]</noinclude> === [[User:MineoBot|]] 8=== {{Request for permissions/links|Mineo..."
22265 !! html/php
22266 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;
22267 !! end
22268
22269 !! test
22270 Space normalisation on autocomment (T24784)
22271 !! options
22272 comment
22273 title=[[Main Page]]
22274 !! wikitext
22275 /* __hello__world__ */
22276 !! html/php
22277 <a href="/wiki/Main_Page#hello_world" title="Main Page">→</a>‎<span dir="auto"><span class="autocomment">__hello__world__</span></span>
22278 !! end
22279
22280 !! test
22281 percent-encoding and + signs in comments (T28410)
22282 !! options
22283 comment
22284 !! wikitext
22285 [[ABC%33D% ++]] [[ABC%33D% ++|+%20]]
22286 !! html/php
22287 <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>
22288 !! end
22289
22290 # Parsoid doesn't support this yet: see T75581
22291 # but it *should* omit the 'src' attribute if the image is bad.
22292 # PHP side of tests was disabled in
22293 # mediawiki/core:6bd31e7d95161a6e88fa86df60871051da997c3c
22294 # because of issues in the PHP parserTests infrastructure
22295 # (but the output below is indeed what the PHP side emits)
22296 !! test
22297 Bad images - basic functionality
22298 !! wikitext
22299 [[File:Bad.jpg]]
22300 !! DISABLED/html/php
22301 !! html/parsoid
22302 <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>
22303 !! end
22304
22305 !! test
22306 Bad images - T18039: text after bad image disappears
22307 !! wikitext
22308 Foo bar
22309 [[File:Bad.jpg]]
22310 Bar foo
22311 !! DISABLED/html/php
22312 <p>Foo bar
22313 </p><p>Bar foo
22314 </p>
22315 !! html/parsoid
22316 <p>Foo bar
22317 <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>
22318 Bar foo</p>
22319 !! end
22320
22321 !! test
22322 Verify that displaytitle works (T24501) no displaytitle
22323 !! options
22324 showtitle
22325 !! config
22326 wgAllowDisplayTitle=true
22327 wgRestrictDisplayTitle=false
22328 !! wikitext
22329 this is not the the title
22330 !! html/php
22331 Parser test
22332 <p>this is not the the title
22333 </p>
22334 !! end
22335
22336 !! test
22337 Verify that displaytitle works (T24501) RestrictDisplayTitle=false
22338 !! options
22339 showtitle
22340 title=[[Screen]]
22341 !! config
22342 wgAllowDisplayTitle=true
22343 wgRestrictDisplayTitle=false
22344 !! wikitext
22345 this is not the the title
22346 {{DISPLAYTITLE:whatever}}
22347 !! html/php
22348 whatever
22349 <p>this is not the the title
22350 </p>
22351 !! end
22352
22353 !! test
22354 Verify that displaytitle works (T24501) RestrictDisplayTitle=true mismatch
22355 !! options
22356 showtitle
22357 title=[[Screen]]
22358 !! config
22359 wgAllowDisplayTitle=true
22360 wgRestrictDisplayTitle=true
22361 !! wikitext
22362 this is not the the title
22363 {{DISPLAYTITLE:whatever}}
22364 !! html/php
22365 Screen
22366 <p>this is not the the title
22367 </p>
22368 !! end
22369
22370 !! test
22371 Verify that displaytitle works (T24501) RestrictDisplayTitle=true matching
22372 !! options
22373 showtitle
22374 title=[[Screen]]
22375 !! config
22376 wgAllowDisplayTitle=true
22377 wgRestrictDisplayTitle=true
22378 !! wikitext
22379 this is not the the title
22380 {{DISPLAYTITLE:screen}}
22381 !! html/php
22382 screen
22383 <p>this is not the the title
22384 </p>
22385 !! end
22386
22387 !! test
22388 Verify that displaytitle works (T24501) AllowDisplayTitle=false
22389 !! options
22390 showtitle
22391 title=[[Screen]]
22392 !! config
22393 wgAllowDisplayTitle=false
22394 !! wikitext
22395 this is not the the title
22396 {{DISPLAYTITLE:screen}}
22397 !! html/php
22398 Screen
22399 <p>this is not the the title
22400 <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>
22401 </p>
22402 !! end
22403
22404 !! test
22405 Verify that displaytitle works (T24501) AllowDisplayTitle=false no DISPLAYTITLE
22406 !! options
22407 showtitle
22408 title=[[Screen]]
22409 !! config
22410 wgAllowDisplayTitle=false
22411 !! wikitext
22412 this is not the the title
22413 !! html/php
22414 Screen
22415 <p>this is not the the title
22416 </p>
22417 !! end
22418
22419 !! test
22420 Verify that displaytitle handles inline CSS styles (T28547) - rejected value
22421 !! options
22422 showtitle
22423 title=[[Screen]]
22424 !! config
22425 wgAllowDisplayTitle=true
22426 wgRestrictDisplayTitle=true
22427 !! wikitext
22428 this is not the the title
22429 {{DISPLAYTITLE:<span style="display: none;">s</span>creen}}
22430 !! html/php
22431 <span style="/* attempt to bypass $wgRestrictDisplayTitle */">s</span>creen
22432 <p>this is not the the title
22433 </p>
22434 !! end
22435
22436 !! test
22437 Verify that displaytitle handles inline CSS styles (T28547) - accepted value
22438 !! options
22439 showtitle
22440 title=[[Screen]]
22441 !! config
22442 wgAllowDisplayTitle=true
22443 wgRestrictDisplayTitle=true
22444 !! wikitext
22445 this is not the the title
22446 {{DISPLAYTITLE:<span style="color: red;">s</span>creen}}
22447 !! html/php
22448 <span style="color: red;">s</span>creen
22449 <p>this is not the the title
22450 </p>
22451 !! end
22452
22453 !! test
22454 Page status indicators: Empty name is invalid
22455 !! options
22456 showindicators
22457 !! wikitext
22458 <indicator name=" "></indicator>
22459 <indicator></indicator>
22460 !! html/php
22461 <p><span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
22462 <span class="error"><strong>Error:</strong> Page status indicators' <code>name</code> attribute must not be empty.</span>
22463 </p>
22464 !! end
22465
22466 !! test
22467 Page status indicators: Weird syntaxes that are okay
22468 !! options
22469 showindicators
22470 !! wikitext
22471 <indicator name="empty" />
22472 <indicator name="name"></indicator>
22473 !! html/php
22474 empty=
22475 name=
22476 <p><br />
22477 </p>
22478 !! end
22479
22480 !! test
22481 Page status indicators: Torture test
22482 !! options
22483 showindicators
22484 !! wikitext
22485 <indicator name="01">hello world</indicator>
22486 <indicator name="02">[[Main Page]]</indicator>
22487 <indicator name="03">[[File:Foobar.jpg|25px|link=]]</indicator>
22488 <indicator name="04">[[File:Foobar.jpg|25px]]</indicator>
22489 <indicator name="05">* foo
22490 * bar</indicator>
22491 <indicator name="06"><nowiki>foo</nowiki></indicator>
22492 <indicator name="07"> Preformatted</indicator>
22493 <indicator name="08"><div>Broken tag</indicator>
22494 <indicator name="09">{| class=wikitable
22495 | cell
22496 |}</indicator>
22497 <indicator name="10">Two
22498
22499 paragraphs</indicator>
22500 !! html/php
22501 01=hello world
22502 02=<a href="/wiki/Main_Page" title="Main Page">Main Page</a>
22503 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" />
22504 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>
22505 05=<ul><li> foo</li>
22506 <li> bar</li></ul>
22507
22508 06=foo
22509 07=<pre>Preformatted
22510 </pre>
22511 08=<div>Broken tag</div>
22512
22513 09=<table class="wikitable">
22514 <tr>
22515 <td> cell
22516 </td></tr></table>
22517
22518 10=<p>Two
22519 </p><p>paragraphs
22520 </p>
22521 <p><br />
22522 </p><p><br />
22523 </p><p><br />
22524 </p><p><br />
22525 </p><p><br />
22526 </p>
22527 !! end
22528
22529 !! test
22530 preload: check <noinclude> and <includeonly>
22531 !! options
22532 preload
22533 !! wikitext
22534 Hello <noinclude>cruel</noinclude><includeonly>kind</includeonly> world.
22535 !! html/php
22536 Hello kind world.
22537 !! end
22538
22539 !! test
22540 preload: check <onlyinclude>
22541 !! options
22542 preload
22543 !! wikitext
22544 Goodbye <onlyinclude>Hello world</onlyinclude>
22545 !! html/php
22546 Hello world
22547 !! end
22548
22549 !! test
22550 preload: can pass tags through if we want to
22551 !! options
22552 preload
22553 !! wikitext
22554 <includeonly><</includeonly>includeonly>Hello world<includeonly><</includeonly>/includeonly>
22555 !! html/php
22556 <includeonly>Hello world</includeonly>
22557 !! end
22558
22559 !! test
22560 preload: check that it doesn't try to do tricks
22561 !! options
22562 preload
22563 !! wikitext
22564 * <!-- Hello --> ''{{world}}'' {{<includeonly>subst:</includeonly>How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
22565 !! html/php
22566 * <!-- Hello --> ''{{world}}'' {{subst:How are you}}{{ {{{|safesubst:}}} #if:1|2|3}}
22567 !! end
22568
22569 !! test
22570 Play a bit with r67090 and T5158
22571 !! wikitext
22572 <div style="width:50% !important">&nbsp;</div>
22573 <div style="width:50%&nbsp;!important">&nbsp;</div>
22574 <div style="width:50%&#160;!important">&nbsp;</div>
22575 <div style="border : solid;">&nbsp;</div>
22576 !! html/php
22577 <div style="width:50% !important">&#160;</div>
22578 <div style="width:50% !important">&#160;</div>
22579 <div style="width:50% !important">&#160;</div>
22580 <div style="border&#160;: solid;">&#160;</div>
22581
22582 !! html/parsoid
22583 <div style="width:50% !important" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
22584 <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>
22585 <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>
22586 <div style="border : solid;" data-parsoid='{"stx":"html"}'><span typeof="mw:Entity" data-parsoid='{"srcContent":" "}'> </span></div>
22587
22588 !! end
22589
22590 !! test
22591 HTML5 data attributes
22592 !! wikitext
22593 <span data-foo="bar">Baz</span>
22594 <p data-abc-def_hij="">Quuz</p>
22595 !! html/php
22596 <p><span data-foo="bar">Baz</span>
22597 </p>
22598 <p data-abc-def_hij="">Quuz</p>
22599
22600 !! html/parsoid
22601 <p><span data-foo="bar" data-parsoid='{"stx":"html"}'>Baz</span></p>
22602 <p data-abc-def_hij="" data-parsoid='{"stx":"html"}'>Quuz</p>
22603 !! end
22604
22605 !! test
22606 Strip reserved data attributes
22607 !! wikitext
22608 <div data-mw="foo" data-parsoid="bar" data-mw-someext="baz" data-ok="fred" data-ooui="xyzzy" data-bad:ns="ns">d</div>
22609 !! html/php
22610 <div data-ok="fred">d</div>
22611
22612 !! html/parsoid
22613 <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>
22614 !! end
22615
22616 !! test
22617 percent-encoding and + signs in internal links (T28410)
22618 !! wikitext
22619 [[User:+%]] [[Page+title%]]
22620 [[%+]] [[%+|%20]] [[%+ ]] [[%+r]]
22621 [[%]] [[+]] [[File:%+abc%39|foo|[[bar]]]]
22622 [[%33%45]] [[%33%45+]]
22623 !! html/php
22624 <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>
22625 <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>
22626 <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>
22627 <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>
22628 </p>
22629 !! html/parsoid
22630 <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>
22631 <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>
22632 <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>
22633 <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>
22634 !! end
22635
22636 !! test
22637 Special characters in embedded file links (T29679)
22638 !! wikitext
22639 [[File:Contains & ampersand.jpg]]
22640 [[File:Does not exist.jpg|Title with & ampersand]]
22641 !! html/php
22642 <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>
22643 <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>
22644 </p>
22645 !! html/parsoid
22646 <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>
22647 <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>
22648 !! end
22649
22650 !! test
22651 Confirm that 'apos' named character reference doesn't make it to output (not legal in HTML 4)
22652 !! wikitext
22653 Text&apos;s been normalized?
22654 !! html
22655 <p>Text&#39;s been normalized?
22656 </p>
22657 !! end
22658
22659 !! test
22660 T21052 U+3000 IDEOGRAPHIC SPACE should terminate free external links
22661 !! wikitext
22662 http://www.example.org/ <-- U+3000 (vim: ^Vu3000)
22663 !! html
22664 <p><a rel="nofollow" class="external free" href="http://www.example.org/">http://www.example.org/</a> &lt;-- U+3000 (vim: ^Vu3000)
22665 </p>
22666 !! end
22667
22668 !! test
22669 T21052 U+3000 IDEOGRAPHIC SPACE should terminate bracketed external links
22670 !! wikitext
22671 [http://www.example.org/ ideograms]
22672 !! html
22673 <p><a rel="nofollow" class="external text" href="http://www.example.org/">ideograms</a>
22674 </p>
22675 !! end
22676
22677 !! test
22678 T21052 U+3000 IDEOGRAPHIC SPACE should terminate external images links
22679 !! wikitext
22680 http://www.example.org/pic.png <-- U+3000 (vim: ^Vu3000)
22681 !! html
22682 <p><img src="http://www.example.org/pic.png" alt="pic.png"/> &lt;-- U+3000 (vim: ^Vu3000)
22683 </p>
22684 !! end
22685
22686 !! article
22687 Mediawiki:loop1
22688 !! text
22689 {{Identical|A}}
22690 !! endarticle
22691
22692 !! article
22693 Mediawiki:loop2
22694 !! text
22695 {{Identical|B}}
22696 !! endarticle
22697
22698 !! article
22699 Template:Identical
22700 !! text
22701 {{int:loop1}}
22702 {{int:loop2}}
22703 !! endarticle
22704
22705 !! test
22706 T33098 Template which includes system messages which includes the template
22707 !! wikitext
22708 {{Identical}}
22709 !! html
22710 <p><span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
22711 <span class="error">Template loop detected: <a href="/wiki/Template:Identical" title="Template:Identical">Template:Identical</a></span>
22712 </p>
22713 !! end
22714
22715 !! test
22716 T33490 Turkish: ucfirst 'blah'
22717 !! options
22718 language=tr
22719 !! wikitext
22720 {{ucfirst:blah}}
22721 !! html
22722 <p>Blah
22723 </p>
22724 !! end
22725
22726 !! test
22727 T33490 Turkish: ucfirst 'ix'
22728 !! options
22729 language=tr
22730 !! wikitext
22731 {{ucfirst:ix}}
22732 !! html
22733 <p>İx
22734 </p>
22735 !! end
22736
22737 !! test
22738 T33490 Turkish: lcfirst 'BLAH'
22739 !! options
22740 language=tr
22741 !! wikitext
22742 {{lcfirst:BLAH}}
22743 !! html
22744 <p>bLAH
22745 </p>
22746 !! end
22747
22748 !! test
22749 T33490 Turkish: ucfırst (with a dotless i)
22750 !! options
22751 language=tr
22752 !! wikitext
22753 {{ucfırst:blah}}
22754 !! html
22755 <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>
22756 </p>
22757 !! end
22758
22759 !! test
22760 T33490 ucfırst (with a dotless i) with English language
22761 !! options
22762 language=en
22763 !! wikitext
22764 {{ucfırst:blah}}
22765 !! html
22766 <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>
22767 </p>
22768 !! end
22769
22770 # Note that Parsoid doesn't emit an explicit TOC.
22771 # Note also that the html2wt direction tends to emit an extra newline
22772 # between the __TOC__ magicword and the first heading unless *both*
22773 # the <meta> and the <h2> have a data-parsoid attribute set (even if
22774 # it's "{}").
22775
22776 !! test
22777 T28375: TOC with italics
22778 !! options
22779 title=[[Main Page]]
22780 !! wikitext
22781 __TOC__
22782 == ''Lost'' episodes ==
22783 !! html/php
22784 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22785 <ul>
22786 <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>
22787 </ul>
22788 </div>
22789
22790 <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>
22791
22792 !! html/parsoid
22793 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22794 <h2 data-parsoid='{}'> <i>Lost</i> episodes </h2>
22795 !! end
22796
22797 !! test
22798 T28375: TOC with bold
22799 !! options
22800 title=[[Main Page]]
22801 !! wikitext
22802 __TOC__
22803 == '''should be bold''' then normal text ==
22804 !! html/php
22805 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22806 <ul>
22807 <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>
22808 </ul>
22809 </div>
22810
22811 <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>
22812
22813 !! html/parsoid
22814 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22815 <h2 data-parsoid='{}'> <b>should be bold</b> then normal text </h2>
22816 !! end
22817
22818 !! test
22819 T35845: Headings become cursive in TOC when they contain an image
22820 !! options
22821 title=[[Main Page]]
22822 !! wikitext
22823 __TOC__
22824 == Image [[Image:foobar.jpg]] ==
22825 !! html/php
22826 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22827 <ul>
22828 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
22829 </ul>
22830 </div>
22831
22832 <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>
22833
22834 !! html/parsoid
22835 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22836 <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>
22837 !! end
22838
22839 !! test
22840 T35845 (2): Headings become bold in TOC when they contain a blockquote
22841 !! options
22842 title=[[Main Page]]
22843 !! wikitext
22844 __TOC__
22845 == <blockquote>Quote</blockquote> ==
22846 !! html/php
22847 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22848 <ul>
22849 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
22850 </ul>
22851 </div>
22852
22853 <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>
22854
22855 !! html/php+tidy
22856 <p></p>
22857 <div id="toc" class="toc">
22858 <div class="toctitle">
22859 <h2>Contents</h2>
22860 </div>
22861 <ul>
22862 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
22863 </ul>
22864 </div>
22865 <p></p>
22866 <h2><span class="mw-headline" id="Quote"></span></h2>
22867 <blockquote>
22868 <p><span class="mw-headline" id="Quote">Quote</span></p>
22869 </blockquote>
22870 <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>
22871 !! html/parsoid
22872 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22873 <h2 data-parsoid='{}'> <blockquote>Quote</blockquote> </h2>
22874 !! end
22875
22876 !! test
22877 Unclosed tags in TOC
22878 !! options
22879 title=[[Main Page]]
22880 !! wikitext
22881 __TOC__
22882 == Proof: 2 < 3 ==
22883 <small>Hanc marginis exiguitas non caperet.</small>
22884 QED
22885 !! html/php
22886 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22887 <ul>
22888 <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>
22889 </ul>
22890 </div>
22891
22892 <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>
22893 <p><small>Hanc marginis exiguitas non caperet.</small>
22894 QED
22895 </p>
22896 !! html/parsoid
22897 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22898 <h2 data-parsoid='{}'> Proof: 2 &lt; 3 </h2>
22899 <p><small>Hanc marginis exiguitas non caperet.</small>
22900 QED</p>
22901 !! end
22902
22903 !! test
22904 Multiple tags in TOC
22905 !! wikitext
22906 __TOC__
22907 == <i>Foo</i> <b>Bar</b> ==
22908
22909 == <i>Foo</i> <blockquote>Bar</blockquote> ==
22910 !! html/php
22911 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22912 <ul>
22913 <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>
22914 <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>
22915 </ul>
22916 </div>
22917
22918 <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>
22919 <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>
22920
22921 !! html/php+tidy
22922 <p></p>
22923 <div id="toc" class="toc">
22924 <div class="toctitle">
22925 <h2>Contents</h2>
22926 </div>
22927 <ul>
22928 <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>
22929 <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>
22930 </ul>
22931 </div>
22932 <p></p>
22933 <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>
22934 <h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i></span></h2>
22935 <blockquote>
22936 <p><span class="mw-headline" id="Foo_Bar_2">Bar</span></p>
22937 </blockquote>
22938 <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>
22939 !! html/parsoid
22940 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
22941 <h2 data-parsoid='{}'> <i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b> </h2>
22942 <h2> <i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote>Bar</blockquote> </h2>
22943 !! end
22944
22945 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
22946 # html5 tag parsing.
22947 !! test
22948 Tags with parameters in TOC
22949 !! options
22950 parsoid=wt2html
22951 !! wikitext
22952 __TOC__
22953 == <sup class="in-h2">Hello</sup> ==
22954
22955 == <sup class="a > b">Evilbye</sup> ==
22956 !! html/php
22957 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22958 <ul>
22959 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
22960 <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>
22961 </ul>
22962 </div>
22963
22964 <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>
22965 <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>
22966
22967 !! html/parsoid
22968 <meta property="mw:PageProp/toc" />
22969 <h2> <sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup> </h2>
22970
22971 <h2> <sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup> </h2>
22972 !! end
22973
22974 !! test
22975 span tags with directionality in TOC
22976 !! wikitext
22977 __TOC__
22978 == <span dir="ltr">C++</span> ==
22979
22980 == <span dir="rtl">זבנג!</span> ==
22981
22982 == <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> ==
22983
22984 == <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> ==
22985
22986 == <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> ==
22987 !! html/php
22988 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
22989 <ul>
22990 <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>
22991 <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>
22992 <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>
22993 <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>
22994 <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>
22995 </ul>
22996 </div>
22997
22998 <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>
22999 <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>
23000 <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>
23001 <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>
23002 <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>
23003
23004 !! html/parsoid
23005 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23006 <h2 data-parsoid='{}'> <span dir="ltr">C++</span> </h2>
23007 <h2> <span dir="rtl">זבנג!</span> </h2>
23008 <h2> <span style="font-style: italic">The attributes on these span tags must be deleted from the TOC</span> </h2>
23009 <h2> <span style="font-style: italic" dir="ltr">All attributes on these span tags must be deleted from the TOC</span> </h2>
23010 <h2> <span dir="ltr" style="font-style: italic">Attributes after dir on these span tags must be deleted from the TOC</span> </h2>
23011 !! end
23012
23013 !! test
23014 T74884: bdi element in ToC
23015 !! wikitext
23016 __TOC__
23017 == <bdi>test</bdi> ==
23018 !! html/php
23019 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23020 <ul>
23021 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
23022 </ul>
23023 </div>
23024
23025 <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>
23026
23027 !! html/parsoid
23028 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23029 <h2 data-parsoid='{}'> <bdi>test</bdi> </h2>
23030 !! end
23031
23032 !! test
23033 T35715: s/strike element in ToC
23034 !! wikitext
23035 __TOC__
23036 == <s>test</s> test <strike>test</strike> ==
23037 !! html/php
23038 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23039 <ul>
23040 <li class="toclevel-1 tocsection-1"><a href="#test_test_test"><span class="tocnumber">1</span> <span class="toctext"><s>test</s> test <strike>test</strike></span></a></li>
23041 </ul>
23042 </div>
23043
23044 <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>
23045
23046 !! html/parsoid
23047 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23048 <h2 data-parsoid='{}'> <s>test</s> test <strike>test</strike> </h2>
23049 !! end
23050
23051 # Note that the html output does not have the <p></p>, but the
23052 # html+tidy output *does*. This is because the empty <p></p> is
23053 # removed by the sanitizer, but only when tidy is *not* enabled (!).
23054 !! test
23055 Empty <p> tag in TOC, removed by Sanitizer (T92892)
23056 !! wikitext
23057 __TOC__
23058 == x ==
23059 !! html/php
23060 <div id="toc" class="toc"><div class="toctitle"><h2>Contents</h2></div>
23061 <ul>
23062 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
23063 </ul>
23064 </div>
23065
23066 <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>
23067
23068 !! html/php+tidy
23069 <p></p>
23070 <div id="toc" class="toc">
23071 <div class="toctitle">
23072 <h2>Contents</h2>
23073 </div>
23074 <ul>
23075 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
23076 </ul>
23077 </div>
23078 <p></p>
23079 <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>
23080 !! html/parsoid
23081 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
23082 <h2 data-parsoid='{}'> x </h2>
23083 !! end
23084
23085 !! article
23086 MediaWiki:T34057
23087 !! text
23088 == {{int:headline_sample}} ==
23089 !! endarticle
23090
23091 !! test
23092 T34057: Title needed when expanding <h> nodes.
23093 !! options
23094 title=[[Main Page]]
23095 !! wikitext
23096 {{int:T34057}}
23097 !! html
23098 <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>
23099
23100 !! end
23101
23102 !! test
23103 Strip marker in urlencode
23104 !! wikitext
23105 {{urlencode:x<nowiki/>y}}
23106 {{urlencode:x<nowiki/>y|wiki}}
23107 {{urlencode:x<nowiki/>y|path}}
23108 {{urlencode:x<pre id="one">two</pre>y}}
23109 !! html/php
23110 <p>xy
23111 xy
23112 xy
23113 xy
23114 </p>
23115 !! end
23116
23117 !! test
23118 Strip marker in lc
23119 !! wikitext
23120 {{lc:x<nowiki/>y}}
23121 !! html
23122 <p>xy
23123 </p>
23124 !! end
23125
23126 !! test
23127 Strip marker in uc
23128 !! wikitext
23129 {{uc:x<nowiki/>y}}
23130 !! html
23131 <p>XY
23132 </p>
23133 !! end
23134
23135 !! test
23136 Strip marker in formatNum
23137 !! wikitext
23138 {{formatnum:1<nowiki/>2}}
23139 {{formatnum:1<nowiki/>2|R}}
23140 !! html
23141 <p>12
23142 12
23143 </p>
23144 !! end
23145
23146 !! test
23147 Check noCommafy in formatNum
23148 !! options
23149 language=be-tarask
23150 !! wikitext
23151 {{formatnum:123456.78}}
23152 {{formatnum:123456.78|NOSEP}}
23153 !! html
23154 <p>123 456,78
23155 123456.78
23156 </p>
23157 !! end
23158
23159 !! test
23160 Wrong option for formatNum (T58199)
23161 !! wikitext
23162 {{formatnum:1,234.56|Random}}
23163 {{formatnum:1,234.56|EVERYTHING}}
23164 {{formatnum:1234.56|any argument that has the string 'NOSEP'}}
23165 !! html
23166 <p>1,234.56
23167 1,234.56
23168 1,234.56
23169 </p>
23170 !! end
23171
23172 !! test
23173 Strip marker in grammar
23174 !! options
23175 language=fi
23176 !! wikitext
23177 {{grammar:elative|foo<nowiki/>bar}}
23178 !! html
23179 <p>foobarista
23180 </p>
23181 !! end
23182
23183 !! test
23184 Strip marker in padleft
23185 !! wikitext
23186 {{padleft:|2|x<nowiki/>y}}
23187 !! html
23188 <p>xy
23189 </p>
23190 !! end
23191
23192 !! test
23193 Strip marker in padright
23194 !! wikitext
23195 {{padright:|2|x<nowiki/>y}}
23196 !! html
23197 <p>xy
23198 </p>
23199 !! end
23200
23201 !! test
23202 Strip marker in anchorencode
23203 !! wikitext
23204 {{anchorencode:x<nowiki/>y}}
23205 !! html
23206 <p>xy
23207 </p>
23208 !! end
23209
23210 !! test
23211 nowiki inside link inside heading (T20295)
23212 !! wikitext
23213 ==[[foo|x<nowiki>y</nowiki>z]]==
23214 !! html
23215 <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>
23216
23217 !! end
23218
23219 !! test
23220 new support for bdi element (T33817)
23221 !! wikitext
23222 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
23223 !! html
23224 <p dir="rtl" lang="he">ולדימיר לנין (ברוסית: <bdi lang="ru">Владимир Ленин</bdi>, 24 באפריל 1870–22 בינואר 1924) הוא מנהיג פוליטי קומוניסטי רוסי.</p>
23225
23226 !!end
23227
23228 !! test
23229 Ignore pipe between table row attributes
23230 !! wikitext
23231 {|
23232 | quux
23233 |- id=foo | style='color: red'
23234 | bar
23235 |}
23236 !! html
23237 <table>
23238 <tr>
23239 <td> quux
23240 </td></tr>
23241 <tr id="foo" style="color: red">
23242 <td> bar
23243 </td></tr></table>
23244
23245 !! end
23246
23247 !!test
23248 Language parser function
23249 !! wikitext
23250 {{#language:ar}}
23251 !! html
23252 <p>العربية
23253 </p>
23254 !! end
23255
23256 !!test
23257 Padleft and padright as substr
23258 !! wikitext
23259 {{padleft:|3|abcde}}
23260 {{padright:|3|abcde}}
23261 !! html
23262 <p>abc
23263 abc
23264 </p>
23265 !! end
23266
23267 !!test
23268 Special parser function
23269 !! wikitext
23270 {{#special:RandomPage}}
23271 {{#special:BaDtItLe}}
23272 {{#special:Foobar}}
23273 !! html
23274 <p>Special:Random
23275 Special:Badtitle
23276 Special:Foobar
23277 </p>
23278 !! end
23279
23280 !!test
23281 T36939 - Case insensitive link parsing ([HttP://])
23282 !! wikitext
23283 [HttP://MediaWiki.Org/]
23284 !! html/php
23285 <p><a rel="nofollow" class="external autonumber" href="HttP://MediaWiki.Org/">[1]</a>
23286 </p>
23287 !! html/parsoid
23288 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/"></a></p>
23289 !! end
23290
23291 !!test
23292 T36939 - Case insensitive link parsing ([HttP:// title])
23293 !! wikitext
23294 [HttP://MediaWiki.Org/ MediaWiki]
23295 !! html
23296 <p><a rel="nofollow" class="external text" href="HttP://MediaWiki.Org/">MediaWiki</a>
23297 </p>
23298 !! end
23299
23300 !!test
23301 T36939 - Case insensitive link parsing (HttP://)
23302 !! wikitext
23303 HttP://MediaWiki.Org/
23304 !! html/php
23305 <p><a rel="nofollow" class="external free" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a>
23306 </p>
23307 !! html/parsoid
23308 <p><a rel="mw:ExtLink" href="HttP://MediaWiki.Org/">HttP://MediaWiki.Org/</a></p>
23309 !! end
23310
23311 !!test
23312 Disable TOC
23313 !! options
23314 notoc
23315 !! wikitext
23316 Lead
23317 == Section 1 ==
23318 == Section 2 ==
23319 == Section 3 ==
23320 == Section 4 ==
23321 == Section 5 ==
23322 !! html
23323 <p>Lead
23324 </p>
23325
23326 <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>
23327 <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>
23328 <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>
23329 <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>
23330 <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>
23331
23332 !! end
23333
23334
23335 ###
23336 ### Parsoid-specific tests
23337 ### Parsoid-PHP parser incompatibilities
23338 ###
23339 !!test
23340 1. SOL-sensitive wikitext tokens as template-args
23341 !!options
23342 parsoid=wt2html,wt2wt
23343 !! wikitext
23344 {{echo|*a}}
23345 {{echo|#a}}
23346 {{echo|:a}}
23347 !! html
23348 <span about="#mwt1" typeof="mw:Transclusion">
23349 </span><ul about="#mwt1"><li>a</li>
23350 </ul>
23351 <span about="#mwt2" typeof="mw:Transclusion">
23352 </span><ol about="#mwt2"><li>a</li>
23353 </ol>
23354 <span about="#mwt3" typeof="mw:Transclusion">
23355 </span><dl about="#mwt3"><dd>a</dd>
23356 </dl>
23357 !!end
23358
23359 #### -----------------------------------------------------------------
23360 #### Parsoid-specific functionality tests
23361 #### -----------------------------------------------------------------
23362
23363 # T65642/T68749: Formatting elt fixup around images is cleaned up.
23364 # We know wt2wt will fail, but we expect selser to pass.
23365 # Due to the nature of our testing, wt2wt and selser tests will enter the
23366 # blacklist and we'll catch selser regressions based on changes to the
23367 # blacklist entries for selser tests.
23368 !! test
23369 1. Bad treebuilder fixup of formatting elt is cleaned up
23370 !! options
23371 parsoid=wt2html,wt2wt
23372 !! wikitext
23373 {|
23374 |
23375 <small>
23376 [[Image:Foobar.jpg|right|Test]]
23377 </small>
23378 |}
23379 !! html/parsoid
23380 <table>
23381 <tbody><tr><td>
23382 <small>
23383 <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>
23384 </small>
23385 </td></tr>
23386 </tbody></table>
23387 !! end
23388
23389 !! test
23390 2. Bad treebuilder fixup of formatting elt is cleaned up
23391 !! options
23392 parsoid=wt2html,wt2wt
23393 !! wikitext
23394 '''foo[[File:Foobar.jpg|thumb|caption]]bar'''
23395
23396 <small>[[Image:Foobar.jpg|right|300px]]</small>
23397 !! html/parsoid
23398
23399 <p><b>foo</b></p>
23400 <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>
23401 <p><b>bar</b></p>
23402 <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>
23403 !! end
23404
23405 !! test
23406 3. Bad treebuilder fixup of formatting elt is cleaned up
23407 !! options
23408 parsoid=wt2html,wt2wt
23409 !! wikitext
23410 <small>'''foo[[File:Foobar.jpg|thumb|caption]]bar'''</small>
23411 !! html/parsoid
23412 <p><small><b>foo</b></small></p>
23413 <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>
23414 <p><small><b>bar</b></small></p>
23415 !! end
23416
23417 !! test
23418 4. Bad treebuilder fixup of formatting elt is cleaned up: formatting tags around captionless images are ignored
23419 !! options
23420 parsoid=wt2html,wt2wt
23421 !! wikitext
23422 '''<small>[[Image:Foobar.jpg|right|300px]]</small>'''
23423 !! html/parsoid
23424 <p><b><small></small></b></p>
23425 <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>
23426 <p></p>
23427 !! end
23428
23429 #### ----------------------------------------------------------------
23430 #### Parsoid-only testing of Parsoid's impl of LST
23431 #### Not implemented yet, see
23432 #### https://www.mediawiki.org/wiki/Parsoid/HTML_based_LST
23433 #### ----------------------------------------------------------------
23434
23435 ## We still need to support serializing the older format while content is stored.
23436 !! test
23437 LST Sections: Backwards compatibility
23438 !! options
23439 parsoid={
23440 "suppressErrors": true,
23441 "modes": ["html2wt"]
23442 }
23443 !! wikitext
23444 <section begin="2011-05-16" />
23445 <section end="2014-04-10 (MW 1.23wmf22)" />
23446 !! html/parsoid
23447 <p><meta typeof="mw:Extension/LabeledSectionTransclusion/begin" content="2011-05-16"/>
23448 <meta typeof="mw:Extension/LabeledSectionTransclusion/end" content="2014-04-10 (MW 1.23wmf22)"/></p>
23449 !! end
23450
23451 !! test
23452 LST Sections: Newfangled approach
23453 !! wikitext
23454 <section begin="2011-05-16" />
23455 <section end="2014-04-10 (MW 1.23wmf22)" />
23456 !! html/parsoid
23457 <p><span typeof="mw:Extension/section" about="#mwt4" data-mw='{"name":"section","attrs":{"begin":"2011-05-16"},"body":null}'>
23458 </span>
23459 <span typeof="mw:Extension/section" about="#mwt6" data-mw='{"name":"section","attrs":{"end":"2014-04-10 (MW 1.23wmf22)"},"body":null}'>
23460 </span></p>
23461 !! end
23462
23463 #--------- Test stripping of empty nodes in template content ----------
23464
23465 !! test
23466 Empty LI and TR nodes should be stripped from template content
23467 !! wikitext
23468 {{EmptyLITest}}
23469 {{EmptyTRTest}}
23470 !! html/parsoid
23471 <ul about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyLITest","href":"./Template:EmptyLITest"},"params":{},"i":0}}]}'>
23472 <li>a</li>
23473 <li>b</li>
23474 </ul>
23475 <table about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRTest","href":"./Template:EmptyTRTest"},"params":{},"i":0}}]}'>
23476 <tbody>
23477 <tr>
23478 <td>foo</td>
23479 </tr>
23480 <tr>
23481 <td>bar</td>
23482 </tr>
23483 </tbody>
23484 </table>
23485 !! end
23486
23487 !! test
23488 Empty LI and TR nodes should not be stripped from top-level content
23489 !! wikitext
23490 * a
23491 *
23492 * b
23493 {|
23494 |-
23495 |-
23496 |foo
23497 |}
23498 !! html/parsoid
23499 <ul>
23500 <li> a</li>
23501 <li></li>
23502 <li> b</li>
23503 </ul>
23504 <table>
23505 <tbody>
23506 <tr></tr>
23507 <tr>
23508 <td>foo</td>
23509 </tr>
23510 </tbody>
23511 </table>
23512 !! end
23513
23514 !! test
23515 Empty TR nodes should not be stripped if they have any attributes set
23516 !! wikitext
23517 {{EmptyTRWithHTMLAttrTest}}
23518 !! html/parsoid
23519 <table about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"EmptyTRWithHTMLAttrTest","href":"./Template:EmptyTRWithHTMLAttrTest"},"params":{},"i":0}}]}'>
23520 <tr align="center"></tr>
23521 <tr><td>foo</td></tr>
23522 <tr align="center"></tr>
23523 <tr><td>bar</td></tr>
23524 </table>
23525 !! end
23526
23527 #### ----------------------------------------------------------------
23528 #### The following section of tests are primarily to test
23529 #### wikitext escaping capabilities of Parsoid. Given that
23530 #### escaping can be done any number of ways, the wikitext (input)
23531 #### is always adjusted to reflect how Parsoid adds nowiki
23532 #### escape tags.
23533 ####
23534 #### We are marking several tests as parsoid-only since the
23535 #### HTML in the result section is different from what the
23536 #### PHP parser generates for it.
23537 #### ----------------------------------------------------------------
23538
23539
23540 #### --------------- Headings ---------------
23541 #### 0. Unnested
23542 #### 1. Nested inside html <h1>=foo=</h1>
23543 #### 2. Outside heading nest on a single line <h1>foo</h1>*bar
23544 #### 3. Nested inside html with wikitext split by html tags
23545 #### 4. No escape needed
23546 #### 5. Empty headings <h1></h1>
23547 #### 6. Heading chars in SOL context
23548 #### ----------------------------------------
23549 !! test
23550 Headings: 0. Unnested
23551 !! options
23552 parsoid=html2wt
23553 !! html/parsoid
23554 <p>=foo=</p>
23555
23556 <p> =foo=
23557 <!--cmt-->
23558 =foo=</p>
23559
23560 <p>=foo<i>a</i>=</p>
23561 !! wikitext
23562 <nowiki>=foo=</nowiki>
23563
23564 <nowiki> </nowiki>=foo=
23565 <!--cmt-->
23566 <nowiki>=foo=</nowiki>
23567
23568 =foo''a''<nowiki>=</nowiki>
23569 !!end
23570
23571 # New headings and existing headings are handled differently
23572 !! test
23573 Headings: 1. Nested inside html
23574 !! options
23575 parsoid=html2wt
23576 !! html/parsoid
23577 <h1>=foo=</h1>
23578 <h2>=foo=</h2>
23579 <h3>=foo=</h3>
23580
23581 <h1 data-parsoid=''>=foo=</h1>
23582 <h2 data-parsoid=''>=foo=</h2>
23583 <h3 data-parsoid=''>=foo=</h3>
23584 <h4 data-parsoid=''>=foo=</h4>
23585 <h5 data-parsoid=''>=foo=</h5>
23586 <h6 data-parsoid=''>=foo=</h6>
23587 !! wikitext
23588 = =foo= =
23589
23590 == =foo= ==
23591
23592 === =foo= ===
23593
23594 =<nowiki>=foo=</nowiki>=
23595 ==<nowiki>=foo=</nowiki>==
23596 ===<nowiki>=foo=</nowiki>===
23597 ====<nowiki>=foo=</nowiki>====
23598 =====<nowiki>=foo=</nowiki>=====
23599 ======<nowiki>=foo=</nowiki>======
23600
23601 !!end
23602
23603 !! test
23604 Headings: 2. Outside heading nest on a single line <h1>foo</h1>*bar
23605 !! options
23606 parsoid=html2wt
23607 !! html/parsoid
23608 <h1>foo</h1>*bar
23609 <h1>foo</h1>=bar
23610 <h1>foo</h1>=bar=
23611 !! wikitext
23612 = foo =
23613 <nowiki>*</nowiki>bar
23614
23615 = foo =
23616 =bar
23617
23618 = foo =
23619 <nowiki>=bar=</nowiki>
23620 !!end
23621
23622 !! test
23623 Headings: 3. Nested inside html with wikitext split by html tags
23624 !! options
23625 parsoid=html2wt
23626 !! html/parsoid
23627 <h1>=<b>bold</b>foo=</h1>
23628 !! wikitext
23629 = ='''bold'''foo= =
23630 !!end
23631
23632 !! test
23633 Headings: 4a. No escaping needed (testing just h1 and h2)
23634 !! options
23635 parsoid=html2wt
23636 !! html/parsoid
23637 <h1>=foo</h1>
23638 <h1>foo=</h1>
23639 <h1> =foo= </h1>
23640 <h1>=foo= bar</h1>
23641 <h2>=foo</h2>
23642 <h2>foo=</h2>
23643 <h1>=</h1>
23644 <h1><i>=</i>foo=</h1>
23645 !! wikitext
23646 = =foo =
23647
23648 = foo= =
23649
23650 = =foo= =
23651
23652 = =foo= bar =
23653
23654 == =foo ==
23655
23656 == foo= ==
23657
23658 = = =
23659
23660 = ''=''foo= =
23661 !!end
23662
23663 !! test
23664 Headings: 4b. No escaping needed (inside p-tags)
23665 !! options
23666 parsoid=html2wt
23667 !! html/parsoid
23668 <p>===
23669 =foo= x
23670 =foo= <s></s>
23671 </p>
23672 !! wikitext
23673 ===
23674 =foo= x
23675 =foo= <s></s>
23676 !!end
23677
23678 !! test
23679 Headings: 5. Empty headings
23680 !! options
23681 parsoid=html2wt
23682 !! html/parsoid
23683 <h1 data-parsoid='{}'></h1>
23684
23685 <h2 data-parsoid='{}'></h2>
23686
23687 <h3 data-parsoid='{}'></h3>
23688
23689 <h4 data-parsoid='{}'></h4>
23690
23691 <h5 data-parsoid='{}'></h5>
23692
23693 <h6 data-parsoid='{}'></h6>
23694 !! wikitext
23695 =<nowiki/>=
23696
23697 ==<nowiki/>==
23698
23699 ===<nowiki/>===
23700
23701 ====<nowiki/>====
23702
23703 =====<nowiki/>=====
23704
23705 ======<nowiki/>======
23706 !!end
23707
23708 !! test
23709 Headings: 6a. Heading chars in SOL context (with trailing spaces)
23710 !! options
23711 parsoid=html2wt
23712 !! html/parsoid
23713 <p>=a=</p>
23714
23715 <p>=a=</p>
23716
23717 <p>=a=</p>
23718 !! wikitext
23719 <nowiki>=a=</nowiki>
23720
23721 <nowiki>=a=</nowiki>
23722
23723 <nowiki>=a=</nowiki>
23724 !!end
23725
23726 !! test
23727 Headings: 6b. Heading chars in SOL context (with trailing newlines)
23728 !! options
23729 parsoid=html2wt
23730 !! html/parsoid
23731 <p>=a=
23732 b</p>
23733
23734 <p>=a=
23735 b</p>
23736
23737 <p>=a=
23738 b</p>
23739 !! wikitext
23740 <nowiki>=a=</nowiki>
23741 b
23742
23743 <nowiki>=a=</nowiki>
23744 b
23745
23746 <nowiki>=a=</nowiki>
23747 b
23748 !!end
23749
23750 !! test
23751 Headings: 6c. Heading chars in SOL context (leading newline break)
23752 !! options
23753 parsoid=html2wt
23754 !! html/parsoid
23755 <p>a
23756 =b=</p>
23757 !! wikitext
23758 a
23759 <nowiki>=b=</nowiki>
23760 !!end
23761
23762 !! test
23763 Headings: 6d. Heading chars in SOL context (with interspersed comments)
23764 !! options
23765 parsoid=html2wt
23766 !! html/parsoid
23767 <!--c0--><p>=a=</p>
23768
23769 <!--c1--><p>=a=</p> <!--c2--> <!--c3-->
23770 !! wikitext
23771 <!--c0--><nowiki>=a=</nowiki>
23772
23773 <!--c1--><nowiki>=a=</nowiki> <!--c2--> <!--c3-->
23774 !!end
23775
23776 !! test
23777 Headings: 6d. Heading chars in SOL context (No escaping needed)
23778 !! options
23779 parsoid=html2wt
23780 !! html/parsoid
23781 =a=<div>b</div>
23782 !! wikitext
23783 =a=<div>b</div>
23784 !!end
23785
23786 !! test
23787 Headings: 7. Insert a newline between new content and headings
23788 !! options
23789 parsoid=html2wt
23790 !! html/parsoid
23791 <h2>NEW</h2>
23792 <p>new</p>
23793 <h2 data-parsoid='{}'>A</h2>
23794 <p data-parsoid='{}'>a</p>
23795 !! wikitext
23796 == NEW ==
23797 new
23798
23799 ==A==
23800 a
23801
23802 !! end
23803
23804 #### --------------- Lists ---------------
23805 #### 0. Outside nests (*foo, etc.)
23806 #### 1. Nested inside html <ul><li>*foo</li></ul>
23807 #### 2. Inside definition lists
23808 #### 3. Only bullets at start should be escaped
23809 #### 4. No escapes needed
23810 #### 5. No unnecessary escapes
23811 #### 6. Escape bullets in SOL position
23812 #### 7. Escape bullets in a multi-line context
23813 #### ----------------------------------------
23814
23815 !! test
23816 Lists: 0. Outside nests
23817 !! options
23818 parsoid=html2wt
23819 !! html/parsoid
23820 <p>*foo</p>
23821
23822 <p>#foo</p>
23823
23824 <p>;Foo:bar</p>
23825 !! wikitext
23826 <nowiki>*</nowiki>foo
23827
23828 <nowiki>#</nowiki>foo
23829
23830 <nowiki>;</nowiki>Foo<nowiki>:</nowiki>bar
23831 !!end
23832
23833 ## Making these next 3 tests Parsoid-only since they are html2wt tests
23834 ## to test wikitext escaping, and insignificant whitespace diffs
23835 ## cause PHP parser tests to barf
23836 !! test
23837 Lists: 1. Nested inside html (No unnecessary escapes)
23838 !! options
23839 parsoid=html2wt
23840 !! html/parsoid
23841 <ul>
23842 <li>*foo</li>
23843 <li>#foo</li>
23844 <li>:foo</li>
23845 <li>;foo</li>
23846 <li data-parsoid='{}'>*foo</li>
23847 <li data-parsoid='{}'>#foo</li>
23848 <li data-parsoid='{}'>:foo</li>
23849 <li data-parsoid='{}'>;foo</li>
23850 </ul>
23851
23852 <ol>
23853 <li>*foo</li>
23854 <li>#foo</li>
23855 <li>:foo</li>
23856 <li>;foo</li>
23857 <li data-parsoid='{}'>*foo</li>
23858 <li data-parsoid='{}'>#foo</li>
23859 <li data-parsoid='{}'>:foo</li>
23860 <li data-parsoid='{}'>;foo</li>
23861 </ol>
23862 !! wikitext
23863 * *foo
23864 * #foo
23865 * :foo
23866 * ;foo
23867 *<nowiki>*foo</nowiki>
23868 *<nowiki>#foo</nowiki>
23869 *<nowiki>:foo</nowiki>
23870 *<nowiki>;foo</nowiki>
23871
23872 # *foo
23873 # #foo
23874 # :foo
23875 # ;foo
23876 #<nowiki>*foo</nowiki>
23877 #<nowiki>#foo</nowiki>
23878 #<nowiki>:foo</nowiki>
23879 #<nowiki>;foo</nowiki>
23880 !!end
23881
23882 !! test
23883 Lists: 2. Inside definition lists
23884 !! options
23885 parsoid=html2wt
23886 !! html/parsoid
23887 <dl><dt>;foo</dt></dl>
23888 <dl><dt>:foo</dt></dl>
23889 <dl><dt>:foo</dt>
23890 <dd>bar</dd></dl>
23891 <dl><dd>:foo</dd></dl>
23892 !! wikitext
23893 ; ;foo
23894
23895 ; <nowiki>:foo</nowiki>
23896
23897 ; <nowiki>:foo</nowiki>
23898 : bar
23899
23900 : :foo
23901 !!end
23902
23903 !! test
23904 Lists: 3. Only bullets at start of text in wikitext-generated HTML should be escaped
23905 !! options
23906 parsoid=html2wt
23907 !! html/parsoid
23908 <ul>
23909 <li>*foo*bar</li>
23910 <li data-parsoid='{}'>*foo<i>it</i>*bar</li>
23911 </ul>
23912 !! wikitext
23913 * *foo*bar
23914 *<nowiki>*foo</nowiki>''it''*bar
23915 !!end
23916
23917 !! test
23918 Lists: 4. No escapes needed
23919 !! options
23920 parsoid=html2wt
23921 !! html/parsoid
23922 <ul>
23923 <li>foo*bar
23924 </li>
23925 </ul>
23926 <ul>
23927 <li><i>foo</i>*bar
23928 </li>
23929 </ul>
23930 <ul>
23931 <li><a rel="mw:WikiLink" href="Foo" title="Foo">Foo</a>: 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 !! wikitext
23939 *foo*bar
23940
23941 *''foo''*bar
23942
23943 *[[Foo]]: bar
23944
23945 *[[Foo]]*bar
23946 !!end
23947
23948 !! test
23949 Lists: 5. No unnecessary escapes
23950 !! options
23951 parsoid=html2wt
23952 !! html/parsoid
23953 <ul><li> bar <span>[[foo]]</span></li></ul>
23954 <ul><li> =bar <span>[[foo]]</span></li></ul>
23955 <ul><li> [[bar <span>[[foo]]</span></li></ul>
23956 <ul><li> ]]bar <span>[[foo]]</span></li></ul>
23957 <ul><li> =bar <span>foo]]</span>=</li></ul>
23958 <ul><li> <s></s>: a</li></ul>
23959 <ul><li> <i>* foo</i></li></ul>
23960
23961 !! wikitext
23962 * bar <span><nowiki>[[foo]]</nowiki></span>
23963
23964 * =bar <span><nowiki>[[foo]]</nowiki></span>
23965
23966 * [[bar <span><nowiki>[[foo]]</nowiki></span>
23967
23968 * ]]bar <span><nowiki>[[foo]]</nowiki></span>
23969
23970 * =bar <span>foo]]</span>=
23971
23972 * <s></s>: a
23973
23974 * ''* foo''
23975 !!end
23976
23977 !! test
23978 Lists: 6. Escape bullets in SOL position
23979 !! options
23980 parsoid=html2wt
23981 !! html/parsoid
23982 <p><!--cmt-->*foo</p>
23983 !! wikitext
23984 <!--cmt--><nowiki>*</nowiki>foo
23985 !!end
23986
23987 !! test
23988 Lists: 7. Escape bullets in a multi-line context
23989 !! options
23990 parsoid=html2wt
23991 !! html/parsoid
23992 <p>a
23993 *b
23994 </p>
23995 !! wikitext
23996 a
23997 <nowiki>*</nowiki>b
23998 !!end
23999
24000 !! test
24001 Lists: 8. Escape colons only if not present in tags
24002 !! options
24003 parsoid=html2wt
24004 !! html/parsoid
24005 <dl><dt>a:b<i>c:d</i></dt></dl>
24006 !! wikitext
24007 ; <nowiki>a:b</nowiki>''c:d''
24008 !! end
24009
24010 #### --------------- HRs ---------------
24011 #### 1. Single line
24012 #### -----------------------------------
24013
24014 !! test
24015 HRs: 1. Single line
24016 !! options
24017 parsoid=html2wt
24018 !! html/parsoid
24019 <hr />----
24020 <hr />=foo=
24021 <hr />*foo
24022 !! wikitext
24023 ----<nowiki>----</nowiki>
24024 ----=foo=
24025 ----*foo
24026 !! end
24027
24028 #### --------------- Tables ---------------
24029 #### 1a. Simple example
24030 #### 1b. No escaping needed (!foo)
24031 #### 1c. No escaping needed (|foo)
24032 #### 1d. No escaping needed (|}foo)
24033 ####
24034 #### 2a. Nested in td (<td>foo|bar</td>)
24035 #### 2b. Nested in td (<td>foo||bar</td>)
24036 #### 2c. Nested in td -- no escaping needed(<td>foo!!bar</td>)
24037 ####
24038 #### 3a. Nested in th (<th>foo!bar</th>)
24039 #### 3b. Nested in th (<th>foo!!bar</th>)
24040 #### 3c. Nested in th -- no escaping needed(<th>foo||bar</th>)
24041 ####
24042 #### 4a. Escape -
24043 #### 4b. Escape +
24044 #### 4c. No escaping needed
24045 #### --------------------------------------
24046
24047 !! test
24048 Tables: 1a. Simple example
24049 !! options
24050 parsoid=html2wt
24051 !! html/parsoid
24052 <p>{|
24053 |}
24054 </p>
24055 !! wikitext
24056 <nowiki>{|</nowiki>
24057 |}
24058 !! end
24059
24060 !! test
24061 Tables: 1b. No escaping needed
24062 !! options
24063 parsoid=html2wt
24064 !! html/parsoid
24065 <p>!foo
24066 </p>
24067 !! wikitext
24068 !foo
24069 !! end
24070
24071 !! test
24072 Tables: 1c. No escaping needed
24073 !! options
24074 parsoid=html2wt
24075 !! html/parsoid
24076 <p>|foo
24077 </p>
24078 !! wikitext
24079 |foo
24080 !! end
24081
24082 !! test
24083 Tables: 1d. No escaping needed
24084 !! options
24085 parsoid=html2wt
24086 !! html/parsoid
24087 <p>|}foo
24088 </p>
24089 !! wikitext
24090 |}foo
24091 !! end
24092
24093 !! test
24094 Tables: 2a. Nested in td
24095 !! options
24096 parsoid=html2wt
24097 !! html/parsoid
24098 <table><tbody><tr>
24099 <td>foo|bar</td></tr>
24100 <tr><td>x<div>a|b</div></td>
24101 </tbody></table>
24102 !! wikitext
24103 {|
24104 |<nowiki>foo|bar</nowiki>
24105 |-
24106 |x<div><nowiki>a|b</nowiki></div>
24107 |}
24108 !! html/php+tidy
24109 <table>
24110 <tr>
24111 <td>foo|bar</td>
24112 </tr>
24113 <tr>
24114 <td>x
24115 <div>a|b</div>
24116 </td>
24117 </tr>
24118 </table>
24119 !! end
24120
24121 !! test
24122 Tables: 2b. Nested in td
24123 !! options
24124 parsoid=html2wt
24125 !! html/parsoid
24126 <table><tbody><tr>
24127 <td>foo||bar</td>
24128 <td>a<i>b||c</i></td>
24129 <td>a<i><div>b||c</div></i></td>
24130 </tr></tbody></table>
24131 !! wikitext
24132 {|
24133 |<nowiki>foo||bar</nowiki>
24134 |a''<nowiki>b||c</nowiki>''
24135 |a''<div><nowiki>b||c</nowiki></div>''
24136 |}
24137 !! html/php
24138 <table>
24139 <tr>
24140 <td>foo||bar
24141 </td>
24142 <td>a<i>b||c</i>
24143 </td>
24144 <td>a<i><div>b||c</div></i>
24145 </td></tr></table>
24146
24147 !! end
24148
24149 !! test
24150 Tables: 2c. Nested in td -- no escaping needed
24151 !! options
24152 parsoid=html2wt
24153 !! html/*
24154 <table>
24155 <tr>
24156 <td>foo!!bar
24157 </td></tr></table>
24158
24159 !! wikitext
24160 {|
24161 |foo!!bar
24162 |}
24163 !! end
24164
24165 !! test
24166 Tables: 3a. Nested in th
24167 !! options
24168 parsoid=html2wt
24169 !! html/*
24170 <table>
24171 <tr>
24172 <th>foo!bar
24173 </th></tr></table>
24174
24175 !! wikitext
24176 {|
24177 !foo!bar
24178 |}
24179 !! end
24180
24181 !! test
24182 Tables: 3b. Nested in th
24183 !! options
24184 parsoid=html2wt
24185 !! html/parsoid
24186 <table><tbody>
24187 <tr><th>foo!!bar</th>
24188 <th><i>foo|bar</i></th>
24189 <th><i>foo!!bar</i></th>
24190 <th><i><span>foo!!bar</span></i></th>
24191 </tr></tbody></table>
24192 !! wikitext
24193 {|
24194 !<nowiki>foo!!bar</nowiki>
24195 !''<nowiki>foo|bar</nowiki>''
24196 !''<nowiki>foo!!bar</nowiki>''
24197 !''<span><nowiki>foo!!bar</nowiki></span>''
24198 |}
24199 !! html/php
24200 <table>
24201 <tr>
24202 <th>foo!!bar
24203 </th>
24204 <th><i>foo|bar</i>
24205 </th>
24206 <th><i>foo!!bar</i>
24207 </th>
24208 <th><i><span>foo!!bar</span></i>
24209 </th></tr></table>
24210
24211 !! end
24212
24213 !! test
24214 Tables: 3c. Nested in th
24215 !! options
24216 parsoid=html2wt
24217 !! html/parsoid
24218 <table><tbody>
24219 <tr><th>foo||bar</th>
24220 <th><span typeof="mw:Nowiki">foo||bar</span></th>
24221 </tr></tbody></table>
24222 !! wikitext
24223 {|
24224 !<nowiki>foo||bar</nowiki>
24225 !<nowiki>foo||bar</nowiki>
24226 |}
24227 !! html/php
24228 <table>
24229 <tr>
24230 <th>foo||bar
24231 </th>
24232 <th>foo||bar
24233 </th></tr></table>
24234
24235 !! end
24236
24237 !! test
24238 Tables: 4a. Escape -
24239 !! options
24240 parsoid=html2wt
24241 !! html/*
24242 <table>
24243 <tr>
24244 <th>-bar
24245 </th></tr>
24246 <tr>
24247 <td>-bar
24248 </td></tr></table>
24249
24250 !! wikitext
24251 {|
24252 !-bar
24253 |-
24254 |<nowiki>-bar</nowiki>
24255 |}
24256 !! end
24257
24258 !! test
24259 Tables: 4b. Escape +
24260 !! options
24261 parsoid=html2wt
24262 !! html/*
24263 <table>
24264 <tr>
24265 <th>+bar
24266 </th></tr>
24267 <tr>
24268 <td>+bar
24269 </td></tr></table>
24270
24271 !! wikitext
24272 {|
24273 !+bar
24274 |-
24275 |<nowiki>+bar</nowiki>
24276 |}
24277 !! end
24278
24279 !! test
24280 Tables: 4c. No escaping needed
24281 !! options
24282 parsoid=html2wt
24283 !! html/parsoid
24284 <table><tbody>
24285 <tr><td>foo-bar</td><td>foo+bar</td></tr>
24286 <tr><td><i>foo</i>-bar</td><td><i>foo</i>+bar</td></tr>
24287 <tr><td>foo
24288 <p>bar|baz
24289 +bar
24290 -bar</p></td></tr>
24291 <tr><td>x
24292 <div>a|b</div></td>
24293 </tbody></table>
24294 !! wikitext
24295 {|
24296 |foo-bar
24297 |foo+bar
24298 |-
24299 |''foo''-bar
24300 |''foo''+bar
24301 |-
24302 |foo
24303 bar|baz
24304 +bar
24305 -bar
24306 |-
24307 |x
24308 <div>a|b</div>
24309 |}
24310 !! html/php
24311 <table>
24312 <tr>
24313 <td>foo-bar
24314 </td>
24315 <td>foo+bar
24316 </td></tr>
24317 <tr>
24318 <td><i>foo</i>-bar
24319 </td>
24320 <td><i>foo</i>+bar
24321 </td></tr>
24322 <tr>
24323 <td>foo
24324 <p>bar|baz
24325 +bar
24326 -bar
24327 </p>
24328 </td></tr>
24329 <tr>
24330 <td>x
24331 <div>a|b</div>
24332 </td></tr></table>
24333
24334 !! end
24335
24336 !! test
24337 Tables: 4d. No escaping needed
24338 !! options
24339 parsoid=html2wt
24340 !! html/parsoid
24341 <table>
24342 <tbody><tr><td><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>-bar</td>
24343 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>+1</td>
24344 <td data-parsoid='{"startTagSrc":"|","attrSepSrc":"|"}'>-2</td></tr>
24345 </tbody></table>
24346 !! wikitext
24347 {|
24348 |[[Foo]]-bar
24349 ||+1
24350 ||-2
24351 |}
24352 !! html/php
24353 <table>
24354 <tr>
24355 <td><a href="/wiki/Foo" title="Foo">Foo</a>-bar
24356 </td>
24357 <td>+1
24358 </td>
24359 <td>-2
24360 </td></tr></table>
24361
24362 !! end
24363
24364 !! test
24365 T97430: Don't emit empty nowiki pairs around marker meta tags
24366 !! options
24367 parsoid=html2wt
24368 !! html/parsoid
24369 <p>*This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
24370 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.</p>
24371 !! wikitext
24372 <nowiki>*</nowiki>This is a long sentence here that will make the nowiki algo split up the nowikis into multiple pairs
24373 |** Make this another long long long sentence forcing the nowiki algo to split up the nowikis.
24374 !! end
24375
24376 !! test
24377 Unclosed xmlish element in table line shouldn't eat end delimiters
24378 !! options
24379 parsoid=html2wt
24380 !! html/parsoid
24381 <table>
24382 <tbody><tr><td> &lt;foo</td>
24383 <td> bar></td></tr>
24384 </tbody></table>
24385 !! wikitext
24386 {|
24387 | <foo
24388 | bar>
24389 |}
24390 !! html/php
24391 <table>
24392 <tr>
24393 <td> &lt;foo
24394 </td>
24395 <td> bar&gt;
24396 </td></tr></table>
24397
24398 !! end
24399
24400 #### --------------- Links ----------------
24401 #### 1. Quote marks in link text
24402 #### 2. Wikilinks: Escapes needed
24403 #### 3. Wikilinks: No escapes needed
24404 #### 4. Extlinks: Escapes needed
24405 #### 5. Extlinks: No escapes needed
24406 #### --------------------------------------
24407 !! test
24408 Links 1. WikiLinks: No escapes needed
24409 !! options
24410 parsoid=html2wt
24411 !! html/parsoid
24412 <p><a rel="mw:WikiLink" href="Foo" title="Foo">Foo<i>boo</i></a>
24413 <a rel="mw:WikiLink" href="Foo" title="Foo">[Foobar]</a>
24414 <a rel="mw:WikiLink" href="Foo" title="Foo">x [Foobar] x</a></p>
24415 !! wikitext
24416 [[Foo|Foo''boo'']]
24417 [[Foo|[Foobar]]]
24418 [[Foo|x [Foobar] x]]
24419 !! html/php
24420 <p><a href="/wiki/Foo" title="Foo">Foo<i>boo</i></a>
24421 <a href="/wiki/Foo" title="Foo">[Foobar]</a>
24422 <a href="/wiki/Foo" title="Foo">x [Foobar] x</a>
24423 </p>
24424 !! end
24425
24426 !! test
24427 Links 2. WikiLinks: Escapes needed
24428 !! options
24429 parsoid=html2wt
24430 !! html/parsoid
24431 <a href="Foo" rel="mw:WikiLink">Foobar]</a>
24432 <a href="Foo" rel="mw:WikiLink">x [http://google.com g] x</a>
24433 <a href="Foo" rel="mw:WikiLink">[[Bar]]</a>
24434 <a href="Foo" rel="mw:WikiLink">x [[Bar]] x</a>
24435 <a href="Foo" rel="mw:WikiLink">|Bar</a>
24436 <a href="Foo" rel="mw:WikiLink">]]bar</a>
24437 <a href="Foo" rel="mw:WikiLink">[[bar</a>
24438 <a href="Foo" rel="mw:WikiLink">x [[ y</a>
24439 <a href="Foo" rel="mw:WikiLink">x ]] y</a>
24440 <a href="Foo" rel="mw:WikiLink">x ]] y [[ z</a>
24441 !! wikitext
24442 [[Foo|<nowiki>Foobar]</nowiki>]]
24443 [[Foo|x <nowiki>[http://google.com g]</nowiki> x]]
24444 [[Foo|<nowiki>[[Bar]]</nowiki>]]
24445 [[Foo|<nowiki>x [[Bar]] x</nowiki>]]
24446 [[Foo|<nowiki>|Bar</nowiki>]]
24447 [[Foo|<nowiki>]]bar</nowiki>]]
24448 [[Foo|<nowiki>[[bar</nowiki>]]
24449 [[Foo|<nowiki>x [[ y</nowiki>]]
24450 [[Foo|<nowiki>x ]] y</nowiki>]]
24451 [[Foo|<nowiki>x ]] y [[ z</nowiki>]]
24452 !! html/php
24453 <p><a href="/wiki/Foo" title="Foo">Foobar]</a>
24454 <a href="/wiki/Foo" title="Foo">x [http://google.com g] x</a>
24455 <a href="/wiki/Foo" title="Foo">[[Bar]]</a>
24456 <a href="/wiki/Foo" title="Foo">x [[Bar]] x</a>
24457 <a href="/wiki/Foo" title="Foo">|Bar</a>
24458 <a href="/wiki/Foo" title="Foo">]]bar</a>
24459 <a href="/wiki/Foo" title="Foo">[[bar</a>
24460 <a href="/wiki/Foo" title="Foo">x [[ y</a>
24461 <a href="/wiki/Foo" title="Foo">x ]] y</a>
24462 <a href="/wiki/Foo" title="Foo">x ]] y [[ z</a>
24463 </p>
24464 !! end
24465
24466 !! test
24467 Links 3. WikiLinks: No escapes needed
24468 !! options
24469 parsoid=html2wt
24470 !! html/parsoid
24471 <p><a rel="mw:WikiLink" href="Foo">[Foobar</a>
24472 <a rel="mw:WikiLink" href="Foo" title="Foo">foo|bar</a></p>
24473 !! wikitext
24474 [[Foo|[Foobar]]
24475 [[Foo|foo|bar]]
24476 !! html/php
24477 <p><a href="/wiki/Foo" title="Foo">[Foobar</a>
24478 <a href="/wiki/Foo" title="Foo">foo|bar</a>
24479 </p>
24480 !! end
24481
24482 !! test
24483 Links 4. ExtLinks: Escapes needed
24484 !! options
24485 parsoid=html2wt
24486 !! html/parsoid
24487 <p><a rel="mw:ExtLink" href="http://google.com">[google]</a>
24488 <a rel="mw:ExtLink" href="http://google.com">google]</a>
24489 <a rel="mw:ExtLink" href="http://google.com">goog] le</a></p>
24490 <p>[http://google.com]</p>
24491 <p>[http://google.com google]</p>
24492 <p>[<a rel="mw:ExtLink" href="http://google.com">http://google.com</a>]</p>
24493 <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>
24494 !! wikitext
24495 [http://google.com <nowiki>[google]</nowiki>]
24496 [http://google.com <nowiki>google]</nowiki>]
24497 [http://google.com <nowiki>goog] le</nowiki>]
24498
24499 <nowiki>[http://google.com]</nowiki>
24500
24501 <nowiki>[http://google.com google]</nowiki>
24502
24503 [http://google.com<nowiki>]</nowiki>
24504
24505 [{{echo|http://google.com}}<nowiki>]</nowiki>
24506 !! html/php
24507 <p><a rel="nofollow" class="external text" href="http://google.com">[google]</a>
24508 <a rel="nofollow" class="external text" href="http://google.com">google]</a>
24509 <a rel="nofollow" class="external text" href="http://google.com">goog] le</a>
24510 </p><p>[http://google.com]
24511 </p><p>[http://google.com google]
24512 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
24513 </p><p>[<a rel="nofollow" class="external free" href="http://google.com">http://google.com</a>]
24514 </p>
24515 !! end
24516
24517 !! test
24518 Links 5. ExtLinks: No escapes needed
24519 !! options
24520 parsoid=html2wt
24521 !! html/parsoid
24522 <p><a rel="mw:ExtLink" href="http://google.com">[google</a></p>
24523 <p>[<a ref="mw:ExtLink" href="http://google.com"></a>]</p>
24524 !! wikitext
24525 [http://google.com [google]
24526
24527 [[http://google.com]]
24528 !! html/php
24529 <p><a rel="nofollow" class="external text" href="http://google.com">[google</a>
24530 </p><p>[<a rel="nofollow" class="external autonumber" href="http://google.com">[1]</a>]
24531 </p>
24532 !! end
24533
24534 !! test
24535 Links 6. Add <nowiki/>s between text-nodes and url-links when required (T66300)
24536 !! options
24537 parsoid=html2wt
24538 !! html/parsoid
24539 <p>x<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>y
24540 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>?x
24541 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>&amp;x
24542 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>'x
24543 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,x
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>;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(x" data-parsoid='{"stx":"url"}'>http://example.com(x</a>)
24552 </p>
24553 !! wikitext
24554 x<nowiki/>http://example.com<nowiki/>y
24555 http://example.com<nowiki/>?x
24556 http://example.com<nowiki/>&x
24557 http://example.com<nowiki/>'x
24558 http://example.com<nowiki/>,x
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(x<nowiki/>)
24567 !! end
24568
24569 !! test
24570 Links 7a. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
24571 !! options
24572 parsoid=html2wt
24573 !! html/parsoid
24574 <p>x
24575 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>
24576 y
24577 "<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>"
24578 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>)
24579 (<a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>) foo
24580 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>,
24581 <a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>, foo
24582 </p>
24583 !! wikitext
24584 x
24585 http://example.com
24586 y
24587 "http://example.com"
24588 (http://example.com)
24589 (http://example.com) foo
24590 http://example.com,
24591 http://example.com, foo
24592 !! html/php
24593 <p>x
24594 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
24595 y
24596 "<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>"
24597 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>)
24598 (<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>) foo
24599 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
24600 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>, foo
24601 </p>
24602 !! end
24603
24604 !! test
24605 Links 7b. Don't add spurious <nowiki/>s between text-nodes and url-links (T66300)
24606 !! options
24607 parsoid=html2wt
24608 !! html/parsoid
24609 <p><a rel="mw:ExtLink" href="http://example.com" data-parsoid='{"stx":"url"}'>http://example.com</a>.,;:!?\
24610 -<a rel="mw:ExtLink" href="http://example.com">http://example.com</a>:</p>
24611 !! wikitext
24612 http://example.com.,;:!?\
24613 -http://example.com:
24614 !! html/php
24615 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>.,;:!?\
24616 -<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>:
24617 </p>
24618 !! end
24619
24620 !! test
24621 Links 8. Add <nowiki/>s between text-nodes and RFC-links when required (T66300)
24622 !! options
24623 parsoid=html2wt
24624 !! html/parsoid
24625 <p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>4
24626 <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y
24627 X<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>y</p>
24628 !! wikitext
24629 RFC 123<nowiki/>4
24630 RFC 123<nowiki/>y
24631 X<nowiki/>RFC 123<nowiki/>y
24632 !! end
24633
24634 !! test
24635 Links 9. Don't add spurious <nowiki/>s between text-nodes and RFC-links (T66300)
24636 !! options
24637 parsoid=html2wt
24638 !! html/parsoid
24639 <p><a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>?foo
24640 <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>&amp;foo
24641 -<a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>RFC 123</a>-
24642 </p>
24643 !! wikitext
24644 RFC 123?foo
24645 RFC 123&foo
24646 -RFC 123-
24647 !! html/php
24648 <p><a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>?foo
24649 <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>&amp;foo
24650 -<a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc123">RFC 123</a>-
24651 </p>
24652 !! end
24653
24654 !! test
24655 Links 10. Add <nowiki/>s between text-nodes and PMID-links when required (T66300)
24656 !! options
24657 parsoid=html2wt
24658 !! html/parsoid
24659 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>4
24660 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
24661 X<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>y
24662 !! wikitext
24663 PMID 123<nowiki/>4
24664 PMID 123<nowiki/>y
24665 X<nowiki/>PMID 123<nowiki/>y
24666 !! end
24667
24668 !! test
24669 Links 11. Don't add spurious <nowiki/>s between text-nodes and PMID-links (T66300)
24670 !! options
24671 parsoid=html2wt
24672 !! html/parsoid
24673 <p><a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>?foo
24674 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>&foo
24675 -<a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink" data-parsoid='{"stx":"magiclink"}'>PMID 123</a>-
24676 </p>
24677 !! wikitext
24678 PMID 123?foo
24679 PMID 123&foo
24680 -PMID 123-
24681 !! html/php
24682 <p><a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>?foo
24683 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>&amp;foo
24684 -<a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract">PMID 123</a>-
24685 </p>
24686 !! end
24687
24688 !! test
24689 Links 12. Add <nowiki/>s between text-nodes and ISBN-links when required (T66300)
24690 !! options
24691 parsoid=html2wt
24692 !! html/parsoid
24693 <p><a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>1
24694 <a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>x
24695 a<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>b
24696 </p>
24697 !! wikitext
24698 ISBN 1234567890<nowiki/>1
24699 ISBN 1234567890<nowiki/>x
24700 a<nowiki/>ISBN 1234567890<nowiki/>b
24701 !! end
24702
24703 !! test
24704 Links 13. Don't add spurious <nowiki/>s between text-nodes and ISBN-links (T66300)
24705 !! options
24706 parsoid=html2wt
24707 !! html/parsoid
24708 <p>-<a href="./Special:BookSources/1234567890" rel="mw:WikiLink" data-parsoid='{"stx":"magiclink"}'>ISBN 1234567890</a>'s
24709 !! wikitext
24710 -ISBN 1234567890's
24711 !! html/php
24712 <p>-<a href="/wiki/Special:BookSources/1234567890" class="internal mw-magiclink-isbn">ISBN 1234567890</a>'s
24713 </p>
24714 !! end
24715
24716 !! test
24717 Links 14. Protect link-like plain text. (Parsoid bug T78425)
24718 !! options
24719 parsoid=html2wt
24720 !! html/*
24721 <p>this is not a link: http://example.com
24722 </p>
24723 !! wikitext
24724 this is not a link: <nowiki>http://example.com</nowiki>
24725 !! end
24726
24727 !! test
24728 Links 15. Link trails can't become link prefixes.
24729 !! options
24730 language=is
24731 parsoid=html2wt
24732 !! html/parsoid
24733 <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>
24734 !! wikitext
24735 [[Söfnuður]]-[[00]]
24736 !! html/php
24737 <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>
24738 </p>
24739 !! end
24740
24741 #### --------------- Quotes ---------------
24742 #### 1. Quotes inside <b> and <i>
24743 #### 2. Link fragments separated by <i> and <b> tags
24744 #### 3. Link fragments inside <i> and <b>
24745 #### 4. No escaping needed
24746 #### --------------------------------------
24747 !! test
24748 1a. Quotes inside <b> and <i>
24749 !! options
24750 parsoid=html2wt
24751 !! html/*
24752 <p><i>'foo'</i>
24753 <i>''foo''</i>
24754 <i>'''foo'''</i>
24755 <i>foo</i>'s
24756 <b>'foo'</b>
24757 <b>''foo''</b>
24758 <b>'''foo'''</b>
24759 <b>foo'<i>bar'</i>baz</b>
24760 <b>foo</b>'s
24761 '<i>foo</i>
24762 <i>foo</i>'
24763 <i>foo'</i>'
24764 '<i>foo</i>'
24765 '<b>foo</b>
24766 <b>foo</b>'
24767 '<b>foo</b>'
24768 <i>fools'<span> errand</span></i>
24769 <i><span>fool</span>'s errand</i>
24770 '<i>foo</i> bar '<i>baz</i>
24771 a|!*#-:;+-~[]{}b'<i>x</i>
24772 </p>
24773 !! wikitext
24774 ''<nowiki/>'foo'''
24775 ''<nowiki>''foo''</nowiki>''
24776 ''<nowiki>'''foo'''</nowiki>''
24777 ''foo''<nowiki/>'s
24778 '''<nowiki/>'foo''''
24779 '''<nowiki>''foo''</nowiki>'''
24780 '''<nowiki>'''foo'''</nowiki>'''
24781 '''foo'<nowiki/>''bar'<nowiki/>''baz'''
24782 '''foo'''<nowiki/>'s
24783 '''foo''
24784 ''foo''<nowiki/>'
24785 ''foo'''<nowiki/>'
24786 '''foo''<nowiki/>'
24787 ''''foo'''
24788 '''foo'''<nowiki/>'
24789 ''''foo'''<nowiki/>'
24790 ''fools'<span> errand</span>''
24791 ''<span>fool</span>'s errand''
24792 '<nowiki/>''foo'' bar '''baz''
24793 a|!*#-:;+-~[]{}b'''x''
24794 !! end
24795
24796 !! test
24797 1b. Quotes inside <b> and <i> with other tags on same line
24798 !! options
24799 parsoid=html2wt
24800 !! html/parsoid
24801 '<i>a</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
24802 <i>a'</i> foo <i><a rel="mw:WikiLink" href="Bar" title="Bar">bar</a></i>
24803 <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>
24804 <a rel="mw:WikiLink" href="Foo" title="Foo">foo</a> x'<i><a href="Bar" rel="mw:WikiLink" title="Bar">bar</a></i>
24805 '<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>
24806 '<i>foo</i> <div title="name">test</div>
24807 '<i>foo</i> and <br data-parsoid='{"stx":"html","noClose":true}'/> bar
24808 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt5" data-mw='{"name":"references","attrs":{}}'>
24809 <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>
24810 </ol>
24811 !! wikitext
24812 '''a'' foo ''[[bar]]''
24813 ''a''' foo ''[[bar]]''
24814 ''a''' foo '''{{echo|[[bar]]}}'''
24815 [[foo]] x'''[[bar]]''
24816 '''foo'' <ref>test</ref>
24817 '''foo'' <div title="name">test</div>
24818 '''foo'' and <br> bar
24819 <references />
24820 !! end
24821
24822 !! test
24823 2. Link fragments separated by <i> and <b> tags
24824 !! options
24825 parsoid=html2wt
24826 !! html/parsoid
24827 <p>[[<i>foo</i>hello]]</p>
24828 <p>[[<b>foo</b>hello]]</p>
24829 !! wikitext
24830 [[''foo''<nowiki>hello]]</nowiki>
24831
24832 [['''foo'''<nowiki>hello]]</nowiki>
24833 !! end
24834
24835 # FIXME: Escaping one or both of [[ and ]] is also acceptable --
24836 # this is one of the shortcomings of this format
24837 !! test
24838 3. Link fragments inside <i> and <b>
24839 !! options
24840 parsoid=html2wt
24841 !! html/parsoid
24842 <p><i>[[foo</i>]]</p>
24843 <p><b>[[foo</b>]]</p>
24844 !! wikitext
24845 ''[[foo''<nowiki>]]</nowiki>
24846
24847 '''[[foo'''<nowiki>]]</nowiki>
24848 !! end
24849
24850 !! test
24851 4. No escaping needed
24852 !! options
24853 parsoid=html2wt
24854 !! html/parsoid
24855 <p>'<span><i>bar</i></span>'
24856 '<span><b>bar</b></span>'
24857 'a:b'foo
24858 </p>
24859 !! wikitext
24860 '<span>''bar''</span>'
24861 '<span>'''bar'''</span>'
24862 'a:b'foo
24863 !! end
24864
24865 #### ----------- Paragraphs ---------------
24866 #### 1. No unnecessary escapes
24867 #### --------------------------------------
24868
24869 !! test
24870 1. No unnecessary escapes
24871 !! options
24872 parsoid=html2wt
24873 !! html/parsoid
24874 <p>bar <span>[[foo]]</span>
24875 </p><p>=bar <span>[[foo]]</span>
24876 </p><p>[[bar <span>[[foo]]</span>
24877 </p><p>]]bar <span>[[foo]]</span>
24878 </p><p>=bar <span>foo]]</span>=
24879 </p>
24880 !! wikitext
24881 bar <span><nowiki>[[foo]]</nowiki></span>
24882
24883 =bar <span><nowiki>[[foo]]</nowiki></span>
24884
24885 [[bar <span><nowiki>[[foo]]</nowiki></span>
24886
24887 ]]bar <span><nowiki>[[foo]]</nowiki></span>
24888
24889 =bar <span>foo]]</span><nowiki>=</nowiki>
24890 !!end
24891
24892 #### ----------------------- PRE --------------------------
24893 #### 1. Leading whitespace in SOL context should be escaped
24894 #### ------------------------------------------------------
24895 !! test
24896 1. Leading whitespace in SOL context should be escaped
24897 !! options
24898 parsoid=html2wt
24899 !! html/parsoid
24900 <p> a</p>
24901
24902 <p> a</p>
24903
24904 <p> a(tab)</p>
24905
24906 <p> a
24907 <!--cmt-->
24908 a</p>
24909
24910 <p>a
24911 b</p>
24912
24913 <p>a
24914 b</p>
24915
24916 <p>a
24917 b</p>
24918 !! wikitext
24919 <nowiki> </nowiki>a
24920
24921 <nowiki> </nowiki> a
24922
24923 a(tab)
24924
24925 <nowiki> </nowiki> a
24926 <!--cmt-->
24927 <nowiki> </nowiki>a
24928
24929 a
24930 <nowiki> </nowiki>b
24931
24932 a
24933 b
24934
24935 a
24936 b
24937 !! html/php
24938 <p> a
24939 </p><p> a
24940 </p><p> a(tab)
24941 </p><p> a
24942 a
24943 </p><p>a
24944 b
24945 </p><p>a
24946 b
24947 </p><p>a
24948 b
24949 </p>
24950 !! end
24951
24952 !! test
24953 2. Leading whitespace in non-indent-pre contexts should not be escaped
24954 !! options
24955 parsoid=html2wt
24956 !! html/parsoid
24957 <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>
24958 <ol class="mw-references" typeof="mw:Extension/references" about="#mwt4" data-mw='{"name":"references","attrs":{}}'>
24959 <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>
24960 b</span></li>
24961 </ol>
24962 !! wikitext
24963 foo <ref>''a''
24964 b</ref>
24965 <references />
24966 !! end
24967
24968 !! test
24969 3. Leading whitespace in indent-pre suppressing contexts should not be escaped
24970 !! options
24971 parsoid=html2wt
24972 !! html/parsoid
24973 <blockquote>
24974 <p>
24975 a
24976 <span>b</span>
24977 c</p>
24978 </blockquote>
24979 !! wikitext
24980 <blockquote>
24981 a
24982 <span>b</span>
24983 c
24984 </blockquote>
24985 !! end
24986
24987 !! test
24988 4. Leading whitespace in indent-pre suppressing contexts should not be escaped
24989 !! options
24990 parsoid=html2wt
24991 !! html/parsoid
24992 <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>
24993 !! wikitext
24994 [[File:Foobar.jpg|thumb|caption]]
24995 !! end
24996
24997 !! test
24998 5. Nowiki escaping should account for indent-pres
24999 !! options
25000 parsoid=html2wt
25001 !! html/parsoid
25002 <pre>==foo==</pre>
25003 !! wikitext
25004 ==foo==
25005 !! end
25006
25007 !!test
25008 T95794: nowiki escaping should account for leading space at start-of-line in an indent-pre block
25009 !! options
25010 parsoid=html2wt
25011 !! html/parsoid
25012 <pre>
25013 * foo
25014 * bar
25015 </pre>
25016 !! wikitext
25017 * foo
25018 * bar
25019 !! end
25020
25021 #### --------------- Behavior Switches --------------------
25022
25023 !! test
25024 1. Valid behavior switches should be escaped
25025 !! options
25026 parsoid=html2wt
25027 !! html/parsoid
25028 __TOC__
25029 <i>__TOC__</i>
25030 !! wikitext
25031 <nowiki>__TOC__</nowiki>
25032 ''<nowiki>__TOC__</nowiki>''
25033 !! end
25034
25035 !! test
25036 2. Invalid behavior switches should not be escaped
25037 !! options
25038 parsoid=html2wt
25039 !! html/parsoid
25040 __TOO__
25041 __|__
25042 !! wikitext
25043 __TOO__
25044 __|__
25045 !! end
25046
25047 # We use indent-pre as an indirect way to test for sol-transparent behavior.
25048 !! test
25049 Behavior switches should be SOL-transparent
25050 !! options
25051 parsoid=html2wt
25052 !! html/parsoid
25053 <meta property="mw:PageProp/toc" />
25054
25055 <!-- this one's bogus -->
25056 <pre>__TOO__</pre>
25057
25058 <pre data-parsoid='{}'><meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/> foo</pre>
25059
25060 <meta property="mw:PageProp/toc" data-parsoid='{"src":"__TOC__","magicSrc":"__TOC__"}'/><pre data-parsoid='{}'>bar</pre>
25061 !! wikitext
25062 __TOC__
25063
25064 <!-- this one's bogus -->
25065 __TOO__
25066
25067 __TOC__ foo
25068
25069 __TOC__
25070 bar
25071 !! end
25072
25073 #### --------------- HTML tags ---------------
25074 #### 1. a tags
25075 #### 2. other tags
25076 #### 3. multi-line html tag
25077 #### 4. extension tags
25078 #### -----------------------------------------
25079 !! test
25080 1. a tags
25081 !! options
25082 parsoid=html2wt
25083 !! html/parsoid
25084 &lt;a href=&quot;http://google.com&quot;&gt;google&lt;/a&gt;
25085 !! wikitext
25086 <a href="http://google.com">google</a>
25087 !! end
25088
25089 !! test
25090 2. other tags
25091 !! options
25092 parsoid=html2wt
25093 !! html/parsoid
25094 <ul><li> &lt;div&gt;foo&lt;/div&gt;</li>
25095 <li> &lt;div style=&quot;color:red&quot;&gt;foo&lt;/div&gt;</li>
25096 <li> &lt;td&gt;</li></ul>
25097
25098 !! wikitext
25099 * <nowiki><div>foo</div></nowiki>
25100 * <nowiki><div style="color:red">foo</div></nowiki>
25101 * <nowiki><td></nowiki>
25102 !! end
25103
25104 !! test
25105 3. multi-line html tag
25106 !! options
25107 parsoid=html2wt
25108 !! html/parsoid
25109 <p>&lt;div
25110 &gt;foo&lt;/div
25111 &gt;
25112 </p>
25113 !! wikitext
25114 <nowiki><div
25115 >foo</div
25116 ></nowiki>
25117 !! end
25118
25119 !! test
25120 4. extension tags
25121 !! options
25122 parsoid=html2wt
25123 !! html/parsoid
25124 <p>&lt;ref&gt;foo&lt;/ref&gt;
25125 </p><p>&lt;ref&gt;bar
25126 </p><p>baz&lt;/ref&gt;
25127 </p>
25128 !! wikitext
25129 <nowiki><ref>foo</ref></nowiki>
25130
25131 <nowiki><ref>bar</nowiki>
25132
25133 baz<nowiki></ref></nowiki>
25134 !! end
25135
25136 #### --------------- Others ---------------
25137 !! test
25138 Escaping nowikis
25139 !! options
25140 parsoid=html2wt
25141 !! html/parsoid
25142 <p>&lt;nowiki&gt;foo&lt;/nowiki&gt;
25143 </p>
25144 !! wikitext
25145 &lt;nowiki&gt;foo&lt;/nowiki&gt;
25146 !! end
25147
25148 ## The quote-char in the input is necessary for triggering the bug
25149 !! test
25150 (T54035) Nowiki-escaping should not get tripped by " :" in text
25151 !! options
25152 parsoid=html2wt
25153 !! html/parsoid
25154 <p>foo's bar :</p>
25155 !! wikitext
25156 foo's bar :
25157 !! end
25158
25159 #----------- End of wikitext escaping tests --------------
25160
25161 !! test
25162
25163 Tag-like HTML structures are passed through as text
25164 !! wikitext
25165 <x y>
25166
25167 <x.y>
25168
25169 <x-y>
25170
25171 1>2
25172
25173 x<y
25174
25175 a>b
25176
25177 1<d e>f
25178 !! html
25179 <p>&lt;x y&gt;
25180 </p><p>&lt;x.y&gt;
25181 </p><p>&lt;x-y&gt;
25182 </p><p>1&gt;2
25183 </p><p>x&lt;y
25184 </p><p>a&gt;b
25185 </p><p>1&lt;d e&gt;f
25186 </p>
25187 !! end
25188
25189 !! test
25190 HTML tag with necessary entities in attributes
25191 !! wikitext
25192 <span title="&amp;amp;">foo</span>
25193 !! html
25194 <p><span title="&amp;amp;">foo</span>
25195 </p>
25196 !! end
25197
25198 !! test
25199 HTML tag with 'unnecessary' entity encoding in attributes
25200 !! wikitext
25201 <span title="&amp;">foo</span>
25202 !! html
25203 <p><span title="&amp;">foo</span>
25204 </p>
25205 !! end
25206
25207 !! test
25208 HTML tag with broken attribute value quoting
25209 !! options
25210 parsoid=wt2html,html2html
25211 !! wikitext
25212 <span title="Hello world>Foo</span>
25213 !! html/php
25214 <p><span title="Hello world">Foo</span>
25215 </p>
25216 !! html/parsoid
25217 <p><span title="Hello world">Foo</span></p>
25218 !! end
25219
25220 !! test
25221 Self-closed tag with broken attribute value quoting
25222 !! options
25223 parsoid=wt2html,html2html
25224 !! wikitext
25225 <div title="Hello world />Foo
25226 !! html/php+tidy
25227 <div title="Hello world"></div>
25228 <p>Foo</p>
25229 !! html/parsoid
25230 <div title="Hello world " data-parsoid='{"stx":"html","selfClose":true}'></div><p>Foo</p>
25231 !! end
25232
25233 !! test
25234 Table with broken attribute value quoting
25235 !! options
25236 parsoid=wt2html,html2html
25237 !! wikitext
25238 {|
25239 | title="Hello world|Foo
25240 |}
25241 !! html/php
25242 <table>
25243 <tr>
25244 <td title="Hello world">Foo
25245 </td></tr></table>
25246
25247 !! html/parsoid
25248 <table>
25249 <tr>
25250 <td title="Hello world">Foo
25251 </td></tr></table>
25252
25253 !! end
25254
25255 !! test
25256 Table with broken attribute value quoting on consecutive lines
25257 !! options
25258 parsoid=wt2html,html2html
25259 !! wikitext
25260 {|
25261 | title="Hello world|Foo
25262 | style="color:red|Bar
25263 |}
25264 !! html/php
25265 <table>
25266 <tr>
25267 <td title="Hello world">Foo
25268 </td>
25269 <td style="color:red">Bar
25270 </td></tr></table>
25271
25272 !! html/parsoid
25273 <table><tbody>
25274 <tr>
25275 <td title="Hello world">Foo
25276 </td><td style="color: red">Bar
25277 </td></tr></tbody></table>
25278
25279 !! end
25280
25281 !!test
25282 Accept empty td cell attribute
25283 !! wikitext
25284 {|
25285 | align="center" | foo || |
25286 |}
25287 !! html
25288 <table>
25289 <tr>
25290 <td align="center"> foo </td>
25291 <td>
25292 </td></tr></table>
25293
25294 !!end
25295
25296 !!test
25297 Non-empty attributes in th-cells
25298 !! wikitext
25299 {|
25300 ! Foo !! style="color: red" | Bar
25301 |}
25302 !! html
25303 <table>
25304 <tr>
25305 <th> Foo </th>
25306 <th style="color: red"> Bar
25307 </th></tr></table>
25308
25309 !!end
25310
25311 !!test
25312 Accept empty attributes in th-cells
25313 !! wikitext
25314 {|
25315 !| foo !!| bar
25316 |}
25317 !! html
25318 <table>
25319 <tr>
25320 <th> foo </th>
25321 <th> bar
25322 </th></tr></table>
25323
25324 !!end
25325
25326 !!test
25327 Empty table rows go away
25328 !! wikitext
25329 {|
25330 | Hello
25331 | there
25332 |- class="foo"
25333 |-
25334 |}
25335 !! html
25336 <table>
25337 <tr>
25338 <td> Hello
25339 </td>
25340 <td> there
25341 </td></tr>
25342
25343 </table>
25344
25345 !! end
25346
25347 ###
25348 ### Parsoid-centric tests for testing RTing of inter-element separators
25349 ### Edge cases not tested by existing parser tests and specific to
25350 ### Parsoid-specific serialization strategies.
25351 ###
25352
25353 !!test
25354 RT-ed inter-element separators should be valid separators
25355 !! wikitext
25356 {|
25357 |- [[foo]]
25358 |}
25359 !! html/php
25360 <table>
25361
25362 </table>
25363
25364 !! html/parsoid
25365 <table>
25366 <tbody><tr data-parsoid='{"startTagSrc":"|-","a":{"[[foo]]":null},"sa":{"[[foo]]":""},"autoInsertedEnd":true}'></tr>
25367 </tbody></table>
25368 !!end
25369
25370 # Parsoid-only since PHP parser relies on Tidy for correct output
25371 !!test
25372 Trailing newlines in a deep dom-subtree that ends a wikitext line should be migrated out
25373 !!options
25374 parsoid
25375 !! wikitext
25376 {|
25377 |<small>foo
25378 bar
25379 |}
25380
25381 {|
25382 |<small>foo<small>
25383 |}
25384 !! html
25385 <table>
25386 <tbody><tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'><small data-parsoid='{"stx":"html","autoInsertedEnd":true}'>foo
25387 <p>bar</p></small></td></tr>
25388 </tbody></table>
25389
25390 <table>
25391 <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>
25392 </tbody></table>
25393 !!end
25394
25395 # Note that the "style" attribute is really a template parameter here.
25396 # The = would have to be {{=}} if you wanted the literal.
25397 !!test
25398 Empty TD followed by TD with tpl-generated attribute
25399 !! wikitext
25400 {|
25401 |-
25402 |
25403 |{{echo|style='color:red'}}|foo
25404 |}
25405 !! html
25406 <table>
25407
25408 <tr>
25409 <td>
25410 </td>
25411 <td>foo
25412 </td></tr></table>
25413
25414 !!end
25415
25416 !!test
25417 Indented table with an empty td
25418 !! wikitext
25419 {|
25420 |-
25421 |
25422 |foo
25423 |}
25424 !! html
25425 <table>
25426
25427 <tr>
25428 <td>
25429 </td>
25430 <td>foo
25431 </td></tr></table>
25432
25433 !!end
25434
25435 ## We have some newline diffs RT-ing this edge case
25436 ## and it is not important enough -- we seem to be emitting
25437 ## at most 2 newlines after a </tr> and this is unrelated to
25438 ## the issue from T85627 that this is testing.
25439 !!test
25440 Indented table with blank lines in between (T85627)
25441 !! options
25442 parsoid=wt2html
25443 !! wikitext
25444 {|
25445 |foo
25446
25447
25448 |}
25449 !! html
25450 <table>
25451
25452 <tr>
25453 <td>foo
25454 </td></tr></table>
25455
25456 !!end
25457
25458 !!test
25459 Indented block & table
25460 !! wikitext
25461 <div>foo</div>
25462 {|
25463 |foo
25464 |}
25465 !! html/php
25466 <div>foo</div>
25467 <table>
25468 <tr>
25469 <td>foo
25470 </td></tr></table>
25471
25472 !! html/parsoid
25473 <div data-parsoid='{"stx":"html"}'>foo</div>
25474 <table><tbody>
25475 <tr data-parsoid='{"autoInsertedEnd":true,"autoInsertedStart":true}'><td data-parsoid='{"autoInsertedEnd":true}'>foo</td></tr>
25476 </tbody></table>
25477 !!end
25478
25479 !! test
25480 Indent and comment before table row
25481 !! wikitext
25482 {|
25483 <!--hi-->|-
25484 | there
25485 |}
25486 !! html/php
25487 <table>
25488
25489 <tr>
25490 <td> there
25491 </td></tr></table>
25492
25493 !! html/parsoid
25494 <table>
25495 <!--hi--><tbody><tr data-parsoid='{"startTagSrc":"|-","autoInsertedEnd":true}'>
25496 <td data-parsoid='{"autoInsertedEnd":true}'> there</td></tr>
25497 </tbody></table>
25498 !! end
25499
25500 # Parsoid-specific since PHP parser doesn't handle this mixed tbl-wikitext
25501 !!test
25502 Empty TR followed by a template-generated TR
25503 !!options
25504 parsoid
25505 !! wikitext
25506 {|
25507 |-
25508 {{echo|<tr><td>foo</td></tr>}}
25509 |}
25510 !! html
25511 <table>
25512 <tbody>
25513 <tr></tr>
25514 <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}}]}'>
25515 <td>foo</td></tr>
25516 </tbody></table>
25517 !!end
25518
25519 ## PHP and parsoid output differ for this, and since this is primarily
25520 ## for testing Parsoid's serializer, marking this Parsoid only
25521 !!test
25522 Empty TR followed by mixed-ws-comment line should RT correctly
25523 !!options
25524 parsoid
25525 !! wikitext
25526 {|
25527 |-
25528 <!--c-->
25529 |-
25530 <!--c--> <!--d-->
25531 |}
25532 !! html
25533 <table>
25534 <tbody>
25535 <tr></tr>
25536 <!--c-->
25537 <tr>
25538 <!--c--> </tr><!--d-->
25539 </tbody></table>
25540
25541 !!end
25542
25543 !!test
25544 Multi-line image caption generated by templates with/without trailing newlines
25545 !! wikitext
25546 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}]]
25547 [[File:Foobar.jpg|thumb|300x300px|foo\n{{echo|A}}\n{{echo|B}}\n{{echo|C}}\n\n]]
25548 !! html/parsoid
25549 <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>
25550 <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>
25551 !!end
25552
25553 !! test
25554 New element inserted (without intervening newlines) after an old sol-transparent node should serialize correctly
25555 !! options
25556 parsoid=html2wt
25557 !! html/parsoid
25558 <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>
25559
25560 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{}'/><h1>new heading</h1>
25561 !! wikitext
25562 <includeonly>foo</includeonly>
25563 new para
25564
25565 [[Category:Foo]]
25566
25567 = new heading =
25568 !! end
25569
25570 ## PHP emits broken html for this, and since this is primarily
25571 ## a Parsoid serializer test, marking this Parsoid only
25572 !!test
25573 Improperly nested inline or quotes tags with whitespace in between
25574 !! wikitext
25575 <span> <s>x</span> </s>
25576 ''' ''x''' ''
25577 !! html/parsoid
25578 <p><span> <s>x</s></span><s> </s>
25579 <b> <i>x</i></b><i> </i>
25580 </p>
25581 !!end
25582
25583 !!test
25584 Encapsulate protected attributes from wt
25585 !! wikitext
25586 <div typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true">foo</div>
25587
25588 {| typeof="mw:placeholder stuff" data-mw="whoo" data-parsoid="weird" data-parsoid-other="no" about="time" rel="mw:true"
25589 | ok
25590 |}
25591 !! html/parsoid
25592 <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>
25593
25594 <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">
25595 <tbody><tr><td data-parsoid='{"autoInsertedEnd":true}'> ok</td></tr>
25596 </tbody></table>
25597 !!end
25598
25599 ## Currently the p-wrapper is fragile in how it adds / removes transformations.
25600 ## Having nested or stray pre tags results in the attempt to add duplicates,
25601 ## causing an assertion fail. This test tries to prevent that situation.
25602 !!test
25603 Ensure ParagraphWrapper can deal with stray closing pre tags
25604 !!options
25605 parsoid=wt2html
25606 !! wikitext
25607 plain text</pre>
25608 !! html/parsoid
25609 plain text
25610 !!end
25611
25612 !!test
25613 1. Ensure fostered text content is wrapped in element nodes
25614 !!options
25615 parsoid=wt2html
25616 !! wikitext
25617 <table>hi</table><table>ho</table>
25618 !! html/parsoid
25619 <p>hi</p>
25620 <table></table>
25621 <p>ho</p>
25622 <table></table>
25623 !!end
25624
25625 !!test
25626 2. Ensure fostered text content is wrapped in element nodes (traps regressions around fostered marker on the element getting lost)
25627 !!options
25628 parsoid=wt2html,wt2wt
25629 !! wikitext
25630 <table>
25631 <tr> || ||
25632 <td> a
25633 </table>
25634 !! html/parsoid
25635 <p> || ||
25636 </p><table>
25637 <tbody><tr><td> a</td></tr>
25638 </tbody></table>
25639 !!end
25640
25641 !!test
25642 Encapsulation properly handles null DSR information from foster box
25643 !!options
25644 parsoid=wt2html,wt2wt
25645 !! wikitext
25646 {{echo|<table>foo<tr><td>bar</td></tr></table>}}
25647 !! html/parsoid
25648 <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>
25649 !!end
25650
25651 !!test
25652 1. Encapsulate foster-parented transclusion content
25653 !!options
25654 parsoid=wt2wt,wt2html
25655 !! wikitext
25656 <table>{{echo|foo<tr><td>bar</td></tr>}}</table>
25657 !! html/parsoid
25658 <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>
25659 <tbody>
25660 <tr>
25661 <td>bar</td>
25662 </tr>
25663 </tbody>
25664 </table>
25665 !!end
25666
25667 !!test
25668 2. Encapsulate foster-parented transclusion content
25669 !!options
25670 parsoid=wt2wt,wt2html
25671 !! wikitext
25672 <table><div>{{echo|foo}}</div><tr><td>bar</td></tr></table>
25673 !! html/parsoid
25674 <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>
25675 <table>
25676 <tbody>
25677 <tr>
25678 <td>bar</td>
25679 </tr>
25680 </tbody>
25681 </table>
25682 !!end
25683
25684 !!test
25685 3. Encapsulate foster-parented transclusion content
25686 !!options
25687 parsoid=wt2wt,wt2html
25688 !! wikitext
25689 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
25690 !! html/parsoid
25691 <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;]}">
25692 <p>foo</p>
25693 </div>
25694 <table>
25695 <tbody>
25696 <tr>
25697 <td>bar</td>
25698 </tr>
25699 </tbody>
25700 </table>
25701 !!end
25702
25703 !!test
25704 4. Encapsulate foster-parented transclusion content
25705 !!options
25706 parsoid=wt2wt,wt2html
25707 !! wikitext
25708 <table><div><p>{{echo|foo</p></div><tr><td>}}bar</td></tr></table>
25709 !! html/parsoid
25710 <div typeof="mw:Transclusion" data-mw="{&quot;parts&quot;:[&quot;<table><div><p>&quot;,{&quot;template&quot;:{&quot;target&quot;:{&quot;wt&quot;:&quot;echo&quot;,&quot;href&quot;:&quot;./Template:Echo&quot;},&quot;params&quot;:{&quot;1&quot;:{&quot;wt&quot;:&quot;foo</p></div><tr><td>&quot;}},&quot;i&quot;:0}},&quot;bar</td></tr></table>&quot;]}">
25711 <p>foo</p>
25712 </div>
25713 <table>
25714 <tbody>
25715 <tr>
25716 <td>bar</td>
25717 </tr>
25718 </tbody>
25719 </table>
25720 !!end
25721
25722 !!test
25723 5. Encapsulate foster-parented transclusion content
25724 !!options
25725 parsoid=wt2wt,wt2html
25726 !! wikitext
25727 <table><tr><td><div><p>{{echo|foo</p></div></td>foo}}</tr></table>
25728 !! html/parsoid
25729 <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>
25730 <table>
25731 <tbody>
25732 <tr>
25733 <td>
25734 <div>
25735 <p>foo</p>
25736 </div>
25737 </td>
25738 </tr>
25739 </tbody>
25740 </table>
25741 !!end
25742
25743 !!test
25744 6. Encapsulate foster-parented transclusion content
25745 !!options
25746 parsoid=wt2wt,wt2html
25747 !! wikitext
25748 <table><tr><td><div><p>{{echo|foo</p></div></td>foo</tr></table>}}<p>ok</p>
25749 !! html/parsoid
25750 <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>
25751 <table>
25752 <tbody>
25753 <tr>
25754 <td>
25755 <div>
25756 <p>foo</p>
25757 </div>
25758 </td>
25759 </tr>
25760 </tbody>
25761 </table>
25762 <p>ok</p>
25763 !!end
25764
25765 !!test
25766 7. Encapsulate foster-parented transclusion content
25767 !!options
25768 parsoid=wt2wt,wt2html
25769 !! wikitext
25770 <table>{{echo|<p>foo</p>}}<td>bar</td></table>
25771 !! html/parsoid
25772 <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>
25773 <table>
25774 <tbody>
25775 <tr>
25776 <td>bar</td>
25777 </tr>
25778 </tbody>
25779 </table>
25780 !!end
25781
25782 # Note that the wt is broken on purpose: the = should be {{=}} if you
25783 # don't want it to be a template parameter key.
25784 !!test
25785 8. Encapsulate foster-parented transclusion content
25786 !!options
25787 parsoid=wt2wt,wt2html
25788 !! wikitext
25789 {{echo|a
25790 }}{|{{echo|style='color:red'}}
25791 |-
25792 |b
25793 |}
25794 !! html/parsoid
25795 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"a\n"}},"i":0}}]}'>a</p>
25796 <span> </span>
25797 <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>
25798 <table>
25799 <tbody>
25800 <tr>
25801 <td>b</td>
25802 </tr>
25803 </tbody>
25804 </table>
25805 !!end
25806
25807 !!test
25808 9. Encapsulate foster-parented transclusion content
25809 !!options
25810 parsoid=wt2wt,wt2html
25811 !! wikitext
25812 <table>{{echo|hi</table>hello}}
25813 !! html/parsoid
25814 <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>
25815 !!end
25816
25817 !!test
25818 Table in fosterable position
25819 !!options
25820 parsoid=wt2html
25821 !! wikitext
25822 {{OpenTable}}
25823 <div>
25824 {|
25825 |}
25826 </div>
25827 |}
25828 !! html/parsoid
25829 <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">
25830 </span>
25831 <table about="#mwt1" data-parsoid='{"autoInsertedEnd":true}'></table>
25832
25833 <table>
25834 </table>
25835 !!end
25836
25837 # Parsoid only for T66747
25838 !! test
25839 Properly encapsulate empty-content transclusions in fosterable positions
25840 !! wikitext
25841 <table>
25842 {{#if:|
25843 <td>foo</td>
25844 }}
25845 </table>
25846 !! html/parsoid
25847 <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"}]]}'>
25848
25849 </table>
25850 !! end
25851
25852 !! test
25853 Always encapsulate foster box when template range is expanded to table
25854 !! options
25855 parsoid=wt2wt
25856 !! wikitext
25857 {|
25858 hello
25859 {{OpenTable}}
25860 |}
25861 !! html/parsoid
25862
25863 !! end
25864
25865 !! test
25866 T115289: Unclosed table
25867 !! wikitext
25868 {{echo|<table>}}<!--c-->[[Category:Two]]
25869 !! html/parsoid
25870 <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>
25871 !! end
25872
25873 !! test
25874 T115289: Don't migrate newlines out of tables with fostered content
25875 !! wikitext
25876 <table><td></td>{{echo|<tr>[[Category:One]]}}<!--c-->[[Category:Two]]
25877 !! html/parsoid
25878 <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>
25879 !! end
25880
25881 !! test
25882 T73074: More fostering fun
25883 !! wikitext
25884 <table><td></td>{{echo|<tr>}}<!--c-->[[Category:Two]]
25885 !! html/parsoid
25886 <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>
25887 !! end
25888
25889 !!test
25890 Support <object> element with .data attribute
25891 !!options
25892 parsoid=html2wt
25893 !! html/parsoid
25894 <object data="test.swf"></object>
25895 !! wikitext
25896 <object data="test.swf"></object>
25897 !!end
25898
25899 !! test
25900 Don't block XML namespace declaration
25901 !! wikitext
25902 <span xmlns:dct="http://purl.org/dc/terms/" property="dct:title">MediaWiki</span>
25903 !! html/php
25904 <p><span xmlns:dct="http&#58;//purl.org/dc/terms/" property="dct:title">MediaWiki</span>
25905 </p>
25906 !! html/parsoid
25907 <p><span xmlns:dct="http://purl.org/dc/terms/" data-x-property="dct:title" data-parsoid='{"stx":"html"}'>MediaWiki</span></p>
25908 !! end
25909
25910 # -----------------------------------------------------------------
25911 # The following section of tests are primarily to spec requirements
25912 # around Parsoid's serialization (old, new, edited content)
25913 #
25914 # All these tests are marked Parsoid html2wt and html2html only
25915 # ----------------------------------------------------------------
25916
25917 !! test
25918 Ignore rel attribute in a-tags during serialization to url-links
25919 !! options
25920 parsoid=html2wt
25921 !! html/parsoid
25922 <a href='http://en.wikipedia.org/wiki/Foobar'>http://en.wikipedia.org/wiki/Foobar</a>
25923 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:ExtLink'>http://en.wikipedia.org/wiki/Foobar</a>
25924 <a href='http://en.wikipedia.org/wiki/Foobar' rel='mw:WikiLink'>http://en.wikipedia.org/wiki/Foobar</a>
25925 !! wikitext
25926 http://en.wikipedia.org/wiki/Foobar
25927 http://en.wikipedia.org/wiki/Foobar
25928 http://en.wikipedia.org/wiki/Foobar
25929 !! end
25930
25931 # 'mi' is a localinterwiki prefix as well as a language
25932 !! test
25933 Serialize interwiki links pointing to the current wiki as plain wiki links (T67869)
25934 !! options
25935 parsoid=html2wt
25936 !! html/parsoid
25937 <p><a rel="mw:ExtLink" href="http://mi.wikipedia.org/wiki/Foo">Foo</a></p>
25938 !! wikitext
25939 [[Foo]]
25940 !! end
25941
25942 !! test
25943 Parsoid should accept interwiki shortcuts
25944 !! options
25945 parsoid=html2wt
25946 !! html/parsoid
25947 <p><a rel='mw:WikiLink' href='./fr:Foo'>Foo</a>
25948 <a rel='mw:ExtLink' href='./fr:Foo'>Foo</a>
25949 <a href='./fr:Foo'>Foo</a></p>
25950 <p><a rel='mw:WikiLink' href='fr%3AFoo'>Foo</a>
25951 <a rel='mw:ExtLink' href='fr%3AFoo'>Foo</a>
25952 <a href='fr%3AFoo'>Foo</a></p>
25953 !! wikitext
25954 [[:fr:Foo|Foo]]
25955 [[:fr:Foo|Foo]]
25956 [[:fr:Foo|Foo]]
25957
25958 [[:fr:Foo|Foo]]
25959 [[:fr:Foo|Foo]]
25960 [[:fr:Foo|Foo]]
25961 !! end
25962
25963 !! test
25964 Parsoid should not accept invalid interwiki shortcuts
25965 !! options
25966 parsoid=html2wt
25967 !! html/parsoid
25968 <p><a rel='mw:WikiLink' href='news:Foo'>Foo</a>
25969 <a rel='mw:ExtLink' href='news:Foo'>Foo</a>
25970 <a href='news:Foo'>Foo</a></p>
25971 !! wikitext
25972 [news:Foo Foo]
25973 [news:Foo Foo]
25974 [news:Foo Foo]
25975 !! end
25976
25977 # See T93839
25978 !! test
25979 New wikilinks should be serialized properly
25980 !! options
25981 parsoid=html2wt
25982 !! html/parsoid
25983 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{}'>Foo</a>
25984 <a rel="mw:WikiLink" href="./Foo" title="Foo">Foo</a>
25985 <a href="//en.wikipedia.org/wiki/Foo">//en.wikipedia.org/wiki/Foo</a>
25986 <a href="http://en.wikipedia.org/wiki/Foo">http://en.wikipedia.org/wiki/Foo</a>
25987 <a href="//en.wikipedia.org/wiki/Foo_bar">//en.wikipedia.org/wiki/Foo bar</a>
25988 !! wikitext
25989 [[Foo]]
25990 [[Foo]]
25991 [[:en:Foo|//en.wikipedia.org/wiki/Foo]]
25992 http://en.wikipedia.org/wiki/Foo
25993 [[:en:Foo_bar|//en.wikipedia.org/wiki/Foo bar]]
25994 !! end
25995
25996 !! test
25997 New wiki links (href variations)
25998 !! options
25999 parsoid=html2wt
26000 !! html/parsoid
26001 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
26002 <a rel="mw:WikiLink" href="Foo_bar">Foo_bar</a>
26003 <a rel="mw:WikiLink" href="Foo bar">Foo_bar</a>
26004 <a rel="mw:WikiLink" href="./Toxine_bact%C3%A9rienne">Toxine bactérienne</a>
26005 !! wikitext
26006 [[Foo_bar]]
26007 [[Foo_bar]]
26008 [[Foo_bar]]
26009 [[Toxine bactérienne]]
26010 !! end
26011
26012 !! test
26013 New wiki links (content string variations)
26014 !! options
26015 parsoid=html2wt
26016 !! html/parsoid
26017 <a rel="mw:WikiLink" href="./Foo_bar">Foo_bar</a>
26018 <a rel="mw:WikiLink" href="./Foo_bar">Foo bar</a>
26019 <a rel="mw:WikiLink" href="./Foo_bar">./Foo_bar</a>
26020 !! wikitext
26021 [[Foo_bar]]
26022 [[Foo bar]]
26023 [[Foo_bar|./Foo_bar]]
26024 !! end
26025
26026 !! test
26027 New category links (href variations)
26028 !! options
26029 parsoid=html2wt
26030 !! html/parsoid
26031 <link rel="mw:PageProp/Category" href="./Category:Toxine_bactérienne" />
26032 <link rel="mw:PageProp/Category" href="./Category:Toxine_bact%C3%A9rienne" />
26033 <link rel="mw:PageProp/Category" href="Category:Toxine_bact%C3%A9rienne" />
26034 !! wikitext
26035 [[Category:Toxine bactérienne]]
26036 [[Category:Toxine bactérienne]]
26037 [[Category:Toxine bactérienne]]
26038 !! end
26039
26040 !! test
26041 New sol transparent links don't need indent-pre nowiki protection
26042 !! options
26043 parsoid=html2wt
26044 language=de
26045 !! html/parsoid
26046 <link rel="mw:PageProp/redirect" href="./Main_Page">
26047 <!-- this is good --> <link rel="mw:PageProp/Category" href="./Category:Good" />
26048 <!-- this is great --> <link rel="mw:PageProp/Category" href="./Kategorie:Great" />
26049 !! wikitext
26050 #WEITERLEITUNG [[Main Page]]
26051 <!-- this is good --> [[Category:Good]]
26052 <!-- this is great --> [[Kategorie:Great]]
26053 !! end
26054
26055 !! test
26056 New interlanguage links (href variations)
26057 !! options
26058 parsoid=html2wt
26059 !! html/parsoid
26060 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine bactérienne" />
26061 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bactérienne" />
26062 <link rel="mw:PageProp/Language" href="http://es.wikipedia.org/wiki/Toxine_bact%C3%A9rienne" />
26063 !! wikitext
26064 [[es:Toxine bactérienne]]
26065 [[es:Toxine_bactérienne]]
26066 [[es:Toxine_bactérienne]]
26067 !! end
26068
26069 !! test
26070 Image: Modifying size of an image (1)
26071 !! options
26072 parsoid={
26073 "modes": ["wt2wt"],
26074 "changes": [
26075 ["img[height]", "attr", "height", "22"],
26076 ["img[width]", "attr", "width", "200"]
26077 ]
26078 }
26079 !! wikitext
26080 [[Image:Foobar.jpg|230x230px]]
26081 !! wikitext/edited
26082 [[Image:Foobar.jpg|200x200px]]
26083 !!end
26084
26085 !! test
26086 Image: Modifying size of an image (2)
26087 !! options
26088 parsoid={
26089 "modes": ["wt2wt"],
26090 "changes": [
26091 ["img[height]", "attr", "height", "100"],
26092 ["img[width]", "attr", "width", "500"]
26093 ]
26094 }
26095 !! wikitext
26096 [[Image:Foobar.jpg|230x230px]]
26097 !! wikitext/edited
26098 [[Image:Foobar.jpg|500x500px]]
26099 !!end
26100
26101 # Change in size is ignored so long as class='mw-default-size'
26102 !! test
26103 Image: Modifying size of an image (3)
26104 !! options
26105 parsoid={
26106 "modes": ["wt2wt"],
26107 "changes": [
26108 ["figure[class]", "removeClass", "mw-default-size"],
26109 ["figure img", "attr", "height", "19"],
26110 ["figure img", "attr", "width", "170"]
26111 ]
26112 }
26113 !! wikitext
26114 [[Image:Foobar.jpg|thumb]]
26115 !! wikitext/edited
26116 [[Image:Foobar.jpg|thumb|170x170px]]
26117 !!end
26118
26119 !! test
26120 Image: Modifying alignment of an image (T50665)
26121 !! options
26122 parsoid={
26123 "modes": ["wt2wt"],
26124 "changes": [
26125 ["figure[class]", "removeClass", "mw-halign-right"],
26126 ["figure[class]", "addClass", "mw-halign-left"]
26127 ]
26128 }
26129 !! wikitext
26130 [[Image:Foobar.jpg|thumb|caption|right]]
26131 !! wikitext/edited
26132 [[Image:Foobar.jpg|thumb|caption|left]]
26133 !! end
26134
26135 !! test
26136 Image: Modifying mw-default-size of an frameless image (T64805)
26137 !! options
26138 parsoid={
26139 "modes": ["wt2wt"],
26140 "changes": [
26141 ["figure.mw-default-size", "removeClass", "mw-default-size"]
26142 ]
26143 }
26144 !! wikitext
26145 [[Image:Foobar.jpg|frameless|right]]
26146 !! wikitext/edited
26147 [[Image:Foobar.jpg|frameless|right|220x220px]]
26148 !! end
26149
26150 !! test
26151 Image: Modifying valign of an image (T51221)
26152 !! options
26153 parsoid={
26154 "modes": ["wt2wt"],
26155 "changes": [
26156 ["*[typeof=\"mw:Image\"]", "removeClass", "mw-valign-middle"],
26157 ["*[typeof=\"mw:Image\"]", "addClass", "mw-valign-text-top"]
26158 ]
26159 }
26160 !! wikitext
26161 [[File:Foobar.jpg|20px|middle]]
26162 !! wikitext/edited
26163 [[File:Foobar.jpg|20px|text-top]]
26164 !! end
26165
26166 !! test
26167 Image: Modifying alt attribute of an image (T58400)
26168 !! options
26169 parsoid={
26170 "modes": ["wt2wt"],
26171 "changes": [
26172 ["img[alt]", "attr", "alt", "some alternate edited text"]
26173 ]
26174 }
26175 !! wikitext
26176 [[File:Foobar.jpg|thumb|some caption|alt=some alternate text]]
26177 !! wikitext/edited
26178 [[File:Foobar.jpg|thumb|some caption|alt=some alternate edited text]]
26179 !!end
26180
26181 !! test
26182 Image: Modifying caption of an image
26183 !! options
26184 parsoid={
26185 "modes": ["wt2wt"],
26186 "changes": [
26187 ["figcaption", "text", "new caption"]
26188 ]
26189 }
26190 !! wikitext
26191 [[Image:Foobar.jpg|thumb|original caption]]
26192 !! wikitext/edited
26193 [[Image:Foobar.jpg|thumb|new caption]]
26194 !!end
26195
26196 !! test
26197 Image: empty alt attribute (T50924)
26198 !! options
26199 parsoid
26200 !! wikitext
26201 [[File:Foobar.jpg|thumb|alt=|bar]]
26202 !! html
26203 <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>
26204 !! end
26205
26206 !! test
26207 Image: new attributes should be serialized in wiki's language for RTL languages (T53852)
26208 !! options
26209 parsoid=html2wt
26210 language=ar
26211 disabled
26212 !! html/parsoid
26213 <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>
26214 !! wikitext
26215 [[Imagen:Foobar.jpg|derecha|miniaturadeimagen]]
26216 !! end
26217
26218 !! test
26219 Image: Block level image should have \n before and after
26220 !! wikitext
26221 123
26222 [[File:Foobar.jpg|right|thumb|150x150px]]
26223 456
26224 !! html/parsoid
26225 <p>123</p>
26226 <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>
26227 <p>456</p>
26228 !!end
26229
26230 !! test
26231 Image: New block level image should have \n before and after (existing content)
26232 !! wikitext
26233 123
26234 [[File:Foobar.jpg|right|thumb|150x150px]]
26235 456
26236 !! html/parsoid
26237 <p>123</p>
26238 <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>
26239 <p>456</p>
26240 !!end
26241
26242 !! test
26243 Image: upright option (parsoid)
26244 !! wikitext
26245 [[File:Foobar.jpg|thumb|upright|caption]]
26246 [[File:Foobar.jpg|thumb|upright=0.5|caption]]
26247 [[File:Foobar.jpg|thumb|500x500px|upright=0.5|caption]]
26248 !! html/parsoid
26249 <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>
26250 <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>
26251 <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>
26252 !!end
26253
26254 !! test
26255 Image: upright option is ignored on inline and frame images (parsoid)
26256 !! wikitext
26257 [[File:Foobar.jpg|500x500px|upright=0.5|caption]]
26258 !! html/parsoid
26259 <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>
26260 !!end
26261
26262 !! test
26263 Image: from basic HTML (1)
26264 !! options
26265 parsoid=html2wt
26266 !! html/parsoid
26267 <span typeof="mw:Image">
26268 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
26269 </span>
26270 !! wikitext
26271 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
26272 !! end
26273
26274 !! test
26275 Image: from basic HTML (2)
26276 !! options
26277 parsoid=html2wt
26278 !! html/parsoid
26279 <img src="./File:Foobar.jpg" width=100 height=100 alt="Alt">
26280 !! wikitext
26281 [[File:Foobar.jpg|link=|alt=Alt|100x100px]]
26282 !! end
26283
26284 !! test
26285 Image: from basic HTML (3)
26286 !! options
26287 parsoid=html2wt
26288 !! html/parsoid
26289 <a href="Main"><img src="./File:Foobar.jpg" width=100 height=100 alt="Alt"></a>
26290 !! wikitext
26291 [[File:Foobar.jpg|link=Main|alt=Alt|100x100px]]
26292 !! end
26293
26294 !! test
26295 Image: from basic HTML (4)
26296 !! options
26297 parsoid=html2wt
26298 !! html/parsoid
26299 <img src="./File:Foobar.jpg">
26300 !! wikitext
26301 [[File:Foobar.jpg|link=]]
26302 !! end
26303
26304 !! test
26305 Image: Invalid title as link
26306 !! wikitext
26307 [[File:Foobar.jpg|link=<]]
26308 !! html/php
26309 <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>
26310 </p>
26311 !! html/parsoid
26312 <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>
26313 !! end
26314
26315 !! test
26316 Lists: Serialize correctly even when list content is wrapped in p-tags (like VE does)
26317 !! options
26318 parsoid=html2wt
26319 !! html/parsoid
26320 <ul>
26321 <li><p>foo</p></li>
26322 </ul>
26323 !! wikitext
26324 * foo
26325 !! end
26326
26327 !! test
26328 Lists: Serialize correctly even when list tags has unneeded whitespace between tags
26329 !! options
26330 parsoid=html2wt
26331 !! html/parsoid
26332 <ul> <li>foo</li></ul>
26333 !! wikitext
26334 * foo
26335 !! end
26336
26337 !! test
26338 Don't strip leading whitespace when handling indent-pre suppressing tags
26339 !! options
26340 parsoid=html2wt
26341 !! html/parsoid
26342 <table>
26343 <tr><td> indented row</td></tr>
26344 </table>
26345 <blockquote><p>
26346 <b>This is very bold of you!</b>
26347 </p>
26348 <table><tr><td>
26349 indented cell (no pre-wrapping!)
26350 </td></tr></table>
26351 </blockquote>
26352 <p>foo</p>
26353 <div>bar</div>
26354 !! wikitext
26355 {|
26356 | indented row
26357 |}
26358 <blockquote>
26359 '''This is very bold of you!'''
26360
26361 {|
26362 |
26363 indented cell (no pre-wrapping!)
26364 |}
26365 </blockquote>
26366 foo
26367 <div>bar</div>
26368 !! end
26369
26370 !! test
26371 Nowiki-wrap leading whitespace when handling indent-pre inducing tags
26372 !! options
26373 parsoid=html2wt
26374 !! html/parsoid
26375 <p>foo</p>
26376 <span>bar</span>
26377
26378 <span>foo2
26379 </span>bar2
26380
26381 <div>foo</div>
26382 <span>bar</span>
26383
26384 <div>
26385 <span>foo</span>
26386 </div>
26387 !! wikitext
26388 foo
26389
26390 <span>bar</span>
26391
26392 <span>foo2
26393 <nowiki> </nowiki></span>bar2
26394
26395 <div>foo</div>
26396 <nowiki> </nowiki><span>bar</span>
26397
26398 <div>
26399 <nowiki> </nowiki><span>foo</span>
26400 </div>
26401 !! end
26402
26403 !! test
26404 Lists: Dont insert newlines in a serialized list item.
26405 !! options
26406 parsoid=html2wt
26407 !! html/parsoid
26408 <ul><li>a<br>b</li><li>c</li></ul>
26409 !! wikitext
26410 * a<br>b
26411 * c
26412 !! end
26413
26414 !! test
26415 1. Headings: Force sol-transparent links and behavior switches to serialize before/after
26416 !! options
26417 parsoid={
26418 "modes": ["html2wt"],
26419 "scrubWikitext": false
26420 }
26421 !! html/parsoid
26422 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
26423 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
26424
26425 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
26426 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
26427
26428 <h2 data-parsoid='{}'>howdy<link href="./Category:A5" rel="mw:PageProp/Category" /></h2>
26429
26430 <h2><meta property="mw:PageProp/toc" /> ok</h2>
26431 !! wikitext
26432 == hello there [[Category:A1]] ==
26433
26434 == [[Category:A2]] hi pal ==
26435
26436 == <!--foo--> [[Category:A3]] how goes it ==
26437
26438 == it goes well [[Category:A4]] <!--bar--> ==
26439
26440 ==howdy [[Category:A5]]==
26441
26442 == __TOC__ ok ==
26443 !! end
26444
26445 !! test
26446 2. Headings: Force sol-transparent links and behavior switches to serialize before/after
26447 !! options
26448 parsoid={
26449 "modes": ["html2wt"],
26450 "scrubWikitext": true
26451 }
26452 !! html/parsoid
26453 <h2>hello there<link href="./Category:A1" rel="mw:PageProp/Category" /></h2>
26454 <h2><link href="./Category:A2" rel="mw:PageProp/Category" />hi pal</h2>
26455
26456 <h2><!--foo--> <link href="./Category:A3" rel="mw:PageProp/Category" /> how goes it</h2>
26457 <h2>it goes well <link href="./Category:A4" rel="mw:PageProp/Category" /> <!--bar--></h2>
26458
26459 <h2><meta property="mw:PageProp/toc" /> ok</h2>
26460 !! wikitext
26461 == hello there ==
26462 [[Category:A1]]
26463 [[Category:A2]]
26464
26465 == hi pal ==
26466
26467 <!--foo--> [[Category:A3]]
26468
26469 == how goes it ==
26470
26471 == it goes well ==
26472 [[Category:A4]] <!--bar-->
26473
26474 __TOC__
26475
26476 == ok ==
26477 !! end
26478
26479 !! test
26480 Headings: Don't hoist metas that come from templates
26481 !! options
26482 parsoid={
26483 "modes": ["html2wt"],
26484 "scrubWikitext": true
26485 }
26486 !! html/parsoid
26487 <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>
26488 !! wikitext
26489 == {{echo|foo [[Category:Foo]]}} ==
26490 !! end
26491
26492 !! test
26493 Headings: Category in ref isn't hoisted
26494 !! options
26495 parsoid={
26496 "modes": ["html2wt"],
26497 "scrubWikitext": true
26498 }
26499 !! html/parsoid
26500 <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>
26501
26502 <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>
26503 !! wikitext
26504 == foo <ref>bar
26505 [[Category:Baz]] </ref> ==
26506
26507 <references />
26508 !! end
26509
26510 !! test
26511 Parsoid: Serialize positional parameters with = in them as named parameter
26512 !! options
26513 parsoid=html2wt
26514 !! html/parsoid
26515 <p about="#mwt1" typeof="mw:Transclusion"
26516 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}},"i":0}}]}'>foo</p>
26517
26518 <p about="#mwt1" typeof="mw:Transclusion"
26519 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"f=oo"}, "2":{"wt":"bar"}},"i":0}}]}'>foo</p>
26520
26521 <!--Orig params with data-parsoid has heuristics for handling = chars-->
26522 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
26523 <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>
26524 !! wikitext
26525 {{echo|1=f=oo}}
26526
26527 {{echo|1=f=oo|2=bar}}
26528
26529 <!--Orig params with data-parsoid has heuristics for handling = chars-->
26530 <!--FIXME: But maybe the heuristic needs fixing to apply to new params as well-->
26531 {{echo|<nowiki>f=oo</nowiki>|bar}}
26532 !! end
26533
26534 !! test
26535 Parsoid: Serialize positional parameters with = in extlink as named parameter
26536 !! options
26537 parsoid=html2wt
26538 !! html/parsoid
26539 <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>
26540 !! wikitext
26541 {{echo|1=http://stuff?is=ok}}
26542 !! end
26543
26544 !! test
26545 Parsoid: Correctly serialize block-node children when they are a combination of text and p-nodes
26546 !! options
26547 parsoid=html2wt
26548 !! html/parsoid
26549 <div>a<p>b</p></div>
26550 <div>a
26551 <p>b</p></div>
26552 <div>
26553 a
26554 <p>b</p></div>
26555 !! wikitext
26556 <div>a
26557 b
26558 </div>
26559 <div>a
26560 b
26561 </div>
26562 <div>
26563 a
26564
26565 b
26566 </div>
26567 !! end
26568
26569 !! test
26570 Substrings resembling wikitext in hrefs should not get nowiki escapes
26571 !! options
26572 parsoid=html2wt
26573 !! html/parsoid
26574 <a rel="mw:WikiLink" href="./Foo''bar''baz">Foo''bar''baz</a>
26575 !! wikitext
26576 [[Foo''bar''baz]]
26577 !! end
26578
26579 !! test
26580 Enforce single-line context in the serializer
26581 !! options
26582 parsoid=html2wt
26583 !! html/parsoid
26584 <h2>testing
26585 123</h2>
26586
26587 <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">
26588 </span><span about="#mwt1">you</span> </h2>
26589
26590 <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>
26591
26592 <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
26593 there</span></li></ol>
26594
26595 <ul><li>asd
26596 sdf</li></ul>
26597
26598 <ul><li>foo
26599 bar
26600 baz</li>
26601 <li>foo <b>bar</b>
26602 baz</li></ul>
26603
26604 <dl><dt>hi
26605 ho </dt><dd data-parsoid='{"stx":"row"}'> hi
26606 ho</dd></dl>
26607
26608 <dl><dd> <table>
26609 <tbody><tr><td> ha
26610 ha
26611 ha</td></tr>
26612 </tbody></table></dd></dl>
26613 !! wikitext
26614 == testing 123 ==
26615
26616 == hi {{bogus|there
26617 you}} ==
26618
26619 == foo <ref>hello
26620 there</ref> ==
26621
26622 <references />
26623
26624 * asd sdf
26625
26626 * foo bar baz
26627 * foo '''bar''' baz
26628
26629 ; hi ho : hi ho
26630
26631 : {|
26632 | ha
26633 ha
26634 ha
26635 |}
26636 !! end
26637
26638 !! test
26639 Serialize new placeholder space without spans
26640 !! options
26641 parsoid=html2wt
26642 !! html/parsoid
26643 <p>foo<span typeof="mw:Placeholder"> </span>: bar</p>
26644
26645 <p>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span>: bar</p>
26646
26647 <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>
26648 !! wikitext
26649 foo : bar
26650
26651 foo : bar
26652
26653 <ref>foo : bar</ref>ok
26654 !! end
26655
26656
26657 #-----------------------
26658 # Tag minimization tests
26659 #-----------------------
26660
26661 !! test
26662 1. I/B quote minimization: wikitext-only tags should be combined
26663 !! options
26664 parsoid=html2wt
26665 !! html/parsoid
26666 <p><i>A</i><i>B</i></p>
26667 <p><b>A</b><b>B</b></p>
26668 <p><i>A</i><b><i>B</i></b></p>
26669 <p><b>A</b><i><b>B</b></i></p>
26670 <p><b>A</b><i><b>B</b><b>C</b></i><b>D</b></p>
26671 <p><i><b>A</b></i><i><b>B</b></i></p>
26672 <p><i><b>A</b></i><b><i>B</i></b></p>
26673 <p><b><i>A</i></b><i><b>B</b></i></p>
26674 !! wikitext
26675 ''AB''
26676
26677 '''AB'''
26678
26679 ''A'''B'''''
26680
26681 '''A''B'''''
26682
26683 '''A''BC''D'''
26684
26685 '''''AB'''''
26686
26687 '''''AB'''''
26688
26689 '''''AB'''''
26690 !! end
26691
26692 !! test
26693 2. I/B quote minimization: wikitext and html tags should not be combined
26694 !! options
26695 parsoid=html2wt
26696 !! html/parsoid
26697 <p><i>A</i><i data-parsoid='{"stx":"html"}'>B</i></p>
26698 <p><i>A</i><b><i data-parsoid='{"stx":"html"}'>B</i></b></p>
26699 !! wikitext
26700 ''A''<i>B</i>
26701
26702 ''A''<nowiki/>'''<i>B</i>'''
26703 !! end
26704
26705 !! test
26706 3. I/B quote minimization: templated content stops minimization
26707 !! options
26708 parsoid=html2wt
26709 !! html/parsoid
26710 <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>
26711 <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>
26712 !! wikitext
26713 ''A''{{echo|''B''}}
26714
26715 ''A''{{echo|'''''B'''''}}
26716 !! end
26717
26718 !! test
26719 4. I/B quote minimization: new content should be mimimized with adjacent old content
26720 !! options
26721 parsoid=html2wt
26722 !! html/parsoid
26723 <p><i>A</i><i>B</i></p>
26724 <p><b>A</b><b>B</b></p>
26725 <p><i>A</i><b><i>B</i></b></p>
26726 !! wikitext
26727 ''AB''
26728
26729 '''AB'''
26730
26731 ''A'''B'''''
26732 !! end
26733
26734 !! test
26735 5a. Merge adjacent quote nodes if they've been edited
26736 !! options
26737 parsoid={
26738 "modes": ["wt2wt", "selser"],
26739 "changes": [
26740 ["p", "contents", "remove", ":contains('b')"]
26741 ]
26742 }
26743 !! wikitext
26744 ''a''b''c''
26745 !! wikitext/edited
26746 ''ac''
26747 !! end
26748
26749 !! test
26750 5b. Merge adjacent quote nodes if they've been edited
26751 !! options
26752 parsoid={
26753 "modes": ["wt2wt", "selser"],
26754 "changes": [
26755 ["#x", "remove"]
26756 ]
26757 }
26758 !! wikitext
26759 ''a''<span id="x">b</span>''c''
26760 !! wikitext/edited
26761 ''ac''
26762 !! end
26763
26764 !! test
26765 1. Merge adjacent link nodes as long as at least one element is new
26766 !! options
26767 parsoid={
26768 "modes": ["html2wt"],
26769 "scrubWikitext": true
26770 }
26771 !! html/parsoid
26772 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
26773 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
26774 <a data-parsoid="{}" rel="mw:WikiLink" href="./Football">Foot</a><a data-parsoid="{}" rel="mw:WikiLink" href="./Football">ball</a>
26775 !! wikitext
26776 [[Football]]
26777 [[Football]]
26778 [[Football|Foot]][[Football|ball]]
26779 !! end
26780
26781 !! test
26782 2. Merge adjacent link nodes and enable additional normalizations
26783 !! options
26784 parsoid={
26785 "modes": ["html2wt"],
26786 "scrubWikitext": true
26787 }
26788 !! html/parsoid
26789 <a rel="mw:WikiLink" href="./Football"><i>Foot</i></a><a rel="mw:WikiLink" href="./Football"><i>ball</i></a>
26790 !! wikitext
26791 [[Football|''Football'']]
26792 !! end
26793
26794 !! test
26795 3. Don't merge adjacent link nodes if scrubWikitext is false
26796 !! options
26797 parsoid={
26798 "modes": ["html2wt"],
26799 "scrubWikitext": false
26800 }
26801 !! html/parsoid
26802 <a rel="mw:WikiLink" href="./Football">Foot</a><a rel="mw:WikiLink" href="./Football">ball</a>
26803 !! wikitext
26804 [[Football|Foot]][[Football|ball]]
26805 !! end
26806
26807 #------------------------------
26808 # End of tag minimization tests
26809 #------------------------------
26810
26811 !!test
26812 T56262: New entities
26813 !! options
26814 parsoid=html2wt
26815 !! html/parsoid
26816 <span typeof="mw:Entity">&nbsp;</span>
26817 !! wikitext
26818 &nbsp;
26819 !! end
26820
26821 ## Note that there is no wikitext output for 'unknownproperty' ##
26822 ## Unknown magic words are silently dropped ##
26823
26824 !! test
26825 Magic words
26826 !! options
26827 parsoid=html2wt
26828 !! html/parsoid
26829 <meta property='mw:PageProp/toc' />
26830 <meta property='mw:PageProp/notoc' />
26831 <meta property='mw:PageProp/forcetoc' />
26832 <meta property='mw:PageProp/index' />
26833 <meta property='mw:PageProp/noindex' />
26834 <meta property='mw:PageProp/nogallery' />
26835 <meta property='mw:PageProp/noeditsection' />
26836 <meta property='mw:PageProp/notitleconvert' />
26837 <meta property='mw:PageProp/nocontentconvert' />
26838 <meta property='mw:PageProp/unknownproperty' />
26839 !! wikitext
26840 __TOC__
26841 __NOTOC__
26842 __FORCETOC__
26843 __INDEX__
26844 __NOINDEX__
26845 __NOGALLERY__
26846 __NOEDITSECTION__
26847 __NOTITLECONVERT__
26848 __NOCONTENTCONVERT__
26849 !! end
26850
26851 !! test
26852 Consecutive <pre>s should not get merged
26853 !! options
26854 parsoid=html2wt,html2html
26855 !! html/parsoid
26856 <pre>a</pre><pre>b</pre>
26857
26858 <pre>c
26859 </pre><pre>
26860 d</pre>
26861
26862 <pre>e
26863
26864 </pre><pre>
26865
26866 f</pre>
26867 !! wikitext
26868 a
26869
26870 b
26871
26872 c
26873
26874 d
26875
26876 e
26877
26878
26879
26880 f
26881 !! end
26882
26883 !! test
26884 Edited ISBN links not serializable as ISBN links should serialize as wikilinks
26885 !! options
26886 parsoid=html2wt
26887 !! html/parsoid
26888 <a href="./Special:BookSources/1234567890" rel="mw:ExtLink">ISBN 1234567895</a>
26889 !! wikitext
26890 [[Special:BookSources/1234567890|ISBN 1234567895]]
26891 !! end
26892
26893 !! test
26894 Edited RFC links not serializable as RFC links should serialize as extlinks
26895 !! options
26896 parsoid=html2wt
26897 !! html/parsoid
26898 <a href="//tools.ietf.org/html/rfc123" rel="mw:ExtLink">New RFC</a>
26899 !! wikitext
26900 [//tools.ietf.org/html/rfc123 New RFC]
26901 !! end
26902
26903 !! test
26904 Edited PMID links not serializable as PMID links should serialize as extlinks
26905 !! options
26906 parsoid=html2wt
26907 !! html/parsoid
26908 <a href="//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract" rel="mw:ExtLink">New PMID</a>
26909 !! wikitext
26910 [//www.ncbi.nlm.nih.gov/pubmed/123?dopt=Abstract New PMID]
26911 !! end
26912
26913 !! test
26914 WTS of autolinks with trailing/surrounding context
26915 !! options
26916 parsoid=html2wt
26917 !! html/parsoid
26918 <p><a href="http://cscott.net">http://cscott.net</a><b>foo</b></p>
26919 <p><a href="http://cscott.net">http://cscott.net</a><b data-parsoid='{"stx":"html"}'>foo</b></p>
26920 <p><b><a href="http://cscott.net">http://cscott.net</a></b></p>
26921 <p><b><a href="http://cscott.net">http://cscott.net</a> </b></p>
26922 <p><b><a href="http://cscott.net">http://cscott.net</a>x</b></p>
26923 <p><a href="http://cscott.net">http://cscott.net</a>x</p>
26924 !! wikitext
26925 http://cscott.net'''foo'''
26926
26927 http://cscott.net<b>foo</b>
26928
26929 '''http://cscott.net'''
26930
26931 '''http://cscott.net '''
26932
26933 '''http://cscott.net<nowiki/>x'''
26934
26935 http://cscott.net<nowiki/>x
26936 !! end
26937
26938 !! test
26939 WTS of autolinks with nowikis (round-trip)
26940 !! wikitext
26941 x<nowiki/>http://cscott.net<nowiki/>x
26942 !! html/parsoid
26943 <p>x<a rel="mw:ExtLink" href="http://cscott.net">http://cscott.net</a>x</p>
26944 !! end
26945
26946 # this is the "easy" test because it leaves in place all the
26947 # data-parsoid information indicating this is an autolink
26948 !! test
26949 WTS of autolinks with escapes (editing)
26950 !! options
26951 parsoid={
26952 "modes": ["wt2wt"],
26953 "changes": [
26954 [ "span", "remove" ]
26955 ]
26956 }
26957 !! wikitext
26958 x<nowiki/>http://cscott.net<nowiki/>x
26959 !! wikitext/edited
26960 x<nowiki/>http://cscott.net<nowiki/>x
26961 !! end
26962
26963 !! test
26964 WTS of edited autolink-like text (T103364)
26965 !! options
26966 parsoid={
26967 "modes": ["wt2wt"],
26968 "changes": [
26969 [ "span[typeof]", "removeAttr", "typeof" ]
26970 ]
26971 }
26972 !! wikitext
26973 Not a link: <nowiki>http://example.com</nowiki>.
26974 !! wikitext/edited
26975 Not a link: <span><nowiki>http://example.com</nowiki></span>.
26976 !! end
26977
26978 !! test
26979 WTS of newly-authored autolink-like text (T103364)
26980 !! options
26981 parsoid=html2wt
26982 !! html/parsoid
26983 <p>http://example.com is not a link.</p>
26984 !! wikitext
26985 <nowiki>http://example.com</nowiki> is not a link.
26986 !! end
26987
26988 !! test
26989 WTS of autolink-like text after an autolink (T108563)
26990 !! options
26991 parsoid=html2wt
26992 !! html/parsoid
26993 <p><a rel="mw:ExtLink" href="http://example.com">http://example.com</a> http://example.com is not a link.</p>
26994 !! wikitext
26995 http://example.com <nowiki>http://example.com</nowiki> is not a link.
26996 !! end
26997
26998 !! test
26999 Magic links inside links (not autolinked)
27000 !! wikitext
27001 [[Foo|http://example.com]]
27002 [[Foo|RFC 1234]]
27003 [[Foo|PMID 1234]]
27004 [[Foo|ISBN 123456789x]]
27005
27006 [http://foo.com http://example.com]
27007 [http://foo.com RFC 1234]
27008 [http://foo.com PMID 1234]
27009 [http://foo.com ISBN 123456789x]
27010 !! html+tidy
27011 <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>
27012 <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>
27013 !! html/parsoid
27014 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">http://example.com</a>
27015 <a rel="mw:WikiLink" href="./Foo" title="Foo">RFC 1234</a>
27016 <a rel="mw:WikiLink" href="./Foo" title="Foo">PMID 1234</a>
27017 <a rel="mw:WikiLink" href="./Foo" title="Foo">ISBN 123456789x</a></p>
27018
27019 <p><a rel="mw:ExtLink" href="http://foo.com">http://example.com</a>
27020 <a rel="mw:ExtLink" href="http://foo.com">RFC 1234</a>
27021 <a rel="mw:ExtLink" href="http://foo.com">PMID 1234</a>
27022 <a rel="mw:ExtLink" href="http://foo.com">ISBN 123456789x</a></p>
27023 !! end
27024
27025 !! test
27026 Magic links inside image captions (autolinked)
27027 !! wikitext
27028 [[File:Foobar.jpg|thumb|http://example.com]]
27029 [[File:Foobar.jpg|thumb|RFC 1234]]
27030 [[File:Foobar.jpg|thumb|PMID 1234]]
27031 [[File:Foobar.jpg|thumb|ISBN 123456789x]]
27032 !! html+tidy
27033 <div class="thumb tright">
27034 <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>
27035 <div class="thumbcaption">
27036 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
27037 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a></div>
27038 </div>
27039 </div>
27040 <div class="thumb tright">
27041 <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>
27042 <div class="thumbcaption">
27043 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
27044 <a class="external mw-magiclink-rfc" rel="nofollow" href="//tools.ietf.org/html/rfc1234">RFC 1234</a></div>
27045 </div>
27046 </div>
27047 <div class="thumb tright">
27048 <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>
27049 <div class="thumbcaption">
27050 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
27051 <a class="external mw-magiclink-pmid" rel="nofollow" href="//www.ncbi.nlm.nih.gov/pubmed/1234?dopt=Abstract">PMID 1234</a></div>
27052 </div>
27053 </div>
27054 <div class="thumb tright">
27055 <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>
27056 <div class="thumbcaption">
27057 <div class="magnify"><a href="/wiki/File:Foobar.jpg" class="internal" title="Enlarge"></a></div>
27058 <a href="/wiki/Special:BookSources/123456789X" class="internal mw-magiclink-isbn">ISBN 123456789x</a></div>
27059 </div>
27060 </div>
27061 !! html/parsoid
27062 <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>
27063 <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>
27064 <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>
27065 <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>
27066 !! end
27067
27068 !! test
27069 WTS of magic word text (T109371)
27070 !! options
27071 parsoid=html2wt
27072 !! html/parsoid
27073 <p>RFC 1234</p>
27074 <p><a href="http://foo.com" rel="mw:ExtLink">RFC 1234</a></p>
27075 <p><a href="./Foo" rel="mw:WikiLink">RFC 1234</a></p>
27076 !! wikitext
27077 <nowiki>RFC 1234</nowiki>
27078
27079 [http://foo.com RFC 1234]
27080
27081 [[Foo|RFC 1234]]
27082 !! end
27083
27084 !! test
27085 Edited Redirect link should emit a non-piped wikitext link
27086 !! options
27087 parsoid=html2wt
27088 !! html/parsoid
27089 <link rel="mw:PageProp/redirect" href="Bar" data-parsoid='{"a":{"href":"./Foo"},"sa":{"href":"Foo"}}'>
27090 !! wikitext
27091 #REDIRECT [[Bar]]
27092 !! end
27093
27094 !! test
27095 T75121: Infer extension name from typeOf if data-mw is not present
27096 !! options
27097 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
27098 !! html/parsoid
27099 <div typeOf="mw:Extension/foo"></div>
27100 !! wikitext
27101 <foo />
27102 !! end
27103
27104 # Note that the <p> wrapping isn't present in PHP parser output
27105 # The important thing for this test is that P-wrapping doesn't
27106 # interfere with the <nowiki> protection for leading - in <td>
27107 # (which isn't necessary for <th>).
27108 !! test
27109 T88318: p-wrapped dash in table.
27110 !! options
27111 parsoid=html2wt,wt2wt
27112 !! html/parsoid
27113 <table><tbody>
27114 <tr><th><p>-</p></th><th><p>- </p></th></tr>
27115 <tr><td><p>-</p></td><td><p>- </p></td></tr>
27116 <tr><td><small>-</small></td><td><br/><p>-</p></td><td><br/>-</td></tr>
27117 </tbody></table>
27118 !! wikitext
27119 {|
27120 !-
27121 !-
27122 |-
27123 |<nowiki>-</nowiki>
27124 |<nowiki>- </nowiki>
27125 |-
27126 |<small>-</small>
27127 |<br>
27128 -
27129 |<br>
27130 -
27131 |}
27132 !! html/php+tidy
27133 <table>
27134 <tr>
27135 <th>-</th>
27136 <th>-</th>
27137 </tr>
27138 <tr>
27139 <td>-</td>
27140 <td>-</td>
27141 </tr>
27142 <tr>
27143 <td><small>-</small></td>
27144 <td><br />
27145 <p>-</p>
27146 </td>
27147 <td><br />
27148 <p>-</p>
27149 </td>
27150 </tr>
27151 </table>
27152 !! end
27153
27154 !! test
27155 T149209: WTS: Handle newlines in table cells properly
27156 !! options
27157 parsoid=html2wt
27158 !! html/parsoid
27159 <table>
27160 <tbody>
27161 <tr><td>a
27162 b
27163 </td><td data-parsoid='{"stx_v":"row"}'>c</td></tr>
27164 <tr><td><p>x</p>
27165 </td><td data-parsoid='{"stx_v":"row", "startTagSrc": "{{!}}{{!}}"}'>y</td></tr>
27166 </tbody></table>
27167 <table>
27168 <tbody>
27169 <tr><th>a
27170 b
27171 </th><th data-parsoid='{"stx_v":"row"}'>c</th></tr>
27172 <tr><th><p>x</h>
27173 </th><th data-parsoid='{"stx_v":"row"}'>y</th></tr>
27174 </tbody></table>
27175 !! wikitext
27176 {|
27177 |a
27178 b
27179 |c
27180 |-
27181 |x
27182 {{!}}y
27183 |}
27184 {|
27185 !a
27186 b
27187 !c
27188 |-
27189 !x
27190 !y
27191 |}
27192 !! end
27193
27194 !! test
27195 T149209: Selser: Handle newlines in table cells properly
27196 !! options
27197 parsoid={
27198 "modes": ["selser"],
27199 "changes": [
27200 [ "#h1", "html", "a\nb\n" ],
27201 [ "#h2", "html", "a\nb\n" ],
27202 [ "#c1", "html", "a\nb\n" ],
27203 [ "#c2", "html", "<p>a</p>" ],
27204 [ "#c3", "html", "<p>a</p>" ],
27205 [ "#c4", "html", "edit-me<p>a</p>" ]
27206 ]
27207 }
27208 !! wikitext
27209 {|
27210 ! id="h1" |edit-me!!1
27211 |-
27212 ! id="h2" |edit-me||2
27213 |-
27214 | id="c1" |edit-me||3
27215 |-
27216 | id="c2" |edit-me||4
27217 |-
27218 | id="c3" |edit-me||p||q||r
27219 |-
27220 | id="c4" |edit-me||p||q||r
27221 |}
27222 !! wikitext/edited
27223 {|
27224 ! id="h1" |a
27225 b
27226 !1
27227 |-
27228 ! id="h2" |a
27229 b
27230 !2
27231 |-
27232 | id="c1" |a
27233 b
27234 |3
27235 |-
27236 | id="c2" |a
27237 |4
27238 |-
27239 | id="c3" |a
27240 |p||q||r
27241 |-
27242 | id="c4" |edit-me
27243 a
27244 |p||q||r
27245 |}
27246 !! end
27247
27248 !! test
27249 HTML id attribute with Parsoid-like element ids should not be serialized to wikitext
27250 !! options
27251 parsoid=html2wt
27252 !! html/parsoid
27253 <table id='mwAb'>
27254 <td id='mwAc'>foo</td>
27255 <td id='serialize-this'>bar</td>
27256 </table>
27257 !! wikitext
27258 {|
27259 |foo
27260 | id="serialize-this" |bar
27261 |}
27262 !! end
27263
27264 !! test
27265 Parsoid-like element ids should not be serialized to wikitext unless shadowed
27266 !! options
27267 parsoid=html2wt
27268 !! html/parsoid
27269 <div id="mwAQ" data-parsoid='{"stx":"html","a":{"id":"mwAQ"},"sa":{"id":"hello"}}'>ok</div>
27270 !! wikitext
27271 <div id="hello">ok</div>
27272 !! end
27273
27274 !! test
27275 WTS change modes
27276 !! options
27277 parsoid={
27278 "modes": ["wt2wt"],
27279 "changes": [
27280 [ "#xyz", "before", "<b>before</b> stuff " ],
27281 [ "#xyz", "after", " stuff <i>after</i>" ],
27282 [ "#xyz", "html", "x <b>y</b> z" ]
27283 ]
27284 }
27285 !! wikitext
27286 <span id="xyz">hello</span>
27287 !! wikitext/edited
27288 '''before''' stuff <span id="xyz">x '''y''' z</span> stuff ''after''
27289 !! end
27290
27291 !! test
27292 Never serialize a-tag as html, regardless of what data-parsoid has to say
27293 !! options
27294 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
27295 !! html/parsoid
27296 <a rel="mw:WikiLink" href="./Foo" title="Foo" data-parsoid='{"stx":"html"}'>Foo</a>
27297 !! wikitext
27298 [[Foo]]
27299 !! end
27300
27301 ## SSS FIXME: This is broken output nevertheless.
27302 ## What might be a reasonable non-broken output for this?
27303 ## This is an edge case unlikely to be seen in production
27304 ## that I am not wasting more time on this right now.
27305 !! test
27306 Never serialize a-tag as html, no matter what attributes it has
27307 !! options
27308 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
27309 !! html/parsoid
27310 <a bad='true' href='http://boo.org'><img src='http://boohoo.org' /></a>
27311 !! wikitext
27312 [http://boo.org http://boohoo.org]
27313 !! end
27314
27315 # Misnested is an indication that selser can reuse the source but these have
27316 # shown to sneak through on occasion. See T101768.
27317 # The original wikitext here is: [http://test.com [[one]] two three]
27318 !! test
27319 Strip span tags added to mark misnested links
27320 !! options
27321 parsoid=html2wt
27322 !! html/parsoid
27323 <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>
27324 !! wikitext
27325 [http://test.com][[one]] two three
27326 !! end
27327
27328 !! test
27329 Catch regression when unpacking misnested links
27330 !! options
27331 parsoid=wt2html
27332 !! wikitext
27333 {{echo|hi}}[http://example.com [[ho]]]
27334 !! html/parsoid
27335 <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>
27336 !! end
27337
27338 !! test
27339 Use data-parsoid.firstWikitextNode to compute newline constraints for template content
27340 !! options
27341 parsoid=html2wt
27342 !! html/parsoid
27343 <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|}"]}'>
27344 <tbody><tr><td>d
27345 </td></tr>
27346 </tbody></table>
27347 !! wikitext
27348 {{echo|a}}
27349 {|{{echo|c
27350 {{!}}d
27351 }}
27352 |}
27353 !! end
27354
27355 ## This test verifies the presence and computation of this attribute indirectly
27356 ## by making an edit and ensuring that the serialization is correct (which it would be
27357 ## only if firstWikitextNode is properly set).
27358 !! test
27359 data-parsoid.firstWikitextNode should be computed properly in the presence of fostered content
27360 !! options
27361 parsoid= {
27362 "modes": ["wt2wt"],
27363 "changes": [
27364 [ "div#x", "remove" ],
27365 [ "div", "before", "<div>new</div>" ]
27366 ]
27367 }
27368 !! wikitext
27369 <div id="x">foo</div>
27370 {|
27371 {{echo|<div>boo</div>
27372 {{!}}b}}
27373 |c
27374 |}
27375 !! wikitext/edited
27376
27377 <div>new</div>
27378 {|
27379 {{echo|<div>boo</div>
27380 {{!}}b}}
27381 |c
27382 |}
27383 !! end
27384
27385 # --------------------------------------------
27386 # Tests spec'ing wikitext serialization norms |
27387 # --------------------------------------------
27388
27389 !! test
27390 Serialize multi-line indent-pre starting with wikitext syntax
27391 !! options
27392 parsoid=html2wt
27393 !! html/parsoid
27394 <pre>* 1
27395 ** 2
27396 * 3</pre>
27397 !! wikitext
27398 * 1
27399 ** 2
27400 * 3
27401 !! end
27402
27403 !! test
27404 1. Categories should always be serialized on their own line
27405 !! options
27406 parsoid=html2wt
27407 !! html/parsoid
27408 foo<link rel="mw:PageProp/Category" href="./Category:Foo">bar
27409 !! wikitext
27410 foo
27411 [[Category:Foo]]
27412 bar
27413 !! end
27414
27415 !! test
27416 2. Categories that are part of templates should not introduce a line break
27417 !! wikitext
27418 foo {{echo|<span>bar</span> [[Category:baz]]}} bar
27419 !! html/parsoid
27420 <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>
27421 !! end
27422
27423 # Careful while editing these next 2 tests. There are \u200f characters
27424 # before and after the <link> tags in the HTML and following some
27425 # of the categories in wikitext
27426 # Do not remove these characters in edits.
27427 #
27428 # As part of the serialization, these bidi characters will get stripped.
27429 !! test
27430 RTL (\u200f) and LTR (\u200e) markers around category tags should be stripped
27431 !! options
27432 parsoid={
27433 "modes": ["html2wt"],
27434 "scrubWikitext": true
27435 }
27436 !! html/parsoid
27437 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏
27438 ‏<link rel="mw:PageProp/Category" href="./קטגוריה:_שיטות_משפט" />‏</p>
27439 !! wikitext
27440 [[קטגוריה:טקסים]]
27441 [[קטגוריה: שיטות משפט]]
27442 !! end
27443
27444 !! test
27445 RTL (\u200f) and LTR (\u200e) markers should not be stripped if followed by a text node
27446 !! options
27447 parsoid={
27448 "modes": ["html2wt"],
27449 "scrubWikitext": true
27450 }
27451 !! html/parsoid
27452 <p>‏<link rel="mw:PageProp/Category" href="./קטגוריה:טקסים" />‏y</p>
27453 !! wikitext
27454 [[קטגוריה:טקסים]]
27455 ‏y
27456 !! end
27457
27458 !! test
27459 Lists: Add space after bullets
27460 !! options
27461 parsoid=html2wt
27462 !! html/parsoid
27463 <ul>
27464 <li>foo</li>
27465 <li> bar</li>
27466 <li><span> baz</span></li>
27467 </ul>
27468 !! wikitext
27469 * foo
27470 * bar
27471 * <span> baz</span>
27472 !! end
27473
27474 !! test
27475 1. Headings: Add space before/after == (T53744)
27476 !! options
27477 parsoid=html2wt
27478 !! html/parsoid
27479 <h2>foo</h2>
27480 <h2> bar</h2>
27481 <h2>baz </h2>
27482 <h2><span> baz</span></h2>
27483 !! wikitext
27484 == foo ==
27485
27486 == bar ==
27487
27488 == baz ==
27489
27490 == <span> baz</span> ==
27491 !! end
27492
27493 !! test
27494 2. Headings: Add space before/after == even after hoisted content
27495 !! options
27496 parsoid={
27497 "modes": ["html2wt"],
27498 "scrubWikitext": true
27499 }
27500 !! html/parsoid
27501 <h2> <link href="./Category:A2" rel="mw:PageProp/Category" />ok</h2>
27502 !! wikitext
27503 [[Category:A2]]
27504
27505 == ok ==
27506 !! end
27507
27508 !! test
27509 1. Headings: suppress newly created empty headings
27510 !! options
27511 parsoid={
27512 "modes": ["html2wt"],
27513 "scrubWikitext": true
27514 }
27515 !! html/parsoid
27516 <h2></h2>
27517 !! wikitext
27518 !! end
27519
27520 !! test
27521 2. Headings: don't suppress empty headings if scrubWikitext is false
27522 !! options
27523 parsoid=html2wt
27524 !! html/parsoid
27525 <h2></h2>
27526 !! wikitext
27527 ==<nowiki/>==
27528 !! end
27529
27530 !! test
27531 3. Headings: suppress empty headings on edits
27532 !! options
27533 parsoid={
27534 "modes": ["selser"],
27535 "scrubWikitext": true,
27536 "changes": [
27537 [ "#x", "remove"]
27538 ]
27539 }
27540 !! wikitext
27541 ==<span id="x">foo</span>==
27542 !! wikitext/edited
27543 !! end
27544
27545 !! test
27546 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = true)
27547 !! options
27548 parsoid={
27549 "modes": ["html2wt"],
27550 "scrubWikitext": true
27551 }
27552 !! html/parsoid
27553 <h2>foo<br/>bar</h2>
27554 <h2>foo <span><br/>bar</span> baz</h2>
27555 !! wikitext
27556 == foo bar ==
27557
27558 == foo <span> bar</span> baz ==
27559 !! end
27560
27561 !! test
27562 Headings: Replace <br/> with a single whitespace char (when scrubWikitext = false)
27563 !! options
27564 parsoid={
27565 "modes": ["html2wt"],
27566 "scrubWikitext": false
27567 }
27568 !! html/parsoid
27569 <h2>foo<br/>bar</h2>
27570 !! wikitext
27571 == foo<br> bar ==
27572 !! end
27573
27574 !! test
27575 1. WT Quote Tags: suppress newly created empty style tags
27576 !! options
27577 parsoid={
27578 "modes": ["html2wt"],
27579 "scrubWikitext": true
27580 }
27581 !! html/parsoid
27582 <i></i><b></b>
27583 !! wikitext
27584 !! end
27585
27586 !! test
27587 2. WT Quote Tags: don't suppress empty style tags if scrubWikitext is false
27588 !! options
27589 parsoid=html2wt
27590 !! html/parsoid
27591 <i></i><b></b>
27592 !! wikitext
27593 ''<nowiki/>'''''<nowiki/>'''
27594 !! end
27595
27596 !! test
27597 3. WT Quote Tags: suppress empty style tags on edits
27598 !! options
27599 parsoid={
27600 "modes": ["selser"],
27601 "scrubWikitext": true,
27602 "changes": [
27603 [ "#x", "remove"]
27604 ]
27605 }
27606 !! wikitext
27607 '''<span id="x">foo</span>'''
27608 !! wikitext/edited
27609 !! end
27610
27611 !! test
27612 1. Anchors: suppress newly created empty anchors
27613 !! options
27614 parsoid={
27615 "modes": ["html2wt"],
27616 "scrubWikitext": true
27617 }
27618 !! html/parsoid
27619 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
27620 !! wikitext
27621 !! end
27622
27623 !! test
27624 2. Anchors: don't suppress empty anchors if scrubWikitext is false
27625 !! options
27626 parsoid={
27627 "modes": ["html2wt"],
27628 "scrubWikitext": false
27629 }
27630 !! html/parsoid
27631 <a rel="mw:WikiLink" href="./Test" title="Test"></a>
27632 !! wikitext
27633 [[Test|<nowiki/>]]
27634 !! end
27635
27636 !! test
27637 3. Anchors: suppress empty anchors on edits
27638 !! options
27639 parsoid={
27640 "modes": ["selser"],
27641 "scrubWikitext": true,
27642 "changes": [
27643 [ "#x", "remove"]
27644 ]
27645 }
27646 !! wikitext
27647 [[Test|<span id="x">foo</span>]]
27648 !! wikitext/edited
27649 !! end
27650
27651 !! test
27652 3a. Anchors: do not suppress numbered extlinks
27653 !! options
27654 parsoid={
27655 "modes": ["wt2wt"],
27656 "scrubWikitext": true
27657 }
27658 !! wikitext
27659 [http://foo.com]
27660 !! html/parsoid
27661 <a rel="mw:ExtLink" href="http://foo.com"></a>
27662 !! end
27663
27664 !! test
27665 3b. Anchors: do not suppress numbered extlinks
27666 !! options
27667 parsoid={
27668 "modes": ["wt2wt"],
27669 "scrubWikitext": true,
27670 "changes": [
27671 [ "#x", "remove"]
27672 ]
27673 }
27674 !! wikitext
27675 [http://foo.com <span id="x">foo</span>]
27676 !! wikitext/edited
27677 [http://foo.com]
27678 !! end
27679
27680 !!test
27681 Normalizations should be restricted to edited content
27682 !!options
27683 parsoid={
27684 "modes": ["selser"],
27685 "scrubWikitext": true,
27686 "changes": [
27687 [ "h1", "before", "<i></i>"]
27688 ]
27689 }
27690 !!wikitext
27691 a
27692 = =
27693 b
27694 !!wikitext/edited
27695 a
27696 = =
27697 b
27698 !!end
27699
27700 !! test
27701 1. Multiple normalizations (html2wt)
27702 !! options
27703 parsoid={
27704 "modes": ["html2wt"],
27705 "scrubWikitext": true
27706 }
27707 !! html
27708 <h2><i></i></h2>
27709 <p><a href='Foo' rel='mw:WikiLink'>foo<i></i>
27710 </a><b><i></i></b>x</p>
27711 !! wikitext
27712
27713 [[foo]]
27714 x
27715
27716 !! end
27717
27718 !! test
27719 2. Multiple normalizations (selser)
27720 !! options
27721 parsoid={
27722 "modes": ["selser"],
27723 "scrubWikitext": true,
27724 "changes": [
27725 [ "#x", "after", "<h1><i></i></h1>\n<p> x<b></b></p>"]
27726 ]
27727 }
27728 !! wikitext
27729 <span id="x">foo</span>
27730 !! wikitext/edited
27731 <span id="x">foo</span>
27732
27733 x
27734 !! end
27735
27736 !! test
27737 1. Indent Pre Nowiki: suppress whitespace at the start of new paragraph
27738 !! options
27739 parsoid={
27740 "modes": ["html2wt"],
27741 "scrubWikitext": true
27742 }
27743 !! html/parsoid
27744 <p> hi</p>
27745 <p> hello</p>
27746 !! wikitext
27747 hi
27748
27749 hello
27750 !! end
27751
27752 !! test
27753 2. Indent Pre Nowiki: don't suppress whitespace at the start of new paragraph if scrubWikitext is false
27754 !! options
27755 parsoid=html2wt
27756 !! html/parsoid
27757 <p> hi</p>
27758 <p> hello</p>
27759 !! wikitext
27760 <nowiki> </nowiki>hi
27761
27762 <nowiki> </nowiki> hello
27763 !! end
27764
27765 !! test
27766 3. Indent Pre Nowiki: suppress whitespace after newlines in new paragraph or table cell
27767 !! options
27768 parsoid={
27769 "modes": ["html2wt"],
27770 "scrubWikitext": true
27771 }
27772 !! html/parsoid
27773 <p>Foo
27774 bar
27775 baz</p>
27776
27777 <table><tr><td>Foo
27778 bar
27779 baz bang</td></tr></table>
27780
27781 <p><!--boo--> foo
27782 bar</p>
27783
27784 <p> foo
27785 bar<span>boo</span></p>
27786 !! wikitext
27787 Foo
27788 bar
27789 baz
27790
27791 {|
27792 |Foo
27793 bar
27794 baz bang
27795 |}
27796
27797 <!--boo-->foo
27798 bar
27799
27800 foo
27801 bar<span>boo</span>
27802 !! end
27803
27804 !! test
27805 4. Indent Pre Nowiki: suppress leading whitespace in edited paragraphs
27806 !! options
27807 parsoid={
27808 "modes": ["selser"],
27809 "scrubWikitext": true,
27810 "changes": [
27811 [ "p", "html", " a\n b" ]
27812 ]
27813 }
27814 !! wikitext
27815 xyz
27816 !! wikitext/edited
27817 a
27818 b
27819 !! end
27820
27821 !! test
27822 1. New links that end in spaces
27823 !! options
27824 parsoid={
27825 "modes": ["html2wt"],
27826 "scrubWikitext": false
27827 }
27828 !! html/parsoid
27829 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
27830 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
27831 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
27832 !! wikitext
27833 [[Berlin ]]<nowiki/>is the capital of Germany.
27834
27835 [[Foo ]]'''bar'''
27836
27837 [[Boston ]] is a city.
27838 !! end
27839
27840 !! test
27841 2. New links that end in spaces
27842 !! options
27843 parsoid={
27844 "modes": ["html2wt"],
27845 "scrubWikitext": true
27846 }
27847 !! html/parsoid
27848 <p><a rel="mw:WikiLink" href="./Berlin" title="Berlin">Berlin </a>is the capital of Germany.</p>
27849 <p><a rel="mw:WikiLink" href="./Foo" title="Foo">Foo </a><b>bar</b></p>
27850 <p><a rel="mw:WikiLink" href="./Boston" title="Boston">Boston </a> is a city.</p>
27851 !! wikitext
27852 [[Berlin]] is the capital of Germany.
27853
27854 [[Foo]] '''bar'''
27855
27856 [[Boston]] is a city.
27857 !! end
27858
27859 !! test
27860 1. Table cells with escapable prefixes
27861 !! options
27862 parsoid={
27863 "modes": ["html2wt"],
27864 "scrubWikitext": false
27865 }
27866 !! html
27867 <table>
27868 <tr><td>a</td></tr>
27869 <tr><td>-</td></tr>
27870 <tr><td>+</td></tr>
27871 </table>
27872 !! wikitext
27873 {|
27874 |a
27875 |-
27876 |<nowiki>-</nowiki>
27877 |-
27878 |<nowiki>+</nowiki>
27879 |}
27880 !! end
27881
27882 !! test
27883 2. Table cells with escapable prefixes
27884 !! options
27885 parsoid={
27886 "modes": ["html2wt"],
27887 "scrubWikitext": true
27888 }
27889 !! html
27890 <table>
27891 <tr><td>a</td></tr>
27892 <tr><td>-</td></tr>
27893 <tr><td>+</td></tr>
27894 </table>
27895 !! wikitext
27896 {|
27897 |a
27898 |-
27899 | -
27900 |-
27901 | +
27902 |}
27903 !! end
27904
27905 !! test
27906 3a. Table cells with escapable prefixes after edits
27907 !! options
27908 parsoid={
27909 "modes": ["selser"],
27910 "scrubWikitext": true,
27911 "changes": [
27912 [ "table tbody tr:first-child td:first-child", "remove"]
27913 ]
27914 }
27915 !! wikitext
27916 {|
27917 |a||-
27918 |}
27919 !! wikitext/edited
27920 {|
27921 | -
27922 |}
27923 !! end
27924
27925 !! test
27926 3b. Table cells with escapable prefixes after edits
27927 !! options
27928 parsoid={
27929 "modes": ["selser"],
27930 "scrubWikitext": true,
27931 "changes": [
27932 [ "table tbody tr:first-child td:first-child", "html", "-" ],
27933 [ "#x", "remove" ]
27934 ]
27935 }
27936 !! wikitext
27937 {|
27938 |pqr
27939 |<span id="x">foo</span>+
27940 |}
27941 !! wikitext/edited
27942 {|
27943 | -
27944 | +
27945 |}
27946 !! end
27947
27948 # FIXME: This test will fail because
27949 # normalization doesn't realize that the id attribute
27950 # will eliminate the escapable scenario
27951 !! test
27952 4a. Table cells without escapable prefixes after edits
27953 !! options
27954 parsoid={
27955 "modes": ["selser"],
27956 "scrubWikitext": true,
27957 "changes": [
27958 [ "#x", "html", "-" ]
27959 ]
27960 }
27961 !! wikitext
27962 {|
27963 | id="x" |abcd
27964 |}
27965 !! wikitext/edited
27966 {|
27967 | id="x" |-
27968 |}
27969 !! end
27970
27971 ## This tests normalizer's ability to discriminate between
27972 ## cells having identical content.
27973 !! test
27974 4b. Table cells without escapable prefixes after edits
27975 !! options
27976 parsoid={
27977 "modes": ["selser"],
27978 "scrubWikitext": true,
27979 "changes": [
27980 [ "td", "html", "-" ]
27981 ]
27982 }
27983 !! wikitext
27984 {|
27985 |a||b
27986 |}
27987 !! wikitext/edited
27988 {|
27989 | -||-
27990 |}
27991 !! end
27992
27993 ## This tests normalizer's ability to not be tripped by
27994 ## comments (and whitespace)
27995 !! test
27996 4c. Table cells without escapable prefixes after edits
27997 !! options
27998 parsoid={
27999 "modes": ["selser"],
28000 "scrubWikitext": true,
28001 "changes": [
28002 [ "table tbody tr td:first-child", "remove" ]
28003 ]
28004 }
28005 !! wikitext
28006 {|
28007 |-
28008 <!--foo--> |a||-
28009 |}
28010 !! wikitext/edited
28011 {|
28012 |-
28013 <!--foo--> | -
28014 |}
28015 !! end
28016
28017 ## This tests normalizer's ability to handle HTML cells
28018 !! test
28019 4d. Table cells without escapable prefixes after edits
28020 !! options
28021 parsoid={
28022 "modes": ["selser"],
28023 "scrubWikitext": true,
28024 "changes": [
28025 [ "td", "html", "-" ]
28026 ]
28027 }
28028 !! wikitext
28029 <table>
28030 <tr><td>a</td></tr>
28031 </table>
28032 !! wikitext/edited
28033 <table>
28034 <tr><td>-</td></tr>
28035 </table>
28036 !! end
28037
28038 ## T111151 Remove font elements without attributes
28039 !! test
28040 5a. font tags without attributes should be dropped in scrubWikitext mode
28041 !! options
28042 parsoid={
28043 "modes": ["html2wt"],
28044 "scrubWikitext": true
28045 }
28046 !! html
28047 <font>foo</font>
28048 <font><font>bar</font></font>
28049 <font class="x">boo</font>
28050 !! wikitext
28051 foo
28052 bar
28053 <font class="x">boo</font>
28054 !! end
28055
28056 !! test
28057 5b. font tags should not be dropped without scrubWikitext being enabled
28058 !! options
28059 parsoid={
28060 "modes": ["html2wt"],
28061 "scrubWikitext": false
28062 }
28063 !! html
28064 <font>foo</font>
28065 !! wikitext
28066 <font>foo</font>
28067 !! end
28068
28069 !! test
28070 Escape nowiki DOM elements
28071 !! options
28072 parsoid=html2wt
28073 !! html/parsoid
28074 <nowiki><i>foo</i></nowiki>
28075 !! wikitext
28076 &lt;nowiki&gt;''foo''&lt;/nowiki&gt;
28077 !! end
28078
28079 # This is meant to be an interim fix while we go about figuring out
28080 # how to not introduce these trailing <nowiki/>s in the first place.
28081 !! test
28082 T115717: Strip trailing <nowiki/>s (without affecting valid uses)
28083 !! options
28084 parsoid=html2wt
28085 !! html/parsoid
28086 <p>x<meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/><meta typeof="mw:Placeholder" data-parsoid='{"src":"&lt;nowiki/>"}'/>
28087 y</p>
28088 <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>
28089 <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>
28090 !! wikitext
28091 x
28092 y
28093
28094 {{echo|
28095 1 = <nowiki/>}}
28096
28097 {{echo|
28098 1 = <nowiki/>
28099 }}
28100 !! end
28101
28102 # ---------------------------------------------------
28103 # End of tests spec'ing wikitext serialization norms |
28104 # ---------------------------------------------------
28105
28106 # T104032
28107 !! test
28108 Bare inline nodes not wrapped inside p-tags should be treated as p-wrapped
28109 !! options
28110 parsoid=html2wt
28111 !! html/parsoid
28112 a<p>b</p>
28113 <b>c</b><p>d</p>
28114 <table><tr>
28115 <td>a<p>b</p></td>
28116 <td><b>c</b><p>d</p></td>
28117 </tr></table>
28118 !! wikitext
28119 a
28120
28121 b
28122
28123 '''c'''
28124
28125 d
28126 {|
28127 |a
28128 b
28129 |'''c'''
28130 d
28131 |}
28132 !! end
28133
28134 !! test
28135 Anchor without href scenarios
28136 !! options
28137 parsoid={ "modes": ["html2wt"], "suppressErrors": true }
28138 !! html/parsoid
28139 <a class="bc"></a>
28140 <a class="no">dice</a>
28141 <a name="foo"></a>
28142 !! wikitext
28143
28144 dice
28145 <span name="foo"></span>
28146 !! end
28147
28148 !! test
28149 New transclusion added after a list should be serialized after the list
28150 !! options
28151 parsoid=html2wt
28152 !! html/parsoid
28153 <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>
28154 !! wikitext
28155 * a
28156 {{echo|foo}}
28157 !! end
28158
28159 # -----------------------------------------------------------------
28160 # End of section for Parsoid-only html2wt tests for serialization
28161 # of new content
28162 # -----------------------------------------------------------------
28163
28164 # -----------------------------------------------------------------
28165 # The following section of tests are primarily to spec behavior of
28166 # the selective serializer. All these tests have manual selser
28167 # changes. The automated selser changes for all tests handle the
28168 # wide variation of changes, but these tests here capture specs
28169 # deterministically.
28170 # ----------------------------------------------------------------
28171
28172 ## T90517
28173 !! test
28174 Selser: New comments should not be lost
28175 !! options
28176 parsoid={
28177 "modes": ["selser"],
28178 "changes": [
28179 [ "#a", "after", "<!--c1-->" ],
28180 [ "#b", "before", "<!--c2-->" ]
28181 ]
28182 }
28183 !! wikitext
28184 <span id="a">a</span>
28185
28186 <span id="b">b</span>
28187 !! wikitext/edited
28188 <span id="a">a</span><!--c1-->
28189
28190 <!--c2--><span id="b">b</span>
28191 !! end
28192
28193 ## T89383
28194 !! test
28195 Selser: Check for validity of DSR before using it
28196 !! options
28197 parsoid={
28198 "modes": ["selser"],
28199 "changes": [
28200 [ "#a", "before", "<meta property='mw:PageProp/displaytitle' content='foo'>" ]
28201 ]
28202 }
28203 !! wikitext
28204 <span id="a">a</span>
28205 !! wikitext/edited
28206 {{DISPLAYTITLE:foo}}
28207 <span id="a">a</span>
28208 !! end
28209
28210 !! test
28211 1. DOMDiff: Changes to <ref> content should be looked up using id
28212 !! options
28213 parsoid={
28214 "modes": ["selser"],
28215 "changes": [
28216 ["#X", "after", "bar"],
28217 ["#Y", "after", "baz"]
28218 ]
28219 }
28220 !! wikitext
28221 X <ref><span id="X">foo</span></ref>
28222 Y <ref name="a" />
28223 <references>
28224 <ref name="a"><span id="Y">foo</span></ref>
28225 </references>
28226 !! wikitext/edited
28227 X <ref><span id="X">foo</span>bar</ref>
28228 Y <ref name="a" />
28229 <references>
28230 <ref name="a"><span id="Y">foo</span>baz</ref>
28231 </references>
28232 !! end
28233
28234 !! test
28235 2. DOMDiff: Changes to <ref> content should be looked up using id
28236 !! options
28237 parsoid={
28238 "modes": ["selser"],
28239 "changes": [
28240 ["#Z", "after", "bar"]
28241 ]
28242 }
28243 !! wikitext
28244 A <ref>foo bar for a</ref>
28245 B <ref group="X" name="b" />
28246
28247 <references />
28248
28249 <references group="X">
28250 <ref name="b"><span id="Z">foo</span></ref>
28251 </references>
28252 !! wikitext/edited
28253 A <ref>foo bar for a</ref>
28254 B <ref group="X" name="b" />
28255
28256 <references />
28257
28258 <references group="X">
28259 <ref name="b"><span id="Z">foo</span>bar</ref>
28260 </references>
28261 !! end
28262
28263 !! test
28264 DOMDiff: Edits to content nested in elements with templated attributes should not be lost (T139388)
28265 !! options
28266 parsoid={
28267 "modes": ["selser"],
28268 "changes": [
28269 [ "div:first-child", "text", "bar" ]
28270 ]
28271 }
28272 !! wikitext
28273 <div style="{{1x|color:red;}}%">foo</div>
28274 !! wikitext/edited
28275 <div style="{{1x|color:red;}}%">bar</div>
28276 !! end
28277
28278 !! test
28279 Empty LI (T49673)
28280 !! wikitext
28281 * a
28282 *
28283 *
28284 * b
28285 !! html/php+tidy
28286 <ul>
28287 <li>a</li>
28288 <li class="mw-empty-elt"></li>
28289 <li class="mw-empty-elt"></li>
28290 <li>b</li>
28291 </ul>
28292 !! end
28293
28294 !! test
28295 Thumbnail output
28296 !! wikitext
28297 [[File:Thumb.png|thumb]]
28298 !! html/php+tidy
28299 <div class="thumb tright">
28300 <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>
28301 <div class="thumbcaption">
28302 <div class="magnify"><a href="/wiki/File:Thumb.png" class="internal" title="Enlarge"></a></div>
28303 </div>
28304 </div>
28305 </div>
28306 !! end
28307
28308 !! test
28309 unclosed internal link XSS (T137264)
28310 !! wikitext
28311 [[#%3Cscript%3Ealert(1)%3C/script%3E|
28312 !! html/php
28313 <p>[[#&lt;script&gt;alert(1)&lt;/script&gt;|
28314 </p>
28315 !! html/parsoid
28316 <p>[[#%3Cscript%3Ealert(1)%3C/script%3E|</p>
28317 !! end
28318
28319 !! test
28320 Validating that <style> isn't eaten by tidy (T167349)
28321 !! options
28322 # Use $wgRawHtml to inject a <style> tag, since you normally can't in wikitext
28323 wgRawHtml=1
28324 !! wikitext
28325 <div class="foo">
28326 <html><style>.foo::before { content: "<foo>"; }</style></html>
28327 <html><style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style></html>
28328 </div>
28329 !! html+tidy
28330 <div class="foo">
28331 <style>.foo::before { content: "<foo>"; }</style>
28332 <style data-mw-foobar="baz">.foo::after { content: "<bar>"; }</style>
28333 </div>
28334 !! end