Separating the table of contents from the content has led to various bugs T311529, T307256, T305123, T316947. Many more issues likely still exist that we are just not aware of.
The main issue here is the addParserOutput method does not consult the skin when generating default options. Perhaps it should?
TODO
- Update addParserOutput or ParserOptions constructor(s) to retreive skin options and set table of contents default options correctly.
- Remove technical debt we've accumulated - direct calls to setSections listed here https://codesearch.wmcloud.org/deployed/?q=-%3EsetSections%5C(&i=nope&files=&excludeFiles=&repos=
- make sure setSections is called as part of addParserOutput
Developer notes
See https://gerrit.wikimedia.org/r/c/mediawiki/core/+/829229 for a first attempt