Skip to content

Instantly share code, notes, and snippets.

@sompylasar
Created January 22, 2019 23:09
Show Gist options
  • Select an option

  • Save sompylasar/d5f56e913c88b7e7f633a15fdc4b44d8 to your computer and use it in GitHub Desktop.

Select an option

Save sompylasar/d5f56e913c88b7e7f633a15fdc4b44d8 to your computer and use it in GitHub Desktop.

Revisions

  1. sompylasar created this gist Jan 22, 2019.
    8 changes: 8 additions & 0 deletions github-wiki-table-of-contents.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,8 @@
    console.log(
    '\n\n\n> **Table of contents**\n> \n' +
    Array.from(document.querySelectorAll('h1 > a, h2 > a, h3 > a')).map((a) => (
    {'H1':'> * ','H2':'> * ','H3':'> - '}[a.parentNode.tagName] +
    `[${a.parentNode.innerText.trim()}](${a.hash})`
    )).join('\n') +
    '\n\n\n'
    );