-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathGruntfile.js
56 lines (48 loc) · 1.02 KB
/
Gruntfile.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
var marked = require('marked');
var Handlebars = require('handlebars');
module.exports = function (grunt) {
grunt.initConfig({
mark: {
all: {
files: [{
src: 'README.md',
dest: 'README.html'
}],
template: 'template.html',
options: {
gfm: true
}
}
},
watch: {
compass: {
files: ['*.md'],
tasks: ['mark'],
options: {}
}
}
});
grunt.registerMultiTask('mark', 'Process markdown', function () {
var data = this.data;
marked.setOptions(data.options);
var template = null;
if (data.template) {
template = Handlebars.compile([
'<!-- THIS IS A GENERATED FILE - DO NOT EDIT -->',
grunt.file.read(data.template)
].join('\n'));
}
data.files.forEach(function(file) {
var content = marked(grunt.file.read(file.src[0]))
if (template) {
content = template({ markdown: content });
}
grunt.file.write(
file.dest,
content
);
});
});
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.registerTask('default', ['mark', 'watch']);
};