-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
27 lines (21 loc) · 636 Bytes
/
index.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
var marked = require('marked');
var extend = require('extend');
var cheerio = require('cheerio');
var highlight = require('highlight.js');
var fs = require('fs');
var template = fs.readFileSync( __dirname + "/template.tpl","utf-8");
// 缓存模板
var $ = cheerio.load(template);
var $template = $;
module.exports = function (content, file, settings) {
marked.setOptions({
highlight: function (code) {
return highlight.highlightAuto(code).value;
}
});
content = marked(content);
$('#mdTitle').html(file.basename);
$('#mdHead > span').html(file.basename);
$('#mdBody').html(content);
return $.html();
}