Debian Codegraph @

tests/parser/legacyHeadings.txt

raw
1 # This file has tests to verify the following:
2 # - TOC section metadata output for wikitext snippets
3 # - Behavior of various *toc* magic words
4 # - Various edge cases related to heading parsing and TOC behavior
5 # (special chars, language variants, entities, bdi chars, etc.)
6 #
7 # NOTE about data-parsoid in html/parsoid
8 # - html/parsoid sections have data-parsoid="{}" to eliminate unnecessary
9 # html2wt failures because of normalization
10 # - We could strip them eithre by marking those tests wt2html, wt2wt only
11
12 !! options
13 version=2
14 parsoid-compatible=wt2html,wt2wt
15 !! end
16
17 !! article
18 Main Page
19 !! text
20 blah blah
21 !! endarticle
22
23 !! article
24 Template:1x
25 !! text
26 {{{1}}}
27 !! endarticle
28
29 !! article
30 Template:Test
31 !! text
32 ==th2==
33 ===th2.1===
34 !! endarticle
35
36 !! test
37 Basic test
38 !! options
39 nohtml
40 showtocdata
41 parsoid={
42 "modes": [ "wt2html" ],
43 "wrapSections": true
44 }
45 !! config
46 wgParserEnableLegacyHeadingDOM=true
47 !! wikitext
48 ==h1==
49 ===h1.1===
50 ==h2==
51 ===h2.1===
52 ====h2.1.1====
53 ===h2.2===
54 ====h2.2.1====
55 ====h2.2.2====
56 ==h3==
57 !! metadata
58 Sections:
59 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:h1 line:h1
60 h3 index:2 toclevel:2 number:1.1 title:Parser_test off:7 anchor/linkAnchor:h1.1 line:h1.1
61 h2 index:3 toclevel:1 number:2 title:Parser_test off:18 anchor/linkAnchor:h2 line:h2
62 h3 index:4 toclevel:2 number:2.1 title:Parser_test off:25 anchor/linkAnchor:h2.1 line:h2.1
63 h4 index:5 toclevel:3 number:2.1.1 title:Parser_test off:36 anchor/linkAnchor:h2.1.1 line:h2.1.1
64 h3 index:6 toclevel:2 number:2.2 title:Parser_test off:51 anchor/linkAnchor:h2.2 line:h2.2
65 h4 index:7 toclevel:3 number:2.2.1 title:Parser_test off:62 anchor/linkAnchor:h2.2.1 line:h2.2.1
66 h4 index:8 toclevel:3 number:2.2.2 title:Parser_test off:77 anchor/linkAnchor:h2.2.2 line:h2.2.2
67 h2 index:9 toclevel:1 number:3 title:Parser_test off:92 anchor/linkAnchor:h3 line:h3
68 !! end
69
70 !! test
71 HTML headings should get TOC entries with some empty properties
72 !! options
73 nohtml
74 showtocdata
75 parsoid={
76 "modes": [ "wt2html" ],
77 "wrapSections": true
78 }
79 !! config
80 wgParserEnableLegacyHeadingDOM=true
81 !! wikitext
82 ==a==
83 <h2>b</h2>
84 <h3>c</h3>
85 ===d===
86 <h2>e</h2>
87 !! metadata
88 Sections:
89 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:a line:a
90 h2 index: toclevel:1 number:2 title:NULL off:NULL anchor/linkAnchor:b line:b
91 h3 index: toclevel:2 number:2.1 title:NULL off:NULL anchor/linkAnchor:c line:c
92 h3 index:2 toclevel:2 number:2.2 title:Parser_test off:28 anchor/linkAnchor:d line:d
93 h2 index: toclevel:1 number:3 title:NULL off:NULL anchor/linkAnchor:e line:e
94 !! end
95
96 !! test
97 Literal html heading from template
98 !! options
99 showtocdata
100 parsoid={
101 "modes": [ "wt2html" ],
102 "wrapSections": true
103 }
104 !! config
105 wgParserEnableLegacyHeadingDOM=true
106 !! wikitext
107 {{1x|
108 <h2>hi</h2>
109 ho
110 }}
111 !! html/php
112 <h2><span class="mw-headline" id="hi">hi</span></h2>
113 <p>ho
114 </p>
115 !! html/parsoid
116 <section data-mw-section-id="0"></section><section data-mw-section-id="-1"><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"\n&lt;h2>hi&lt;/h2>\nho\n"}},"i":0}}]}'>
117 </span><h2 about="#mwt1" id="hi">hi</h2><span about="#mwt1">
118 </span><p about="#mwt1">ho</p><span about="#mwt1">
119 </span></section>
120 !! metadata
121 Sections:
122 h2 index: toclevel:1 number:1 title:NULL off:NULL anchor/linkAnchor:hi line:hi
123 !! end
124
125 !! test
126 Duplicate headings should get unique anchors
127 !! options
128 nohtml
129 showtocdata
130 parsoid={
131 "modes": [ "wt2html" ],
132 "wrapSections": true
133 }
134 !! config
135 wgParserEnableLegacyHeadingDOM=true
136 !! wikitext
137 ==a==
138 ==a==
139 ==b==
140 !! metadata
141 Sections:
142 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:a line:a
143 h2 index:2 toclevel:1 number:2 title:Parser_test off:6 anchor/linkAnchor:a_2 line:a
144 h2 index:3 toclevel:1 number:3 title:Parser_test off:12 anchor/linkAnchor:b line:b
145 !! end
146
147 !! test
148 Templated sections (heading from template content)
149 !! options
150 nohtml
151 showtocdata
152 parsoid={
153 "modes": [ "wt2html" ],
154 "wrapSections": true
155 }
156 !! config
157 wgParserEnableLegacyHeadingDOM=true
158 !! wikitext
159 ==a==
160 {{Test}}
161 !! metadata
162 Sections:
163 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:a line:a
164 h2 index:T-1 toclevel:1 number:2 title:Template:Test off:NULL anchor/linkAnchor:th2 line:th2
165 h3 index:T-2 toclevel:2 number:2.1 title:Template:Test off:NULL anchor/linkAnchor:th2.1 line:th2.1
166 !! end
167
168 !! test
169 Ensure headings with html tags get the right anchors
170 !! options
171 nohtml
172 showtocdata
173 parsoid={
174 "modes": [ "wt2html" ],
175 "wrapSections": true
176 }
177 !! config
178 wgParserEnableLegacyHeadingDOM=true
179 !! wikitext
180 ==<span>x</span>==
181 ==<strike>y</strike>==
182 !! metadata
183 Sections:
184 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:x line:<span>x</span>
185 h2 index:2 toclevel:1 number:2 title:Parser_test off:19 anchor/linkAnchor:y line:<strike>y</strike>
186 !! end
187
188 !! test
189 Ensure unallowed tag wrappers in headings get stripped
190 !! options
191 nohtml
192 showtocdata
193 parsoid={
194 "modes": [ "wt2html" ],
195 "wrapSections": true
196 }
197 !! config
198 wgParserEnableLegacyHeadingDOM=true
199 !! wikitext
200 ==<div>b</div>==
201 ==<font>c</font>==
202 !! metadata
203 Sections:
204 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:b line:b
205 h2 index:2 toclevel:1 number:2 title:Parser_test off:17 anchor/linkAnchor:c line:c
206 !! end
207
208 !! test
209 Ensure disallowed attributes are stripped, but dir attribute in a span is left behind
210 !! options
211 nohtml
212 showtocdata
213 parsoid={
214 "modes": [ "wt2html" ],
215 "wrapSections": true
216 }
217 !! config
218 wgParserEnableLegacyHeadingDOM=true
219 !! wikitext
220 ==<span dir='ltr' title='x'>a</span>==
221 ==<span dir='rtl' title='x'>b</span>==
222 ==<i dir='rtl' title='ha'>c</i>==
223 !! metadata
224 Sections:
225 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:a line:<span dir="ltr">a</span>
226 h2 index:2 toclevel:1 number:2 title:Parser_test off:39 anchor/linkAnchor:b line:<span dir="rtl">b</span>
227 h2 index:3 toclevel:1 number:3 title:Parser_test off:78 anchor/linkAnchor:c line:<i>c</i>
228 !! end
229
230 # Legacy parser behavior is broken. Parsoid's output is correct.
231 !! test
232 Ensure empty tags are stripped
233 !! options
234 nohtml
235 showtocdata
236 parsoid={
237 "modes": [ "wt2html" ],
238 "wrapSections": true
239 }
240 !! config
241 wgParserEnableLegacyHeadingDOM=true
242 !! wikitext
243 ==<span><div></div></span>x==
244 ==<span dir='ltr'><i dir='ltr'></i></span>y==
245 !! metadata/php
246 Sections:
247 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:x line:x
248 h2 index:2 toclevel:1 number:2 title:Parser_test off:30 anchor/linkAnchor:y line:<span dir="ltr"><i></i></span>y
249 !! metadata/parsoid
250 Sections:
251 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:x line:x
252 h2 index:2 toclevel:1 number:2 title:Parser_test off:30 anchor/linkAnchor:y line:y
253 !! end
254
255 !! test
256 Ensure comments in toc lines are stripped
257 !! config
258 wgRawHtml=1
259 wgParserEnableLegacyHeadingDOM=true
260 !! options
261 nohtml
262 showtocdata
263 !! wikitext
264 ==hi<html><!--ho--></html>==
265 !! metadata/php
266 Sections:
267 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:hi line:hi
268 !! end
269
270 !! test
271 Handle links in heading content
272 !! options
273 nohtml
274 showtocdata
275 parsoid={
276 "modes": [ "wt2html" ],
277 "wrapSections": true
278 }
279 !! config
280 wgParserEnableLegacyHeadingDOM=true
281 !! wikitext
282 ==[[Cat]]==
283 ==[[Dog]]s==
284 ==[[Cat|I love my ''cat'']]==
285 !! metadata
286 Sections:
287 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:Cat line:Cat
288 h2 index:2 toclevel:1 number:2 title:Parser_test off:12 anchor/linkAnchor:Dogs line:Dogs
289 h2 index:3 toclevel:1 number:3 title:Parser_test off:25 anchor/linkAnchor:I_love_my_cat line:I love my <i>cat</i>
290 !! end
291
292 # Parsoid uses HTML5 semantics for anchors as the default.
293 # Legacy parser tests require wgFragmentMode=[ "html5" ] for the same
294 # behavior, which isn't (yet) the default in ParserTestRunner
295 !! test
296 Ensure headings with special chars get the right anchors
297 !! options
298 nohtml
299 showtocdata
300 parsoid={
301 "modes": [ "wt2html" ],
302 "wrapSections": true
303 }
304 !! config
305 wgFragmentMode=[ "html5", "legacy" ]
306 wgParserEnableLegacyHeadingDOM=true
307 !! wikitext
308 ===a=
309 =''x''=
310 !! metadata
311 Sections:
312 h1 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:==a line:==a
313 h1 index:2 toclevel:1 number:2 title:Parser_test off:6 anchor/linkAnchor:x line:<i>x</i>
314 !! end
315
316 # For heading that come from template args, core, Parsoid-standalone, and
317 # Parsoid-integrate different in ther "index" output.
318 #
319 # - For templated sections, Parsoid and core differ in some of the metadata.
320 # Parsoid doesn't distinguish between sections that come from template args
321 # and from templated content - it treats them all as template-generated headings.
322 # But core does not consider headings from template-args as "inTemplate", but
323 # 'fromtitle' is set to false even so.
324 #
325 # - Parsoid's behavior is more consistent wrt templates. But, this is potentially
326 # a breaking change for users of TOC data. The index for templated
327 # content is used to generate section edit links for content coming
328 # from a template, and in updating the appropriate article when that
329 # section is saved. So this is potentially a breaking change when
330 # Parsoid starts to generate section edit links, and possible one
331 # which could cause db corruption.
332 #
333 # - Additionally, heading-index is reset in integrated mode because templates are
334 # processed by core preprocessor whereas in native preprocessing mode (used by
335 # parsertests), the heading index is not reset.
336 # - See also T222419.
337 !! test
338 Templated sections (heading from template arg)
339 !! options
340 nohtml
341 showtocdata
342 parsoid={
343 "modes": [ "wt2html" ],
344 "wrapSections": true
345 }
346 !! config
347 wgParserEnableLegacyHeadingDOM=true
348 !! wikitext
349 ==a==
350 {{1x|1=
351 ==b==
352 }}
353 !! metadata/php
354 Sections:
355 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:a line:a
356 h2 index: toclevel:1 number:2 title:NULL off:NULL anchor/linkAnchor:b line:b
357 !! metadata/parsoid+integrated
358 Sections:
359 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:a line:a
360 h2 index:T-1 toclevel:1 number:2 title:Template:1x off:NULL anchor/linkAnchor:b line:b
361 !! metadata/parsoid+standalone
362 Sections:
363 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:a line:a
364 h2 index:T-2 toclevel:1 number:2 title:Template:1x off:NULL anchor/linkAnchor:b line:b
365 !! end
366
367 !! test
368 Handle extension content in section headers properly (non-Cite version)
369 !! config
370 wgFragmentMode=[ "html5", "legacy" ]
371 wgParserEnableLegacyHeadingDOM=true
372 !! options
373 nohtml
374 showtocdata
375 parsoid={
376 "modes": [ "wt2html" ],
377 "wrapSections": true
378 }
379 !! wikitext
380 ==c<tag>d</tag>==
381 !! metadata
382 Sections:
383 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:c'd'_array_(_) line:"c'd'\narray (\n)"
384 !! end
385
386 !! test
387 Offsets in toc metadata should be unicode codepoints, not bytes or UCS-2
388 !! config
389 wgFragmentMode=[ "html5", "legacy" ]
390 wgParserEnableLegacyHeadingDOM=true
391 !! options
392 parsoid={
393 "modes": [ "wt2html" ],
394 "wrapSections": true
395 }
396 showtocdata
397 nohtml
398 !! wikitext
399 ==One 💩==
400 ==Two 💩==
401 ==Three 💩==
402 !! metadata
403 Sections:
404 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:One_💩 line:One 💩
405 h2 index:2 toclevel:1 number:2 title:Parser_test off:10 anchor/linkAnchor:Two_💩 line:Two 💩
406 h2 index:3 toclevel:1 number:3 title:Parser_test off:20 anchor/linkAnchor:Three_💩 line:Three 💩
407 !! end
408
409 !! test
410 Handle multi-part content transclusion blocks
411 !! options
412 nohtml
413 showtocdata
414 parsoid={
415 "modes": [ "wt2html" ],
416 "wrapSections": true
417 }
418 !! config
419 wgParserEnableLegacyHeadingDOM=true
420 !! wikitext
421 <div>
422 {{1x|1=
423 ==foo==
424 </div>
425 }}
426 ==bar==
427 !! metadata
428 Sections:
429 h2 index: toclevel:1 number:1 title:NULL off:NULL anchor/linkAnchor:foo line:foo
430 h2 index:2 toclevel:1 number:2 title:Parser_test off:32 anchor/linkAnchor:bar line:bar
431 !! end
432
433 # Parsoid's parser function implementation used for standalone testing
434 # is incomplete and only used in parser tests.
435 # So, use HTML h-tags instead of wikitext h-tags in the parser function
436 # to let us run this test in both standalone and integrated modes.
437 !! test
438 Handle parser functions generating sections
439 !! options
440 nohtml
441 showtocdata
442 parsoid={
443 "modes": [ "wt2html" ],
444 "wrapSections": true
445 }
446 !! config
447 wgParserEnableLegacyHeadingDOM=true
448 !! wikitext
449 {{#if:1|<h2>foo</h2>|unused}}
450 ==bar==
451 !! metadata
452 Sections:
453 h2 index: toclevel:1 number:1 title:NULL off:NULL anchor/linkAnchor:foo line:foo
454 h2 index:1 toclevel:1 number:2 title:Parser_test off:30 anchor/linkAnchor:bar line:bar
455 !! end
456
457 !! test
458 Handle top-level template args generating sections
459 !! options
460 nohtml
461 showtocdata
462 parsoid={
463 "modes": [ "wt2html" ],
464 "wrapSections": true
465 }
466 !! config
467 wgParserEnableLegacyHeadingDOM=true
468 !! wikitext
469 {{{foo|
470 ==tplarg==
471 |abcd}}}
472 !! metadata
473 Sections:
474 h2 index: toclevel:1 number:1 title:NULL off:NULL anchor/linkAnchor:tplarg line:tplarg
475 !! end
476
477 ###
478 ### Sections
479 ###
480 !! test
481 Basic section headings
482 !! config
483 wgParserEnableLegacyHeadingDOM=true
484 !! wikitext
485 ==Headline 1==
486 Some text
487
488 ==Headline 2==
489 More
490 ===Smaller headline===
491 Blah blah
492 !! html
493 <h2><span class="mw-headline" id="Headline_1">Headline 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: Headline 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
494 <p>Some text
495 </p>
496 <h2><span class="mw-headline" id="Headline_2">Headline 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: Headline 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
497 <p>More
498 </p>
499 <h3><span class="mw-headline" id="Smaller_headline">Smaller headline</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: Smaller headline">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
500 <p>Blah blah
501 </p>
502 !! end
503
504 !! test
505 Section headings with TOC
506 !! config
507 wgParserEnableLegacyHeadingDOM=true
508 !! wikitext
509 ==Headline 1==
510 ===Subheadline 1===
511 =====Skipping a level=====
512 ======Skipping a level======
513
514 ==Headline 2==
515 Some text
516 ===Another headline===
517 !! html/php
518 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
519 <ul>
520 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
521 <ul>
522 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a>
523 <ul>
524 <li class="toclevel-3 tocsection-3"><a href="#Skipping_a_level"><span class="tocnumber">1.1.1</span> <span class="toctext">Skipping a level</span></a>
525 <ul>
526 <li class="toclevel-4 tocsection-4"><a href="#Skipping_a_level_2"><span class="tocnumber">1.1.1.1</span> <span class="toctext">Skipping a level</span></a></li>
527 </ul>
528 </li>
529 </ul>
530 </li>
531 </ul>
532 </li>
533 <li class="toclevel-1 tocsection-5"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
534 <ul>
535 <li class="toclevel-2 tocsection-6"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
536 </ul>
537 </li>
538 </ul>
539 </div>
540
541 <h2><span class="mw-headline" id="Headline_1">Headline 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: Headline 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
542 <h3><span class="mw-headline" id="Subheadline_1">Subheadline 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: Subheadline 1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
543 <h5><span class="mw-headline" id="Skipping_a_level">Skipping a level</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: Skipping a level">edit</a><span class="mw-editsection-bracket">]</span></span></h5>
544 <h6><span class="mw-headline" id="Skipping_a_level_2">Skipping a level</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: Skipping a level">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
545 <h2><span class="mw-headline" id="Headline_2">Headline 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: Headline 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
546 <p>Some text
547 </p>
548 <h3><span class="mw-headline" id="Another_headline">Another headline</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: Another headline">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
549 !! html/parsoid
550 <h2 id="Headline_1" data-parsoid="{}">Headline 1</h2>
551 <h3 id="Subheadline_1" data-parsoid="{}">Subheadline 1</h3>
552 <h5 id="Skipping_a_level" data-parsoid="{}">Skipping a level</h5>
553 <h6 id="Skipping_a_level_2" data-parsoid="{}">Skipping a level</h6>
554
555 <h2 id="Headline_2" data-parsoid="{}">Headline 2</h2>
556 <p data-parsoid="{}">Some text</p>
557 <h3 id="Another_headline" data-parsoid="{}">Another headline</h3>
558 !! end
559
560 !! test
561 Section headings with TOC and language conversion (T295187, T306862)
562 !! config
563 wgUsePigLatinVariant=true
564 wgParserEnableLegacyHeadingDOM=true
565 !! options
566 language=en htmlVariantLanguage=en-x-piglatin
567 !! wikitext
568 ==Headline 1==
569 ===Subheadline 1===
570 ==Headline 2==
571 Some text
572 ===Another headline===
573 !! html/php
574 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en-x-piglatin" dir="ltr"><h2 id="mw-toc-heading">Ontentscay</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
575 <ul>
576 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Eadlinehay 1</span></a>
577 <ul>
578 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Ubheadlinesay 1</span></a></li>
579 </ul>
580 </li>
581 <li class="toclevel-1 tocsection-3"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Eadlinehay 2</span></a>
582 <ul>
583 <li class="toclevel-2 tocsection-4"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Anotherway eadlinehay</span></a></li>
584 </ul>
585 </li>
586 </ul>
587 </div>
588
589 <h2><span class="mw-headline" id="Headline_1">Eadlinehay 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: Eadlinehay 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
590 <h3><span class="mw-headline" id="Subheadline_1">Ubheadlinesay 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: Ubheadlinesay 1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
591 <h2><span class="mw-headline" id="Headline_2">Eadlinehay 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: Eadlinehay 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
592 <p>Omesay exttay
593 </p>
594 <h3><span class="mw-headline" id="Another_headline">Anotherway eadlinehay</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: Anotherway eadlinehay">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
595 !! html/parsoid
596 <h2 id="Headline_1" data-parsoid="{}">Headline 1</h2>
597 <h3 id="Subheadline_1" data-parsoid="{}">Subheadline 1</h3>
598 <h2 id="Headline_2" data-parsoid="{}">Headline 2</h2>
599 <p data-parsoid="{}">Some text</p>
600 <h3 id="Another_headline" data-parsoid="{}">Another headline</h3>
601 !! end
602
603 # Note that even though conversion of the *content* is disabled, the
604 # user interface messages (aka the TOC title) are still in the user's
605 # preferred UX variant (that is, pig latin).
606 !! test
607 Section headings with TOC and language conversion disabled (T295187)
608 !! config
609 wgUsePigLatinVariant=true
610 wgParserEnableLegacyHeadingDOM=true
611 !! options
612 language=en htmlVariantLanguage=en-x-piglatin
613 !! wikitext
614 ==Headline 1==
615 ===Subheadline 1===
616 ==Headline 2==
617 Some text
618 ===Another headline===
619 __NOCONTENTCONVERT__
620 !! html/php
621 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en-x-piglatin" dir="ltr"><h2 id="mw-toc-heading">Ontentscay</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
622 <ul>
623 <li class="toclevel-1 tocsection-1"><a href="#Headline_1"><span class="tocnumber">1</span> <span class="toctext">Headline 1</span></a>
624 <ul>
625 <li class="toclevel-2 tocsection-2"><a href="#Subheadline_1"><span class="tocnumber">1.1</span> <span class="toctext">Subheadline 1</span></a></li>
626 </ul>
627 </li>
628 <li class="toclevel-1 tocsection-3"><a href="#Headline_2"><span class="tocnumber">2</span> <span class="toctext">Headline 2</span></a>
629 <ul>
630 <li class="toclevel-2 tocsection-4"><a href="#Another_headline"><span class="tocnumber">2.1</span> <span class="toctext">Another headline</span></a></li>
631 </ul>
632 </li>
633 </ul>
634 </div>
635
636 <h2><span class="mw-headline" id="Headline_1">Headline 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: Headline 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
637 <h3><span class="mw-headline" id="Subheadline_1">Subheadline 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: Subheadline 1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
638 <h2><span class="mw-headline" id="Headline_2">Headline 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: Headline 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
639 <p>Some text
640 </p>
641 <h3><span class="mw-headline" id="Another_headline">Another headline</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: Another headline">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
642 !! html/parsoid
643 <h2 id="Headline_1" data-parsoid="{}">Headline 1</h2>
644 <h3 id="Subheadline_1" data-parsoid="{}">Subheadline 1</h3>
645 <h2 id="Headline_2" data-parsoid="{}">Headline 2</h2>
646 <p data-parsoid="{}">Some text</p>
647 <h3 id="Another_headline" data-parsoid="{}">Another headline</h3>
648 <meta property="mw:PageProp/nocontentconvert" data-parsoid="{}" />
649 !! end
650
651 # The -{T}- below checks for regressions in T26072: the contents of
652 # the displaytitle should not be double-converted. That is, we want
653 # the title to end up as 'Bar' not 'Ball' (aka converted by the -{H}-
654 # rule immediately preceding it).
655 !! test
656 Section headings with TOC, language conversion rules, and displaytitle
657 (T306862, T331316, T26072)
658 !! config
659 wgUsePigLatinVariant=true
660 wgRestrictDisplayTitle=false
661 wgParserEnableLegacyHeadingDOM=true
662 !! options
663 language=en htmlVariantLanguage=en-x-piglatin
664 showtitle
665 showtocdata
666 parsoid={
667 "modes": [ "wt2html" ],
668 "wrapSections": true
669 }
670 !! wikitext
671 <!--
672 -->-{H|Foo=>en:Boo;Foo=>en-x-piglatin:Bob;}-<!--
673 -->-{H|Bar=>en:Bat;Bar=>en-x-piglatin:Ball;}-<!--
674 -->-{T|en:Foo;en-x-piglatin:Bar;}-<!--
675 -->
676 Introduction.
677 -{A|en:Do; en-x-piglatin:Re;}-
678 == Foo ==
679 Foo Do
680 == Bar ==
681 Bar Re
682 == -{Foo Bar}- ==
683 !! metadata
684 Bar
685 Sections:
686 h2 index:1 toclevel:1 number:1 title:Parser_test off:192 anchor/linkAnchor:Foo line:Bob
687 h2 index:2 toclevel:1 number:2 title:Parser_test off:209 anchor/linkAnchor:Bar line:Ball
688 h2 index:3 toclevel:1 number:3 title:Parser_test off:226 anchor/linkAnchor:-.7BFoo_Bar.7D- line:Foo Bar
689 !! html/php
690 <p>
691 Introductionway.
692 Re
693 </p>
694 <h2><span class="mw-headline" id="Foo">Bob</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: Bob">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
695 <p>Bob Re
696 </p>
697 <h2><span class="mw-headline" id="Bar">Ball</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: Ball">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
698 <p>Ball Eray
699 </p>
700 <h2><span class="mw-headline" id="-.7BFoo_Bar.7D-">Foo Bar</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: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
701 !! html/parsoid+standalone
702 <section data-mw-section-id="0"><!--
703 --><p>-{H|Foo=>en:Boo;Foo=>en-x-piglatin:Bob;}-<!--
704 -->-{H|Bar=>en:Bat;Bar=>en-x-piglatin:Ball;}-<!--
705 -->-{T|en:Foo;en-x-piglatin:Bar;}-<!--
706 -->
707 Introduction.
708 -{A|en:Do; en-x-piglatin:Re;}-</p>
709 </section><section data-mw-section-id="1"><h2 id="Foo">Foo</h2>
710 <p>Foo Do</p>
711 </section><section data-mw-section-id="2"><h2 id="Bar">Bar</h2>
712 <p>Bar Re</p>
713 </section><section data-mw-section-id="3"><h2 id="-{Foo_Bar}-"><span id="-.7BFoo_Bar.7D-" typeof="mw:FallbackId"></span>-{Foo Bar}-</h2></section>
714 !! html/parsoid+integrated
715 <section data-mw-section-id="0"><!--
716 --><p><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"Foo","l":"en","t":"Boo"},{"f":"Foo","l":"en-x-piglatin","t":"Bob"}]}'/><!--
717 --><meta typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"oneway":[{"f":"Bar","l":"en","t":"Bat"},{"f":"Bar","l":"en-x-piglatin","t":"Ball"}]}'/><!--
718 --><meta typeof="mw:LanguageVariant" data-mw-variant='{"title":true,"twoway":[{"l":"en","t":"Foo"},{"l":"en-x-piglatin","t":"Bar"}]}'/><!--
719 --> Introduction. <span typeof="mw:LanguageVariant" data-mw-variant='{"add":true,"twoway":[{"l":"en","t":"Do"},{"l":"en-x-piglatin","t":"Re"}]}'></span></p>
720 </section><section data-mw-section-id="1"><h2 id="Foo">Foo</h2>
721 <p>Foo Do</p>
722 </section><section data-mw-section-id="2"><h2 id="Bar">Bar</h2>
723 <p>Bar Re</p>
724 </section><section data-mw-section-id="3"><h2 id="-{Foo_Bar}-"><span id="-.7BFoo_Bar.7D-" typeof="mw:FallbackId"></span><span typeof="mw:LanguageVariant" data-mw-variant='{"disabled":{"t":"Foo Bar"}}'></span></h2>
725 </section>
726
727 !! end
728
729 !! test
730 TOC anchors don't collide
731 !! config
732 wgParserEnableLegacyHeadingDOM=true
733 !! wikitext
734 __FORCETOC__
735 ==Headline 2==
736 ==Headline==
737 ==Headline 2==
738 ==Headline==
739 !! html/php
740 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
741 <ul>
742 <li class="toclevel-1 tocsection-1"><a href="#Headline_2"><span class="tocnumber">1</span> <span class="toctext">Headline 2</span></a></li>
743 <li class="toclevel-1 tocsection-2"><a href="#Headline"><span class="tocnumber">2</span> <span class="toctext">Headline</span></a></li>
744 <li class="toclevel-1 tocsection-3"><a href="#Headline_2_2"><span class="tocnumber">3</span> <span class="toctext">Headline 2</span></a></li>
745 <li class="toclevel-1 tocsection-4"><a href="#Headline_3"><span class="tocnumber">4</span> <span class="toctext">Headline</span></a></li>
746 </ul>
747 </div>
748
749 <h2><span class="mw-headline" id="Headline_2">Headline 2</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: Headline 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
750 <h2><span class="mw-headline" id="Headline">Headline</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: Headline">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
751 <h2><span class="mw-headline" id="Headline_2_2">Headline 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: Headline 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
752 <h2><span class="mw-headline" id="Headline_3">Headline</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: Headline">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
753 !! end
754
755 # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10'
756 # Parsoid html2wt direction adds <nowiki> for level 7 and up.
757 !! test
758 Handling of sections up to level 6 and beyond
759 !! options
760 parsoid=wt2html
761 !! config
762 wgParserEnableLegacyHeadingDOM=true
763 !! wikitext
764 =Level 1 Heading=
765 ==Level 2 Heading==
766 ===Level 3 Heading===
767 ====Level 4 Heading====
768 =====Level 5 Heading=====
769 ======Level 6 Heading======
770 =======Level 7 Heading=======
771 ========Level 8 Heading========
772 =========Level 9 Heading=========
773 ==========Level 10 Heading==========
774 !! html/php
775 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
776 <ul>
777 <li class="toclevel-1 tocsection-1"><a href="#Level_1_Heading"><span class="tocnumber">1</span> <span class="toctext">Level 1 Heading</span></a>
778 <ul>
779 <li class="toclevel-2 tocsection-2"><a href="#Level_2_Heading"><span class="tocnumber">1.1</span> <span class="toctext">Level 2 Heading</span></a>
780 <ul>
781 <li class="toclevel-3 tocsection-3"><a href="#Level_3_Heading"><span class="tocnumber">1.1.1</span> <span class="toctext">Level 3 Heading</span></a>
782 <ul>
783 <li class="toclevel-4 tocsection-4"><a href="#Level_4_Heading"><span class="tocnumber">1.1.1.1</span> <span class="toctext">Level 4 Heading</span></a>
784 <ul>
785 <li class="toclevel-5 tocsection-5"><a href="#Level_5_Heading"><span class="tocnumber">1.1.1.1.1</span> <span class="toctext">Level 5 Heading</span></a>
786 <ul>
787 <li class="toclevel-6 tocsection-6"><a href="#Level_6_Heading"><span class="tocnumber">1.1.1.1.1.1</span> <span class="toctext">Level 6 Heading</span></a></li>
788 <li class="toclevel-6 tocsection-7"><a href="#.3DLevel_7_Heading.3D"><span class="tocnumber">1.1.1.1.1.2</span> <span class="toctext">=Level 7 Heading=</span></a></li>
789 <li class="toclevel-6 tocsection-8"><a href="#.3D.3DLevel_8_Heading.3D.3D"><span class="tocnumber">1.1.1.1.1.3</span> <span class="toctext">==Level 8 Heading==</span></a></li>
790 <li class="toclevel-6 tocsection-9"><a href="#.3D.3D.3DLevel_9_Heading.3D.3D.3D"><span class="tocnumber">1.1.1.1.1.4</span> <span class="toctext">===Level 9 Heading===</span></a></li>
791 <li class="toclevel-6 tocsection-10"><a href="#.3D.3D.3D.3DLevel_10_Heading.3D.3D.3D.3D"><span class="tocnumber">1.1.1.1.1.5</span> <span class="toctext">====Level 10 Heading====</span></a></li>
792 </ul>
793 </li>
794 </ul>
795 </li>
796 </ul>
797 </li>
798 </ul>
799 </li>
800 </ul>
801 </li>
802 </ul>
803 </div>
804
805 <h1><span class="mw-headline" id="Level_1_Heading">Level 1 Heading</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: Level 1 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
806 <h2><span class="mw-headline" id="Level_2_Heading">Level 2 Heading</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: Level 2 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
807 <h3><span class="mw-headline" id="Level_3_Heading">Level 3 Heading</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: Level 3 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
808 <h4><span class="mw-headline" id="Level_4_Heading">Level 4 Heading</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: Level 4 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
809 <h5><span class="mw-headline" id="Level_5_Heading">Level 5 Heading</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: Level 5 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h5>
810 <h6><span class="mw-headline" id="Level_6_Heading">Level 6 Heading</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: Level 6 Heading">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
811 <h6><span class="mw-headline" id=".3DLevel_7_Heading.3D">=Level 7 Heading=</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: =Level 7 Heading=">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
812 <h6><span class="mw-headline" id=".3D.3DLevel_8_Heading.3D.3D">==Level 8 Heading==</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: ==Level 8 Heading==">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
813 <h6><span class="mw-headline" id=".3D.3D.3DLevel_9_Heading.3D.3D.3D">===Level 9 Heading===</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: ===Level 9 Heading===">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
814 <h6><span class="mw-headline" id=".3D.3D.3D.3DLevel_10_Heading.3D.3D.3D.3D">====Level 10 Heading====</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: ====Level 10 Heading====">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
815 !! html/parsoid
816 <h1 id="Level_1_Heading" data-parsoid='{}'>Level 1 Heading</h1>
817 <h2 id="Level_2_Heading" data-parsoid='{}'>Level 2 Heading</h2>
818 <h3 id="Level_3_Heading" data-parsoid='{}'>Level 3 Heading</h3>
819 <h4 id="Level_4_Heading" data-parsoid='{}'>Level 4 Heading</h4>
820 <h5 id="Level_5_Heading" data-parsoid='{}'>Level 5 Heading</h5>
821 <h6 id="Level_6_Heading" data-parsoid='{}'>Level 6 Heading</h6>
822 <h6 id="=Level_7_Heading=" data-parsoid='{}'><span id=".3DLevel_7_Heading.3D" typeof="mw:FallbackId"></span>=Level 7 Heading=</h6>
823 <h6 id="==Level_8_Heading==" data-parsoid='{}'><span id=".3D.3DLevel_8_Heading.3D.3D" typeof="mw:FallbackId"></span>==Level 8 Heading==</h6>
824 <h6 id="===Level_9_Heading===" data-parsoid='{}'><span id=".3D.3D.3DLevel_9_Heading.3D.3D.3D" typeof="mw:FallbackId"></span>===Level 9 Heading===</h6>
825 <h6 id="====Level_10_Heading====" data-parsoid='{}'><span id=".3D.3D.3D.3DLevel_10_Heading.3D.3D.3D.3D" typeof="mw:FallbackId"></span>====Level 10 Heading====</h6>
826 !! end
827
828 !! test
829 TOC regression (T11764)
830 !! config
831 wgParserEnableLegacyHeadingDOM=true
832 !! wikitext
833 ==title 1==
834 ===title 1.1===
835 ====title 1.1.1====
836 ===title 1.2===
837 ==title 2==
838 ===title 2.1===
839 !! html/php
840 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
841 <ul>
842 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
843 <ul>
844 <li class="toclevel-2 tocsection-2"><a href="#title_1.1"><span class="tocnumber">1.1</span> <span class="toctext">title 1.1</span></a>
845 <ul>
846 <li class="toclevel-3 tocsection-3"><a href="#title_1.1.1"><span class="tocnumber">1.1.1</span> <span class="toctext">title 1.1.1</span></a></li>
847 </ul>
848 </li>
849 <li class="toclevel-2 tocsection-4"><a href="#title_1.2"><span class="tocnumber">1.2</span> <span class="toctext">title 1.2</span></a></li>
850 </ul>
851 </li>
852 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
853 <ul>
854 <li class="toclevel-2 tocsection-6"><a href="#title_2.1"><span class="tocnumber">2.1</span> <span class="toctext">title 2.1</span></a></li>
855 </ul>
856 </li>
857 </ul>
858 </div>
859
860 <h2><span class="mw-headline" id="title_1">title 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: title 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
861 <h3><span class="mw-headline" id="title_1.1">title 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: title 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
862 <h4><span class="mw-headline" id="title_1.1.1">title 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=3" title="Edit section: title 1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
863 <h3><span class="mw-headline" id="title_1.2">title 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=4" title="Edit section: title 1.2">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
864 <h2><span class="mw-headline" id="title_2">title 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: title 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
865 <h3><span class="mw-headline" id="title_2.1">title 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=6" title="Edit section: title 2.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
866 !! html/parsoid
867 <h2 id="title_1" data-parsoid="{}">title 1</h2>
868 <h3 id="title_1.1" data-parsoid="{}">title 1.1</h3>
869 <h4 id="title_1.1.1" data-parsoid="{}">title 1.1.1</h4>
870 <h3 id="title_1.2" data-parsoid="{}">title 1.2</h3>
871 <h2 id="title_2" data-parsoid="{}">title 2</h2>
872 <h3 id="title_2.1" data-parsoid="{}">title 2.1</h3>
873 !! end
874
875 !! test
876 TOC for heading containing <span id="..."></span> (T96153)
877 !! config
878 wgParserEnableLegacyHeadingDOM=true
879 !! wikitext
880 __FORCETOC__
881 ==<span id="old-anchor"></span>New title==
882 !! html/php
883 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
884 <ul>
885 <li class="toclevel-1 tocsection-1"><a href="#New_title"><span class="tocnumber">1</span> <span class="toctext">New title</span></a></li>
886 </ul>
887 </div>
888
889 <h2><span class="mw-headline" id="New_title"><span id="old-anchor"></span>New title</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: New title">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
890 !! end
891
892 !! test
893 TOC with wgMaxTocLevel=3 (T8204)
894 !! options
895 wgMaxTocLevel=3
896 !! config
897 wgParserEnableLegacyHeadingDOM=true
898 !! wikitext
899 ==title 1==
900 ===title 1.1===
901 ====title 1.1.1====
902 ===title 1.2===
903 ==title 2==
904 ===title 2.1===
905 !! html/php
906 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
907 <ul>
908 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
909 <ul>
910 <li class="toclevel-2 tocsection-2"><a href="#title_1.1"><span class="tocnumber">1.1</span> <span class="toctext">title 1.1</span></a></li>
911 <li class="toclevel-2 tocsection-4"><a href="#title_1.2"><span class="tocnumber">1.2</span> <span class="toctext">title 1.2</span></a></li>
912 </ul>
913 </li>
914 <li class="toclevel-1 tocsection-5"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a>
915 <ul>
916 <li class="toclevel-2 tocsection-6"><a href="#title_2.1"><span class="tocnumber">2.1</span> <span class="toctext">title 2.1</span></a></li>
917 </ul>
918 </li>
919 </ul>
920 </div>
921
922 <h2><span class="mw-headline" id="title_1">title 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: title 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
923 <h3><span class="mw-headline" id="title_1.1">title 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: title 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
924 <h4><span class="mw-headline" id="title_1.1.1">title 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=3" title="Edit section: title 1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
925 <h3><span class="mw-headline" id="title_1.2">title 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=4" title="Edit section: title 1.2">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
926 <h2><span class="mw-headline" id="title_2">title 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: title 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
927 <h3><span class="mw-headline" id="title_2.1">title 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=6" title="Edit section: title 2.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
928 !! html/parsoid
929 <h2 id="title_1" data-parsoid="{}">title 1</h2>
930 <h3 id="title_1.1" data-parsoid="{}">title 1.1</h3>
931 <h4 id="title_1.1.1" data-parsoid="{}">title 1.1.1</h4>
932 <h3 id="title_1.2" data-parsoid="{}">title 1.2</h3>
933 <h2 id="title_2" data-parsoid="{}">title 2</h2>
934 <h3 id="title_2.1" data-parsoid="{}">title 2.1</h3>
935 !! end
936
937 !! test
938 TOC with wgMaxTocLevel=3 and two level four headings (T8204)
939 !! options
940 wgMaxTocLevel=3
941 !! config
942 wgParserEnableLegacyHeadingDOM=true
943 !! wikitext
944 ==Section 1==
945 ===Section 1.1===
946 ====Section 1.1.1====
947 ====Section 1.1.1.1====
948 ==Section 2==
949 !! html/php
950 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
951 <ul>
952 <li class="toclevel-1 tocsection-1"><a href="#Section_1"><span class="tocnumber">1</span> <span class="toctext">Section 1</span></a>
953 <ul>
954 <li class="toclevel-2 tocsection-2"><a href="#Section_1.1"><span class="tocnumber">1.1</span> <span class="toctext">Section 1.1</span></a></li>
955 </ul>
956 </li>
957 <li class="toclevel-1 tocsection-5"><a href="#Section_2"><span class="tocnumber">2</span> <span class="toctext">Section 2</span></a></li>
958 </ul>
959 </div>
960
961 <h2><span class="mw-headline" id="Section_1">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: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
962 <h3><span class="mw-headline" id="Section_1.1">Section 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: Section 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
963 <h4><span class="mw-headline" id="Section_1.1.1">Section 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=3" title="Edit section: Section 1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
964 <h4><span class="mw-headline" id="Section_1.1.1.1">Section 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=4" title="Edit section: Section 1.1.1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h4>
965 <h2><span class="mw-headline" id="Section_2">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=5" title="Edit section: Section 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
966 !! html/parsoid
967 <h2 id="Section_1" data-parsoid="{}">Section 1</h2>
968 <h3 id="Section_1.1" data-parsoid="{}">Section 1.1</h3>
969 <h4 id="Section_1.1.1" data-parsoid="{}">Section 1.1.1</h4>
970 <h4 id="Section_1.1.1.1" data-parsoid="{}">Section 1.1.1.1</h4>
971 <h2 id="Section_2" data-parsoid="{}">Section 2</h2>
972 !! end
973
974 !! test
975 Resolving duplicate section names
976 !! config
977 wgParserEnableLegacyHeadingDOM=true
978 !! wikitext
979 ==Foo bar==
980 ==Foo bar==
981 !! html
982 <h2><span class="mw-headline" id="Foo_bar">Foo bar</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: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
983 <h2><span class="mw-headline" id="Foo_bar_2">Foo bar</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: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
984 !! end
985
986 !! test
987 Resolving duplicate section names with differing case (T12721)
988 !! config
989 wgParserEnableLegacyHeadingDOM=true
990 !! wikitext
991 ==Foo bar==
992 ==Foo Bar==
993 !! html
994 <h2><span class="mw-headline" id="Foo_bar">Foo bar</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: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
995 <h2><span class="mw-headline" id="Foo_Bar_2">Foo Bar</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: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
996 !! end
997
998 !! article
999 Template:sections
1000 !! text
1001 ===Section 1===
1002 ==Section 2==
1003 !! endarticle
1004
1005 !! test
1006 Template with sections, __NOTOC__
1007 !! options
1008 showflags
1009 parsoid={
1010 "wrapSections": true
1011 }
1012 !! config
1013 wgParserEnableLegacyHeadingDOM=true
1014 !! wikitext
1015 __NOTOC__
1016 ==Section 0==
1017 {{sections}}
1018 ==Section 4==
1019 !! metadata
1020 flags=no-toc
1021 !! html/php
1022 <h2><span class="mw-headline" id="Section_0">Section 0</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: Section 0">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1023 <h3><span class="mw-headline" id="Section_1">Section 1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Sections&amp;action=edit&amp;section=T-1" title="Edit section: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
1024 <h2><span class="mw-headline" id="Section_2">Section 2</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Sections&amp;action=edit&amp;section=T-2" title="Edit section: Section 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1025 <h2><span class="mw-headline" id="Section_4">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=2" title="Edit section: Section 4">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1026 !! html/parsoid
1027 <section data-mw-section-id="0"><meta property="mw:PageProp/notoc" data-parsoid="{}" />
1028 </section><section data-mw-section-id="1" about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":["==Section 0==\n",{"template":{"target":{"wt":"sections","href":"./Template:Sections"},"params":{},"i":0}},"\n"]}'><h2 id="Section_0" data-parsoid="{}">Section 0</h2>
1029 <section data-mw-section-id="-1"><h3 about="#mwt1" typeof="mw:Transclusion" id="Section_1" data-parsoid="{}" data-mw='{"parts":[{"template":{"target":{"wt":"sections","href":"./Template:Sections"},"params":{},"i":0}}]}'>Section 1</h3><span about="#mwt1">
1030 </span></section></section><section data-mw-section-id="-1" about="#mwt2"><h2 about="#mwt1" id="Section_2">Section 2</h2>
1031 </section><section data-mw-section-id="2"><h2 id="Section_4" data-parsoid="{}">Section 4</h2></section>
1032 !! end
1033
1034 !! test
1035 T307691: show-toc flag: no sections
1036 !! options
1037 showflags
1038 parsoid={
1039 "wrapSections": true
1040 }
1041 !! config
1042 wgParserEnableLegacyHeadingDOM=true
1043 !! wikitext
1044 !! metadata
1045 flags=
1046 !! html
1047 !! html/parsoid
1048 <section data-mw-section-id="0"></section>
1049 !! end
1050
1051 # You can't force a TOC if there aren't any sections
1052 !! test
1053 T307691: show-toc flag: no sections, but __FORCETOC__
1054 !! options
1055 showflags
1056 parsoid={
1057 "wrapSections": true
1058 }
1059 !! config
1060 wgParserEnableLegacyHeadingDOM=true
1061 !! wikitext
1062 __FORCETOC__
1063 !! metadata
1064 flags=
1065 !! html/php
1066 !! html/parsoid
1067 <section data-mw-section-id="0"><meta property="mw:PageProp/forcetoc"/></section>
1068 !! end
1069
1070 # Placing a manual __TOC__ doesn't do anything if there aren't any sections
1071 !! test
1072 T307691: show-toc flag: no sections, but __TOC__
1073 !! options
1074 showflags
1075 parsoid={
1076 "wrapSections": true
1077 }
1078 !! config
1079 wgParserEnableLegacyHeadingDOM=true
1080 !! wikitext
1081 __TOC__
1082 !! metadata
1083 flags=
1084 !! html/php
1085 !! html/parsoid
1086 <section data-mw-section-id="0"><meta property="mw:PageProp/toc"/></section>
1087 !! end
1088
1089 !! test
1090 T307691: show-toc flag: no sections, and __NOTOC__
1091 !! options
1092 showflags
1093 parsoid={
1094 "wrapSections": true
1095 }
1096 !! config
1097 wgParserEnableLegacyHeadingDOM=true
1098 !! wikitext
1099 __NOTOC__
1100 !! metadata
1101 flags=no-toc
1102 !! html/php
1103 !! html/parsoid
1104 <section data-mw-section-id="0"><meta property="mw:PageProp/notoc"/></section>
1105 !! end
1106
1107 !! test
1108 T307691: show-toc flag: not "enough" sections
1109 !! options
1110 showflags
1111 parsoid={
1112 "wrapSections": true
1113 }
1114 !! config
1115 wgParserEnableLegacyHeadingDOM=true
1116 !! wikitext
1117 == One ==
1118 !! metadata
1119 flags=
1120 !! html/php
1121 <h2><span class="mw-headline" id="One">One</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: One">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1122 !! html/parsoid
1123 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h2 id="One">One</h2>
1124 </section>
1125 !! end
1126
1127 !! test
1128 T352467: synthetic sections shouldn't count towards "enough" sections
1129 !! options
1130 showflags
1131 parsoid={
1132 "modes": [ "wt2html" ],
1133 "wrapSections": true
1134 }
1135 !! config
1136 wgParserEnableLegacyHeadingDOM=true
1137 !! wikitext
1138 <div>
1139 ==a==
1140 ==b==
1141 </div>
1142 ==c==
1143 !! metadata
1144 flags=
1145 !! html/php
1146 <div>
1147 <h2><span class="mw-headline" id="a">a</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">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1148 <h2><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=2" title="Edit section: b">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1149 </div>
1150 <h2><span class="mw-headline" id="c">c</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: c">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1151 !! html/parsoid
1152 <section data-mw-section-id="-1"></section><section data-mw-section-id="-2"><div>
1153 <section data-mw-section-id="1"><h2 id="a">a</h2>
1154 </section><section data-mw-section-id="-1"><h2 id="b">b</h2>
1155 </section></div>
1156 </section><section data-mw-section-id="3"><h2 id="c">c</h2></section>
1157 !! end
1158
1159 !! test
1160 T307691: show-toc flag: not "enough" sections, but __FORCETOC__
1161 !! options
1162 showflags
1163 parsoid={
1164 "wrapSections": true
1165 }
1166 !! config
1167 wgParserEnableLegacyHeadingDOM=true
1168 !! wikitext
1169 __FORCETOC__
1170 == One ==
1171 !! metadata
1172 flags=show-toc
1173 !! html/php
1174 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1175 <ul>
1176 <li class="toclevel-1 tocsection-1"><a href="#One"><span class="tocnumber">1</span> <span class="toctext">One</span></a></li>
1177 </ul>
1178 </div>
1179
1180 <h2><span class="mw-headline" id="One">One</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: One">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1181 !! html/parsoid
1182 <section data-mw-section-id="0"><meta property="mw:PageProp/forcetoc"/>
1183 <meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="1">
1184 <h2 id="One">One</h2></section>
1185 !! end
1186
1187 !! test
1188 T307691: show-toc flag: not "enough" sections, but __TOC__
1189 !! options
1190 showflags
1191 parsoid={
1192 "wrapSections": true
1193 }
1194 !! config
1195 wgParserEnableLegacyHeadingDOM=true
1196 !! wikitext
1197 == One ==
1198 __TOC__
1199 !! metadata
1200 flags=show-toc
1201 !! html/php
1202 <h2><span class="mw-headline" id="One">One</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: One">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1203 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1204 <ul>
1205 <li class="toclevel-1 tocsection-1"><a href="#One"><span class="tocnumber">1</span> <span class="toctext">One</span></a></li>
1206 </ul>
1207 </div>
1208 !! html/parsoid
1209 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h2 id="One">One</h2>
1210 <meta property="mw:PageProp/toc"/></section>
1211 !! end
1212
1213 !! test
1214 T307691: show-toc flag: not "enough" sections, and __NOTOC__
1215 !! options
1216 showflags
1217 parsoid={
1218 "wrapSections": true
1219 }
1220 !! config
1221 wgParserEnableLegacyHeadingDOM=true
1222 !! wikitext
1223 __NOTOC__
1224 == One ==
1225 !! metadata
1226 flags=no-toc
1227 !! html/php
1228 <h2><span class="mw-headline" id="One">One</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: One">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1229 !! html/parsoid
1230 <section data-mw-section-id="0"><meta property="mw:PageProp/notoc"/>
1231 </section><section data-mw-section-id="1">
1232 <h2 id="One">One</h2></section>
1233 !! end
1234
1235 !! test
1236 T307691: show-toc flag: "enough" sections
1237 !! options
1238 showflags
1239 parsoid={
1240 "wrapSections": true
1241 }
1242 !! config
1243 wgParserEnableLegacyHeadingDOM=true
1244 !! wikitext
1245 == One ==
1246 === Two ===
1247 == Three ==
1248 === Four ===
1249 !! metadata
1250 flags=show-toc
1251 !! html/php
1252 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1253 <ul>
1254 <li class="toclevel-1 tocsection-1"><a href="#One"><span class="tocnumber">1</span> <span class="toctext">One</span></a>
1255 <ul>
1256 <li class="toclevel-2 tocsection-2"><a href="#Two"><span class="tocnumber">1.1</span> <span class="toctext">Two</span></a></li>
1257 </ul>
1258 </li>
1259 <li class="toclevel-1 tocsection-3"><a href="#Three"><span class="tocnumber">2</span> <span class="toctext">Three</span></a>
1260 <ul>
1261 <li class="toclevel-2 tocsection-4"><a href="#Four"><span class="tocnumber">2.1</span> <span class="toctext">Four</span></a></li>
1262 </ul>
1263 </li>
1264 </ul>
1265 </div>
1266
1267 <h2><span class="mw-headline" id="One">One</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: One">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1268 <h3><span class="mw-headline" id="Two">Two</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: Two">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
1269 <h2><span class="mw-headline" id="Three">Three</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: Three">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1270 <h3><span class="mw-headline" id="Four">Four</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: Four">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
1271 !! html/parsoid
1272 <section data-mw-section-id="0"><meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="1"><h2 id="One">One</h2>
1273 <section data-mw-section-id="2"><h3 id="Two">Two</h3>
1274 </section></section><section data-mw-section-id="3"><h2 id="Three">Three</h2>
1275 <section data-mw-section-id="4"><h3 id="Four">Four</h3></section></section>
1276 !! end
1277
1278 !! test
1279 T307691: show-toc flag: "enough" sections and __FORCETOC__
1280 !! options
1281 showflags
1282 parsoid={
1283 "wrapSections": true
1284 }
1285 !! config
1286 wgParserEnableLegacyHeadingDOM=true
1287 !! wikitext
1288 __FORCETOC__
1289 == One ==
1290 === Two ===
1291 == Three ==
1292 === Four ===
1293 !! metadata
1294 flags=show-toc
1295 !! html/php
1296 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1297 <ul>
1298 <li class="toclevel-1 tocsection-1"><a href="#One"><span class="tocnumber">1</span> <span class="toctext">One</span></a>
1299 <ul>
1300 <li class="toclevel-2 tocsection-2"><a href="#Two"><span class="tocnumber">1.1</span> <span class="toctext">Two</span></a></li>
1301 </ul>
1302 </li>
1303 <li class="toclevel-1 tocsection-3"><a href="#Three"><span class="tocnumber">2</span> <span class="toctext">Three</span></a>
1304 <ul>
1305 <li class="toclevel-2 tocsection-4"><a href="#Four"><span class="tocnumber">2.1</span> <span class="toctext">Four</span></a></li>
1306 </ul>
1307 </li>
1308 </ul>
1309 </div>
1310
1311 <h2><span class="mw-headline" id="One">One</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: One">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1312 <h3><span class="mw-headline" id="Two">Two</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: Two">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
1313 <h2><span class="mw-headline" id="Three">Three</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: Three">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1314 <h3><span class="mw-headline" id="Four">Four</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: Four">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
1315 !! html/parsoid
1316 <section data-mw-section-id="0"><meta property="mw:PageProp/forcetoc"/>
1317 <meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="1"><h2 id="One">One</h2>
1318 <section data-mw-section-id="2"><h3 id="Two">Two</h3>
1319 </section></section><section data-mw-section-id="3"><h2 id="Three">Three</h2>
1320 <section data-mw-section-id="4"><h3 id="Four">Four</h3></section></section>
1321 !! end
1322
1323 !! test
1324 T307691: show-toc flag: "enough" sections and __NOTOC__
1325 !! options
1326 showflags
1327 parsoid={
1328 "wrapSections": true
1329 }
1330 !! config
1331 wgParserEnableLegacyHeadingDOM=true
1332 !! wikitext
1333 __NOTOC__
1334 == One ==
1335 === Two ===
1336 == Three ==
1337 === Four ===
1338 !! metadata
1339 flags=no-toc
1340 !! html/php
1341 <h2><span class="mw-headline" id="One">One</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: One">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1342 <h3><span class="mw-headline" id="Two">Two</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: Two">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
1343 <h2><span class="mw-headline" id="Three">Three</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: Three">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1344 <h3><span class="mw-headline" id="Four">Four</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: Four">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
1345 !! html/parsoid
1346 <section data-mw-section-id="0"><meta property="mw:PageProp/notoc"/>
1347 </section><section data-mw-section-id="1"><h2 id="One">One</h2>
1348 <section data-mw-section-id="2"><h3 id="Two">Two</h3>
1349 </section></section><section data-mw-section-id="3"><h2 id="Three">Three</h2>
1350 <section data-mw-section-id="4"><h3 id="Four">Four</h3></section></section>
1351 !! end
1352
1353 !! test
1354 __NOEDITSECTION__ keyword
1355 !! options
1356 showflags
1357 parsoid={
1358 "wrapSections": true
1359 }
1360 !! config
1361 wgParserEnableLegacyHeadingDOM=true
1362 !! wikitext
1363 __NOEDITSECTION__
1364 ==Section 1==
1365 ==Section 2==
1366 !! html/php
1367 <h2><span class="mw-headline" id="Section_1">Section 1</span></h2>
1368 <h2><span class="mw-headline" id="Section_2">Section 2</span></h2>
1369 !! metadata/php
1370 flags=
1371 !! html/parsoid
1372 <section data-mw-section-id="0"><meta property="mw:PageProp/noeditsection" data-parsoid='{"magicSrc":"__NOEDITSECTION__"}'/>
1373 </section><section data-mw-section-id="1"><h2 id="Section_1" data-parsoid='{}'>Section 1</h2>
1374 </section><section data-mw-section-id="2"><h2 id="Section_2" data-parsoid='{}'>Section 2</h2></section>
1375 !! metadata/parsoid
1376 flags=no-section-edit-links
1377 !! end
1378
1379 !! test
1380 Link inside a section heading
1381 !! config
1382 wgParserEnableLegacyHeadingDOM=true
1383 !! wikitext
1384 ==Section with a [[Main Page|link]] in it==
1385 !! html
1386 <h2><span class="mw-headline" id="Section_with_a_link_in_it">Section with a <a href="/wiki/Main_Page" title="Main Page">link</a> in it</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: Section with a link in it">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1387 !! end
1388
1389 !! test
1390 TOC regression (T14077)
1391 !! config
1392 wgParserEnableLegacyHeadingDOM=true
1393 !! wikitext
1394 __TOC__
1395 ==title 1==
1396 ===title 1.1===
1397 ==title 2==
1398 !! html/php
1399 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1400 <ul>
1401 <li class="toclevel-1 tocsection-1"><a href="#title_1"><span class="tocnumber">1</span> <span class="toctext">title 1</span></a>
1402 <ul>
1403 <li class="toclevel-2 tocsection-2"><a href="#title_1.1"><span class="tocnumber">1.1</span> <span class="toctext">title 1.1</span></a></li>
1404 </ul>
1405 </li>
1406 <li class="toclevel-1 tocsection-3"><a href="#title_2"><span class="tocnumber">2</span> <span class="toctext">title 2</span></a></li>
1407 </ul>
1408 </div>
1409
1410 <h2><span class="mw-headline" id="title_1">title 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: title 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1411 <h3><span class="mw-headline" id="title_1.1">title 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: title 1.1">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
1412 <h2><span class="mw-headline" id="title_2">title 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: title 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1413 !! html/parsoid
1414 <meta property="mw:PageProp/toc" data-parsoid="{}"/>
1415 <h2 id="title_1" data-parsoid="{}">title 1</h2>
1416 <h3 id="title_1.1" data-parsoid="{}">title 1.1</h3>
1417 <h2 id="title_2" data-parsoid="{}">title 2</h2>
1418 !! end
1419
1420 # test added in 4e717c01589378893c98e333884315c166c217b3
1421 # __FORCETOC__ won't set show-toc if there are no sections
1422 # present to show; also test that __NEWSECTIONLINK__ results in the
1423 # proper ParserOutputFlag being set.
1424 !! test
1425 __FORCETOC__ override
1426 !! options
1427 showflags
1428 parsoid={
1429 "wrapSections": true
1430 }
1431 !! config
1432 wgParserEnableLegacyHeadingDOM=true
1433 !! wikitext
1434 __NEWSECTIONLINK__
1435 __FORCETOC__
1436 !! metadata
1437 flags=mw-NewSection
1438 !! html/php
1439 <p><br />
1440 </p>
1441 !! html/parsoid
1442 <section data-mw-section-id="0"><meta property="mw:PageProp/newsectionlink" />
1443 <meta property="mw:PageProp/forcetoc" /></section>
1444 !! end
1445
1446 # Note that Parsoid doesn't emit an explicit TOC.
1447 # Note also that the html2wt direction tends to emit an extra newline
1448 # between the __TOC__ magicword and the first heading unless *both*
1449 # the <meta> and the <h2> have a data-parsoid attribute set (even if
1450 # it's "{}").
1451
1452 !! test
1453 T28375: TOC with italics
1454 !! options
1455 title=[[Main Page]]
1456 !! config
1457 wgParserEnableLegacyHeadingDOM=true
1458 !! wikitext
1459 __TOC__
1460 ==''Lost'' episodes==
1461 !! html/php
1462 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1463 <ul>
1464 <li class="toclevel-1 tocsection-1"><a href="#Lost_episodes"><span class="tocnumber">1</span> <span class="toctext"><i>Lost</i> episodes</span></a></li>
1465 </ul>
1466 </div>
1467
1468 <h2><span class="mw-headline" id="Lost_episodes"><i>Lost</i> episodes</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Lost episodes">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1469 !! html/parsoid
1470 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
1471 <h2 id="Lost_episodes" data-parsoid='{}'><i>Lost</i> episodes</h2>
1472 !! end
1473
1474 !! test
1475 T28375: TOC with bold
1476 !! options
1477 title=[[Main Page]]
1478 !! config
1479 wgParserEnableLegacyHeadingDOM=true
1480 !! wikitext
1481 __TOC__
1482 =='''should be bold''' then normal text==
1483 !! html/php
1484 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1485 <ul>
1486 <li class="toclevel-1 tocsection-1"><a href="#should_be_bold_then_normal_text"><span class="tocnumber">1</span> <span class="toctext"><b>should be bold</b> then normal text</span></a></li>
1487 </ul>
1488 </div>
1489
1490 <h2><span class="mw-headline" id="should_be_bold_then_normal_text"><b>should be bold</b> then normal text</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: should be bold then normal text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1491 !! html/parsoid
1492 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
1493 <h2 id="should_be_bold_then_normal_text" data-parsoid='{}'><b>should be bold</b> then normal text</h2>
1494 !! end
1495
1496 !! test
1497 T35845: Headings become cursive in TOC when they contain an image
1498 !! options
1499 title=[[Main Page]]
1500 !! config
1501 wgParserEnableLegacyMediaDOM=false
1502 wgParserEnableLegacyHeadingDOM=true
1503 !! wikitext
1504 __TOC__
1505 ==Image [[Image:foobar.jpg]]==
1506 !! html/php
1507 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1508 <ul>
1509 <li class="toclevel-1 tocsection-1"><a href="#Image"><span class="tocnumber">1</span> <span class="toctext">Image</span></a></li>
1510 </ul>
1511 </div>
1512
1513 <h2><span class="mw-headline" id="Image">Image <span class="mw-default-size" typeof="mw:File"><a href="/wiki/File:Foobar.jpg" class="mw-file-description"><img src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" width="1941" height="220" class="mw-file-element" /></a></span></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Image">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1514 !! html/parsoid
1515 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
1516 <h2 id="Image" data-parsoid='{}'>Image <span class="mw-default-size" typeof="mw:File"><a href="./File:Foobar.jpg" class="mw-file-description"><img resource="./File:Foobar.jpg" src="http://example.com/images/3/3a/Foobar.jpg" decoding="async" data-file-width="1941" data-file-height="220" data-file-type="bitmap" height="220" width="1941" data-parsoid='{"a":{"resource":"./File:Foobar.jpg","height":"220","width":"1941"},"sa":{"resource":"Image:foobar.jpg"}}' class="mw-file-element"/></a></span></h2>
1517 !! end
1518
1519 !! test
1520 T35845 (2): Headings become bold in TOC when they contain a blockquote
1521 !! options
1522 title=[[Main Page]]
1523 !! config
1524 wgParserEnableLegacyHeadingDOM=true
1525 !! wikitext
1526 __TOC__
1527 ==<blockquote>Quote</blockquote>==
1528 !! html/php
1529 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1530 <ul>
1531 <li class="toclevel-1 tocsection-1"><a href="#Quote"><span class="tocnumber">1</span> <span class="toctext">Quote</span></a></li>
1532 </ul>
1533 </div>
1534
1535 <h2><span class="mw-headline" id="Quote"><blockquote><p>Quote</p></blockquote></span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Quote">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1536 !! html/parsoid
1537 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
1538 <h2 id="Quote" data-parsoid='{}'><blockquote><p>Quote</p></blockquote></h2>
1539 !! end
1540
1541 !! test
1542 Unclosed tags in TOC
1543 !! config
1544 wgFragmentMode=[ "html5", "legacy" ]
1545 wgParserEnableLegacyHeadingDOM=true
1546 !! options
1547 title=[[Main Page]]
1548 !! wikitext
1549 __TOC__
1550 ==Proof: 2 < 3==
1551 <small>Hanc marginis exiguitas non caperet.</small>
1552 QED
1553 !! html/php
1554 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1555 <ul>
1556 <li class="toclevel-1 tocsection-1"><a href="#Proof:_2_&lt;_3"><span class="tocnumber">1</span> <span class="toctext">Proof: 2 &lt; 3</span></a></li>
1557 </ul>
1558 </div>
1559
1560 <h2><span id="Proof:_2_.3C_3"></span><span class="mw-headline" id="Proof:_2_&lt;_3">Proof: 2 &lt; 3</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Main_Page&amp;action=edit&amp;section=1" title="Edit section: Proof: 2 &lt; 3">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1561 <p><small>Hanc marginis exiguitas non caperet.</small>
1562 QED
1563 </p>
1564 !! html/parsoid
1565 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
1566 <h2 id="Proof:_2_&lt;_3" data-parsoid='{}'><span id="Proof:_2_.3C_3" typeof="mw:FallbackId"></span>Proof: 2 &lt; 3</h2>
1567 <p><small>Hanc marginis exiguitas non caperet.</small>
1568 QED</p>
1569 !! end
1570
1571 !! test
1572 Multiple tags in TOC
1573 !! config
1574 wgParserEnableLegacyHeadingDOM=true
1575 !! wikitext
1576 __TOC__
1577 ==<i>Foo</i> <b>Bar</b>==
1578
1579 ==<i>Foo</i> <blockquote>Bar</blockquote>==
1580 !! html/php
1581 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1582 <ul>
1583 <li class="toclevel-1 tocsection-1"><a href="#Foo_Bar"><span class="tocnumber">1</span> <span class="toctext"><i>Foo</i> <b>Bar</b></span></a></li>
1584 <li class="toclevel-1 tocsection-2"><a href="#Foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext"><i>Foo</i> Bar</span></a></li>
1585 </ul>
1586 </div>
1587
1588 <h2><span class="mw-headline" id="Foo_Bar"><i>Foo</i> <b>Bar</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: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1589 <h2><span class="mw-headline" id="Foo_Bar_2"><i>Foo</i> <blockquote><p>Bar</p></blockquote></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: Foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1590 !! html/parsoid
1591 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
1592 <h2 id="Foo_Bar" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <b data-parsoid='{"stx":"html"}'>Bar</b></h2>
1593
1594 <h2 id="Foo_Bar_2" data-parsoid='{}'><i data-parsoid='{"stx":"html"}'>Foo</i> <blockquote><p>Bar</p></blockquote></h2>
1595 !! end
1596
1597 # Don't expect Parsoid to roundtrip this until the php parser comes closer to
1598 # html5 tag parsing.
1599 !! test
1600 Tags with parameters in TOC
1601 !! options
1602 parsoid=wt2html
1603 !! config
1604 wgParserEnableLegacyHeadingDOM=true
1605 !! wikitext
1606 __TOC__
1607 ==<sup class="in-h2">Hello</sup>==
1608
1609 ==<sup class="a > b">Evilbye</sup>==
1610 !! html/php
1611 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1612 <ul>
1613 <li class="toclevel-1 tocsection-1"><a href="#Hello"><span class="tocnumber">1</span> <span class="toctext"><sup>Hello</sup></span></a></li>
1614 <li class="toclevel-1 tocsection-2"><a href="#b.22.3EEvilbye"><span class="tocnumber">2</span> <span class="toctext"><sup> b"&gt;Evilbye</sup></span></a></li>
1615 </ul>
1616 </div>
1617
1618 <h2><span class="mw-headline" id="Hello"><sup class="in-h2">Hello</sup></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: Hello">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1619 <h2><span class="mw-headline" id="b.22.3EEvilbye"><sup class="a"> b"&gt;Evilbye</sup></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&quot;&gt;Evilbye">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1620 !! html/parsoid
1621 <meta property="mw:PageProp/toc" />
1622 <h2 id="Hello"><sup class="in-h2" data-parsoid='{"stx":"html"}'>Hello</sup></h2>
1623
1624 <h2 id='b">Evilbye'><span id="b.22.3EEvilbye" typeof="mw:FallbackId"></span><sup class="a " data-parsoid='{"stx":"html"}'> b">Evilbye</sup></h2>
1625 !! end
1626
1627 !! test
1628 span tags with directionality in TOC
1629 !! config
1630 wgParserEnableLegacyHeadingDOM=true
1631 !! wikitext
1632 __TOC__
1633 ==<span dir="ltr">C++</span>==
1634
1635 ==<span dir="rtl">זבנג!</span>==
1636
1637 ==<span style="font-style: italic" dir="ltr" title="hello">Attributes other than dir</span>==
1638 !! html/php
1639 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1640 <ul>
1641 <li class="toclevel-1 tocsection-1"><a href="#C.2B.2B"><span class="tocnumber">1</span> <span class="toctext"><span dir="ltr">C++</span></span></a></li>
1642 <li class="toclevel-1 tocsection-2"><a href="#.D7.96.D7.91.D7.A0.D7.92.21"><span class="tocnumber">2</span> <span class="toctext"><span dir="rtl">זבנג!</span></span></a></li>
1643 <li class="toclevel-1 tocsection-3"><a href="#Attributes_other_than_dir"><span class="tocnumber">3</span> <span class="toctext"><span dir="ltr">Attributes other than dir</span></span></a></li>
1644 </ul>
1645 </div>
1646
1647 <h2><span class="mw-headline" id="C.2B.2B"><span dir="ltr">C++</span></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: C++">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1648 <h2><span class="mw-headline" id=".D7.96.D7.91.D7.A0.D7.92.21"><span dir="rtl">זבנג!</span></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: זבנג!">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1649 <h2><span class="mw-headline" id="Attributes_other_than_dir"><span style="font-style: italic" dir="ltr" title="hello">Attributes other than dir</span></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: Attributes other than dir">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1650 !! html/parsoid
1651 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
1652 <h2 id="C++" data-parsoid='{}'><span id="C.2B.2B" typeof="mw:FallbackId"></span><span dir="ltr">C++</span></h2>
1653 <h2 id="זבנג!"><span id=".D7.96.D7.91.D7.A0.D7.92.21" typeof="mw:FallbackId"></span><span dir="rtl">זבנג!</span></h2>
1654 <h2 id="Attributes_other_than_dir"><span style="font-style: italic" dir="ltr" title="hello">Attributes other than dir</span></h2>
1655 !! end
1656
1657 !! test
1658 T74884: bdi element in ToC
1659 !! config
1660 wgParserEnableLegacyHeadingDOM=true
1661 !! wikitext
1662 __TOC__
1663 ==<bdi>test</bdi>==
1664 !! html/php
1665 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1666 <ul>
1667 <li class="toclevel-1 tocsection-1"><a href="#test"><span class="tocnumber">1</span> <span class="toctext"><bdi>test</bdi></span></a></li>
1668 </ul>
1669 </div>
1670
1671 <h2><span class="mw-headline" id="test"><bdi>test</bdi></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: test">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1672 !! html/parsoid
1673 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
1674 <h2 id="test" data-parsoid='{}'><bdi>test</bdi></h2>
1675 !! end
1676
1677 !! test
1678 T35715: s/strike element in ToC
1679 !! config
1680 wgParserEnableLegacyHeadingDOM=true
1681 !! wikitext
1682 __TOC__
1683 ==<s>test</s> test <strike>test</strike>==
1684 !! html/php
1685 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1686 <ul>
1687 <li class="toclevel-1 tocsection-1"><a href="#test_test_test"><span class="tocnumber">1</span> <span class="toctext"><s>test</s> test <strike>test</strike></span></a></li>
1688 </ul>
1689 </div>
1690
1691 <h2><span class="mw-headline" id="test_test_test"><s>test</s> test <strike>test</strike></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: test test test">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1692 !! html/parsoid
1693 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
1694 <h2 id="test_test_test" data-parsoid='{}'><s>test</s> test <strike>test</strike></h2>
1695 !! end
1696
1697 !! test
1698 T198618: style element in ToC
1699 !! options
1700 styletag=1
1701 !! config
1702 wgParserEnableLegacyHeadingDOM=true
1703 !! wikitext
1704 __TOC__
1705 ==<style>.foo {}</style>Style<style>.bar {}</style>==
1706 !! html/php
1707 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1708 <ul>
1709 <li class="toclevel-1 tocsection-1"><a href="#Style"><span class="tocnumber">1</span> <span class="toctext">Style</span></a></li>
1710 </ul>
1711 </div>
1712
1713 <h2><span class="mw-headline" id="Style"><style>.foo {}</style>Style<style>.bar {}</style></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: Style">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1714 !! html/parsoid
1715 <meta property="mw:PageProp/toc" data-parsoid="{}"/>
1716 <h2 id="Style" data-parsoid="{}"><style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".foo {}"}}'>.foo {}</style>Style<style typeof="mw:Extension/style" data-mw='{"name":"style","attrs":{},"body":{"extsrc":".bar {}"}}'>.bar {}</style></h2>
1717 !! end
1718
1719 !! test
1720 T198618: script element in ToC
1721 !! options
1722 wgRawHtml=1
1723 !! config
1724 wgParserEnableLegacyHeadingDOM=true
1725 !! wikitext
1726 __TOC__
1727 ==<html><script>alert(1);</script></html>Script<html><script>alert(1);</script></html>==
1728 !! html/php
1729 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1730 <ul>
1731 <li class="toclevel-1 tocsection-1"><a href="#Script"><span class="tocnumber">1</span> <span class="toctext">Script</span></a></li>
1732 </ul>
1733 </div>
1734
1735 <h2><span class="mw-headline" id="Script"><script>alert(1);</script>Script<script>alert(1);</script></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: Script">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1736 !! html/parsoid
1737 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
1738 <h2 id="Script" data-parsoid='{}'><script typeof="mw:Extension/html" about="#mwt4" data-mw='{"name":"html","attrs":{},"body":{"extsrc":"&lt;script>alert(1);&lt;/script>"}}'>alert(1);</script>Script<script typeof="mw:Extension/html" about="#mwt6" data-mw='{"name":"html","attrs":{},"body":{"extsrc":"&lt;script>alert(1);&lt;/script>"}}'>alert(1);</script></h2>
1739 !! end
1740
1741 !! test
1742 Empty <p> tag in TOC, removed by Sanitizer (T92892)
1743 !! config
1744 wgParserEnableLegacyHeadingDOM=true
1745 !! wikitext
1746 __TOC__
1747 ==x==
1748 !! html/php
1749 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1750 <ul>
1751 <li class="toclevel-1 tocsection-1"><a href="#x"><span class="tocnumber">1</span> <span class="toctext">x</span></a></li>
1752 </ul>
1753 </div>
1754
1755 <h2><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></h2>
1756 !! html/parsoid
1757 <meta property="mw:PageProp/toc" data-parsoid='{}'/>
1758 <h2 id="x" data-parsoid='{}'>x</h2>
1759 !! end
1760
1761 !! test
1762 Disable TOC
1763 !! options
1764 notoc
1765 !! config
1766 wgParserEnableLegacyHeadingDOM=true
1767 !! wikitext
1768 Lead
1769 ==Section 1==
1770 ==Section 2==
1771 ==Section 3==
1772 ==Section 4==
1773 ==Section 5==
1774 !! html
1775 <p>Lead
1776 </p>
1777
1778 <h2><span class="mw-headline" id="Section_1">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: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1779 <h2><span class="mw-headline" id="Section_2">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: Section 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1780 <h2><span class="mw-headline" id="Section_3">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: Section 3">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1781 <h2><span class="mw-headline" id="Section_4">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: Section 4">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1782 <h2><span class="mw-headline" id="Section_5">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: Section 5">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1783 !! end
1784
1785 ###
1786 ### Headings
1787 ###
1788
1789 # Parsoid doesn't wt2wt this cleanly because it adds <nowiki>s.
1790 !! test
1791 Short headings with trailing space should match behavior of Parser::doHeadings (T21910)
1792 !! options
1793 parsoid=wt2html,html2html
1794 !! config
1795 wgParserEnableLegacyHeadingDOM=true
1796 !! wikitext
1797 ===
1798 The line above must have a trailing space!
1799 === <!--
1800 --> <!-- -->
1801 But just in case it doesn't...
1802 !! html/php
1803 <h1><span class="mw-headline" id=".3D">=</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: =">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
1804 <p>The line above must have a trailing space!
1805 </p>
1806 <h1><span class="mw-headline" id=".3D_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: =">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
1807 <p>But just in case it doesn't...
1808 </p>
1809 !! html/parsoid
1810 <h1 id="="><span id=".3D" typeof="mw:FallbackId"></span>=</h1>
1811 <p>The line above must have a trailing space!</p>
1812 <h1 id="=_2"><span id=".3D_2" typeof="mw:FallbackId"></span>=</h1> <!--
1813 --> <!-- -->
1814 <p>But just in case it doesn't...</p>
1815 !! end
1816
1817 !! test
1818 Header with special characters (T27462)
1819 !! config
1820 wgParserEnableLegacyHeadingDOM=true
1821 !! wikitext
1822 The tooltips shall not show entities to the user (ie. be double escaped)
1823
1824 ==text > text==
1825 section 1
1826
1827 ==text < text==
1828 section 2
1829
1830 ==text & text==
1831 section 3
1832
1833 ==text ' text==
1834 section 4
1835
1836 ==text " text==
1837 section 5
1838 !! html/php
1839 <p>The tooltips shall not show entities to the user (ie. be double escaped)
1840 </p>
1841 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1842 <ul>
1843 <li class="toclevel-1 tocsection-1"><a href="#text_.3E_text"><span class="tocnumber">1</span> <span class="toctext">text &gt; text</span></a></li>
1844 <li class="toclevel-1 tocsection-2"><a href="#text_.3C_text"><span class="tocnumber">2</span> <span class="toctext">text &lt; text</span></a></li>
1845 <li class="toclevel-1 tocsection-3"><a href="#text_.26_text"><span class="tocnumber">3</span> <span class="toctext">text &amp; text</span></a></li>
1846 <li class="toclevel-1 tocsection-4"><a href="#text_.27_text"><span class="tocnumber">4</span> <span class="toctext">text ' text</span></a></li>
1847 <li class="toclevel-1 tocsection-5"><a href="#text_.22_text"><span class="tocnumber">5</span> <span class="toctext">text " text</span></a></li>
1848 </ul>
1849 </div>
1850
1851 <h2><span class="mw-headline" id="text_.3E_text">text &gt; text</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: text &gt; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1852 <p>section 1
1853 </p>
1854 <h2><span class="mw-headline" id="text_.3C_text">text &lt; text</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: text &lt; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1855 <p>section 2
1856 </p>
1857 <h2><span class="mw-headline" id="text_.26_text">text &amp; text</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: text &amp; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1858 <p>section 3
1859 </p>
1860 <h2><span class="mw-headline" id="text_.27_text">text ' text</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: text &#39; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1861 <p>section 4
1862 </p>
1863 <h2><span class="mw-headline" id="text_.22_text">text " text</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: text &quot; text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1864 <p>section 5
1865 </p>
1866 !! html/parsoid
1867 <p>The tooltips shall not show entities to the user (ie. be double escaped)</p>
1868
1869 <h2 id="text_>_text"><span id="text_.3E_text" typeof="mw:FallbackId"></span>text > text</h2>
1870 <p>section 1</p>
1871
1872 <h2 id="text_&lt;_text"><span id="text_.3C_text" typeof="mw:FallbackId"></span>text &lt; text</h2>
1873 <p>section 2</p>
1874
1875 <h2 id="text_&amp;_text"><span id="text_.26_text" typeof="mw:FallbackId"></span>text &amp; text</h2>
1876 <p>section 3</p>
1877
1878 <h2 id="text_'_text"><span id="text_.27_text" typeof="mw:FallbackId"></span>text ' text</h2>
1879 <p>section 4</p>
1880
1881 <h2 id='text_"_text'><span id="text_.22_text" typeof="mw:FallbackId"></span>text " text</h2>
1882 <p>section 5</p>
1883 !! end
1884
1885 !! test
1886 Header with space, plus and underscore as entity
1887 !! config
1888 wgParserEnableLegacyHeadingDOM=true
1889 !! wikitext
1890 Id should not contain + for spaces
1891
1892 ==Space between Text==
1893 section 1
1894
1895 ==Space-Entity&#32;between&#32;Text==
1896 section 2
1897
1898 ==Plus+between+Text==
1899 section 3
1900
1901 ==Plus-Entity&#43;between&#43;Text==
1902 section 4
1903
1904 ==Underscore_between_Text==
1905 section 5
1906
1907 ==Underscore-Entity&#95;between&#95;Text==
1908 section 6
1909
1910 [[#Space between Text]]
1911 [[#Space-Entity&#32;between&#32;Text]]
1912 [[#Plus+between+Text]]
1913 [[#Plus-Entity&#43;between&#43;Text]]
1914 [[#Underscore_between_Text]]
1915 [[#Underscore-Entity&#95;between&#95;Text]]
1916 !! html/php
1917 <p>Id should not contain + for spaces
1918 </p>
1919 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1920 <ul>
1921 <li class="toclevel-1 tocsection-1"><a href="#Space_between_Text"><span class="tocnumber">1</span> <span class="toctext">Space between Text</span></a></li>
1922 <li class="toclevel-1 tocsection-2"><a href="#Space-Entity_between_Text"><span class="tocnumber">2</span> <span class="toctext">Space-Entity between Text</span></a></li>
1923 <li class="toclevel-1 tocsection-3"><a href="#Plus.2Bbetween.2BText"><span class="tocnumber">3</span> <span class="toctext">Plus+between+Text</span></a></li>
1924 <li class="toclevel-1 tocsection-4"><a href="#Plus-Entity.2Bbetween.2BText"><span class="tocnumber">4</span> <span class="toctext">Plus-Entity+between+Text</span></a></li>
1925 <li class="toclevel-1 tocsection-5"><a href="#Underscore_between_Text"><span class="tocnumber">5</span> <span class="toctext">Underscore_between_Text</span></a></li>
1926 <li class="toclevel-1 tocsection-6"><a href="#Underscore-Entity_between_Text"><span class="tocnumber">6</span> <span class="toctext">Underscore-Entity_between_Text</span></a></li>
1927 </ul>
1928 </div>
1929
1930 <h2><span class="mw-headline" id="Space_between_Text">Space between Text</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: Space between Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1931 <p>section 1
1932 </p>
1933 <h2><span class="mw-headline" id="Space-Entity_between_Text">Space-Entity&#32;between&#32;Text</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: Space-Entity between Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1934 <p>section 2
1935 </p>
1936 <h2><span class="mw-headline" id="Plus.2Bbetween.2BText">Plus+between+Text</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: Plus+between+Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1937 <p>section 3
1938 </p>
1939 <h2><span class="mw-headline" id="Plus-Entity.2Bbetween.2BText">Plus-Entity&#43;between&#43;Text</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: Plus-Entity+between+Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1940 <p>section 4
1941 </p>
1942 <h2><span class="mw-headline" id="Underscore_between_Text">Underscore_between_Text</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: Underscore_between_Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1943 <p>section 5
1944 </p>
1945 <h2><span class="mw-headline" id="Underscore-Entity_between_Text">Underscore-Entity&#95;between&#95;Text</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: Underscore-Entity_between_Text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
1946 <p>section 6
1947 </p><p><a href="#Space_between_Text">#Space between Text</a>
1948 <a href="#Space-Entity_between_Text">#Space-Entity&#32;between&#32;Text</a>
1949 <a href="#Plus.2Bbetween.2BText">#Plus+between+Text</a>
1950 <a href="#Plus-Entity.2Bbetween.2BText">#Plus-Entity&#43;between&#43;Text</a>
1951 <a href="#Underscore_between_Text">#Underscore_between_Text</a>
1952 <a href="#Underscore-Entity_between_Text">#Underscore-Entity&#95;between&#95;Text</a>
1953 </p>
1954 !! html/parsoid
1955 <p>Id should not contain + for spaces</p>
1956
1957 <h2 id="Space_between_Text">Space between Text</h2>
1958 <p>section 1</p>
1959
1960 <h2 id="Space-Entity_between_Text">Space-Entity<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#32;","srcContent":" "}'> </span>between<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#32;","srcContent":" "}'> </span>Text</h2>
1961 <p>section 2</p>
1962
1963 <h2 id="Plus+between+Text"><span id="Plus.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus+between+Text</h2>
1964 <p>section 3</p>
1965
1966 <h2 id="Plus-Entity+between+Text"><span id="Plus-Entity.2Bbetween.2BText" typeof="mw:FallbackId"></span>Plus-Entity<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#43;","srcContent":"+"}'>+</span>between<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#43;","srcContent":"+"}'>+</span>Text</h2>
1967 <p>section 4</p>
1968
1969 <h2 id="Underscore_between_Text">Underscore_between_Text</h2>
1970 <p>section 5</p>
1971
1972 <h2 id="Underscore-Entity_between_Text">Underscore-Entity<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#95;","srcContent":"_"}'>_</span>between<span typeof="mw:Entity" data-parsoid='{"src":"&amp;#95;","srcContent":"_"}'>_</span>Text</h2>
1973 <p>section 6</p>
1974
1975 <p><a rel="mw:WikiLink" href="./Parser_test#Space_between_Text" class="mw-selflink-fragment" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Space_between_Text"},"sa":{"href":"#Space between Text"}}'>#Space between Text</a>
1976 <a rel="mw:WikiLink" href="./Parser_test#Space-Entity_between_Text" class="mw-selflink-fragment" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Space-Entity_between_Text"},"sa":{"href":"#Space-Entity&amp;#32;between&amp;#32;Text"}}'>#Space-Entity between Text</a>
1977 <a rel="mw:WikiLink" href="./Parser_test#Plus+between+Text" class="mw-selflink-fragment" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Plus+between+Text"},"sa":{"href":"#Plus+between+Text"}}'>#Plus+between+Text</a>
1978 <a rel="mw:WikiLink" href="./Parser_test#Plus-Entity+between+Text" class="mw-selflink-fragment" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Plus-Entity+between+Text"},"sa":{"href":"#Plus-Entity&amp;#43;between&amp;#43;Text"}}'>#Plus-Entity+between+Text</a>
1979 <a rel="mw:WikiLink" href="./Parser_test#Underscore_between_Text" class="mw-selflink-fragment" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Underscore_between_Text"},"sa":{"href":"#Underscore_between_Text"}}'>#Underscore_between_Text</a>
1980 <a rel="mw:WikiLink" href="./Parser_test#Underscore-Entity_between_Text" class="mw-selflink-fragment" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Underscore-Entity_between_Text"},"sa":{"href":"#Underscore-Entity&amp;#95;between&amp;#95;Text"}}'>#Underscore-Entity_between_Text</a></p>
1981 !! end
1982
1983 # Parsoid html2wt disabled because it adds padding spaces around =
1984 !! test
1985 Headers with excess '=' characters
1986 (Are similar tests necessary beyond the 1st level?)
1987 !! options
1988 parsoid=wt2html,wt2wt,html2html
1989 !! config
1990 wgParserEnableLegacyHeadingDOM=true
1991 !! wikitext
1992 =foo==
1993 ==foo=
1994 =''italic'' heading==
1995 ==''italic'' heading=
1996 !! html/php
1997 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
1998 <ul>
1999 <li class="toclevel-1 tocsection-1"><a href="#foo.3D"><span class="tocnumber">1</span> <span class="toctext">foo=</span></a></li>
2000 <li class="toclevel-1 tocsection-2"><a href="#.3Dfoo"><span class="tocnumber">2</span> <span class="toctext">=foo</span></a></li>
2001 <li class="toclevel-1 tocsection-3"><a href="#italic_heading.3D"><span class="tocnumber">3</span> <span class="toctext"><i>italic</i> heading=</span></a></li>
2002 <li class="toclevel-1 tocsection-4"><a href="#.3Ditalic_heading"><span class="tocnumber">4</span> <span class="toctext">=<i>italic</i> heading</span></a></li>
2003 </ul>
2004 </div>
2005
2006 <h1><span class="mw-headline" id="foo.3D">foo=</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: foo=">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
2007 <h1><span class="mw-headline" id=".3Dfoo">=foo</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: =foo">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
2008 <h1><span class="mw-headline" id="italic_heading.3D"><i>italic</i> heading=</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: italic heading=">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
2009 <h1><span class="mw-headline" id=".3Ditalic_heading">=<i>italic</i> heading</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: =italic heading">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
2010 !! html/parsoid
2011 <h1 id="foo=" data-parsoid="{}"><span id="foo.3D" typeof="mw:FallbackId"></span>foo=</h1>
2012 <h1 id="=foo" data-parsoid="{}"><span id=".3Dfoo" typeof="mw:FallbackId"></span>=foo</h1>
2013 <h1 id="italic_heading=" data-parsoid="{}"><span id="italic_heading.3D" typeof="mw:FallbackId"></span><i>italic</i> heading=</h1>
2014 <h1 id="=italic_heading" data-parsoid="{}"><span id=".3Ditalic_heading" typeof="mw:FallbackId"></span>=<i>italic</i> heading</h1>
2015 !! end
2016
2017 !! test
2018 HTML headers vs TOC (T25393)
2019 (__NOEDITSECTION__ for clearer output, doesn't matter here)
2020 !! config
2021 wgParserEnableLegacyHeadingDOM=true
2022 !! wikitext
2023 <h1>Header 1</h1>
2024 ==Header 1.1==
2025 ==Header 1.2==
2026
2027 <h1>Header 2
2028 </h1>
2029 ==Header 2.1==
2030 ==Header 2.2==
2031 __NOEDITSECTION__
2032 !! html/php
2033 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
2034 <ul>
2035 <li class="toclevel-1"><a href="#Header_1"><span class="tocnumber">1</span> <span class="toctext">Header 1</span></a>
2036 <ul>
2037 <li class="toclevel-2 tocsection-1"><a href="#Header_1.1"><span class="tocnumber">1.1</span> <span class="toctext">Header 1.1</span></a></li>
2038 <li class="toclevel-2 tocsection-2"><a href="#Header_1.2"><span class="tocnumber">1.2</span> <span class="toctext">Header 1.2</span></a></li>
2039 </ul>
2040 </li>
2041 <li class="toclevel-1"><a href="#Header_2"><span class="tocnumber">2</span> <span class="toctext">Header 2</span></a>
2042 <ul>
2043 <li class="toclevel-2 tocsection-3"><a href="#Header_2.1"><span class="tocnumber">2.1</span> <span class="toctext">Header 2.1</span></a></li>
2044 <li class="toclevel-2 tocsection-4"><a href="#Header_2.2"><span class="tocnumber">2.2</span> <span class="toctext">Header 2.2</span></a></li>
2045 </ul>
2046 </li>
2047 </ul>
2048 </div>
2049
2050 <h1><span class="mw-headline" id="Header_1">Header 1</span></h1>
2051 <h2><span class="mw-headline" id="Header_1.1">Header 1.1</span></h2>
2052 <h2><span class="mw-headline" id="Header_1.2">Header 1.2</span></h2>
2053 <h1><span class="mw-headline" id="Header_2">Header 2
2054 </span></h1>
2055 <h2><span class="mw-headline" id="Header_2.1">Header 2.1</span></h2>
2056 <h2><span class="mw-headline" id="Header_2.2">Header 2.2</span></h2>
2057 !! html/parsoid
2058 <h1 id="Header_1" data-parsoid='{"stx":"html"}'>Header 1</h1>
2059 <h2 id="Header_1.1" data-parsoid='{}'>Header 1.1</h2>
2060 <h2 id="Header_1.2" data-parsoid='{}'>Header 1.2</h2>
2061
2062 <h1 id="Header_2" data-parsoid='{"stx":"html"}'>Header 2
2063 </h1>
2064 <h2 id="Header_2.1" data-parsoid='{}'>Header 2.1</h2>
2065 <h2 id="Header_2.2" data-parsoid='{}'>Header 2.2</h2>
2066 <meta property="mw:PageProp/noeditsection"/>
2067 !! end
2068
2069 !! test
2070 Out-of-order TOC heading levels
2071 !! config
2072 wgParserEnableLegacyHeadingDOM=true
2073 !! wikitext
2074 ==2==
2075 ======6======
2076 ===3===
2077 =1=
2078 =====5=====
2079 ==2==
2080 !! html/php
2081 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
2082 <ul>
2083 <li class="toclevel-1 tocsection-1"><a href="#2"><span class="tocnumber">1</span> <span class="toctext">2</span></a>
2084 <ul>
2085 <li class="toclevel-2 tocsection-2"><a href="#6"><span class="tocnumber">1.1</span> <span class="toctext">6</span></a></li>
2086 <li class="toclevel-2 tocsection-3"><a href="#3"><span class="tocnumber">1.2</span> <span class="toctext">3</span></a></li>
2087 </ul>
2088 </li>
2089 <li class="toclevel-1 tocsection-4"><a href="#1"><span class="tocnumber">2</span> <span class="toctext">1</span></a>
2090 <ul>
2091 <li class="toclevel-2 tocsection-5"><a href="#5"><span class="tocnumber">2.1</span> <span class="toctext">5</span></a></li>
2092 <li class="toclevel-2 tocsection-6"><a href="#2_2"><span class="tocnumber">2.2</span> <span class="toctext">2</span></a></li>
2093 </ul>
2094 </li>
2095 </ul>
2096 </div>
2097
2098 <h2><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=1" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2099 <h6><span class="mw-headline" id="6">6</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: 6">edit</a><span class="mw-editsection-bracket">]</span></span></h6>
2100 <h3><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=3" title="Edit section: 3">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
2101 <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=4" title="Edit section: 1">edit</a><span class="mw-editsection-bracket">]</span></span></h1>
2102 <h5><span class="mw-headline" id="5">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: 5">edit</a><span class="mw-editsection-bracket">]</span></span></h5>
2103 <h2><span class="mw-headline" id="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=6" title="Edit section: 2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2104 !! html/parsoid
2105 <h2 id="2" data-parsoid="{}">2</h2>
2106 <h6 id="6" data-parsoid="{}">6</h6>
2107 <h3 id="3" data-parsoid="{}">3</h3>
2108 <h1 id="1" data-parsoid="{}">1</h1>
2109 <h5 id="5" data-parsoid="{}">5</h5>
2110 <h2 id="2_2" data-parsoid="{}">2</h2>
2111 !! end
2112
2113 # Note that HTML (but not wikitext) allows the trailing semicolon to
2114 # be omitted from an entity, so we need to escape the ampersand in
2115 # situations where HTML would interpret a "semicolonless" entity.
2116 !! test
2117 TOC with HTML entities which are not wikitext entities (T355386)
2118 !! config
2119 wgFragmentMode=[ "html5" ]
2120 wgParserEnableLegacyHeadingDOM=true
2121 !! options
2122 nohtml
2123 showtocdata
2124 parsoid={
2125 "modes": [ "wt2html" ],
2126 "wrapSections": true
2127 }
2128 !! wikitext
2129 __TOC__
2130 == F&GT ==
2131 Test
2132 !! metadata
2133 Sections:
2134 h2 index:1 toclevel:1 number:1 title:Parser_test off:8 anchor/linkAnchor:F&GT line:F&amp;GT
2135 !! end
2136
2137 # Note that the metadata section below contains non-breaking spaces around
2138 # the french quotes, which also show up in the link anchor
2139 !! test
2140 TOC with french spacing (T324763)
2141 !! config
2142 wgFragmentMode=[ "html5" ]
2143 wgParserEnableLegacyHeadingDOM=true
2144 !! options
2145 nohtml
2146 showtocdata
2147 parsoid={
2148 "modes": [ "wt2html" ],
2149 "wrapSections": true
2150 }
2151 !! wikitext
2152 __TOC__
2153 == Renommer la page « Informatique durable » en « Numérique responsable » ? ==
2154 Oui.
2155 !! metadata/php
2156 Sections:
2157 h2 index:1 toclevel:1 number:1 title:Parser_test off:8 anchor/linkAnchor:Renommer_la_page_«_Informatique_durable_»_en_«_Numérique_responsable_»_? line:Renommer la page « Informatique durable » en « Numérique responsable » ?
2158 !! metadata/parsoid
2159 Sections:
2160 h2 index:1 toclevel:1 number:1 title:Parser_test off:8 anchor/linkAnchor:Renommer_la_page_«_Informatique_durable_»_en_«_Numérique_responsable_»_? line:Renommer la page «<span> </span>Informatique durable<span> </span>» en «<span> </span>Numérique responsable<span> </span>»<span> </span>?
2161 !! end
2162
2163 !! test
2164 1. Ensure sections in extensions are ignored + TOC is inserted outside extensions
2165 !! options
2166 showtocdata
2167 parsoid={
2168 "modes": [ "wt2html" ],
2169 "wrapSections": true
2170 }
2171 !! config
2172 wgParserEnableLegacyHeadingDOM=true
2173 !! wikitext
2174 __FORCETOC__
2175 <spantag>
2176 ==spantag h2==
2177 </spantag>
2178 intro
2179 ==page h2==
2180 blah
2181 !! html/php
2182 <p><span>
2183 </span></p>
2184 <h2><span class="mw-headline" id="spantag_h2">spantag h2</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: spantag h2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2185 <p>intro
2186 </p>
2187 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
2188 <ul>
2189 <li class="toclevel-1 tocsection-1"><a href="#page_h2"><span class="tocnumber">1</span> <span class="toctext">page h2</span></a></li>
2190 </ul>
2191 </div>
2192
2193 <h2><span class="mw-headline" id="page_h2">page h2</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: page h2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2194 <p>blah
2195 </p>
2196 !! html/parsoid
2197 <section data-mw-section-id="-1"><meta property="mw:PageProp/forcetoc"/> </section><section data-mw-section-id="-2"><span typeof="mw:Extension/spantag" data-mw='{"name":"spantag","attrs":{},"body":{"extsrc":"\n==spantag h2==\n"}}'>
2198 <section data-mw-section-id="-1"><h2 id="spantag_h2">spantag h2</h2></section></span>
2199 <p>intro</p>
2200 <meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="1"><h2 id="page_h2">page h2</h2>
2201 <p>blah</p></section>
2202 !! metadata
2203 Sections:
2204 h2 index:1 toclevel:1 number:1 title:Parser_test off:55 anchor/linkAnchor:page_h2 line:page h2
2205 !! end
2206
2207 !! test
2208 2. Ensure sections in extensions are ignored + TOC is inserted outside extensions
2209 !! options
2210 showtocdata
2211 parsoid={
2212 "modes": [ "wt2html" ],
2213 "wrapSections": true
2214 }
2215 !! config
2216 wgParserEnableLegacyHeadingDOM=true
2217 !! wikitext
2218 __FORCETOC__
2219 {{1x|1=foo
2220 <spantag>
2221 ==spantag h2==
2222 </spantag>
2223 }}
2224 intro
2225 ==page h2==
2226 blah
2227 !! html/php
2228 <p>foo
2229 <span>
2230 </span></p>
2231 <h2><span class="mw-headline" id="spantag_h2">spantag h2</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: spantag h2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2232 <p>intro
2233 </p>
2234 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
2235 <ul>
2236 <li class="toclevel-1 tocsection-1"><a href="#page_h2"><span class="tocnumber">1</span> <span class="toctext">page h2</span></a></li>
2237 </ul>
2238 </div>
2239
2240 <h2><span class="mw-headline" id="page_h2">page h2</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: page h2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2241 <p>blah
2242 </p>
2243 !! html/parsoid
2244 <section data-mw-section-id="-1" about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":["__FORCETOC__\n",{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"foo\n&lt;spantag>\n==spantag h2==\n&lt;/spantag>"}},"i":0}},"\nintro\n"]}'><meta property="mw:PageProp/forcetoc" />
2245 <p about="#mwt2" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"foo\n&lt;spantag>\n==spantag h2==\n&lt;/spantag>"}},"i":0}}]}'>foo</p><span about="#mwt2">
2246 </span></section><section data-mw-section-id="-2" about="#mwt4"><span typeof="mw:Extension/spantag" about="#mwt2" data-mw='{"name":"spantag","attrs":{},"body":{"extsrc":"\n==spantag h2==\n"}}'>
2247 <section data-mw-section-id="-1"><h2 id="spantag_h2">spantag h2</h2></section></span>
2248 <p>intro</p>
2249 <meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="1"><h2 id="page_h2">page h2</h2>
2250 <p>blah</p></section>
2251 !! metadata
2252 Sections:
2253 h2 index:1 toclevel:1 number:1 title:Parser_test off:69 anchor/linkAnchor:page_h2 line:page h2
2254 !! end
2255
2256 !! test
2257 3. Ensure sections in extensions are ignored + TOC is inserted outside extensions
2258 !! options
2259 showtocdata
2260 parsoid={
2261 "modes": [ "wt2html" ],
2262 "wrapSections": true
2263 }
2264 !! config
2265 wgParserEnableLegacyHeadingDOM=true
2266 !! wikitext
2267 __FORCETOC__
2268 {{1x|1=<spantag>
2269 ==spantag h2==
2270 </spantag>
2271 ==template h2==
2272 }}
2273 intro
2274 ==page h2==
2275 blah
2276 !! html/php
2277 <p><span>
2278 </span></p>
2279 <h2><span class="mw-headline" id="spantag_h2">spantag h2</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: spantag h2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2280 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
2281 <ul>
2282 <li class="toclevel-1"><a href="#template_h2"><span class="tocnumber">1</span> <span class="toctext">template h2</span></a></li>
2283 <li class="toclevel-1 tocsection-2"><a href="#page_h2"><span class="tocnumber">2</span> <span class="toctext">page h2</span></a></li>
2284 </ul>
2285 </div>
2286
2287 <h2><span class="mw-headline" id="template_h2">template h2</span></h2>
2288 <p>intro
2289 </p>
2290 <h2><span class="mw-headline" id="page_h2">page h2</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: page h2">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2291 <p>blah
2292 </p>
2293 !! html/parsoid
2294 <section data-mw-section-id="-1"><meta property="mw:PageProp/forcetoc" data-parsoid='{"src":"__FORCETOC__","magicSrc":"__FORCETOC__"}'/>
2295 </section><section data-mw-section-id="-2" about="#mwt4" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;spantag>\n==spantag h2==\n&lt;/spantag>\n==template h2=="}},"i":0}},"\nintro\n"]}'><span typeof="mw:Extension/spantag mw:Transclusion" about="#mwt2" data-parsoid='{"pi":[[{"k":"1","named":true,"spc":["","","","\n"]}]],"dsr":[13,74,null,null]}' data-mw='{"name":"spantag","attrs":{},"body":{"extsrc":"\n==spantag h2==\n"},"parts":[{"template":{"target":{"wt":"1x","href":"./Template:1x"},"params":{"1":{"wt":"&lt;spantag>\n==spantag h2==\n&lt;/spantag>\n==template h2=="}},"i":0}}]}'>
2296 <section data-mw-section-id="-1"><h2 id="spantag_h2">spantag h2</h2>
2297 </section></span><span about="#mwt2">
2298 </span><meta property="mw:PageProp/toc" data-mw='{"autoGenerated":true}'/></section><section data-mw-section-id="-1" about="#mwt4"><h2 about="#mwt2" id="template_h2">template h2</h2>
2299 <p>intro</p>
2300 </section><section data-mw-section-id="2"><h2 id="page_h2">page h2</h2>
2301 <p>blah</p></section>
2302 !! metadata/php
2303 Sections:
2304 h2 index: toclevel:1 number:1 title:NULL off:NULL anchor/linkAnchor:template_h2 line:template h2
2305 h2 index:2 toclevel:1 number:2 title:Parser_test off:81 anchor/linkAnchor:page_h2 line:page h2
2306 !! metadata/parsoid
2307 Sections:
2308 h2 index:T-1 toclevel:1 number:1 title:Template:1x off:NULL anchor/linkAnchor:template_h2 line:template h2
2309 h2 index:2 toclevel:1 number:2 title:Parser_test off:81 anchor/linkAnchor:page_h2 line:page h2
2310 !! end
2311
2312 !! test
2313 TOC data when heading content is equal to an id already set on the page
2314 !! options
2315 showtocdata
2316 parsoid={
2317 "modes": [ "wt2html" ],
2318 "wrapSections": true
2319 }
2320 !! config
2321 wgParserEnableLegacyHeadingDOM=true
2322 !! wikitext
2323 <span id="hiho">hiho</span>
2324 === hiho ===
2325 !! html/php
2326 <p><span id="hiho">hiho</span>
2327 </p>
2328 <h3><span class="mw-headline" id="hiho">hiho</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: hiho">edit</a><span class="mw-editsection-bracket">]</span></span></h3>
2329 !! metadata/php
2330 Sections:
2331 h3 index:1 toclevel:1 number:1 title:Parser_test off:28 anchor/linkAnchor:hiho line:hiho
2332 !! html/parsoid
2333 <section data-mw-section-id="0"><p><span id="hiho">hiho</span></p>
2334 </section><section data-mw-section-id="1"><h3 id="hiho_2">hiho</h3></section>
2335 !! metadata/parsoid
2336 Sections:
2337 h3 index:1 toclevel:1 number:1 title:Parser_test off:28 anchor/linkAnchor:hiho_2 line:hiho
2338 !! end
2339
2340 !! test
2341 TOC data when heading already has an id
2342 !! options
2343 showtocdata
2344 parsoid={
2345 "modes": [ "wt2html" ],
2346 "wrapSections": true
2347 }
2348 !! config
2349 wgParserEnableLegacyHeadingDOM=true
2350 !! wikitext
2351 <h3 id="asdf">odd</h3>
2352 !! html/php
2353 <h3 id="asdf"><span class="mw-headline">odd</span></h3>
2354 !! metadata/php
2355 Sections:
2356 h3 index: toclevel:1 number:1 title:NULL off:NULL anchor/linkAnchor:asdf line:odd
2357 !! html/parsoid
2358 <section data-mw-section-id="0"></section><section data-mw-section-id="-1"><h3 id="asdf" data-parsoid='{"stx":"html","reusedId":true}'>odd</h3></section>
2359 !! metadata/parsoid
2360 Sections:
2361 h3 index: toclevel:1 number:1 title:NULL off:NULL anchor/linkAnchor:asdf line:odd
2362 !! end
2363
2364 !! test
2365 Extra newlines followed by heading
2366 !! config
2367 wgParserEnableLegacyHeadingDOM=true
2368 !! wikitext
2369 a
2370
2371
2372 =b=
2373 [[a]]
2374
2375
2376 =b=
2377 !! html
2378 <p>a
2379 </p><p><br />
2380 </p>
2381 <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>
2382 <p><a href="/wiki/A" title="A">a</a>
2383 </p><p><br />
2384 </p>
2385 <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>
2386 !! end
2387
2388 !! article
2389 A
2390 !! text
2391 Dummy article to suppress redlinks in tests
2392 !! end
2393
2394 !! test
2395 Extra newlines between heading and content are swallowed (Parsoid does not)
2396 !! config
2397 wgParserEnableLegacyHeadingDOM=true
2398 !! wikitext
2399 =b=
2400
2401
2402
2403 [[a]]
2404 !! html/php
2405 <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>
2406 <p><a href="/wiki/A" title="A">a</a>
2407 </p>
2408 !! html/parsoid
2409 <h1 id="b">b</h1>
2410 <p>
2411 <br/></p>
2412
2413 <p><a rel="mw:WikiLink" href="./A" title="A" data-parsoid='{"stx":"simple","a":{"href":"./A"},"sa":{"href":"a"}}'>a</a></p>
2414 !! end
2415
2416 !! test
2417 Heading with line break in nowiki
2418 !! options
2419 parsoid=wt2html
2420 !! config
2421 wgFragmentMode=[ "html5", "legacy" ]
2422 wgParserEnableLegacyHeadingDOM=true
2423 !! wikitext
2424 ==A <nowiki>B
2425 C</nowiki>==
2426 !! html/php
2427 <h2><span id="A_B.0AC"></span><span class="mw-headline" id="A_B_C">A B
2428 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>
2429 !! html/parsoid
2430 <h2 id="A_B_C"><span id="A_B.0AC" typeof="mw:FallbackId"></span>A <span typeof="mw:Nowiki">B
2431 C</span></h2>
2432 !! end
2433
2434 !! test
2435 Heading with nonbreaking space in prefix/suffix (T235684)
2436 !! options
2437 parsoid=wt2html,html2html
2438 !! config
2439 wgFragmentMode=[ "html5", "legacy" ]
2440 wgParserEnableLegacyHeadingDOM=true
2441 !! wikitext
2442 == &nbsp; A &nbsp; B &nbsp; ==
2443 !! html/php
2444 <h2><span class="mw-headline" id="_A_B">&#160; A &#160; B &#160;</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: &#160; A &#160; B &#160;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2445 !! html/parsoid
2446 <h2 id="_A_B"><span typeof="mw:Entity"> </span> A <span typeof="mw:Entity"> </span> B <span typeof="mw:Entity"> </span></h2>
2447 !! end
2448
2449 !! test
2450 Heading with literal wikitext - the wikitext is not parsed in section edit link tooltip
2451 !! config
2452 wgFragmentMode=[ "html5" ]
2453 wgParserEnableLegacyHeadingDOM=true
2454 !! wikitext
2455 == <nowiki>{{PAGENAME}}</nowiki> ==
2456 == &#123;&#123;PAGENAME}} ==
2457 !! html/php
2458 <h2><span class="mw-headline" id="{{PAGENAME}}">{{PAGENAME}}</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: {{PAGENAME}}">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2459 <h2><span class="mw-headline" id="{{PAGENAME}}_2">&#123;&#123;PAGENAME}}</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: {{PAGENAME}}">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2460 !! end
2461
2462 !! article
2463 Template:Includeonly section
2464 !! text
2465 <includeonly>
2466 ==Includeonly section==
2467 </includeonly>
2468 ==Section T-1==
2469 !!endarticle
2470
2471 !! test
2472 T8563: Edit link generation for section shown by <includeonly>
2473 !! config
2474 wgParserEnableLegacyHeadingDOM=true
2475 !! wikitext
2476 {{includeonly section}}
2477 !! html
2478 <h2><span class="mw-headline" id="Includeonly_section">Includeonly section</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Includeonly_section&amp;action=edit&amp;section=T-1" title="Edit section: Includeonly section">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2479 <h2><span class="mw-headline" id="Section_T-1">Section T-1</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=Template:Includeonly_section&amp;action=edit&amp;section=T-2" title="Edit section: Section T-1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2480 !! end
2481
2482 !! test
2483 T8563: Edit link generation for section suppressed by <includeonly>
2484 !! config
2485 wgParserEnableLegacyHeadingDOM=true
2486 !! wikitext
2487 <includeonly>
2488 ==Includeonly section==
2489 </includeonly>
2490 ==Section 1==
2491 !! html
2492 <h2><span class="mw-headline" id="Section_1">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: Section 1">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2493 !! end
2494
2495 # Note that Parsoid output differs from the PHP parser here: the PHP
2496 # parser breaks the URL for the magic word, while in Parsoid the URL
2497 # production takes precedence.
2498 !! test
2499 Fuzz testing: Parser14
2500 !! config
2501 wgParserEnableLegacyHeadingDOM=true
2502 !! wikitext
2503 ==onmouseover===
2504 http://__TOC__
2505 !! html/php
2506 <h2><span class="mw-headline" id="onmouseover.3D">onmouseover=</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: onmouseover=">edit</a><span class="mw-editsection-bracket">]</span></span></h2><p>
2507 http://</p><div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
2508 <ul>
2509 <li class="toclevel-1 tocsection-1"><a href="#onmouseover.3D"><span class="tocnumber">1</span> <span class="toctext">onmouseover=</span></a></li>
2510 </ul>
2511 </div>
2512 !! html/parsoid
2513 <h2 id="onmouseover="><span id="onmouseover.3D" typeof="mw:FallbackId"></span>onmouseover=</h2>
2514 <p><a rel="mw:ExtLink" href="http://__TOC__" class="external free" data-parsoid='{"stx":"url"}'>http://__TOC__</a></p>
2515 !! end
2516
2517 !! test
2518 Fuzz testing: Parser14-table
2519 !! options
2520 parsoid=wt2html,html2html
2521 !! config
2522 wgParserEnableLegacyHeadingDOM=true
2523 !! wikitext
2524 ==a==
2525 {| STYLE=__TOC__
2526 !! html/php
2527 <h2><span class="mw-headline" id="a">a</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">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2528 <table style="&#95;&#95;TOC&#95;&#95;">
2529 <tbody><tr><td></td></tr>
2530 </tbody></table>
2531 !! html/parsoid
2532 <h2 id="a">a</h2>
2533 <table style="__TOC__"></table>
2534 !! end
2535
2536
2537 !! article
2538 MediaWiki:Fake
2539 !! text
2540 ==header==
2541 !! endarticle
2542
2543 !! test
2544 Inclusion of !userCanEdit() content
2545 !! config
2546 wgParserEnableLegacyHeadingDOM=true
2547 !! wikitext
2548 {{MediaWiki:Fake}}
2549 !! html
2550 <h2><span class="mw-headline" id="header">header</span><span class="mw-editsection"><span class="mw-editsection-bracket">[</span><a href="/index.php?title=MediaWiki:Fake&amp;action=edit&amp;section=T-1" title="Edit section: header">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2551 !! end
2552
2553 !! test
2554 Morwen/13: Unclosed link followed by heading
2555 !! config
2556 wgParserEnableLegacyHeadingDOM=true
2557 !! wikitext
2558 [[link
2559 ==heading==
2560 !! html
2561 <p>[[link
2562 </p>
2563 <h2><span class="mw-headline" id="heading">heading</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: heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2564 !! end
2565
2566 !! test
2567 HHP2.1: Heuristics for headings in preprocessor parenthetical structures
2568 !! config
2569 wgParserEnableLegacyHeadingDOM=true
2570 !! wikitext
2571 {{foo|
2572 =heading=
2573 !! html
2574 <p>{{foo|
2575 </p>
2576 <h1><span class="mw-headline" id="heading">heading</span></h1>
2577 !! end
2578
2579 !! test
2580 HHP2.2: Heuristics for headings in preprocessor parenthetical structures
2581 !! config
2582 wgParserEnableLegacyHeadingDOM=true
2583 !! wikitext
2584 {{foo|
2585 ==heading==
2586 !! html
2587 <p>{{foo|
2588 </p>
2589 <h2><span class="mw-headline" id="heading">heading</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: heading">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2590 !! end
2591
2592 !!article
2593 Foo
2594 !!text
2595 FOO
2596 !!endarticle
2597
2598 !! test
2599 nowiki inside link inside heading (T20295)
2600 !! config
2601 wgParserEnableLegacyHeadingDOM=true
2602 !! wikitext
2603 ==[[foo|x<nowiki>y</nowiki>z]]==
2604 !! html
2605 <h2><span class="mw-headline" id="xyz"><a href="/wiki/Foo" title="Foo">xyz</a></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: xyz">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2606 !! end
2607
2608 !! test
2609 Decoding of HTML entities in headings and links for IDs and link fragments (T103714)
2610 !! config
2611 wgFragmentMode=[ "html5", "legacy" ]
2612 wgParserEnableLegacyHeadingDOM=true
2613 !! options
2614 showtocdata
2615 parsoid={
2616 "wrapSections": true
2617 }
2618 !! wikitext
2619 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
2620 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
2621 !! html/php
2622 <h2><span id="A.26B.26C.26amp.3BD.26amp.3Bamp.3BE"></span><span class="mw-headline" id="A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E">A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</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&amp;B&amp;C&amp;amp;D&amp;amp;amp;E">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2623 <p><a href="#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
2624 </p>
2625 !! html/parsoid
2626 <section data-mw-section-id="0"></section><section data-mw-section-id="1"><h2 id="A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E"><span id="A.26B.26C.26amp.3BD.26amp.3Bamp.3BE" typeof="mw:FallbackId"></span>A&amp;B<span typeof="mw:Entity" data-parsoid='{"src":"&amp;amp;","srcContent":"&amp;"}'>&amp;</span>C<span typeof="mw:Entity" data-parsoid='{"src":"&amp;amp;","srcContent":"&amp;"}'>&amp;</span>amp;D<span typeof="mw:Entity" data-parsoid='{"src":"&amp;amp;","srcContent":"&amp;"}'>&amp;</span>amp;amp;E</h2>
2627 <p><a rel="mw:WikiLink" href="./Parser_test#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E" class="mw-selflink-fragment" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E"},"sa":{"href":"#A&amp;B&amp;amp;C&amp;amp;amp;D&amp;amp;amp;amp;E"}}'>#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a></p></section>
2628 !! metadata
2629 Sections:
2630 h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:A&B&C&amp;D&amp;amp;E line:A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E
2631 !! end
2632
2633 !! test
2634 Decoding of HTML entities in headings and links for IDs and link fragments (T103714) (legacy)
2635 !! config
2636 wgFragmentMode=[ "legacy" ]
2637 wgParserEnableLegacyHeadingDOM=true
2638 !! wikitext
2639 ==A&B&amp;C&amp;amp;D&amp;amp;amp;E==
2640 [[#A&B&amp;C&amp;amp;D&amp;amp;amp;E]]
2641 !! html/php
2642 <h2><span class="mw-headline" id="A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</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&amp;B&amp;C&amp;amp;D&amp;amp;amp;E">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2643 <p><a href="#A.26B.26C.26amp.3BD.26amp.3Bamp.3BE">#A&amp;B&amp;C&amp;amp;D&amp;amp;amp;E</a>
2644 </p>
2645 !! end
2646
2647 # This fragment mode is what Parsoid supports.
2648 !! test
2649 HTML5 ids: fallback to legacy
2650 !! config
2651 wgFragmentMode=[ "html5", "legacy" ]
2652 wgParserEnableLegacyHeadingDOM=true
2653 !! wikitext
2654 ==Foo bar==
2655
2656 ==foo Bar==
2657
2658 ==Тест==
2659
2660 ==Тест==
2661
2662 ==тест==
2663
2664 ==Hey < # " > % : '==
2665 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
2666
2667 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
2668
2669 <!-- These two links should produce identical HTML -->
2670 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
2671
2672 !! html/php
2673 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
2674 <ul>
2675 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
2676 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
2677 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
2678 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
2679 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
2680 <li class="toclevel-1 tocsection-6"><a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
2681 </ul>
2682 </div>
2683
2684 <h2><span class="mw-headline" id="Foo_bar">Foo bar</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: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2685 <h2><span class="mw-headline" id="foo_Bar_2">foo Bar</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: foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2686 <h2><span id=".D0.A2.D0.B5.D1.81.D1.82"></span><span class="mw-headline" id="Тест">Тест</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: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2687 <h2><span id=".D0.A2.D0.B5.D1.81.D1.82_2"></span><span class="mw-headline" id="Тест_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: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2688 <h2><span id=".D1.82.D0.B5.D1.81.D1.82"></span><span class="mw-headline" id="тест">тест</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: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2689 <h2><span id="Hey_.3C_.23_.22_.3E_.25_:_.27"></span><span class="mw-headline" id="Hey_&lt;_#_&quot;_&gt;_%_:_'">Hey &lt; # " &gt;&#160;%&#160;: '</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: Hey &lt; # &quot; &gt;&#160;%&#160;: &#39;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2690 <p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
2691 </p><p>💩 <span id="💩"></span>
2692 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
2693 </p>
2694 !! html/parsoid
2695 <h2 id="Foo_bar">Foo bar</h2>
2696
2697 <h2 id="foo_Bar_2">foo Bar</h2>
2698
2699 <h2 id="Тест"><span id=".D0.A2.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>Тест</h2>
2700
2701 <h2 id="Тест_2"><span id=".D0.A2.D0.B5.D1.81.D1.82_2" typeof="mw:FallbackId"></span>Тест</h2>
2702
2703 <h2 id="тест"><span id=".D1.82.D0.B5.D1.81.D1.82" typeof="mw:FallbackId"></span>тест</h2>
2704
2705 <h2 id="Hey_&lt;_#_&quot;_>_%_:_'"><span id="Hey_.3C_.23_.22_.3E_.25_:_.27" typeof="mw:FallbackId"></span>Hey &lt; # " ><span typeof="mw:DisplaySpace"> </span>%<span typeof="mw:DisplaySpace"> </span>: '</h2>
2706 <p><a rel="mw:WikiLink" href="./Parser_test#Foo_bar" class="mw-selflink-fragment">#Foo bar</a> <a rel="mw:WikiLink" href="./Parser_test#foo_Bar" class="mw-selflink-fragment">#foo Bar</a> <a rel="mw:WikiLink" href="./Parser_test#Тест" class="mw-selflink-fragment">#Тест</a> <a rel="mw:WikiLink" href="./Parser_test#тест" class="mw-selflink-fragment">#тест</a> <a rel="mw:WikiLink" href="./Parser_test#Hey_&lt;_#_&quot;_>_%_:_'" class="mw-selflink-fragment">#Hey &lt; # " ><span typeof="mw:DisplaySpace"> </span>%<span typeof="mw:DisplaySpace"> </span>: '</a></p>
2707
2708 <p><span about="#mwt1" typeof="mw:Transclusion" data-mw='{"parts":[{"template":{"target":{"wt":"anchorencode:💩","function":"anchorencode"},"params":{},"i":0}}]}'>💩</span> <span id="💩" about="#mwt3" typeof="mw:ExpandedAttrs" data-mw='{"attribs":[[{"txt":"id"},{"html":"&lt;span about=\"#mwt2\" typeof=\"mw:Transclusion\" data-parsoid=&#39;{\"pi\":[[]],\"dsr\":[178,197,null,null]}&#39; data-mw=&#39;{\"parts\":[{\"template\":{\"target\":{\"wt\":\"anchorencode:💩\",\"function\":\"anchorencode\"},\"params\":{},\"i\":0}}]}&#39;>💩&lt;/span>"}]]}'></span></p>
2709
2710 <!-- These two links should produce identical HTML -->
2711 <p><a rel="mw:WikiLink" href="./Parser_test#啤酒" class="mw-selflink-fragment">#啤酒</a> <a rel="mw:WikiLink" href="./Parser_test#啤酒" class="mw-selflink-fragment" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#啤酒"},"sa":{"href":"#%E5%95%A4%E9%85%92"}}'>#啤酒</a></p>
2712 !! end
2713
2714 # Parsoid doesn't support this mode
2715 !! test
2716 HTML5 ids: legacy with a fallback to modern
2717 !! config
2718 wgFragmentMode=[ "legacy", "html5" ]
2719 wgParserEnableLegacyHeadingDOM=true
2720 !! wikitext
2721 ==Foo bar==
2722
2723 ==foo Bar==
2724
2725 ==Тест==
2726
2727 ==Тест==
2728
2729 ==тест==
2730
2731 ==Hey < # " > % : '==
2732 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
2733
2734 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
2735
2736 <!-- These two links should produce identical HTML -->
2737 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
2738
2739 !! html/php
2740 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
2741 <ul>
2742 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
2743 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
2744 <li class="toclevel-1 tocsection-3"><a href="#.D0.A2.D0.B5.D1.81.D1.82"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
2745 <li class="toclevel-1 tocsection-4"><a href="#.D0.A2.D0.B5.D1.81.D1.82_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
2746 <li class="toclevel-1 tocsection-5"><a href="#.D1.82.D0.B5.D1.81.D1.82"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
2747 <li class="toclevel-1 tocsection-6"><a href="#Hey_.3C_.23_.22_.3E_.25_:_.27"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
2748 </ul>
2749 </div>
2750
2751 <h2><span class="mw-headline" id="Foo_bar">Foo bar</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: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2752 <h2><span class="mw-headline" id="foo_Bar_2">foo Bar</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: foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2753 <h2><span id="Тест"></span><span class="mw-headline" id=".D0.A2.D0.B5.D1.81.D1.82">Тест</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: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2754 <h2><span id="Тест_2"></span><span class="mw-headline" id=".D0.A2.D0.B5.D1.81.D1.82_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: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2755 <h2><span id="тест"></span><span class="mw-headline" id=".D1.82.D0.B5.D1.81.D1.82">тест</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: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2756 <h2><span id="Hey_&lt;_#_&quot;_&gt;_%_:_'"></span><span class="mw-headline" id="Hey_.3C_.23_.22_.3E_.25_:_.27">Hey &lt; # " &gt;&#160;%&#160;: '</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: Hey &lt; # &quot; &gt;&#160;%&#160;: &#39;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2757 <p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#.D0.A2.D0.B5.D1.81.D1.82">#Тест</a> <a href="#.D1.82.D0.B5.D1.81.D1.82">#тест</a> <a href="#Hey_.3C_.23_.22_.3E_.25_:_.27">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
2758 </p><p>.F0.9F.92.A9 <span id=".F0.9F.92.A9"></span>
2759 </p><p><a href="#.E5.95.A4.E9.85.92">#啤酒</a> <a href="#.E5.95.A4.E9.85.92">#啤酒</a>
2760 </p>
2761 !! end
2762
2763 # Parsoid doesn't support this mode.
2764 !! test
2765 HTML5 ids: no legacy
2766 !! config
2767 wgFragmentMode=[ "html5" ]
2768 wgParserEnableLegacyHeadingDOM=true
2769 !! wikitext
2770 ==Foo bar==
2771
2772 ==foo Bar==
2773
2774 ==Тест==
2775
2776 ==Тест==
2777
2778 ==тест==
2779
2780 ==Hey < # " > % : '==
2781 [[#Foo bar]] [[#foo Bar]] [[#Тест]] [[#тест]] [[#Hey < # " > % : ']]
2782
2783 {{anchorencode:💩}} <span id="{{anchorencode:💩}}"></span>
2784
2785 <!-- These two links should produce identical HTML -->
2786 [[#啤酒]] [[#%E5%95%A4%E9%85%92]]
2787
2788 !! html/php
2789 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
2790 <ul>
2791 <li class="toclevel-1 tocsection-1"><a href="#Foo_bar"><span class="tocnumber">1</span> <span class="toctext">Foo bar</span></a></li>
2792 <li class="toclevel-1 tocsection-2"><a href="#foo_Bar_2"><span class="tocnumber">2</span> <span class="toctext">foo Bar</span></a></li>
2793 <li class="toclevel-1 tocsection-3"><a href="#Тест"><span class="tocnumber">3</span> <span class="toctext">Тест</span></a></li>
2794 <li class="toclevel-1 tocsection-4"><a href="#Тест_2"><span class="tocnumber">4</span> <span class="toctext">Тест</span></a></li>
2795 <li class="toclevel-1 tocsection-5"><a href="#тест"><span class="tocnumber">5</span> <span class="toctext">тест</span></a></li>
2796 <li class="toclevel-1 tocsection-6"><a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;"><span class="tocnumber">6</span> <span class="toctext">Hey &lt; # " &gt;&#160;%&#160;: '</span></a></li>
2797 </ul>
2798 </div>
2799
2800 <h2><span class="mw-headline" id="Foo_bar">Foo bar</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: Foo bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2801 <h2><span class="mw-headline" id="foo_Bar_2">foo Bar</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: foo Bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2802 <h2><span class="mw-headline" id="Тест">Тест</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: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2803 <h2><span class="mw-headline" id="Тест_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: Тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2804 <h2><span class="mw-headline" id="тест">тест</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: тест">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2805 <h2><span class="mw-headline" id="Hey_&lt;_#_&quot;_&gt;_%_:_'">Hey &lt; # " &gt;&#160;%&#160;: '</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: Hey &lt; # &quot; &gt;&#160;%&#160;: &#39;">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2806 <p><a href="#Foo_bar">#Foo bar</a> <a href="#foo_Bar">#foo Bar</a> <a href="#Тест">#Тест</a> <a href="#тест">#тест</a> <a href="#Hey_&lt;_#_&quot;_&gt;_%_:_&#39;">#Hey &lt; # " &gt;&#160;%&#160;: '</a>
2807 </p><p>💩 <span id="💩"></span>
2808 </p><p><a href="#啤酒">#啤酒</a> <a href="#啤酒">#啤酒</a>
2809 </p>
2810 !! end
2811
2812 !! test
2813 T90902: Normalize weird characters in section IDs
2814 !! config
2815 wgFragmentMode=[ "html5", "legacy" ]
2816 wgParserEnableLegacyHeadingDOM=true
2817 !! wikitext
2818 ==Foo&nbsp;bar==
2819 [[#Foo&nbsp;bar]]
2820
2821 !! html/php
2822 <h2><span class="mw-headline" id="Foo_bar">Foo&#160;bar</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: Foo&#160;bar">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2823 <p><a href="#Foo_bar">#Foo&#160;bar</a>
2824 </p>
2825 !! html/parsoid
2826 <h2 id="Foo_bar">Foo<span typeof="mw:Entity" data-parsoid='{"src":"&amp;nbsp;","srcContent":" "}'> </span>bar</h2>
2827 <p><a rel="mw:WikiLink" href="./Parser_test#Foo_bar" class="mw-selflink-fragment" data-parsoid='{"stx":"simple","a":{"href":"./Parser_test#Foo_bar"},"sa":{"href":"#Foo&amp;nbsp;bar"}}'>#Foo bar</a></p>
2828 !! end
2829
2830 !! test
2831 mw-heading wrapper edge cases
2832 !! options
2833 notoc
2834 !! config
2835 wgParserEnableLegacyHeadingDOM=true
2836 !! wikitext
2837 ==Normal heading!==
2838
2839 <h2>HTML heading!</h2>
2840
2841 <h2 style="border: 1px solid green; background: lightgreen; padding: 5px; font-size: 1.5em;">HTML heading with attributes!</h2>
2842
2843 <div class="mw-heading mw-heading2">
2844 ==Normal heading with existing wrapper!==
2845 </div>
2846 !! html/php
2847
2848 <h2><span class="mw-headline" id="Normal_heading.21">Normal heading!</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: Normal heading!">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2849 <h2><span class="mw-headline" id="HTML_heading.21">HTML heading!</span></h2>
2850 <h2 style="border: 1px solid green; background: lightgreen; padding: 5px; font-size: 1.5em;"><span class="mw-headline" id="HTML_heading_with_attributes.21">HTML heading with attributes!</span></h2>
2851 <div class="mw-heading mw-heading2">
2852 <h2><span class="mw-headline" id="Normal_heading_with_existing_wrapper.21">Normal heading with existing wrapper!</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: Normal heading with existing wrapper!">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2853 </div>
2854 !! html/parsoid
2855 <h2 id="Normal_heading!" data-parsoid='{"dsr":[0,19,2,2]}'><span id="Normal_heading.21" typeof="mw:FallbackId" data-parsoid='{"dsr":[2,2,null,null]}'></span>Normal heading!</h2>
2856
2857 <h2 id="HTML_heading!" data-parsoid='{"stx":"html","dsr":[21,43,4,5]}'><span id="HTML_heading.21" typeof="mw:FallbackId" data-parsoid='{"dsr":[25,25,null,null]}'></span>HTML heading!</h2>
2858
2859 <h2 style="border: 1px solid green; background: lightgreen; padding: 5px; font-size: 1.5em;" id="HTML_heading_with_attributes!" data-parsoid='{"stx":"html","dsr":[45,172,93,5]}'><span id="HTML_heading_with_attributes.21" typeof="mw:FallbackId" data-parsoid='{"dsr":[138,138,null,null]}'></span>HTML heading with attributes!</h2>
2860
2861 <div class="mw-heading mw-heading2" data-parsoid='{"stx":"html","dsr":[174,259,36,6]}'>
2862 <h2 id="Normal_heading_with_existing_wrapper!" data-parsoid='{"dsr":[211,252,2,2]}'><span id="Normal_heading_with_existing_wrapper.21" typeof="mw:FallbackId" data-parsoid='{"dsr":[213,213,null,null]}'></span>Normal heading with existing wrapper!</h2>
2863 </div>
2864 !! end
2865
2866 !! test
2867 T365413: Headings with dollar signs
2868 !! options
2869 wgParserEnableLegacyHeadingDOM=true
2870 !! wikitext
2871 ==$text==
2872
2873 ==$ text==
2874
2875 ==text $text==
2876
2877 ==\$text==
2878
2879 ==$$text==
2880 !! html/php
2881 <div id="toc" class="toc" role="navigation" aria-labelledby="mw-toc-heading"><input type="checkbox" role="button" id="toctogglecheckbox" class="toctogglecheckbox" style="display:none" /><div class="toctitle" lang="en" dir="ltr"><h2 id="mw-toc-heading">Contents</h2><span class="toctogglespan"><label class="toctogglelabel" for="toctogglecheckbox"></label></span></div>
2882 <ul>
2883 <li class="toclevel-1 tocsection-1"><a href="#.24text"><span class="tocnumber">1</span> <span class="toctext">$text</span></a></li>
2884 <li class="toclevel-1 tocsection-2"><a href="#.24_text"><span class="tocnumber">2</span> <span class="toctext">$ text</span></a></li>
2885 <li class="toclevel-1 tocsection-3"><a href="#text_.24text"><span class="tocnumber">3</span> <span class="toctext">text $text</span></a></li>
2886 <li class="toclevel-1 tocsection-4"><a href="#.5C.24text"><span class="tocnumber">4</span> <span class="toctext">\$text</span></a></li>
2887 <li class="toclevel-1 tocsection-5"><a href="#.24.24text"><span class="tocnumber">5</span> <span class="toctext">$$text</span></a></li>
2888 </ul>
2889 </div>
2890
2891 <h2><span class="mw-headline" id=".24text">$text</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: $text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2892 <h2><span class="mw-headline" id=".24_text">$ text</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: $ text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2893 <h2><span class="mw-headline" id="text_.24text">text $text</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: text $text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2894 <h2><span class="mw-headline" id=".5C.24text">\$text</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: \$text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2895 <h2><span class="mw-headline" id=".24.24text">$$text</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: $$text">edit</a><span class="mw-editsection-bracket">]</span></span></h2>
2896 !! end