Skip to content

GitHub table of contents

Rob Garrison edited this page Mar 25, 2017 · 58 revisions

A userscript that adds a table of contents to both readme and wiki pages.

  • A draggable popup window is automatically added when rendered markdown is detected; there must be at least three anchors.
  • The TOC will refresh while switching between pages, and previewing markdown changes.
  • Click and hold on the header to move the TOC window. If it gets moved and you can't get it back, use the keyboard shortcut to reset the position.
  • Click on the header icon to toggle the window between the upper right corner and its last position. Or use the keyboard shortcut to toggle the view.
  • Each anchor within the rendered markdown will be included in the TOC window.
  • Some anchor link text may be truncated, hover over the link to see the full title.
  • Click on the arrow next to the anchor link to toggle the sub-group.
  • Shift + Click on the arrow next to the anchor to toggle all same level items.
  • To modify the "Table of Contents" text, open the userscript addon popup window and look for the "Set Table of Contents Title" setting.
  • Keyboard commands:
    • Press Esc to "hide" the TOC in the upper right corner.
    • Press g + t, within one second of each other, to toggle the TOC view.
    • Press g + r, within one second of each other, to reset the TOC position.
  • Click this link to install from GitHub, or install from GreasyFork.
  • Then test it on this page.

Screenshot

github-toc

Change Log

Version 1.2.2 (3/25/2017)

  • Use pjax event & fix linting.
  • Add link to docs.

Version 1.2.1 (12/28/2016)

  • Clean up linting issues.

Version 1.2.0 (7/29/2016)

Version 1.1.2 (7/5/2016)

  • Arrows will again collapse content.

Version 1.1.1 (6/6/2016)

  • Only clicking on an arrow will toggle the sub-group.

Version 1.1.0 (6/6/2016)

  • Shift + Click now toggles all same level items.
  • Don't show TOC when less than 3 listings.
  • Code cleanup.

Version 1.0.1 (5/25/2016)

  • Prevent JS errors on pages with no ".header".

Version 1.0.0 (3/28/2016)

  • Initial commit
Clone this wiki locally