remove symbol in anchorText

This commit is contained in:
Ryan Wu 2015-04-03 20:02:17 +08:00
parent 5698c017c6
commit 60c6d2bbff
2 changed files with 10 additions and 9 deletions

7
toc.js
View file

@ -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);