1 Star 1 Fork 0

zz-github-forks/How-To-Ask-Questions-The-Smart-Way

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
toc.js 768 Bytes
一键复制 编辑 原始数据 按行查看 历史
Ryan Wu 提交于 2015-04-03 20:02 . remove symbol in anchorText
(function(window) {
String.prototype.repeat = function(num) {
return new Array(num + 1).join(this);
};
var url = document.URL,
headers = jQuery("article :header"),
result;
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(" ", "-");
anchorText = anchorText.replace(/,|:|、/g, "");
var hIndex = parseInt(header.nodeName.substring(1)) - 1,
indent = " ".repeat(hIndex),
link = ['<pre>', indent, '* [', headerText, '](', '#', anchorText, ')', '\n', '</pre>'];
result += link.join('');
}
var win = window.open("", "win");
win.document.body.innerHTML = result;
})(window);
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zz-github-forks/How-To-Ask-Questions-The-Smart-Way.git
git@gitee.com:zz-github-forks/How-To-Ask-Questions-The-Smart-Way.git
zz-github-forks
How-To-Ask-Questions-The-Smart-Way
How-To-Ask-Questions-The-Smart-Way
master

搜索帮助