Make functions and headlines in the documentation linkable

I wanted to make specific parts of the xtag documentation linkable.
The given implementation adds `<a name="some-identifier">` to code blocks and some headlines.

It works on the /doc page and click links. 
Once you reload the page or open a new page with a given anchor it destroys the position and everything is aligned on the left side (tested in Chromium, Firefox, Opera). 

Does anyone knows how to fix this? It's too bad that you can't link to a specific method right now and the documentation is kinda huge to simply say "go there and look for `addEvent`".