Updated index.py to handle no link case

These changes prevent crashing when creating an index for t.docx.
The index it creates is pretty good, but still shows a number of places where index entries which should be merged are not. I'll aim to find and fix those cases sometime later in the week, but I wanted to get this material in, in case you want to use it sooner.