Allow resolving of links to repeated headers.

In the case of multiple headings with the same text, there was no way of linking to anything but the first heading. This PR allows the resolving of the 0th (as before) but also the 1st 2nd and so on as an optional argument.

This is required for a pull request that I'll submit to doctoc to automatically handle multiple identical headings.