bffc56ed11a6769ea5f121b9819d7fe20b295e82
[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:echo3
114 !! text
115 {{{1}}}
116 {{{1}}}
117 {{{1}}}
118 !! endarticle
119
120 // For Serbian; localize Template namespace
121 !! article
122 Шаблон:Echo
123 !! text
124 {{{1}}}
125 !! endarticle
126
127 !! article
128 Template:echo_with_span
129 !! text
130 <span>{{{1}}}</span>
131 !! endarticle
132
133 !! article
134 Template:echo_with_div
135 !! text
136 <div>{{{1}}}</div>
137 !! endarticle
138
139 !! article
140 Template:echo with depth
141 !! text
142 {{echo|{{{1}}}}}
143 !! endarticle
144
145 !! article
146 Template:blank_param
147 !! text
148 {{{1}}}
149 {{{}}}
150 !! endarticle
151
152 !! article
153 Template:table_attribs
154 !! text
155 <noinclude>
156 |</noinclude>style="color:red;"|Foo
157 !! endarticle
158
159 !! article
160 Template:table_attribs_2
161 !! text
162 <noinclude>
163 |</noinclude>style="color:red;"|Foo
164 |Bar||Baz
165 !! endarticle
166
167 !! article
168 Template:table_attribs_3
169 !! text
170 <noinclude>
171 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo
172 !! endarticle
173
174 !! article
175 Template:table_attribs_4
176 !! text
177 | style="background-color:#DC241f;" width="10px" |
178 !! endarticle
179
180 !! article
181 Template:table_attribs_5
182 !! text
183 <noinclude>
184 |</noinclude>style="color:red;"||Bar
185 !! endarticle
186
187 !! article
188 Template:table_attribs_6
189 !! text
190 style="background: <nowiki>
191
192
193 red;</nowiki>" |
194 !! endarticle
195
196 !! article
197 Template:table_attribs_7
198 !! text
199 <noinclude>
200 |</noinclude>style{{=}}"background:&#35;f9f9f9;"|Foo<ref>foo</ref>
201 !! endarticle
202
203 !! article
204 Template:table_header_cells
205 !! text
206 {{table_attribs}}!!style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
207 !! endarticle
208
209 !! article
210 Template:table_cells
211 !! text
212 {{table_attribs}}||style='color:red;'|''Bar''||style='color:brown;'|''Foo'' and Baz
213 !! endarticle
214
215 !! article
216 Template:PartialTable
217 !! text
218 {|
219 |-
220 !! endarticle
221
222 !! article
223 Template:image_attribs
224 !! text
225 <noinclude>
226 [[File:foobar.jpg|</noinclude>right|Caption text<noinclude>]]</noinclude>
227 !! endarticle
228
229 ## See T48811 for details
230 !! article
231 Template:mixed_attr_content_template
232 !! text
233 style="color:red;" title="T48811"
234 |-
235 |foo
236 !! endarticle
237
238 !! article
239 Template:definition_list
240 !! text
241 one
242 ::two
243 !! endarticle
244
245 !! article
246 A?b
247 !! text
248 Weirdo titles!
249 !! endarticle
250
251 !!article
252 Template:Bullet
253 !!text
254 * Bar
255 !!endarticle
256
257 !!article
258 Template:OpenTable
259 !!text
260 {|
261 !!endarticle
262
263 !!article
264 Template:EmptyLITest
265 !!text
266 *a
267 *
268 *
269 *b
270 !!endarticle
271
272 !!article
273 Template:EmptyTRTest
274 !!text
275 {|
276 |-
277 |-
278 |foo
279 |-
280 |-
281 |bar
282 |}
283 !!endarticle
284
285 !!article
286 Template:EmptyTRWithHTMLAttrTest
287 !!text
288 <table>
289 <tr align="center"></tr>
290 <tr><td>foo</td></tr>
291 <tr align="center"></tr>
292 <tr><td>bar</td></tr>
293 </table>
294 !!endarticle
295
296 !! article
297 Template:With: Colon
298 !! text
299 Template with colon
300 !! endarticle
301
302 ###
303 ### Basic tests
304 ###
305
306 !! test
307 Blank input
308 !! wikitext
309 !! html
310 !! end
311
312 !! test
313 Simple paragraph
314 !! wikitext
315 This is a simple paragraph.
316 !! html
317 <p>This is a simple paragraph.
318 </p>
319 !! end
320
321 !! test
322 Paragraphs with extra newline spacing
323 !! wikitext
324 foo
325
326 bar
327
328
329 baz
330
331
332
333 booz
334 !! html
335 <p>foo
336 </p><p>bar
337 </p><p><br />
338 baz
339 </p><p><br />
340 </p><p>booz
341 </p>
342 !! end
343
344 !! test
345 Paragraphs with newline spacing with comment lines in between
346 !! wikitext
347 ----
348 a
349 <!--foo-->
350 b
351 ----
352 a
353 <!--foo--><!--More than 1 comment, still stripped-->
354 b
355 ----
356 a
357 <!--foo--> <!----> <!-- bar -->
358 b
359 ----
360 a
361 <!--foo-->
362
363 b
364 ----
365 a
366
367 <!--foo-->
368 b
369 ----
370 a
371 <!--foo-->
372
373
374 b
375 ----
376 a
377
378
379 <!--foo-->
380 b
381 ----
382 !! html
383 <hr />
384 <p>a
385 b
386 </p>
387 <hr />
388 <p>a
389 b
390 </p>
391 <hr />
392 <p>a
393 b
394 </p>
395 <hr />
396 <p>a
397 </p><p>b
398 </p>
399 <hr />
400 <p>a
401 </p><p>b
402 </p>
403 <hr />
404 <p>a
405 </p><p><br />
406 b
407 </p>
408 <hr />
409 <p>a
410 </p><p><br />
411 b
412 </p>
413 <hr />
414
415 !! end
416
417 !! test
418 Paragraphs with newline spacing with non-empty white-space lines in between
419 !! wikitext
420 ----
421 a
422
423 b
424 ----
425 a
426
427
428 b
429 ----
430 !! html
431 <hr />
432 <p>a
433 </p><p>b
434 </p>
435 <hr />
436 <p>a
437 </p><p><br />
438 b
439 </p>
440 <hr />
441
442 !! end
443
444 !! test
445 Paragraphs with newline spacing with non-empty mixed comment and white-space lines in between
446 !! wikitext
447 ----
448 a
449 <!--foo-->
450 b
451 ----
452 a
453 <!--foo--><!--More than 1 comment doesn't disable stripping of this line!-->
454 b
455 ----
456 a
457
458 <!--foo-->
459 <!--bar-->
460 b
461 ----
462 a
463
464 <!--foo-->
465 <!--bar-->
466
467 b
468 ----
469 !! html
470 <hr />
471 <p>a
472 b
473 </p>
474 <hr />
475 <p>a
476 b
477 </p>
478 <hr />
479 <p>a
480 </p><p>b
481 </p>
482 <hr />
483 <p>a
484 </p><p><br />
485 b
486 </p>
487 <hr />
488
489 !! end
490
491 !! test
492 Extra newlines: More paragraphs with indented comment
493 !! wikitext
494 a
495
496 <!--boo-->
497
498 b
499 !! html
500 <p>a
501 </p><p><br />
502 b
503 </p>
504 !!end
505
506 !! test
507 Extra newlines followed by heading
508 !! wikitext
509 a
510
511
512
513 =b=
514 [[a]]
515
516
517 =b=
518 !! html
519 <p>a
520 </p><p><br />
521 </p>
522 <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>
523 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
524 </p><p><br />
525 </p>
526 <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>
527
528 !! end
529
530 !! test
531 Extra newlines between heading and content are swallowed
532 !! wikitext
533 =b=
534
535
536
537 [[a]]
538 !! html
539 <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>
540 <p><a href="/index.php?title=A&amp;action=edit&amp;redlink=1" class="new" title="A (page does not exist)">a</a>
541 </p>
542 !! end
543
544 !! test
545 Heading with line break in nowiki
546 !! options
547 parsoid=wt2html
548 !! config
549 wgFragmentMode=[ 'html5', 'legacy' ]
550 !! wikitext
551 ==A <nowiki>B
552 C</nowiki>==
553 !! html/php
554 <h2><span id="A_B.0AC"></span><span class="mw-headline" id="A_B
555 C">A B
556 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>
557
558 !! html/parsoid
559 <h2 id="A_B
560 C"><span id="A_B.0AC" typeof="mw:FallbackId"></span>A <span typeof="mw:Nowiki">B
561 C</span></h2>
562 !! end
563
564 !! test
565 Parsing an URL
566 !! wikitext
567 http://fr.wikipedia.org/wiki/🍺
568 <!-- EasterEgg we love beer, better be able be able to link to it -->
569 !! html
570 <p><a rel="nofollow" class="external free" href="http://fr.wikipedia.org/wiki/🍺">http://fr.wikipedia.org/wiki/🍺</a>
571 </p>
572 !! end
573
574 !! test
575 Simple list
576 !! wikitext
577 *Item 1
578 *Item 2
579 !! html
580 <ul><li>Item 1</li>
581 <li>Item 2</li></ul>
582
583 !! end
584
585 !! test
586 Italics and bold
587 !! wikitext
588 *plain
589 *plain''italic''plain
590 *plain''italic''plain''italic''plain
591 *plain'''bold'''plain
592 *plain'''bold'''plain'''bold'''plain
593 *plain''italic''plain'''bold'''plain
594 *plain'''bold'''plain''italic''plain
595 *plain''italic'''bold-italic'''italic''plain
596 *plain'''bold''bold-italic''bold'''plain
597 *plain'''''bold-italic'''italic''plain
598 *plain'''''bold-italic''bold'''plain
599 *plain''italic'''bold-italic'''''plain
600 *plain'''bold''bold-italic'''''plain
601 *plain l'''italic''plain
602 *plain l''''bold''' plain
603 !! html
604 <ul><li>plain</li>
605 <li>plain<i>italic</i>plain</li>
606 <li>plain<i>italic</i>plain<i>italic</i>plain</li>
607 <li>plain<b>bold</b>plain</li>
608 <li>plain<b>bold</b>plain<b>bold</b>plain</li>
609 <li>plain<i>italic</i>plain<b>bold</b>plain</li>
610 <li>plain<b>bold</b>plain<i>italic</i>plain</li>
611 <li>plain<i>italic<b>bold-italic</b>italic</i>plain</li>
612 <li>plain<b>bold<i>bold-italic</i>bold</b>plain</li>
613 <li>plain<i><b>bold-italic</b>italic</i>plain</li>
614 <li>plain<b><i>bold-italic</i>bold</b>plain</li>
615 <li>plain<i>italic<b>bold-italic</b></i>plain</li>
616 <li>plain<b>bold<i>bold-italic</i></b>plain</li>
617 <li>plain l'<i>italic</i>plain</li>
618 <li>plain l'<b>bold</b> plain</li></ul>
619
620 !! end
621
622 # this example taken from the [[simple:Moon]] article (T49326)
623 !! test
624 Italics and possessives (1)
625 !! wikitext
626 obtained by ''[[Lunar Prospector]]'''s gamma-ray spectrometer
627 !! html
628 <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
629 </p>
630 !! end
631
632 # this example taken from [[en:Flaming Pie]] (T51926)
633 !! test
634 Italics and possessives (2)
635 !! wikitext
636 '''''Flaming Pie''''' is ... released in 1997. In ''Flaming Pie'''s liner notes
637 !! html
638 <p><i><b>Flaming Pie</b></i> is ... released in 1997. In <i>Flaming Pie'</i>s liner notes
639 </p>
640 !! end
641
642 # this example taken from [[en:Dictionary]] (T51926)
643 !! test
644 Italics and possessives (3)
645 !! wikitext
646 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''.
647 !! html
648 <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>.
649 </p>
650 !! end
651
652
653 ###
654 ### 2-quote opening sequence tests
655 ###
656 !! test
657 Italics and bold: 2-quote opening sequence: (2,2)
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,3)
667 !! wikitext
668 ''foo'''
669 !! html/*
670 <p><i>foo'</i>
671 </p>
672 !!end
673
674 !! test
675 Italics and bold: 2-quote opening sequence: (2,4)
676 !! options
677 parsoid=wt2html
678 !! wikitext
679 ''foo''''
680 !! html/*
681 <p><i>foo''</i>
682 </p>
683 !!end
684
685 # same html as previous, but wikitext adjusted to match parsoid html2wt
686 !! test
687 Italics and bold: 2-quote opening sequence: (2,4) w/ nowiki
688 !! wikitext
689 ''foo<nowiki>''</nowiki>''
690 !! html
691 <p><i>foo''</i>
692 </p>
693 !! end
694
695 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
696 !! test
697 Italics and bold: 2-quote opening sequence: (2,5)
698 !! options
699 parsoid=wt2html
700 !! wikitext
701 ''foo'''''
702 !! html/php
703 <p><i>foo</i>
704 </p>
705 !! html/parsoid
706 <p><i>foo</i><b></b>
707 </p>
708 !!end
709
710 # same html as previous, but wikitext adjusted to match parsoid html2wt
711 !! test
712 Italics and bold: 2-quote opening sequence: (2,5+3) w/ nowiki
713 !! wikitext
714 ''foo'''''<nowiki/>'''
715 !! html/php
716 <p><i>foo</i>
717 </p>
718 !! html/parsoid
719 <p><i>foo</i><b></b>
720 </p>
721 !! end
722
723
724 ###
725 ### 3-quote opening sequence tests
726 ###
727
728 !! test
729 Italics and bold: 3-quote opening sequence: (3,2)
730 !! wikitext
731 '''foo''
732 !! html/*
733 <p>'<i>foo</i>
734 </p>
735 !!end
736
737 !! test
738 Italics and bold: 3-quote opening sequence: (3,3)
739 !! wikitext
740 '''foo'''
741 !! html
742 <p><b>foo</b>
743 </p>
744 !!end
745
746 !! test
747 Italics and bold: 3-quote opening sequence: (3,4)
748 !! wikitext
749 '''foo''''
750 !! html/*
751 <p><b>foo'</b>
752 </p>
753 !!end
754
755 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
756 !! test
757 Italics and bold: 3-quote opening sequence: (3,5)
758 !! options
759 parsoid=wt2html
760 !! wikitext
761 '''foo'''''
762 !! html/php
763 <p><b>foo</b>
764 </p>
765 !! html/parsoid
766 <p><b>foo</b><i></i>
767 </p>
768 !!end
769
770 # same html as previous, but wikitext adjusted to match parsoid html2wt
771 !! test
772 Italics and bold: 3-quote opening sequence: (3,5+2) w/ nowiki
773 !! wikitext
774 '''foo'''''<nowiki/>''
775 !! html/php
776 <p><b>foo</b>
777 </p>
778 !! html/parsoid
779 <p><b>foo</b><i></i>
780 </p>
781 !! end
782
783
784 ###
785 ### 4-quote opening sequence tests
786 ###
787
788 !! test
789 Italics and bold: 4-quote opening sequence: (4,2)
790 !! options
791 parsoid=wt2html
792 !! wikitext
793 ''''foo''
794 !! html/*
795 <p>''<i>foo</i>
796 </p>
797 !!end
798
799 # same html as previous, but wikitext adjusted to match parsoid html2wt
800 !! test
801 Italics and bold: 4-quote opening sequence: (4,2) w/ nowiki
802 !! wikitext
803 <nowiki>''</nowiki>''foo''
804 !! html
805 <p>''<i>foo</i>
806 </p>
807 !! end
808
809 !! test
810 Italics and bold: 4-quote opening sequence: (4,3)
811 !! wikitext
812 ''''foo'''
813 !! html/*
814 <p>'<b>foo</b>
815 </p>
816 !!end
817
818 !! test
819 Italics and bold: 4-quote opening sequence: (4,4)
820 !! options
821 parsoid=wt2html
822 !! wikitext
823 ''''foo''''
824 !! html/*
825 <p>'<b>foo'</b>
826 </p>
827 !!end
828
829 # same html as previous, but wikitext adjusted to match parsoid html2wt
830 !! test
831 Italics and bold: 4-quote opening sequence: (4,4) w/ nowiki
832 !! wikitext
833 '<nowiki/>'''foo''''
834 !! html
835 <p>'<b>foo'</b>
836 </p>
837 !! end
838
839 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
840 !! test
841 Italics and bold: 4-quote opening sequence: (4,5)
842 !! options
843 parsoid=wt2html
844 !! wikitext
845 ''''foo'''''
846 !! html/php
847 <p>'<b>foo</b>
848 </p>
849 !! html/parsoid
850 <p>'<b>foo</b><i></i>
851 </p>
852 !!end
853
854 # same html as previous, but wikitext adjusted to match parsoid html2wt
855 !! test
856 Italics and bold: 4-quote opening sequence: (4,5+2) w/ nowiki
857 !! wikitext
858 '<nowiki/>'''foo'''''<nowiki/>''
859 !! html/php
860 <p>'<b>foo</b>
861 </p>
862 !! html/parsoid
863 <p>'<b>foo</b><i></i>
864 </p>
865 !! end
866
867
868 ###
869 ### 5-quote opening sequence tests
870 ###
871
872 !! test
873 Italics and bold: 5-quote opening sequence: (5,2)
874 !! options
875 parsoid=wt2html
876 !! wikitext
877 '''''foo''
878 !! html/*
879 <p><b><i>foo</i></b>
880 </p>
881 !!end
882
883 # same html as previous, but wikitext adjusted to match parsoid html2wt
884 !! test
885 Italics and bold: 5-quote opening sequence: (5,2+3)
886 !! wikitext
887 '''''foo'''''
888 !! html/*
889 <p><i><b>foo</b></i>
890 </p>
891 !! end
892
893 !! test
894 Italics and bold: 5-quote opening sequence: (5,3)
895 !! options
896 parsoid=wt2html
897 !! wikitext
898 '''''foo'''
899 !! html/*
900 <p><i><b>foo</b></i>
901 </p>
902 !!end
903
904 # same html as previous, but wikitext adjusted to match parsoid html2wt
905 !! test
906 Italics and bold: 5-quote opening sequence: (5,3+2)
907 !! wikitext
908 '''''foo'''''
909 !! html
910 <p><i><b>foo</b></i>
911 </p>
912 !! end
913
914 !! test
915 Italics and bold: 5-quote opening sequence: (5,4)
916 !! options
917 parsoid=wt2html
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,5)
927 !! wikitext
928 '''''foo'''''
929 !! html
930 <p><i><b>foo</b></i>
931 </p>
932 !!end
933
934 !! test
935 Italics and bold: 5-quote opening sequence: (5,6)
936 !! wikitext
937 '''''foo''''''
938 !! html/*
939 <p><i><b>foo'</b></i>
940 </p>
941 !! end
942
943 ###
944 ### multiple quote sequences in a line
945 ###
946
947 !! test
948 Italics and bold: multiple quote sequences: (2,4,2)
949 !! options
950 parsoid=wt2html
951 !! wikitext
952 ''foo''''bar''
953 !! html/*
954 <p><i>foo'<b>bar</b></i>
955 </p>
956 !! end
957
958 # same html as previous, but wikitext adjusted to match parsoid html2wt
959 !! test
960 Italics and bold: multiple quote sequences: (2,4,2+3) w/ nowiki
961 !! wikitext
962 ''foo'<nowiki/>'''bar'''''
963 !! html
964 <p><i>foo'<b>bar</b></i>
965 </p>
966 !! end
967
968 !! test
969 Italics and bold: multiple quote sequences: (2,4,3)
970 !! options
971 parsoid=wt2html
972 !! wikitext
973 ''foo''''bar'''
974 !! html/*
975 <p><i>foo'<b>bar</b></i>
976 </p>
977 !! end
978
979 # same html as previous, but wikitext adjusted to match parsoid html2wt
980 !! test
981 Italics and bold: multiple quote sequences: (2,4,3+2) w/ nowiki
982 !! wikitext
983 ''foo'<nowiki/>'''bar'''''
984 !! html
985 <p><i>foo'<b>bar</b></i>
986 </p>
987 !! end
988
989 !! test
990 Italics and bold: multiple quote sequences: (2,4,4)
991 !! options
992 parsoid=wt2html
993 !! wikitext
994 ''foo''''bar''''
995 !! html/*
996 <p><i>foo'<b>bar'</b></i>
997 </p>
998 !! end
999
1000 # same html as previous, but wikitext adjusted to match parsoid html2wt
1001 !! test
1002 Italics and bold: multiple quote sequences: (2,4,4+2) w/ nowiki
1003 !! wikitext
1004 ''foo'<nowiki/>'''bar'<nowiki/>'''''
1005 !! html
1006 <p><i>foo'<b>bar'</b></i>
1007 </p>
1008 !! end
1009
1010 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1011 !! test
1012 Italics and bold: multiple quote sequences: (3,4,2)
1013 !! options
1014 parsoid=wt2html
1015 !! wikitext
1016 '''foo''''bar''
1017 !! html/php
1018 <p><b>foo'</b>bar
1019 </p>
1020 !! html/parsoid
1021 <p><b>foo'</b>bar<i></i>
1022 </p>
1023 !! end
1024
1025 # same html as previous, but wikitext adjusted to match parsoid html2wt
1026 !! test
1027 Italics and bold: multiple quote sequences: (3,4,2+2) w/ nowiki
1028 !! wikitext
1029 '''foo''''bar''<nowiki/>''
1030 !! html/php
1031 <p><b>foo'</b>bar
1032 </p>
1033 !! html/parsoid
1034 <p><b>foo'</b>bar<i></i>
1035 </p>
1036 !! end
1037
1038 # The PHP parser strips the empty tags out for giggles; parsoid doesn't.
1039 !! test
1040 Italics and bold: multiple quote sequences: (3,4,3)
1041 !! options
1042 parsoid=wt2html
1043 !! wikitext
1044 '''foo''''bar'''
1045 !! html/php
1046 <p><b>foo'</b>bar
1047 </p>
1048 !! html/parsoid
1049 <p><b>foo'</b>bar<b></b>
1050 </p>
1051 !! end
1052
1053 # same html as previous, but wikitext adjusted to match parsoid html2wt
1054 !! test
1055 Italics and bold: multiple quote sequences: (3,4,3+3) w/ nowiki
1056 !! wikitext
1057 '''foo''''bar'''<nowiki/>'''
1058 !! html/php
1059 <p><b>foo'</b>bar
1060 </p>
1061 !! html/parsoid
1062 <p><b>foo'</b>bar<b></b>
1063 </p>
1064 !! end
1065
1066 ###
1067 ### other quote tests
1068 ###
1069 !! test
1070 Italics and bold: other quote tests: (2,3,5)
1071 !! wikitext
1072 ''this is about '''foo's family'''''
1073 !! html
1074 <p><i>this is about <b>foo's family</b></i>
1075 </p>
1076 !!end
1077
1078
1079 !! test
1080 Italics and bold: other quote tests: (2,(3,3),2)
1081 !! wikitext
1082 ''this is about '''foo's''' family''
1083 !! html
1084 <p><i>this is about <b>foo's</b> family</i>
1085 </p>
1086 !!end
1087
1088
1089 !! test
1090 Italics and bold: other quote tests: (3,2,3,2)
1091 !! options
1092 parsoid=wt2html
1093 !! wikitext
1094 '''this is about ''foo'''s family''
1095 !! html/*
1096 <p><b>this is about <i>foo</i></b><i>s family</i>
1097 </p>
1098 !!end
1099
1100
1101 # same html as previous, but wikitext adjusted to match parsoid html2wt
1102 !! test
1103 Italics and bold: other quote tests: (3,2,3+2+2,2)
1104 !! wikitext
1105 '''this is about ''foo'''''<nowiki/>''s family''
1106 !! html
1107 <p><b>this is about <i>foo</i></b><i>s family</i>
1108 </p>
1109 !! end
1110
1111
1112 !! test
1113 Italics and bold: other quote tests: (3,2,3,3)
1114 !! wikitext
1115 '''this is about ''foo'''s family'''
1116 !! html/*
1117 <p>'<i>this is about </i>foo<b>s family</b>
1118 </p>
1119 !!end
1120
1121
1122 !! test
1123 Italics and bold: other quote tests: (3,(2,2),3)
1124 !! wikitext
1125 '''this is about ''foo's'' family'''
1126 !! html
1127 <p><b>this is about <i>foo's</i> family</b>
1128 </p>
1129 !!end
1130
1131
1132 !! test
1133 Italicized possessive
1134 !! wikitext
1135 The ''[[Main Page]]'''s talk page.
1136 !! html/php
1137 <p>The <i><a href="/wiki/Main_Page" title="Main Page">Main Page</a>'</i>s talk page.
1138 </p>
1139 !! html/parsoid
1140 <p>The <i><a rel="mw:WikiLink" href="./Main_Page" title="Main Page">Main Page</a>'</i>s talk page.</p>
1141 !! end
1142
1143 !! test
1144 Quote balancing context should be restricted to td/th cells on the same wikitext line
1145 !! options
1146 parsoid=wt2html,wt2wt
1147 !! wikitext
1148 {|
1149 !''a!!''b
1150 |''a||''b
1151 |}
1152 !! html+tidy
1153 <table>
1154 <tbody><tr>
1155 <th><i>a</i></th>
1156 <th><i>b</i>
1157 </th>
1158 <td><i>a</i></td>
1159 <td><i>b</i>
1160 </td></tr></tbody></table>
1161 !! end
1162
1163 ###
1164 ### Non-html5 tags
1165 ###
1166
1167 !! test
1168 Non-html5 tags should be accepted
1169 !! wikitext
1170 <center>''foo''</center>
1171 <big>''foo''</big>
1172 <font>''foo''</font>
1173 <strike>''foo''</strike>
1174 <tt>''foo''</tt>
1175 !! html
1176 <center><i>foo</i></center>
1177 <p><big><i>foo</i></big>
1178 <font><i>foo</i></font>
1179 <strike><i>foo</i></strike>
1180 <tt><i>foo</i></tt>
1181 </p>
1182 !! end
1183
1184 !! test
1185 <wbr> is valid wikitext (T54468)
1186 !! wikitext
1187 <wbr>
1188 !! html
1189 <p><wbr />
1190 </p>
1191 !! end
1192
1193 # <strike> is HTML4, <s> is HTML4/5.
1194 !! test
1195 <s> or <strike> for strikethrough
1196 !! wikitext
1197 <strike>strike</strike>
1198
1199 <s>s</s>
1200 !! html
1201 <p><strike>strike</strike>
1202 </p><p><s>s</s>
1203 </p>
1204 !! end
1205
1206 ## a not permitted
1207 ## i,b,br omitted
1208 !! test
1209 Text-level semantic html elements in wikitext
1210 !! wikitext
1211 <em>text</em>
1212 <strong>text</strong>
1213 <small>text</small>
1214 <s>text</s>
1215 <cite>text</cite>
1216 <q>text</q>
1217 <dfn>text</dfn>
1218 <abbr>text</abbr>
1219 <data>text</data>
1220 <time>text</time>
1221 <code>text</code>
1222 <var>text</var>
1223 <samp>text</samp>
1224 <kbd>text</kbd>
1225 <sub>text</sub>
1226 <u>text</u>
1227 <mark>text</mark>
1228 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1229 <bdi>text</bdi>
1230 <bdo>text</bdo>
1231 <span>text</span>
1232 <wbr />
1233 !! html
1234 <p><em>text</em>
1235 <strong>text</strong>
1236 <small>text</small>
1237 <s>text</s>
1238 <cite>text</cite>
1239 <q>text</q>
1240 <dfn>text</dfn>
1241 <abbr>text</abbr>
1242 <data>text</data>
1243 <time>text</time>
1244 <code>text</code>
1245 <var>text</var>
1246 <samp>text</samp>
1247 <kbd>text</kbd>
1248 <sub>text</sub>
1249 <u>text</u>
1250 <mark>text</mark>
1251 <ruby><rb>明日</rb><rp>(</rp><rt>Ashita</rt><rp> </rp><rtc>あした</rtc><rp>)</rp></ruby>
1252 <bdi>text</bdi>
1253 <bdo>text</bdo>
1254 <span>text</span>
1255 <wbr />
1256 </p>
1257 !! end
1258
1259 # test cases taken from
1260 # https://www.w3.org/TR/html5/text-level-semantics.html#the-ruby-element
1261 !! test
1262 Ruby markup (W3C-style)
1263 !! wikitext
1264 ;Mono-ruby for individual base characters
1265 :<ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby>
1266 ;Group ruby
1267 :<ruby>今日<rt>きょう</rt></ruby>
1268 ;Jukugo ruby
1269 :<ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby>
1270 ;Inline ruby
1271 :<ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby>
1272 ;Double-sided ruby
1273 :<ruby><rb>旧</rb><rb>金</rb><rb>山</rb><rt>jiù</rt><rt>jīn</rt><rt>shān</rt><rtc>San Francisco</rtc></ruby>
1274
1275 <ruby>
1276 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1277 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1278 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1279 </ruby>
1280 !! html
1281 <dl><dt>Mono-ruby for individual base characters</dt>
1282 <dd><ruby>日<rt>に</rt>本<rt>ほん</rt>語<rt>ご</rt></ruby></dd>
1283 <dt>Group ruby</dt>
1284 <dd><ruby>今日<rt>きょう</rt></ruby></dd>
1285 <dt>Jukugo ruby</dt>
1286 <dd><ruby>法<rb>華</rb><rb>経</rb><rt>ほ</rt><rt>け</rt><rt>きょう</rt></ruby></dd>
1287 <dt>Inline ruby</dt>
1288 <dd><ruby>東<rb>京</rb><rp>(</rp><rt>とう</rt><rt>きょう</rt><rp>)</rp></ruby></dd>
1289 <dt>Double-sided ruby</dt>
1290 <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>
1291 <p><ruby>
1292 <rb>♥</rb><rtc><rt>Heart</rt></rtc><rtc lang="fr"><rt>Cœur</rt></rtc>
1293 <rb>☘</rb><rtc><rt>Shamrock</rt></rtc><rtc lang="fr"><rt>Trèfle</rt></rtc>
1294 <rb>✶</rb><rtc><rt>Star</rt></rtc><rtc lang="fr"><rt>Étoile</rt></rtc>
1295 </ruby>
1296 </p>
1297 !! end
1298
1299 # The next two test different paths in the sanitizer.
1300 !! test
1301 Non-word characters don't terminate tag names (T19663, T42670, T54022)
1302 !! wikitext
1303 <blockquote|>a</blockquote>
1304
1305 <b→> doesn't terminate </b→>
1306
1307 <bä> doesn't terminate </bä>
1308
1309 <boo> doesn't terminate </boo>
1310
1311 <s.foo> doesn't terminate </s.foo>
1312
1313 <sub-ID#1>
1314 !! html
1315 <p>&lt;blockquote|&gt;a&lt;/blockquote&gt;
1316 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1317 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1318 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1319 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1320 </p><p>&lt;sub-ID#1&gt;
1321 </p>
1322 !! end
1323
1324 !! test
1325 Non-word characters don't terminate tag names
1326 !! wikitext
1327 <blockquote|>a</blockquote>
1328
1329 <b→> doesn't terminate </b→>
1330
1331 <bä> doesn't terminate </bä>
1332
1333 <boo> doesn't terminate </boo>
1334
1335 <s.foo> doesn't terminate </s.foo>
1336
1337 <sub-ID#1>
1338 !! html+tidy
1339 <p>&lt;blockquote|&gt;a
1340 </p><p>&lt;b→&gt; doesn't terminate &lt;/b→&gt;
1341 </p><p>&lt;bä&gt; doesn't terminate &lt;/bä&gt;
1342 </p><p>&lt;boo&gt; doesn't terminate &lt;/boo&gt;
1343 </p><p>&lt;s.foo&gt; doesn't terminate &lt;/s.foo&gt;
1344 </p><p>&lt;sub-ID#1&gt;
1345 </p>
1346 !! end
1347
1348 ###
1349 ### See tests/parser/parserTestsParserHook.php for the <tåg> extension)
1350 ### This checks that HTML5 tags (with non-word characters in the tag
1351 ### name) make it safely through the parser -- the Sanitizer will
1352 ### munge them later, as it should.
1353 ###
1354 !! test
1355 Non-word characters are valid in extension tags (T19663)
1356 !! wikitext
1357 <tåg>tåg</tåg>
1358 !! html/php
1359 <pre>
1360 'tåg'
1361 array (
1362 )
1363 </pre>
1364
1365 !! html/parsoid
1366 <pre typeof="mw:Extension/tåg" data-mw='{"name":"tåg","attrs":{},"body":{"extsrc":"tåg"}}' data-parsoid='{}' about="#mwt2"></pre>
1367 !! end
1368
1369 !! test
1370 Isolated close tags should be treated as literal text (T54760)
1371 !! options
1372 parsoid=wt2html
1373 !! wikitext
1374 </b>
1375
1376 <s.foo>s</s>
1377 !! html/php+tidy
1378 <p class="mw-empty-elt">
1379 </p><p>&lt;s.foo&gt;s
1380 </p>
1381 !! html/parsoid
1382 <p>&lt;s.foo&gt;s</p>
1383 !! end
1384
1385 ###
1386 ### Special characters
1387 ###
1388
1389 !! test
1390 Bare pipe character (T54363)
1391 !! wikitext
1392 |
1393 !! html
1394 <p>|
1395 </p>
1396 !! end
1397
1398 !! test
1399 Bare pipe character from a template (T54363)
1400 !! wikitext
1401 {{pipe}}
1402 !! html
1403 <p>|
1404 </p>
1405 !! end
1406
1407 ###
1408 ### <nowiki> test cases
1409 ###
1410
1411 !! test
1412 <nowiki> unordered list
1413 !! wikitext
1414 <nowiki>* This is not an unordered list item.</nowiki>
1415 !! html/php
1416 <p>* This is not an unordered list item.
1417 </p>
1418 !! html/parsoid
1419 <p><span typeof="mw:Nowiki">* This is not an unordered list item.</span></p>
1420 !! end
1421
1422 !! test
1423 <nowiki> spacing
1424 !! wikitext
1425 <nowiki>Lorem ipsum dolor
1426
1427 sed abit.
1428 sed nullum.
1429
1430 :and a colon
1431 </nowiki>
1432 !! html/php
1433 <p>Lorem ipsum dolor
1434
1435 sed abit.
1436 sed nullum.
1437
1438 :and a colon
1439
1440 </p>
1441 !! html/parsoid
1442 <p><span typeof="mw:Nowiki">Lorem ipsum dolor
1443
1444 sed abit.
1445 sed nullum.
1446
1447 :and a colon
1448 </span></p>
1449 !! end
1450
1451 !! test
1452 Don't parse <nowiki><span class="error"></nowiki> (T149622)
1453 !! wikitext
1454 <nowiki><span class="error"></nowiki>
1455 !! html/php
1456 <p>&lt;span class="error"&gt;
1457 </p>
1458 !! html/parsoid
1459 <p><span typeof="mw:Nowiki">&lt;span class="error"></span></p>
1460 !! end
1461
1462 !! test
1463 nowiki 3
1464 !! wikitext
1465 :There is not nowiki.
1466 :There is <nowiki>nowiki</nowiki>.
1467
1468 #There is not nowiki.
1469 #There is <nowiki>nowiki</nowiki>.
1470
1471 *There is not nowiki.
1472 *There is <nowiki>nowiki</nowiki>.
1473 !! html/php
1474 <dl><dd>There is not nowiki.</dd>
1475 <dd>There is nowiki.</dd></dl>
1476 <ol><li>There is not nowiki.</li>
1477 <li>There is nowiki.</li></ol>
1478 <ul><li>There is not nowiki.</li>
1479 <li>There is nowiki.</li></ul>
1480
1481 !! html/parsoid
1482 <dl><dd data-parsoid='{}'>There is not nowiki.</dd>
1483 <dd data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</dd></dl>
1484
1485 <ol><li data-parsoid='{}'>There is not nowiki.</li>
1486 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ol>
1487
1488 <ul><li data-parsoid='{}'>There is not nowiki.</li>
1489 <li data-parsoid='{}'>There is <span typeof="mw:Nowiki">nowiki</span>.</li></ul>
1490 !! end
1491
1492 !! test
1493 Entities inside <nowiki>
1494 !! wikitext
1495 <nowiki>&lt;</nowiki>
1496 !! html/php
1497 <p>&lt;
1498 </p>
1499 !! html/parsoid
1500 <p><span typeof="mw:Nowiki"><span typeof="mw:Entity" data-parsoid='{"src":"&amp;lt;","srcContent":"&lt;"}'>&lt;</span></span></p>
1501 !! end
1502
1503 !! test
1504 Entities inside template parameters
1505 !! wikitext
1506 {{echo|&ndash;}}
1507 !! html/php+tidy
1508 <p>&#8211;
1509 </p>
1510 !! html/parsoid
1511 <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>
1512 !! end
1513
1514 !! test
1515 Properly escape nowiki when combined with other wiki markup
1516 !! options
1517 parsoid=html2wt
1518 !! html/parsoid
1519 <p>* &lt;/nowiki&gt; tag</p>
1520 !! wikitext
1521 <nowiki>*</nowiki> <nowiki>&lt;/nowiki&gt;</nowiki> tag
1522 !! end
1523
1524 !! test
1525 T93824: Put escaped HTML tags inside nowiki
1526 !! options
1527 parsoid=html2wt
1528 !! html/parsoid
1529 <p>&lt;h2&gt;foo&lt;/h2&gt;</p>
1530 !! wikitext
1531 <nowiki><h2>foo</h2></nowiki>
1532 !! end
1533
1534 !! test
1535 T71950: 1. Put nowiki as close to cause as possible, even with non-quote escapable chars
1536 !! options
1537 parsoid=html2wt
1538 !! html/parsoid
1539 <p>This text: L'<a rel="mw:WikiLink" href="./Foo">Foo</a>
1540 This text: L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1541 This text: L'''<a rel="mw:WikiLink" href="./Foo">Foo</a>''</p>
1542 !! wikitext
1543 This text: L'[[Foo]]
1544 This text: L<nowiki>''</nowiki>[[Foo]]
1545 This text: L<nowiki>'''</nowiki>[[Foo]]<nowiki>''</nowiki>
1546 !! end
1547
1548 # This test fails because wikitext whitespace is not normalized before comparing.
1549 !! test
1550 T71950: 2. Put nowiki as close to cause as possible, after ' :'
1551 !! options
1552 parsoid=html2wt
1553 !! html/parsoid
1554 <p>This text : L''<a rel="mw:WikiLink" href="./Foo">Foo</a>
1555 </p>
1556 !! wikitext
1557 This text : L<nowiki>''</nowiki>[[Foo]]
1558 !! end
1559
1560 # This test and the next one are html2wt only as they test that incorrect wikitext
1561 # passed in template arguments gets escaped or wrapped in nowikis where required.
1562 !! test
1563 T71482: Use {{!}} instead of nowiki for single pipe in template argument
1564 !! options
1565 parsoid=html2wt
1566 !! html/parsoid
1567 <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>
1568 <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>
1569 !! wikitext
1570 {{echo|foo{{!}}bar}}
1571 {{echo|<nowiki>foo|bar |[[</nowiki>}}
1572 !! end
1573
1574 !! test
1575 T53961: Output correct nowikis in template arguments
1576 !! options
1577 parsoid=html2wt
1578 !! html/parsoid
1579 <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>
1580 <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>
1581 <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>
1582 <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>
1583 <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>
1584 !! wikitext
1585 {{echo|a [ b}}
1586 {{echo|<nowiki>a }} b</nowiki>}}
1587 {{echo|<nowiki>a [[ b</nowiki>}}
1588 {{echo|<nowiki>a | {{ ]]</nowiki>}}
1589 {{echo|a <nowiki>}</nowiki>}}
1590 !! end
1591
1592 !! test
1593 Cases where "!!" needs nowiki protection
1594 !! options
1595 parsoid=html2wt
1596 !! html/parsoid
1597 <table>
1598 <tr><th>this needs protection !! here</th></tr>
1599 </table>
1600
1601 <table>
1602 <tr><th>this does not need
1603 protection !! here</th></tr>
1604 </table>
1605 !! wikitext
1606 {|
1607 !<nowiki>this needs protection !! here</nowiki>
1608 |}
1609
1610 {|
1611 !this does not need
1612 protection !! here
1613 |}
1614 !! end
1615
1616 ###
1617 ### Comments
1618 ###
1619 !! test
1620 Comments and Indent-Pre
1621 !! wikitext
1622 <!-- comment 1 --> asdf
1623
1624 <!-- comment 1 --> asdf
1625 <!-- comment 2 -->
1626
1627 <!-- comment 1 --> asdf
1628 <!-- comment 2 -->xyz
1629
1630 <!-- comment 1 --> asdf
1631 <!-- comment 2 --> xyz
1632 !! html
1633 <pre>asdf
1634 </pre>
1635 <pre>asdf
1636 </pre>
1637 <pre>asdf
1638 </pre>
1639 <p>xyz
1640 </p>
1641 <pre>asdf
1642 xyz
1643 </pre>
1644 !! end
1645
1646 !! test
1647 Comment test 2a
1648 !! wikitext
1649 asdf
1650 <!-- comment 1 -->
1651 jkl
1652 !! html
1653 <p>asdf
1654 jkl
1655 </p>
1656 !! end
1657
1658 !! test
1659 Comment test 2b
1660 !! wikitext
1661 asdf
1662 <!-- comment 1 -->
1663
1664 jkl
1665 !! html
1666 <p>asdf
1667 </p><p>jkl
1668 </p>
1669 !! end
1670
1671 !! test
1672 Comment test 3
1673 !! wikitext
1674 asdf
1675 <!-- comment 1 -->
1676 <!-- comment 2 -->
1677 jkl
1678 !! html
1679 <p>asdf
1680 jkl
1681 </p>
1682 !! end
1683
1684 !! test
1685 Comment test 4
1686 !! wikitext
1687 asdf<!-- comment 1 -->jkl
1688 !! html
1689 <p>asdfjkl
1690 </p>
1691 !! end
1692
1693 !! test
1694 Comment spacing
1695 !! wikitext
1696 a
1697 <!-- foo --> b <!-- bar -->
1698 c
1699 !! html
1700 <p>a
1701 </p>
1702 <pre> b
1703 </pre>
1704 <p>c
1705 </p>
1706 !! end
1707
1708 !! test
1709 Comment whitespace
1710 !! wikitext
1711 <!-- returns a single newline, not nothing, since the newline after > is not stripped -->
1712 !! html
1713
1714 !! end
1715
1716 !! test
1717 Comment semantics and delimiters
1718 !! wikitext
1719 <!-- --><!----><!-----><!------>
1720 !! html/php
1721
1722 !! html/parsoid
1723 <!-- --><!----><!--&#x2D;--><!--&#x2D;&#x2D;-->
1724 !! end
1725
1726 !! test
1727 Comment semantics and delimiters, redux
1728 !! wikitext
1729 <!-- In SGML every "foo" here would actually show up in the text -- foo -- bar
1730 -- foo -- funky huh? ... -->
1731 !! html/php
1732
1733 !! html/parsoid
1734 <!-- In SGML every "foo" here would actually show up in the text &#x2D;&#x2D; foo &#x2D;&#x2D; bar
1735 &#x2D;&#x2D; foo &#x2D;&#x2D; funky huh? ... -->
1736 !! end
1737
1738 !! test
1739 Comment semantics and delimiters: directors cut
1740 !! wikitext
1741 <!-- ... However we like to keep things simple and somewhat XML-ish so we eat
1742 everything starting with < followed by !-- until the first -- and > we see,
1743 that wouldn't be valid XML however, since in XML -- has to terminate a comment
1744 -->-->
1745 !! html/php
1746 <p>--&gt;
1747 </p>
1748 !! html/parsoid
1749 <!-- ... However we like to keep things simple and somewhat XML&#x2D;ish so we eat
1750 everything starting with < followed by !&#x2D;&#x2D; until the first &#x2D;&#x2D; and &#x3E; we see,
1751 that wouldn't be valid XML however, since in XML &#x2D;&#x2D; has to terminate a comment
1752 --><p>--></p>
1753 !! end
1754
1755 !! test
1756 Comment semantics: nesting
1757 !! wikitext
1758 <!--<!-- no, we're not going to do anything fancy here -->-->
1759 !! html/php
1760 <p>--&gt;
1761 </p>
1762 !! html/parsoid
1763 <!--<!&#x2D;&#x2D; no, we're not going to do anything fancy here --><p>--></p>
1764 !! end
1765
1766 # Parsoid closes the unclosed comment, even if it means a slight
1767 # round-trip diff.
1768 !! test
1769 Comment semantics: unclosed comment at end
1770 !! options
1771 parsoid=wt2html,html2html
1772 !! wikitext
1773 <!--This comment will run out to the end of the document
1774 !! html/php
1775
1776 !! html/parsoid
1777 <!--This comment will run out to the end of the document-->
1778 !! end
1779
1780 !! test
1781 Comment semantics: normalize comments to play nice with XML and browsers
1782 !! wikitext
1783 <!-- Browsers --!> think this is closed -->
1784 <!--> This would normally be text -->
1785 <!---> As would this -->
1786 <!-- XML doesn't like trailing dashes -------->
1787 <!-- Nor doubled hyphens -- anywhere in the data -->
1788 But this is not a comment.
1789 !! html/php
1790 <p>But this is not a comment.
1791 </p>
1792 !! html/parsoid
1793 <!-- Browsers &#x2D;&#x2D;!&#x3E; think this is closed -->
1794 <!--&#x3E; This would normally be text -->
1795 <!--&#x2D;&#x3E; As would this -->
1796 <!-- XML doesn't like trailing dashes &#x2D;&#x2D;&#x2D;&#x2D;&#x2D;&#x2D;-->
1797 <!-- Nor doubled hyphens &#x2D;&#x2D; anywhere in the data -->
1798 <p>But this is not a comment.</p>
1799 !! end
1800
1801 !! test
1802 Comment semantics: round-trip even text which contains encoded -->
1803 !! wikitext
1804 <!-- hello & goodbye - > --&gt; --&amp;gt; --&xx -->
1805 !! html/parsoid
1806 <!-- hello &#x26; goodbye &#x2D; &#x3E; &#x2D;&#x2D;&#x3E; &#x2D;&#x2D;&#x26;gt; &#x2D;&#x2D;&#x26;xx -->
1807 !! end
1808
1809 !! test
1810 Comment in template title
1811 !! wikitext
1812 {{f<!---->oo}}
1813 !! html
1814 <p>FOO
1815 </p>
1816 !! end
1817
1818 !! test
1819 Comment on its own line post-expand
1820 !! wikitext
1821 a
1822 {{blank}}<!---->
1823 b
1824 !! html
1825 <p>a
1826 </p><p>b
1827 </p>
1828 !! end
1829
1830 !! test
1831 Comment on its own line post-expand with non-significant whitespace
1832 !! wikitext
1833 a
1834 {{blank}} <!---->
1835 b
1836 !! html
1837 <p>a
1838 </p><p>b
1839 </p>
1840 !! end
1841
1842 !! test
1843 post-expand include size being exceeded
1844 !! options
1845 maxincludesize=20
1846 !! wikitext
1847 {{echo3|1234567890}}
1848 !! html
1849 <p><a href="/wiki/Template:Echo3" title="Template:Echo3">Template:Echo3</a><!-- WARNING: template omitted, post-expand include size too large -->
1850 </p>
1851 !! end
1852
1853 !! test
1854 max template depth being reached
1855 !! options
1856 maxtemplatedepth=1
1857 !! wikitext
1858 {{echo with depth|too deep!}}
1859 !! html
1860 <p><span class="error">Template recursion depth limit exceeded (1)</span>
1861 </p>
1862 !! end
1863
1864 !! test
1865 Multiple comments should still parse as SOL-transparent
1866 !! options
1867 parsoid=wt2html,wt2wt
1868 !! wikitext
1869 <!--c1-->*a
1870 <!--c2--><!--c3--><!--c4-->*b
1871 !! html/php
1872 <ul><li>a</li>
1873 <li>b</li></ul>
1874
1875 !! html/parsoid
1876 <!--c1--><ul>
1877 <li>a
1878 </li>
1879 <!--c2--><!--c3--><!--c4-->
1880 <li>b
1881 </li>
1882 </ul>
1883 !! end
1884
1885 ## Make sure ">" gets escaped in comments to avoid XSS
1886 !! test
1887 IE conditional comments
1888 !! wikitext
1889 <!--[if lt IE 9]>
1890 <script>alert('hi');</script>
1891 <![endif]-->
1892 !! html/parsoid
1893 <!--[if lt IE 9]&#x3E;
1894 <script&#x3E;alert('hi');</script&#x3E;
1895 <![endif]-->
1896 !! end
1897
1898 ###
1899 ### paragraph wrapping tests
1900 ###
1901
1902 !! test
1903 No block tags
1904 !! wikitext
1905 a
1906
1907 b
1908 !! html
1909 <p>a
1910 </p><p>b
1911 </p>
1912 !! end
1913
1914 !! test
1915 Block tag on one line (<div>)
1916 !! wikitext
1917 a <div>foo</div>
1918
1919 b
1920 !! html
1921 a <div>foo</div>
1922 <p>b
1923 </p>
1924 !! html+tidy
1925 <p>a </p><div>foo</div>
1926 <p>b
1927 </p>
1928 !! end
1929
1930 # Remex wraps empty tag runs with p-tags.
1931 # Parsoid strips them out during p-wrapping.
1932 !! test
1933 No p-wrappable content
1934 !! wikitext
1935 <span><div>x</div></span>
1936 <span><s><div>x</div></s></span>
1937 <small><em></em></small><span><s><div>x</div></s></span>
1938 !! html/php+tidy
1939 <span><div>x</div></span>
1940 <span><s><div>x</div></s></span>
1941 <p><small><em></em></small></p><span><s><div>x</div></s></span>
1942 !! html/parsoid
1943 <span><div>x</div></span>
1944 <span><s><div>x</div></s></span>
1945 <small><em></em></small><span><s><div>x</div></s></span>
1946 !! end
1947
1948 # T177612: Parsoid-only test
1949 !! test
1950 Transclusion meta tags shouldn't trip Parsoid's useless p-wrapper stripping code
1951 !! wikitext
1952 {{echo|<span><div>x</div></span>}}
1953 x
1954 !! html/parsoid
1955 <span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;span>&lt;div>x&lt;/div>&lt;/span>"}},"i":0}}]}'><div>x</div></span>
1956 <p>x</p>
1957 !! end
1958
1959 !! test
1960 Block tag on one line (<blockquote>)
1961 !! wikitext
1962 a <blockquote>foo</blockquote>
1963
1964 b
1965 !! html
1966 a <blockquote>foo</blockquote>
1967 <p>b
1968 </p>
1969 !! html+tidy
1970 <p>a </p><blockquote><p>foo</p></blockquote>
1971 <p>b
1972 </p>
1973 !! end
1974
1975 !! test
1976 Block tag on both lines (<div>)
1977 !! wikitext
1978 a <div>foo</div>
1979
1980 b <div>foo</div>
1981 !! html
1982 a <div>foo</div>
1983 b <div>foo</div>
1984
1985 !! html+tidy
1986 <p>a </p><div>foo</div><p>
1987 b </p><div>foo</div>
1988 !! end
1989
1990 !! test
1991 Block tag on both lines (<blockquote>)
1992 !! wikitext
1993 a <blockquote>foo</blockquote>
1994
1995 b <blockquote>foo</blockquote>
1996 !! html
1997 a <blockquote>foo</blockquote>
1998 b <blockquote>foo</blockquote>
1999
2000 !! html+tidy
2001 <p>a </p><blockquote><p>foo</p></blockquote><p>
2002 b </p><blockquote><p>foo</p></blockquote>
2003 !! end
2004
2005 !! test
2006 Multiple lines without block tags
2007 !! wikitext
2008 <div>foo</div> a
2009 b
2010 c
2011 d<!--foo--> e
2012 x <div>foo</div> z
2013 !! html
2014 <div>foo</div> a
2015 <p>b
2016 c
2017 d e
2018 </p>
2019 x <div>foo</div> z
2020
2021 !! html+tidy
2022 <div>foo</div><p> a
2023 </p><p>b
2024 c
2025 d e
2026 </p><p>
2027 x </p><div>foo</div><p> z
2028 </p>
2029 !! end
2030
2031 # The difference between Parsoid & Remex here
2032 # is because of Parsoid's Tidy-emulation code
2033 # for p-wrapping. We'll start work to remove this
2034 # emulation code in Parsoid sooner than later.
2035 # Remex wraps empty tag runs with p-tags.
2036 # Parsoid strips them out in a separate pass.
2037 !! test
2038 Empty lines between lines with block tags
2039 !! wikitext
2040 <div></div>
2041
2042
2043 <div></div>a
2044
2045 b
2046 <div>a</div>b
2047
2048 <div>b</div>d
2049
2050
2051 <div>e</div>
2052 !! html
2053 <div></div>
2054 <p><br />
2055 </p>
2056 <div></div>a
2057 <p>b
2058 </p>
2059 <div>a</div>b
2060 <div>b</div>d
2061 <p><br />
2062 </p>
2063 <div>e</div>
2064
2065 !! html+tidy
2066 <div></div>
2067 <p><br />
2068 </p>
2069 <div></div><p>a
2070 </p><p>b
2071 </p>
2072 <div>a</div><p>b
2073 </p><div>b</div><p>d
2074 </p><p><br />
2075 </p>
2076 <div>e</div>
2077 !! html/parsoid
2078 <div data-parsoid='{"stx":"html"}'></div>
2079
2080 <p><br /></p>
2081 <div data-parsoid='{"stx":"html"}'></div><p>a</p>
2082
2083 <p>b</p>
2084 <div data-parsoid='{"stx":"html"}'>a</div><p>b</p>
2085
2086 <div data-parsoid='{"stx":"html"}'>b</div><p>d</p>
2087
2088 <p><br /></p>
2089 <div data-parsoid='{"stx":"html"}'>e</div>
2090 !! end
2091
2092 !! test
2093 Unclosed HTML p-tags should be handled properly
2094 !! wikitext
2095 <div><p>foo</div>
2096 a
2097
2098 b
2099 !! html/php+tidy
2100 <div><p>foo</p></div>
2101 <p>a
2102 </p><p>b
2103 </p>
2104 !! html/parsoid
2105 <div data-parsoid='{"stx":"html"}'><p data-parsoid='{"stx":"html", "autoInsertedEnd":true}'>foo</p></div>
2106 <p>a</p>
2107 <p>b</p>
2108 !! end
2109
2110 ## SSS FIXME: I can come up with other scenarios where this doesn't work because
2111 ## of eager output of buffered tokens in the p-wrapper. But, I'm going to ignore
2112 ## them for now.
2113 !! test
2114 1. P-wrapping should leave sol-transparent tags outside p-tags where possible
2115 !! options
2116 parsoid=wt2html
2117 !! wikitext
2118 a [[Category:A1]] [[Category:A2]]
2119 [[Category:A3]]
2120 [[Category:A4]]
2121 !! html/parsoid
2122 <p>a</p>
2123 <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"/>
2124 !! end
2125
2126 !! test
2127 2. P-wrapping should leave sol-transparent tags outside p-tags where possible
2128 !! options
2129 parsoid=wt2html
2130 !! wikitext
2131 [[Category:A1]]a
2132 !! html/parsoid
2133 <link rel="mw:PageProp/Category" href="./Category:A1"/><p>a</p>
2134 !! end
2135
2136 !! test
2137 No paragraph necessary for SOL transparent template
2138 !! wikitext
2139 <span><div>foo</div></span>
2140 [[Category:Foo]]
2141
2142 <span><div>foo</div></span>
2143 {{echo|[[Category:Foo]]}}
2144 !! html/php
2145 <span><div>foo</div></span>
2146 <span><div>foo</div></span>
2147
2148 !! html/parsoid
2149 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2150 <link rel="mw:PageProp/Category" href="./Category:Foo"/>
2151
2152 <span data-parsoid='{"stx":"html"}'><div data-parsoid='{"stx":"html"}'>foo</div></span>
2153 <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]]"}},"i":0}}]}'/>
2154 !! end
2155
2156 !! test
2157 Avoid expanding multiline sol transparent template ranges unnecessarily
2158 !! wikitext
2159 hi
2160
2161
2162 {{echo|<br/>
2163 }}
2164
2165 [[Category:Ho]]
2166 !! html/php
2167 <p>hi
2168 </p><p><br />
2169 <br />
2170 </p>
2171 !! html/parsoid
2172 <p>hi</p>
2173
2174 <p><br />
2175 <br about="#mwt1" typeof="mw:Transclusion" data-parsoid='{}' data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"&lt;br/>\n"}},"i":0}}]}'/><span about="#mwt1">
2176 </span></p>
2177
2178 <link rel="mw:PageProp/Category" href="./Category:Ho" />
2179 !! end
2180
2181 ###
2182 ### Preformatted text
2183 ###
2184
2185 !! test
2186 Preformatted text
2187 !! wikitext
2188 This is some
2189 Preformatted text
2190 With ''italic''
2191 And '''bold'''
2192 And a [[Main Page|link]]
2193 !! html
2194 <pre>This is some
2195 Preformatted text
2196 With <i>italic</i>
2197 And <b>bold</b>
2198 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
2199 </pre>
2200 !! end
2201
2202 !! test
2203 Tabs don't trigger preformatted text
2204 !! wikitext
2205 This is not
2206 preformatted text.
2207 This is preformatted text.
2208 So is this.
2209 !! html/php
2210 <p> This is not
2211 preformatted text.
2212 </p>
2213 <pre>This is preformatted text.
2214 So is this.
2215 </pre>
2216 !! html/parsoid
2217 <p> This is not
2218 preformatted text.</p>
2219 <pre>This is preformatted text.
2220 So is this.</pre>
2221 !! end
2222
2223 !! test
2224 Space before tab needs nowiki pre protection
2225 !! options
2226 parsoid=html2wt
2227 !! html/parsoid
2228 <p> a</p>
2229 !! wikitext
2230 <nowiki> </nowiki> a
2231 !! end
2232
2233 !! test
2234 Ident preformatting with inline content
2235 !! wikitext
2236 a
2237 ''b''
2238 !! html
2239 <pre>a
2240 <i>b</i>
2241 </pre>
2242 !! end
2243
2244 !! test
2245 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
2246 !! wikitext
2247 <pre><nowiki>
2248 <b>
2249 <cite>
2250 <em>
2251 </nowiki></pre>
2252 !! html
2253 <pre>
2254 &lt;b&gt;
2255 &lt;cite&gt;
2256 &lt;em&gt;
2257 </pre>
2258
2259 !! end
2260
2261 !! test
2262 Regression with preformatted in <center>
2263 !! wikitext
2264 <center>
2265 Blah
2266 </center>
2267 !! html
2268 <center>
2269 <pre>Blah
2270 </pre>
2271 </center>
2272
2273 !! end
2274
2275 !! test
2276 T54763: Preformatted in <blockquote>
2277 !! wikitext
2278 <blockquote>
2279 Blah
2280 {|
2281 |
2282 indented cell (no pre-wrapping!)
2283 |}
2284 </blockquote>
2285 !! html
2286 <blockquote>
2287 <p> Blah
2288 </p>
2289 <table>
2290 <tr>
2291 <td>
2292 <p> indented cell (no pre-wrapping!)
2293 </p>
2294 </td></tr></table>
2295 </blockquote>
2296
2297 !! end
2298
2299 !! test
2300 T53086: Double newlines in blockquotes should be turned into paragraphs
2301 !! wikitext
2302 <blockquote>
2303 Foo
2304
2305 Bar
2306 </blockquote>
2307 !! html
2308 <blockquote>
2309 <p>Foo
2310 </p><p>Bar
2311 </p>
2312 </blockquote>
2313
2314 !! end
2315
2316 !! test
2317 T17491: <ins>/<del> in blockquote
2318 !! wikitext
2319 <blockquote>
2320 Foo <del>bar</del> <ins>baz</ins> quux
2321 </blockquote>
2322 !! html
2323 <blockquote>
2324 <p>Foo <del>bar</del> <ins>baz</ins> quux
2325 </p>
2326 </blockquote>
2327
2328 !! end
2329
2330 !! test
2331 T17491: <ins>/<del> in blockquote (2)
2332 !! wikitext
2333 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2334 </blockquote>
2335 !! html
2336 <blockquote>Foo <del>bar</del> <ins>baz</ins> quux
2337 </blockquote>
2338
2339 !! html+tidy
2340 <blockquote><p>Foo </p><del>bar</del> <ins>baz</ins><p> quux
2341 </p></blockquote>
2342 !! end
2343
2344 !! test
2345 <pre> with attributes (T5202)
2346 !! wikitext
2347 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2348 !! html
2349 <pre style="background: blue; color:white">Bluescreen of WikiDeath</pre>
2350
2351 !! end
2352
2353 !! test
2354 <pre> with width attribute (T5202)
2355 !! wikitext
2356 <pre width="8">Narrow screen goodies</pre>
2357 !! html
2358 <pre width="8">Narrow screen goodies</pre>
2359
2360 !! end
2361
2362 !! test
2363 <pre> with forbidden attribute (T5202)
2364 !! wikitext
2365 <pre width="8" onmouseover="alert(document.cookie)">Narrow screen goodies</pre>
2366 !! html
2367 <pre width="8">Narrow screen goodies</pre>
2368
2369 !! end
2370
2371 !! test
2372 Entities inside <pre>
2373 !! wikitext
2374 <pre>&lt;</pre>
2375 !! html
2376 <pre>&lt;</pre>
2377
2378 !! end
2379
2380 !! test
2381 <pre> with forbidden attribute values (T5202)
2382 !! wikitext
2383 <pre width="8" style="border-width: expression(alert(document.cookie))">Narrow screen goodies</pre>
2384 !! html
2385 <pre width="8" style="/* insecure input */">Narrow screen goodies</pre>
2386
2387 !! end
2388
2389 !! test
2390 <nowiki> inside <pre> (T15238)
2391 !! wikitext
2392 <pre>
2393 <nowiki>
2394 </pre>
2395 <pre>
2396 <nowiki></nowiki>
2397 </pre>
2398 <pre><nowiki><nowiki></nowiki>Foo<nowiki></nowiki></nowiki></pre>
2399 !! html
2400 <pre>
2401 &lt;nowiki&gt;
2402 </pre>
2403 <pre>
2404
2405 </pre>
2406 <pre>&lt;nowiki&gt;Foo&lt;/nowiki&gt;</pre>
2407
2408 !! end
2409
2410 !! test
2411 <nowiki> inside of #tag:pre
2412 !! wikitext
2413 {{#tag:pre|Foo <nowiki>&rarr;bar</nowiki>}}
2414 !! html/php
2415 <pre>Foo &#8594;bar</pre>
2416
2417 !! html/parsoid
2418 <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>
2419 !! end
2420
2421 ## Don't expect this to rt, Parsoid drops the unmatched closing pre tags that
2422 ## aren't enclosed in nowikis.
2423 !! test
2424 <nowiki> and <pre> preference (first one wins)
2425 !! options
2426 parsoid=wt2html
2427 !! wikitext
2428 <pre>
2429 <nowiki>
2430 </pre>
2431 </nowiki>
2432 </pre>
2433
2434 <nowiki>
2435 <pre>
2436 <nowiki>
2437 </pre>
2438 </nowiki>
2439 </pre>
2440
2441 !! html/php
2442 <pre>
2443 &lt;nowiki&gt;
2444 </pre>
2445 <p>&lt;/nowiki&gt;
2446 &lt;/pre&gt;
2447 </p><p>
2448 &lt;pre&gt;
2449 &lt;nowiki&gt;
2450 &lt;/pre&gt;
2451
2452 &lt;/pre&gt;
2453 </p>
2454 !! html/parsoid
2455 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n&lt;nowiki>\n"}}'>&lt;nowiki>
2456 </pre>
2457 <p>&lt;/nowiki></p>
2458
2459
2460 <p><span typeof="mw:Nowiki">
2461 &lt;pre>
2462 &lt;nowiki>
2463 &lt;/pre>
2464 </span></p>
2465 !! end
2466
2467 !! test
2468 </pre> inside nowiki
2469 !! wikitext
2470 <nowiki></pre></nowiki>
2471 !! html
2472 <p>&lt;/pre&gt;
2473 </p>
2474 !! end
2475
2476 !! test
2477 Empty pre; pre inside other HTML tags (T56946)
2478 !! wikitext
2479 a
2480
2481 <div><pre>
2482 foo
2483 </pre></div>
2484 <pre></pre>
2485 !! html/php+tidy
2486 <p>a
2487 </p>
2488 <div><pre>foo
2489 </pre></div>
2490 <pre></pre>
2491 !! html/parsoid
2492 <p>a</p>
2493
2494 <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
2495 </pre></div>
2496 <pre typeof="mw:Extension/pre" about="#mwt4" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":""}}'></pre>
2497 !! end
2498
2499 !! test
2500 HTML pre followed by indent-pre
2501 !! wikitext
2502 <pre>foo</pre>
2503 bar
2504 !! html
2505 <pre>foo</pre>
2506 <pre>bar
2507 </pre>
2508 !! end
2509
2510 !! test
2511 Block tag pre
2512 !! wikitext
2513 <p><pre>foo</pre></p>
2514 !! html/php+tidy
2515 <p class="mw-empty-elt"></p><pre>foo</pre><p class="mw-empty-elt"></p>
2516 !! html/parsoid
2517 <p class='mw-empty-elt' data-parsoid='{"stx":"html","autoInsertedEnd":true}'></p><pre typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre><p class='mw-empty-elt' data-parsoid='{"autoInsertedStart":true,"stx":"html"}'></p>
2518 !! end
2519
2520 !!test
2521 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
2522 !! wikitext
2523 {{echo|}}
2524 !! html
2525
2526 !!end
2527
2528 !!test
2529 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
2530 !! wikitext
2531 {{echo|
2532 foo}}
2533 !! html
2534 <p>foo
2535 </p>
2536 !!end
2537
2538 !! test
2539 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
2540 !! wikitext
2541 {{echo|a
2542 b}}
2543 !! html
2544 <pre>a
2545 </pre>
2546 <p>b
2547 </p>
2548 !!end
2549
2550 !! test
2551 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
2552 !! wikitext
2553 {{echo|a
2554 b
2555 c
2556 d
2557 e
2558 }}
2559 !! html
2560 <pre>a
2561 </pre>
2562 <p>b
2563 c
2564 </p>
2565 <pre>d
2566 </pre>
2567 <p>e
2568 </p>
2569 !!end
2570
2571 !!test
2572 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
2573 !! wikitext
2574 {{echo| foo}}
2575
2576 {{echo| foo}}{{echo| bar}}
2577
2578 {{echo| foo}}
2579 {{echo| bar}}
2580
2581 {{echo|<!--cmt--> foo}}
2582
2583 <!--cmt-->{{echo| foo}}
2584
2585 {{echo|{{echo| }}bar}}
2586 !! html
2587 <pre>foo
2588 </pre>
2589 <pre>foo bar
2590 </pre>
2591 <pre>foo
2592 bar
2593 </pre>
2594 <pre>foo
2595 </pre>
2596 <pre>foo
2597 </pre>
2598 <pre>bar
2599 </pre>
2600 !!end
2601
2602 !! test
2603 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
2604 !! wikitext
2605 {{echo| }}a
2606
2607 {{echo|
2608 }}a
2609
2610 {{echo|
2611 b}}
2612
2613 {{echo|a
2614 }}b
2615
2616 {{echo|a
2617 }} b
2618 !! html
2619 <pre>a
2620 </pre>
2621 <p><br />
2622 </p>
2623 <pre>a
2624 </pre>
2625 <p><br />
2626 </p>
2627 <pre>b
2628 </pre>
2629 <p>a
2630 </p>
2631 <pre>b
2632 </pre>
2633 <p>a
2634 </p>
2635 <pre>b
2636 </pre>
2637 !!end
2638
2639 ## Hmm, should Parsoid rt this?
2640 !! test
2641 Pres with newline attributes
2642 !! options
2643 parsoid=wt2html,html2html
2644 !! wikitext
2645 <pre class="one
2646 two">hi</pre>
2647 !! html/php
2648 <pre class="one two">hi</pre>
2649
2650 !! html/parsoid
2651 <pre typeof="mw:Extension/pre" about="#mwt2" class="one two" data-mw='{"name":"pre","attrs":{"class":"one two"},"body":{"extsrc":"hi"}}'>hi</pre>
2652 !! end
2653
2654 !! test
2655 Things that look like <pre> tags aren't treated as such
2656 !! wikitext
2657 Barack Obama <President> of the United States
2658 <President></President>
2659 !! html
2660 <p>Barack Obama &lt;President&gt; of the United States
2661 &lt;President&gt;&lt;/President&gt;
2662 </p>
2663 !! end
2664
2665 !! test
2666 Handle broken pre-like tags (T66025)
2667 !! options
2668 parsoid=wt2html
2669 !! wikitext
2670 {{echo|<pre <pre>x</pre>}}
2671
2672 <table><pre </table>
2673 !! html/php
2674 <pre>x</pre>
2675 <table>&lt;pre </table>
2676
2677 !! html/php+tidy
2678 <pre>x</pre>
2679 &lt;pre <table></table>
2680 !! html/parsoid
2681 <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>
2682
2683
2684 <p>&lt;pre </p>
2685
2686 <table></table>
2687 !! end
2688
2689 !! test
2690 Parsoid: handle pre with space after attribute
2691 !! options
2692 parsoid=wt2html
2693 !! wikitext
2694 <pre style="width:50%;" >{{echo|foo}}</pre>
2695 !! html/php
2696 <pre style="width:50%;">{{echo|foo}}</pre>
2697
2698 !! html/parsoid
2699 <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>
2700 !! end
2701
2702 # TODO / maybe: fix wt2wt for this
2703 !! test
2704 Parsoid: Don't paragraph-wrap fosterable content
2705 !! options
2706 parsoid=wt2html
2707 !! wikitext
2708 {|
2709 <td></td>
2710 <td></td>
2711
2712
2713
2714 |}
2715 !! html
2716 <table>
2717
2718 <tbody>
2719 <tr>
2720 <td></td>
2721
2722 <td></td></tr>
2723
2724
2725
2726 </tbody></table>
2727 !! end
2728
2729 !! test
2730 Self-closed pre
2731 !! wikitext
2732 <pre />
2733 !! html/php
2734 <pre></pre>
2735
2736 !! html/parsoid
2737 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":null}'></pre>
2738 !! end
2739
2740 !! test
2741 Parsoid: Don't paragraph-wrap fosterable content even if table syntax is unbalanced
2742 !! options
2743 parsoid=wt2html
2744 !! wikitext
2745 {|
2746 <td>
2747 <td>
2748 </td>
2749
2750
2751
2752 |}
2753 !! html
2754 <table>
2755
2756 <tbody>
2757 <tr>
2758 <td></td>
2759
2760 <td>
2761 </td></tr>
2762
2763
2764
2765 </tbody></table>
2766 !! end
2767
2768
2769 #--------------------------------------------------------------------
2770 # Transclusion parameter whitespace stripping tests
2771 # Behavior is different for positional and named parameters
2772 #--------------------------------------------------------------------
2773 !! test
2774 Templates: Strip leading and trailing whitespace from named-param values
2775 !! wikitext
2776 {{echo|1= a }}
2777
2778 {{echo|1= {{echo|b}} }}
2779
2780 {{echo| 1 =
2781 c }}
2782
2783 {{echo| 1 =
2784 * d
2785 }}
2786 !! html
2787 <p>a
2788 </p><p>b
2789 </p><p>c
2790 </p>
2791 <ul><li>d</li></ul>
2792
2793 !! end
2794
2795 !! test
2796 Templates: Don't strip whitespace from positional-param values
2797 !! wikitext
2798 {{echo|a }}
2799
2800 {{echo|{{echo|b}} }}
2801
2802 {{echo| c
2803 }}
2804
2805 {{echo| {{echo|d}}
2806 }}
2807
2808 {{echo|
2809 e}}
2810
2811 {{echo|
2812 *f}}
2813
2814 {{echo|
2815 }}g
2816 !! html
2817 <p>a
2818 </p><p>b
2819 </p>
2820 <pre>c
2821 </pre>
2822 <p><br />
2823 </p>
2824 <pre>d
2825 </pre>
2826 <p><br />
2827 </p>
2828 <pre>e
2829 </pre>
2830 <p><br />
2831 </p>
2832 <ul><li>f</li></ul>
2833 <p><br />
2834 </p>
2835 <pre>g
2836 </pre>
2837 !! end
2838
2839 !! test
2840 Templates: Don't recognize targets split by newlines
2841 !! options
2842 parsoid=wt2html
2843 !! wikitext
2844 {{ech
2845 o|foo}}
2846 !! html/php
2847 <p>{{ech
2848 o|foo}}
2849 </p>
2850 !! html/parsoid
2851 <p>{{ech
2852 o|foo}}</p>
2853 !! end
2854
2855 !! test
2856 Templates: Recognize targets when newlines and comments don't split the target
2857 !! options
2858 parsoid=wt2html
2859 !! wikitext
2860 {{
2861 <!--X--> ech<!--X-->o<!--X-->
2862 <!--X--> <!--X-->
2863
2864 |foo}}
2865 !! html/php
2866 <p>foo
2867 </p>
2868 !! html/parsoid
2869 <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>
2870 !! end
2871
2872 !! test
2873 Templates: Handle empty comment-and-ws-only lines correctly
2874 !! wikitext
2875 {{echo|foo
2876 <!--should be ignored-->
2877 <!--should be ignored as well-->
2878 bar}}
2879 !! html/php
2880 <p>foo
2881 bar
2882 </p>
2883 !! html/parsoid
2884 <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>
2885 !! end
2886
2887 !! test
2888 Templates: Handle comments in the target
2889 !! wikitext
2890 {{echo
2891 <!-- should be ignored -->
2892 |foo}}
2893
2894 {{echo
2895 <!-- should be ignored and spaces on next line should not trip us up (T147742) -->
2896 |foo}}
2897
2898 {{echo<!-- should be ignored -->
2899 |foo}}
2900
2901 {{echo<!-- should be ignored -->|foo}}
2902
2903 {{<!-- should be ignored -->echo|foo}}
2904 !! html/php
2905 <p>foo
2906 </p><p>foo
2907 </p><p>foo
2908 </p><p>foo
2909 </p><p>foo
2910 </p>
2911 !! html/parsoid
2912 <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>
2913
2914 <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>
2915
2916 <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>
2917
2918 <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>
2919
2920 <p typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"foo"}},"i":0}}]}'>foo</p>
2921 !! end
2922
2923 !! test
2924 Templates: Handle comments in parameter names (T69657)
2925 !! wikitext
2926 {{echo|1
2927 <!-- should be ignored -->
2928 =foo}}
2929
2930 {{echo|
2931 <!-- should be ignored -->
2932 1 = foo}}
2933
2934 {{echo|1<!-- should be ignored -->=foo}}
2935
2936 {{echo|<!-- should be ignored -->1=foo}}
2937 !! html/php
2938 <p>foo
2939 </p><p>foo
2940 </p><p>foo
2941 </p><p>foo
2942 </p>
2943 !! html/parsoid
2944 <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>
2945
2946 <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>
2947
2948 <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>
2949
2950 <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>
2951 !! end
2952
2953 !! test
2954 Templates: Other wikitext in parameter names (T69657)
2955 !! wikitext
2956 {{echo|''1''=foo}}
2957 !! html/php
2958 <p>{{{1}}}
2959 </p>
2960 !! html/parsoid
2961 <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>
2962 !! end
2963
2964 !! test
2965 Templates: With colons
2966 !! wikitext
2967 {{With: Colon}}
2968 !! html/php
2969 <p>Template with colon
2970 </p>
2971 !! html/parsoid
2972 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"With: Colon","href":"./Template:With:_Colon"},"params":{},"i":0}}]}'>Template with colon</p>
2973 !! end
2974
2975 #--------------------------------------------------------------------
2976 # Transclusion parameter escaping tests
2977 #--------------------------------------------------------------------
2978
2979 !! test
2980 Templates: Parsoid parameter escaping test 1
2981 !! wikitext
2982 {{echo|[foo]|{{echo|[bar]}}}}
2983 !! html/php+tidy
2984 <p>[foo]
2985 </p>
2986 !! html/parsoid
2987 <p about="#mwt1" typeof="mw:Transclusion"
2988 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"1":{"wt":"[foo]"},"2":{"wt":"{{echo|[bar]}}"}},"i":0}}]}'>[foo]</p>
2989 !! end
2990
2991 !! test
2992 Parsoid: Pipes in external links in template parameter
2993 !! wikitext
2994 {{echo|[{{echo|http://example.com}} link]}}
2995 !! html/php+tidy
2996 <p><a rel="nofollow" class="external text" href="http://example.com">link</a>
2997 </p>
2998 !! html/parsoid
2999 <p><a rel="mw:ExtLink" class="external text" 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>
3000 !! end
3001
3002 !! test
3003 Parsoid: pipe in transclusion parameter
3004 !! wikitext
3005 {{echo|http://foo.com/a&#124;b}}
3006 !! html/php+tidy
3007 <p><a rel="nofollow" class="external free" href="http://foo.com/a%7Cb">http://foo.com/a%7Cb</a>
3008 </p>
3009 !! html/parsoid
3010 <p><a rel="mw:ExtLink" class="external free" href="http://foo.com/a%7Cb" about="#mwt1" typeof="mw:Transclusion" 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>
3011 !! end
3012
3013 !! test
3014 Parsoid: Pipe in external link target and content in template parameter
3015 !! options
3016 parsoid=html2wt,wt2wt
3017 !! wikitext
3018 {{echo|[http://foo.com/a&#124;b a&#124;b]}}
3019 !! html/php+tidy
3020 <p><a rel="nofollow" class="external text" href="http://foo.com/a%7Cb">a&#124;b</a>
3021 </p>
3022 !! html/parsoid
3023 <p><a rel="mw:ExtLink" href="http://foo.com/a|b" about="#mwt1"
3024 typeof="mw:Transclusion"
3025 data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},
3026 "params":{"1":{"wt":"[http://foo.com/a|b a|b]"}},"i":0}}]}'>a|b</a></p>
3027 !! end
3028
3029 !! test
3030 Parsoid: Pipe in template with nested template in external link target in template parameter (seriously)
3031 !! options
3032 parsoid
3033 !! wikitext
3034 {{echo|[{{fullurl:{{FULLPAGENAME}}|action=edit}} bar]}}
3035 !! html
3036 <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>
3037 !! end
3038
3039 !! test
3040 Templates: Don't escape already nowiki-escaped text in template parameters
3041 !! options
3042 parsoid=html2wt,wt2wt
3043 !! wikitext
3044 {{echo|foo<nowiki>|</nowiki>bar}}
3045 {{echo|<nowiki>&lt;div&gt;</nowiki>}}
3046 {{echo|<nowiki></nowiki>}}
3047 !! html/php+tidy
3048 <p>foo|bar
3049 &lt;div&gt;
3050
3051 </p>
3052 !! html/parsoid
3053 <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>
3054 <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>
3055 <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>
3056 </p>
3057 !! end
3058
3059 ## T54824
3060 !! test
3061 Templates: '=' char in nested transclusions should not trigger nowiki escapes or conversion to named param
3062 !! options
3063 parsoid=html2wt,wt2wt
3064 !! wikitext
3065 {{echo|{{echo|1=bar}}}}
3066 !! html/php+tidy
3067 <p>bar
3068 </p>
3069 !! html/parsoid
3070 <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>
3071 !! end
3072
3073 ## T58733
3074 !! test
3075 Templates parameters with special tokenizing behavior dont get modified because of arg escaping
3076 !! wikitext
3077 {{echo|a : b}}
3078 !! html/php+tidy
3079 <p>a&#160;: b
3080 </p>
3081 !! html/parsoid
3082 <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>
3083 !! end
3084
3085 ## T73412
3086 !! test
3087 Templates: Preserve blank parameter names
3088 !! wikitext
3089 {{echo|=foo}}
3090 !! html/php+tidy
3091 <p>{{{1}}}
3092 </p>
3093 !! html/parsoid
3094 <p about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"echo","href":"./Template:Echo"},"params":{"":{"wt":"foo"}},"i":0}}]}'>{{{1}}}</p>
3095 !! end
3096
3097 !! test
3098 Templates: Preserve blank parameter names in other positions
3099 !! wikitext
3100 {{blank_param|bar|=foo}}
3101 !! html/php+tidy
3102 <p>bar
3103 foo
3104 </p>
3105 !! html/parsoid
3106 <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
3107 foo</p>
3108 !! end
3109
3110 ###
3111 ### Parsoid-centric tests for testing RT edge cases for pre
3112 ###
3113
3114 !!test
3115 1a. Indent-Pre and Comments
3116 !! wikitext
3117 a
3118 <!--a-->
3119 c
3120 !! html
3121 <pre>a
3122 </pre>
3123 <p>c
3124 </p>
3125 !!end
3126
3127 !!test
3128 1b. Indent-Pre and Comments
3129 !! wikitext
3130 a
3131 <!--a-->
3132 c
3133 !! html
3134 <pre>a
3135 </pre>
3136 <p>c
3137 </p>
3138 !!end
3139
3140 !!test
3141 1c. Indent-Pre and Comments
3142 !! wikitext
3143 <!--a--> a
3144
3145 <!--a--> a
3146 !! html
3147 <pre> a
3148 </pre>
3149 <pre> a
3150 </pre>
3151 !!end
3152
3153 !!test
3154 1d. Indent-Pre and Comments
3155 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
3156 !! wikitext
3157 <!--a--> a
3158
3159 <!--b-->b
3160 !! html
3161 <pre>a
3162 </pre>
3163 <pre>b
3164 </pre>
3165 !!end
3166
3167 !!test
3168 2a. Indent-Pre and tables
3169 !! wikitext
3170 {|
3171 |-
3172 !h1!!h2
3173 |foo||bar
3174 |}
3175 !! html
3176 <table>
3177
3178 <tr>
3179 <th>h1</th>
3180 <th>h2
3181 </th>
3182 <td>foo</td>
3183 <td>bar
3184 </td></tr></table>
3185
3186 !!end
3187
3188 !!test
3189 2b. Indent-Pre and tables
3190 !! wikitext
3191 {|
3192 |-
3193 |foo
3194 |}
3195 !! html
3196 <table>
3197
3198 <tr>
3199 <td>foo
3200 </td></tr></table>
3201
3202 !!end
3203
3204 !!test
3205 2c. Indent-Pre and tables (T44252)
3206 !! wikitext
3207 {|
3208 |+foo
3209 ! |bar
3210 |}
3211 !! html
3212 <table>
3213 <caption>foo
3214 </caption>
3215 <tr>
3216 <th>bar
3217 </th></tr></table>
3218
3219 !!end
3220
3221 !!test
3222 2d. Indent-Pre and tables
3223 !! wikitext
3224 a
3225 {|
3226 |b
3227 |}
3228 !! html/php
3229 <pre>a
3230 </pre>
3231 <table>
3232 <tr>
3233 <td>b
3234 </td></tr></table>
3235
3236 !! html/parsoid
3237 <pre>a</pre>
3238 <table>
3239 <tbody><tr><td> b</td></tr>
3240 </tbody></table>
3241 !!end
3242
3243 !!test
3244 2e. Indent-Pre and table-line syntax
3245 !! wikitext
3246 a
3247 | b
3248 | c
3249 !! html/php
3250 <pre>a
3251 | b
3252 | c
3253 </pre>
3254 !!end
3255
3256 !!test
3257 2f. Indent-pre started by table-line syntax
3258 !! wikitext
3259 a
3260 | b
3261 | c
3262 !! html/php
3263 <p>a
3264 </p>
3265 <pre>| b
3266 | c
3267 </pre>
3268 !! html/parsoid
3269 <p>a</p>
3270 <pre>
3271 | b
3272 | c</pre>
3273 !!end
3274
3275 !! test
3276 2g. Indented table markup mixed with indented pre content (proposed in T8200)
3277 !! wikitext
3278 <table>
3279 <tr>
3280 <td>
3281 Text that should be rendered preformatted
3282 </td>
3283 </tr>
3284 </table>
3285 !! html
3286 <table>
3287 <tr>
3288 <td>
3289 <pre>Text that should be rendered preformatted
3290 </pre>
3291 </td>
3292 </tr>
3293 </table>
3294
3295 !! end
3296
3297 !!test
3298 3a. Indent-Pre and block tags (single-line html)
3299 !! wikitext
3300 a <p> foo </p>
3301 b <div> foo </div>
3302 c <blockquote> foo </blockquote>
3303 <span> foo </span>
3304 !! html
3305 a <p> foo </p>
3306 b <div> foo </div>
3307 c <blockquote> foo </blockquote>
3308 <pre><span> foo </span>
3309 </pre>
3310 !! html/parsoid
3311 <p>a </p><p data-parsoid='{"stx":"html"}'> foo </p>
3312 <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
3313 <p>c </p><blockquote data-parsoid='{"stx":"html"}'> foo </blockquote>
3314 <pre><span> foo </span>
3315 </pre>
3316 !! html/php+tidy
3317 <p> a </p><p> foo </p><p>
3318 b </p><div> foo </div><p>
3319 c </p><blockquote><p> foo </p></blockquote>
3320 <pre><span> foo </span>
3321 </pre>
3322 !! end
3323
3324 !!test
3325 3b. Indent-Pre and block tags (multi-line html)
3326 !! wikitext
3327 a <span>foo</span>
3328 b <div> foo </div>
3329 !! html
3330 <pre>a <span>foo</span>
3331 </pre>
3332 b <div> foo </div>
3333
3334 !! html/parsoid
3335 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
3336 b <div data-parsoid='{"stx":"html"}'> foo </div>
3337 !! html/php+tidy
3338 <pre>a <span>foo</span>
3339 </pre><p>
3340 b </p><div> foo </div>
3341 !!end
3342
3343 !!test
3344 3c. Indent-Pre and block tags (pre-content on separate line)
3345 !! wikitext
3346 <p>
3347 foo
3348 </p>
3349
3350 <div>
3351 foo
3352 </div>
3353
3354 <center>
3355 foo
3356 </center>
3357
3358 <blockquote>
3359 foo
3360 </blockquote>
3361
3362 <blockquote>
3363 <pre>
3364 foo
3365 </pre>
3366 </blockquote>
3367
3368 <table><tr><td>
3369 foo
3370 </td></tr></table>
3371
3372 <ul><li>
3373 foo
3374 </li></ul>
3375
3376 !! html
3377 <p>
3378 foo
3379 </p>
3380 <div>
3381 <pre>foo
3382 </pre>
3383 </div>
3384 <center>
3385 <pre>foo
3386 </pre>
3387 </center>
3388 <blockquote>
3389 <p> foo
3390 </p>
3391 </blockquote>
3392 <blockquote>
3393 <pre>
3394 foo
3395 </pre>
3396 </blockquote>
3397 <table><tr><td>
3398 <pre>foo
3399 </pre>
3400 </td></tr></table>
3401 <ul><li>
3402 foo
3403 </li></ul>
3404
3405 !!end
3406
3407 !! test
3408 4. Indent-Pre and extension tags
3409 !! wikitext
3410 a <tag />
3411 !! html/php
3412 a <pre>
3413 NULL
3414 array (
3415 )
3416 </pre>
3417
3418 !! html/parsoid
3419 a <pre typeof="mw:Extension/tag" about="#mwt2" data-parsoid='{}' data-mw='{"name":"tag","attrs":{},"body":null}'></pre>
3420 !! end
3421
3422 !! test
3423 5. Indent-Pre and html pre
3424 !! wikitext
3425 <pre class="123">hi</pre>
3426 !! html/php
3427 <pre class="123">hi</pre>
3428
3429 !! html/parsoid
3430 <pre typeof="mw:Extension/pre" about="#mwt2" class="123" data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
3431 !! end
3432
3433 !!test
3434 Render paragraphs when indent-pre is suppressed in blocklevels
3435 !! wikitext
3436 <blockquote>
3437 foo
3438
3439 bar
3440 </blockquote>
3441 !! html
3442 <blockquote>
3443 <p> foo
3444 </p><p> bar
3445 </p>
3446 </blockquote>
3447
3448 !!end
3449
3450 !!test
3451 4. Multiple spaces at start-of-line
3452 !! wikitext
3453 <p> foo </p>
3454 foo
3455 {|
3456 |foo
3457 |}
3458 !! html
3459 <p> foo </p>
3460 <pre> foo
3461 </pre>
3462 <table>
3463 <tr>
3464 <td>foo
3465 </td></tr></table>
3466
3467 !!end
3468
3469 ## NOTE: the leading white-space chars on empty line are significant
3470 !! test
3471 5a. White-space in indent-pre
3472 !! wikitext
3473 a<br />
3474
3475 b
3476 !! html
3477 <pre>a<br />
3478
3479 b
3480 </pre>
3481 !! end
3482
3483 ## NOTE: the leading white-space chars on empty line are significant
3484 !! test
3485 5b. White-space in indent-pre
3486 !! wikitext
3487 a
3488
3489 b
3490
3491
3492 c
3493 !! html
3494 <pre>a
3495
3496 b
3497
3498
3499 c
3500 </pre>
3501 !! end
3502
3503 !! test
3504 5c. White-space in indent-pre
3505 !! wikitext
3506 ''a''
3507 ''b''
3508 ''c''
3509 !! html
3510 <pre><i>a</i>
3511 <i>b</i>
3512 <i>c</i>
3513 </pre>
3514 !! end
3515
3516 !! test
3517 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
3518 !! wikitext
3519 a
3520
3521 <!-- continue -->
3522 b
3523
3524 c
3525
3526 d
3527 !! html
3528 <pre>a
3529
3530 b
3531 </pre>
3532 <pre>c
3533
3534 </pre>
3535 <p>d
3536 </p>
3537 !! end
3538
3539 !! test
3540 7a. Indent-pre and category links
3541 !! options
3542 parsoid=wt2html,wt2wt
3543 !! wikitext
3544 [[Category:foo]] <!-- No pre-wrapping -->
3545 {{echo| [[Category:foo]]}} <!-- No pre-wrapping -->
3546 !! html/php+tidy
3547 !! html/parsoid
3548 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
3549 <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 -->
3550 !! end
3551
3552 ## We used to, but no longer wt2wt this test since the default serializer
3553 ## will normalize all categories to serialize on their own line.
3554 ## This wikitext usage is going to be fairly uncommon in production and
3555 ## selser will take care of preserving formatting in those scenarios.
3556 !! test
3557 7b. Indent-pre and category links
3558 !! options
3559 parsoid=wt2html
3560 !! wikitext
3561 [[Category:foo]] a
3562 [[Category:foo]] {{echo|b}}
3563 !! html/parsoid
3564 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
3565 <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>
3566 !! end
3567
3568 !! test
3569 Indent-Pre: Newlines in comments shouldn't affect sol state
3570 !! wikitext
3571 a <!--
3572 foo
3573 --> b
3574 !! html/php+tidy
3575 <p>a b
3576 </p>
3577 !! html/parsoid
3578 <p>a <!--
3579 foo
3580 --> b</p>
3581 !! end
3582
3583 ###
3584 ### HTML-pre (some to spec PHP parser behavior and some Parsoid-RT-centric)
3585 ###
3586
3587 !!test
3588 HTML-pre: 1. embedded newlines
3589 !! wikitext
3590 <pre>foo</pre>
3591
3592 <pre>
3593 foo
3594 </pre>
3595
3596 <pre>
3597
3598 foo
3599 </pre>
3600
3601 <pre>
3602
3603
3604 foo
3605 </pre>
3606 !! html/php+tidy
3607 <pre>foo</pre>
3608 <pre>foo
3609 </pre>
3610 <pre>
3611
3612 foo
3613 </pre>
3614 <pre>
3615
3616
3617 foo
3618 </pre>
3619 !! html/parsoid
3620 <pre typeof="mw:Extension/pre" about="#mwt2" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"foo"}}'>foo</pre>
3621
3622 <pre typeof="mw:Extension/pre" about="#mwt4" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
3623 </pre>
3624
3625 <pre typeof="mw:Extension/pre" about="#mwt6" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\nfoo\n"}}'>
3626
3627 foo
3628 </pre>
3629
3630 <pre typeof="mw:Extension/pre" about="#mwt8" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\n\n\nfoo\n"}}'>
3631
3632
3633 foo
3634 </pre>
3635 !!end
3636
3637 !! test
3638 HTML-pre: big spaces
3639 !! wikitext
3640 <pre>
3641
3642
3643
3644
3645 haha
3646
3647
3648
3649
3650 haha
3651
3652
3653
3654
3655 </pre>
3656 !! html/php+tidy
3657 <pre>
3658
3659
3660
3661
3662 haha
3663
3664
3665
3666
3667 haha
3668
3669
3670
3671
3672 </pre>
3673 !! html/parsoid
3674 <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"}}'>
3675
3676
3677
3678
3679 haha
3680
3681
3682
3683
3684 haha
3685
3686
3687
3688
3689 </pre>
3690 !! end
3691
3692 !!test
3693 HTML-pre: 2: indented text
3694 !! wikitext
3695 <pre>
3696 foo
3697 </pre>
3698 !! html
3699 <pre>
3700 foo
3701 </pre>
3702
3703 !!end
3704
3705 !!test
3706 HTML-pre: 3: other wikitext
3707 !! wikitext
3708 <pre>
3709 * foo
3710 # bar
3711 = no-h =
3712 '' no-italic ''
3713 [[ NoLink ]]
3714 </pre>
3715 !! html/php
3716 <pre>
3717 * foo
3718 # bar
3719 = no-h =
3720 '' no-italic ''
3721 [[ NoLink ]]
3722 </pre>
3723
3724 !! html/parsoid
3725 <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
3726 # bar
3727 = no-h =
3728 '' no-italic ''
3729 [[ NoLink ]]
3730 </pre>
3731 !!end
3732
3733 ###
3734 ### Definition lists
3735 ###
3736 !! test
3737 Simple definition
3738 !! wikitext
3739 ;name :Definition
3740 !! html
3741 <dl><dt>name&#160;</dt>
3742 <dd>Definition</dd></dl>
3743
3744 !! end
3745
3746 !! test
3747 Definition list for indentation only
3748 !! wikitext
3749 :Indented text
3750 !! html
3751 <dl><dd>Indented text</dd></dl>
3752
3753 !! end
3754
3755 !! test
3756 Definition list with no space
3757 !! wikitext
3758 ;name:Definition
3759 !! html
3760 <dl><dt>name</dt>
3761 <dd>Definition</dd></dl>
3762
3763 !!end
3764
3765 !! test
3766 Definition list with URL link
3767 !! wikitext
3768 ;http://example.com/ :definition
3769 !! html
3770 <dl><dt><a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a>&#160;</dt>
3771 <dd>definition</dd></dl>
3772
3773 !! end
3774
3775 !! test
3776 Definition list with bracketed URL link
3777 !! wikitext
3778 ;[http://www.example.com/ Example]:Something about it
3779 !! html
3780 <dl><dt><a rel="nofollow" class="external text" href="http://www.example.com/">Example</a></dt>
3781 <dd>Something about it</dd></dl>
3782
3783 !! end
3784
3785 !! test
3786 Definition list with wikilink containing colon
3787 !! wikitext
3788 ; [[Help:FAQ]]:The least-read page on Wikipedia
3789 !! html
3790 <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>
3791 <dd>The least-read page on Wikipedia</dd></dl>
3792
3793 !! end
3794
3795 # At Brion's and JeLuF's insistence... :)
3796 !! test
3797 Definition list with news link containing colon
3798 !! wikitext
3799 ;news:alt.wikipedia.rox: This isn't even a real newsgroup!
3800 !! html/php
3801 <dl><dt><a rel="nofollow" class="external free" href="news:alt.wikipedia.rox">news:alt.wikipedia.rox</a></dt>
3802 <dd>This isn't even a real newsgroup!</dd></dl>
3803
3804 !! html/parsoid
3805 <dl><dt> <a rel="mw:ExtLink" class="external free" 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>
3806 !! end
3807
3808 !! test
3809 Malformed definition list with colon
3810 !! wikitext
3811 ; news:alt.wikipedia.rox -- don't crash or enter an infinite loop
3812 !! html
3813 <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>
3814
3815 !! end
3816
3817 !! test
3818 Definition lists: colon in external link text
3819 !! wikitext
3820 ;[http://www.wikipedia2.org/ Wikipedia :The Next Generation] :OK, I made that up
3821 !! html
3822 <dl><dt><a rel="nofollow" class="external text" href="http://www.wikipedia2.org/">Wikipedia&#160;:The Next Generation</a>&#160;</dt>
3823 <dd>OK, I made that up</dd></dl>
3824
3825 !! end
3826
3827 !! test
3828 Definition lists: colon in HTML attribute
3829 !! wikitext
3830 ;<b style="display: inline">bold</b>
3831 !! html
3832 <dl><dt><b style="display: inline">bold</b></dt></dl>
3833
3834 !! end
3835
3836 !! test
3837 Definition lists: self-closed tag
3838 !! wikitext
3839 ;one<br/>two :two-line fun
3840 !! html
3841 <dl><dt>one<br />two&#160;</dt>
3842 <dd>two-line fun</dd></dl>
3843
3844 !! end
3845
3846 !! test
3847 Definition lists: ignore colons inside tags
3848 !! wikitext
3849 ;one <b>two : tag <i>fun:</i>:</b>:def
3850 !! html
3851 <dl><dt>one <b>two&#160;: tag <i>fun:</i>:</b></dt>
3852 <dd>def</dd></dl>
3853
3854 !! end
3855
3856 !! test
3857 Definition lists: excess closed tags
3858 !! wikitext
3859 ;one</b>two :bad tag fun
3860 !! html/php+tidy
3861 <dl><dt>onetwo&#160;</dt>
3862 <dd>bad tag fun</dd></dl>
3863 !! html/parsoid
3864 <dl>
3865 <dt>onetwo</dt>
3866 <dd>bad tag fun</dd>
3867 </dl>
3868 !! end
3869
3870 !! test
3871 T13748: Literal closing tags
3872 !! wikitext
3873 <dl>
3874 <dt>test 1</dt>
3875 <dd>test test test test test</dd>
3876 <dt>test 2</dt>
3877 <dd>test test test test test</dd>
3878 </dl>
3879 !! html
3880 <dl>
3881 <dt>test 1</dt>
3882 <dd>test test test test test</dd>
3883 <dt>test 2</dt>
3884 <dd>test test test test test</dd>
3885 </dl>
3886
3887 !! end
3888
3889 !! test
3890 Definition and unordered list using wiki syntax nested in unordered list using html tags.
3891 !! wikitext
3892 <ul><li>
3893 ;term :description
3894 *unordered
3895 </li></ul>
3896 !! html
3897 <ul><li>
3898 <dl><dt>term&#160;</dt>
3899 <dd>description</dd></dl>
3900 <ul><li>unordered</li></ul>
3901 </li></ul>
3902
3903 !! end
3904
3905 !! test
3906 Definition list with empty definition and following paragraph
3907 !! wikitext
3908 ;term:
3909
3910 Paragraph text
3911 !! html
3912 <dl><dt>term</dt>
3913 <dd></dd></dl>
3914 <p>Paragraph text
3915 </p>
3916 !! end
3917
3918 !! test
3919 Nested definition lists using html syntax
3920 !! wikitext
3921 <dl><dt>x</dt>
3922 <dd>a</dd>
3923 <dd>b</dd></dl>
3924 !! html
3925 <dl><dt>x</dt>
3926 <dd>a</dd>
3927 <dd>b</dd></dl>
3928
3929 !! end
3930
3931 !! test
3932 Definition Lists: No nesting: Multiple dd's
3933 !! wikitext
3934 ;x
3935 :a
3936 :b
3937 !! html
3938 <dl><dt>x</dt>
3939 <dd>a</dd>
3940 <dd>b</dd></dl>
3941
3942 !! end
3943
3944 !! test
3945 Definition Lists: Indentation: Regular
3946 !! wikitext
3947 :i1
3948 ::i2
3949 :::i3
3950 !! html
3951 <dl><dd>i1
3952 <dl><dd>i2
3953 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3954
3955 !! end
3956
3957 !! test
3958 Definition Lists: Indentation: Missing 1st level
3959 !! wikitext
3960 ::i2
3961 :::i3
3962 !! html
3963 <dl><dd><dl><dd>i2
3964 <dl><dd>i3</dd></dl></dd></dl></dd></dl>
3965
3966 !! end
3967
3968 !! test
3969 Definition Lists: Indentation: Multi-level indent
3970 !! wikitext
3971 :::i3
3972 !! html
3973 <dl><dd><dl><dd><dl><dd>i3</dd></dl></dd></dl></dd></dl>
3974
3975 !! end
3976
3977 !! test
3978 Definition Lists: Hacky use to indent tables
3979 !! wikitext
3980 ::{|
3981 |foo
3982 |bar
3983 |}
3984 this text
3985 should be left alone
3986 !! html
3987 <dl><dd><dl><dd><table>
3988 <tr>
3989 <td>foo
3990 </td>
3991 <td>bar
3992 </td></tr></table></dd></dl></dd></dl>
3993 <p>this text
3994 should be left alone
3995 </p>
3996 !! end
3997
3998 !! test
3999 Definition Lists: Hacky use to indent tables (with content following table)
4000 !! wikitext
4001 :{|
4002 |foo
4003 |bar
4004 |} <!--c1--> this text should be part of the dl
4005 !! html/php+tidy
4006 <dl><dd><table>
4007 <tbody><tr>
4008 <td>foo
4009 </td>
4010 <td>bar
4011 </td></tr></tbody></table> this text should be part of the dl</dd></dl>
4012 !! html/parsoid
4013 <dl><dd><table>
4014 <tbody><tr>
4015 <td>foo
4016 </td>
4017 <td>bar
4018 </td></tr></tbody></table> <!--c1--> this text should be part of the dl</dd></dl>
4019 !! end
4020
4021 !! test
4022 Definition Lists: Hacky use to indent tables, with comments (T65979)
4023 !! wikitext
4024 <!-- foo -->
4025 ::{|
4026 |foo
4027 |bar
4028 |}<!-- bar -->
4029 this text
4030 should be left alone
4031 !! html/parsoid
4032 <!-- foo -->
4033 <dl><dd><dl><dd><table><tr>
4034 <td>foo</td>
4035 <td>bar</td>
4036 </tr></table><!-- bar --></dd></dl></dd></dl>
4037 <p>this text
4038 should be left alone</p>
4039 !! end
4040
4041 !! test
4042 Definition Lists: Hacky use to indent tables, with comment before table
4043 !! wikitext
4044 ::<!-- foo -->{|
4045 |foo
4046 |}
4047 !! html/parsoid
4048 <dl><dd><dl><dd><!-- foo --><table><tr>
4049 <td>foo</td>
4050 </tr></table></dd></dl></dd></dl>
4051 !! end
4052
4053 # The trailing whitespace in this test is to catch a regression in
4054 # Parsoid after T54473.
4055 !! test
4056 Definition Lists: Hacky use to indent tables (WS-insensitive)
4057 !! wikitext
4058 : {|
4059 |a
4060 |}
4061 !! html/php
4062 <dl><dd><table>
4063 <tr>
4064 <td>a
4065 </td></tr></table></dd></dl>
4066
4067 !! html/parsoid
4068 <dl><dd> <table>
4069 <tbody><tr><td>a</td></tr>
4070 </tbody></table> </dd></dl>
4071 !! end
4072
4073 ## The PHP parser treats : items (dd) without a corresponding ; item (dt)
4074 ## as an empty dt item. It also ignores all but the last ";" when followed
4075 ## by ":" later on. So, ";" are not ignored in ";;;t3" but are ignored in
4076 ## ";;;t3 :d1". So, PHP parser behavior is a little inconsistent wrt multiple
4077 ## ";"s.
4078 ##
4079 ## Ex: ";;t2 ::d2" is transformed into:
4080 ##
4081 ## <dl>
4082 ## <dt>t2 </dt>
4083 ## <dd>
4084 ## <dl>
4085 ## <dt></dt>
4086 ## <dd>d2</dd>
4087 ## </dl>
4088 ## </dd>
4089 ## </dl>
4090 ##
4091 ## But, Parsoid treats "; :" as a tight atomic unit and excess ":" as plain text
4092 ## So, the same wikitext above (;;t2 ::d2) is transformed into:
4093 ##
4094 ## <dl>
4095 ## <dt>
4096 ## <dl>
4097 ## <dt>t2 </dt>
4098 ## <dd>:d2</dd>
4099 ## </dl>
4100 ## </dt>
4101 ## </dl>
4102 ##
4103 ## All Parsoid only definition list tests have this difference.
4104 ##
4105 ## See also: https://phabricator.wikimedia.org/T8569
4106 ## and https://lists.wikimedia.org/pipermail/wikitext-l/2011-November/000483.html
4107
4108 !! test
4109 Table / list interaction: indented table with lists in table contents
4110 !! wikitext
4111 :{|
4112 |-
4113 |a
4114
4115 *b
4116 |-
4117 |c
4118
4119 *d
4120 |}
4121 !! html
4122 <dl><dd><table>
4123
4124 <tr>
4125 <td>a
4126 <ul><li>b</li></ul>
4127 </td></tr>
4128 <tr>
4129 <td>c
4130 <ul><li>d</li></ul>
4131 </td></tr></table></dd></dl>
4132
4133 !! end
4134
4135 !!test
4136 Table / list interaction: lists nested in tables nested in indented lists
4137 !! wikitext
4138 :{|
4139 |
4140 :a
4141 :b
4142 |
4143 *c
4144 *d
4145 |}
4146
4147 *e
4148 *f
4149 !! html
4150 <dl><dd><table>
4151 <tr>
4152 <td>
4153 <dl><dd>a</dd>
4154 <dd>b</dd></dl>
4155 </td>
4156 <td>
4157 <ul><li>c</li>
4158 <li>d</li></ul>
4159 </td></tr></table></dd></dl>
4160 <ul><li>e</li>
4161 <li>f</li></ul>
4162
4163 !!end
4164
4165 !! test
4166 Definition Lists: Nesting: Multi-level (Parsoid only)
4167 !! wikitext
4168 ;t1 :d1
4169 ;;t2 ::d2
4170 ;;;t3 :::d3
4171 !! html/parsoid
4172 <dl>
4173 <dt>t1 </dt>
4174 <dd>d1</dd>
4175 <dt>
4176 <dl>
4177 <dt>t2 </dt>
4178 <dd>:d2</dd>
4179 <dt>
4180 <dl>
4181 <dt>t3 </dt>
4182 <dd>::d3</dd>
4183 </dl>
4184 </dt>
4185 </dl>
4186 </dt>
4187 </dl>
4188
4189
4190 !! end
4191
4192
4193 !! test
4194 Definition Lists: Nesting: Test 2
4195 !! wikitext
4196 ;t1
4197 ::d2
4198 !! html+tidy
4199 <dl><dt>t1</dt>
4200 <dd>
4201 <dl><dd>d2</dd></dl></dd></dl>
4202 !! end
4203
4204
4205 !! test
4206 Definition Lists: Nesting: Test 3
4207 !! wikitext
4208 :;t1
4209 ::::d2
4210 !! html+tidy
4211 <dl><dd><dl><dt>t1</dt>
4212 <dd>
4213 <dl><dd><dl><dd>d2</dd></dl></dd></dl></dd></dl></dd></dl>
4214 !! end
4215
4216
4217 !! test
4218 Definition Lists: Nesting: Test 4
4219 !! wikitext
4220 ::;t3
4221 :::d3
4222 !! html
4223 <dl><dd><dl><dd><dl><dt>t3</dt>
4224 <dd>d3</dd></dl></dd></dl></dd></dl>
4225
4226 !! end
4227
4228
4229 ## The Parsoid team believes the following three test exposes a
4230 ## bug in the PHP parser. (Parsoid team thinks the PHP parser is
4231 ## wrong to close the <dl> after the <dt> containing the <ul>.)
4232 ## It also exposes a "misfeature" in tidy, which doesn't like
4233 ## <dl> tags with a single <dt> child; it converts the <dt> into
4234 ## a <dd> in that case. (Parsoid leaves the <dt> alone!)
4235 !! test
4236 Definition Lists: Mixed Lists: Test 1
4237 !! wikitext
4238 :;*foo
4239 ::*bar
4240 :;baz
4241 !! html/php
4242 <dl><dd><dl><dt><ul><li>foo</li>
4243 <li>bar</li></ul></dt></dl>
4244 <dl><dt>baz</dt></dl></dd></dl>
4245
4246 !! html/php+tidy
4247 <dl><dd><dl><dt><ul><li>foo</li>
4248 <li>bar</li></ul></dt></dl>
4249 <dl><dt>baz</dt></dl></dd></dl>
4250 !! html/parsoid
4251 <dl>
4252 <dd><dl>
4253 <dt><ul>
4254 <li>foo
4255 </li>
4256 </ul></dt>
4257 <dd><ul>
4258 <li>bar
4259 </li>
4260 </ul></dd>
4261 <dt>baz</dt>
4262 </dl></dd>
4263 </dl>
4264 !! end
4265
4266 !! test
4267 Definition Lists: Mixed Lists: Test 2
4268 !! wikitext
4269 *:d1
4270 *:d2
4271 !! html
4272 <ul><li><dl><dd>d1</dd>
4273 <dd>d2</dd></dl></li></ul>
4274
4275 !! end
4276
4277
4278 !! test
4279 Definition Lists: Mixed Lists: Test 3
4280 !! wikitext
4281 *:::d1
4282 *:::d2
4283 !! html
4284 <ul><li><dl><dd><dl><dd><dl><dd>d1</dd>
4285 <dd>d2</dd></dl></dd></dl></dd></dl></li></ul>
4286
4287 !! end
4288
4289
4290 !! test
4291 Definition Lists: Mixed Lists: Test 4
4292 !! wikitext
4293 *;d1 :d2
4294 *;d3 :d4
4295 !! html
4296 <ul><li><dl><dt>d1&#160;</dt>
4297 <dd>d2</dd>
4298 <dt>d3&#160;</dt>
4299 <dd>d4</dd></dl></li></ul>
4300
4301 !! end
4302
4303
4304 !! test
4305 Definition Lists: Mixed Lists: Test 5
4306 !! wikitext
4307 *:d1
4308 *::d2
4309 !! html
4310 <ul><li><dl><dd>d1
4311 <dl><dd>d2</dd></dl></dd></dl></li></ul>
4312
4313 !! end
4314
4315
4316 !! test
4317 Definition Lists: Mixed Lists: Test 6
4318 !! wikitext
4319 #*:d1
4320 #*:::d3
4321 !! html
4322 <ol><li><ul><li><dl><dd>d1
4323 <dl><dd><dl><dd>d3</dd></dl></dd></dl></dd></dl></li></ul></li></ol>
4324
4325 !! end
4326
4327
4328 !! test
4329 Definition Lists: Mixed Lists: Test 7
4330 !! wikitext
4331 :*d1
4332 :*d2
4333 !! html
4334 <dl><dd><ul><li>d1</li>
4335 <li>d2</li></ul></dd></dl>
4336
4337 !! end
4338
4339
4340 !! test
4341 Definition Lists: Mixed Lists: Test 8
4342 !! wikitext
4343 :*d1
4344 ::*d2
4345 !! html
4346 <dl><dd><ul><li>d1</li></ul>
4347 <dl><dd><ul><li>d2</li></ul></dd></dl></dd></dl>
4348
4349 !! end
4350
4351
4352 !! test
4353 Definition Lists: Mixed Lists: Test 9
4354 !! wikitext
4355 *;foo :bar
4356 !! html
4357 <ul><li><dl><dt>foo&#160;</dt>
4358 <dd>bar</dd></dl></li></ul>
4359
4360 !! end
4361
4362
4363 !! test
4364 Definition Lists: Mixed Lists: Test 10
4365 !! wikitext
4366 *#;foo :bar
4367 !! html
4368 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4369 <dd>bar</dd></dl></li></ol></li></ul>
4370
4371 !! end
4372
4373 # The Parsoid team disagrees with the PHP parser's seemingly-random
4374 # rules regarding dd/dt on the next few tests. Parsoid is more
4375 # consistent, and recognizes the shared nesting and keeps the
4376 # still-open tags around until the nesting is complete.
4377
4378 # This is a regression test for T175099
4379 !! test
4380 Definition Lists: Mixed Lists: Test 11
4381 !! wikitext
4382 ;a
4383 :*b
4384 !! html/php
4385 <dl><dt>a</dt>
4386 <dd>
4387 <ul><li>b</li></ul></dd></dl>
4388
4389 !! html/parsoid
4390 <dl><dt>a
4391 <dd><ul><li>b</li></ul></dd></dl>
4392 !! end
4393
4394 # FIXME: Maybe get rid of this test?
4395 !! test
4396 Definition Lists: Mixed Lists: Test 12
4397 !! wikitext
4398 *#*#;*;;foo :bar
4399 *#*#;boo :baz
4400 !! html/php
4401 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4402 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dd></dl></li></ul></dd></dl>
4403 <dl><dt>boo&#160;</dt>
4404 <dd>baz</dd></dl></li></ol></li></ul></li></ol></li></ul>
4405
4406 !! html/php+tidy
4407 <ul><li><ol><li><ul><li><ol><li><dl><dt>foo&#160;</dt>
4408 <dd><ul><li><dl><dt><dl><dt>bar</dt></dl></dt></dl></li></ul></dd></dl></li></ol></li></ul>
4409 <dl><dt>boo&#160;</dt>
4410 <dd>baz</dd></dl></li></ol></li></ul>
4411 !! html/parsoid
4412 <ul>
4413 <li>
4414 <ol>
4415 <li>
4416 <ul>
4417 <li>
4418 <ol>
4419 <li>
4420 <dl>
4421 <dt>
4422 <ul>
4423 <li>
4424 <dl>
4425 <dt>
4426 <dl>
4427 <dt>foo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4428 <dd data-parsoid='{"stx":"row"}'>bar</dd>
4429 </dl></dt>
4430 </dl></li>
4431 </ul></dt>
4432 <dt>boo<span typeof="mw:Placeholder" data-parsoid='{"src":" "}'>&nbsp;</span></dt>
4433 <dd data-parsoid='{"stx":"row"}'>baz</dd>
4434 </dl></li>
4435 </ol></li>
4436 </ul></li>
4437 </ol></li>
4438 </ul>
4439 !! end
4440
4441 # FIXME: Maybe get rid of this test?
4442 # From whitelist:
4443 # * The test is wrong, there are two colons where there should be :;
4444 # * The PHP parser is wrong to close the <dl> after the <dt> containing the <ul>.
4445 !! test
4446 Definition Lists: Weird Ones: Test 1
4447 !! wikitext
4448 *#;*::;;foo :bar (who uses this?)
4449 !! html/php+tidy
4450 <ul><li><ol><li><dl><dt>foo&#160;</dt>
4451 <dd><ul><li><dl><dd><dl><dd><dl><dt><dl><dt>bar (who uses this?)</dt></dl></dt></dl></dd></dl></dd></dl></li></ul></dd></dl></li></ol></li></ul>
4452 !! html/parsoid
4453 <ul>
4454 <li>
4455 <ol>
4456 <li>
4457 <dl>
4458 <dt>
4459 <ul>
4460 <li>
4461 <dl>
4462 <dd>
4463 <dl>
4464 <dd>
4465 <dl>
4466 <dt>
4467 <dl>
4468 <dt>foo<span typeof="mw:DisplaySpace mw:Placeholder" data-parsoid='{"src":" ","isDisplayHack":true}'> </span></dt>
4469 <dd data-parsoid='{"stx":"row"}'>bar (who uses this?)</dd>
4470 </dl></dt>
4471 </dl></dd>
4472 </dl></dd>
4473 </dl></li>
4474 </ul></dt>
4475 </dl></li>
4476 </ol></li>
4477 </ul>
4478 !! end
4479
4480 !! test
4481 Definition Lists: colons occurring in tags
4482 !! wikitext
4483 ;a:b
4484 ;'''a:b'''
4485 ;<i>a:b</i>
4486 ;<span>a:b</span>
4487 ;<div>a:b</div>
4488 ;<div>a
4489 :b</div>
4490 ;{{echo|a:b}}
4491 ;{{echo|''a:b''}}
4492 ;;;''a:b''
4493 !! html+tidy
4494 <dl><dt>a</dt>
4495 <dd>b</dd>
4496 <dt><b>a:b</b></dt>
4497 <dt><i>a:b</i></dt>
4498 <dt><span>a:b</span></dt>
4499 <dt><div>a:b</div></dt>
4500 <dt><div>a</div></dt>
4501 <dd>b</dd>
4502 <dt>a</dt>
4503 <dd>b</dd>
4504 <dt><i>a:b</i></dt></dl>
4505 <dl><dt><dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4506 !! html/parsoid
4507 <dl><dt>a</dt><dd data-parsoid='{"stx":"row"}'>b</dd>
4508 <dt><b>a:b</b></dt>
4509 <dt><i data-parsoid='{"stx":"html"}'>a:b</i></dt>
4510 <dt><span data-parsoid='{"stx":"html"}'>a:b</span></dt>
4511 <dt><div data-parsoid='{"stx":"html"}'>a:b</div></dt>
4512 <dt><div data-parsoid='{"stx":"html","autoInsertedEnd":true}'>a</div></dt>
4513 <dd>b</dd>
4514 <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>
4515 <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>
4516 <dl><dt><dl><dt><i>a:b</i></dt></dl></dt></dl></dt></dl>
4517 !! end
4518
4519 # Parsoid's output differs here again because it shares
4520 # nesting between the two lists unlike the PHP parser.
4521 # Unsure which is more desirable.
4522 !! test
4523 Definition Lists: colons and tables 1
4524 !! wikitext
4525 :{|
4526 |x
4527 |}
4528 :{|
4529 |y
4530 |}
4531 !! html/php
4532 <dl><dd><table>
4533 <tr>
4534 <td>x
4535 </td></tr></table></dd></dl>
4536 <dl><dd><table>
4537 <tr>
4538 <td>y
4539 </td></tr></table></dd></dl>
4540
4541 !! html/parsoid
4542 <dl><dd><table>
4543 <tr>
4544 <td>x
4545 </td></tr></table></dd>
4546 <dd><table>
4547 <tr>
4548 <td>y
4549 </td></tr></table></dd></dl>
4550 !! end
4551
4552 # FIXME: Does this need a html/php section?
4553 !! test
4554 Definition Lists: template interaction
4555 !! wikitext
4556 ::{{definition_list}}
4557
4558 :one
4559 ::{{definition_list}}
4560 :::two
4561 :::three
4562 ::four
4563 !! html/parsoid
4564 <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">
4565 </span><dd about="#mwt1">two</dd></dl></dd></dl>
4566
4567 <dl><dd data-parsoid='{}'>one
4568 <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">
4569 </span><dd about="#mwt2">two
4570 <dl><dd>two</dd>
4571 <dd>three</dd></dl></dd>
4572 <dd data-parsoid='{}'>four</dd></dl></dd></dl>
4573 !! end
4574
4575
4576 ###
4577 ### External links
4578 ###
4579 !! test
4580 External links: non-bracketed
4581 !! wikitext
4582 Non-bracketed: http://example.com
4583 !! html
4584 <p>Non-bracketed: <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4585 </p>
4586 !! end
4587
4588 # parsoid doesn't explicitly mark autonumbered links, see T55505
4589 !! test
4590 External links: numbered
4591 !! wikitext
4592 Numbered: [http://example.com]
4593 Numbered: [http://example.net]
4594 Numbered: [http://example.com]
4595 !! html/php
4596 <p>Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[1]</a>
4597 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.net">[2]</a>
4598 Numbered: <a rel="nofollow" class="external autonumber" href="http://example.com">[3]</a>
4599 </p>
4600 !! html/parsoid
4601 <p>Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a>
4602 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.net"></a>
4603 Numbered: <a rel="mw:ExtLink" class="external autonumber" href="http://example.com"></a></p>
4604 !!end
4605
4606 !! test
4607 External links: specified text
4608 !! wikitext
4609 Specified text: [http://example.com link]
4610 !! html
4611 <p>Specified text: <a rel="nofollow" class="external text" href="http://example.com">link</a>
4612 </p>
4613 !!end
4614
4615 !! test
4616 External links: trail
4617 !! wikitext
4618 Linktrails should not work for external links: [http://example.com link]s
4619 !! html
4620 <p>Linktrails should not work for external links: <a rel="nofollow" class="external text" href="http://example.com">link</a>s
4621 </p>
4622 !! end
4623
4624 !! test
4625 External links: dollar sign in URL
4626 !! wikitext
4627 http://example.com/1$2345
4628 !! html
4629 <p><a rel="nofollow" class="external free" href="http://example.com/1$2345">http://example.com/1$2345</a>
4630 </p>
4631 !! end
4632
4633 # parsoid doesn't explicitly mark autonumbered links, see T55505
4634 !! test
4635 External links: dollar sign in URL (autonumber)
4636 !! wikitext
4637 [http://example.com/1$2345]
4638 !! html/php
4639 <p><a rel="nofollow" class="external autonumber" href="http://example.com/1$2345">[1]</a>
4640 </p>
4641 !! html/parsoid
4642 <p><a rel="mw:ExtLink" class="external autonumber" href="http://example.com/1$2345"></a></p>
4643 !!end
4644
4645 !! test
4646 External links: open square bracket forbidden in URL (T6377)
4647 !! options
4648 parsoid=wt2html,wt2wt,html2html
4649 !! wikitext
4650 http://example.com/1[2345
4651 !! html/php
4652 <p><a rel="nofollow" class="external free" href="http://example.com/1">http://example.com/1</a>[2345
4653 </p>
4654 !! html/parsoid
4655 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/1">http://example.com/1</a>[2345</p>
4656 !! end
4657
4658 !! test
4659 External links: open square bracket forbidden in URL (named) (T6377)
4660 !! options
4661 parsoid=wt2html,html2html
4662 !! wikitext
4663 [http://example.com/1[2345]
4664 !! html/php
4665 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4666 </p>
4667 !! html/parsoid
4668 <p><a rel="mw:ExtLink" class="external text" href="http://example.com/1">[2345</a></p>
4669 !!end
4670
4671 # parsoid adds a space before the link name
4672 !! test
4673 External links: open square bracket forbidden in URL (named) (T6377)
4674 Parsoid variant.
4675 !! wikitext
4676 [http://example.com/1 [2345]
4677 !! html
4678 <p><a rel="nofollow" class="external text" href="http://example.com/1">[2345</a>
4679 </p>
4680 !!end
4681
4682 !! test
4683 External links: nowiki in URL link text (T8230)
4684 !! wikitext
4685 [http://example.com/ <nowiki>''example site''</nowiki>]
4686 !! html
4687 <p><a rel="nofollow" class="external text" href="http://example.com/">''example site''</a>
4688 </p>
4689 !! end
4690
4691 !! test
4692 External links: newline forbidden in text (T8230 regression check)
4693 !! wikitext
4694 [http://example.com/ first
4695 second]
4696 !! html
4697 <p>[<a rel="nofollow" class="external free" href="http://example.com/">http://example.com/</a> first
4698 second]
4699 </p>
4700 !!end
4701
4702 !! test
4703 External links: Pipe char between url and text
4704 !! wikitext
4705 [http://example.com | link]
4706 !! html
4707 <p><a rel="nofollow" class="external text" href="http://example.com">| link</a>
4708 </p>
4709 !!end
4710
4711 !! test
4712 External links: protocol-relative URL in brackets
4713 !! wikitext
4714 [//example.com/ Test]
4715 !! html
4716 <p><a rel="nofollow" class="external text" href="//example.com/">Test</a>
4717 </p>
4718 !! end
4719
4720 # parsoid doesn't explicitly mark autonumbered links, see T55505
4721 !! test
4722 External links: protocol-relative URL in brackets without text
4723 !! wikitext
4724 [//example.com]
4725 !! html/php
4726 <p><a rel="nofollow" class="external autonumber" href="//example.com">[1]</a>
4727 </p>
4728 !! html/parsoid
4729 <p><a rel="mw:ExtLink" class="external autonumber" href="//example.com"></a></p>
4730 !! end
4731
4732 !! test
4733 External links: protocol-relative URL in free text is left alone
4734 !! wikitext
4735 //example.com/Foo
4736 !! html
4737 <p>//example.com/Foo
4738 </p>
4739 !!end
4740
4741 !! test
4742 External links: protocol-relative URL in the middle of a word is left alone (T32269)
4743 !! wikitext
4744 foo//example.com/Foo
4745 !! html
4746 <p>foo//example.com/Foo
4747 </p>
4748 !! end
4749
4750 ## html2wt and html2html will fail because we will prefer the :en: interwiki prefix over wikipedia:
4751 !! test
4752 External links: with no contents
4753 !! options
4754 parsoid=wt2html,wt2wt
4755 !! wikitext
4756 [http://en.wikipedia.org/wiki/Foo]
4757
4758 [[wikipedia:Foo|Bar]]
4759
4760 [[wikipedia:Foo|<span>Bar</span>]]
4761 !! html/php
4762 <p><a rel="nofollow" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo">[1]</a>
4763 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo">Bar</a>
4764 </p><p><a href="http://en.wikipedia.org/wiki/Foo" class="extiw" title="wikipedia:Foo"><span>Bar</span></a>
4765 </p>
4766 !! html/parsoid
4767 <p><a rel="mw:ExtLink" class="external autonumber" href="http://en.wikipedia.org/wiki/Foo"></a></p>
4768 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo">Bar</a></p>
4769 <p><a rel="mw:WikiLink/Interwiki" href="http://en.wikipedia.org/wiki/Foo" title="wikipedia:Foo"><span>Bar</span></a></p>
4770 !! end
4771
4772 !! test
4773 External links: Free with trailing punctuation
4774 !! wikitext
4775 http://example.com,
4776 http://example.com;
4777 http://example.com\
4778 http://example.com.
4779 http://example.com:
4780 http://example.com!
4781 http://example.com?
4782 http://example.com)
4783 http://example.com/url_with_(brackets)
4784 (http://example.com/url_without_brackets)
4785 http://example.com/url_with_entity&amp;
4786 http://example.com/url_with_entity&#x26;
4787 http://example.com/url_with_entity&#038;
4788 http://example.com/url_with_entity&nbsp;
4789 http://example.com/url_with_entity&#xA0;
4790 http://example.com/url_with_entity&#160;
4791 http://example.com/url_with_entity&lt;
4792 http://example.com/url_with_entity&#x3C;
4793 http://example.com/url_with_entity&#60;
4794 !! html/php
4795 <p><a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>,
4796 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>;
4797 <a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>\
4798 <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/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4804 (<a rel="nofollow" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4805 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4806 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4807 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4808 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4809 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#xa0;
4810 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#160;
4811 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&lt;
4812 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#x3c;
4813 <a rel="nofollow" class="external free" href="http://example.com/url_with_entity">http://example.com/url_with_entity</a>&#60;
4814 </p>
4815 !! html/parsoid
4816 <p><a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>,
4817 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>;
4818 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>\
4819 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>.
4820 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>:
4821 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>!
4822 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>?
4823 <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a>)
4824 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_(brackets)">http://example.com/url_with_(brackets)</a>
4825 (<a rel="mw:ExtLink" class="external free" href="http://example.com/url_without_brackets">http://example.com/url_without_brackets</a>)
4826 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4827 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4828 <a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;">http://example.com/url_with_entity&amp;</a>
4829 <a rel="mw:ExtLink" class="external free" 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>
4830 <a rel="mw:ExtLink" class="external free" 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>
4831 <a rel="mw:ExtLink" class="external free" 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>
4832 <a rel="mw:ExtLink" class="external free" 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>
4833 <a rel="mw:ExtLink" class="external free" 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>
4834 <a rel="mw:ExtLink" class="external free" 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>
4835 !! end
4836
4837 !! test
4838 External links: tricky Parsoid html2html case
4839 !! options
4840 parsoid=wt2html,wt2wt,html2html
4841 !! wikitext
4842 http://example.com/url_with_entity&amp;amp;
4843 !! html/php
4844 <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>;
4845 </p>
4846 !! html/parsoid
4847 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/url_with_entity&amp;amp">http://example.com/url_with_entity&amp;amp</a>;</p>
4848 !! end
4849
4850 !! test
4851 External links: Free with trailing quotes (T113666)
4852 !! wikitext
4853 '''News:''' Stuff here
4854
4855 news:'a'b''c''d e
4856 !! html/php
4857 <p><b>News:</b> Stuff here
4858 </p><p><a rel="nofollow" class="external free" href="news:&#39;a&#39;b">news:'a'b</a><i>c</i>d e
4859 </p>
4860 !! html/parsoid
4861 <p><b>News:</b> Stuff here</p>
4862 <p><a rel="mw:ExtLink" class="external free" href="news:'a'b">news:'a'b</a><i>c</i>d e</p>
4863 !! end
4864
4865 !! test
4866 External links: with entity
4867 !! wikitext
4868 [http://&#x20;www.librarieswithoutborders.org Libraries without borders]
4869 !! html/php
4870 <p><a rel="nofollow" class="external text" href="http://+www.librarieswithoutborders.org">Libraries without borders</a>
4871 </p>
4872 !! html/parsoid
4873 <p><a rel="mw:ExtLink" class="external text" 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>
4874 !! end
4875
4876 !! test
4877 External links: Lone protocols are never linked (T105697)
4878 !! wikitext
4879 http://
4880 http://;
4881 (http://)
4882 bitcoin:
4883 bitcoin:;
4884 (bitcoin:)
4885 !! html
4886 <p>http://
4887 http://;
4888 (http://)
4889 bitcoin:
4890 bitcoin:;
4891 (bitcoin:)
4892 </p>
4893 !! end
4894
4895 !! test
4896 External links: No preceding word characters allowed (T67278)
4897 !! wikitext
4898 NOPEhttp://example.com
4899 N0http://example.com
4900 ok:http://example.com
4901 ok-http://example.com
4902 !! html
4903 <p>NOPEhttp://example.com
4904 N0http://example.com
4905 ok:<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4906 ok-<a rel="nofollow" class="external free" href="http://example.com">http://example.com</a>
4907 </p>
4908 !! end
4909
4910 !! test
4911 External links: nofollow domain exception
4912 !! wikitext
4913 A [https://no-nofollow.org/foobar link], and another [https://example.org link].
4914 !! html
4915 <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>.
4916 </p>
4917 !!end
4918
4919 !! test
4920 External image
4921 !! wikitext
4922 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4923 !! html
4924 <p>External image: <img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
4925 </p>
4926 !! end
4927
4928 !! test
4929 External image from https
4930 !! wikitext
4931 External image from https: https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4932 !! html
4933 <p>External image from https: <img src="https://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png"/>
4934 </p>
4935 !! end
4936
4937 !! test
4938 External image (when not allowed)
4939 !! options
4940 wgAllowExternalImages=0
4941 !! wikitext
4942 External image: http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png
4943 !! html
4944 <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>
4945 </p>
4946 !! end
4947
4948 !! test
4949 Link to non-http image, no img tag
4950 !! wikitext
4951 Link to non-http image, no img tag: ftp://example.com/test.jpg
4952 !! html
4953 <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>
4954 </p>
4955 !! end
4956
4957 !! test
4958 External links: terminating separator
4959 !! wikitext
4960 Terminating separator: http://example.com/thing,
4961 !! html
4962 <p>Terminating separator: <a rel="nofollow" class="external free" href="http://example.com/thing">http://example.com/thing</a>,
4963 </p>
4964 !! end
4965
4966 !! test
4967 External links: intervening separator
4968 !! wikitext
4969 Intervening separator: http://example.com/1,2,3
4970 !! html
4971 <p>Intervening separator: <a rel="nofollow" class="external free" href="http://example.com/1,2,3">http://example.com/1,2,3</a>
4972 </p>
4973 !! end
4974
4975 !! test
4976 External links: old bug with URL in query
4977 !! wikitext
4978 Old bug with URL in query: [http://example.com/thing?url=http://example.com link]
4979 !! html
4980 <p>Old bug with URL in query: <a rel="nofollow" class="external text" href="http://example.com/thing?url=http://example.com">link</a>
4981 </p>
4982 !! end
4983
4984 !! test
4985 External links: old URL-in-URL bug, mixed protocols
4986 !! wikitext
4987 And again with mixed protocols: [ftp://example.com?url=http://example.com link]
4988 !! html
4989 <p>And again with mixed protocols: <a rel="nofollow" class="external text" href="ftp://example.com?url=http://example.com">link</a>
4990 </p>
4991 !!end
4992
4993 # Since Parsoid is starting to emit canonical wikitext for links,
4994 # [http://example.com http://example.com] will not RT back to that
4995 # form anymore.
4996 !! test
4997 External links: URL in text
4998 !! options
4999 parsoid=wt2html
5000 !! wikitext
5001 URL in text: [http://example.com http://example.com]
5002 !! html/php
5003 <p>URL in text: <a rel="nofollow" class="external text" href="http://example.com">http://example.com</a>
5004 </p>
5005 !! html/parsoid
5006 <p>URL in text: <a rel="mw:ExtLink" class="external free" href="http://example.com">http://example.com</a></p>
5007 !! end
5008
5009 !! test
5010 External links: Clickable images
5011 !! wikitext
5012 ja-style clickable images: [http://example.com http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png]
5013 !! html/php
5014 <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>
5015 </p>
5016 !! html/parsoid
5017 <p>ja-style clickable images: <a rel="mw:ExtLink" class="external text" href="http://example.com"><img src="http://meta.wikimedia.org/upload/f/f1/Ncwikicol.png" alt="Ncwikicol.png" data-parsoid='{"type":"extlink"}'/></a></p>
5018 !! end
5019
5020 !! test
5021 External links: raw ampersand
5022 !! wikitext
5023 Old &amp; use: http://x&y
5024 !! html
5025 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5026 </p>
5027 !! end
5028
5029 !! test
5030 External links: encoded ampersand
5031 !! wikitext
5032 Old &amp; use: http://x&amp;y
5033 !! html/php
5034 <p>Old &amp; use: <a rel="nofollow" class="external free" href="http://x&amp;y">http://x&amp;y</a>
5035 </p>
5036 !! html/parsoid
5037 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external free" href="http://x&amp;y">http://x&amp;y</a></p>
5038 !! end
5039
5040 !! test
5041 External links: encoded equals (T8102)
5042 !! wikitext
5043 http://example.com/?foo&#61;bar
5044 !! html/php
5045 <p><a rel="nofollow" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a>
5046 </p>
5047 !! html/parsoid
5048 <p><a rel="mw:ExtLink" class="external free" href="http://example.com/?foo=bar">http://example.com/?foo=bar</a></p>
5049 !! end
5050
5051 ##
5052 ## Note that parsoid doesn't explicit mark autonumbered links, nor
5053 ## does it number them. As discussed in T55505, we can identify
5054 ## autonumbered links via CSS.
5055 ##
5056
5057 !! test
5058 External links: [raw ampersand]
5059 !! wikitext
5060 Old &amp; use: [http://x&y]
5061 !! html/php
5062 <p>Old &amp; use: <a rel="nofollow" class="external autonumber" href="http://x&amp;y">[1]</a>
5063 </p>
5064 !! html/parsoid
5065 <p>Old <span typeof="mw:Entity">&amp;</span> use: <a rel="mw:ExtLink" class="external autonumber" href="http://x&amp;y"></a></p>
5066 !! end
5067
5068 # note that parsoid html is identical to [raw ampersand] case; so html2wt
5069 # mode will return the [raw ampersand] wikitext