forked from htmlhint/HTMLHint
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmarkdown.js
36 lines (36 loc) · 1.32 KB
/
markdown.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
var markdownFormatter = function(formatter, HTMLHint){
formatter.on('end', function(event){
console.log('# TOC');
var arrToc = [];
var arrContents = [];
var arrAllMessages = event.arrAllMessages;
arrAllMessages.forEach(function(fileInfo){
var filePath = fileInfo.file;
var arrMessages = fileInfo.messages;
var errorCount = 0;
var warningCount = 0;
arrMessages.forEach(function(message){
if(message.type === 'error'){
errorCount ++;
}
else{
warningCount ++;
}
});
arrToc.push(' - ['+filePath+'](#'+filePath+')');
arrContents.push('<a name="'+filePath+'" />');
arrContents.push('# '+filePath);
arrContents.push('');
arrContents.push('Found '+errorCount+' errors, '+warningCount+' warnings');
var arrLogs = HTMLHint.format(arrMessages);
arrContents.push('');
arrLogs.forEach(function(log){
arrContents.push(' '+log);
});
arrContents.push('');
});
console.log(arrToc.join('\r\n')+'\r\n');
console.log(arrContents.join('\r\n'));
});
};
module.exports = markdownFormatter;