HTML outliner update

The previous version did not treat “implied headings” correctly. In
addition, this fixes two bugs in the outline algorithm itself (see
https://www.w3.org/Bugs/Public/show_bug.cgi?id=24097)