Skip to content

Instantly share code, notes, and snippets.

@jonschlinkert
Created December 15, 2015 19:42
Show Gist options
  • 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.
@AvgustPol
Copy link

thanks <3

@matrixtribe
Copy link

matrixtribe commented Dec 6, 2020

What about using heading numbers?

  1. Introduction
    1.1 Purpose
    1.2 Description
  2. Development toolset
    2.1 IDEs
    2.2 Continuous Integration tools
    etc...

nm, got it!!

- [1. Introduction](#1-introduction)
  * [1.1 Purpose](#11-purpose)
  * [1.2 Scope](#12-scope)
  * [1.3 Acronyms](#13-acronyms)
  * [1.4 References](#14-references)
    + [1.4.1 Internal References](#141-internal-references)
    + [1.4.2 External References](#142-external-references)
  * [1.5 Overview](#15-overview)

@Aybak3k
Copy link

Aybak3k commented Apr 24, 2021

THX A LOT!!!!

@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