提交 8fb4ff84 编写于 作者: W wizardforcel

2020-04-04 11:44:58

上级 ac828c39
此差异已折叠。
因为 它太大了无法显示 source diff 。你可以改为 查看blob
此差异已折叠。
因为 它太大了无法显示 source diff 。你可以改为 查看blob
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
var fs = require('fs')
var RE_LI = new RegExp(
"^##\\x20+(.+?)\\s+" +
"\\+ \\[Gitee 下载\\]\\((.+?)\\)\\s+" +
"\\+ \\[Github 下载\\]\\((.+?)\\)\\s+" +
"\\+ \\[SourceForge 下载\\]\\((.+?)\\)",
"mg"
)
var RE_TR = /^\| (.+?) \(.+?\) \| (.+?) \|$/mg
function parseContent(idcs, md) {
var m
while(m = RE_LI.exec(md)) {
var title = m[1],
gitee = m[2],
github = m[3],
sourceforge = m[4]
idcs[title] = idcs[title] || {}
idcs[title].gitee = gitee
idcs[title].github = github
idcs[title].sourceforge = sourceforge
}
while(m = RE_TR.exec(md)) {
var title = m[1],
link = m[2]
var prefix = link.split('://')[0]
idcs[title] = idcs[title] || {}
idcs[title][prefix] = link
}
}
function main() {
var fname = process.argv[2]
if(!fname.endsWith('.md')) {
console.log('请提供 MD 文件')
}
var res = {}
var md = fs.readFileSync(fname)
parseContent(res, md)
fs.writeFileSync(
fname + '.json',
JSON.stringify(res)
)
}
if(require.main === module) main()
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册