# This file has tests to verify the following: # - TOC section metadata output for wikitext snippets # - Behavior of various *toc* magic words # - Various edge cases related to heading parsing and TOC behavior # (special chars, language variants, entities, bdi chars, etc.) # # NOTE about data-parsoid in html/parsoid # - html/parsoid sections have data-parsoid="{}" to eliminate unnecessary # html2wt failures because of normalization # - We could strip them eithre by marking those tests wt2html, wt2wt only !! options version=2 parsoid-compatible=wt2html,wt2wt !! end !! article Main Page !! text blah blah !! endarticle !! article Template:1x !! text {{{1}}} !! endarticle !! article Template:Test !! text ==th2== ===th2.1=== !! endarticle !! test Basic test !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext ==h1== ===h1.1=== ==h2== ===h2.1=== ====h2.1.1==== ===h2.2=== ====h2.2.1==== ====h2.2.2==== ==h3== !! metadata Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:h1 line:h1 h3 index:2 toclevel:2 number:1.1 title:Parser_test off:7 anchor/linkAnchor:h1.1 line:h1.1 h2 index:3 toclevel:1 number:2 title:Parser_test off:18 anchor/linkAnchor:h2 line:h2 h3 index:4 toclevel:2 number:2.1 title:Parser_test off:25 anchor/linkAnchor:h2.1 line:h2.1 h4 index:5 toclevel:3 number:2.1.1 title:Parser_test off:36 anchor/linkAnchor:h2.1.1 line:h2.1.1 h3 index:6 toclevel:2 number:2.2 title:Parser_test off:51 anchor/linkAnchor:h2.2 line:h2.2 h4 index:7 toclevel:3 number:2.2.1 title:Parser_test off:62 anchor/linkAnchor:h2.2.1 line:h2.2.1 h4 index:8 toclevel:3 number:2.2.2 title:Parser_test off:77 anchor/linkAnchor:h2.2.2 line:h2.2.2 h2 index:9 toclevel:1 number:3 title:Parser_test off:92 anchor/linkAnchor:h3 line:h3 !! end !! test HTML headings should get TOC entries with some empty properties !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext ==a==

b

c

===d===

e

!! metadata Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:a line:a h2 index: toclevel:1 number:2 title:NULL off:NULL anchor/linkAnchor:b line:b h3 index: toclevel:2 number:2.1 title:NULL off:NULL anchor/linkAnchor:c line:c h3 index:2 toclevel:2 number:2.2 title:Parser_test off:28 anchor/linkAnchor:d line:d h2 index: toclevel:1 number:3 title:NULL off:NULL anchor/linkAnchor:e line:e !! end !! test Duplicate headings should get unique anchors !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext ==a== ==a== ==b== !! metadata Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:a line:a h2 index:2 toclevel:1 number:2 title:Parser_test off:6 anchor/linkAnchor:a_2 line:a h2 index:3 toclevel:1 number:3 title:Parser_test off:12 anchor/linkAnchor:b line:b !! end !! test Templated sections (heading from template content) !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext ==a== {{Test}} !! metadata Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:a line:a h2 index:T-1 toclevel:1 number:2 title:Template:Test off:NULL anchor/linkAnchor:th2 line:th2 h3 index:T-2 toclevel:2 number:2.1 title:Template:Test off:NULL anchor/linkAnchor:th2.1 line:th2.1 !! end !! test Ensure headings with html tags get the right anchors !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext ==x== ==y== !! metadata Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:x line:x h2 index:2 toclevel:1 number:2 title:Parser_test off:19 anchor/linkAnchor:y line:y !! end !! test Ensure unallowed tag wrappers in headings get stripped !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext ==
b
== ==c== !! metadata Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:b line:b h2 index:2 toclevel:1 number:2 title:Parser_test off:17 anchor/linkAnchor:c line:c !! end !! test Ensure disallowed attributes are stripped, but dir attribute in a span is left behind !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext ==a== ==b== ==c== !! metadata Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:a line:a h2 index:2 toclevel:1 number:2 title:Parser_test off:39 anchor/linkAnchor:b line:b h2 index:3 toclevel:1 number:3 title:Parser_test off:78 anchor/linkAnchor:c line:c !! end # Legacy parser behavior is broken. Parsoid's output is correct. !! test Ensure empty tags are stripped !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext ==
x== ==y== !! metadata/php Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:x line:x h2 index:2 toclevel:1 number:2 title:Parser_test off:30 anchor/linkAnchor:y line:y !! metadata/parsoid Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:x line:x h2 index:2 toclevel:1 number:2 title:Parser_test off:30 anchor/linkAnchor:y line:y !! end !! test Handle links in heading content !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext ==[[Cat]]== ==[[Dog]]s== ==[[Cat|I love my ''cat'']]== !! metadata Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:Cat line:Cat h2 index:2 toclevel:1 number:2 title:Parser_test off:12 anchor/linkAnchor:Dogs line:Dogs h2 index:3 toclevel:1 number:3 title:Parser_test off:25 anchor/linkAnchor:I_love_my_cat line:I love my cat !! end # Parsoid uses HTML5 semantics for anchors as the default. # Legacy parser tests require wgFragmentMode=[ "html5" ] for the same # behavior, which isn't (yet) the default in ParserTestRunner !! test Ensure headings with special chars get the right anchors !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! config wgFragmentMode=[ "html5", "legacy" ] !! wikitext ===a= =''x''= !! metadata Sections: h1 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:==a line:==a h1 index:2 toclevel:1 number:2 title:Parser_test off:6 anchor/linkAnchor:x line:x !! end # For heading that come from template args, core, Parsoid-standalone, and # Parsoid-integrate different in ther "index" output. # # - For templated sections, Parsoid and core differ in some of the metadata. # Parsoid doesn't distinguish between sections that come from template args # and from templated content - it treats them all as template-generated headings. # But core does not consider headings from template-args as "inTemplate", but # 'fromtitle' is set to false even so. # # - Parsoid's behavior is more consistent wrt templates. But, this is potentially # a breaking change for users of TOC data. The index for templated # content is used to generate section edit links for content coming # from a template, and in updating the appropriate article when that # section is saved. So this is potentially a breaking change when # Parsoid starts to generate section edit links, and possible one # which could cause db corruption. # # - Additionally, heading-index is reset in integrated mode because templates are # processed by core preprocessor whereas in native preprocessing mode (used by # parsertests), the heading index is not reset. # - See also T222419. !! test Templated sections (heading from template arg) !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext ==a== {{1x|1= ==b== }} !! metadata/php Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:a line:a h2 index: toclevel:1 number:2 title:NULL off:NULL anchor/linkAnchor:b line:b !! metadata/parsoid+integrated Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:a line:a h2 index:T-1 toclevel:1 number:2 title:Template:1x off:NULL anchor/linkAnchor:b line:b !! metadata/parsoid+standalone Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:a line:a h2 index:T-2 toclevel:1 number:2 title:Template:1x off:NULL anchor/linkAnchor:b line:b !! end # FIXME: # 1. This potentially exposes a subtle issue in the interaction between TOC, Cite, and # localization. Parsoid doesn't localize numbers in Cite (at all!) since it relies on CSS. # But, with the legacy parser, a wiki with localized numbers will have an anchor # based off a localized number if a is used in a heading. Parsoid won't!. # 2. We probably should be a bit smarter about what to strip for tags when that output # comes from extensions. Below, we have stripped all extension typeofs and info. # But, depends on who uses this 'line' property and how. # FIXME: test disabled because CI doesn't have the Cite extension installed !! test Handle extension content in section headers properly !! config wgFragmentMode=[ "html5", "legacy" ] !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext ==cd== !! metadata/php+disabled Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:c[1] line:c[1] !! metadata/parsoid Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:c[1] line:c[1] !! end # FIXME: This test shows a similar difference between legacy and # Parsoid output, but it may be due to a subtle difference in the # whitespace emitted by the parser test runner's implementation !! test Handle extension content in section headers properly (non-Cite version) !! config wgFragmentMode=[ "html5", "legacy" ] !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext ==cd== !! metadata/php Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:c_'d'_array_(_) line:"c\n'd'\narray (\n)" !! metadata/parsoid Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:c'd'_array_(_) line:"c'd'\narray (\n)" !! end !! test Offsets in toc metadata should be unicode codepoints, not bytes or UCS-2 !! config wgFragmentMode=[ "html5", "legacy" ] !! options parsoid={ "modes": [ "wt2html" ], "wrapSections": true } showtocdata nohtml !! wikitext ==One 💩== ==Two 💩== ==Three 💩== !! metadata Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:0 anchor/linkAnchor:One_💩 line:One 💩 h2 index:2 toclevel:1 number:2 title:Parser_test off:10 anchor/linkAnchor:Two_💩 line:Two 💩 h2 index:3 toclevel:1 number:3 title:Parser_test off:20 anchor/linkAnchor:Three_💩 line:Three 💩 !! end !! test Handle multi-part content transclusion blocks !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext
{{1x|1= ==foo==
}} ==bar== !! metadata Sections: h2 index: toclevel:1 number:1 title:NULL off:NULL anchor/linkAnchor:foo line:foo h2 index:2 toclevel:1 number:2 title:Parser_test off:32 anchor/linkAnchor:bar line:bar !! end # Parsoid's parser function implementation used for standalone testing # is incomplete and only used in parser tests. # So, use HTML h-tags instead of wikitext h-tags in the parser function # to let us run this test in both standalone and integrated modes. !! test Handle parser functions generating sections !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext {{#if:1|

