-
Notifications
You must be signed in to change notification settings - Fork 0
/
findLink.js
45 lines (31 loc) · 1.02 KB
/
findLink.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
var fs = require('fs')
var marked = require('marked')
var linkValidator = require('./request')
var EventEmitter = require('events');
EventEmitter.defaultMaxListeners = 25;
class MyEmitter extends EventEmitter {}
var myEmitter = new MyEmitter();
myEmitter.on('findLink', findLink);
//myEmitter.emit('findLink');
function findLink(filename) {
var renderer = new marked.Renderer();
// Override function
renderer.link = function (href, title, text) {
//console.log('got a link')
//console.log(filename, href, title, text)
if (href.lastIndexOf('http', 0) === 0) {
//console.log('link is ' + href)
linkValidator.emit('validateLink', href, filename)
}
//debugger
};
fs.readFile(filename, "utf8", function (err, data) {
if (err) throw err;
//console.log('filename is ========= == ' + filename);
jsonData = marked(data, { renderer: renderer } )
//console.log(typesInmd)
//var unique = typesInmd.filter(typesInmd);
//console.log(unique)
});
}
module.exports = myEmitter