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