Rework TOC generation to create correct section numberings

Previously the section numbering for the TOC was left to HTML with nested OL LI which does not use the parent section number as a prefix. BTW the headers in the document did not contain the section number.
This fixes these issues.