-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
53 lines (42 loc) · 1.36 KB
/
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
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
var MarkedBrunchStatic, _, marked;
marked = require('marked');
_ = {
merge: require('lodash.merge')
};
MarkedBrunchStatic = (function() {
class MarkedBrunchStatic {
constructor(config1) {
var ref, ref1;
this.config = config1;
if ((ref = this.config) != null ? ref.fileMatch : void 0) {
this.handles = this.config.fileMatch;
delete this.config.fileMatch;
}
if ((ref1 = this.config) != null ? ref1.fileTransform : void 0) {
this.transformPath = this.config.fileTransform;
delete this.config.fileTransform;
}
}
transformPath(filename) {
return filename.replace(/\.static\.\w+$/, '.html');
}
compile(data, filename, options, callback) {
var opts;
opts = _.merge({}, this.config, options != null ? options.markdown : void 0);
return marked(data, opts, function(err, content) {
if (err) {
callback(err);
return;
}
// we need to fix some html-escaping that breaks handlebars
content = content.replace(/\{\{>/g, '{{>');
return callback(null, content);
});
}
};
MarkedBrunchStatic.prototype.handles = /\.static\.(?:markdown|mdown|mkdn|md|mkd|mdwn|mdtxt|mdtext|text)$/;
return MarkedBrunchStatic;
}).call(this);
module.exports = function(config) {
return new MarkedBrunchStatic(config);
};