Last active
April 2, 2020 13:27
-
-
Save JamieMason/c43e7ee1d078fc63e7c0f15746845c2e to your computer and use it in GitHub Desktop.
Revisions
-
JamieMason revised this gist
Apr 2, 2020 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,7 @@ Paste this into the console in Google Chrome. ```js [].map .call(document.querySelectorAll('.anchor'), el => `* [${el.parentNode.innerText}](${el.getAttribute('href')})` ) .join('\n'); ``` @@ -29,7 +29,7 @@ The following version is longer, but will indent the items according to the head [].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})` }) -
JamieMason revised this gist
Aug 16, 2016 . 1 changed file with 13 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -12,7 +12,7 @@ Paste this into the console in Google Chrome. .join('\n'); ``` The output if run on the [lodash README](https://github.com/lodash/lodash) should look something like this; > ``` > "* [lodash v4.14.0](#lodash-v4140) @@ -21,11 +21,9 @@ The output should look something like this; > * [Module Formats](#module-formats)" > ``` ## Include indentation The following version is longer, but will indent the items according to the headers; ```javascript [].map @@ -36,4 +34,13 @@ The following version is longer, but will indent the list according to the heade return `${indents}* [${label}](${link})` }) .join('\n'); ``` The output if run on the [lodash README](https://github.com/lodash/lodash) should look something like this; > ``` > "* [lodash v4.15.0](#lodash-v4150) > * [Download](#download) > * [Why Lodash?](#why-lodash) > * [Module Formats](#module-formats)" > ``` -
JamieMason revised this gist
Aug 16, 2016 . 1 changed file with 16 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -21,4 +21,19 @@ The output should look something like this; > * [Module Formats](#module-formats)" > ``` The above example was run at https://github.com/lodash/lodash. **EDIT** The following version is longer, but will indent the list according to the headers; ```javascript [].map .call(document.querySelectorAll('.anchor'), function(el) { var indents = ' '.repeat(parseFloat(el.parentNode.nodeName.charAt(1)) - 1); var label = el.nextSibling.nodeValue; var link = el.getAttribute('href'); return `${indents}* [${label}](${link})` }) .join('\n'); ``` -
JamieMason created this gist
Jul 19, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ ## Quick way to generate a table of contents from a GitHub README Visit the README.md on GitHub. Paste this into the console in Google Chrome. ```js [].map .call(document.querySelectorAll('.anchor'), el => `* [${el.nextSibling.nodeValue}](${el.getAttribute('href')})` ) .join('\n'); ``` The output should look something like this; > ``` > "* [lodash v4.14.0](#lodash-v4140) > * [Download](#download) > * [Why Lodash?](#why-lodash) > * [Module Formats](#module-formats)" > ``` The above example was run at https://github.com/lodash/lodash.