-
Notifications
You must be signed in to change notification settings - Fork 26
/
genpres.js
68 lines (58 loc) · 1.5 KB
/
genpres.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
57
58
59
60
61
62
63
64
65
66
67
68
var ometajs = require('ometa-js');
var fs = require('fs');
var Mustache = require('mustache');
var template = fs.readFileSync('templates/presentation.template').toString();
var MD = require('./markdown2.ometajs').Markdown;
var pages = [];
var currentPage = {
buf:"",
notes:"",
content:[],
};
pages.push(currentPage);
var inNote = false;
MD.append = function(text) {
if(text) {
if(inNote) {
//console.log('appending inside note',text);
currentPage.notes += text;
} else {
currentPage.buf += text;
}
}
}
MD.horizontalRule = function() {
this.append('\n');
this.closeAll();
inNote = false;
// console.log('==============\nopening note = ', currentPage.notes);
currentPage = { buf:'', notes:'', content:[] };
pages.push(currentPage);
}
/*
var old_closeAll = MD.closeAll;
MD.closeAll = function() {
old_closeAll.call(MD);
inNote = false;
}
*/
/*
MD.openNoteParagraph = function() {
console.log("opening note");
// inNote = true;
this.openBlock('p');
}
*/
if(!fs.existsSync('build')) fs.mkdirSync('build');
var input = fs.readFileSync('presentations/ble.md').toString();
MD.reset();
var out = MD.matchAll(input,'start');
//console.log("output = ",out);
//console.log("pages = ",pages);
//console.log("=======");
pages.forEach(function(page) {
// console.log('<section>');
console.log(page.notes);
// console.log('</section>\n\n');
});
fs.writeFileSync('build/pres.html',Mustache.render(template,pages));;