forked from zestdocs/zest
-
Notifications
You must be signed in to change notification settings - Fork 0
/
unfluff
37 lines (34 loc) · 1.11 KB
/
unfluff
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
var p5 = require('parse5')
function uf(nm) {
var body='', headers = '', d = new p5.SAXParser(), inHeader = false;
d.on('text', function(text) {
if (inHeader) {
headers += ' ' + text;
} else {
body += ' ' + text;
}
});
/* d.on('startTag', function(name) {
console.log(name);
if (name == 'dt') inHeader = true;
})
d.on('endTag', function(name) {
if (name == 'dt') inHeader = false;
}) */
d.write(require('fs').readFileSync('app/'+nm, 'utf8'));
return body; /* {
body: body,
headers: headers
} */
}
const nodelucene = require('./build/Release/nodelucene');
var items =
require('fs').readdirSync('app/python/library').map(function(s) { return 'python/library/'+s; }).concat(
require('fs').readdirSync('app/clojure').filter(function(s) { return s.indexOf('.html') != -1}).map(function(s) { return 'clojure/'+s; }));
index = new nodelucene.LuceneIndex();
index.startWriting();
for (var i = 0; i < items.length; ++i) {
index.addFile(items[i], uf(items[i]));
console.log(i);
}
index.endWriting()