IMHO delete all the <a ... </a> stuff (except the <Span> pair and, and contents).
and adjust the value after the # in the Inline TOC to be the id=value in the H1 tag
If each chapter is a separate file (the H1 tag at top, you need not bother with the # update in the TOC. Simply remove that part. The default is: TOF (top of file)
|