提交 9bfb0fc3 编写于 作者: D DCloud_LXH

fix: markdown normalizeLink

上级 dc903b81
...@@ -46,11 +46,15 @@ function parseBar(tab, file, options) { ...@@ -46,11 +46,15 @@ function parseBar(tab, file, options) {
} }
} }
link = path.join('/', link.replace(/\.md\b/, '') link = path.join(
.replace(/\bREADME\b/, '') '/',
.replace(/\/index/, '/') link
.replace(/\?id=/, '#')) .replace(/(\bREADME\.md\b)|(\bREADME(?!\.))/i, 'index.html') // README.md | README | readme.md | readme -> index.html
.replace(/\\/g, '/') .replace(/(\bindex\.md\b)|(index(?!\.))/, 'index.html') // /index -> /index.html
.replace(/\.md\b/, '.html') // *.md -> *.html
.replace(/\?id=/, '#') // ?id= -> #
.replace(/\\/g, '/') // \ -> /
)
links.push(link) links.push(link)
} }
......
...@@ -21,11 +21,11 @@ module.exports = function (md) { ...@@ -21,11 +21,11 @@ module.exports = function (md) {
url = isExternal(url) url = isExternal(url)
? url ? url
: normalizeLink(url) : normalizeLink(url)
.replace(/\.md\b/, '.html') .replace(/(\bREADME\.md\b)|(\bREADME(?!\.))/i, 'index.html') // README.md | README | readme.md | readme -> index.html
.replace(/\bREADME\b/, 'index.html') .replace(/(\bindex\.md\b)|(index(?!\.))/, 'index.html') // /index -> /index.html
.replace(/\/index(?!\.)/, 'index.html') .replace(/\.md\b/, '.html') // *.md -> *.html
.replace(/\?id=/, '#') .replace(/\?id=/, '#') // ?id= -> #
.replace(/\\/g, '/') .replace(/\\/g, '/') // \ -> /
return oldNormalizeLink.bind(this)(url) return oldNormalizeLink.bind(this)(url)
} }
})(md.normalizeLink) })(md.normalizeLink)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册