Skip to content

Instantly share code, notes, and snippets.

@m-bartlett
Last active March 21, 2022 16:10
Show Gist options
  • Save m-bartlett/e56954102dca6cd3eb685ca005e74b4a to your computer and use it in GitHub Desktop.
Save m-bartlett/e56954102dca6cd3eb685ca005e74b4a to your computer and use it in GitHub Desktop.
Generate a markdown Table of Contents by visiting the README page of the repo and pasting this javascript into the browser developer console
// Copied and minified from https://gist.github.com/JamieMason/c43e7ee1d078fc63e7c0f15746845c2e
console.log([].map.call(document.querySelectorAll('.anchor'), function(el) {var indents = ' '.repeat(parseFloat(el.parentNode.nodeName.charAt(1)) - 1);var label = el.parentNode.innerText;var link = el.getAttribute('href');return `${indents}* [${label}](${link})`}).join('\n'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment