fix some links
This commit is contained in:
parent
c861ade3fa
commit
5faa996805
2 changed files with 3 additions and 3 deletions
|
|
@ -52,8 +52,8 @@ function generate(pathname) {
|
||||||
.replace(/<title>Mithril\.js<\/title>/, "<title>" + title[1] + " - Mithril.js</title>")
|
.replace(/<title>Mithril\.js<\/title>/, "<title>" + title[1] + " - Mithril.js</title>")
|
||||||
.replace(/\[version\]/, version) // update version
|
.replace(/\[version\]/, version) // update version
|
||||||
.replace(/\[body\]/, markedHtml)
|
.replace(/\[body\]/, markedHtml)
|
||||||
.replace(/<h5 id="([^"]+?)">([^<]+?)<\/h5>/gim, function(match, id, text) { // fix anchors
|
.replace(/<h(.) id="([^"]+?)">(.+?)<\/h.>/gim, function(match, n, id, text) { // fix anchors
|
||||||
return "<h5 id=\"" + text.toLowerCase().replace(/\.|\[|\]|"|\//g, "") + "\">" + text + "</h5>"
|
return "<h" + n + " id=\"" + text.toLowerCase().replace(/<(\/?)code>/g, "").replace(/<a.*?>.+?<\/a>/g, "").replace(/\.|\[|\]|"|\/|\(|\)/g, "").replace(/\s/g, "-") + "\">" + text + "</h" + n + ">"
|
||||||
})
|
})
|
||||||
fs.writeFileSync("../mithril/archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
|
fs.writeFileSync("../mithril/archive/v" + version + "/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
|
||||||
fs.writeFileSync("../mithril/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
|
fs.writeFileSync("../mithril/" + outputFilename.replace(/^docs\//, ""), html, "utf-8")
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ function ensureLinkIsValid(file, data) {
|
||||||
var links = data.match(/\]\(([^\)]+?)\)/gim) || []
|
var links = data.match(/\]\(([^\)]+?)\)/gim) || []
|
||||||
links.forEach(function(match) {
|
links.forEach(function(match) {
|
||||||
var link = match.slice(2, -1)
|
var link = match.slice(2, -1)
|
||||||
var path = link.match(/[\w-]+\.md/)
|
var path = (link.match(/[\w-#]+\.md/) || [])[0]
|
||||||
if (link.match(/http/)) {
|
if (link.match(/http/)) {
|
||||||
var u = url.parse(link)
|
var u = url.parse(link)
|
||||||
http.request({method: "HEAD", host: u.host, path: u.pathname, port: 80}).on("error", function() {
|
http.request({method: "HEAD", host: u.host, path: u.pathname, port: 80}).on("error", function() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue