Generates a table of contents and anchors based on document headers