!! Version 2 ## ## This file has tests for Parsoid's section-wrapping feature ## !! article Template:Foobar1 !! text {{1x|boo}} == Foobar == baz !! endarticle !! article Template:Foobar2 !! text {{1x|boo}} [[Category:BadTemplate]] __NOTOC__ == Foobar == baz !! endarticle !! article Template:1x !! text {{{1}}} !! endarticle !! article Template:3x_on_newline !! text {{{1}}} {{{1}}} {{{1}}} !! endarticle !! test Section wrapping for well-nested sections (no leading content) !! options notoc parsoid={ "wrapSections": true } !! wikitext =1= a =2= b ==2.1== c ==2.2== d ===2.2.1=== e =3= f !! html/php

1[edit]

a

2[edit]

b

2.1[edit]

c

2.2[edit]

d

2.2.1[edit]

e

3[edit]

f

!! html/parsoid

1

a

2

b

2.1

c

2.2

d

2.2.1

e

3

f

!! end !! test Section wrapping for well-nested sections (with leading content) !! options notoc parsoid={ "wrapSections": true } !! wikitext Para 1. Para 2 with a
nested in it
Para 3. =1= a =2= b ==2.1== c !! html/php

Para 1.

Para 2 with a

nested in it

Para 3.

1[edit]

a

2[edit]

b

2.1[edit]

c

!! html/parsoid

Para 1.

Para 2 with a

nested in it

Para 3.

1

a

2

b

2.1

c

!! end !! test Section wrapping with template-generated sections (good nesting 1) !! options notoc parsoid={ "wrapSections": true } !! wikitext =1= a {{1x|1= ==1.1== b }} ==1.2== c =2= d !! html/php

1[edit]

a

1.1

b

1.2[edit]

c

2[edit]

d

!! html/parsoid

1

a

1.1

b

1.2

c

2

d

!! end # In this example, the template scope is mildly expanded to incorporate the # trailing newline after the transclusion since that is part of section 1.1.1 !! test Section wrapping with template-generated sections (good nesting 2) !! options notoc parsoid={ "wrapSections": true, "modes": ["wt2html", "wt2wt"] } !! wikitext =1= a {{1x|1= ==1.1== b ===1.1.1=== d }} {{{BOOO}}} =2= e !! html/php

1[edit]

a

1.1

b

1.1.1

d {{{BOOO}}}

2[edit]

e

!! html/parsoid

1

a

1.1

b

1.1.1

d {{{BOOO}}}

2

e

!! end # In this example, the template scope is mildly expanded to incorporate the # trailing newline after the transclusion since that is part of section 1.2.1 !! test Section wrapping with template-generated sections (good nesting 3) !! options notoc parsoid={ "wrapSections": true, "modes": ["wt2html", "wt2wt"] } !! wikitext =1= a {{1x|1= x ==1.1== b ==1.2== c ===1.2.1=== d }} =2= e !! html/php

1[edit]

a

x

1.1

b

1.2

c

1.2.1

d

2[edit]

e

!! html/parsoid

1

a

x

1.1

b

1.2

c

1.2.1

d

2

e

!! end # Because of section-wrapping and template-wrapping interactions, # the scope of the template is expanded so that the template markup # is valid in the presence of
tags. # This exercises the s1 is null scenario in the wrapSections code !! test Section wrapping with template-generated sections (bad nesting 1) !! options notoc parsoid={ "wrapSections": true } !! wikitext
a {{1x|1= =1= b }} c
!! html/php

a

1

b

c

!! html/parsoid

a

1

b

c

!! end # Because of section-wrapping and template-wrapping interactions, # the scope of the template is expanded so that the template markup # is valid in the presence of
tags. # This exercises the s1 is ancestor of s2 scenario in the wrapSections code !! test Section wrapping with template-generated sections (bad nesting 2) !! options notoc parsoid={ "wrapSections": true } !! wikitext =1= a {{1x|1= =2= b ==2.1== c }} d =3= e !! html/php

1[edit]

a

2

b

2.1

c

d

3[edit]

e

!! html/parsoid

1

a

2

b

2.1

c

d

3

e

!! end # Because of section-wrapping and template-wrapping interactions, # additional template wrappers are added to
tags # so that template wrapping semantics are valid whether section # tags are retained or stripped. But, the template scope can expand # greatly when accounting for section tags. # This exercises the s1 and s2 are in different subtrees scenario !! test Section wrapping with template-generated sections (bad nesting 3) !! options notoc parsoid={ "wrapSections": true, "modes": ["wt2html", "wt2wt"] } !! wikitext =1= a {{1x|1= ==1.2== b =2= c }} d =3= e !! html/php

1[edit]

a

1.2

b

2

c

d

3[edit]

e

!! html/parsoid

1

a

1.2

b

2

c

d

3

e

!! end !! test Section wrapping with uneditable lead section + div wrapping multiple sections !! options notoc parsoid={ "wrapSections": true } !! wikitext foo
=1= a ==1.1== b =2= c
=3= d ==3.1== e !! html/php

foo

1[edit]

a

1.1[edit]

b

2[edit]

c

3[edit]

d

3.1[edit]

e

!! html/parsoid

foo

1

a

1.1

b

2

c

3

d

3.1

e

!! end !! test Section wrapping with editable lead section + div overlapping multiple sections !! options notoc parsoid={ "wrapSections": true } !! wikitext foo =1= a
b ==1.1== c =2= d
e =3= f ==3.1== g !! html/php

foo

1[edit]

a

b

1.1[edit]

c

2[edit]

d

e

3[edit]

f

3.1[edit]

g

!! html/parsoid

foo

1

a

b

1.1

c

2

d

e

3

f

3.1

g

!! end !! test HTML header tags should also be wrapped in section tags (with section ids set to -1) !! options notoc parsoid={ "wrapSections": true } !! wikitext foo

a

=b=

c

=d= !! html/php

foo

a

b[edit]

c

d[edit]

!! html/parsoid

foo

a

b

c

d

!! end !! test Lead section containing only whitespace and comments. !! options notoc parsoid={ "wrapSections": true } !! wikitext =1= a =2= b !! html/php

1[edit]

a

2[edit]

b

!! html/parsoid

1

a

2

b

!! end !! test Pseudo-sections emitted by templates should have id -2 !! options notoc parsoid={ "wrapSections": true } !! wikitext foo {{1x|
==a== ==b==
}} !! html/php

foo

a

b

!! html/parsoid

foo

a

b

!! end !! test T213468: Transcluded sections don't get PHP section numbers !! options notoc parsoid={ "wrapSections": true } !! wikitext ==PHP section=1== {{1x|1= == This is counted as if it were section 2 == }} ==PHP section=3== !! html/php

PHP section=1[edit]

This is counted as if it were section 2

PHP section=3[edit]

!! html/parsoid

PHP section=1

This is counted as if it were section 2

PHP section=3

!! end !! test T213468: Corner cases in edit section ID assignment in tokenizer !! options notoc parsoid={ "wrapSections": true } !! config wgParserEnableLegacyMediaDOM=false !! wikitext ==PHP section=1== {{1x|Not a section| == This is counted as if it were section 2 == }} ==PHP section=3== {{3x_on_newline|1= == This is counted as if it were section 4 == }} ==PHP section=5== {{#tag:p|Not a section|data-ignored= == This is counted as if it were section 6 == }} ==PHP section=7== {{1x|1=Not a ==heading==}} ==PHP section=8== [[File:Foobar.jpg|thumb| ==This is section 9, even though it's in a caption== ]] ==PHP section=10== !! html/php

PHP section=1[edit]

Not a section

PHP section=3[edit]

This is counted as if it were section 4

This is counted as if it were section 4

This is counted as if it were section 4

PHP section=5[edit]

Not a section

PHP section=7[edit]

Not a ==heading==

PHP section=8[edit]

This is section 9, even though it's in a caption[edit]

PHP section=10[edit]

!! html/parsoid

PHP section=1

Not a section

PHP section=3

This is counted as if it were section 4

This is counted as if it were section 4

This is counted as if it were section 4

PHP section=5

Not a section

PHP section=7

Not a ==heading==

PHP section=8

This is section 9, even though it's in a caption

PHP section=10

!! end !! test T215628: Section numbering and and on a page !! options notoc parsoid={ "wrapSections": true } !! wikitext ==PHP section=1== ==PHP section=2== ==PHP section=3== ==This is not counted as section 4== ==PHP section=4== !! html/php

PHP section=1[edit]

PHP section=2[edit]

PHP section=3[edit]

PHP section=4[edit]

!! html/parsoid PARSOID HAS A BUG HERE: T215628 !! end !! test T236866: Ensure comments are handled correctly during section wrapping !! options notoc parsoid={ "wrapSections": true } !! wikitext {{1x|1= x ==boo== }} !! html/php

x

boo

!! html/parsoid

x

boo

!! end !! test T265737: 1. Relax section start requirements to reduce unnecessary conflicts between template and section boundaries !! options notoc parsoid={ "wrapSections": true } !! wikitext = x = {{Foobar1}} y !! html/php

x[edit]

bar[edit]

baz y

!! html/parsoid

x

bar

baz y

!! end !! test T265737: 2. Relax section start requirements to reduce unnecessary conflicts between template and section boundaries !! options notoc parsoid={ "wrapSections": true } !! wikitext = x = {{Foobar2}} y !! html/php

x[edit]


bar[edit]

baz y

!! html/parsoid

x

bar

baz y

!! end