Skip to content

Instantly share code, notes, and snippets.

@jonschlinkert
Created December 15, 2015 19:42
Show Gist options
  • Star 56 You must be signed in to star a gist
  • Fork 25 You must be signed in to fork a gist
  • Save jonschlinkert/ac5d8122bfaaa394f896 to your computer and use it in GitHub Desktop.
Save jonschlinkert/ac5d8122bfaaa394f896 to your computer and use it in GitHub Desktop.
Example table of contents generated by markdown-toc, correctly links repeated headings.
@Badboy1307
Copy link

Thanks a ton.

@VictoriaChoy
Copy link

TKS!

@ian-l-kennedy
Copy link

ian-l-kennedy commented Feb 3, 2023

Hello,
Is there a way to add a link to get back to the TOC?

I often use Typora to edit my markdown. Occasionally I export the doc I am working on to a PDF. This is a convenient tool because the PDF supports all the linking throughout the doc. So, the TOC provides a great way to jump to content.

What if I wanted a link back to the TOC underneath some headings? Lets say I have a 50 page PDF that I generated from markdown, it would be awfully convenient if a user of the PDF could jump to content on page 45, then jump back to the TOC with only 2 clicks, and no scrolling.

It is as if I want this markdown to automagically work:

[link to TOC](this.TOC)

or

[link to TOC](#TOC#)

@ian-l-kennedy
Copy link

I guess I could just link to a heading very close to the TOC, or add a heading to the TOC and link to that :/ so, one click at the TOC to get to content, then a link somewhere to the heading ### Table of contents which just so happens to be above the TOC. dumb question maybe.

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