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")
diff --git a/docs/index.md b/docs/index.md
index 86aca2cc..09640b6a 100644
--- a/docs/index.md
+++ b/docs/index.md
@@ -50,7 +50,7 @@ Mithril supports browsers all the way back to IE9, no polyfills required.
### Getting started
-The easiest way to try out Mithril is to include it from a CDN, and follow this tutorial. It'll cover the majority of the API surface (including routing and XHR) but it'll only take 10 minutes.
+An easy way to try out Mithril is to include it from a CDN and follow this tutorial. It'll cover the majority of the API surface (including routing and XHR) but it'll only take 10 minutes.
Let's create an HTML file to follow along:
@@ -65,6 +65,11 @@ Let's create an HTML file to follow along: