-
Notifications
You must be signed in to change notification settings - Fork 96
/
nico.js
65 lines (62 loc) · 1.7 KB
/
nico.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
exports = module.exports = {
"source": "content",
"output": "_site",
"theme": "theme",
"permalink": "{{directory}}/{{filename}}",
"navigation":[
{
"link":"/",
"title":"首页"
},
{
"link":"/wiki",
"title":"异常列表"
}
],
"google": {
"id": "UA-39646187-1",
"domain": "errors.totorojs.org"
},
"github": "https://github.com/saijs/wiki",
"writers": [
"nico.PageWriter",
"nico.PostWriter",
"nico.FileWriter",
"nico.StaticWriter"
]
}
var INTERNAL_KEY_WORD = {
"案例": "case",
"相关异常": "related",
"延伸阅读": "see-also",
"参考": "see-also"
};
var INTERNAL_REGEXP = [], _k;
for(var k in INTERNAL_KEY_WORD){
_k = encodeURIComponent(k);
//INTERNAL_REGEXP.push({
//regexp: new RegExp('href="#'+k+'"', "g"),
//value: 'href='+INTERNAL_KEY_WORD[k]+'"'
//});
INTERNAL_REGEXP.push({
regexp: new RegExp('id="'+_k+'"', "g"),
value: 'id="'+INTERNAL_KEY_WORD[k]+'"'
});
}
exports.filters = {
fixlink: function(html) {
// format permalink, ends without .html
html = html.replace(/(href="[^"]+)\.md(">)/ig, "$1$2");
// set columns width.
html = html.replace(/<th>Language<\/th>/g, '<th width="100">Language</th>');
html = html.replace(/<th>Browser<\/th>/g, '<th width="100">Browser</th>');
html = html.replace(/<th>Number<\/th>/g, '<th width="100">Number</th>');
html = html.replace(/<th>异常字段<\/th>/g, '<th width="100">异常字段</th>');
// fix internal relative link.
for(var i=0,l=INTERNAL_REGEXP.length; i<l; i++){
html = html.replace(INTERNAL_REGEXP[i].regexp, INTERNAL_REGEXP[i].value);
}
// TODO: 自动附加相关异常。
return html;
}
}