Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Links to section headers don't work #58

Closed
sjackman opened this issue May 16, 2014 · 1 comment
Closed

Links to section headers don't work #58

sjackman opened this issue May 16, 2014 · 1 comment
Labels
Milestone

Comments

@sjackman
Copy link

The anchor name of a section header such as ## Table 1 has a prefix of user-content- such as user-content-table-1, and so a link to #table-1 doesn't work.

For example, ## Table 1 becomes:

<a name="user-content-table-1" class="anchor" href="#table-1"><span class="octicon octicon-link"></span></a>Table 1</h2>

GitHub does the same thing, but the links on GitHub work, probably due to some magic GitHub script.

@joeyespo joeyespo added the bug label Jun 14, 2014
@joeyespo joeyespo modified the milestone: 2.1 Jun 14, 2014
@joeyespo
Copy link
Owner

Oh wow, you're absolutely right. GitHub is prefixing the anchor tags with "user-content". I imagine it's so your headers don't interfere with GitHub's anchors. Still, it's kind of hacky.

I threw together a working solution. Namely, I found the part in the GitHub source that scrolls to elements when the hash changes and manually copied that into index.html. I didn't immediately find how it scrolls on page-load though, so I used window.onload for now, leaving some room for improvement. (I just don't want to include heavy dependencies like jQuery until absolutely necessary.)

Thanks for opening this issue, @sjackman!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants