提交 e8cf7da7 编写于 作者: D DCloud_LXH

fix: markdown normalizeLink

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