Created
January 22, 2019 23:09
-
-
Save sompylasar/d5f56e913c88b7e7f633a15fdc4b44d8 to your computer and use it in GitHub Desktop.
While in the Wiki Edit (`/_edit`) Preview mode, run this snippet in the browser console to get a Markdown of a Table of contents. https://github.com/isaacs/github/issues/215
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment