diff --git a/docs/generate.js b/docs/generate.js
index 691a1040..9d694b87 100644
--- a/docs/generate.js
+++ b/docs/generate.js
@@ -52,8 +52,8 @@ function generate(pathname) {
.replace(/
Mithril\.js<\/title>/, "" + title[1] + " - Mithril.js")
.replace(/\[version\]/, version) // update version
.replace(/\[body\]/, markedHtml)
- .replace(/([^<]+?)<\/h5>/gim, function(match, id, text) { // fix anchors
- return "" + text + "
"
+ .replace(/(.+?)<\/h.>/gim, function(match, n, id, text) { // fix anchors
+ return "/g, "").replace(/.+?<\/a>/g, "").replace(/\.|\[|\]|"|\/|\(|\)/g, "").replace(/\s/g, "-") + "\">" + text + ""
})
fs.writeFileSync("../mithril/archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
fs.writeFileSync("../mithril/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
diff --git a/docs/lint.js b/docs/lint.js
index 6ed537b2..3ab0d559 100644
--- a/docs/lint.js
+++ b/docs/lint.js
@@ -88,7 +88,7 @@ function ensureLinkIsValid(file, data) {
var links = data.match(/\]\(([^\)]+?)\)/gim) || []
links.forEach(function(match) {
var link = match.slice(2, -1)
- var path = link.match(/[\w-]+\.md/)
+ var path = (link.match(/[\w-#]+\.md/) || [])[0]
if (link.match(/http/)) {
var u = url.parse(link)
http.request({method: "HEAD", host: u.host, path: u.pathname, port: 80}).on("error", function() {