Ensure GitHub style anchors are also in TOC

Pull request #286 introduced GitHub style anchors but we forgot also to
generate these nice IDs in the tables of content.

Simply move the snippets about IDs generation to a function to avoid
code duplication and make output common if we need to output it
elsewhere.

Also remove the useless header_count entry from the toc_data struct
since we are not generating header's IDs through a counter.
Merge pull request #291 from vmg/html-toc-github-style

Ensure GitHub style anchors are also in TOC