foo

|unused}} ==bar== !! metadata Sections: h2 index: toclevel:1 number:1 title:NULL off:NULL anchor/linkAnchor:foo line:foo h2 index:1 toclevel:1 number:2 title:Parser_test off:30 anchor/linkAnchor:bar line:bar !! end !! test Handle top-level template args generating sections !! options nohtml showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext {{{foo| ==tplarg== |abcd}}} !! metadata Sections: h2 index: toclevel:1 number:1 title:NULL off:NULL anchor/linkAnchor:tplarg line:tplarg !! end ### ### Sections ### !! test Basic section headings !! wikitext ==Headline 1== Some text ==Headline 2== More ===Smaller headline=== Blah blah !! html

Headline 1[edit]

Some text

Headline 2[edit]

More

Smaller headline[edit]

Blah blah

!! end !! test Section headings with TOC !! wikitext ==Headline 1== ===Subheadline 1=== =====Skipping a level===== ======Skipping a level====== ==Headline 2== Some text ===Another headline=== !! html/php

Headline 1[edit]

Subheadline 1[edit]

Skipping a level[edit]
Skipping a level[edit]

Headline 2[edit]

Some text

Another headline[edit]

!! html/parsoid

Headline 1

Subheadline 1

Skipping a level
Skipping a level

Headline 2

Some text

Another headline

!! end !! test Section headings with TOC and language conversion (T295187, T306862) !! config wgUsePigLatinVariant=true !! options language=en variant=en-x-piglatin !! wikitext ==Headline 1== ===Subheadline 1=== ==Headline 2== Some text ===Another headline=== !! html/php

Eadlinehay 1[edit]

Ubheadlinesay 1[edit]

Eadlinehay 2[edit]

Omesay exttay

Anotherway eadlinehay[edit]

!! html/parsoid

Headline 1

Subheadline 1

Headline 2

Some text

Another headline

!! end # Note that even though conversion of the *content* is disabled, the # user interface messages (aka the TOC title) are still in the user's # preferred UX variant (that is, pig latin). !! test Section headings with TOC and language conversion disabled (T295187) !! config wgUsePigLatinVariant=true !! options language=en variant=en-x-piglatin !! wikitext ==Headline 1== ===Subheadline 1=== ==Headline 2== Some text ===Another headline=== __NOCONTENTCONVERT__ !! html/php

Headline 1[edit]

Subheadline 1[edit]

Headline 2[edit]

Some text

Another headline[edit]

!! html/parsoid

Headline 1

Subheadline 1

Headline 2

Some text

Another headline

!! end # The -{T}- below checks for regressions in T26072: the contents of # the displaytitle should not be double-converted. That is, we want # the title to end up as 'Bar' not 'Ball' (aka converted by the -{H}- # rule immediately preceding it). !! test Section headings with TOC, language conversion rules, and displaytitle (T306862, T331316, T26072) !! config wgUsePigLatinVariant=true wgRestrictDisplayTitle=false !! options language=en variant=en-x-piglatin showtitle showtocdata parsoid={ "modes": [ "wt2html" ], "wrapSections": true } !! wikitext -{H|Foo=>en:Boo;Foo=>en-x-piglatin:Bob;}--{H|Bar=>en:Bat;Bar=>en-x-piglatin:Ball;}--{T|en:Foo;en-x-piglatin:Bar;}- Introduction. -{A|en:Do; en-x-piglatin:Re;}- == Foo == Foo Do == Bar == Bar Re == -{Foo Bar}- == !! metadata Bar Sections: h2 index:1 toclevel:1 number:1 title:Parser_test off:192 anchor/linkAnchor:Foo line:Bob h2 index:2 toclevel:1 number:2 title:Parser_test off:209 anchor/linkAnchor:Bar line:Ball h2 index:3 toclevel:1 number:3 title:Parser_test off:226 anchor/linkAnchor:-.7BFoo_Bar.7D- line:Foo Bar !! html/php

