Debian Codegraph @

vendor/wikimedia/parsoid/tests/parser/sectionWrappingParserTests.txt

raw
1 !! Version 2
2 ##
3 ## This file has tests for Parsoid's section-wrapping feature
4 ##
5
6 !! article
7 Template:Foobar1
8 !! text
9 <noinclude>{{1x|boo}}</noinclude>
10
11 == <noinclude>Foo</noinclude><includeonly>bar</includeonly> ==
12 baz
13 !! endarticle
14
15 !! article
16 Template:Foobar2
17 !! text
18 <!--Some comment-->
19 <!--Some comment-->
20 <noinclude>{{1x|boo}}</noinclude>
21 [[Category:BadTemplate]]
22 __NOTOC__
23
24 == <noinclude>Foo</noinclude><includeonly>bar</includeonly> ==
25 baz
26 !! endarticle
27
28 !! article
29 Template:1x
30 !! text
31 {{{1}}}
32 !! endarticle
33
34 !! article
35 Template:3x_on_newline
36 !! text
37 {{{1}}}
38 {{{1}}}
39 {{{1}}}
40 !! endarticle
41
42 !! test
43 Section wrapping for well-nested sections (no leading content)
44 !! options
45 notoc
46 parsoid={
47 "wrapSections": true
48 }
49 !! wikitext
50 =1=
51 a
52
53 =2=
54 b
55
56 ==2.1==
57 c
58
59 ==2.2==
60 d
61
62 ===2.2.1===
63 e
64
65 =3=
66 f
67 !! html/php
68
69 <h1><span class="mw-headline" id="1">1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: 1">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
70 <p>a
71 </p>
72 <h1><span class="mw-headline" id="2">2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
73 <p>b
74 </p>
75 <h2><span class="mw-headline" id="2.1">2.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: 2.1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
76 <p>c
77 </p>
78 <h2><span class="mw-headline" id="2.2">2.2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: 2.2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
79 <p>d
80 </p>
81 <h3><span class="mw-headline" id="2.2.1">2.2.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: 2.2.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
82 <p>e
83 </p>
84 <h1><span class="mw-headline" id="3">3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=6" title="Edit section: 3">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
85 <p>f
86 </p>
87 !! html/parsoid
88 <section data-mw-section-id="0"><meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="1"><h1 id="1" data-parsoid="{}">1</h1>
89 <p>a</p>
90
91 </section><section data-mw-section-id="2"><h1 id="2" data-parsoid="{}">2</h1>
92 <p>b</p>
93
94 <section data-mw-section-id="3"><h2 id="2.1" data-parsoid="{}">2.1</h2>
95 <p>c</p>
96
97 </section><section data-mw-section-id="4"><h2 id="2.2" data-parsoid="{}">2.2</h2>
98 <p>d</p>
99
100 <section data-mw-section-id="5"><h3 id="2.2.1" data-parsoid="{}">2.2.1</h3>
101 <p>e</p>
102
103 </section></section></section><section data-mw-section-id="6"><h1 id="3" data-parsoid="{}">3</h1>
104 <p>f</p>
105
106 </section>
107 !! end
108
109 !! test
110 Section wrapping for well-nested sections (with leading content)
111 !! options
112 notoc
113 parsoid={
114 "wrapSections": true
115 }
116 !! wikitext
117 Para 1.
118
119 Para 2 with a <div>nested in it</div>
120
121 Para 3.
122
123 =1=
124 a
125
126 =2=
127 b
128
129 ==2.1==
130 c
131 !! html/php
132 <p>Para 1.
133 </p><p>
134 Para 2 with a </p><div>nested in it</div>
135 <p>Para 3.
136 </p>
137 <h1><span class="mw-headline" id="1">1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: 1">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
138 <p>a
139 </p>
140 <h1><span class="mw-headline" id="2">2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
141 <p>b
142 </p>
143 <h2><span class="mw-headline" id="2.1">2.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: 2.1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
144 <p>c
145 </p>
146 !! html/parsoid
147 <section data-mw-section-id="0"><p>Para 1.</p>
148
149 <p>Para 2 with a </p><div>nested in it</div>
150
151 <p>Para 3.</p>
152
153 </section><section data-mw-section-id="1"><h1 id="1" data-parsoid="{}">1</h1>
154 <p>a</p>
155
156 </section><section data-mw-section-id="2"><h1 id="2" data-parsoid="{}">2</h1>
157 <p>b</p>
158
159 <section data-mw-section-id="3"><h2 id="2.1" data-parsoid="{}">2.1</h2>
160 <p>c</p>
161
162 </section></section>
163 !! end
164
165 !! test
166 Section wrapping with template-generated sections (good nesting 1)
167 !! options
168 notoc
169 parsoid={
170 "wrapSections": true
171 }
172 !! wikitext
173 =1=
174 a
175
176 {{1x|1=
177 ==1.1==
178 b
179 }}
180 ==1.2==
181 c
182
183 =2=
184 d
185 !! html/php
186
187 <h1><span class="mw-headline" id="1">1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: 1">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
188 <p>a
189 </p>
190 <h2><span class="mw-headline" id="1.1">1.1</span></h2>
191 <p>b
192 </p>
193 <h2><span class="mw-headline" id="1.2">1.2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: 1.2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
194 <p>c
195 </p>
196 <h1><span class="mw-headline" id="2">2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
197 <p>d
198 </p>
199 !! html/parsoid
200 <section data-mw-section-id="0"><meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="1"><h1 id="1" data-parsoid="{}">1</h1>
201 <p>a</p>
202
203 <section data-mw-section-id="-1"><h2 about="#mwt1" typeof="mw:Transclusion" id="1.1" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"==1.1==\nb"}},"i":0}}]}'>1.1</h2><span about="#mwt1">
204 </span><p about="#mwt1">b</p>
205 </section><section data-mw-section-id="3"><h2 id="1.2" data-parsoid="{}">1.2</h2>
206 <p>c</p>
207
208 </section></section><section data-mw-section-id="4"><h1 id="2" data-parsoid="{}">2</h1>
209 <p>d</p></section>
210 !! end
211
212 # In this example, the template scope is mildly expanded to incorporate the
213 # trailing newline after the transclusion since that is part of section 1.1.1
214 !! test
215 Section wrapping with template-generated sections (good nesting 2)
216 !! options
217 notoc
218 parsoid={
219 "wrapSections": true,
220 "modes": ["wt2html", "wt2wt"]
221 }
222 !! wikitext
223 =1=
224 a
225
226 {{1x|1=
227 ==1.1==
228 b
229 ===1.1.1===
230 d
231 }}
232 {{{BOOO}}} <!--needed to exercise templatearg code path in collapseWrappers-->
233 =2=
234 e
235 !! html/php
236
237 <h1><span class="mw-headline" id="1">1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: 1">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
238 <p>a
239 </p>
240 <h2><span class="mw-headline" id="1.1">1.1</span></h2>
241 <p>b
242 </p>
243 <h3><span class="mw-headline" id="1.1.1">1.1.1</span></h3>
244 <p>d
245 {{{BOOO}}}
246 </p>
247 <h1><span class="mw-headline" id="2">2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
248 <p>e
249 </p>
250 !! html/parsoid
251 <section data-mw-section-id="0"><meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="1"><h1 id="1">1</h1>
252 <p>a</p>
253
254 <section data-mw-section-id="-1" about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}],[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"==1.1==\nb\n===1.1.1===\nd"}},"i":0}},"\n",{"templatearg":{"target":{"wt":"BOOO"},"params":{},"i":1}}," &lt;!--needed to exercise templatearg code path in collapseWrappers-->\n"]}'><h2 about="#mwt1" typeof="mw:Transclusion" id="1.1" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}],[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"==1.1==\nb\n===1.1.1===\nd"}},"i":0}},"\n",{"templatearg":{"target":{"wt":"BOOO"},"params":{},"i":1}}]}'>1.1</h2><span about="#mwt1">
255 </span><p about="#mwt1">b</p><span about="#mwt1">
256 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.1.1">1.1.1</h3><span about="#mwt1">
257 </span><p about="#mwt1">d
258 {{{BOOO}}}</p> <!--needed to exercise templatearg code path in collapseWrappers-->
259 </section></section></section><section data-mw-section-id="4"><h1 id="2">2</h1>
260 <p>e</p></section>
261 !! end
262
263 # In this example, the template scope is mildly expanded to incorporate the
264 # trailing newline after the transclusion since that is part of section 1.2.1
265 !! test
266 Section wrapping with template-generated sections (good nesting 3)
267 !! options
268 notoc
269 parsoid={
270 "wrapSections": true,
271 "modes": ["wt2html", "wt2wt"]
272 }
273 !! wikitext
274 =1=
275 a
276
277 {{1x|1=
278 x
279 ==1.1==
280 b
281 ==1.2==
282 c
283 ===1.2.1===
284 d
285 }}
286 =2=
287 e
288 !! html/php
289
290 <h1><span class="mw-headline" id="1">1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: 1">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
291 <p>a
292 </p><p>x
293 </p>
294 <h2><span class="mw-headline" id="1.1">1.1</span></h2>
295 <p>b
296 </p>
297 <h2><span class="mw-headline" id="1.2">1.2</span></h2>
298 <p>c
299 </p>
300 <h3><span class="mw-headline" id="1.2.1">1.2.1</span></h3>
301 <p>d
302 </p>
303 <h1><span class="mw-headline" id="2">2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
304 <p>e
305 </p>
306 !! html/parsoid
307 <section data-mw-section-id="0"><meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="1" about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":["=1=\na\n\n",{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"x\n==1.1==\nb\n==1.2==\nc\n===1.2.1===\nd"}},"i":0}},"\n"]}'><h1 id="1"> 1 </h1>
308 <p>a</p>
309
310 <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"x\n==1.1==\nb\n==1.2==\nc\n===1.2.1===\nd"}},"i":0}}]}'>x</p><span about="#mwt1">
311 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.1">1.1</h2><span about="#mwt1">
312 </span><p about="#mwt1">b</p><span about="#mwt1">
313 </span></section><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="1.2">1.2</h2><span about="#mwt1">
314 </span><p about="#mwt1">c</p><span about="#mwt1">
315 </span><section data-mw-section-id="-1" about="#mwt1"><h3 about="#mwt1" id="1.2.1">1.2.1</h3><span about="#mwt1">
316 </span><p about="#mwt1">d</p>
317 </section></section></section><section data-mw-section-id="5"><h1 id="2">2</h1>
318 <p>e</p></section>
319 !! end
320
321 # Because of section-wrapping and template-wrapping interactions,
322 # the scope of the template is expanded so that the template markup
323 # is valid in the presence of <section> tags.
324 # This exercises the s1 is null scenario in the wrapSections code
325 !! test
326 Section wrapping with template-generated sections (bad nesting 1)
327 !! options
328 notoc
329 parsoid={
330 "wrapSections": true
331 }
332 !! wikitext
333 <div>
334 a
335
336 {{1x|1=
337 =1=
338 b
339 }}
340
341 c
342 </div>
343 !! html/php
344 <div>
345 <p>a
346 </p>
347 <h1><span class="mw-headline" id="1">1</span></h1>
348 <p>b
349 </p><p>c
350 </p>
351 </div>
352 !! html/parsoid
353 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'>
354 <p>a</p>
355
356 <section data-mw-section-id="-1"><h1 about="#mwt1" typeof="mw:Transclusion" id="1" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"=1=\nb"}},"i":0}}]}'>1</h1><span about="#mwt1">
357 </span><p about="#mwt1">b</p>
358
359 <p>c</p>
360 </section></div></section>
361 !! end
362
363 # Because of section-wrapping and template-wrapping interactions,
364 # the scope of the template is expanded so that the template markup
365 # is valid in the presence of <section> tags.
366 # This exercises the s1 is ancestor of s2 scenario in the wrapSections code
367 !! test
368 Section wrapping with template-generated sections (bad nesting 2)
369 !! options
370 notoc
371 parsoid={
372 "wrapSections": true
373 }
374 !! wikitext
375 =1=
376 a
377
378 {{1x|1=
379 =2=
380 b
381 ==2.1==
382 c
383 }}
384
385 d
386
387 =3=
388 e
389 !! html/php
390
391 <h1><span class="mw-headline" id="1">1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: 1">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
392 <p>a
393 </p>
394 <h1><span class="mw-headline" id="2">2</span></h1>
395 <p>b
396 </p>
397 <h2><span class="mw-headline" id="2.1">2.1</span></h2>
398 <p>c
399 </p><p>d
400 </p>
401 <h1><span class="mw-headline" id="3">3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: 3">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
402 <p>e
403 </p>
404 !! html/parsoid
405 <section data-mw-section-id="0"><meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="1"><h1 id="1" data-parsoid="{}">1</h1>
406 <p>a</p>
407
408 </section><section data-mw-section-id="-1" about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"=2=\nb\n==2.1==\nc"}},"i":0}},"\n\nd\n\n"]}'><h1 about="#mwt1" typeof="mw:Transclusion" id="2" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"=2=\nb\n==2.1==\nc"}},"i":0}}]}'>2</h1><span about="#mwt1">
409 </span><p about="#mwt1">b</p><span about="#mwt1">
410 </span><section data-mw-section-id="-1" about="#mwt1"><h2 about="#mwt1" id="2.1">2.1</h2><span about="#mwt1">
411 </span><p about="#mwt1">c</p>
412
413 <p>d</p>
414
415 </section></section><section data-mw-section-id="4"><h1 id="3" data-parsoid="{}">3</h1>
416 <p>e</p></section>
417 !! end
418
419 # Because of section-wrapping and template-wrapping interactions,
420 # additional template wrappers are added to <section> tags
421 # so that template wrapping semantics are valid whether section
422 # tags are retained or stripped. But, the template scope can expand
423 # greatly when accounting for section tags.
424 # This exercises the s1 and s2 are in different subtrees scenario
425 !! test
426 Section wrapping with template-generated sections (bad nesting 3)
427 !! options
428 notoc
429 parsoid={
430 "wrapSections": true,
431 "modes": ["wt2html", "wt2wt"]
432 }
433 !! wikitext
434 =1=
435 a
436
437 {{1x|1=
438 ==1.2==
439 b
440 =2=
441 c
442 }}
443
444 d
445
446 =3=
447 e
448 !! html/php
449
450 <h1><span class="mw-headline" id="1">1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: 1">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
451 <p>a
452 </p>
453 <h2><span class="mw-headline" id="1.2">1.2</span></h2>
454 <p>b
455 </p>
456 <h1><span class="mw-headline" id="2">2</span></h1>
457 <p>c
458 </p><p>d
459 </p>
460 <h1><span class="mw-headline" id="3">3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: 3">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
461 <p>e
462 </p>
463 !! html/parsoid
464 <section data-mw-section-id="0"><meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="1" about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":["=1=\na\n\n",{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"==1.2==\nb\n=2=\nc"}},"i":0}},"\n\nd\n\n"]}'><h1 id="1">1</h1>
465 <p>a</p>
466
467 <section data-mw-section-id="-1"><h2 about="#mwt1" typeof="mw:Transclusion" id="1.2" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"==1.2==\nb\n=2=\nc"}},"i":0}}]}'>1.2</h2><span about="#mwt1">
468 </span><p about="#mwt1">b</p><span about="#mwt1">
469 </span></section></section><section data-mw-section-id="-1" about="#mwt1"><h1 about="#mwt1" id="2">2</h1><span about="#mwt1">
470 </span><p about="#mwt1">c</p>
471
472 <p>d</p>
473 </section><section data-mw-section-id="4"><h1 id="3">3</h1>
474 <p>e</p></section>
475 !! end
476
477 !! test
478 Section wrapping with uneditable lead section + div wrapping multiple sections
479 !! options
480 notoc
481 parsoid={
482 "wrapSections": true
483 }
484 !! wikitext
485 foo
486
487 <div style="border:1px solid red;">
488 =1=
489 a
490
491 ==1.1==
492 b
493
494 =2=
495 c
496 </div>
497
498 =3=
499 d
500
501 ==3.1==
502 e
503 !! html/php
504 <p>foo
505 </p>
506 <div style="border:1px solid red;">
507
508 <h1><span class="mw-headline" id="1">1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: 1">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
509 <p>a
510 </p>
511 <h2><span class="mw-headline" id="1.1">1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
512 <p>b
513 </p>
514 <h1><span class="mw-headline" id="2">2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
515 <p>c
516 </p>
517 </div>
518 <h1><span class="mw-headline" id="3">3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: 3">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
519 <p>d
520 </p>
521 <h2><span class="mw-headline" id="3.1">3.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: 3.1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
522 <p>e
523 </p>
524 !! html/parsoid
525 <section data-mw-section-id="-1"><p>foo</p>
526
527 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
528 <section data-mw-section-id="-2"><meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="1"><h1 id="1" data-parsoid="{}">1</h1>
529 <p>a</p>
530
531 <section data-mw-section-id="2"><h2 id="1.1" data-parsoid="{}">1.1</h2>
532 <p>b</p>
533
534 </section></section><section data-mw-section-id="-1"><h1 id="2" data-parsoid="{}">2</h1>
535 <p>c</p>
536 </section></div>
537
538 </section><section data-mw-section-id="4"><h1 id="3" data-parsoid="{}">3</h1>
539 <p>d</p>
540
541 <section data-mw-section-id="5"><h2 id="3.1" data-parsoid="{}">3.1</h2>
542 <p>e</p>
543 </section></section>
544 !! end
545
546 ## Regression test for Parsoid
547 !! test
548 TOC insertion with div wrapping first heading as first child
549 !! options
550 notoc
551 parsoid={
552 "modes": ["wt2html", "wt2wt", "html2html"],
553 "wrapSections": true
554 }
555 !! wikitext
556 hi
557
558 <div><h3>ho</h3>
559 </div>
560
561 ==hi==
562 ==ho==
563 ==hi==
564 ==ho==
565 !! html/php
566 <p>hi
567 </p>
568 <div>
569 <h3><span class="mw-headline" id="ho">ho</span></h3>
570 </div>
571 <h2><span class="mw-headline" id="hi">hi</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: hi">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
572 <h2><span class="mw-headline" id="ho_2">ho</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: ho">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
573 <h2><span class="mw-headline" id="hi_2">hi</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: hi">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
574 <h2><span class="mw-headline" id="ho_3">ho</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: ho">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
575 !! html/parsoid
576 <section data-mw-section-id="-1"><p>hi</p>
577
578 </section><section data-mw-section-id="-2"><div data-parsoid='{"stx":"html"}'><section data-mw-section-id="-2"><meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="-1"><h3 id="ho" data-parsoid='{"stx":"html"}'>ho</h3>
579 </section></div>
580
581 </section><section data-mw-section-id="1"><h2 id="hi">hi</h2>
582 </section><section data-mw-section-id="2"><h2 id="ho_2">ho</h2>
583 </section><section data-mw-section-id="3"><h2 id="hi_2">hi</h2>
584 </section><section data-mw-section-id="4"><h2 id="ho_3">ho</h2></section>
585 !! end
586
587 !! test
588 Section wrapping with editable lead section + div overlapping multiple sections
589 !! options
590 notoc
591 parsoid={
592 "wrapSections": true
593 }
594 !! wikitext
595 foo
596
597 =1=
598 a
599 <div style="border:1px solid red;">
600 b
601
602 ==1.1==
603 c
604
605 =2=
606 d
607 </div>
608 e
609
610 =3=
611 f
612
613 ==3.1==
614 g
615 !! html/php
616 <p>foo
617 </p>
618
619 <h1><span class="mw-headline" id="1">1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: 1">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
620 <p>a
621 </p>
622 <div style="border:1px solid red;">
623 <p>b
624 </p>
625 <h2><span class="mw-headline" id="1.1">1.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
626 <p>c
627 </p>
628 <h1><span class="mw-headline" id="2">2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
629 <p>d
630 </p>
631 </div>
632 <p>e
633 </p>
634 <h1><span class="mw-headline" id="3">3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: 3">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
635 <p>f
636 </p>
637 <h2><span class="mw-headline" id="3.1">3.1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: 3.1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
638 <p>g
639 </p>
640 !! html/parsoid
641 <section data-mw-section-id="0"><p>foo</p>
642
643 <meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="-1"><h1 id="1" data-parsoid="{}">1</h1>
644 <p>a</p>
645 </section><section data-mw-section-id="-2"><div style="border:1px solid red;">
646 <p>b</p>
647
648 <section data-mw-section-id="2"><h2 id="1.1" data-parsoid="{}">1.1</h2>
649 <p>c</p>
650
651 </section><section data-mw-section-id="-1"><h1 id="2" data-parsoid="{}">2</h1>
652 <p>d</p>
653 </section></div>
654 <p>e</p>
655
656 </section><section data-mw-section-id="4"><h1 id="3" data-parsoid="{}">3</h1>
657 <p>f</p>
658
659 <section data-mw-section-id="5"><h2 id="3.1" data-parsoid="{}">3.1</h2>
660 <p>g</p>
661 </section></section>
662 !! end
663
664 !! test
665 HTML header tags should also be wrapped in section tags (with section ids set to -1)
666 !! options
667 notoc
668 parsoid={
669 "wrapSections": true
670 }
671 !! wikitext
672 foo
673
674 <h1>a</h1>
675
676 =b=
677
678 <h1>c</h1>
679
680 =d=
681 !! html/php
682 <p>foo
683 </p>
684
685 <h1><span class="mw-headline" id="a">a</span></h1>
686 <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>
687 <h1><span class="mw-headline" id="c">c</span></h1>
688 <h1><span class="mw-headline" id="d">d</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: d">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
689 !! html/parsoid
690 <section data-mw-section-id="0"><p>foo</p>
691
692 <meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="-1"><h1 id="a" data-parsoid='{"stx":"html"}'>a</h1>
693
694 </section><section data-mw-section-id="1"><h1 id="b" data-parsoid="{}">b</h1>
695
696 </section><section data-mw-section-id="-1"><h1 id="c" data-parsoid='{"stx":"html"}'>c</h1>
697
698 </section><section data-mw-section-id="2"><h1 id="d" data-parsoid="{}">d</h1></section>
699 !! end
700
701 !! test
702 Lead section containing only whitespace and comments.
703 !! options
704 notoc
705 parsoid={
706 "wrapSections": true
707 }
708 !! wikitext
709
710 <!-- this is a comment, presumably significant to editors -->
711 =1=
712 a
713
714 =2=
715 b
716 !! html/php
717 <h1><span class="mw-headline" id="1">1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: 1">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
718 <p>a
719 </p>
720 <h1><span class="mw-headline" id="2">2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
721 <p>b
722 </p>
723 !! html/parsoid
724 <section data-mw-section-id="0">
725 <!-- this is a comment, presumably significant to editors -->
726 </section><section data-mw-section-id="1"><h1 id="1" data-parsoid="{}">1</h1>
727 <p>a</p>
728
729 </section><section data-mw-section-id="2"><h1 id="2" data-parsoid="{}">2</h1>
730 <p>b</p>
731 </section>
732 !! end
733
734 !! test
735 Pseudo-sections emitted by templates should have id -2
736 !! options
737 notoc
738 parsoid={
739 "wrapSections": true
740 }
741 !! wikitext
742 foo
743 {{1x|<div>
744 ==a==
745 ==b==
746 </div>
747 }}
748 !! html/php
749 <p>foo
750 </p>
751 <div>
752 <h2><span class="mw-headline" id="a">a</span></h2>
753 <h2><span class="mw-headline" id="b">b</span></h2>
754 </div>
755 !! html/parsoid
756 <section data-mw-section-id="-1"><p>foo</p>
757 </section><section data-mw-section-id="-2"><div about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"stx":"html","pi":[[{"k":"1"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;div>\n==a==\n==b==\n&lt;/div>\n"}},"i":0}}]}'>
758 <section data-mw-section-id="-1"><h2 id="a">a</h2>
759 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
760 </section></div><span about="#mwt1">
761 </span></section>
762 !! end
763
764 !! test
765 T213468: Transcluded sections don't get PHP section numbers
766 !! options
767 notoc
768 parsoid={
769 "wrapSections": true
770 }
771 !! wikitext
772 ==PHP section=1==
773 {{1x|1=
774 == This is counted as if it were section 2 ==
775 }}
776 ==PHP section=3==
777 !! html/php
778 <h2><span class="mw-headline" id="PHP_section.3D1">PHP section=1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: PHP section=1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
779 <h2><span class="mw-headline" id="This_is_counted_as_if_it_were_section_2">This is counted as if it were section 2</span></h2>
780 <h2><span class="mw-headline" id="PHP_section.3D3">PHP section=3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: PHP section=3">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
781 !! html/parsoid
782 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h2 id="PHP_section=1" data-parsoid="{}"><span id="PHP_section.3D1" typeof="mw:FallbackId"></span>PHP section=1</h2>
783 </section><section data-mw-section-id="-1"><h2 about="#mwt1" typeof="mw:Transclusion" id="This_is_counted_as_if_it_were_section_2" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"== This is counted as if it were section 2 =="}},"i":0}}]}'>This is counted as if it were section 2</h2>
784 </section><section data-mw-section-id="3"><h2 id="PHP_section=3" data-parsoid="{}"><span id="PHP_section.3D3" typeof="mw:FallbackId"></span>PHP section=3</h2></section>
785 !! end
786
787 !! test
788 T213468: Corner cases in edit section ID assignment in tokenizer
789 !! options
790 notoc
791 parsoid={
792 "wrapSections": true
793 }
794 !! config
795 wgParserEnableLegacyMediaDOM=false
796 !! wikitext
797 ==PHP section=1==
798 {{1x|Not a section|
799 == This is counted as if it were section 2 ==
800 }}
801
802 ==PHP section=3==
803 {{3x_on_newline|1=
804 == This is counted as if it were section 4 ==
805 }}
806 ==PHP section=5==
807 {{#tag:p|Not a section|data-ignored=
808 == This is counted as if it were section 6 ==
809 }}
810 ==PHP section=7==
811 {{1x|1=Not a ==heading==}}
812
813 ==PHP section=8==
814 [[File:Foobar.jpg|thumb|
815 ==This is section 9, even though it's in a caption==
816 ]]
817 ==PHP section=10==
818 !! html/php
819
820 <h2><span class="mw-headline" id="PHP_section.3D1">PHP section=1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: PHP section=1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
821 <p>Not a section
822 </p>
823 <h2><span class="mw-headline" id="PHP_section.3D3">PHP section=3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: PHP section=3">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
824 <h2><span class="mw-headline" id="This_is_counted_as_if_it_were_section_4">This is counted as if it were section 4</span></h2>
825 <h2><span class="mw-headline" id="This_is_counted_as_if_it_were_section_4_2">This is counted as if it were section 4</span></h2>
826 <h2><span class="mw-headline" id="This_is_counted_as_if_it_were_section_4_3">This is counted as if it were section 4</span></h2>
827 <h2><span class="mw-headline" id="PHP_section.3D5">PHP section=5</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=5" title="Edit section: PHP section=5">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
828 <p data-ignored="== This is counted as if it were section 6 ==">Not a section</p>
829 <h2><span class="mw-headline" id="PHP_section.3D7">PHP section=7</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=7" title="Edit section: PHP section=7">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
830 <p>Not a ==heading==
831 </p>
832 <h2><span class="mw-headline" id="PHP_section.3D8">PHP section=8</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=8" title="Edit section: PHP section=8">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
833 <figure class="mw-default-size" typeof="mw:File/Thumb"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" decoding="async" width="180" height="20" class="mw-file-element" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" /></a><figcaption> <h2><span class="mw-headline" id="This_is_section_9.2C_even_though_it.27s_in_a_caption">This is section 9, even though it's in a caption</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=9" title="Edit section: This is section 9, even though it&#39;s in a caption">edit</a><span class="mw-editsection-bracket">]</span></span></h2> </figcaption></figure>
834 <h2><span class="mw-headline" id="PHP_section.3D10">PHP section=10</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=10" title="Edit section: PHP section=10">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
835 !! html/parsoid
836 <section data-mw-section-id="0"><meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="1"><h2 id="PHP_section=1" data-parsoid="{}"><span id="PHP_section.3D1" typeof="mw:FallbackId"></span>PHP section=1</h2>
837 <p><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"},{"k":"2"}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"Not a section"},"2":{"wt":"\n== This is counted as if it were section 2 ==\n"}},"i":0}}]}'>Not a section</span></p>
838 </section><section data-mw-section-id="3"><h2 id="PHP_section=3" data-parsoid="{}"><span id="PHP_section.3D3" typeof="mw:FallbackId"></span>PHP section=3</h2>
839 </section><section data-mw-section-id="-1" about="#mwt5" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"3x_on_newline","href":"./Template:3x_on_newline"},"params":{"1":{"wt":"== This is counted as if it were section 4 =="}},"i":0}},"\n"]}'><h2 about="#mwt2" typeof="mw:Transclusion" id="This_is_counted_as_if_it_were_section_4" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"3x_on_newline","href":"./Template:3x_on_newline"},"params":{"1":{"wt":"== This is counted as if it were section 4 =="}},"i":0}}]}'>This is counted as if it were section 4</h2><span about="#mwt2">
840 </span></section><section data-mw-section-id="-1" about="#mwt5"><h2 about="#mwt2" id="This_is_counted_as_if_it_were_section_4_2">This is counted as if it were section 4</h2><span about="#mwt2">
841 </span></section><section data-mw-section-id="-1" about="#mwt5"><h2 about="#mwt2" id="This_is_counted_as_if_it_were_section_4_3">This is counted as if it were section 4</h2>
842 </section><section data-mw-section-id="5"><h2 id="PHP_section=5" data-parsoid="{}"><span id="PHP_section.3D5" typeof="mw:FallbackId"></span>PHP section=5</h2>
843 <p data-ignored=" This is counted as if it were section 6 " about="#mwt3" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1"},{"k":"data-ignored","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"#tag:p","function":"tag"},"params":{"1":{"wt":"Not a section"},"data-ignored":{"wt":"== This is counted as if it were section 6 =="}},"i":0}}]}'>Not a section</p>
844 </section><section data-mw-section-id="7"><h2 id="PHP_section=7" data-parsoid="{}"><span id="PHP_section.3D7" typeof="mw:FallbackId"></span>PHP section=7</h2>
845 <p><span about="#mwt4" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","named":true}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"Not a ==heading=="}},"i":0}}]}'>Not a ==heading==</span></p>
846 </section><section data-mw-section-id="8"><h2 id="PHP_section=8" data-parsoid="{}"><span id="PHP_section.3D8" typeof="mw:FallbackId"></span>PHP section=8</h2>
847 <figure class="mw-default-size" typeof="mw:File/Thumb" data-parsoid='{"optList":[{"ck":"thumbnail","ak":"thumb"},{"ck":"caption","ak":"\n==This is section 9, even though it&apos;s in a caption==\n"}]}'><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/thumb/3/3a/Foobar.jpg/180px-Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="20" width="180" srcset="http://example.com/images/thumb/3/3a/Foobar.jpg/270px-Foobar.jpg 1.5x, http://example.com/images/thumb/3/3a/Foobar.jpg/360px-Foobar.jpg 2x" class="mw-file-element"/></a><figcaption>
848 <section data-mw-section-id="-1"><h2 id="This_is_section_9,_even_though_it's_in_a_caption" data-parsoid="{}"><span id="This_is_section_9.2C_even_though_it.27s_in_a_caption" typeof="mw:FallbackId"></span>This is section 9, even though it's in a caption</h2>
849 </section></figcaption></figure>
850 </section><section data-mw-section-id="10"><h2 id="PHP_section=10" data-parsoid="{}"><span id="PHP_section.3D10" typeof="mw:FallbackId" data-parsoid='{}'></span>PHP section=10</h2></section>
851 !! end
852
853 !! test
854 T215628: Section numbering and <includeonly> and <noinclude> on a page
855 !! options
856 notoc
857 parsoid={
858 "wrapSections": true
859 }
860 !! wikitext
861 ==PHP section=1==
862 <noinclude>
863 ==PHP section=2==
864 </noinclude>
865 ==PHP section=3==
866 <includeonly>
867 ==This is not counted as section 4==
868 </includeonly>
869 ==PHP section=4==
870 !! html/php
871
872 <h2><span class="mw-headline" id="PHP_section.3D1">PHP section=1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: PHP section=1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
873 <h2><span class="mw-headline" id="PHP_section.3D2">PHP section=2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=2" title="Edit section: PHP section=2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
874 <h2><span class="mw-headline" id="PHP_section.3D3">PHP section=3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=3" title="Edit section: PHP section=3">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
875 <h2><span class="mw-headline" id="PHP_section.3D4">PHP section=4</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=4" title="Edit section: PHP section=4">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
876 !! html/parsoid
877 PARSOID HAS A BUG HERE: T215628
878 !! end
879
880 !! test
881 T236866: Ensure comments are handled correctly during section wrapping
882 !! options
883 notoc
884 parsoid={
885 "wrapSections": true
886 }
887 !! wikitext
888 <!-- 내 (use a multi-byte char to demonstrate effect of bad offsets) -->
889 {{1x|1=
890 x
891 ==boo==
892 }}
893 !! html/php
894 <p>x
895 </p>
896 <h2><span class="mw-headline" id="boo">boo</span></h2>
897 !! html/parsoid
898 <section data-mw-section-id="0" about="#mwt2" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":["&lt;!-- 내 (use a multi-byte char to demonstrate effect of bad offsets) -->\n",{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"x\n==boo=="}},"i":0}}]}'><!-- 내 (use a multi&#x2D;byte char to demonstrate effect of bad offsets) -->
899 <p about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["","","\n","\n"]}]]}' data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"x\n==boo=="}},"i":0}}]}'>x</p><span about="#mwt1">
900 </span></section><section data-mw-section-id="-1" about="#mwt2"><h2 about="#mwt1" id="boo">boo</h2></section>
901 !! end
902
903 !! test
904 T265737: 1. Relax section start requirements to reduce unnecessary conflicts between template and section boundaries
905 !! options
906 notoc
907 parsoid={
908 "wrapSections": true
909 }
910 !! wikitext
911 = x =
912 {{Foobar1}}
913 y
914 !! html/php
915 <h1><span class="mw-headline" id="x">x</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: x">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
916 <h2><span class="mw-headline" id="bar">bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Foobar1&amp;action=edit&amp;section=T-1" title="Edit section: bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
917 <p>baz
918 y
919 </p>
920 !! html/parsoid
921 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="x">x</h1>
922 <section data-mw-section-id="-1"><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"Foobar1","href":"./Template:Foobar1"},"params":{},"i":0}},"\ny"]}'>
923
924 </span><h2 about="#mwt1" id="bar">bar</h2><span about="#mwt1">
925 </span><p about="#mwt1">baz
926 y</p></section></section>
927 !! end
928
929 !! test
930 T265737: 2. Relax section start requirements to reduce unnecessary conflicts between template and section boundaries
931 !! options
932 notoc
933 parsoid={
934 "wrapSections": true
935 }
936 !! wikitext
937 = x =
938 {{Foobar2}}
939 y
940 !! html/php
941 <h1><span class="mw-headline" id="x">x</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Parser_test&amp;action=edit&amp;section=1" title="Edit section: x">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
942 <p><br />
943 </p>
944 <h2><span class="mw-headline" id="bar">bar</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Foobar2&amp;action=edit&amp;section=T-1" title="Edit section: bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
945 <p>baz
946 y
947 </p>
948 !! html/parsoid
949 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h1 id="x">x</h1>
950 <section data-mw-section-id="-1"><span about="#mwt1" typeof="mw:Transclusion" data-parsoid='{"pi":[[]]}' data-mw='{"parts":[{"template":{"target":{"wt":"Foobar2","href":"./Template:Foobar2"},"params":{},"i":0}},"\ny"]}'><!--Some comment--></span><span about="#mwt1">
951 </span><span about="#mwt1"><!--Some comment--></span><span about="#mwt1">
952
953 </span><link rel="mw:PageProp/Category" href="./Category:BadTemplate" about="#mwt1"/><span about="#mwt1">
954 </span><meta property="mw:PageProp/notoc" about="#mwt1"/><span about="#mwt1">
955
956 </span><h2 about="#mwt1" id="bar">bar</h2><span about="#mwt1">
957 </span><p about="#mwt1">baz
958 y</p></section></section>
959 !! end