When passed a non-container root node, or when the visitor whould return
SkipChildren for the root node, the former algorithm would go on walking
down the rest of the tree beyond the root.
This commit also removes unneeded functions and variables.
Move these two flags from HTML renderer's flags to extensions. Implement
both since they were not yet implemented in the AST rewrite. Add tests.
Note: the expected test strings differ very slightly from v1. The HTML
produced by v2 has a few extra newlines compared to the old one, but
it's now uniform with other sections of the generated document. If the
newline placement gets cleaned up in the future, this will get fixed
automatically, since the renderer is agnostic about the TOC list.