Introductionway. Re

Bob[edit]

Bob Re

Ball[edit]

Ball Eray

Foo Bar[edit]

!! html/parsoid+standalone

-{H|Foo=>en:Boo;Foo=>en-x-piglatin:Bob;}--{H|Bar=>en:Bat;Bar=>en-x-piglatin:Ball;}--{T|en:Foo;en-x-piglatin:Bar;}- Introduction. -{A|en:Do; en-x-piglatin:Re;}-

Foo

Foo Do

Bar

Bar Re

-{Foo Bar}-

!! html/parsoid+integrated

Introduction.

Foo

Foo Do

Bar

Bar Re

!! end !! test TOC anchors don't collide !! wikitext __FORCETOC__ ==Headline 2== ==Headline== ==Headline 2== ==Headline== !! html/php

Headline 2[edit]

Headline[edit]

Headline 2[edit]

Headline[edit]

!! end # perl -e 'print "="x$_," Level $_ heading","="x$_,"\n" for 1..10' # Parsoid html2wt direction adds for level 7 and up. !! test Handling of sections up to level 6 and beyond !! options parsoid=wt2html !! wikitext =Level 1 Heading= ==Level 2 Heading== ===Level 3 Heading=== ====Level 4 Heading==== =====Level 5 Heading===== ======Level 6 Heading====== =======Level 7 Heading======= ========Level 8 Heading======== =========Level 9 Heading========= ==========Level 10 Heading========== !! html/php

Level 1 Heading[edit]

Level 2 Heading[edit]

Level 3 Heading[edit]

Level 4 Heading[edit]

Level 5 Heading[edit]
Level 6 Heading[edit]
=Level 7 Heading=[edit]
==Level 8 Heading==[edit]
===Level 9 Heading===[edit]
====Level 10 Heading====[edit]
!! html/parsoid

Level 1 Heading

Level 2 Heading

Level 3 Heading

Level 4 Heading

Level 5 Heading
Level 6 Heading
=Level 7 Heading=
==Level 8 Heading==
===Level 9 Heading===
====Level 10 Heading====
!! end !! test TOC regression (T11764) !! wikitext ==title 1== ===title 1.1=== ====title 1.1.1==== ===title 1.2=== ==title 2== ===title 2.1=== !! html/php

title 1[edit]

title 1.1[edit]

title 1.1.1[edit]

title 1.2[edit]

title 2[edit]

title 2.1[edit]

!! html/parsoid

title 1

title 1.1

title 1.1.1

title 1.2

title 2

title 2.1

!! end !! test TOC for heading containing (T96153) !! wikitext __FORCETOC__ ==New title== !! html/php

New title[edit]

!! end !! test TOC with wgMaxTocLevel=3 (T8204) !! options wgMaxTocLevel=3 !! wikitext ==title 1== ===title 1.1=== ====title 1.1.1==== ===title 1.2=== ==title 2== ===title 2.1=== !! html/php

title 1[edit]

title 1.1[edit]

title 1.1.1[edit]

title 1.2[edit]

title 2[edit]

title 2.1[edit]

!! html/parsoid

title 1

title 1.1

title 1.1.1

title 1.2

title 2

title 2.1

!! end !! test TOC with wgMaxTocLevel=3 and two level four headings (T8204) !! options wgMaxTocLevel=3 !! wikitext ==Section 1== ===Section 1.1=== ====Section 1.1.1==== ====Section 1.1.1.1==== ==Section 2== !! html/php

Section 1[edit]

Section 1.1[edit]

Section 1.1.1[edit]

Section 1.1.1.1[edit]

Section 2[edit]

!! html/parsoid

Section 1

Section 1.1

Section 1.1.1

Section 1.1.1.1

Section 2

!! end !! test Resolving duplicate section names !! wikitext ==Foo bar== ==Foo bar== !! html

Foo bar[edit]

Foo bar[edit]

!! end !! test Resolving duplicate section names with differing case (T12721) !! wikitext ==Foo bar== ==Foo Bar== !! html

Foo bar[edit]

Foo Bar[edit]

!! end !! article Template:sections !! text ===Section 1=== ==Section 2== !! endarticle !! test Template with sections, __NOTOC__ !! options showflags parsoid={ "wrapSections": true } !! wikitext __NOTOC__ ==Section 0== {{sections}} ==Section 4== !! metadata flags=no-toc !! html/php

Section 0[edit]

Section 1[edit]

Section 2[edit]

Section 4[edit]

!! html/parsoid

Section 0

Section 1

Section 2

Section 4

!! end !! test T307691: show-toc flag: no sections !! options showflags parsoid={ "wrapSections": true } !! wikitext !! metadata flags= !! html !! html/parsoid
!! end # You can't force a TOC if there aren't any sections !! test T307691: show-toc flag: no sections, but __FORCETOC__ !! options showflags parsoid={ "wrapSections": true } !! wikitext __FORCETOC__ !! metadata flags= !! html/php !! html/parsoid
!! end # Placing a manual __TOC__ doesn't do anything if there aren't any sections !! test T307691: show-toc flag: no sections, but __TOC__ !! options showflags parsoid={ "wrapSections": true } !! wikitext __TOC__ !! metadata flags= !! html/php !! html/parsoid
!! end !! test T307691: show-toc flag: no sections, and __NOTOC__ !! options showflags parsoid={ "wrapSections": true } !! wikitext __NOTOC__ !! metadata flags=no-toc !! html/php !! html/parsoid
!! end !! test T307691: show-toc flag: not "enough" sections !! options showflags parsoid={ "wrapSections": true } !! wikitext == One == !! metadata flags= !! html/php

One[edit]

!! html/parsoid

One

!! end !! test T307691: show-toc flag: not "enough" sections, but __FORCETOC__ !! options showflags parsoid={ "wrapSections": true } !! wikitext __FORCETOC__ == One == !! metadata flags=show-toc !! html/php

One[edit]

!! html/parsoid

One

!! end !! test T307691: show-toc flag: not "enough" sections, but __TOC__ !! options showflags parsoid={ "wrapSections": true } !! wikitext == One == __TOC__ !! metadata flags=show-toc !! html/php

One[edit]

!! html/parsoid

One

!! end !! test T307691: show-toc flag: not "enough" sections, and __NOTOC__ !! options showflags parsoid={ "wrapSections": true } !! wikitext __NOTOC__ == One == !! metadata flags=no-toc !! html/php

One[edit]

!! html/parsoid

One

!! end !! test T307691: show-toc flag: "enough" sections !! options showflags parsoid={ "wrapSections": true } !! wikitext == One == === Two === == Three == === Four === !! metadata flags=show-toc !! html/php

One[edit]

Two[edit]

Three[edit]

Four[edit]

!! html/parsoid

One

Two

Three

Four

!! end !! test T307691: show-toc flag: "enough" sections and __FORCETOC__ !! options showflags parsoid={ "wrapSections": true } !! wikitext __FORCETOC__ == One == === Two === == Three == === Four === !! metadata flags=show-toc !! html/php

One[edit]

Two[edit]

Three[edit]

Four[edit]

!! html/parsoid

One

Two

Three

Four

!! end !! test T307691: show-toc flag: "enough" sections and __NOTOC__ !! options showflags parsoid={ "wrapSections": true } !! wikitext __NOTOC__ == One == === Two === == Three == === Four === !! metadata flags=no-toc !! html/php

One[edit]

Two[edit]

Three[edit]

Four[edit]

!! html/parsoid

One

Two

Three

Four

!! end !! test __NOEDITSECTION__ keyword !! wikitext __NOEDITSECTION__ ==Section 1== ==Section 2== !! html

Section 1

Section 2

!! end !! test Link inside a section heading !! wikitext ==Section with a [[Main Page|link]] in it== !! html

Section with a link in it[edit]

!! end !! test TOC regression (T14077) !! wikitext __TOC__ ==title 1== ===title 1.1=== ==title 2== !! html/php

