diff --git a/docs/generate.js b/docs/generate.js
index 52bc3e70..4bc76499 100644
--- a/docs/generate.js
+++ b/docs/generate.js
@@ -27,6 +27,7 @@ function generate(pathname) {
if (pathname.match(/\.md$/)) {
var outputFilename = pathname.replace(/\.md$/, ".html")
var markdown = fs.readFileSync(pathname, "utf-8")
+ var anchors = {}
var fixed = markdown
.replace(/`((?:\S| -> |, )+)(\|)(\S+)`/gim, function(match, a, b, c) { // fix pipes in code tags
return "" + (a + b + c).replace(/\|/g, "|") + ""
@@ -53,6 +54,12 @@ function generate(pathname) {
.replace(/(.+?)<\/h.>/gim, function(match, n, id, text) { // fix anchors
var anchor = text.toLowerCase().replace(/<(\/?)code>/g, "").replace(/.+?<\/a>/g, "").replace(/\.|\[|\]|"|\/|\(|\)/g, "").replace(/\s/g, "-");
+ if(anchor in anchors) {
+ anchor += ++anchors[anchor]
+ } else {
+ anchors[anchor] = 0;
+ }
+
return `${text}`;
})
fs.writeFileSync("./dist/archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")