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

{:toc} leaves links #434

Closed
nate-wernimont opened this Issue May 19, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@nate-wernimont

nate-wernimont commented May 19, 2017

Hello, I am making a website using jekyll, and I am using a table of contents. My problem is that I am linking to websites with my headers, but I want the table of contents to link to where that header is on the page, not to the same website that the header links to.

So, my markdown document looks something like this:


layout: page

  1. TOC
    {:toc}

[Header](link to website)

information
...
...

[Header](link to website)

...
...

Is there anyway to remove that link when I generate my table of contents so that the table of contents can function correctly?

@gettalong gettalong self-assigned this May 20, 2017

@gettalong gettalong added the bug label May 20, 2017

@gettalong

This comment has been minimized.

Owner

gettalong commented May 20, 2017

You could you a post-processor to remove the inner <a> tags.

However, according to the HTML 5 spec nested <a> tags are not allowed. So the better solution would be for kramdown to strip all <a> tags from the content of a TOC entry itself.

Marking this as a bug - thanks for reporting!

@nate-wernimont

This comment has been minimized.

nate-wernimont commented May 22, 2017

As an update, I looked at the generated HTML code, and it doesn't even nest the . It leaves them as completely separate, which is weird to me. So, it does the following when it is trying to make a table of contents that has links:


Example

@gettalong

This comment has been minimized.

Owner

gettalong commented May 22, 2017

Hmm... if I run your example through kramdown I get the following output for the TOC:

<ol id="markdown-toc">
  <li><a href="#headerlink-to-website" id="markdown-toc-headerlink-to-website"><a href="link to website">Header</a></a></li>
  <li><a href="#headerlink-to-website-1" id="markdown-toc-headerlink-to-website-1"><a href="link to website">Header</a></a></li>
</ol>

As you can see, the <a> tags are nested. Maybe some postprocessing recognizes the invalid nesting and closes the first tag?

nate-wernimont added a commit to lab-design/design.cs.iastate.edu that referenced this issue May 22, 2017

Update the table of contents on the projects page
See Issue #12. The table of contents now correctly points to the right locations. There is a bug in Jekyll that can be found here gettalong/kramdown#434 and the current solution is a workaround that can hopefully be fixed in the future.

.gitignore was also updated to be emacs friendly.
@nate-wernimont

This comment has been minimized.

nate-wernimont commented May 22, 2017

You are right. When I view the actual source, it is nested, but it appears that Safari un nests it in the inspect element box.

@gettalong

This comment has been minimized.

Owner

gettalong commented Aug 27, 2017

Done - will be in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment