!! 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
!! end
!! test
Section wrapping for well-nested sections (with leading content)
!! options
notoc
parsoid={
"wrapSections": true
}
!! wikitext
Para 1.
Para 2 with a
!! 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
!! 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
!! 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
!! 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
!! 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
!! end
!! test
Section wrapping with uneditable lead section + div wrapping multiple sections
!! options
notoc
parsoid={
"wrapSections": true
}
!! wikitext
foo
!! end
!! test
Section wrapping with editable lead section + div overlapping multiple sections
!! options
notoc
parsoid={
"wrapSections": true
}
!! wikitext
foo
=1=
a
!! 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
!! end
!! test
Lead section containing only whitespace and comments.
!! options
notoc
parsoid={
"wrapSections": true
}
!! wikitext
=1=
a
=2=
b
!! html/php
!! 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
!! 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
!! 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
!! 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
!! 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