mirror of
https://github.com/ryanhanwu/How-To-Ask-Questions-The-Smart-Way.git
synced 2025-12-26 18:14:58 +08:00
update toc and toc generator script
This commit is contained in:
parent
cb0a3af5c5
commit
5698c017c6
2 changed files with 8 additions and 7 deletions
7
toc.js
7
toc.js
|
|
@ -7,11 +7,12 @@
|
|||
result;
|
||||
for (var i = 3; i < headers.length; i++) { //skip H1, history, and toc
|
||||
var header = headers[i],
|
||||
headerText = header.textContent.trim(),
|
||||
headerText = headerText.replace(" ", "-");
|
||||
headerText = header.textContent.trim();
|
||||
var anchorText = headerText.toLowerCase(),
|
||||
anchorText = anchorText.replace(" ", "-");
|
||||
var hIndex = parseInt(header.nodeName.substring(1)) - 1,
|
||||
indent = " ".repeat(hIndex),
|
||||
link = ['<pre>', indent, '* [', headerText, '](', '#', headerText, ')', '\n', '</pre>'];
|
||||
link = ['<pre>', indent, '* [', headerText, '](', '#', anchorText, ')', '\n', '</pre>'];
|
||||
result += link.join('');
|
||||
}
|
||||
var win = window.open("", "win");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue