jgallen23 / toc

Table of Contents Plugin
http://projects.jga.me/toc/
MIT License
531 stars 111 forks source link

add id attr directly in heading if possible #60

Open moy opened 7 years ago

moy commented 7 years ago

Instead of generating a useless before the relevant <h?> tag, just add the id attr to the <h?> tag if it does not have one already.

This way, the target of the link is exactly the <h?> tag, and the browser positions the focus exactly on it. Without this, there was a slight difference in offset between tags which had an id= attr an tags which didn't.

patrickcate commented 4 years ago

@moy Can you update this PR with the branch conflicts fixed?

moy commented 4 years ago

I didn't follow the development, but apparently the new version doesn't have the drawback I fixed with this PR, so I guess we can just close without merging.