title 1[edit]

title 1.1[edit]

title 2[edit]

!! html/parsoid

title 1

title 1.1

title 2

!! end # test added in 4e717c01589378893c98e333884315c166c217b3 # __FORCETOC__ won't set show-toc if there are no sections # present to show; also test that __NEWSECTIONLINK__ results in the # proper ParserOutputFlag being set. !! test __FORCETOC__ override !! options showflags parsoid={ "wrapSections": true } !! wikitext __NEWSECTIONLINK__ __FORCETOC__ !! metadata flags=mw-NewSection !! html/php


!! html/parsoid
!! end # Note that Parsoid doesn't emit an explicit TOC. # Note also that the html2wt direction tends to emit an extra newline # between the __TOC__ magicword and the first heading unless *both* # the and the

have a data-parsoid attribute set (even if # it's "{}"). !! test T28375: TOC with italics !! options title=[[Main Page]] !! wikitext __TOC__ ==''Lost'' episodes== !! html/php

Lost episodes[edit]

!! html/parsoid

Lost episodes

!! end !! test T28375: TOC with bold !! options title=[[Main Page]] !! wikitext __TOC__ =='''should be bold''' then normal text== !! html/php

should be bold then normal text[edit]

!! html/parsoid

should be bold then normal text

!! end !! test T35845: Headings become cursive in TOC when they contain an image !! options title=[[Main Page]] !! config wgParserEnableLegacyMediaDOM=false !! wikitext __TOC__ ==Image [[Image:foobar.jpg]]== !! html/php

Image [edit]

!! html/parsoid

Image

!! end !! test T35845 (2): Headings become bold in TOC when they contain a blockquote !! options title=[[Main Page]] !! wikitext __TOC__ ==
Quote
== !! html/php

Quote

[edit]

!! html/parsoid

Quote

!! end !! test Unclosed tags in TOC !! config wgFragmentMode=[ "html5", "legacy" ] !! options title=[[Main Page]] !! wikitext __TOC__ ==Proof: 2 < 3== Hanc marginis exiguitas non caperet. QED !! html/php

Proof: 2 < 3[edit]

Hanc marginis exiguitas non caperet. QED

!! html/parsoid

Proof: 2 < 3

Hanc marginis exiguitas non caperet. QED

!! end !! test Multiple tags in TOC !! wikitext __TOC__ ==Foo Bar== ==Foo
Bar
== !! html/php

Foo Bar[edit]

Foo

Bar

[edit]

!! html/parsoid

Foo Bar

Foo

Bar

!! end # Don't expect Parsoid to roundtrip this until the php parser comes closer to # html5 tag parsing. !! test Tags with parameters in TOC !! options parsoid=wt2html !! wikitext __TOC__ ==Hello== ==Evilbye== !! html/php

Hello[edit]

b">Evilbye[edit]

!! html/parsoid

Hello

b">Evilbye

!! end !! test span tags with directionality in TOC !! wikitext __TOC__ ==C++== ==זבנג!== ==The attributes on these span tags must be deleted from the TOC== ==All attributes on these span tags must be deleted from the TOC== ==Attributes after dir on these span tags must be deleted from the TOC== !! html/php

C++[edit]

זבנג![edit]

The attributes on these span tags must be deleted from the TOC[edit]

All attributes on these span tags must be deleted from the TOC[edit]

Attributes after dir on these span tags must be deleted from the TOC[edit]

!! html/parsoid

C++

זבנג!

The attributes on these span tags must be deleted from the TOC

All attributes on these span tags must be deleted from the TOC

Attributes after dir on these span tags must be deleted from the TOC

!! end !! test T74884: bdi element in ToC !! wikitext __TOC__ ==test== !! html/php

test[edit]

!! html/parsoid

test

!! end !! test T35715: s/strike element in ToC !! wikitext __TOC__ ==test test test== !! html/php

test test test[edit]

!! html/parsoid

test test test

!! end !! test T198618: style element in ToC !! options styletag=1 !! wikitext __TOC__ ==Style== !! html/php

Style[edit]

!! html/parsoid

Style

!! end !! test T198618: script element in ToC !! options wgRawHtml=1 !! wikitext __TOC__ ==Script== !! html/php

Script[edit]

!! html/parsoid

Script

!! end !! test Empty

tag in TOC, removed by Sanitizer (T92892) !! wikitext __TOC__ ==x== !! html/php

x[edit]

!! html/parsoid

x

!! end !!test Disable TOC !! options notoc !! wikitext Lead ==Section 1== ==Section 2== ==Section 3== ==Section 4== ==Section 5== !! html

Lead

Section 1[edit]

Section 2[edit]

Section 3[edit]

Section 4[edit]

Section 5[edit]

!! end ### ### Headings ### # Parsoid doesn't wt2wt this cleanly because it adds s. !! test Short headings with trailing space should match behavior of Parser::doHeadings (T21910) !! options parsoid=wt2html,html2html !! wikitext === The line above must have a trailing space! === But just in case it doesn't... !! html/php

=[edit]

The line above must have a trailing space!

=[edit]

But just in case it doesn't...

!! html/parsoid

=

The line above must have a trailing space!

=

But just in case it doesn't...

!! end !! test Header with special characters (T27462) !! wikitext The tooltips shall not show entities to the user (ie. be double escaped) ==text > text== section 1 ==text < text== section 2 ==text & text== section 3 ==text ' text== section 4 ==text " text== section 5 !! html/php

The tooltips shall not show entities to the user (ie. be double escaped)

text > text[edit]

section 1

text < text[edit]

section 2

text & text[edit]

section 3

text ' text[edit]

section 4

text " text[edit]

section 5

!! html/parsoid

The tooltips shall not show entities to the user (ie. be double escaped)

text > text

section 1

text < text

section 2

text & text

section 3

text ' text

section 4

text " text

section 5

!! end !! test Header with space, plus and underscore as entity !! wikitext Id should not contain + for spaces ==Space between Text== section 1 ==Space-Entity between Text== section 2 ==Plus+between+Text== section 3 ==Plus-Entity+between+Text== section 4 ==Underscore_between_Text== section 5 ==Underscore-Entity_between_Text== section 6 [[#Space between Text]] [[#Space-Entity between Text]] [[#Plus+between+Text]] [[#Plus-Entity+between+Text]] [[#Underscore_between_Text]] [[#Underscore-Entity_between_Text]] !! html/php

Id should not contain + for spaces

Space between Text[edit]

section 1

Space-Entity between Text[edit]

section 2

Plus+between+Text[edit]

section 3

Plus-Entity+between+Text[edit]

section 4

Underscore_between_Text[edit]

section 5

Underscore-Entity_between_Text[edit]

section 6

#Space between Text #Space-Entity between Text #Plus+between+Text #Plus-Entity+between+Text #Underscore_between_Text #Underscore-Entity_between_Text

!! html/parsoid

Id should not contain + for spaces

Space between Text

section 1

Space-Entity between Text

section 2

Plus+between+Text

section 3

Plus-Entity+between+Text

section 4

Underscore_between_Text

section 5

Underscore-Entity_between_Text

section 6

#Space between Text #Space-Entity between Text #Plus+between+Text #Plus-Entity+between+Text #Underscore_between_Text #Underscore-Entity_between_Text

!! end # Parsoid html2wt disabled because it adds padding spaces around = !! test Headers with excess '=' characters (Are similar tests necessary beyond the 1st level?) !! options parsoid=wt2html,wt2wt,html2html !! wikitext =foo== ==foo= =''italic'' heading== ==''italic'' heading= !! html/php

foo=[edit]

=foo[edit]

italic heading=[edit]

=italic heading[edit]

!! html/parsoid

foo=

=foo

italic heading=

=italic heading

!! end !! test HTML headers vs TOC (T25393) (__NOEDITSECTION__ for clearer output, doesn't matter here) !! wikitext

Header 1

==Header 1.1== ==Header 1.2==

Header 2

==Header 2.1== ==Header 2.2== __NOEDITSECTION__ !! html/php

Header 1

Header 1.1

Header 1.2

Header 2

Header 2.1

Header 2.2

!! html/parsoid

Header 1

Header 1.1

Header 1.2

Header 2

Header 2.1

Header 2.2

!! end !! test Out-of-order TOC heading levels !! wikitext ==2== ======6====== ===3=== =1= =====5===== ==2== !! html/php

2[edit]

6[edit]

3[edit]

1[edit]

5[edit]

2[edit]

!! html/parsoid

2

6

3

1

5

2

!! end