A few missing things (sorry for lumping them all together into one task):
- ParserOutputFlags::SHOW_TOC isn't set on the parsoid side
- This involves (among other things) determining whether there are "enough" sections present in order to set SHOW_TOC
- Parsoid should add a "synthetic" __TOC__ marker if none is present in the input wikitext
- https://github.com/wikimedia/mediawiki/blob/master/includes/parser/Parser.php#L4470-L4475 (core side version of this)
- presumably we'll mark this <meta> in some way to indicate that it is not present in the input wikitext (the same way we mark missing end tags which we supply?) so that it is not round-tripped back to a literal __TOC__ in the wikitext.
- whatever markup we add should match Parser::TOC_PLACEHOLDER_REGEX in core, although that was written to be pretty broad (aka should permit arbitrary additional attributes to be added for disambiguation of the automatically-inserted case on the parsoid side).
- probably need to check that VE knows to leave this marker alone (or strip it, like it does <section> tags?)