Last active
March 1, 2020 15:58
-
-
Save r-brown/2c5b0cd07548ad9f02f6ce8a76a32848 to your computer and use it in GitHub Desktop.
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
// In the Wiki Edit (/_edit) Preview mode, run this snippet in the browser console to get a Markdown of a Table of Contents: | |
console.log( | |
'**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' + '***' | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment