-
Notifications
You must be signed in to change notification settings - Fork 65
/
fis-conf.js
69 lines (63 loc) · 1.84 KB
/
fis-conf.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
var path = require('path')
var fs = require('fs')
function tsdocHTML(content) {
return tsdoc(content)
}
function tsdoc (content) {
let md = content.trim().replace(/\;\`([\s\S]*?)^\`/gm, function(source, $1){
return '```\r\n' + $1.replace(/\\\`/g,'`') + '```ts'
})
md = md.trim().replace(/^\`\`\`/,'')
md +="\r\n```"
md = md.trim()
md = md.replace(/"\.\.\/lib\"/g,"\"percent-demo\"")
/*
支持语法:
// @tsrun:hidden begin
test('part 0 total 10 return 0', () = {
expect(percent(0,10)).toBe(0)>
})
// @tsrun:hidden end
*/
md = md.replace(/\/\/ \@tsrun:hidden begin[\s\S]*\/\/ \@tsrun:hidden end/g, '')
md = md.replace(new RegExp("// \@ts-ignore.*", "g"), "")
md = md.replace(/\`\`\`ts([\s\S]*)\`\`\`/gm, function (source, $1) {
return '```ts\r\n' + $1.trim() + '\r\n```'
})
md = md.replace(/```ts;/, "```ts")
md = md.replace(/\^\^\^/g, "```")
md = md.replace(/\^/g, "`")
md = md.trim()
return md
}
fis.match("**", {
release: false,
},1)
fis.match("(**).source.md", {
parser: [
function (content, file) {
return content.replace(/\[(.*?)\|embed\]\((.*)\)/g, function (source, name, ref) {
const extname = path.extname(ref).replace(".", "")
const code = fs.readFileSync(path.join(__dirname,file.subdirname, ref)).toString()
return `[${name}](${ref})` +
'\r\n' +
'```' + extname +
'\r\n' +
code +
'\r\n' +
'```'
})
}
],
release: "/$1.md",
}, 999)
fis.match('(**).doc.ts', {
parser: [
function (content, file) {
return tsdoc(content)
}
],
release: "/$1.md",
isHtmlLike: true,
rExt: "md",
}, 999)