For header reference parsing (scrubbing invalid header characters to match the way Obsidian creates the links) the following seems to be missing from logic and needs to be added:
"/" slashes need to convert. Primary use case is #parent/child tags in headers. Need to replace with a " " space. "This is a #parent/child tag" needs to be "This is a parent child tag"
The hashtag # removal for non nested #tags already seems to work fine... so it is just the replacing "/" slashes with a space " " that needs to be updated I believe.
It seems that if you start with a header reference that is NOT an ! embed... [[page#header]] it will not pick up the reference.
If you switch the link to an embed adding ! like ![[page#header]] it then finds it and adds the counter.
Then if you switch it back removing the ! embed back to [[page#header]] it stays there fine.
So something isn't triggering the initial index of the reference when it is just a [[link]] and not an ![[embed]].
Also if you close Obsidian and re-open then a [[page#header]] link (non embed) will work from the start.
Even going to a different page and then coming back doesn't "trigger" it. Have to close and open obsidian (or make it an ! embed and then switch it back to link).
Some parsing / logic issues I have found: