Debian Codegraph @

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