Debian Codegraph @

tests/parser/indentPre.txt

raw
1 # The parsoid-compatible option below is only relevant when we are running
2 # parser tests in integrated mode with Parsoid. This option is ignored
3 # when this test file is run with Parsoid in standalone mode.
4 !! options
5 parsoid-compatible=wt2html,wt2wt
6 version=2
7 !! end
8
9 # This is the standard article assumed to exist.
10 !! article
11 Main Page
12 !! text
13 blah blah
14 !! endarticle
15
16 !! article
17 Template:1x
18 !! text
19 {{{1}}}
20 !! endarticle
21
22 !! article
23 Template:T1
24 !! text
25 <pwraptest /><div>foo</div><pwraptest />
26 !! endarticle
27
28 !! test
29 Preformatted text
30 !! wikitext
31 This is some
32 Preformatted text
33 With ''italic''
34 And '''bold'''
35 And a [[Main Page|link]]
36 !! html
37 <pre>This is some
38 Preformatted text
39 With <i>italic</i>
40 And <b>bold</b>
41 And a <a href="/wiki/Main_Page" title="Main Page">link</a>
42 </pre>
43 !! end
44
45 !! test
46 Tabs don't trigger preformatted text
47 !! wikitext
48 This is not
49 preformatted text.
50 This is preformatted text.
51 So is this.
52 !! html/php
53 <p> This is not
54 preformatted text.
55 </p>
56 <pre>This is preformatted text.
57 So is this.
58 </pre>
59 !! html/parsoid
60 <p> This is not
61 preformatted text.</p>
62 <pre>This is preformatted text.
63 So is this.</pre>
64 !! end
65
66 ## FIXME: This test is less useful now that the leading space is normalized away
67 !! test
68 Space before tab needs nowiki pre protection
69 !! options
70 parsoid=html2wt
71 !! html/parsoid
72 <p> a</p>
73 !! wikitext
74 a
75 !! end
76
77 !! test
78 Indent preformatting with inline content
79 !! wikitext
80 a
81 ''b''
82 !! html
83 <pre>a
84 <i>b</i>
85 </pre>
86 !! end
87
88 !! test
89 <pre> with <nowiki> inside (compatibility with 1.6 and earlier)
90 !! wikitext
91 <pre><nowiki>
92 <b>
93 <cite>
94 <em>
95 </nowiki></pre>
96 !! html
97 <pre>&lt;b&gt;
98 &lt;cite&gt;
99 &lt;em&gt;
100 </pre>
101 !! end
102
103 !! test
104 Regression with preformatted in <center>
105 !! wikitext
106 <center>
107 Blah
108 </center>
109 !! html
110 <center>
111 <pre>Blah
112 </pre>
113 </center>
114 !! end
115
116 !! test
117 T54763: Preformatted in <blockquote>
118 !! wikitext
119 <blockquote>
120 Blah
121 {|
122 |
123 indented cell (no pre-wrapping!)
124 |}
125 </blockquote>
126 !! html
127 <blockquote>
128 <p> Blah
129 </p>
130 <table>
131 <tbody><tr>
132 <td>
133 <p> indented cell (no pre-wrapping!)
134 </p>
135 </td></tr></tbody></table>
136 </blockquote>
137 !! end
138
139 !!test
140 Templates: Indent-Pre: 1a. Templates that break a line should suppress <pre>
141 !! wikitext
142 {{1x|}}
143 !! html
144 !! end
145
146 !!test
147 Templates: Indent-Pre: 1b. Templates that break a line should suppress <pre>
148 !! wikitext
149 {{1x|
150 foo}}
151 !! html
152 <p>foo
153 </p>
154 !!end
155
156 !! test
157 Templates: Indent-Pre: 1c: Wrapping should be based on expanded content
158 !! wikitext
159 {{1x|a
160 b}}
161 !! html
162 <pre>a
163 </pre>
164 <p>b
165 </p>
166 !!end
167
168 !! test
169 Templates: Indent-Pre: 1d: Wrapping should be based on expanded content
170 !! wikitext
171 {{1x|a
172 b
173 c
174 d
175 e
176 }}
177 !! html
178 <pre>a
179 </pre>
180 <p>b
181 c
182 </p>
183 <pre>d
184 </pre>
185 <p>e
186 </p>
187 !!end
188
189 !!test
190 Templates: Indent-Pre: 1e. Wrapping should be based on expanded content
191 !! wikitext
192 {{1x| foo}}
193
194 {{1x| foo}}{{1x| bar}}
195
196 {{1x| foo}}
197 {{1x| bar}}
198
199 {{1x|<!--cmt--> foo}}
200
201 <!--cmt-->{{1x| foo}}
202
203 {{1x|{{1x| }}bar}}
204 !! html
205 <pre>foo
206 </pre>
207 <pre>foo bar
208 </pre>
209 <pre>foo
210 bar
211 </pre>
212 <pre>foo
213 </pre>
214 <pre>foo
215 </pre>
216 <pre>bar
217 </pre>
218 !!end
219
220 !! test
221 Templates: Indent-Pre: 1f: Wrapping should be based on expanded content
222 !! wikitext
223 {{1x| }}a
224
225 {{1x|
226 }}a
227
228 {{1x|
229 b}}
230
231 {{1x|a
232 }}b
233
234 {{1x|a
235 }} b
236 !! html
237 <pre>a
238 </pre>
239 <p><br />
240 </p>
241 <pre>a
242 </pre>
243 <p><br />
244 </p>
245 <pre>b
246 </pre>
247 <p>a
248 </p>
249 <pre>b
250 </pre>
251 <p>a
252 </p>
253 <pre>b
254 </pre>
255 !!end
256
257 ###
258 ### Parsoid-centric regression tests
259 ###
260
261 !! test
262 Off-by-1 DSR values: Regression test for indent-pre usages
263 !! options
264 parsoid=wt2html,selser
265 !! wikitext
266 {{1x|
267 }} ''{{1x|
268 }} X'' {{1x|<span></span>
269 }} Y
270 !! html/parsoid
271 <span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"\n"}},"i":0}}]}'>
272 </span><pre><i data-parsoid='{"autoInsertedEnd":true}'></i><span about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"\n"}},"i":0}}]}'>
273 </span>X<i about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"autoInsertedEnd":true,"firstWikitextNode":"I","pi":[[{"k":"1"}]]}' data-mw='{"parts":["&apos;&apos; ",{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;span>&lt;/span>\n"}},"i":0}}]}'> <span></span></i><span about="#mwt3">
274 </span>Y</pre>
275 !! html/php
276 <pre><i></i>
277 X<i> <span></span></i>
278 Y
279 </pre>
280 !! end
281
282 !! test
283 Ensure DSR values for mw:DisplaySpace spans are computed correctly
284 !! options
285 parsoid=wt2html,selser
286 !! wikitext
287 x
288 y :)
289 !! html/parsoid
290 <pre>x
291 y :)</pre>
292 !! html/php
293 <pre>x
294 y&#160;:)
295 </pre>
296 !! end
297
298 !! test
299 pwrap test
300 !! options
301 parsoid=wt2html
302 !! wikitext
303 {{T1}}{{T1}}
304 !! html/parsoid
305 <span typeof="mw:Extension/pwraptest mw:Transclusion" about="#mwt1" data-mw='{"name":"pwraptest","attrs":{},"parts":[{"template":{"target":{"wt":"T1","href":"./Template:T1"},"params":{},"i":0}}]}'><!--CMT--></span><style about="#mwt1">p{}</style><div about="#mwt1">foo</div><span typeof="mw:Extension/pwraptest" about="#mwt1" data-mw='{"name":"pwraptest","attrs":{}}'><!--CMT--></span><style about="#mwt1">p{}</style><span typeof="mw:Extension/pwraptest mw:Transclusion" about="#mwt7" data-mw='{"name":"pwraptest","attrs":{},"parts":[{"template":{"target":{"wt":"T1","href":"./Template:T1"},"params":{},"i":0}}]}'><!--CMT--></span><style about="#mwt7">p{}</style><div about="#mwt7">foo</div><span typeof="mw:Extension/pwraptest" about="#mwt7" data-mw='{"name":"pwraptest","attrs":{}}'><!--CMT--></span><style about="#mwt7">p{}</style>
306 !! end
307
308 ###
309 ### Parsoid-centric tests for testing RT edge cases for pre
310 ###
311
312 !!test
313 1a. Indent-Pre and Comments
314 !! wikitext
315 a
316 <!--a-->
317 c
318 !! html
319 <pre>a
320 </pre>
321 <p>c
322 </p>
323 !!end
324
325 !!test
326 1b. Indent-Pre and Comments
327 !! wikitext
328 a
329 <!--a-->
330 c
331 !! html
332 <pre>a
333 </pre>
334 <p>c
335 </p>
336 !!end
337
338 !!test
339 1c. Indent-Pre and Comments
340 !! wikitext
341 <!--a--> a
342
343 <!--a--> a
344 !! html
345 <pre> a
346 </pre>
347 <pre> a
348 </pre>
349 !!end
350
351 !!test
352 1d. Indent-Pre and Comments
353 (Pre-handler currently cannot distinguish between comment/ws order and normalizes them to [comment,ws] order)
354 !! wikitext
355 <!--a--> a
356
357 <!--b-->b
358 !! html
359 <pre>a
360 </pre>
361 <pre>b
362 </pre>
363 !!end
364
365 !!test
366 2a. Indent-Pre and tables
367 !! wikitext
368 {|
369 |-
370 !h1!!h2
371 |foo||bar
372 |}
373 !! html
374 <table>
375
376 <tbody><tr>
377 <th>h1</th>
378 <th>h2
379 </th>
380 <td>foo</td>
381 <td>bar
382 </td></tr></tbody></table>
383 !!end
384
385 !!test
386 2b. Indent-Pre and tables
387 !! wikitext
388 {|
389 |-
390 |foo
391 |}
392 !! html
393 <table>
394
395 <tbody><tr>
396 <td>foo
397 </td></tr></tbody></table>
398 !!end
399
400 !!test
401 2c. Indent-Pre and tables (T44252)
402 !! wikitext
403 {|
404 |+foo
405 ! |bar
406 |}
407 !! html
408 <table>
409 <caption>foo
410 </caption>
411 <tbody><tr>
412 <th>bar
413 </th></tr></tbody></table>
414 !!end
415
416 !!test
417 2d. Indent-Pre and tables
418 !! wikitext
419 a
420 {|
421 |b
422 |}
423 !! html/php
424 <pre>a
425 </pre>
426 <table>
427 <tbody><tr>
428 <td>b
429 </td></tr></tbody></table>
430 !! html/parsoid
431 <pre>a</pre>
432 <table>
433 <tbody><tr><td> b</td></tr>
434 </tbody></table>
435 !!end
436
437 !!test
438 2e. Indent-Pre and table-line syntax
439 !! wikitext
440 a
441 | b
442 | c
443 !! html/php
444 <pre>a
445 | b
446 | c
447 </pre>
448 !!end
449
450 !!test
451 2f. Indent-pre started by table-line syntax
452 !! wikitext
453 a
454 | b
455 | c
456 !! html/php
457 <p>a
458 </p>
459 <pre>| b
460 | c
461 </pre>
462 !! html/parsoid
463 <p>a</p>
464 <pre>
465 | b
466 | c</pre>
467 !!end
468
469 !! test
470 2g. Indented table markup mixed with indented pre content (proposed in T8200)
471 !! wikitext
472 <table>
473 <tr>
474 <td>
475 Text that should be rendered preformatted
476 </td>
477 </tr>
478 </table>
479 !! html
480 <table>
481 <tbody><tr>
482 <td>
483 <pre>Text that should be rendered preformatted
484 </pre>
485 </td>
486 </tr>
487 </tbody></table>
488 !! end
489
490 !! test
491 2h. Indent pre in tables
492 !! options
493 parsoid=wt2html,html2html
494 !! wikitext
495 {|
496 !
497 foo
498 !
499 bar
500 |-
501 |
502 baz
503 {{!}}
504 bam
505 |}
506 !! html/php
507 <table>
508 <tbody><tr>
509 <th>
510 <pre>foo
511 </pre>
512 </th>
513 <th>
514 <pre>bar
515 </pre>
516 </th></tr>
517 <tr>
518 <td>
519 <pre>baz
520 </pre>
521 </td>
522 <td>
523 <pre>bam
524 </pre>
525 </td></tr></tbody></table>
526 !! html/parsoid
527 <table>
528 <tbody><tr><th>
529 <pre>foo</pre>
530 </th><th>
531 <pre>bar</pre>
532 </th></tr><tr>
533 <td>
534 <pre>baz</pre>
535 </td><td data-parsoid='{"startTagSrc":"{{!}}"}'>
536 <pre>bam</pre>
537 </td></tr></tbody></table>
538 !! end
539
540 !! test
541 3a. Indent-Pre and block tags (single-line html)
542 !! wikitext
543 a <p> foo </p>
544 b <div> foo </div>
545 c <blockquote> foo </blockquote>
546 <span> foo </span>
547 !! html/php
548 <p> a </p><p> foo </p><p>
549 b </p><div> foo </div><p>
550 c </p><blockquote><p> foo </p></blockquote>
551 <pre><span> foo </span>
552 </pre>
553 !! html/parsoid
554 <p> a </p><p data-parsoid='{"stx":"html"}'> foo </p><p>
555 b </p><div data-parsoid='{"stx":"html"}'> foo </div><p>
556 c </p><blockquote data-parsoid='{"stx":"html"}'><p> foo </p></blockquote>
557 <pre><span data-parsoid='{"stx":"html"}'> foo </span></pre>
558 !! end
559
560 !! test
561 3b. Indent-Pre and block tags (multi-line html)
562 !! wikitext
563 a <span>foo</span>
564 <!-- comment --> b <div> foo </div>
565 !! html/parsoid
566 <pre>a <span data-parsoid='{"stx":"html"}'>foo</span></pre>
567 <!-- comment --> <p>b </p><div data-parsoid='{"stx":"html"}'> foo </div>
568 !! html/php
569 <pre>a <span>foo</span>
570 </pre><p>
571 b </p><div> foo </div>
572 !! end
573
574 !! test
575 3c. Indent-Pre and block tags (pre-content on separate line)
576 !! wikitext
577 <p>
578 foo
579 </p>
580
581 <div>
582 foo
583 </div>
584
585 <center>
586 foo
587 </center>
588
589 <blockquote>
590 foo
591 </blockquote>
592
593 <blockquote>
594 <pre>
595 foo
596 </pre>
597 </blockquote>
598
599 <table><tr><td>
600 foo
601 </td></tr></table>
602
603 <ul><li>
604 foo
605 </li></ul>
606 !! html/php
607 <p>
608 foo
609 </p>
610 <div>
611 <pre>foo
612 </pre>
613 </div>
614 <center>
615 <pre>foo
616 </pre>
617 </center>
618 <blockquote>
619 <p> foo
620 </p>
621 </blockquote>
622 <blockquote>
623 <pre>foo
624 </pre>
625 </blockquote>
626 <table><tbody><tr><td>
627 <pre>foo
628 </pre>
629 </td></tr></tbody></table>
630 <ul><li>
631 foo
632 </li></ul>
633 !! html/parsoid
634 <p data-parsoid='{"stx":"html"}'>
635 foo
636 </p>
637
638 <div>
639 <pre>foo</pre>
640 </div>
641
642 <center>
643 <pre>foo</pre>
644 </center>
645
646 <blockquote>
647 <p> foo</p>
648 </blockquote>
649
650 <blockquote>
651 <pre typeof="mw:Extension/pre" about="#mwt3" data-mw='{"name":"pre","attrs":{},"body":{"extsrc":"\nfoo\n"}}'>foo
652 </pre>
653 </blockquote>
654
655 <table data-parsoid='{"stx":"html"}'><tbody><tr data-parsoid='{"stx":"html"}'><td data-parsoid='{"stx":"html"}'>
656 <pre>foo</pre>
657 </td></tr></tbody></table>
658
659 <ul data-parsoid='{"stx":"html"}'><li data-parsoid='{"stx":"html"}'>
660 foo
661 </li></ul>
662 !! end
663
664 !! test
665 4. Indent-Pre and extension tags
666 !! options
667 parsoid=wt2html,html2html
668 !! wikitext
669 a <tag />
670 !! html/php
671 <p> a </p><pre>NULL
672 array (
673 )
674 </pre>
675 !! html/parsoid
676 <p> a </p><pre typeof="mw:Extension/tag" about="#mwt2" data-mw='{"name":"tag","attrs":{}}'>NULL
677 array (
678 )
679 </pre>
680 !! end
681
682 !! test
683 5. Indent-Pre and html pre
684 !! wikitext
685 <pre class="123">hi</pre>
686 !! html/php
687 <pre class="123">hi</pre>
688 !! html/parsoid
689 <pre class="123" typeof="mw:Extension/pre" about="#mwt2" data-parsoid='{"stx":"html"}' data-mw='{"name":"pre","attrs":{"class":"123"},"body":{"extsrc":"hi"}}'>hi</pre>
690 !! end
691
692 !! test
693 Serializing indent pre at sol
694 !! html/parsoid
695 <pre>hi</pre>
696 !! html/php
697 <pre>hi
698 </pre>
699 !! wikitext
700 hi
701 !! end
702
703 !!test
704 Render paragraphs when indent-pre is suppressed in blocklevels
705 !! wikitext
706 <blockquote>
707 foo
708
709 bar
710 </blockquote>
711 !! html
712 <blockquote>
713 <p> foo
714 </p><p> bar
715 </p>
716 </blockquote>
717 !!end
718
719 !!test
720 4. Multiple spaces at start-of-line
721 !! wikitext
722 <p> foo </p>
723 foo
724 {|
725 |foo
726 |}
727 !! html
728 <p> foo </p>
729 <pre> foo
730 </pre>
731 <table>
732 <tbody><tr>
733 <td>foo
734 </td></tr></tbody></table>
735 !!end
736
737 ## NOTE: the leading white-space chars on empty line are significant
738 !! test
739 5a. White-space in indent-pre
740 !! wikitext
741 a<br />
742
743 b
744 !! html
745 <pre>a<br />
746
747 b
748 </pre>
749 !! end
750
751 ## NOTE: the leading white-space chars on empty line are significant
752 !! test
753 5b. White-space in indent-pre
754 !! wikitext
755 a
756
757 b
758
759
760 c
761 !! html
762 <pre>a
763
764 b
765
766
767 c
768 </pre>
769 !! end
770
771 !! test
772 5c. White-space in indent-pre
773 !! wikitext
774 ''a''
775 ''b''
776 ''c''
777 !! html
778 <pre><i>a</i>
779 <i>b</i>
780 <i>c</i>
781 </pre>
782 !! end
783
784 !! test
785 6. Pre-blocks should extend across lines with leading WS even when there is no wrappable content
786 !! wikitext
787 a
788
789 <!-- continue -->
790 b
791
792 c
793
794 d
795 !! html
796 <pre>a
797
798 b
799 </pre>
800 <pre>c
801
802 </pre>
803 <p>d
804 </p>
805 !! end
806
807 !! test
808 7a. Indent-pre and category links
809 !! options
810 parsoid=wt2html,wt2wt
811 !! wikitext
812 [[Category:foo]] <!-- No pre-wrapping -->
813 {{1x| [[Category:foo]]}} <!-- No pre-wrapping -->
814 !! html/php
815 !! html/parsoid
816 <link rel="mw:PageProp/Category" href="./Category:Foo"> <!-- No pre&#x2D;wrapping -->
817 <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":" [[Category:foo]]"}},"i":0}}]}'> </span><link rel="mw:PageProp/Category" href="./Category:Foo" about="#mwt1"> <!-- No pre&#x2D;wrapping -->
818 !! end
819
820 ## We used to, but no longer wt2wt this test since the default serializer
821 ## will normalize all categories to serialize on their own line.
822 ## This wikitext usage is going to be fairly uncommon in production and
823 ## selser will take care of preserving formatting in those scenarios.
824 !! test
825 7b. Indent-pre and category links
826 !! options
827 parsoid=wt2html
828 !! wikitext
829 [[Category:foo]] a
830 [[Category:foo]] {{1x|b}}
831 !! html/parsoid
832 <pre><link rel="mw:PageProp/Category" href="./Category:Foo"> a
833 <link rel="mw:PageProp/Category" href="./Category:Foo"> <span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"b"}},"i":0}}]}'>b</span></pre>
834 !! end
835
836 !! test
837 Indent-Pre: Newlines in comments shouldn't affect sol state
838 !! wikitext
839 a <!--
840 foo
841 --> b
842 !! html/php
843 <p>a b
844 </p>
845 !! html/parsoid
846 <p>a <!--
847 foo
848 --> b</p>
849 !! end
850
851 !! test
852 Indent pre with leading colon
853 !! wikitext
854 :foo
855 !! html/php
856 <pre>:foo
857 </pre>
858 !! html/parsoid
859 <pre>:foo</pre>
860 !! end
861
862 ## DO NOT DELETE trailing whitespace in the wikitext below!
863 !! test
864 Indent-Pre regression test: Trailing whitespace after sol-transparent content
865 !! wikitext
866 [[Category:Foo]]
867 [[Category:Bar]]
868 !! html/php
869 !! html/parsoid
870 <link rel="mw:PageProp/Category" href="./Category:Foo" data-parsoid='{"stx":"simple","a":{"href":"./Category:Foo"},"sa":{"href":"Category:Foo"}}'/>
871 <link rel="mw:PageProp/Category" href="./Category:Bar" data-parsoid='{"stx":"simple","a":{"href":"./Category:Bar"},"sa":{"href":"Category:Bar"}}'/>
872 !! end
873
874 !! test
875 Preserving leading whitespace in indent-pre suppressing contexts
876 !! wikitext
877 <ol>
878 <li>
879 foo
880 bar
881 </li>
882 </ol>
883 !! html/php
884 <ol>
885 <li>
886 foo
887 bar
888 </li>
889 </ol>
890 !! html/parsoid
891 <ol data-parsoid='{"stx":"html"}'>
892 <li data-parsoid='{"stx":"html"}'>
893 foo
894 bar
895 </li>
896 </ol>
897 !! end