1 Star 0 Fork 3

银色飞翼/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/joshliu357/How-To-Ask-Questions-The-Smart-Way.git
git@gitee.com:joshliu357/How-To-Ask-Questions-The-Smart-Way.git
joshliu357
How-To-Ask-Questions-The-Smart-Way
How-To-Ask-Questions-The-Smart-Way
main

搜索帮助

0d507c66 1850385 C8b1a773 1850385